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

namespace NewPosInstaller
{
        /// <summary>
    /// 전문(Tran, IRT, VAN) 정의
    /// </summary>
    public static class Column
    {
        #region 통신헤더
        /// <summary>
        /// 통신해더
        /// </summary>
        public class COMM_HEADER
        {
            public class DATA
            {
                /// <summary>
                /// 전문길이
                /// </summary>
                public string MsgLen;
                /// <summary>
                /// 전문구분
                /// </summary>
                public string MsgType;
                /// <summary>
                /// 회사코드
                /// </summary>
                public string CmpCd;
                /// <summary>
                /// 브랜드코드
                /// </summary>
                public string BrandCd;
                /// <summary>
                /// 점포코드
                /// </summary>
                public string StoreCd;
                /// <summary>
                /// POS번호
                /// </summary>
                public string PosNo;
                ///// <summary>
                ///// 등록번호
                ///// </summary>
                //public string RegNo;
                /// <summary>
                /// 거래번호
                /// </summary>
                public string TradeNo;
                /// <summary>
                /// TRAN일자
                /// </summary>
                public string TranYmd;
                /// <summary>
                /// 시스템일자
                /// </summary>
                public string SysYmd;
                /// <summary>
                /// 시스템시간
                /// </summary>
                public string SysHms;
                /// <summary>
                /// 전문암호화구분(0:평문, 1:암호화)
                /// </summary>
                public string EncType;
                /// <summary>
                /// 에러코드
                /// </summary>
                public string ErrCd;
            }

            /// <summary>
            /// 컬럼순서
            /// </summary>
            public class SEQ
            {
                public const int MsgLen = 0;
                public const int MsgType = 1;
                public const int CmpCd = 2;
                public const int BrandCd = 3;
                public const int StoreCd = 4;
                public const int TranYmd = 5;
                public const int PosNo = 6;
                //public const int RegNo = 7;
                public const int TradeNo = 7;
                public const int SysYmd = 8;
                public const int SysHms = 9;
                public const int EncType = 10;
                public const int ErrCd = 11;
            }

            /// <summary>
            /// 컬럼길이
            /// </summary>
            public static int[] LEN = { 6, 2, 4, 4, 10, 8, 2, 5, 8, 6, 1, 3 };

            /// <summary>
            /// 컬럼타입(0:문자형, 1:숫자형, 2:금액형)
            /// </summary>
            public static int[] TYPE = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
        }
        #endregion

        #region POS 마스터 요청/응답
        /// <summary>
        /// POS 마스터 요청
        /// </summary>
        public class IQ_POSMASTER_REQ
        {
            /// <summary>
            /// 컬럼명
            /// </summary>
            public class DATA
            {
                /// <summary>
                /// INQ 종별
                /// </summary>
                public const string InqType = "INQ_TYPE";
                /// <summary>
                /// 마스터 요청 구분
                /// </summary>
                public const string MasterDiv = "MASTER_DIV";
                /// <summary>
                /// 점포코드
                /// </summary>
                public const string StorCd = "STOR_CD";
                /// <summary>
                /// SUB점포코드
                /// </summary>
                public const string SubStorCd = "SUB_STOR_CD";
                /// <summary>
                /// 변경 일시
                /// </summary>
                public const string UpdDt = "UPD_DT";
                /// <summary>
                /// 전송데이터 COUNT
                /// </summary>
                public const string DataCount = "DATA_COUNT";
                /// <summary>
                /// 요청코드
                /// </summary>
                public const string ProcCd = "PROC_CD";
                /// <summary>
                /// 응답코드
                /// </summary>
                public const string ResCd = "RES_CD";
            }

