using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cosmos.Common;
using Cosmos.BaseFrame;
using Cosmos.UserFrame;
using Cosmos.ServiceProvider;
using System.Runtime.Serialization.Formatters.Soap;
using System.Threading;
using System.Data;
using System.Data.SqlClient;
using System.Net;
using System.IO;
using System.Xml;
using System.Net.Sockets;
namespace Cosmos.TranInterfaceOutside
{
public class TranInterfaceOutside : lTranInterfaceOutside
{
#region 변수선언
///
/// StateServer Object (StateServer 객체)
///
private StateServer StateObject = (StateServer)StateServer.GetInstance();
///
/// POS Status Value (POS 상태값)
///
private PosStatus m_cPosStatus = null;
///
/// MSSQL DB 관련 객체
///
private static SqlDB sqlDb = null;
///
/// Inteferface Thread
///
private Thread m_tIFProc = null;
///
/// 동작 여부
///
private bool m_IFProcRunning = false;
///
/// 처리중
///
private bool m_ProcStart = false;
///
/// 대기시간
///
private int nWAIT_TIME = 6000;
///
/// 전송할 데이터
///
private string m_sSendData = string.Empty;
///
/// FTP 모듈
///
private NetworkFtp m_cNetworkFTP = null;
protected TcpSocket m_cTcpSocket = null;
#endregion
#region 생성자
///
/// InterfaceOutside
///
public TranInterfaceOutside()
{
m_cPosStatus = (PosStatus)StateObject.POS;
m_cNetworkFTP = new NetworkFtp();
m_cTcpSocket = new TcpSocket();
}
#endregion
#region 스레드 시작 및 종료
///
/// 스레드 시작
///
public void Start()
{
try
{
// Database Connection
sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, m_cPosStatus.Base.LocalDbCatalog, m_cPosStatus.Base.LocalDbUserID, m_cPosStatus.Base.LocalDbPassword);
m_sSendData = string.Empty;
m_tIFProc = new Thread(new ThreadStart(IFExecuteProc));
m_IFProcRunning = true;
m_tIFProc.Start();
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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);
}
}
///
/// 스레드 종료
///
public void Stop()
{
try
{
m_IFProcRunning = false;
int count = 0;
while (count < 10)
{
if (m_tIFProc != null && m_tIFProc.IsAlive) m_IFProcRunning = false;
else break;
count++;
Thread.Sleep(10);
}
if (count == 10)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
UserCom.INFO_LEVEL,
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 (함수명))
"Force I/F Agent Stop!!!");
m_tIFProc.Abort();
}
// DB Close
sqlDb.DBClose();
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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);
}
}
#endregion
#region 외부 Interface 처리
private void IFExecuteProc()
{
int nCount = 0;
string sRet = UserCom.RST_ERR;
while (m_IFProcRunning)
{
try
{
// Set Wait Time
Thread.Sleep((int)nWAIT_TIME);
// 1분 대기후 처리
if (nCount >= 1)
{
// 현재 처리중이면 Skip
if (m_ProcStart != true)
{
m_ProcStart = true;
// 생성 처리
sRet = IF_ExecMake(m_cPosStatus.Mst.ETC_IF_DIV);
// 90일전 데이터 삭제
sRet = IFSendDataDelete();
m_ProcStart = false;
nCount = 0;
}
}
nCount++;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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);
}
}
}
#endregion
#region 인터페이스 생성
///
/// 인터페이스 생성
///
///
///
private string IF_ExecMake(string sIFDiv)
{
string sRet = UserCom.RST_ERR;
bool bRet = false;
DataTable dtData = new DataTable();
string sResCD = "99";
string sResMsg = "Not Send";
string sResData = "";
string sSendYn = "0";
int iRecvTimeOut = 10000;
string sRecvData = "";
try
{
// I/F 대상 거래 조회
sRet = SelTranData(ref dtData, sIFDiv);
if (sRet == UserCom.RST_OK)
{
foreach (DataRow dr in dtData.Rows)
{
// 전송상태
sSendYn = "0";
switch (sIFDiv)
{
#region 1.무역센터
case ItemConst.TranInterfaceOutside.IF_CHN_01: // 무역센터
{
// 생성
sRet = CHN_01_Make(dr);
if (sRet == UserCom.RST_OK)
{
// 데이터 전송
sResCD = "99";
//sRet = HttpPOST_SendReceive("http://10.254.10.60/ChiaTai/salestrans.asmx", m_sSendData, ref sResCD, ref sResMsg, ref sResData);
sRet = HttpPOST_SendReceive(sIFDiv, m_cPosStatus.Mst.ETC_IF_URL1, m_sSendData, ref sResCD, ref sResMsg, ref sResData);
if (sRet == UserCom.RST_OK)
{
if (sResCD == "0") sSendYn = "1";
}
if (sResCD != "0")
{
// 실패시
string sFileName = "FAIL" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "_" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + ".XML";
CmUtil.CreateDirectory(BaseCom.NxBinPath + @"TRADE\FAIL\");
CmUtil.FileDelete(BaseCom.NxBinPath + @"TRADE\FAIL\" + sFileName);
bRet = WriteFile(BaseCom.NxBinPath + @"TRADE\FAIL\", BaseCom.NxBinPath + @"TRADE\FAIL\" + sFileName, m_sSendData);
}
}
break;
}
#endregion
#region 2.상해쩡따광장
case ItemConst.TranInterfaceOutside.IF_CHN_02: // 상해쩡따광장
{
// 생성
sRet = CHN_02_Make(dr);
if (sRet == UserCom.RST_OK)
{
// 파일명
string sFileName = "C" + m_cPosStatus.Mst.JOIN_STOR_CD + "_" + m_cPosStatus.Mst.JOIN_BRAND_CD + "_" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "_" + CmUtil.GetDataRowStr(dr, "POS_NO") + CmUtil.GetDataRowStr(dr, "TRADE_NO") + ".dat";
// 파일저장
CmUtil.CreateDirectory(BaseCom.NxBinPath + @"FTPDATA\");
CmUtil.FileDelete(BaseCom.NxBinPath + @"FTPDATA\" + sFileName);
bRet = WriteFile(BaseCom.NxBinPath + "FTPDATA", BaseCom.NxBinPath + @"FTPDATA\" + sFileName, m_sSendData);
if (CmUtil.Exists(sFileName) == true)
{
// ftp 전송
if (m_cNetworkFTP.Connect(m_cPosStatus.Mst.ETC_IF_FTP_IP, m_cPosStatus.Mst.ETC_IF_FTP_ID, m_cPosStatus.Mst.ETC_IF_FTP_PW, 10, CmUtil.IntParse(m_cPosStatus.Mst.ETC_IF_FTP_PORT)) == 0)
{
// FTP 다운로드
int iRet = m_cNetworkFTP.Upload(m_cPosStatus.Mst.ETC_IF_FTP_PATH, BaseCom.NxBinPath + @"FTPDATA\", sFileName);
if (iRet == 0)
{
// 정상
CmUtil.FileDelete(BaseCom.NxBinPath + @"FTPDATA\" + sFileName);
sSendYn = "1";
sResCD = "00";
sResMsg = "OK";
}
}
}
}
break;
}
#endregion
#region 3.왕진활현
case ItemConst.TranInterfaceOutside.IF_CHN_03: // 왕진활현
{
// 생성
sRet = CHN_03_Make(dr);
if (sRet == UserCom.RST_OK)
{
// 파일저장
//CmUtil.FileDelete(BaseCom.NxBinPath + @"CapitaInterface\possalesdata.txt"); // 개점시 삭제
bRet = WriteFile(@"C:\HOME\IMPORT\", @"C:\HOME\IMPORT\possalesdata.txt", m_sSendData);
// 처리 거래정보 저장
sRet = SavePOSInfoini(dr);
if (bRet == true)
{
// 생성후 데몬이 전송처리하여 생성만 되면 전상 처리
sSendYn = "1";
sResCD = "00";
sResMsg = "OK";
}
}
break;
}
#endregion
#region 4.조양따훼청
case ItemConst.TranInterfaceOutside.IF_CHN_04: // 조양따훼청
{
// 생성
sRet = CHN_04_Make(dr);
if (sRet == UserCom.RST_OK)
{
// 파일명
string sFileName = CmUtil.GetDataRowStr(dr, "SALE_DT") + "_" + CmUtil.GetDataRowStr(dr, "POS_NO") + "_" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + ".dat";
// 파일저장
CmUtil.CreateDirectory(@"C:\PosData\import\");
CmUtil.FileDelete(@"C:\PosData\import\" + sFileName);
bRet = WriteFile(@"C:\PosData\import\", @"C:\PosData\import\" + sFileName, m_sSendData);
if (CmUtil.Exists(@"C:\PosData\import\" + sFileName) == true)
{
// 생성후 데몬이 전송처리하여 생성만 되면 전상 처리
sSendYn = "1";
sResCD = "00";
sResMsg = "OK";
}
}
break;
}
#endregion
#region 5.풍란
case ItemConst.TranInterfaceOutside.IF_CHN_05: // 풍란
{
// 생성
sRet = CHN_05_Make(dr);
if (sRet == UserCom.RST_OK)
{
// 파일명
string sFileName = CmUtil.GetDataRowStr(dr, "SALE_DT") + "_" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + ".XML";
// 파일저장
CmUtil.FileDelete(BaseCom.NxBinPath + @"FENGLAN\" + sFileName);
bRet = WriteFile(BaseCom.NxBinPath + @"FENGLAN\", BaseCom.NxBinPath + @"FENGLAN\" + sFileName, m_sSendData);
if (CmUtil.Exists(BaseCom.NxBinPath + @"FENGLAN\" + sFileName) == true)
{
sRet = XMLSendSocket(m_cPosStatus.Mst.ETC_IF_FTP_IP, CmUtil.IntParse(m_cPosStatus.Mst.ETC_IF_FTP_PORT), m_sSendData, ref sRecvData);
// 생성후 데몬이 전송처리하여 생성만 되면 정상 처리
sResCD = "99";
sRet = XmlParser(ItemConst.TranInterfaceOutside.IF_CHN_05, sRecvData, "result", ref sResCD, ref sResMsg);
if (sRet == UserCom.RST_OK)
{
if (sResCD == "0")
{
sSendYn = "1";
// 정상 처리사 삭제
CmUtil.FileDelete(BaseCom.NxBinPath + @"FENGLAN\" + sFileName);
}
}
if (sResCD != "0")
{
// 오류시 FIAL 폴더로 이동
sSendYn = "9";
CmUtil.CreateDirectory(BaseCom.NxBinPath + @"FENGLAN\FAIL\");
CmUtil.FileMove(BaseCom.NxBinPath + @"FENGLAN\" + sFileName, BaseCom.NxBinPath + @"FENGLAN\FAIL\" + sFileName);
}
}
}
break;
}
#endregion
#region 7.싱가포르-창이공항
case ItemConst.TranInterfaceOutside.IF_SIN_01: // 창이공항
{
// 생성
sRet = SIN_01_Make(dr);
if (sRet == UserCom.RST_OK)
{
// 파일명
string sFileName = string.Format("{0:0000}", CmUtil.GetDataRowDouble(dr, "POS_NO")) + "_" + CmUtil.GetDataRowStr(dr, "TRADE_NO");
// 파일저장
CmUtil.FileDelete(BaseCom.NxBinPath + @"FTPDATA\" + sFileName);
bRet = WriteFile(BaseCom.NxBinPath + "FTPDATA", BaseCom.NxBinPath + @"FTPDATA\" + sFileName, m_sSendData);
if (CmUtil.Exists(BaseCom.NxBinPath + @"FTPDATA\" + sFileName) == true)
{
// ftp 전송
if (m_cNetworkFTP.Connect(m_cPosStatus.Mst.ETC_IF_FTP_IP, m_cPosStatus.Mst.ETC_IF_FTP_ID, m_cPosStatus.Mst.ETC_IF_FTP_PW, 10, CmUtil.IntParse(m_cPosStatus.Mst.ETC_IF_FTP_PORT)) == 0)
{
// FTP 다운로드
int iRet = m_cNetworkFTP.Upload(m_cPosStatus.Mst.ETC_IF_FTP_PATH, BaseCom.NxBinPath + @"FTPDATA\", sFileName);
if (iRet == 0)
{
// 정상
CmUtil.FileDelete(BaseCom.NxBinPath + @"FTPDATA\" + sFileName);
sSendYn = "1";
sResCD = "00";
sResMsg = "OK";
}
else
{
sSendYn = "9";
CmUtil.CreateDirectory(BaseCom.NxBinPath + @"FTPDATA\BackUp\");
CmUtil.FileMove(BaseCom.NxBinPath + @"FTPDATA\" + sFileName, BaseCom.NxBinPath + @"FTPDATA\BackUp\" + sFileName);
}
}
}
}
break;
}
#endregion
}
// 전송후 상태값 저장
sRet = IFSendFlgUpdate(dr, sIFDiv, sResCD, sResMsg, m_sSendData, sResData, sSendYn);
}
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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 sRet;
}
#endregion
#region I/F 대상 거래 조회
///
/// I/F 대상 거래 조회
///
///
///
///
private string SelTranData(ref DataTable dtData, string sIFDiv)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
try
{
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , TSH.PAY_TIME \n";
sQuery += " , TSH.ORG_BILLDT \n";
sQuery += " , TSH.ORG_BILL_NO \n";
sQuery += " , TSH.ORG_BILL_POSNO \n";
sQuery += " , ISNULL(SUM(TSH.QTY), 0) QTY \n";
sQuery += " , ISNULL(SUM(TSH.NET_SALE_AMT), 0) SALE_AMT \n";
sQuery += "FROM POSLOG..TR_SALE_HEADER TSH \n";
sQuery += " LEFT JOIN POSLOG..LOG_SALE_IF LSI \n";
sQuery += " ON TSH.CMP_CD = LSI.CMP_CD \n";
sQuery += " AND TSH.SALE_DT = LSI.SALE_DT \n";
sQuery += " AND TSH.STOR_CD = LSI.STOR_CD \n";
sQuery += " AND TSH.POS_NO = LSI.POS_NO \n";
sQuery += " AND TSH.TRADE_NO = LSI.TRADE_NO \n";
sQuery += " AND LSI.IF_DIV = '" + sIFDiv.Trim() + "' \n";
sQuery += "WHERE \n";
sQuery += " TSH.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sQuery += "AND TSH.SALE_DT >= CONVERT(VARCHAR(8), DATEADD(day, -3, '" + m_cPosStatus.Base.SaleDate + "'), 112) \n"; // 영업일 기준 3일 이전부터 체크
sQuery += "AND TSH.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sQuery += "AND TSH.POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n";
sQuery += "AND TSH.TRAIN_MODE_YN = '0' \n";
sQuery += "AND TSH.TRADE_KINDPER = '00' \n"; // 거래구분 ('00', '10', '11', '20', '21', '42', '43') -- 일반거래, 미결거래, 대외거래, 선불판매, 상품권판매
sQuery += "AND LSI.CMP_CD IS NULL \n";
sQuery += "GROUP BY \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , TSH.PAY_TIME \n";
sQuery += " , TSH.ORG_BILLDT \n";
sQuery += " , TSH.ORG_BILL_NO \n";
sQuery += " , TSH.ORG_BILL_POSNO \n";
sQuery += "ORDER BY 1, 2, 3, 4, 5 \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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 sRet;
}
#endregion
#region 1.무역센터 - 중국
#region CHN_01_Make 생성
///
/// CHN_01_Make 생성
///
///
///
private string CHN_01_Make(DataRow dr)
{
string sRet = UserCom.RST_ERR;
try
{
// 1.헤더정보
sRet = CHN_01_Header(dr);
if(sRet != UserCom.RST_OK ) return sRet;
// 2.상품정보
sRet = CHN_01_iTem(dr);
if(sRet != UserCom.RST_OK ) return sRet;
// 3.결제정보
sRet = CHN_01_Tender(dr);
if(sRet != UserCom.RST_OK ) return sRet;
// 4.종결
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
sRet = UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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 sRet;
}
#endregion
#region CHN_01_Header 헤더
///
/// CHN_01_Header 헤더
///
///
///
private string CHN_01_Header(DataRow dr)
{
string sRet = UserCom.RST_ERR;
try
{
m_sSendData = "";
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
// 1. XML 헤더
m_sSendData += PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "SB124A" + PosConst.CRLF;
m_sSendData += "SB124A" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + IntParse(CmUtil.GetDataRowStr(dr, "TRADE_NO")) + "" + PosConst.CRLF; // 거래번호
m_sSendData += "" + IntParse(CmUtil.GetDataRowStr(dr, "TRADE_NO")) + "" + PosConst.CRLF; // 거래번호
m_sSendData += "0" + PosConst.CRLF;
m_sSendData += "SALESDATA" + PosConst.CRLF;
m_sSendData += "332" + PosConst.CRLF;
m_sSendData += "V332M" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
// 2. XML 합계정보
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "SB124A" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "" + PosConst.CRLF;
m_sSendData += "" + CmUtil.GetDataRowStr(dr, "PAY_TIME") + "" + PosConst.CRLF;
m_sSendData += "2037" + PosConst.CRLF;
m_sSendData += "SB124A" + PosConst.CRLF;
m_sSendData += "" + CmUtil.GetDataRowStr(dr, "POS_NO") + "" + PosConst.CRLF;
string sTranDiv = "SA";
if (CmUtil.GetDataRowStr(dr, "TRADE_DIV") == "1") sTranDiv = "SR";
m_sSendData += "" + sTranDiv + "" + PosConst.CRLF;
m_sSendData += "" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "" + PosConst.CRLF;
m_sSendData += "" + CmUtil.GetDataRowStr(dr, "ORG_BILLDT") + "" + PosConst.CRLF;
m_sSendData += "" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "" + PosConst.CRLF;
m_sSendData += "" + CmUtil.GetDataRowStr(dr, "ORG_BILL_POSNO") + "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "SB124A" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + IntParse(CmUtil.GetDataRowStr(dr, "QTY")) + "" + PosConst.CRLF;
m_sSendData += "0.00" + PosConst.CRLF;
m_sSendData += "" + DoubleParse(CmUtil.GetDataRowStr(dr, "SALE_AMT")) + "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "0" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "0" + PosConst.CRLF;
m_sSendData += "0" + PosConst.CRLF;
m_sSendData += "" + DoubleParse(CmUtil.GetDataRowStr(dr, "SALE_AMT")) + "" + PosConst.CRLF;
m_sSendData += "" + DoubleParse(CmUtil.GetDataRowStr(dr, "SALE_AMT")) + "" + PosConst.CRLF;
m_sSendData += "0.00" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "SB124A" + PosConst.CRLF;
m_sSendData += "" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "" + PosConst.CRLF;
m_sSendData += "" + CmUtil.GetDataRowStr(dr, "PAY_TIME") + "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "10" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
sRet = UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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 sRet;
}
#endregion
#region CHN_01_iTem 상품정보
///
/// CHN_01_iTem 상품정보
///
///
///
private string CHN_01_iTem(DataRow dr)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
DataTable dtData = new DataTable();
try
{
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSD.SEQ \n";
sQuery += " , TSD.ITEM_PLU_CD \n";
sQuery += " , ISNULL(TSD.SALE_QTY, 0) SALE_QTY \n";
sQuery += " , ISNULL(TSD.BILL_AMT, 0) BILL_AMT \n";
sQuery += "FROM POSLOG..TR_SALE_DETAIL TSD \n";
sQuery += "WHERE \n";
sQuery += " TSD.CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += "AND TSD.SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += "AND TSD.STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += "AND TSD.POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += "AND TSD.TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += "AND TSD.CANCEL_DIV = '0' \n";
sQuery += "ORDER BY TSD.SEQ \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
m_sSendData += "" + PosConst.CRLF;
foreach(DataRow dri in dtData.Rows)
{
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "1" + PosConst.CRLF;
m_sSendData += "" + IntParse(CmUtil.GetDataRowStr(dri, "SEQ")) + "" + PosConst.CRLF;
m_sSendData += "SB124A" + PosConst.CRLF;
m_sSendData += "SB124A1" + PosConst.CRLF;
m_sSendData += "SB124A1 " + PosConst.CRLF;
m_sSendData += "" + CmUtil.GetDataRowStr(dri, "ITEM_PLU_CD") + "" + PosConst.CRLF;
m_sSendData += "" + CmUtil.GetDataRowStr(dri, "ITEM_PLU_CD") + "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "*" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "0" + PosConst.CRLF;
m_sSendData += "0" + PosConst.CRLF;
m_sSendData += "1" + PosConst.CRLF;
m_sSendData += "" + IntParse(CmUtil.GetDataRowStr(dri, "SALE_QTY")) + "" + PosConst.CRLF;
m_sSendData += "1.00" + PosConst.CRLF;
m_sSendData += "0.00" + PosConst.CRLF;
m_sSendData += "0.00" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "0" + PosConst.CRLF;
m_sSendData += "0" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "0" + PosConst.CRLF;
m_sSendData += "0" + PosConst.CRLF;
m_sSendData += "0" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + DoubleParse(CmUtil.GetDataRowStr(dri, "BILL_AMT")) + "" + PosConst.CRLF;
m_sSendData += "0" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
}
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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 sRet;
}
#endregion
#region CHN_01_Tender 결제정보
///
/// CHN_01_Tender 결제정보
///
///
///
private string CHN_01_Tender(DataRow dr)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
DataTable dtData = new DataTable();
try
{
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSP.SEQ \n";
sQuery += " , CASE ISNULL(TSP.PAY_WAY_CD, '00') WHEN '00' THEN 'CH' \n";
sQuery += " WHEN '02' THEN 'CI' \n";
sQuery += " ELSE 'OH' END PAY_WAY_CD \n";
sQuery += " , ISNULL(TSP.QTY_ENTRY_01, 0) QTY \n";
sQuery += " , ISNULL(TSP.PAY_AMT, 0) PAY_AMT \n";
sQuery += "FROM POSLOG..TR_SALE_PAY TSP \n";
sQuery += "WHERE \n";
sQuery += " TSP.CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += "AND TSP.SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += "AND TSP.STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += "AND TSP.POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += "AND TSP.TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += "AND TSP.CANCEL_DIV = '0' \n";
sQuery += "ORDER BY TSP.SEQ \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
m_sSendData += " " + PosConst.CRLF;
foreach(DataRow dri in dtData.Rows)
{
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + IntParse(CmUtil.GetDataRowStr(dri, "SEQ")) + "" + PosConst.CRLF;
m_sSendData += "" + CmUtil.GetDataRowStr(dri, "PAY_WAY_CD") + "" + PosConst.CRLF;
m_sSendData += "0" + PosConst.CRLF;
m_sSendData += "0" + PosConst.CRLF;
m_sSendData += "" + DoubleParse(CmUtil.GetDataRowStr(dri, "PAY_AMT")) + "" + PosConst.CRLF;
m_sSendData += "" + DoubleParse(CmUtil.GetDataRowStr(dri, "PAY_AMT")) + "" + PosConst.CRLF;
m_sSendData += "0" + PosConst.CRLF;
m_sSendData += "-BS2037A00181,-DTSA,-CT99," + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
m_sSendData += "" + PosConst.CRLF;
}
m_sSendData += " " + PosConst.CRLF;
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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 sRet;
}
#endregion
#endregion
#region 2.상해쩡따광장
#region CHN_02_Make 생성
///
/// CHN_02_Make 생성
///
///
///
private string CHN_02_Make(DataRow dr)
{
string sRet = UserCom.RST_ERR;
try
{
// 1.헤더정보
sRet = CHN_02_Header(dr);
if (sRet != UserCom.RST_OK) return sRet;
// 2.상품정보
sRet = CHN_02_iTem(dr);
if (sRet != UserCom.RST_OK) return sRet;
// 3.결제정보
sRet = CHN_02_Tender(dr);
if (sRet != UserCom.RST_OK) return sRet;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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 sRet;
}
#endregion
#region CHN_02_Header 헤더
///
/// CHN_02_Header 헤더
///
///
///
private string CHN_02_Header(DataRow dr)
{
string sRet = UserCom.RST_ERR;
try
{
m_sSendData = "";
m_sSendData += "C";
m_sSendData += m_cPosStatus.Mst.JOIN_BRAND_CD; // 임대번호
m_sSendData += "~";
m_sSendData += m_cPosStatus.Mst.JOIN_STOR_CD; // 기계번호
m_sSendData += "~";
m_sSendData += "H"; // 기록유형 (H-head)
m_sSendData += "~";
m_sSendData += m_cPosStatus.Base.PosNo; // pos번호
m_sSendData += "~";
m_sSendData += m_cPosStatus.Base.TradeNo; // 거래번호
m_sSendData += "~";
string sTranDiv = "1";
if (CmUtil.GetDataRowStr(dr, "TRADE_DIV") == "1") sTranDiv = "2";
m_sSendData += sTranDiv; // 거래유형 (1:매출, 2:환불)
m_sSendData += "~";
m_sSendData += DoubleParse(CmUtil.GetDataRowStr(dr, "SALE_AMT")); // 거래총금액
m_sSendData += "~";
m_sSendData += ""; // 회원카드번호
m_sSendData += "~";
m_sSendData += CmUtil.GetDataRowStr(dr, "SALE_DT") + CmUtil.GetDataRowStr(dr, "PAY_TIME"); // 거래일시
m_sSendData += PosConst.CRLF;
sRet = UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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 sRet;
}
#endregion
#region CHN_02_iTem 상품정보
///
/// CHN_02_iTem 상품정보
///
///
///
private string CHN_02_iTem(DataRow dr)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
DataTable dtData = new DataTable();
try
{
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSD.SEQ \n";
sQuery += " , TSD.ITEM_PLU_CD \n";
sQuery += " , ISNULL(TSD.SALE_QTY, 0) SALE_QTY \n";
sQuery += " , ISNULL(TSD.BILL_AMT, 0) BILL_AMT \n";
sQuery += " , ISNULL(MI.SHTCUT_ITEMNM, '') ITEM_NM \n";
sQuery += "FROM POSLOG..TR_SALE_DETAIL TSD \n";
sQuery += " LEFT JOIN POSMST..MST_ITEM MI \n";
sQuery += " ON MI.CMP_CD = TSD.CMP_CD \n";
sQuery += " AND MI.STOR_CD = TSD.STOR_CD \n";
sQuery += " AND MI.SUB_STOR_CD = TSD.SUB_SHOP_CD \n";
sQuery += " AND MI.ITEM_CD = TSD.ITEM_PLU_CD \n";
sQuery += " AND MI.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n";
sQuery += "WHERE \n";
sQuery += " TSD.CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += "AND TSD.SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += "AND TSD.STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += "AND TSD.POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += "AND TSD.TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += "AND TSD.CANCEL_DIV = '0' \n";
sQuery += "ORDER BY TSD.SEQ \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
foreach (DataRow dri in dtData.Rows)
{
m_sSendData += "C";
m_sSendData += m_cPosStatus.Mst.JOIN_BRAND_CD; // 임대번호
m_sSendData += "~";
m_sSendData += m_cPosStatus.Mst.JOIN_STOR_CD; // 기계번호
m_sSendData += "~";
m_sSendData += "I"; // 기록유형 (I-item)
m_sSendData += "~";
m_sSendData += CmUtil.GetDataRowStr(dri, "ITEM_PLU_CD"); // 상품코드
m_sSendData += "~";
m_sSendData += IntParse(CmUtil.GetDataRowStr(dri, "SALE_QTY")); // 수량
m_sSendData += "~";
m_sSendData += DoubleParse(CmUtil.GetDataRowStr(dri, "BILL_AMT")); // 금액
m_sSendData += "~";
m_sSendData += CmUtil.MidH(CmUtil.GetDataRowStr(dri, "ITEM_NM"), 0, 40); // 명칭
m_sSendData += PosConst.CRLF;
}
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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 sRet;
}
#endregion
#region CHN_02_Tender 결제정보
///
/// CHN_02_Tender 결제정보
///
///
///
private string CHN_02_Tender(DataRow dr)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
DataTable dtData = new DataTable();
try
{
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSP.SEQ \n";
sQuery += " , CASE ISNULL(TSP.PAY_WAY_CD, '00') WHEN '00' THEN '1' \n";
sQuery += " WHEN '02' THEN (CASE ISNULL(TSP.OCCUR_ENTRY_05, '') WHEN 'C' THEN '3' ELSE '2' END) \n";
sQuery += " WHEN '06' THEN '4' \n";
sQuery += " ELSE '5' END PAY_WAY_CD \n";
sQuery += " , ISNULL(TSP.QTY_ENTRY_01, 0) QTY \n";
sQuery += " , ISNULL(TSP.PAY_AMT, 0) PAY_AMT \n";
sQuery += "FROM POSLOG..TR_SALE_PAY TSP \n";
sQuery += "WHERE \n";
sQuery += " TSP.CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += "AND TSP.SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += "AND TSP.STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += "AND TSP.POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += "AND TSP.TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += "AND TSP.CANCEL_DIV = '0' \n";
sQuery += "ORDER BY TSP.SEQ \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
foreach (DataRow dri in dtData.Rows)
{
m_sSendData += "C";
m_sSendData += m_cPosStatus.Mst.JOIN_BRAND_CD; // 임대번호
m_sSendData += "~";
m_sSendData += m_cPosStatus.Mst.JOIN_STOR_CD; // 기계번호
m_sSendData += "~";
m_sSendData += "T"; // 기록유형 (T-TENDER)
m_sSendData += "~";
m_sSendData += CmUtil.GetDataRowStr(dri, "PAY_WAY_CD"); // 지불방식: 1-현금 2-신용카드 3-IC카드 4-상품권 5-기타
m_sSendData += "~";
m_sSendData += DoubleParse(CmUtil.GetDataRowStr(dri, "PAY_AMT")); // 금액
m_sSendData += PosConst.CRLF;
}
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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 sRet;
}
#endregion
#endregion
#region 3.왕진활현
#region CHN_03_Make 생성
///
/// CHN_03_Make 생성
///
///
///
private string CHN_03_Make(DataRow dr)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
DataTable dtData = new DataTable();
try
{
m_sSendData = "";
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , '2052011401001' STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.PAY_TIME \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , '2052011401001' ITEM_CD \n";
sQuery += " , ISNULL(SUM(TSH.NET_SALE_AMT), 0) SALE_AMT \n";
sQuery += " FROM POSLOG..TR_SALE_HEADER TSH \n";
sQuery += " WHERE \n";
sQuery += " TSH.CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += " AND TSH.SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += " AND TSH.STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += " AND TSH.POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += " AND TSH.TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += " AND TSH.TRAIN_MODE_YN = '0' \n";
sQuery += " AND TSH.TRADE_KINDPER = '00' \n";
sQuery += " GROUP BY \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , TSH.PAY_TIME \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
foreach (DataRow dri in dtData.Rows)
{
double nTranDiv = 1;
if (CmUtil.GetDataRowStr(dri, "TRADE_DIV") == ItemConst.PAY_CANCEL_DIV.CANCEL) nTranDiv = -1;
m_sSendData += " "; // 스페이스
m_sSendData += "\t";
m_sSendData += m_cPosStatus.Mst.JOIN_STOR_CD; // 점포코드
m_sSendData += "\t";
m_sSendData += CmUtil.GetDataRowStr(dri, "POS_NO"); // POS번호
m_sSendData += "\t";
m_sSendData += CmUtil.GetDataRowStr(dri, "SALE_DT"); // 거래일자
m_sSendData += "\t";
m_sSendData += CmUtil.GetDataRowStr(dri, "PAY_TIME"); // 거래시간
m_sSendData += "\t";
m_sSendData += CmUtil.GetDataRowStr(dri, "TRADE_NO"); // 거래번호
m_sSendData += "\t";
m_sSendData += m_cPosStatus.Mst.JOIN_ITEM_CD; // 상품코드
m_sSendData += "\t";
m_sSendData += CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "SALE_AMT")), nTranDiv); // 결제금액
m_sSendData += "\t";
m_sSendData += ""; // TENDER
m_sSendData += PosConst.CRLF;
}
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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 sRet;
}
#endregion
#endregion
#region 4.조양따훼청
#region CHN_04_Make 생성
///
/// CHN_04_Make 생성
///
///
///
private string CHN_04_Make(DataRow dr)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
DataTable dtData = new DataTable();
try
{
m_sSendData = "";
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , '1F31A1' STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.PAY_TIME \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , '1031110' ITEM_CD \n";
sQuery += " , ISNULL(SUM(CASE ISNULL(TSP.PAY_WAY_CD, '') WHEN '00' THEN ISNULL(TSP.PAY_AMT, 0) ELSE 0 END), 0) CASH_AMT \n";
sQuery += " , ISNULL(SUM(CASE ISNULL(TSP.PAY_WAY_CD, '') WHEN '02' THEN (CASE WHEN ISNULL(TSP.OCCUR_ENTRY_18, '') = '20' THEN ISNULL(TSP.PAY_AMT, 0) ELSE 0 END) ELSE 0 END), 0) CARD_UN_SUM \n";
sQuery += " , ISNULL(SUM(CASE ISNULL(TSP.PAY_WAY_CD, '') WHEN '02' THEN (CASE WHEN ISNULL(TSP.OCCUR_ENTRY_18, '') <> '20' THEN ISNULL(TSP.PAY_AMT, 0) ELSE 0 END) ELSE 0 END), 0) CARD_20_SUM \n";
sQuery += " , ISNULL(SUM(CASE ISNULL(TSP.PAY_WAY_CD, '') WHEN '00' THEN 0 \n";
sQuery += " WHEN '02' THEN 0 \n";
sQuery += " ELSE ISNULL(TSP.PAY_AMT, 0) END), 0) ETC_SUM \n";
sQuery += " , ISNULL(SUM(TSH.NET_SALE_AMT), 0) SALE_AMT \n";
sQuery += " FROM POSLOG..TR_SALE_HEADER TSH \n";
sQuery += " LEFT JOIN POSLOG..TR_SALE_PAY TSP \n";
sQuery += " ON TSP.CMP_CD = TSH.CMP_CD \n";
sQuery += " AND TSP.SALE_DT = TSH.SALE_DT \n";
sQuery += " AND TSP.STOR_CD = TSH.STOR_CD \n";
sQuery += " AND TSP.POS_NO = TSH.POS_NO \n";
sQuery += " AND TSP.TRADE_NO = TSH.TRADE_NO \n";
sQuery += " AND TSP.CANCEL_DIV = '0' \n";
sQuery += " WHERE \n";
sQuery += " TSH.CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += " AND TSH.SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += " AND TSH.STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += " AND TSH.POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += " AND TSH.TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += " AND TSH.TRAIN_MODE_YN = '0' \n";
sQuery += " AND TSH.TRADE_KINDPER = '00' \n";
sQuery += " GROUP BY \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , TSH.PAY_TIME \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
foreach (DataRow dri in dtData.Rows)
{
double nTranDiv = 1;
if (CmUtil.GetDataRowStr(dri, "TRADE_DIV") == ItemConst.PAY_CANCEL_DIV.CANCEL) nTranDiv = -1;
m_sSendData += " "; // 스페이스
m_sSendData += "\t";
m_sSendData += m_cPosStatus.Mst.JOIN_STOR_CD; // 점포코드
m_sSendData += "\t";
m_sSendData += CmUtil.GetDataRowStr(dri, "POS_NO"); // POS번호
m_sSendData += "\t";
m_sSendData += CmUtil.GetDataRowStr(dri, "SALE_DT"); // 거래일자
m_sSendData += "\t";
m_sSendData += CmUtil.GetDataRowStr(dri, "PAY_TIME"); // 거래시간
m_sSendData += "\t";
m_sSendData += CmUtil.GetDataRowStr(dri, "TRADE_NO"); // 거래번호
m_sSendData += "\t";
m_sSendData += m_cPosStatus.Mst.JOIN_ITEM_CD; // 상품코드
m_sSendData += "\t";
m_sSendData += CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "CASH_AMT")), nTranDiv); // 현금
m_sSendData += "\t";
m_sSendData += CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "CARD_UN_SUM")), nTranDiv); // 중국은행카드
m_sSendData += "\t";
m_sSendData += CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "CARD_20_SUM")), nTranDiv); // 해외은행카드
m_sSendData += "\t";
m_sSendData += CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "ETC_SUM")), nTranDiv); // 기타
m_sSendData += "\t";
m_sSendData += CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "SALE_AMT")), nTranDiv); // 합계
m_sSendData += PosConst.CRLF;
}
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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 sRet;
}
#endregion
#endregion
#region 5.풍란
#region CHN_05_Make 생성
///
/// CHN_05_Make 생성
///
///
///
private string CHN_05_Make(DataRow dr)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
DataTable dtData = new DataTable();
string sDocNo = "";
string sSaleDate = "";
try
{
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , '000984' STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.PAY_TIME \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , '000984' ITEM_CD \n";
sQuery += " , ISNULL(SUM(CASE ISNULL(TSP.PAY_WAY_CD, '') WHEN '00' THEN ISNULL(TSP.PAY_AMT, 0) ELSE 0 END), 0) CASH_AMT \n";
sQuery += " , ISNULL(SUM(CASE ISNULL(TSP.PAY_WAY_CD, '') WHEN '02' THEN (CASE WHEN ISNULL(TSP.OCCUR_ENTRY_18, '') = '20' THEN ISNULL(TSP.PAY_AMT, 0) ELSE 0 END) ELSE 0 END), 0) CARD_UN_SUM \n";
sQuery += " , ISNULL(SUM(CASE ISNULL(TSP.PAY_WAY_CD, '') WHEN '02' THEN (CASE WHEN ISNULL(TSP.OCCUR_ENTRY_18, '') <> '20' THEN ISNULL(TSP.PAY_AMT, 0) ELSE 0 END) ELSE 0 END), 0) CARD_20_SUM \n";
sQuery += " , ISNULL(SUM(CASE ISNULL(TSP.PAY_WAY_CD, '') WHEN '00' THEN 0 \n";
sQuery += " WHEN '02' THEN 0 \n";
sQuery += " ELSE ISNULL(TSP.PAY_AMT, 0) END), 0) ETC_SUM \n";
sQuery += " , ISNULL(SUM(TSH.TOTDC_AMT), 0) TOTDC_AMT \n";
sQuery += " , ISNULL(SUM(TSH.NET_SALE_AMT), 0) SALE_AMT \n";
sQuery += " FROM POSLOG..TR_SALE_HEADER TSH \n";
sQuery += " LEFT JOIN POSLOG..TR_SALE_PAY TSP \n";
sQuery += " ON TSP.CMP_CD = TSH.CMP_CD \n";
sQuery += " AND TSP.SALE_DT = TSH.SALE_DT \n";
sQuery += " AND TSP.STOR_CD = TSH.STOR_CD \n";
sQuery += " AND TSP.POS_NO = TSH.POS_NO \n";
sQuery += " AND TSP.TRADE_NO = TSH.TRADE_NO \n";
sQuery += " AND TSP.CANCEL_DIV = '0' \n";
sQuery += " WHERE \n";
sQuery += " TSH.CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += " AND TSH.SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += " AND TSH.STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += " AND TSH.POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += " AND TSH.TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += " AND TSH.TRAIN_MODE_YN = '0' \n";
sQuery += " AND TSH.TRADE_KINDPER = '00' \n";
sQuery += " GROUP BY \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , TSH.PAY_TIME \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
m_sSendData = "";
foreach (DataRow dri in dtData.Rows)
{
double nTranDiv = 1;
if (CmUtil.GetDataRowStr(dri, "TRADE_DIV") == ItemConst.PAY_CANCEL_DIV.CANCEL) nTranDiv = -1;
m_sSendData += "";
m_sSendData += "SENDSALE"; // doc
m_sSendData += "" + m_cPosStatus.Mst.JOIN_STOR_CD + "
"; // 점포코드
m_sSendData += "" + CmUtil.GetDataRowStr(dri, "POS_NO").PadLeft(3, '0') + ""; // POS번호
sDocNo = "S" + CmUtil.MidH(CmUtil.GetDataRowStr(dri, "SALE_DT"), 2, 6) + CmUtil.MidH(CmUtil.GetDataRowStr(dri, "TRADE_NO"), 2, 3);
m_sSendData += "" + sDocNo + ""; // 증빙서류
m_sSendData += "" + m_cPosStatus.Mst.JOIN_ITEM_CD + ""; // 상품코드
m_sSendData += "" + "" + ""; // vip 코드
sSaleDate = string.Format("0:0000/00/00", CmUtil.DoubleParse(CmUtil.GetDataRowStr(dri, "SALE_DT"))) + " " + CmUtil.MidH(CmUtil.GetDataRowStr(dri, "PAY_TIME"), 0, 4);
m_sSendData += "" + sSaleDate + ""; // 매출일시
m_sSendData += "" + CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "CASH_AMT")), nTranDiv) + ""; // 현금
m_sSendData += "" + CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "CARD_UN_SUM")), nTranDiv) + ""; // 내부카드
m_sSendData += "" + CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "CARD_20_SUM")), nTranDiv) + ""; // 외부카드
m_sSendData += "" + CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "ETC_SUM")), nTranDiv) + ""; // 기타
m_sSendData += "" + CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "TOTDC_AMT")), nTranDiv) + ""; // 할인
m_sSendData += "" + CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "SALE_AMT")), nTranDiv) + ""; // 총금액
m_sSendData += "";
m_sSendData += PosConst.CRLF;
}
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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 sRet;
}
#endregion
#endregion
#region 7.창이공항
#region SIN_01_Make 생성
///
/// SIN_01_Make 생성
///
///
///
private string SIN_01_Make(DataRow dr)
{
string sQuery = string.Empty;
string sRet = UserCom.RST_ERR;
DataTable dtData = new DataTable();
double nTotalAmt = 0;
double nSubAmt = 0;
double nSumDCAmt = 0;
double nSumTax = 0;
double nDCAmt = 0;
try
{
m_sSendData = "";
sQuery = "";
sQuery += " SELECT \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , TSH.STOR_CD \n";
sQuery += " , TSH.POS_NO \n" ;
sQuery += " , TSH.SALE_DT \n" ;
sQuery += " , TSH.PAY_TIME \n" ;
sQuery += " , TSH.TRADE_NO \n" ;
sQuery += " , TSH.TRADE_DIV \n" ;
sQuery += " , TSD.ITEM_PLU_CD ITEM_CD \n";
sQuery += " , ISNULL(MI.SHTCUT_ITEMNM, '') ITEM_NM \n";
sQuery += " , ISNULL(TSD.SALE_QTY, 0) SALE_QTY \n";
sQuery += " , ISNULL(TSD.BILL_AMT, 0) BILL_AMT \n";
sQuery += " , ISNULL(TSD.APPLY_TAX_AMT, 0) APPLY_TAX_AMT \n";
sQuery += " , ISNULL(TSD.ITEM_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.SUM_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.CPI_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.COOP_CARD_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.POINT_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.CPN_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.EMP_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.SET_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.ETC_DC_AMT, 0) \n";
sQuery += " + ISNULL(TSD.EXCEP_DC_AMT, 0) ITEM_DC_AMT \n";
sQuery += " , 0 TAX1 \n";
sQuery += " , '1' TAX2 \n";
sQuery += " , 0 TAX3 \n";
sQuery += " , 0 SERV1 \n";
sQuery += " , 0 SERV2 \n";
sQuery += " , (SELECT ISNULL(MIC.ITEM_CLSS_NM, '') ITEM_CLSS_NM \n";
sQuery += " FROM POSMST..MST_ITEM_CLSS MIC \n";
sQuery += " WHERE \n";
sQuery += " MIC.CMP_CD = MI.CMP_CD \n";
sQuery += " AND MIC.ITEM_CLSS_TYPE_CD = '00' \n";
sQuery += " AND MIC.ITEM_CLSS_CD = MI.L_CLSS \n";
sQuery += " AND MIC.ITEM_CLSS_LVL_TYPE = 'L' \n";
sQuery += " AND MIC.USE_YN = '" + PosConst.MST_USE_YN.YES + "') ITEM_CLSS_NM \n";
sQuery += " FROM POSLOG..TR_SALE_HEADER TSH \n";
sQuery += " LEFT JOIN POSLOG..TR_SALE_DETAIL TSD \n";
sQuery += " ON TSD.CMP_CD = TSH.CMP_CD \n";
sQuery += " AND TSD.SALE_DT = TSH.SALE_DT \n";
sQuery += " AND TSD.STOR_CD = TSH.STOR_CD \n";
sQuery += " AND TSD.POS_NO = TSH.POS_NO \n";
sQuery += " AND TSD.TRADE_NO = TSH.TRADE_NO \n";
sQuery += " AND TSD.CANCEL_DIV = '0' \n";
sQuery += " LEFT JOIN POSMST..MST_ITEM MI \n";
sQuery += " ON MI.CMP_CD = TSD.CMP_CD \n";
sQuery += " AND MI.STOR_CD = TSD.STOR_CD \n";
sQuery += " AND MI.SUB_STOR_CD = TSD.SUB_SHOP_CD \n";
sQuery += " AND MI.ITEM_CD = TSD.ITEM_PLU_CD \n";
sQuery += " AND MI.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n";
sQuery += " WHERE \n";
sQuery += " TSH.CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += " AND TSH.SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += " AND TSH.STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += " AND TSH.POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += " AND TSH.TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += " AND TSH.TRAIN_MODE_YN = '0' \n";
sQuery += " AND TSH.TRADE_KINDPER = '00' \n";
sQuery += " ORDER BY \n";
sQuery += " TSH.CMP_CD \n";
sQuery += " , TSH.SALE_DT \n";
sQuery += " , TSH.STOR_CD \n";
sQuery += " , TSH.POS_NO \n";
sQuery += " , TSH.TRADE_NO \n";
sQuery += " , TSH.TRADE_DIV \n";
sQuery += " , TSD.SEQ \n";
sQuery = sQuery.Replace("\t", " ");
// 조회
if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK)
{
foreach (DataRow dri in dtData.Rows)
{
double nTranDiv = 1;
if (CmUtil.GetDataRowStr(dri, "TRADE_DIV") == ItemConst.PAY_CANCEL_DIV.CANCEL) nTranDiv = -1;
nSubAmt = CmUtil.DoubleAdd(nSubAmt, CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "BILL_AMT")), nTranDiv));
nDCAmt = CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "ITEM_DC_AMT")), nTranDiv);
nSumDCAmt = CmUtil.DoubleAdd(nSumDCAmt, nDCAmt);
nSumTax = CmUtil.DoubleAdd(nSumTax, CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "APPLY_TAX_AMT")), nTranDiv));
nTotalAmt = CmUtil.DoubleAdd(nTotalAmt, CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "BILL_AMT")), nTranDiv));
nTotalAmt = CmUtil.DoubleAdd(nTotalAmt, CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "APPLY_TAX_AMT")), nTranDiv));
m_sSendData += "I"; // 구분
m_sSendData += "," + CmUtil.GetDataRowStr(dri, "TRADE_NO"); // 거래번호
m_sSendData += "," + CmUtil.GetDataRowStr(dri, "ITEM_CD"); // 상품코드
m_sSendData += "," + CmUtil.GetDataRowStr(dri, "ITEM_NM"); // 상품명
m_sSendData += "," + IntParse(CmUtil.GetDataRowStr(dri, "SALE_QTY")); // 수량
m_sSendData += "," + CmUtil.DoubleMultiplication(DoubleParse(CmUtil.GetDataRowStr(dri, "BILL_AMT")), nTranDiv); // 판매금액
m_sSendData += "," + nDCAmt; // 할인금액
if (nDCAmt > 0)
m_sSendData += "," + "1"; // 할인구분 (1:할인, 0:미할인)
else
m_sSendData += "," + "0";
m_sSendData += "," + DoubleParse(CmUtil.GetDataRowStr(dri, "TAX1")); // 봉사료
m_sSendData += "," + DoubleParse(CmUtil.GetDataRowStr(dri, "TAX2")); // 부가세율
m_sSendData += "," + DoubleParse(CmUtil.GetDataRowStr(dri, "TAX3")); // 고정
m_sSendData += "," + DoubleParse(CmUtil.GetDataRowStr(dri, "SERV1")); // 고정
m_sSendData += "," + DoubleParse(CmUtil.GetDataRowStr(dri, "SERV1")); // 고정
m_sSendData += "," + CmUtil.GetDataRowStr(dri, "ITEM_CLSS_NM"); // 분류명
m_sSendData += PosConst.CRLF;
}
// 계
if (m_sSendData.Trim() != "")
{
m_sSendData += "D" + "," + "subtotal" + "," + nSubAmt + PosConst.CRLF; // 순매출
m_sSendData += "D" + "," + "disc" + "," + nSumDCAmt + PosConst.CRLF; // 할인
m_sSendData += "D" + "," + "tax2" + "," + nSumTax + PosConst.CRLF; // 부가세
m_sSendData += "D" + "," + "total" + "," + nTotalAmt; // 총매출
}
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_DEBUG,
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 sRet;
}
#endregion
#endregion
#region I/F POST방식 Request
///
/// I/F POST방식 Request
///
///
///
///
///
///
///
public string HttpPOST_SendReceive(string sIFDiv, string sUrl, string sSendData, ref string sResCD, ref string sResMsg, ref string sResData)
{
string sRet = UserCom.RST_ERR;
string sRespString = string.Empty;
string[] sResponeData = new string[4];
try
{
if (sIFDiv == ItemConst.TranInterfaceOutside.IF_CHN_01)
{
// 무역센터
sResponeData[0] = "application/soap+xml"; // ContentType
sResponeData[1] = "postsalescreate"; // SelectNodes
sResponeData[2] = "responsecode"; // res cd
sResponeData[3] = "responsemessage"; // res msg
}
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl);
byte[] reqByte = Encoding.UTF8.GetBytes(sSendData);
req.Method = "POST";
req.ContentType = sResponeData[0];
req.ContentLength = reqByte.Length;
// create our stream to send
Stream webDataStream = req.GetRequestStream();
webDataStream.Write(reqByte, 0, reqByte.Length);
// get thre response from our stream
WebResponse resp = req.GetResponse();
webDataStream = resp.GetResponseStream();
// convert the result into a string
StreamReader respStreamReader = new StreamReader(webDataStream);
string respFromServer = respStreamReader.ReadToEnd();
respStreamReader.Close();
// 파싱
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(respFromServer);
XmlNodeList xnList = xmlDoc.SelectNodes(sResponeData[1]);
foreach (XmlNode xn in xnList)
{
if (sIFDiv == ItemConst.TranInterfaceOutside.IF_CHN_01)
{
sResCD = xn[sResponeData[2]].InnerText;
sResMsg = xn[sResponeData[3]].InnerText;
sResData = respFromServer;
}
else
{
sResData = respFromServer;
}
}
sRet = UserCom.RST_OK;
}
catch(Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,
System.Reflection.MethodBase.GetCurrentMethod().Name + "()",
ex.ToString());
}
return sRet;
}
#endregion
#region 전송 상태값 저장
///
/// 전송 상태값 저장
///
///
///
///
///
///
///
///
private string IFSendFlgUpdate(DataRow dr, string sIFDiv, string sResCD, string sResMsg, string sSData, string sRData, string sSendYn)
{
int iRet = UserCom.NG;
string sRet = UserCom.RST_ERR;
string sQuery = string.Empty;
try
{
if (CmUtil.GetDataRowStr(dr, "CMP_CD").Trim() == "") return sRet;
sResMsg = sResMsg.Replace("'", "`");
sSData = sSData.Replace("'", "`");
sRData = sRData.Replace("'", "`");
sQuery = "";
sQuery += "BEGIN \n";
sQuery += " UPDATE POSLOG..LOG_SALE_IF \n";
sQuery += " SET \n";
sQuery += " RES_CD = '" + sResCD.Trim() + "' \n";
sQuery += " , RES_MSG = N'" + sResMsg.Trim() + "' \n";
sQuery += " , SDATA = N'" + sSData.Trim() + "' \n";
sQuery += " , RDATA = N'" + sRData.Trim() + "' \n";
sQuery += " , SEND_YN = '" + sSendYn + "' \n";
sQuery += " , UPD_DATE = CONVERT(VARCHAR(8), GETDATE(), 112) + REPLACE(CONVERT(VARCHAR(8), GETDATE(), 114), ':', '') \n";
sQuery += " WHERE \n";
sQuery += " CMP_CD = '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += " AND SALE_DT = '" + CmUtil.GetDataRowStr(dr, "SALE_DT")+ "' \n";
sQuery += " AND STOR_CD = '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += " AND POS_NO = '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += " AND TRADE_NO = '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += " AND IF_DIV = '" + sIFDiv.Trim() + "' \n";
sQuery += " \n";
sQuery += " IF @@ROWCOUNT = 0 \n";
sQuery += " BEGIN \n";
sQuery += " INSERT INTO POSLOG..LOG_SALE_IF \n";
sQuery += " (CMP_CD, SALE_DT, STOR_CD, POS_NO, TRADE_NO, IF_DIV, RES_CD, RES_MSG, SDATA, RDATA, SEND_YN, REG_DATE) \n";
sQuery += " VALUES( \n";
sQuery += " '" + CmUtil.GetDataRowStr(dr, "CMP_CD") + "' \n";
sQuery += " , '" + CmUtil.GetDataRowStr(dr, "SALE_DT") + "' \n";
sQuery += " , '" + CmUtil.GetDataRowStr(dr, "STOR_CD") + "' \n";
sQuery += " , '" + CmUtil.GetDataRowStr(dr, "POS_NO") + "' \n";
sQuery += " , '" + CmUtil.GetDataRowStr(dr, "TRADE_NO") + "' \n";
sQuery += " , '" + sIFDiv.Trim() + "' \n";
sQuery += " , '" + sResCD.Trim() + "' \n";
sQuery += " , N'" + sResMsg.Trim() + "' \n";
sQuery += " , N'" + sSData.Trim() + "' \n";
sQuery += " , N'" + sRData.Trim() + "' \n";
sQuery += " , '" + sSendYn.Trim() + "' \n";
sQuery += " , CONVERT(VARCHAR(8), GETDATE(), 112) + REPLACE(CONVERT(VARCHAR(8), GETDATE(), 114), ':', '') \n";
sQuery += " ) \n";
sQuery += " END \n";
sQuery += "END \n";
sQuery = sQuery.Replace("\t", " ");
iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (System.Data.SqlClient.SqlParameter[])null);
if (iRet > 0 )
{
sRet = UserCom.RST_OK;
}
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
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 sRet;
}
#endregion
#region 90일 이전 데이터 삭제
///
/// 90 이전 데이터 삭제
///
///
private string IFSendDataDelete()
{
int iRet = UserCom.NG;
string sRet = UserCom.RST_ERR;
string sQuery = string.Empty;
try
{
sQuery = "";
sQuery += " DELETE POSLOG..LOG_SALE_IF \n";
sQuery += " WHERE \n";
sQuery += " CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n";
sQuery += " AND SALE_DT <= CONVERT(VARCHAR(8), DATEADD(day, -90, GETDATE()), 112) \n";
sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n";
sQuery += " AND SEND_YN = '1' \n";
sQuery = sQuery.Replace("\t", " ");
iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (System.Data.SqlClient.SqlParameter[])null);
sRet = UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
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 sRet;
}
#endregion
#region 파일 저장
///
/// 파일 저장
///
///
///
///
///
public bool WriteFile(string sFullPath, string sFileName, string sFileData)
{
bool bRet = false;
try
{
// 디렉토리 생성
CmUtil.CreateDirectory(sFullPath);
// 파일 저장
FileStream fs = new FileStream(sFileName, FileMode.Append, FileAccess.Write);
StreamWriter sw = new StreamWriter(fs, System.Text.Encoding.Default);
try
{
sw.BaseStream.Seek(0, SeekOrigin.End);
sw.WriteLine(sFileData);
sw.Flush();
bRet = true;
}
catch
{
}
finally
{
sw.Close();
fs.Close();
}
}
catch
{
return false;
}
return bRet;
}
#endregion
#region xml 소켓통신
///
/// XMLSendSocket
///
///
///
///
///
private string XMLSendSocket(String sHostIp, int nPort, String sSendData, ref string sRecvData)
{
string sRet = UserCom.RST_ERR;
try
{
TcpClient client = new TcpClient();
client.Connect(sHostIp, nPort);
if (client == null) return sRet;
NetworkStream nsStream = client.GetStream();
StreamWriter writer = new StreamWriter(nsStream, Encoding.UTF8);
writer.AutoFlush = false;
writer.Write(sSendData);
writer.Flush();
StreamReader reader = new StreamReader(nsStream, Encoding.UTF8);
sRecvData = reader.ReadLine();
nsStream.Close();
sRet = UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
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 sRet;
}
#endregion
#region xml 파싱
///
/// xml 파싱
///
///
///
///
///
///
///
private string XmlParser(string sIFDiv, string sXMLData, string sSelectNode, ref string sResCD, ref string sResMsg)
{
string sRet = UserCom.RST_ERR;
try
{
sResCD = "99";
sResMsg = "not xml data";
if (sXMLData.Trim() == "") return sRet;
// 파싱
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(sXMLData);
XmlNodeList xnList = xmlDoc.SelectNodes(sSelectNode);
foreach (XmlNode xn in xnList)
{
if (sIFDiv == ItemConst.TranInterfaceOutside.IF_CHN_05)
{
sResCD = xn["code"].InnerText;
sResMsg = xn["message"].InnerText;
}
}
sRet = UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
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 sRet;
}
#endregion
#region 처리 거래정보 ini 저장 (왕진활현)
///
/// 처리정보 ini 저장 (왕진활현)
///
///
///
private string SavePOSInfoini(DataRow dr)
{
string sRet = UserCom.RST_ERR;
string sFilePath = @"C:\HOME\IMPORT\";
string sFileName = "POSINFO.ini";
try
{
CmUtil.CreateDirectory(sFilePath);
WinAPI.WritePrivateProfileString("POSINFO", "StoreCode", m_cPosStatus.Mst.JOIN_STOR_CD, sFilePath + sFileName); // 점포코드
WinAPI.WritePrivateProfileString("POSINFO", "Tillid", CmUtil.GetDataRowStr(dr, "POS_NO"), sFilePath + sFileName); // POS번호
WinAPI.WritePrivateProfileString("POSINFO", "ItemCode", m_cPosStatus.Mst.JOIN_ITEM_CD, sFilePath + sFileName); // 상품코드
WinAPI.WritePrivateProfileString("POSINFO", "PathName", sFilePath, sFilePath + sFileName); // 경로
WinAPI.WritePrivateProfileString("POSINFO", "FileName", "possalesdata.txt", sFilePath + sFileName); // 상품코드
WinAPI.WritePrivateProfileString("DATAINFO", "LASTTXDATE", CmUtil.GetDataRowStr(dr, "SALE_DT"), sFilePath + sFileName); // 거래일자
WinAPI.WritePrivateProfileString("DATAINFO", "LASTDOCNO", CmUtil.GetDataRowStr(dr, "TRADE_NO"), sFilePath + sFileName); // 최종거래번호
// POSINFO.INI 파일을 CapitaInterface.zip 파일로 압축
bool bRet = CmUtil.ZipFile(sFilePath, sFilePath + "CapitaInterface.zip", "POSINFO.ini");
if (bRet == true) sRet = UserCom.RST_OK;
}
catch (Exception ex)
{
UserLog.WriteLogFile(UserCom.LOG_ERROR,
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 sRet;
}
#endregion
#region 글로벌 숫자 변환
///
/// 문자열의 숫자(Int)로 변환
///
///
///
public int IntParse(string sValue)
{
return (int)DoubleParse(sValue);
}
///
/// 문자열의 숫자(Long)로 변환
///
///
///
public long LongParse(string sValue)
{
return (long)DoubleParse(sValue);
}
///
/// 문자열의 숫자(Double)로 변환
///
///
///
public double DoubleParse(string sValue)
{
double dValue = 0;
try
{
if (sValue.Trim().Length > 0)
{
// 화폐 문자열 이면 글로벌 변환 처리
if (sValue.Trim().Contains(m_cPosStatus.Global.m_stCultureMaster.strGroupingSymbol) == true || sValue.Trim().Contains(m_cPosStatus.Global.m_stCultureMaster.strDecimalSymbol) == true)
dValue = m_cPosStatus.Global.CurrencyTONumeric(sValue.Trim());
else
dValue = double.Parse(sValue.Trim());
}
}
catch { }
return dValue;
}
#endregion
}
}