using System; using System.Text; using System.Collections; using System.Collections.Generic; namespace NewPosInstaller { /// /// 전문(Tran, IRT, VAN) 정의 /// public static class Column { #region 통신헤더 /// /// 통신해더 /// public class COMM_HEADER { public class DATA { /// /// 전문길이 /// public string MsgLen; /// /// 전문구분 /// public string MsgType; /// /// 회사코드 /// public string CmpCd; /// /// 브랜드코드 /// public string BrandCd; /// /// 점포코드 /// public string StoreCd; /// /// POS번호 /// public string PosNo; ///// ///// 등록번호 ///// //public string RegNo; /// /// 거래번호 /// public string TradeNo; /// /// TRAN일자 /// public string TranYmd; /// /// 시스템일자 /// public string SysYmd; /// /// 시스템시간 /// public string SysHms; /// /// 전문암호화구분(0:평문, 1:암호화) /// public string EncType; /// /// 에러코드 /// public string ErrCd; } /// /// 컬럼순서 /// 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; } /// /// 컬럼길이 /// public static int[] LEN = { 6, 2, 4, 4, 10, 8, 2, 5, 8, 6, 1, 3 }; /// /// 컬럼타입(0:문자형, 1:숫자형, 2:금액형) /// public static int[] TYPE = { 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; } #endregion #region POS 마스터 요청/응답 /// /// POS 마스터 요청 /// public class IQ_POSMASTER_REQ { /// /// 컬럼명 /// public class DATA { /// /// INQ 종별 /// public const string InqType = "INQ_TYPE"; /// /// 마스터 요청 구분 /// public const string MasterDiv = "MASTER_DIV"; /// /// 점포코드 /// public const string StorCd = "STOR_CD"; /// /// SUB점포코드 /// public const string SubStorCd = "SUB_STOR_CD"; /// /// 변경 일시 /// public const string UpdDt = "UPD_DT"; /// /// 전송데이터 COUNT /// public const string DataCount = "DATA_COUNT"; /// /// 요청코드 /// public const string ProcCd = "PROC_CD"; /// /// 응답코드 /// public const string ResCd = "RES_CD"; } /// /// 컬럼순서 /// public class SEQ { } /// /// 컬럼길이 /// public static int[] LEN = { }; /// /// 컬럼타입(0:문자형, 1:숫자형, 2:금액형) /// public static int[] TYPE = { }; } /// /// POS 마스터 응답 /// public class IQ_POSMASTER_RSP { /// /// 컬럼명 /// public class DATA { /// /// 마스터 Row Count /// public const string Count = "COUNT"; /// /// 마스터 Data /// public const string Data = "DATA"; } /// /// 컬럼순서 /// public class SEQ { } /// /// 컬럼길이 /// public static int[] LEN = { }; /// /// 컬럼타입(0:문자형, 1:숫자형, 2:금액형) /// public static int[] TYPE = { }; } #endregion #region POS TABLE 마스터 저장요청 public class IQ_POS_TABLE_MST_INQ { public const string MSG_ID = "55"; /// /// 컬럼명 /// public class DATA { /// /// INQ 종별 = 55 /// public const string INQ_TYPE = "INQ_TYPE"; /// /// 점포코드 /// public const string STOR_CD = "STOR_CD"; /// /// 요청구분 /// 1:저장요청, 2:조회요청 /// public const string INQ_DIV = "INQ_DIV"; /// /// 테이블/층 저장 데이터 /// /// /// #~01(층)|필드1|필드2|필드3|필드4~~~ /// #~01(층)|필드1|필드2|필드3|필드4~~~ /// #~02(테이블)|필드1|필드2|필드3|필드4~~~ /// #~02(테이블)|필드1|필드2|필드3|필드4~~~ /// public const string DATA_LIST = "DATA"; /// /// 응답코드 /// public const string RES_CD = "RES_CD"; } /// /// 컬럼순서 /// public class SEQ { } /// /// 컬럼길이 /// public static int[] LEN = { }; /// /// 컬럼타입(0:문자형, 1:숫자형, 2:금액형) /// public static int[] TYPE = { }; } #endregion #region IQ_PGMUPDATE_REQ 프로그램 업데이트 목록 요청 /// /// 프로그램 업데이트 목록 요청 /// public class IQ_PGMUPDATE_REQ { /// /// 03 /// public const string MSG_ID = "03"; /// /// 컬럼명 /// public class DATA { /// /// INQ 종별 /// public const string INQ_TYPE = "INQ_TYPE"; /// /// 상세종별 /// public const string FILE_KIND = "FILE_KIND"; /// /// 적용구분 /// public const string FILE_APP_TY = "FILE_APP_TY"; /// /// 적용 일시 /// public const string FILE_YMDHMS = "FILE_YMDHMS"; /// /// 요청구분(A:전체, U:변경분) /// public const string DOWN_DIV = "DOWN_DIV"; } /// /// 컬럼순서 /// public class SEQ { } /// /// 컬럼길이 /// public static int[] LEN = { }; /// /// 컬럼타입(0:문자형, 1:숫자형, 2:금액형) /// public static int[] TYPE = { }; } #endregion #region IQ_PGMUPDATE_RSP 프로그램 업데이트 목록 응답 /// /// 프로그램 업데이트 목록 응답 /// public class IQ_PGMUPDATE_RSP { /// /// 컬럼명 /// public class DATA { /// /// INQ 종별 /// public const string INQ_TYPE = "INQ_TYPE"; /// /// 서버 IP /// public const string FILE_HQ_IP = "FILE_HQ_IP"; /// /// FTP IP /// public const string FTP_IP = "FTP_IP"; /// /// FTP PORT /// public const string FTP_PORT = "FTP_PORT"; /// /// FTP ID /// public const string FTP_ID = "FTP_ID"; /// /// FTP PWD /// public const string FTP_PWD = "FTP_PWD"; /// /// VALUE (배포구분, 적용구분, 적용일시, 파일경로, 파일명, 파일버전) /// public const string VALUE = "VALUE"; /// /// 요청구분(A:전체, U:변경분) /// public const string DOWN_DIV = "DOWN_DIV"; /// /// 응답코드 /// public const string RES_CD = "RES_CD"; } /// /// 컬럼순서 /// public class SEQ { } /// /// 컬럼길이 /// public static int[] LEN = { }; /// /// 컬럼타입(0:문자형, 1:숫자형, 2:금액형) /// public static int[] TYPE = { }; } #endregion /// /// 설치일정 조회 (57) /// public class IQ_INSTALL_SCHEDULE_INQ { public const string MSG_ID = "57"; public class DATA { /// /// INQ 종별 = X0 /// public const string INQ_TYPE = "INQ_TYPE"; /// /// 점포코드 /// public const string STOR_CD = "STOR_CD"; /// /// 요청구분 /// 1:설치정보조회, 2:전환정보조회(POS) /// public const string REQ_TYPE = "REQ_TYPE"; /// /// 설치일자 /// public const string INSTALL_DATE = "INSTALL_DATE"; /// /// 설치시간 /// public const string INSTALL_TIME = "INSTALL_TIME"; /// /// 시스템오픈일자 /// public const string SYS_OPEN_DATE = "SYS_OPEN_DATE"; /// /// 응답코드 (00:정상,01:NO DATA, 그외 오류) /// public const string RES_CD = "RES_CD"; } } /// /// 설치상태(결과) 전송 (58) :: 미정 /// /// /// INQ 종별 = X1 /// public const string INQ_TYPE = "INQ_TYPE"; /// /// 점포코드 /// public const string STOR_CD = "STOR_CD"; /// /// 포스번호 /// public const string POS_NO = "POS_NO"; /// /// 상태코드 /// 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 /// public const string STATUS = "STATUS"; /// /// SUCCESS/FAIL/SKIP /// public const string RESULT = "RESULT"; /// /// /// public const string REMARKS = "REMARKS"; public const string RES_CD = "RES_CD"; } } /// /// 설치로그 전송 (59) /// public class IQ_INSTALL_LOG_INQ { public const string MSG_ID = "59"; public class DATA { /// /// INQ 종별 = X2 /// public const string INQ_TYPE = "INQ_TYPE"; /// /// 점포코드 /// public const string STOR_CD = "STOR_CD"; /// /// 포스번호 /// public const string POS_NO = "POS_NO"; /// /// 로그시간 (yyyyMMddcHHmmssfff) /// public const string LOG_TIME = "LOG_TIME"; /// /// 1:info /// 2:error /// 3:exceptionc /// public const string LOG_TYPE = "LOG_TYPE"; /// /// /// public const string LOG_DATA = "DATA"; } } /// /// 이행 마스터 임시저장 요청 (61) /// public class IQ_TMP_POSMST_INQ { public const string MSG_ID = "61"; /// /// 마스터종류 /// public class MSTKIND { /// /// 01 터치키 /// public const string TOUCHKEY = "01"; /// /// 02 플레이버 /// public const string FLAVOR = "02"; /// /// 03 KPS/KVS 정보 /// public const string KPS = "03"; /// /// 04 POS터미널 정보 /// public const string POSINFO = "04"; /// /// 05 포스옵션 정보 /// public const string POSOPT = "05"; } public class DATA { /// /// INQ 종별 = 61 /// public const string INQ_TYPE = "INQ_TYPE"; /// /// 점포코드 /// public const string STOR_CD = "STOR_CD"; /// /// 포스번호 /// public const string POS_NO = "POS_NO"; /// /// 요청구분 /// 01:터치키 마스터 /// 02:플레이버 마스터 /// 03:KPS 마스터 /// public const string MST_KIND = "MST_KIND"; /// /// 이행마스터 데이터 /// /// /// 01:터치키 마스터 /// #~터치키구분|터치키TYPE|터치키그룹코드|터치키상세코드|메뉴명|화면위치 /// /// 02:플레이버 마스터 /// #~상품코드|화면위치 /// /// 03:KPS 마스터 /// #~장치코드|장치명|장치사용구분((1:Serial, 3:Lan)|ComPort|ComBaudRate|NetIP|NetPort|장치구분 /// /// 04:포스터미널정보 /// #~POSIP|POS구분|메인여부|화면크기|카드리더기종류|CAT단말기종류 /// /// 05:포스옵션 /// #~옵션코드|옵션값 /// public const string DATA_LIST = "DATA"; /// /// 응답코드 /// public const string RES_CD = "RES_CD"; } } } #region 전문 생성 및 분해 처리 public class ItemColumn { /// /// 전문 생성 처리 /// /// /// /// /// 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; } /// /// 전문 분해 처리 /// /// /// /// /// /// 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; } /// /// 전문 가변 필드 처리 /// /// /// /// /// 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; } /// /// 전문 분해 처리 /// /// /// /// /// /// 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, "", ""); } /// /// 전문 분해 처리 /// /// /// /// /// /// public static int ParseMessage(int[] aItemLen, int[] aItemType, byte[] bytData, int nPos, ref string[] aItemData) { return ParseMessage(aItemLen, aItemType, bytData, ref nPos, ref aItemData, "", ""); } /// /// 메시지 길이 얻기 /// /// /// 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; } /// /// 통신해더 전문을 생성 한다. /// /// /// /// /// 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 }