            /// <summary>
            /// 컬럼순서
            /// </summary>
            public class SEQ { }
            /// <summary>
            /// 컬럼길이
            /// </summary>
            public static int[] LEN = { };
            /// <summary>
            /// 컬럼타입(0:문자형, 1:숫자형, 2:금액형)
            /// </summary>
            public static int[] TYPE = { };
        }
        /// <summary>
        /// POS 마스터 응답
        /// </summary>
        public class IQ_POSMASTER_RSP
        {
            /// <summary>
            /// 컬럼명
            /// </summary>
            public class DATA
            {
                /// <summary>
                /// 마스터 Row Count
                /// </summary>
                public const string Count = "COUNT";
                /// <summary>
                /// 마스터 Data
                /// </summary>
                public const string Data = "DATA";
            }
            /// <summary>
            /// 컬럼순서
            /// </summary>
            public class SEQ { }
            /// <summary>
            /// 컬럼길이
            /// </summary>
            public static int[] LEN = { };
            /// <summary>
            /// 컬럼타입(0:문자형, 1:숫자형, 2:금액형)
            /// </summary>
            public static int[] TYPE = { };
        }
        #endregion

        #region POS TABLE 마스터 저장요청
        public class IQ_POS_TABLE_MST_INQ
        {
            public const string MSG_ID = "55"; 

            /// <summary>
            /// 컬럼명
            /// </summary>
            public class DATA
            {
                /// <summary>
                /// INQ 종별 = 55
                /// </summary>
                public const string INQ_TYPE = "INQ_TYPE";
                /// <summary>
                /// 점포코드 
                /// </summary>
                public const string STOR_CD = "STOR_CD";
                /// <summary>
                /// 요청구분 
                /// 1:저장요청, 2:조회요청
                /// </summary>
                public const string INQ_DIV = "INQ_DIV";
                /// <summary>
                /// 테이블/층 저장 데이터 
                /// </summary>
                /// <example>
                /// #~01(층)|필드1|필드2|필드3|필드4~~~
                /// #~01(층)|필드1|필드2|필드3|필드4~~~
                /// #~02(테이블)|필드1|필드2|필드3|필드4~~~
                /// #~02(테이블)|필드1|필드2|필드3|필드4~~~
                /// </example>
                public const string DATA_LIST = "DATA";
                /// <summary>
                /// 응답코드 
                /// </summary>
                public const string RES_CD = "RES_CD";
            }

            /// <summary>
            /// 컬럼순서
            /// </summary>
            public class SEQ { }
            /// <summary>
            /// 컬럼길이
            /// </summary>
            public static int[] LEN = { };
            /// <summary>
            /// 컬럼타입(0:문자형, 1:숫자형, 2:금액형)
            /// </summary>
            public static int[] TYPE = { };
        }
        #endregion

        #region IQ_PGMUPDATE_REQ 프로그램 업데이트 목록 요청
        /// <summary>
        /// 프로그램 업데이트 목록 요청
        /// </summary>
        public class IQ_PGMUPDATE_REQ
        {
            /// <summary>
            /// 03
            /// </summary>
            public const string MSG_ID = "03"; 
            /// <summary>
            /// 컬럼명
            /// </summary>
            public class DATA
            {
                /// <summary>
                /// INQ 종별
                /// </summary>
                public const string INQ_TYPE = "INQ_TYPE";
                /// <summary>
                /// 상세종별
                /// </summary>
                public const string FILE_KIND = "FILE_KIND";
                /// <summary>
                /// 적용구분
                /// </summary>
                public const string FILE_APP_TY = "FILE_APP_TY";
                /// <summary>
                /// 적용 일시
                /// </summary>
                public const string FILE_YMDHMS = "FILE_YMDHMS";
                /// <summary>
                /// 요청구분(A:전체, U:변경분)
                /// </summary>
                public const string DOWN_DIV = "DOWN_DIV";
            }

            /// <summary>
            /// 컬럼순서
            /// </summary>
            public class SEQ { }
            /// <summary>
            /// 컬럼길이
            /// </summary>
            public static int[] LEN = { };
            /// <summary>
            /// 컬럼타입(0:문자형, 1:숫자형, 2:금액형)
            /// </summary>
            public static int[] TYPE = { };
        }
        #endregion

