using System;
using System.Collections;
using System.Linq;
using System.Text;

using Cosmos.Common;
using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using Cosmos.CommonManager;

namespace Cosmos.Service
{
    class VenderSearch : IDataServiceUs
    {
        private SManager sManager = new SManager();                                 // 이 객체를 통해 업무 Service 호출
        private PosStatus m_cPosStatus = new PosStatus();                           // 기본정보 참조
        private StateServer StateObject = (StateServer)StateServer.GetInstance();   // StateObject : StateServer Object (객체)

        protected IDataCommonUs m_cDataCommon = null;                               // 판매공통 모듈

        public VenderSearch()
        {
            m_cPosStatus = (PosStatus)StateObject.POS;      // POS 기본정보
            m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON);
        }

        /// <summary>
        /// 행사 주문 내역 조회
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public object GetData(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;

            try
            {
                Hashtable htSendData = new Hashtable();
                Hashtable htRecvData = new Hashtable();

                //INQ_TYPE
                htSendData.Add("INQ_TYPE", ItemConst.IRT_INQ_TYPE.POS_SPPRINFO_REQ);
                // CMP_CD
                htSendData.Add("CMP_CD", m_cPosStatus.Base.CmpCd);
                // STOR_CD
                htSendData.Add("STOR_CD", m_cPosStatus.Base.StoreNo);
                // 매입처 조회 조건
                htSendData.Add("SPPR_INFO", aParam[0]);
                // 사업장 정보
                htSendData.Add("DATA", "");
                // RES_CD
                htSendData.Add("RES_CD", "");

                sRet = m_cDataCommon.ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.PayInqPort, 10000, htSendData, ref htRecvData);
                if (sRet != UserCom.RST_OK)
                {
                    WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0326));
                    sRet = UserCom.RST_ERR;
                    return sRet;
                }

                if (htRecvData["RES_CD"].ToString() != "01")
                {
                    return htRecvData["DATA"].ToString();
                }
                else
                {
                    WinManager.ErrorMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0302));
                    sRet = UserCom.RST_ERR;
                    return sRet;
                }
            }
            catch (Exception ex)
            {
                WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
                    System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message);
            }
            return sRet;
        }

        public string SetData(object oParam)
        {
            throw new NotImplementedException();
        }

        public string Execute(string[] aParam)
        {
            throw new NotImplementedException();
        }

    }
}
