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

using Newtonsoft.Json;

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


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

        INetworkJSON m_cNetworkJson;

        string m_sDmbHeader = "";
        Hashtable m_htDmbBody = new Hashtable();

        //#16569 파스쿠찌 드라이브 스루 기능 개발 요청 start
        private TcpSocket m_cDtSocket = null;
        //#16569 파스쿠찌 드라이브 스루 기능 개발 요청 end

        public DmbIF()
        {
            m_cPosStatus = (PosStatus)StateObject.POS;      // POS 기본정보

            m_cNetworkJson = (INetworkJSON)sManager.InitServiceInstance(ServiceLists.AGENT_NETWORK.DLL, ServiceLists.AGENT_NETWORK.NETWORK_JSON);
        }

        /// <summary>
        /// IRT 전송
        /// </summary>
        /// <param name="aParam"></param>
        /// <returns></returns>
        public string Execute(string[] aParam)
        {
            string sRet = UserCom.RST_ERR;

            string sReqHeader = "";
            string sReqBody = "";
            string sReceivedData = "";

            try
            {
                //#16569 파스쿠찌 드라이브 스루 기능 개발 요청 start
                //기존
                #region 주석
                /*
                string[] aDmbHeader = new string[Column.DMB_REQ_HEADER.LEN.Length];
                Hashtable htDmbBody = new Hashtable();

                aDmbHeader[Column.DMB_REQ_HEADER.SEQ.Version] = "1.0.0";
                aDmbHeader[Column.DMB_REQ_HEADER.SEQ.Command] = aParam[0];
                aDmbHeader[Column.DMB_REQ_HEADER.SEQ.ContentsType] = "application/json";
                
                if(aParam[0] == ItemConst.DMB_IRT_ID.PRODUCT_REG)
                {
                    htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.CmpCd, m_cPosStatus.Base.CmpCd);
                    htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.BrandCd, m_cPosStatus.Base.BrandCd);
                    htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.StorCd, m_cPosStatus.Base.StoreNo);
                    htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.PosNo, m_cPosStatus.Base.PosNo);
                    htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.SaleDt, m_cPosStatus.Base.SaleDate);
                    htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.BillNo, m_cPosStatus.Base.TradeNo);
                    htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.ItemCd, aParam[1]);                   // ITEM_CD
                    htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.ItemNm, aParam[2]);                   // ITEM_NM
                    htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.Div, aParam[3]);                      // 1:등록, 2:수량변경, 3:지정취소

                    sReqBody = JsonConvert.SerializeObject(htDmbBody);
                    Byte[] sBytTempBuff = Encoding.UTF8.GetBytes(sReqBody);

                    // 헤더의 Body size 기록
                    aDmbHeader[Column.DMB_REQ_HEADER.SEQ.BodySize] = sBytTempBuff.Length.ToString();
                }
                else if(aParam[0] == ItemConst.DMB_IRT_ID.POINT_INFO)
                {
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.CmpCd, m_cPosStatus.Base.CmpCd);
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.BrandCd, m_cPosStatus.Base.BrandCd);
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.StorCd, m_cPosStatus.Base.StoreNo);
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.PosNo, m_cPosStatus.Base.PosNo);
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.SaleDt, m_cPosStatus.Base.SaleDate);
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.BillNo, m_cPosStatus.Base.TradeNo);
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.PointDiv, aParam[1]);                  // HPC:해피포인트, SKT:T멤버쉽
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.AppDiv, aParam[2]);                    // Y:HPC APP, 그외 N
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.DIV, aParam[3]);                       // 1:조회, 2:적립, 3:할인 ...
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.Amount, aParam[4]);                    // 포인트 사용 금액
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.Point, aParam[5]);                     // 적립, 할인, 사용 포인트
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.RPoint, aParam[6]);                    // 잔여포인트
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.TPoint, aParam[7]);                    // 
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.CardNo, aParam[8]);                    // 마스킹 된 카드번호
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.CustName, aParam[9]);                  // 고객명(HPC)
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.CampaignInfo, aParam[10]);             // 
                    htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.SaleTm, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));

                    sReqBody = JsonConvert.SerializeObject(htDmbBody);
                    Byte[] sBytTempBuff = Encoding.UTF8.GetBytes(sReqBody);

                    // 헤더의 Body size 기록
                    aDmbHeader[Column.DMB_REQ_HEADER.SEQ.BodySize] = sBytTempBuff.Length.ToString();
                }
                else if(aParam[0] == ItemConst.DMB_IRT_ID.SALE_BEGIN)
                {
                    htDmbBody.Add(Column.DMB_REQ_SALE_BEGIN.DATA.CmpCd, m_cPosStatus.Base.CmpCd);
                    htDmbBody.Add(Column.DMB_REQ_SALE_BEGIN.DATA.BrandCd, m_cPosStatus.Base.BrandCd);
                    htDmbBody.Add(Column.DMB_REQ_SALE_BEGIN.DATA.StorCd, m_cPosStatus.Base.StoreNo);
                    htDmbBody.Add(Column.DMB_REQ_SALE_BEGIN.DATA.PosNo, m_cPosStatus.Base.PosNo);
                    htDmbBody.Add(Column.DMB_REQ_SALE_BEGIN.DATA.SaleDt, m_cPosStatus.Base.SaleDate);
                    htDmbBody.Add(Column.DMB_REQ_SALE_BEGIN.DATA.BillNo, m_cPosStatus.Base.TradeNo);
                    htDmbBody.Add(Column.DMB_REQ_SALE_BEGIN.DATA.SaleTm, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                }
                else if(aParam[0] == ItemConst.DMB_IRT_ID.SALE_END)
                {
                    htDmbBody.Add(Column.DMB_REQ_SALE_END.DATA.CmpCd, m_cPosStatus.Base.CmpCd);
                    htDmbBody.Add(Column.DMB_REQ_SALE_END.DATA.BrandCd, m_cPosStatus.Base.BrandCd);
                    htDmbBody.Add(Column.DMB_REQ_SALE_END.DATA.StorCd, m_cPosStatus.Base.StoreNo);
                    htDmbBody.Add(Column.DMB_REQ_SALE_END.DATA.PosNo, m_cPosStatus.Base.PosNo);
                    htDmbBody.Add(Column.DMB_REQ_SALE_END.DATA.SaleDt, m_cPosStatus.Base.SaleDate);
                    htDmbBody.Add(Column.DMB_REQ_SALE_END.DATA.BillNo, m_cPosStatus.Base.TradeNo);
                    htDmbBody.Add(Column.DMB_REQ_SALE_END.DATA.SaleTm, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                }

                // 요청 헤더 생성
                sReqHeader = ItemColumn.MakeMessage(aDmbHeader, Column.DMB_REQ_HEADER.LEN, Column.DMB_REQ_HEADER.TYPE);
                                
                //System.Threading.Thread worker = new System.Threading.Thread(new System.Threading.ThreadStart(IrtProc));
                //worker.Start();
                IrtProc(sReqHeader, htDmbBody);
                */
                #endregion 주석
                //변경

                Hashtable htDmbBody = new Hashtable();

                if (PosMstManager.GetPosOption(POS_OPTION.OPT554) == "1")
                {
                    string[] aDmbHeader = new string[Column.DT_REQ_HEADER.LEN.Length];

                    //전문 HEADER
                    aDmbHeader[Column.DT_REQ_HEADER.SEQ.Version] = "1.0.0";
                    aDmbHeader[Column.DT_REQ_HEADER.SEQ.Command] = aParam[0];
                    aDmbHeader[Column.DT_REQ_HEADER.SEQ.ContentsType] = "application/json";

                    //전문 BODY
                    if (aParam[0] == ItemConst.DT_IRT_ID.SALE_BEGIN)
                    {
                        htDmbBody.Add(Column.DT_REQ_SALE_BEGIN.DATA.CmpCd, m_cPosStatus.Base.CmpCd);
                        htDmbBody.Add(Column.DT_REQ_SALE_BEGIN.DATA.BrandCd, m_cPosStatus.Base.BrandCd);
                        htDmbBody.Add(Column.DT_REQ_SALE_BEGIN.DATA.StorCd, m_cPosStatus.Base.StoreNo);
                        htDmbBody.Add(Column.DT_REQ_SALE_BEGIN.DATA.PosNo, m_cPosStatus.Base.PosNo);
                        htDmbBody.Add(Column.DT_REQ_SALE_BEGIN.DATA.SaleDt, m_cPosStatus.Base.SaleDate);
                        htDmbBody.Add(Column.DT_REQ_SALE_BEGIN.DATA.SaleTm, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));

                    }
                    else if (aParam[0] == ItemConst.DT_IRT_ID.PRODUCT_REG)
                    {
                        int iSeq = 1;

                        ArrayList al_SaleDT = null;
                        al_SaleDT = new ArrayList();
                        al_SaleDT.Clear();

                        ArrayList alSaleItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM);

                        foreach (Column.TR_PLU.DATA cPluItem in alSaleItem)
                        {
                            Hashtable tr_SaleDT = new Hashtable();

                            //취소면 제외
                            if (cPluItem.CANCEL_DIV == "1" || cPluItem.CANCEL_DIV_MAIN == "1") cPluItem.CANCEL_DIV = "1";

                            if (cPluItem.CANCEL_DIV == "1")
                            {
                                continue;
                            }

                            tr_SaleDT.Add(Column.DT_REQ_PRODUCT_REG.DATA.CmpCd, m_cPosStatus.Base.CmpCd);
                            tr_SaleDT.Add(Column.DT_REQ_PRODUCT_REG.DATA.BrandCd, m_cPosStatus.Base.BrandCd);
                            tr_SaleDT.Add(Column.DT_REQ_PRODUCT_REG.DATA.StorCd, m_cPosStatus.Base.StoreNo);
                            tr_SaleDT.Add(Column.DT_REQ_PRODUCT_REG.DATA.PosNo, m_cPosStatus.Base.PosNo);
                            tr_SaleDT.Add(Column.DT_REQ_PRODUCT_REG.DATA.SaleDt, m_cPosStatus.Base.SaleDate);

                            //부가메뉴 구분
                            if (cPluItem.ITEM_DIV == ItemConst.PLU_ITEM_DIV.NORMAL)
                            {
                                tr_SaleDT.Add(Column.DT_REQ_PRODUCT_REG.DATA.Seq, iSeq.ToString());
                                tr_SaleDT.Add(Column.DT_REQ_PRODUCT_REG.DATA.ItemDiv, "1");
                            }
                            else
                            {
                                iSeq--;
                                tr_SaleDT.Add(Column.DT_REQ_PRODUCT_REG.DATA.Seq, iSeq.ToString());
                                tr_SaleDT.Add(Column.DT_REQ_PRODUCT_REG.DATA.ItemDiv, "2");
                            }

                            tr_SaleDT.Add(Column.DT_REQ_PRODUCT_REG.DATA.ItemCd, cPluItem.ITEM_PLU_CD);
                            tr_SaleDT.Add(Column.DT_REQ_PRODUCT_REG.DATA.ItemNm, cPluItem.ITEM_NAME);
                            tr_SaleDT.Add(Column.DT_REQ_PRODUCT_REG.DATA.ItemQty, cPluItem.SALE_QTY);
                            tr_SaleDT.Add(Column.DT_REQ_PRODUCT_REG.DATA.ItemAmt, cPluItem.SALE_AMT);

                            al_SaleDT.Add(tr_SaleDT);

                            tr_SaleDT = null;

                            iSeq++;
                        }

                        htDmbBody.Add(Column.DT_REQ_PRODUCT_REG.ITEM, al_SaleDT);
                    }
                    else if (aParam[0] == ItemConst.DT_IRT_ID.PRODUCT_CANC)
                    {
                        htDmbBody.Add(Column.DT_REQ_PRODUCT_REG.DATA.CmpCd, m_cPosStatus.Base.CmpCd);
                        htDmbBody.Add(Column.DT_REQ_PRODUCT_REG.DATA.BrandCd, m_cPosStatus.Base.BrandCd);
                        htDmbBody.Add(Column.DT_REQ_PRODUCT_REG.DATA.StorCd, m_cPosStatus.Base.StoreNo);
                        htDmbBody.Add(Column.DT_REQ_PRODUCT_REG.DATA.PosNo, m_cPosStatus.Base.PosNo);
                        htDmbBody.Add(Column.DT_REQ_PRODUCT_REG.DATA.SaleDt, m_cPosStatus.Base.SaleDate);
                    }

                    else if (aParam[0] == ItemConst.DT_IRT_ID.SALE_END)
                    {
                        htDmbBody.Add(Column.DT_REQ_SALE_END.DATA.CmpCd, m_cPosStatus.Base.CmpCd);
                        htDmbBody.Add(Column.DT_REQ_SALE_END.DATA.BrandCd, m_cPosStatus.Base.BrandCd);
                        htDmbBody.Add(Column.DT_REQ_SALE_END.DATA.StorCd, m_cPosStatus.Base.StoreNo);
                        htDmbBody.Add(Column.DT_REQ_SALE_END.DATA.PosNo, m_cPosStatus.Base.PosNo);
                        htDmbBody.Add(Column.DT_REQ_SALE_END.DATA.SaleDt, m_cPosStatus.Base.SaleDate);
                        htDmbBody.Add(Column.DT_REQ_SALE_END.DATA.SaleTm, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                    }

                    // 헤더의 Body size 기록
                    sReqBody = JsonConvert.SerializeObject(htDmbBody);
                    Byte[] sBytTempBuff = Encoding.UTF8.GetBytes(sReqBody);
                    aDmbHeader[Column.DT_REQ_HEADER.SEQ.BodySize] = sBytTempBuff.Length.ToString();

                    // 요청 헤더 생성
                    sReqHeader = ItemColumn.MakeMessage(aDmbHeader, Column.DT_REQ_HEADER.LEN, Column.DT_REQ_HEADER.TYPE);

                    //전문 처리
                    bool bSendRecvYN = false;

                    while (bSendRecvYN == false)
                    {
                        bSendRecvYN = IrtProc_DtIf(sReqHeader, htDmbBody);

                        //전송 실패시 재전송 여부
                        if (bSendRecvYN == false)
                        {
                            bSendRecvYN = !(bool)WinManager.QuestionMessage("IF 실패 재전송 하시겠습니까?[" + aParam[0] + "]");    //MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0591)
                        }
                    }

                }
                else
                {
                    string[] aDmbHeader = new string[Column.DMB_REQ_HEADER.LEN.Length];

                    aDmbHeader[Column.DMB_REQ_HEADER.SEQ.Version] = "1.0.0";
                    aDmbHeader[Column.DMB_REQ_HEADER.SEQ.Command] = aParam[0];
                    aDmbHeader[Column.DMB_REQ_HEADER.SEQ.ContentsType] = "application/json";

                    if (aParam[0] == ItemConst.DMB_IRT_ID.PRODUCT_REG)
                    {
                        htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.CmpCd, m_cPosStatus.Base.CmpCd);
                        htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.BrandCd, m_cPosStatus.Base.BrandCd);
                        htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.StorCd, m_cPosStatus.Base.StoreNo);
                        htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.PosNo, m_cPosStatus.Base.PosNo);
                        htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.SaleDt, m_cPosStatus.Base.SaleDate);
                        htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.BillNo, m_cPosStatus.Base.TradeNo);
                        htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.ItemCd, aParam[1]);                   // ITEM_CD
                        htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.ItemNm, aParam[2]);                   // ITEM_NM
                        htDmbBody.Add(Column.DMB_REQ_PRODUCT_REG.DATA.Div, aParam[3]);                      // 1:등록, 2:수량변경, 3:지정취소

                        sReqBody = JsonConvert.SerializeObject(htDmbBody);
                        Byte[] sBytTempBuff = Encoding.UTF8.GetBytes(sReqBody);

                        // 헤더의 Body size 기록
                        aDmbHeader[Column.DMB_REQ_HEADER.SEQ.BodySize] = sBytTempBuff.Length.ToString();
                    }
                    else if (aParam[0] == ItemConst.DMB_IRT_ID.POINT_INFO)
                    {
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.CmpCd, m_cPosStatus.Base.CmpCd);
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.BrandCd, m_cPosStatus.Base.BrandCd);
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.StorCd, m_cPosStatus.Base.StoreNo);
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.PosNo, m_cPosStatus.Base.PosNo);
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.SaleDt, m_cPosStatus.Base.SaleDate);
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.BillNo, m_cPosStatus.Base.TradeNo);
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.PointDiv, aParam[1]);                  // HPC:해피포인트, SKT:T멤버쉽
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.AppDiv, aParam[2]);                    // Y:HPC APP, 그외 N
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.DIV, aParam[3]);                       // 1:조회, 2:적립, 3:할인 ...
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.Amount, aParam[4]);                    // 포인트 사용 금액
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.Point, aParam[5]);                     // 적립, 할인, 사용 포인트
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.RPoint, aParam[6]);                    // 잔여포인트
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.TPoint, aParam[7]);                    // 
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.CardNo, aParam[8]);                    // 마스킹 된 카드번호
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.CustName, aParam[9]);                  // 고객명(HPC)
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.CampaignInfo, aParam[10]);             // 
                        htDmbBody.Add(Column.DMB_REQ_POINT_INFO.DATA.SaleTm, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));

                        sReqBody = JsonConvert.SerializeObject(htDmbBody);
                        Byte[] sBytTempBuff = Encoding.UTF8.GetBytes(sReqBody);

                        // 헤더의 Body size 기록
                        aDmbHeader[Column.DMB_REQ_HEADER.SEQ.BodySize] = sBytTempBuff.Length.ToString();
                    }
                    else if (aParam[0] == ItemConst.DMB_IRT_ID.SALE_BEGIN)
                    {
                        htDmbBody.Add(Column.DMB_REQ_SALE_BEGIN.DATA.CmpCd, m_cPosStatus.Base.CmpCd);
                        htDmbBody.Add(Column.DMB_REQ_SALE_BEGIN.DATA.BrandCd, m_cPosStatus.Base.BrandCd);
                        htDmbBody.Add(Column.DMB_REQ_SALE_BEGIN.DATA.StorCd, m_cPosStatus.Base.StoreNo);
                        htDmbBody.Add(Column.DMB_REQ_SALE_BEGIN.DATA.PosNo, m_cPosStatus.Base.PosNo);
                        htDmbBody.Add(Column.DMB_REQ_SALE_BEGIN.DATA.SaleDt, m_cPosStatus.Base.SaleDate);
                        htDmbBody.Add(Column.DMB_REQ_SALE_BEGIN.DATA.BillNo, m_cPosStatus.Base.TradeNo);
                        htDmbBody.Add(Column.DMB_REQ_SALE_BEGIN.DATA.SaleTm, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                    }
                    else if (aParam[0] == ItemConst.DMB_IRT_ID.SALE_END)
                    {
                        htDmbBody.Add(Column.DMB_REQ_SALE_END.DATA.CmpCd, m_cPosStatus.Base.CmpCd);
                        htDmbBody.Add(Column.DMB_REQ_SALE_END.DATA.BrandCd, m_cPosStatus.Base.BrandCd);
                        htDmbBody.Add(Column.DMB_REQ_SALE_END.DATA.StorCd, m_cPosStatus.Base.StoreNo);
                        htDmbBody.Add(Column.DMB_REQ_SALE_END.DATA.PosNo, m_cPosStatus.Base.PosNo);
                        htDmbBody.Add(Column.DMB_REQ_SALE_END.DATA.SaleDt, m_cPosStatus.Base.SaleDate);
                        htDmbBody.Add(Column.DMB_REQ_SALE_END.DATA.BillNo, m_cPosStatus.Base.TradeNo);
                        htDmbBody.Add(Column.DMB_REQ_SALE_END.DATA.SaleTm, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"));
                    }

                    // 요청 헤더 생성
                    sReqHeader = ItemColumn.MakeMessage(aDmbHeader, Column.DMB_REQ_HEADER.LEN, Column.DMB_REQ_HEADER.TYPE);

                    IrtProc(sReqHeader, htDmbBody);
                }
                //#16569 파스쿠찌 드라이브 스루 기능 개발 요청 end
            }
            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;
        }

        private void IrtProc(string sHeader, Hashtable htBody)
        {
            string sReceivedData = "";

            try
            {
                m_cNetworkJson.DmbIRTSendReceive(m_cPosStatus.Base.DmbSvrIp, (int)m_cPosStatus.Base.DmbIfPort, 3000, sHeader, htBody, ref sReceivedData);

                // 응답 전문 파싱
                if (sReceivedData != null && sReceivedData.Length > 0)
                {
                    string[] aRspHeader = new string[Column.DMB_RSP_HEADER.LEN.Length];
                    ItemColumn.ParseMessage(Column.DMB_RSP_HEADER.LEN, Column.DMB_RSP_HEADER.TYPE, sReceivedData, 0, ref aRspHeader);

                    // 정상 처리
                    if (aRspHeader[Column.DMB_RSP_HEADER.SEQ.ResCode] == "200")
                    {
                        
                    }
                }
            }
            catch(Exception ex)
            {

            }
        }

        //#16569 파스쿠찌 드라이브 스루 기능 개발 요청 start
        private bool IrtProc_DtIf(string sHeader, Hashtable htBody)
        {
            bool bRet = false;
            string sReceivedData = "";
            byte[] bytRecvBuff = new byte[1024];

            try
            {
                m_cNetworkJson.DmbIRTSendReceive(m_cPosStatus.Base.DmbSvrIp, (int)m_cPosStatus.Base.DmbIfPort, 3000, sHeader, htBody, ref sReceivedData);

                // 응답 전문 파싱
                if (sReceivedData != null && sReceivedData.Length > 0)
                {
                    string[] aRspHeader = new string[Column.DT_RSP_HEADER.LEN.Length];
                    ItemColumn.ParseMessage(Column.DT_RSP_HEADER.LEN, Column.DT_RSP_HEADER.TYPE, sReceivedData, 0, ref aRspHeader);

                    // 정상 처리
                    if (aRspHeader[Column.DT_RSP_HEADER.SEQ.ResCode].Trim() == "200")
                    {
                        bRet = true;
                    }
                }
            }
            catch (Exception ex)
            {

            }

            return bRet;
        }

        public int OpenDtTcpDevice(string sIp, int iPort, int iTimeout)
        {
            int iRet = UserCom.NG;
            try
            {
                // PING 테스트 확인
                if (CmUtil.PingTest(sIp) == false)
                {
                    if (CmUtil.PingTest(sIp) == false)
                    {
                        UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                             System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                             System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                             "OpenDtTcpDevice PingTest Fail");
                        return iRet;
                    }

                }

                m_cDtSocket = new TcpSocket(sIp, iPort, iTimeout);

                if (m_cDtSocket == null)
                {
                    UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                        System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                        System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                        "OpenDtTcpDevice TcpSocket null");
                    return -9;
                }

                try
                {
                    iRet = m_cDtSocket.Connect(-1);
                }
                catch (Exception ex)
                {
                    iRet = UserCom.NG;
                    UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                         System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                         System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                         "OpenDtTcpDevice Exception Error=" + ex.Message);
                    m_cDtSocket.Close();
                }
                // 접속 실패
                if (iRet != UserCom.OK)
                {
                    iRet = UserCom.NG;
                    UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                         System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                         System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                         "OpenDtTcpDevice(Ethernet) Connect Error");
                    m_cDtSocket.Close();
                }

                return iRet;
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_SOCK,
                                     System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                     ex.Message);
                return -99;
            }
        }

        public void ClosePrtTcpDevice()
        {
            try
            {
                if (m_cDtSocket != null)
                {
                    m_cDtSocket.Close();
                    m_cDtSocket = null;
                }
            }
            catch (Exception ex)
            {
                UserLog.WriteLogFile(UserCom.LOG_SOCK,
                                     System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,      // Project Name (프로젝트명)
                                     System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." +  // Class Name (Class Name (클래스명))
                                     System.Reflection.MethodBase.GetCurrentMethod().Name + "()",                // Function Name (Function Name (함수명))
                                     ex.Message);
            }
        }
        //#16569 파스쿠찌 드라이브 스루 기능 개발 요청 end

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

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