        #region IQ_PGMUPDATE_RSP 프로그램 업데이트 목록 응답
        /// <summary>
        /// 프로그램 업데이트 목록 응답
        /// </summary>
        public class IQ_PGMUPDATE_RSP
        {
            /// <summary>
            /// 컬럼명
            /// </summary>
            public class DATA
            {
                /// <summary>
                /// INQ 종별
                /// </summary>
                public const string INQ_TYPE = "INQ_TYPE";
                /// <summary>
                /// 서버 IP
                /// </summary>
                public const string FILE_HQ_IP = "FILE_HQ_IP";
                /// <summary>
                /// FTP IP
                /// </summary>
                public const string FTP_IP = "FTP_IP";
                /// <summary>
                /// FTP PORT
                /// </summary>
                public const string FTP_PORT = "FTP_PORT";
                /// <summary>
                /// FTP ID
                /// </summary>
                public const string FTP_ID = "FTP_ID";
                /// <summary>
                /// FTP PWD
                /// </summary>
                public const string FTP_PWD = "FTP_PWD";
                /// <summary>
                /// VALUE (배포구분, 적용구분, 적용일시, 파일경로, 파일명, 파일버전)
                /// </summary>
                public const string VALUE = "VALUE";
                /// <summary>
                /// 요청구분(A:전체, U:변경분)
                /// </summary>
                public const string DOWN_DIV = "DOWN_DIV";
                /// <summary>
                /// 응답코드
                /// </summary>
                public const string RES_CD = "RES_CD";
            }

            /// <summary>
            /// 컬럼순서
            /// </summary>
            public class SEQ { }
            /// <summary>
            /// 컬럼길이
            /// </summary>
            public static int[] LEN = { };
            /// <summary>
            /// 컬럼타입(0:문자형, 1:숫자형, 2:금액형)
            /// </summary>
            public static int[] TYPE = { };
        }
        #endregion

        /// <summary>
        /// 설치일정 조회 (57)
        /// </summary>
        public class IQ_INSTALL_SCHEDULE_INQ
        {
            public const string MSG_ID = "57"; 

            public class DATA
            {
                /// <summary>
                /// INQ 종별 = X0
                /// </summary>
                public const string INQ_TYPE = "INQ_TYPE";
                /// <summary>
                /// 점포코드 
                /// </summary>
                public const string STOR_CD = "STOR_CD";
                /// <summary>
                /// 요청구분 
                /// 1:설치정보조회, 2:전환정보조회(POS)
                /// </summary>
                public const string REQ_TYPE = "REQ_TYPE"; 
                /// <summary>
                /// 설치일자
                /// </summary>
                public const string INSTALL_DATE = "INSTALL_DATE";
                /// <summary>
                /// 설치시간
                /// </summary>
                public const string INSTALL_TIME = "INSTALL_TIME";
                /// <summary>
                /// 시스템오픈일자
                /// </summary>
                public const string SYS_OPEN_DATE = "SYS_OPEN_DATE";
                /// <summary>
                /// 응답코드 (00:정상,01:NO DATA, 그외 오류)
                /// </summary>
                public const string RES_CD = "RES_CD";
            }
        }

        /// <summary>
        /// 설치상태(결과) 전송 (58) :: 미정
        /// </summary>
        /// <remarks 
        public class IQ_INSTALL_STATUS_INQ
        {
            public const string MSG_ID = "58"; 

            public class DATA
            {
                /// <summary>
                /// INQ 종별 = X1
                /// </summary>
                public const string INQ_TYPE = "INQ_TYPE";
                /// <summary>
                /// 점포코드 
                /// </summary>
                public const string STOR_CD = "STOR_CD";
                /// <summary>
                /// 포스번호
                /// </summary>
                public const string POS_NO = "POS_NO";
                /// <summary>
                /// 상태코드 
                /// 01 : Install Start
                /// 02 : POS Setup 
                /// 03 : DB Create 
                /// 04 : POS Config info migration 
                /// 05 : POS  Device info migration 
                /// 06 : KPS info upload 
                /// 07 : TouchKey info upload 
                /// 08 : Flavor info upload 
                /// 09 : Floor / Table info migration 
                /// 10 : Etc info migration 
                /// 11 : Install complete
                /// </summary>
                public const string STATUS = "STATUS"; 
                /// <summary>
                /// SUCCESS/FAIL/SKIP
                /// </summary>
                public const string RESULT = "RESULT";
                /// <summary>
                /// 
                /// </summary>
                public const string REMARKS = "REMARKS";

                public const string RES_CD = "RES_CD";
            }
        }

        /// <summary>
        /// 설치로그 전송 (59) 
        /// </summary>
        public class IQ_INSTALL_LOG_INQ
        {
            public const string MSG_ID = "59";

            public class DATA
            {
                /// <summary>
                /// INQ 종별 = X2
                /// </summary>
                public const string INQ_TYPE = "INQ_TYPE";
                /// <summary>
                /// 점포코드 
                /// </summary>
                public const string STOR_CD = "STOR_CD";
                /// <summary>
                /// 포스번호
                /// </summary>
                public const string POS_NO = "POS_NO";
                /// <summary>
                /// 로그시간 (yyyyMMddcHHmmssfff)
                /// </summary>
                public const string LOG_TIME = "LOG_TIME";
                /// <summary>
                /// 1:info
                /// 2:error
                /// 3:exceptionc
                /// </summary>
                public const string LOG_TYPE = "LOG_TYPE";
                /// <summary>
                /// 
                /// </summary>
                public const string LOG_DATA = "DATA"; 
            }
        }

        /// <summary>
        /// 이행 마스터 임시저장 요청 (61)
        /// </summary>
        public class IQ_TMP_POSMST_INQ
        {
            public const string MSG_ID = "61";

            /// <summary>
            /// 마스터종류
            /// </summary>
            public class MSTKIND
            {
                /// <summary>
                /// 01 터치키 
                /// </summary>
                public const string TOUCHKEY = "01";
                /// <summary>
                /// 02 플레이버 
                /// </summary>
                public const string FLAVOR = "02";
                /// <summary>
                /// 03 KPS/KVS 정보 
                /// </summary>
                public const string KPS = "03";
                /// <summary>
                /// 04 POS터미널 정보 
                /// </summary>
                public const string POSINFO = "04";
                /// <summary>
                /// 05 포스옵션 정보 
                /// </summary>
                public const string POSOPT = "05";
            }

            public class DATA
            {
                /// <summary>
                /// INQ 종별 = 61
                /// </summary>
                public const string INQ_TYPE = "INQ_TYPE";
                /// <summary>
                /// 점포코드 
                /// </summary>
                public const string STOR_CD = "STOR_CD";
                /// <summary>
                /// 포스번호
                /// </summary>
                public const string POS_NO = "POS_NO";
                /// <summary>
                /// 요청구분
                /// 01:터치키 마스터 
                /// 02:플레이버 마스터
                /// 03:KPS 마스터
                /// </summary>
                public const string MST_KIND = "MST_KIND";
                /// <summary>
                /// 이행마스터 데이터 
                /// </summary>
                /// <example>
                /// 01:터치키 마스터 
                /// #~터치키구분|터치키TYPE|터치키그룹코드|터치키상세코드|메뉴명|화면위치
                /// 
                /// 02:플레이버 마스터
                /// #~상품코드|화면위치
                /// 
                /// 03:KPS 마스터
                /// #~장치코드|장치명|장치사용구분((1:Serial, 3:Lan)|ComPort|ComBaudRate|NetIP|NetPort|장치구분
                /// 
                /// 04:포스터미널정보 
                /// #~POSIP|POS구분|메인여부|화면크기|카드리더기종류|CAT단말기종류
                /// 
                /// 05:포스옵션
                /// #~옵션코드|옵션값
                /// </example>
                public const string DATA_LIST = "DATA";
                /// <summary>
                /// 응답코드 
                /// </summary>
                public const string RES_CD = "RES_CD";
            }
        }

    }


    #region 전문 생성 및 분해 처리
    public class ItemColumn
    {
        /// <summary>
        /// 전문 생성 처리
        /// </summary>
        /// <param name="aItemData"></param>
        /// <param name="aItemLen"></param>
        /// <param name="aItemType"></param>
        /// <returns></returns>
        public static string MakeMessage(string[] aItemData, int[] aItemLen, int[] aItemType)
        {
            return MakeMessage(aItemData, aItemLen, aItemType, "", "");
        }
        public static string MakeMessage(string[] aItemData, int[] aItemLen, int[] aItemType, string sPosNo, string sTranNo)
        {
            string sRetData = "";

            for (int i = 0; i < aItemLen.Length; i++)
            {
                if (aItemLen[i] == 0) continue;
                if (aItemData[i] == null) aItemData[i] = "";

                if (aItemLen[i] == -1)
                {
                    sRetData += aItemData[i];
                    continue;
                }

                // 컬럼타입(0:문자형, 1:숫자형, 2:금액형, 3:가변)
                if (aItemType[i] == 1)          // 숫자형
                {
                    string sNumData = "";
                    if (ComLib.LongParse(aItemData[i]) < 0)
                    {
                        sNumData = "-" + System.Math.Abs(ComLib.LongParse(aItemData[i])).ToString().PadLeft(aItemLen[i] - 1, '0');
                    }
                    else
                    {
                        sNumData = aItemData[i].PadLeft(aItemLen[i], '0');
                    }
                    sRetData += ComLib.RPadH(sNumData, aItemLen[i]);

                }
                else if (aItemType[i] == 2)     // 금액형
                {
                    string sNumData = "";
                    if (ComLib.DoubleParse(aItemData[i]) < 0)
                    {
                        sNumData = "-" + System.Math.Abs(ComLib.DoubleParse(aItemData[i])).ToString().PadLeft(aItemLen[i] - 1, '0');
                    }
                    else
                    {
                        sNumData = aItemData[i].PadLeft(aItemLen[i], '0');
                    }
                    sRetData += ComLib.RPadH(sNumData, aItemLen[i]);
                }
                else if (aItemType[i] == 3 || aItemType[i] == 4)     // 가변
                {
                    sRetData += aItemData[i]; //Trim(); 가변은 데이터 넘기는 부분에 trim이 필요할 경우 처리해야 한다.
                }
                else                            // 문자형
                {
                    sRetData += ComLib.RPadH(aItemData[i], aItemLen[i]);
                }

            }
            return sRetData;
        }

        /// <summary>
        /// 전문 분해 처리
        /// </summary>
        /// <param name="aItemLen"></param>
        /// <param name="aData"></param>
        /// <param name="nNowPos"></param>
        /// <param name="aItemData"></param>
        /// <returns></returns>
        public static int ParseMessage(int[] aItemLen, int[] aItemType, byte[] aData, ref int nNowPos, ref string[] aItemData)
        {
            return ParseMessage(aItemLen, aItemType, aData, ref nNowPos, ref aItemData, "", "");
        }
        public static int ParseMessage(int[] aItemLen, int[] aItemType, byte[] aData, ref int nNowPos, ref string[] aItemData, string sPosNo, string sTranNo)
        {
            for (int i = 0; i < aItemLen.Length; i++)
            {
                if (aItemLen[i] == 0 || aItemLen[i] == -1) continue;

                try
                {
                    if (aData.Length < nNowPos + aItemLen[i])
                    {
                        if (aData.Length > nNowPos)
                        {
                            byte[] byValue = new byte[aData.Length - nNowPos];
                            Array.Copy(aData, nNowPos, byValue, 0, aData.Length - nNowPos);
                            aItemData[i] = Encoding.Default.GetString(byValue, 0, byValue.Length);
                        }
                        else
                            aItemData[i] = "";
                    }
                    else
                    {
                        if (aItemType[i] == 3 || aItemType[i] == 4)   //가변데이터 처리
                        {
                            int iDataLen = 0;
                            aItemData[i] = ParseIndexOf(aItemType[i], nNowPos, aData, ref iDataLen);
                            nNowPos += iDataLen;
                            continue;
                        }
                        else
                        {
                            byte[] byValue = new byte[aItemLen[i]];
                            Array.Copy(aData, nNowPos, byValue, 0, aItemLen[i]);
                            aItemData[i] = Encoding.Default.GetString(byValue, 0, byValue.Length);
                        }

                    }
                }
                catch (Exception ex)
                {
                    //UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, "ItemColumn.ParsMessage()", "Exception.[" + i.ToString() + "]" + ex.Message);
                    ComLog.WriteLog(ComLog.Level.Exception
                                  , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "."
                                  + System.Reflection.MethodBase.GetCurrentMethod().Name + "()"
                                  , "[" + i.ToString() + "]" + ex.Message);             
                }
                nNowPos += aItemLen[i];
            }
            return nNowPos;
        }

        /// <summary>
        /// 전문 가변 필드 처리
        /// </summary>
        /// <param name="Start"></param>
        /// <param name="byVal"></param>
        /// <param name="DataLen"></param>
        /// <returns></returns>
        public static string ParseIndexOf(int nType, int Start, byte[] byVal, ref int DataLen)
        {
            string sData = "";

            DataLen = 0;

            for (int i = Start; i < byVal.Length; i++)
            {

                if (nType == 4)
                {
                    // RS 만 구분 필드로 체크
                    if (byVal[i] == PosConst.VAN_HEXA_BYTE.RS)
                    {
                        DataLen = i - Start;
                        if (DataLen > 0)
                        {
                            byte[] byValue = new byte[DataLen];
                            Array.Copy(byVal, Start, byValue, 0, DataLen);
                            sData = Encoding.Default.GetString(byValue, 0, byValue.Length);
                        }
                        break;
                    }
                }
                else
                {
                    if (byVal[i] == PosConst.VAN_HEXA_BYTE.GS || byVal[i] == PosConst.VAN_HEXA_BYTE.ETX || byVal[i] == PosConst.VAN_HEXA_BYTE.RS)
                    {
                        DataLen = i - Start;
                        if (DataLen > 0)
                        {
                            byte[] byValue = new byte[DataLen];
                            Array.Copy(byVal, Start, byValue, 0, DataLen);
                            sData = Encoding.Default.GetString(byValue, 0, byValue.Length);
                        }
                        break;
                    }
                }
            }
            return sData;
        }


        /// <summary>
        /// 전문 분해 처리
        /// </summary>
        /// <param name="aItemLen"></param>
        /// <param name="sData"></param>
        /// <param name="nPos"></param>
        /// <param name="aItemData"></param>
        /// <returns></returns>
        public static int ParseMessage(int[] aItemLen, int[] aItemType, string sData, int nPos, ref string[] aItemData)
        {
            byte[] bytData = Encoding.Default.GetBytes(sData);

            return ParseMessage(aItemLen, aItemType, bytData, ref nPos, ref aItemData, "", "");
        }
        /// <summary>
        /// 전문 분해 처리
        /// </summary>
        /// <param name="aItemLen"></param>
        /// <param name="bytData"></param>
        /// <param name="nPos"></param>
        /// <param name="aItemData"></param>
        /// <returns></returns>
        public static int ParseMessage(int[] aItemLen, int[] aItemType, byte[] bytData, int nPos, ref string[] aItemData)
        {
            return ParseMessage(aItemLen, aItemType, bytData, ref nPos, ref aItemData, "", "");
        }

        /// <summary>
        /// 메시지 길이 얻기
        /// </summary>
        /// <param name="aItemLen"></param>
        /// <returns></returns>
        public static int LenMessage(int[] aItemLen)
        {
            int nLen = 0;

            for (int i = 0; i < aItemLen.Length; i++)
            {
                if (aItemLen[i] == 0 || aItemLen[i] == -1) continue;

                nLen += aItemLen[i];
            }

            return nLen;
        }

        /// <summary>
        /// 통신해더 전문을 생성 한다.
        /// </summary>
        /// <param name="nMsgLen"></param>
        /// <param name="sMsgType"></param>
        /// <param name="sMsgKind"></param>
        /// <returns></returns>
        public static string MakeCommHeader(int nMsgLen, string sMsgType)
        {
            try
            {
                //PosStatus m_cPosStatus = (PosStatus)((StateServer)StateServer.GetInstance()).POS;

                string[] aCommHead = new string[Column.COMM_HEADER.LEN.Length];

                // 통신헤더의 전문 길이는 통신헤더길이 제외
                // 박동철B, 조충연K - 2016.0818
                //int nHeadLen = nMsgLen + LenMessage(Column.COMM_HEADER.LEN);
                //int nHeadLen = nMsgLen;
                //aCommHead[Column.COMM_HEADER.SEQ.MsgLen] = nHeadLen.ToString();
                //aCommHead[Column.COMM_HEADER.SEQ.MsgType] = sMsgType;
                //aCommHead[Column.COMM_HEADER.SEQ.CmpCd] = m_cPosStatus.Base.CmpCd;
                //aCommHead[Column.COMM_HEADER.SEQ.BrandCd] = m_cPosStatus.Base.BrandCd;
                //aCommHead[Column.COMM_HEADER.SEQ.StoreCd] = m_cPosStatus.Base.StoreNo;
                //aCommHead[Column.COMM_HEADER.SEQ.PosNo] = m_cPosStatus.Base.PosNo;
                ////aCommHead[Column.COMM_HEADER.SEQ.RegNo] = m_cPosStatus.Base.RegNo;
                //aCommHead[Column.COMM_HEADER.SEQ.TradeNo] = m_cPosStatus.Base.TradeNo;
                //aCommHead[Column.COMM_HEADER.SEQ.TranYmd] = m_cPosStatus.Base.SaleDate;
                //aCommHead[Column.COMM_HEADER.SEQ.SysYmd] = DateTime.Now.ToString("yyyyMMdd");
                //aCommHead[Column.COMM_HEADER.SEQ.SysHms] = DateTime.Now.ToString("HHmmss");
                //aCommHead[Column.COMM_HEADER.SEQ.EncType] = "0";
                //aCommHead[Column.COMM_HEADER.SEQ.ErrCd] = "000";

                int nHeadLen = nMsgLen;
                aCommHead[Column.COMM_HEADER.SEQ.MsgLen] = nHeadLen.ToString();
                aCommHead[Column.COMM_HEADER.SEQ.MsgType] = sMsgType;
                aCommHead[Column.COMM_HEADER.SEQ.CmpCd] = BasicInfo.CompCd;
                aCommHead[Column.COMM_HEADER.SEQ.BrandCd] = BasicInfo.BrandCd;
                aCommHead[Column.COMM_HEADER.SEQ.StoreCd] = BasicInfo.StoreNo;
                aCommHead[Column.COMM_HEADER.SEQ.PosNo] = BasicInfo.PosNo; 
                aCommHead[Column.COMM_HEADER.SEQ.TradeNo] = "0000";
                aCommHead[Column.COMM_HEADER.SEQ.TranYmd] = DateTime.Now.ToString("yyyyMMdd");
                aCommHead[Column.COMM_HEADER.SEQ.SysYmd] = DateTime.Now.ToString("yyyyMMdd");
                aCommHead[Column.COMM_HEADER.SEQ.SysHms] = DateTime.Now.ToString("HHmmss");
                aCommHead[Column.COMM_HEADER.SEQ.EncType] = "0";
                aCommHead[Column.COMM_HEADER.SEQ.ErrCd] = "000";


                return ItemColumn.MakeMessage(aCommHead, Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE);
            }
            catch (Exception ex)
            {
                //UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, "ItemColumn.MakeCommHeader()", "Exception." + ex.Message);
                ComLog.WriteLog(ComLog.Level.Exception
                              , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "."
                              + System.Reflection.MethodBase.GetCurrentMethod().Name + "()"
                              , ex.Message);
            }
            return "";
        }
    }
    #endregion
}
