commit 60754b31f8061740727387fc254015eb0b4bf105 Author: crusader Date: Sun Jun 16 14:12:09 2019 +0900 6/14 초기화 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3c4efe2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,261 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +project.fragment.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +#*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config +# NuGet v3's project.json files produces more ignoreable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# JetBrains Rider +.idea/ +*.sln.iml + +# CodeRush +.cr/ + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc \ No newline at end of file diff --git a/Agent/Database/Activator.cs b/Agent/Database/Activator.cs new file mode 100644 index 0000000..c5d59b1 --- /dev/null +++ b/Agent/Database/Activator.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : Database 관련 클래스 Activator +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.Service +{ + public class Activator : InitServiceAbstract + { + /// + /// 프로젝트 로드의 주진입점을 정의합니다. + /// + public Activator() + { + } + + /// + /// + /// + /// + /// + public override object InitServiceInstance(string sClassNm) + { + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Starting !!!"); + + object retObj = null; + + //클래스 찾아오기 위함 + switch (sClassNm) + { + case ServiceLists.AGENT_DATABASE.DATABASE_MSSQL: + { + Cosmos.Database.DatabaseMssql agentClass = new Cosmos.Database.DatabaseMssql(); + retObj = agentClass; + break; + } + case ServiceLists.AGENT_DATABASE.DATABASE_ORACLE: + { + //Cosmos.Database.DatabaseOracle agentClass = new Cosmos.Database.DatabaseOracle(); + //retObj = agentClass; + break; + } + } + + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Completed !!!"); + + return retObj; + + } + } +} diff --git a/Agent/Database/Database.csproj b/Agent/Database/Database.csproj new file mode 100644 index 0000000..9ec02ee --- /dev/null +++ b/Agent/Database/Database.csproj @@ -0,0 +1,80 @@ + + + + + Debug + AnyCPU + {057CA9DA-C2C8-4873-B914-92E115F94659} + Library + Properties + Cosmos.Database + Agent.Database + v4.0 + 512 + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + ..\..\..\BIN\Agent.Database.XML + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\BIN\Cosmos.BaseFrame.dll + + + False + ..\..\..\BIN\Cosmos.UserFrame.dll + + + + + + + + + + + + + + + + + {a5b7accd-79eb-4261-bd36-01ab484ad8e3} + Common + + + + + copy .\IC\Agent.Database.dll .\Agent.Database.dll + + + copy .\Agent.Database.dll .\IC\Agent.Database.dll + + + \ No newline at end of file diff --git a/Agent/Database/DatabaseMssql.cs b/Agent/Database/DatabaseMssql.cs new file mode 100644 index 0000000..6ded456 --- /dev/null +++ b/Agent/Database/DatabaseMssql.cs @@ -0,0 +1,132 @@ +using System.Data.SqlClient; +using System.Data; +using System.Diagnostics; + +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : MSSQL DB 관련 처리 +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.Database +{ + public class DatabaseMssql : IDatabaseSQL + { + private SqlDB sqlDb = null; + + public bool Begin() + { + return sqlDb.DBBeginTransaction(); + } + + public bool Commit() + { + return sqlDb.DBTransactionCommit(); + } + + public bool Rollback() + { + return sqlDb.DBTransactionRollback(); + } + + public void Close() + { + sqlDb.DBClose(); + } + + /// + /// SQL DataTable를 이용한 Select + /// return -> 1:OK, -1:Connection 정보 에러, -2:SQL 에러, -3:기타 에러, 0:Select 결과 없음 + /// + /// + /// + /// + public int DBSelect(string sQuery, out DataTable outDtReturn) + { + int iReturn = -9; + DataTable dtReturn = null; + + string strCommand = sQuery; + CommandType sqlCommandType = CommandType.Text; + + //System.Diagnostics.Debug.Print("SQL=" + sQuery); + iReturn = sqlDb.DBDataTableSelect(strCommand, sqlCommandType, (SqlParameter[])null, out dtReturn); + + outDtReturn = dtReturn; + return iReturn; + } + + /// + /// return -> 1:OK, -1:Connection 에러, -2:SQL 에러, -3:기타 에러, -4:적용된 Row 없음 + /// + /// + /// + public int DBExecuteNonQuery(string sQuery) + { + int iReturn = 0; + + CommandType sqlCommandType = CommandType.Text; + + iReturn = sqlDb.DBExecuteNonQuery(sQuery, sqlCommandType, (SqlParameter[])null); + + return iReturn; + } + + /// + /// return -> 1:OK, -1:Connection 에러, -2:SQL 에러, -3:기타 에러, -4:적용된 Row 없음 + /// + /// + /// + public int DBExecuteNonQuery(string[] sQuery) + { + int iReturn = 0; + + CommandType sqlCommandType = CommandType.Text; + + iReturn = sqlDb.DBExecuteNonQuery(sQuery, sqlCommandType, (SqlParameter[])null); + + return iReturn; + } + + /// + /// return -> 1:OK, -1:Connection 에러, -2:SQL 에러, -3:기타 에러, -4:적용된 Row 없음 + /// + /// + /// + public int DBExecuteNonQuery(string[] sQuery, bool bStandAlone) + { + int iReturn = 0; + + CommandType sqlCommandType = CommandType.Text; + + iReturn = sqlDb.DBExecuteNonQuery(sQuery, sqlCommandType, (SqlParameter[])null, bStandAlone); + + return iReturn; + } + + /// + /// MSSQL Database Conntction String + /// + /// + /// + /// + /// + public bool SetDBConnectionString(string pDataSource, string pInitialCatalog, string pUID, string pPassword) + { + bool bReturn = false; + + if(sqlDb != null) + { + if (sqlDb.IsDBOpen()) sqlDb.DBClose(); + } + + sqlDb = new SqlDB(pDataSource, pInitialCatalog, pUID, pPassword); + + bReturn = sqlDb.IsDBOpen(); + + return bReturn; + } + + } +} diff --git a/Agent/Database/Properties/AssemblyInfo.cs b/Agent/Database/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5bd8507 --- /dev/null +++ b/Agent/Database/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("Database")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Database")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("dab8af19-a211-4c3f-87a1-79b22ffca956")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Agent/InterfaceOutside/Activator.cs b/Agent/InterfaceOutside/Activator.cs new file mode 100644 index 0000000..fd4d85f --- /dev/null +++ b/Agent/InterfaceOutside/Activator.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : TranInterfaceOutside 관련 클래스 Activator +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.Service +{ + public class Activator : InitServiceAbstract + { + /// + /// 프로젝트 로드의 주진입점을 정의합니다. + /// + public Activator() + { + } + + /// + /// + /// + /// + /// + public override object InitServiceInstance(string sClassNm) + { + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Starting !!!"); + + object retObj = null; + + //클래스 찾아오기 위함 + switch (sClassNm) + { + case ServiceLists.AGENT_TranInterfaceOutside.TIFO_MAIN: + { + Cosmos.TranInterfaceOutside.TranInterfaceOutside agentClass = new Cosmos.TranInterfaceOutside.TranInterfaceOutside(); + retObj = agentClass; + break; + } + } + + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Completed !!!"); + + return retObj; + + } + } +} \ No newline at end of file diff --git a/Agent/InterfaceOutside/NetworkFtp.cs b/Agent/InterfaceOutside/NetworkFtp.cs new file mode 100644 index 0000000..f91fae5 --- /dev/null +++ b/Agent/InterfaceOutside/NetworkFtp.cs @@ -0,0 +1,181 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Net; +using System.Collections; +using System.Diagnostics; +using System.Runtime.Serialization.Formatters.Binary; +using System.Data; + +using System.Net.Sockets; +using System.Threading; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : FTP 다운로드 +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.TranInterfaceOutside +{ + public class NetworkFtp : INetworkFTP + { + private readonly string LOCAL_DOWN_PATH = BaseCom.NxRootPath + @"DOWN\"; //Download File Location (다운로드 파일위치) + + /// + /// StateServer Object (StateServer 객체) + /// + public StateServer StateObject = (StateServer)StateServer.GetInstance(); + /// + /// POS Status Value (POS 상태값) + /// + private PosStatus m_cPosStatus = null; + + private FTP m_ClsFtp; + + public NetworkFtp() + { + m_cPosStatus = (PosStatus)StateObject.POS; + } + + /// + /// FTP 서버에 Connect + /// + /// + /// + /// + /// + /// + /// 0 : 정상접속, -1:시간초과, -2:로그인 실패, -3:서버접속 실패, -4:지원하지 않는 시스템 + public int Connect(string sServer, string sUserId, string sPassword, int iTimeOutSeconds, int iPort) + { + int nReturn = -9; + + try + { + m_ClsFtp = new FTP((iPort == 0) ? sServer : sServer + ":" + iPort, sUserId, sPassword); + + if (m_ClsFtp != null) nReturn = 0; + else nReturn = -1; + + ////m_ClsFtp = new ClsFtp(sServer, sUserId, sPassword, iTimeOutSeconds, iPort); + + ////if ((nReturn = m_ClsFtp.Connect()) != 0) + ////{ + //// //MessageBox.Show("FTP Server Connect Error !!! [" + nReturn.ToString() + "]"); + //// return nReturn; + ////} + + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkFtp.Connect()", e.Message); + return nReturn; + } + + return nReturn; + } + + /// + /// + /// + /// + /// + /// + /// 0:정상종료, -1:Not Connected, -2:Binary Mode set failed, -3: failed local file Create, -4:socket 에러, -5:remote file 없슴, -6:정상수신실패, -7: 파일사이즈 틀림 + public int Download(string sSvrDirectory, string sLocalDirectory, string sFileNm, string sFtpMode = PosConst.FTP_CONN_TYPE.PASSIVE) + { + string sMsg = ""; + return Download(sSvrDirectory, sLocalDirectory, sFileNm, ref sMsg, sFtpMode); + } + public int Download(string sSvrDirectory, string sLocalDirectory, string sFileNm, ref string sMsg, string sFtpMode = PosConst.FTP_CONN_TYPE.PASSIVE) + { + int nReturn = -9; + bool bRet = false; + try + { + if (CmUtil.RightH(sLocalDirectory, 1) != "\\") sLocalDirectory += "\\"; + + if (Directory.Exists(sLocalDirectory) == false) Directory.CreateDirectory(sLocalDirectory); + + bRet = m_ClsFtp.Download(sSvrDirectory + sFileNm, sLocalDirectory + sFileNm, ref sMsg, sFtpMode); + + if (bRet) nReturn = 0; + else nReturn = -1; + ////if ((nReturn = m_ClsFtp.Connect()) != 0) + ////{ + //// return nReturn; + ////} + + ////string sDir = m_ClsFtp.ChangeDir(sSvrDirectory); + + ////nReturn = m_ClsFtp.Download(sLocalDirectory, sFileNm, true); + ////if (nReturn < 0 && File.Exists(BaseCom.NxDownPath + sFileNm + ".ftp") == true) + ////{ + //// File.Delete(BaseCom.NxDownPath + sFileNm + ".ftp"); + ////} + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkFtp.Download()", e.Message); + + sMsg = sFileNm + " " + e.Message; + return nReturn; + } + + return nReturn; + } + + /// + /// FTP서버와의 연결을 종료 + /// + public void Disconnect() + { + //m_ClsFtp.Close(); + //m_ClsFtp.cleanup(); + } + + /// + /// 정해진 디렉토리에 정해진 파일을 업로드 + /// + /// + /// + /// + /// 0:정상완료, -1:Not Connected, -2: data socket create error, -3: file write 실패, -4:socket error, -5: 정상처리 실패(서버) + public int Upload(string sSvrDirectory, string sLocalDirectory, string sFileNm) + { + int nReturn = -9; + bool bRet = false; + + try + { + bRet = m_ClsFtp.Upload(sLocalDirectory + sFileNm, sSvrDirectory + sFileNm); + + if (bRet) nReturn = 0; + else nReturn = -1; + ////if ((nReturn = m_ClsFtp.Connect()) != 0) + ////{ + //// return nReturn; + ////} + + ////string sDir = m_ClsFtp.ChangeDir(sSvrDirectory); + + ////nReturn = m_ClsFtp.Upload(sLocalDirectory, sFileNm, true); + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkFtp.Upload()", e.Message); + + return nReturn; + } + return nReturn; + } + } +} diff --git a/Agent/InterfaceOutside/Properties/AssemblyInfo.cs b/Agent/InterfaceOutside/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e8edc04 --- /dev/null +++ b/Agent/InterfaceOutside/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("TranInterfaceOutside")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("TranInterfaceOutside")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("21f97fce-451b-4bfd-922a-565e98bf87c6")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Agent/InterfaceOutside/TranInterfaceOutside.cs b/Agent/InterfaceOutside/TranInterfaceOutside.cs new file mode 100644 index 0000000..0430a68 --- /dev/null +++ b/Agent/InterfaceOutside/TranInterfaceOutside.cs @@ -0,0 +1,1979 @@ +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 + } +} diff --git a/Agent/InterfaceOutside/TranInterfaceOutside.csproj b/Agent/InterfaceOutside/TranInterfaceOutside.csproj new file mode 100644 index 0000000..e17f8ec --- /dev/null +++ b/Agent/InterfaceOutside/TranInterfaceOutside.csproj @@ -0,0 +1,85 @@ + + + + + Debug + AnyCPU + {7BA1E882-7E84-4A09-AE93-0447624BB13E} + Library + Properties + Cosmos.TranInterfaceOutside + Agent.TranInterfaceOutside + v4.0 + 512 + + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\BIN\Cosmos.BaseFrame.dll + + + ..\..\..\BIN\Cosmos.ServiceProvider.dll + + + ..\..\..\BIN\Cosmos.UserFrame.dll + + + + + + + + + + + + + + + + + + + + + {a5b7accd-79eb-4261-bd36-01ab484ad8e3} + Common + + + + + copy .\IC\Agent.TranInterfaceOutside.dll .\Agent.TranInterfaceOutside.dll + + + copy .\Agent.TranInterfaceOutside.dll .\IC\Agent.TranInterfaceOutside.dll + + + \ No newline at end of file diff --git a/Agent/KDS/Activator.cs b/Agent/KDS/Activator.cs new file mode 100644 index 0000000..18784a9 --- /dev/null +++ b/Agent/KDS/Activator.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : KDS 관련 클래스 Activator +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.Service +{ + public class Activator : InitServiceAbstract + { + /// + /// 프로젝트 로드의 주진입점을 정의합니다. + /// + public Activator() + { + } + + /// + /// + /// + /// + /// + public override object InitServiceInstance(string sClassNm) + { + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Starting !!!"); + + object retObj = null; + + //클래스 찾아오기 위함 + switch (sClassNm) + { + case ServiceLists.AGENT_KDS.KDS_MAIN: + { + Cosmos.KDS.KDSMain agentClass = new Cosmos.KDS.KDSMain(); + retObj = agentClass; + break; + } + } + + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Completed !!!"); + + return retObj; + + } + } +} \ No newline at end of file diff --git a/Agent/KDS/Common.cs b/Agent/KDS/Common.cs new file mode 100644 index 0000000..02aa7e0 --- /dev/null +++ b/Agent/KDS/Common.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Cosmos.KDS +{ + public class KDSItem + { + public string sOrderType; + public string sFloorCd; + public string sTableNo; + public string sKtchSysCd; + public int nSeq; + public string sCmpCd; + public string sBrandCd; + public string sStorCd; + public string sPosNo; + public string sTradeNo; + public string sSaleDt; + public string sPosType; + public string sItemCd; + public string sItemDiv; + public string sItemNm; + public int nQty; + public string sPackDiv; + public string sSetMenuCd; + public string sOrdTime; + public string sCancelDiv; + public string sOrgBillPosNo; + public string sOrgBillDt; + public string sOrgBillNo; + public string sKtchSysUseDiv; + public string sKtchKdsIp; + public string sKtchKdsPort; + public string sErrorCd; + public string sSendYn; + public string sResendYn; + public string sFiller1; + public string sFiller2; + public string sFiller3; + public string sFiller4; + public string sFiller5; + } +} diff --git a/Agent/KDS/KDS.csproj b/Agent/KDS/KDS.csproj new file mode 100644 index 0000000..1503b8b --- /dev/null +++ b/Agent/KDS/KDS.csproj @@ -0,0 +1,89 @@ + + + + + Debug + AnyCPU + {DF8A2088-9F76-47DE-9B50-7AA93FE359A4} + Library + Properties + Cosmos.KDS + Agent.KDS + v4.0 + 512 + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\BIN\Cosmos.BaseFrame.dll + + + ..\..\..\BIN\Cosmos.ServiceProvider.dll + + + ..\..\..\BIN\Cosmos.UserFrame.dll + + + False + ..\..\..\BIN\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + {670a81be-cee3-4c29-846d-a37652ca270d} + CommonManager + + + {a5b7accd-79eb-4261-bd36-01ab484ad8e3} + Common + + + + + copy .\IC\Agent.KDS.dll .\Agent.KDS.dll + + + copy .\Agent.KDS.dll .\IC\Agent.KDS.dll + + + \ No newline at end of file diff --git a/Agent/KDS/KDSMain.cs b/Agent/KDS/KDSMain.cs new file mode 100644 index 0000000..209501a --- /dev/null +++ b/Agent/KDS/KDSMain.cs @@ -0,0 +1,1145 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Data.SqlClient; +using System.Data; + +using Cosmos.Common; +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.CommonManager; +using Cosmos.ServiceProvider; + +using Newtonsoft.Json; + +namespace Cosmos.KDS +{ + public class KDSMain : IWatcher + { + #region 클래스 변수 선언 + /// + /// StateServer Object (StateServer 객체) + /// + private StateServer StateObject = (StateServer)StateServer.GetInstance(); + + /// + /// POS Status Value (POS 상태값) + /// + private PosStatus m_cPosStatus = null; + + /// + /// KPS Thread (KPS 스레드) + /// + private Thread m_tKDSProc = null; + + /// + /// KPS Proc Operation Yes/No (KPS Proc 작동여부) + /// + private bool m_KDSProcRunning = true; + + /// + /// MSSQL DB 관련 객체 + /// + private static SqlDB sqlDb = null; + + // 대기시간 + //private int WAIT_TIME = 3000; + private int WAIT_TIME = 1000; + + // Delay time to close socket + private int m_iTimeout = 5000; + + // 전송 소켓 + private static TcpSocket m_sendSocket = null; + + // KDS 전문 헤더 길이 + private const int DATA_LEN_SIZE = 5; + + //17.08.22 dkshin SS 해피오더 + private SManager sManager = new SManager(); + private IHappyOrderList m_cHappyOrder = null; // 해피오더 서비스 처리 + private ISaleCompleteUs m_cRecService = null; + #endregion 클래스 변수 선언 + + #region 생성자 + public KDSMain() + { + m_cPosStatus = (PosStatus)StateObject.POS; + m_cHappyOrder = (IHappyOrderList)sManager.InitServiceInstance(ServiceLists.BSV_SALE.DLL, ServiceLists.BSV_SALE.HAPPY_ORDER_LIST);//17.08.22 dkshin SS 해피오더 + m_cRecService = (ISaleCompleteUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.SALE_COMPLETE);//17.08.22 dkshin SS 해피오더 + } + #endregion + + #region KDS 데몬 기동/종료 + public void Start() + { + try + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "KDS Start"); + + // Database Connection + sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, m_cPosStatus.Base.LocalDbCatalog, m_cPosStatus.Base.LocalDbUserID, m_cPosStatus.Base.LocalDbPassword); + + m_tKDSProc = new Thread(new ThreadStart(KDSExecuteProc)); + m_KDSProcRunning = true; + m_tKDSProc.Start(); + } + 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); + } + } + + public void Stop() + { + try + { + m_KDSProcRunning = false; + + int count = 0; + while(count < 10) + { + if (m_tKDSProc != null && m_tKDSProc.IsAlive) m_KDSProcRunning = false; + else break; + + count++; + Thread.Sleep(100); + } + + if (count == 10) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.INFO_LEVEL, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "Force KDS Agent Stop!!!"); + m_tKDSProc.Abort(); + } + + UserLog.WriteLogFile(UserCom.LOG_IOS, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "KDS Stop"); + } + 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); + } + } + #endregion + + #region Thread Main + private void KDSExecuteProc() + { + string sIp = ""; + int iPort = -1; + + //#20180202 KDS 전송 실패시 3회 재시도, 최초 한번 영수증 출력 start + //기존 + //string sSendFlag = "9"; + //#20180202 KDS 전송 실패시 3회 재시도, 최초 한번 영수증 출력 end + + while (m_KDSProcRunning) + { + try + { + //// Set Wait Time + //Thread.Sleep((int)WAIT_TIME); + + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "KDSSendItemMake Start"); + */ + // KDS Send Item Make + KDSSendItemMake(); + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "KDSSendItemMake End"); + */ + Hashtable htKDSSendItem = new Hashtable(); + + //#20180202 KDS 전송 실패시 3회 재시도, 최초 한번 영수증 출력 start + //기존 + //string[] saKey = new string[4]; + //변경 + string[] saKey = new string[5]; + //#20180202 KDS 전송 실패시 3회 재시도, 최초 한번 영수증 출력 end + + Hashtable htSendJsonData = GetKDSSendItem(ref htKDSSendItem, ref sIp, ref iPort, ref saKey); + + //if(sIp == "" || iPort == -1 || htSendJsonData == null || htSendJsonData.Count == 0) + //{ + // continue; + //} + + if (sIp != "" && iPort != -1 && htSendJsonData != null && htSendJsonData.Count != 0) + { + //#20180202 KDS 전송 실패시 3회 재시도, 최초 한번 영수증 출력 start + string sSendFlag = "9"; + //#20180202 KDS 전송 실패시 3회 재시도, 최초 한번 영수증 출력 end + + string sReturn = SendProcess(sIp, iPort, m_iTimeout, htSendJsonData); + + if (sReturn == UserCom.RST_OK) + { + sSendFlag = "1"; + + //#14180 JJ 코엑스_ 2번포스 주방영수증에서 레시피 출력 안되는 증상,phj start + //2018-03-06 + //MST_KTCH_ORD_MSG 테이블은 KPS, KDS 모두 접근하는 테이블인데 (KPS, KDS 기능 모두 사용하는 점포) + //먼저 KDS 스레드에서 MST_KTCH_ORD_MSG 검색해서 MST_KDS_ORD_MSG 테이블로 인서트 성공하면 + //해당 주방상품 데이터 삭제 시키기 때문에 이 후에 KPS 스레드가 돌면 해당 주방상품의 주방 영수증이 출력 안될 수 있다. + //그렇기 때문에 아래에 함수 주석처리한다. + /* + //17.08.22 dkshin SS 해피오더 - KDS 전송 성공 후 주문 목록 데이타 삭제(KDS 보낼 때 주문 목록 데이타를 검색해서 보내기 때문에) + //Hashtable htOrderHeader = (Hashtable)htSendJsonData["ORDERHEADER"]; + Hashtable htOrderHeader = (Hashtable)htSendJsonData["HEADER"]; + m_cHappyOrder.DeleteSSHappyOrderMSG(htOrderHeader["TRAN_NO"].ToString()); + */ + //#14180 JJ 코엑스_ 2번포스 주방영수증에서 레시피 출력 안되는 증상,phj end + } + //17.08.22 dkshin SS 해피오더 - KDS 전송 실패 시 영수증 출력 + else + { + //#20180202 KDS 전송 실패시 3회 재시도, 최초 한번 영수증 출력 start + //기존 + /* + ArrayList m_sPrintData = new ArrayList(); + Hashtable[] hsOrderItem = (Hashtable[])htSendJsonData["ORDER_ITEM"]; + + for (int i = 0; i < hsOrderItem.Length; i++) + { + Column.TR_HPORD.HPORD_ITEM item = new Column.TR_HPORD.HPORD_ITEM(); + item.GoodsName = hsOrderItem[i]["ITEM_NM"].ToString(); + item.Qty = hsOrderItem[i]["ITEM_QTY"].ToString(); + m_sPrintData.Add(item); + } + + m_cRecService.HappyOrderKDSPrint(m_sPrintData);// + */ + //변경 + if (saKey[4] == "0") + { + ArrayList m_sPrintData = new ArrayList(); + Hashtable[] hsOrderItem = (Hashtable[])htSendJsonData["ORDER_ITEM"]; + + for (int i = 0; i < hsOrderItem.Length; i++) + { + Column.TR_HPORD.HPORD_ITEM item = new Column.TR_HPORD.HPORD_ITEM(); + item.GoodsName = hsOrderItem[i]["ITEM_NM"].ToString(); + item.Qty = hsOrderItem[i]["ITEM_QTY"].ToString(); + m_sPrintData.Add(item); + } + + m_cRecService.HappyOrderKDSPrint(m_sPrintData);// + } + //#20180202 KDS 전송 실패시 3회 재시도, 최초 한번 영수증 출력 end + + } + + UpdateKDSSendFlag(saKey[0], saKey[1], saKey[2], saKey[3], sSendFlag); + } + + int nNowSleepTerm = 0; + while (nNowSleepTerm < WAIT_TIME) + { + if (m_KDSProcRunning == false) break; + Thread.Sleep(100); + nNowSleepTerm += 100; + } + } + 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); + } + } + } + #endregion + + #region 데이터 이행 처리(주방주문데이터 -> KDS) + /// + /// MST_KTCH_ORD_MSG(주방주문데이터) 에서 KDS 전송 데이터 조회 + /// + public bool KDSSendItemMake() + { + bool bRtn = false; + string sQuery = ""; + + Hashtable htKDSSendingItem = new Hashtable(); + + try + { + #region 복합매장 적용 이전 버전 + //sQuery += "SELECT A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, B.KTCH_SYS_CD, A.SEQ "; + //sQuery += " , A.CMP_CD, A.BRAND_CD, A.STOR_CD, A.POS_NO, A.TRADE_NO, A.SALE_DT "; + //sQuery += " , A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM, A.SALE_QTY, A.PACK_DIV "; + //sQuery += " , A.SET_MENU_CD, A.ORD_TIME, A.CANCEL_DIV, A.ORG_BILL_POSNO, A.ORG_BILLDT, A.ORG_BILL_NO "; + //sQuery += " , A.SUB_MEMO_DIV, A.RESEND_YN, C.KTCH_SYS_USE_DIV, C.KTCH_DSP_IP, C.KTCH_DSP_PORT, C.FILLER1 "; + //sQuery += " , C.FILLER2, C.FILLER3, C.FILLER4, C.FILLER5 "; + //sQuery += " FROM POSMST..MST_KTCH_ORD_MSG A "; + //sQuery += " , POSMST..MST_KTCH_DEVICE_ITEM B "; + //sQuery += " , POSMST..MST_KTCH_DEVICE C "; + //sQuery += " WHERE A.SEND_YN = '0' "; + //sQuery += " AND A.ITEM_DIV IN ('0', '1', '2', '3', '4') "; + //sQuery += " AND B.ITEM_CD = A.ITEM_CD "; + //sQuery += " AND B.FLOOR_CD = A.FLOOR_CD "; + //sQuery += " AND B.KTCH_SYS_CD = C.KTCH_SYS_CD "; + //sQuery += " AND C.KTCH_SYS_DIV = '" + PosConst.KTCH_SYS_DIV.KDS + "' "; + //sQuery += " AND C.USE_YN = '" + PosConst.MST_USE_YN.YES + "' "; + + //DataTable dtData = null; + //if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) != UserCom.OK) + //{ + // UserLog.WriteLogFile(UserCom.LOG_DEBUG, + // UserCom.WARNING_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 (함수명)) + // sQuery); + // return; + //} + //foreach(DataRow dr in dtData.Rows) + //{ + // KDSItem cKDSItem = new KDSItem(); + + // cKDSItem.sOrderType = CmUtil.GetDataRowStr(dr, "ORD_DIV"); + // cKDSItem.sFloorCd = CmUtil.GetDataRowStr(dr, "FLOOR_CD"); + // cKDSItem.sTableNo = CmUtil.GetDataRowStr(dr, "TBL_NO"); + // cKDSItem.sKtchSysCd = CmUtil.GetDataRowStr(dr, "KTCH_SYS_CD"); + // cKDSItem.nSeq = CmUtil.GetDataRowInt(dr, "SEQ"); + // cKDSItem.sCmpCd = CmUtil.GetDataRowStr(dr, "CMP_CD"); + // cKDSItem.sBrandCd = CmUtil.GetDataRowStr(dr, "BRAND_CD"); + // cKDSItem.sStorCd = CmUtil.GetDataRowStr(dr, "STOR_CD"); + // cKDSItem.sPosNo = CmUtil.GetDataRowStr(dr, "POS_NO"); + // cKDSItem.sTradeNo = CmUtil.GetDataRowStr(dr, "TRADE_NO"); + // cKDSItem.sSaleDt = CmUtil.GetDataRowStr(dr, "SALE_DT"); + // cKDSItem.sPosType = CmUtil.GetDataRowStr(dr, "POS_TYPE"); + // cKDSItem.sItemCd = CmUtil.GetDataRowStr(dr, "ITEM_CD"); + // cKDSItem.sItemDiv = CmUtil.GetDataRowStr(dr, "ITEM_DIV"); + // cKDSItem.sItemNm = CmUtil.GetDataRowStr(dr, "SHTCUT_ITEMNM"); + // cKDSItem.nQty = CmUtil.GetDataRowInt(dr, "SALE_QTY"); + // cKDSItem.sPackDiv = CmUtil.GetDataRowStr(dr, "PACK_DIV"); + // cKDSItem.sSetMenuCd = CmUtil.GetDataRowStr(dr, "SET_MENU_CD"); + // cKDSItem.sOrdTime = CmUtil.GetDataRowStr(dr, "ORD_TIME"); + // cKDSItem.sCancelDiv = CmUtil.GetDataRowStr(dr, "CANCEL_DIV"); + // cKDSItem.sOrgBillPosNo = CmUtil.GetDataRowStr(dr, "ORG_BILL_POSNO"); + // cKDSItem.sOrgBillDt = CmUtil.GetDataRowStr(dr, "ORG_BILL_DT"); + // cKDSItem.sOrgBillNo = CmUtil.GetDataRowStr(dr, "ORG_BILL_NO"); + // cKDSItem.sKtchSysUseDiv = CmUtil.GetDataRowStr(dr, "KTCH_SYS_USE_DIV"); + // cKDSItem.sKtchKdsIp = CmUtil.GetDataRowStr(dr, "KTCH_DSP_IP"); + // cKDSItem.sKtchKdsPort = CmUtil.GetDataRowStr(dr, "KTCH_DSP_PORT"); + // cKDSItem.sResendYn = CmUtil.GetDataRowStr(dr, "RESEND_YN"); + // cKDSItem.sFiller1 = CmUtil.GetDataRowStr(dr, "FILLER1"); + // cKDSItem.sFiller2 = CmUtil.GetDataRowStr(dr, "FILLER2"); + // cKDSItem.sFiller3 = CmUtil.GetDataRowStr(dr, "FILLER3"); + // cKDSItem.sFiller4 = CmUtil.GetDataRowStr(dr, "FILLER4"); + // cKDSItem.sFiller5 = CmUtil.GetDataRowStr(dr, "FILLER5"); + + // cKDSItem.sSendYn = "0"; + // cKDSItem.sErrorCd = "0000"; + + // htKDSSendingItem.Add(htKDSSendingItem.Count, cKDSItem); + //} + + //if (htKDSSendingItem.Count > 0) + //{ + // InsertIntoKDS(htKDSSendingItem); + //} + #endregion 복합매장 적용 이전 버전 + + #region 연습모드 적용 이전 버전 + //sQuery = "SELECT A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ, A.CMP_CD, A.BRAND_CD, A.STOR_CD, A.SUB_STOR_CD, A.POS_NO, A.TRADE_NO, A.SALE_DT, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM \n" + // + " , A.SALE_QTY, A.PACK_DIV, A.SET_MENU_CD, A.ORD_TIME, A.CANCEL_DIV, A.SUB_MEMO_DIV, A.RESEND_YN \n" + // + " , A.MSG1, A.MSG2, A.MSG3, A.FILLER2 AS ETC_ORD_FLAG, A.FILLER3 AS ADD_ORD_FLAG \n" + // + " , C.SUB_STOR_CD, C.KTCH_SYS_CD \n" + // + " , C.KTCH_SYS_USE_DIV, C.KTCH_DSP_IP, C.KTCH_DSP_PORT, C.FILLER1, C.FILLER2, A.FILLER3, C.FILLER4, C.FILLER5 \n" + // + " FROM POSMST..MST_KTCH_ORD_MSG A \n" + // + " , POSMST..MST_KTCH_DEVICE_ITEM B WITH(NOLOCK) \n" + // + " , POSMST..MST_KTCH_DEVICE C WITH(NOLOCK) \n" + // + " WHERE A.CMP_CD = B.CMP_CD AND A.STOR_CD = B.STOR_CD AND A.SUB_STOR_CD = B.SUB_STOR_CD AND A.ITEM_CD = B.ITEM_CD \n" + // + " AND (A.FLOOR_CD = B.FLOOR_CD OR '999' = B.FLOOR_CD) \n" + // + " AND B.CMP_CD = C.CMP_CD AND B.STOR_CD = C.STOR_CD \n" + // + " AND B.SUB_STOR_CD = C.SUB_STOR_CD AND B.KTCH_SYS_CD = C.KTCH_SYS_CD \n" + // + " AND A.ORD_DIV = '0' \n" + // + " AND A.SEND_YN = '0' \n" + // + " AND A.ITEM_DIV IN ('0', '1', '2', '3', '4') \n" + // + " AND A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + // + " AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + // + " AND B.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" + // + " AND C.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" + // + " AND C.KTCH_SYS_DIV = '" + PosConst.KTCH_SYS_DIV.KDS + "' \n" + // + " ORDER BY C.SUB_STOR_CD, C.KTCH_SYS_CD \n" + // ; + #endregion + + #region KPS + KDS 중복사용 적용 이전 버전 + ////sQuery = "SELECT A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ, A.CMP_CD, A.BRAND_CD, A.STOR_CD, A.SUB_STOR_CD, A.POS_NO, A.TRADE_NO, A.SALE_DT, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM \n" + //sQuery = "SELECT A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ, A.CMP_CD, A.BRAND_CD, A.STOR_CD, A.POS_NO, A.TRADE_NO, A.SALE_DT, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM \n" + // + " , A.SALE_QTY, A.PACK_DIV, A.SET_MENU_CD, A.ORD_TIME, A.CANCEL_DIV, A.SUB_MEMO_DIV, A.RESEND_YN \n" + // + " , A.MSG1, A.MSG2, A.MSG3, A.FILLER2 AS ETC_ORD_FLAG, A.FILLER3 AS ADD_ORD_FLAG \n" + // + " , C.SUB_STOR_CD, C.KTCH_SYS_CD \n" + // + " , C.KTCH_SYS_USE_DIV, C.KTCH_DSP_IP, C.KTCH_DSP_PORT, C.FILLER1, C.FILLER2, A.FILLER3, C.FILLER4, C.FILLER5 \n" + // + " FROM POSMST..MST_KTCH_ORD_MSG A \n" + // + " , POSMST..MST_KTCH_DEVICE_ITEM B WITH(NOLOCK) \n" + // + " , POSMST..MST_KTCH_DEVICE C WITH(NOLOCK) \n" + // + " WHERE A.CMP_CD = B.CMP_CD AND A.STOR_CD = B.STOR_CD AND A.SUB_STOR_CD = B.SUB_STOR_CD AND A.ITEM_CD = B.ITEM_CD \n" + // + " AND (A.FLOOR_CD = B.FLOOR_CD OR '999' = B.FLOOR_CD) \n" + // + " AND B.CMP_CD = C.CMP_CD AND B.STOR_CD = C.STOR_CD \n" + // + " AND B.SUB_STOR_CD = C.SUB_STOR_CD AND B.KTCH_SYS_CD = C.KTCH_SYS_CD \n" + // + " AND A.TRAIN_MODE_YN = '" + ItemConst.TRAINING_FLAG.TRAINING_NO + "' \n" // Add, 2017.03.03, 연습모드 KDS는 연습모드 없음. + // + " AND A.ORD_DIV = '0' \n" + // + " AND A.SEND_YN = '0' \n" + // + " AND A.ITEM_DIV IN ('0', '1', '2', '3', '4') \n" + // + " AND A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + // + " AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + // + " AND B.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" + // + " AND C.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" + // //+ " AND C.KTCH_SYS_DIV = '" + PosConst.KTCH_SYS_DIV.KDS + "' \n" + // + " AND C.KTCH_SYS_DIV IN ('" + PosConst.KTCH_SYS_DIV.KDS + "', '" + PosConst.KTCH_SYS_DIV.KVS + "') \n" + // + " ORDER BY C.SUB_STOR_CD, C.KTCH_SYS_CD \n" + // ; + #endregion + + sQuery = "SELECT A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ, A.CMP_CD, A.BRAND_CD, A.STOR_CD, A.POS_NO, A.TRADE_NO, A.SALE_DT, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM \n" + + " , A.SALE_QTY, A.PACK_DIV, A.SET_MENU_CD, A.ORD_TIME, A.CANCEL_DIV, A.SUB_MEMO_DIV, A.RESEND_YN \n" + + " , A.MSG1, A.MSG2, A.MSG3, A.FILLER2 AS ETC_ORD_FLAG, A.FILLER3 AS ADD_ORD_FLAG \n" + + " , C.SUB_STOR_CD, C.KTCH_SYS_CD \n" + //17.09.13 dkshin SS 해피오더 수정 + + " , A.ORG_BILL_POSNO, A.ORG_BILL_NO \n" + //17.08.22 dkshin SS 해피오더 + //+ " , C.KTCH_SYS_USE_DIV, C.KTCH_DSP_IP, C.KTCH_DSP_PORT, C.FILLER1, C.FILLER2, A.FILLER3, C.FILLER4, C.FILLER5 \n" + + //#20170915 KVS 전송 안되는 현상 수정 start + //KTCH_SYS_DIV가 장비 구분인데 KTCH_SYS_USE_DIV값으로 가져와서 전송이 안됨. + //기존 + //+ " , C.KTCH_SYS_USE_DIV, C.KTCH_DSP_IP, C.KTCH_DSP_PORT, C.FILLER1, A.FILLER2, A.FILLER3, A.FILLER4, C.FILLER5 \n" + //변경 + + " , C.KTCH_SYS_DIV as KTCH_SYS_USE_DIV, C.KTCH_DSP_IP, C.KTCH_DSP_PORT, C.FILLER1, A.FILLER2, A.FILLER3, A.FILLER4, C.FILLER5 \n" + //#20170915 KVS 전송 안되는 현상 수정 end + + + " FROM POSMST..MST_KTCH_ORD_MSG A \n" + + //#20180208 거래데이터 저장 실패시 KDS 키중복 에러 발생할수 있어 NOLOCK 제거 start + //기존 + + " , POSMST..MST_KTCH_DEVICE C WITH(NOLOCK) \n" + //변경 + //+ " , POSMST..MST_KTCH_DEVICE C \n" + //#20180208 거래데이터 저장 실패시 KDS 키중복 에러 발생할수 있어 NOLOCK 제거 end + + + " WHERE A.CMP_CD = C.CMP_CD AND A.STOR_CD = C.STOR_CD AND A.SUB_STOR_CD = C.SUB_STOR_CD \n" + + " AND A.TRAIN_MODE_YN = '" + ItemConst.TRAINING_FLAG.TRAINING_NO + "' \n" + + " AND A.ORD_DIV = '0' \n" + + " AND A.KDS_SEND_YN = '0' \n" + + " AND A.ITEM_DIV IN ('0', '1', '2', '3', '4') \n" + + " AND A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + + " AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'\n" + //#20170913 SS해피오더 KDS 미전송 수정 start + //기존 + //+ " AND A.ORD_POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n" + //#20170913 SS해피오더 KDS 미전송 수정 end + + " AND C.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" + + " AND C.KTCH_SYS_DIV IN ('" + PosConst.KTCH_SYS_DIV.KDS + "', '" + PosConst.KTCH_SYS_DIV.KVS + "') \n" + + " ORDER BY C.SUB_STOR_CD, C.KTCH_SYS_CD \n" + ; + + + + // 조회 + DataTable dtData = null; + if(sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) != UserCom.OK) + { + //if (dtData != null && dtData.Rows.Count != 0) + //{ + // UserLog.WriteLogFile(UserCom.LOG_ERROR, + // UserCom.WARNING_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 (함수명)) + // sQuery); + //} + return bRtn; + } + + if (dtData.Rows.Count > 0) + { + foreach (DataRow dr in dtData.Rows) + { + KDSItem cKDSItem = new KDSItem(); + + cKDSItem.sOrderType = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "ORD_DIV")); + cKDSItem.sFloorCd = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "FLOOR_CD")); + cKDSItem.sTableNo = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "TBL_NO")); + cKDSItem.sKtchSysCd = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "KTCH_SYS_CD")); + cKDSItem.nSeq = CmUtil.GetDataRowInt(dr, "SEQ"); + + if (cKDSItem.sOrderType == string.Empty || cKDSItem.sFloorCd == string.Empty || cKDSItem.sTableNo == string.Empty || + cKDSItem.sKtchSysCd == string.Empty) + { + continue; + } + + cKDSItem.sCmpCd = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "CMP_CD")); + cKDSItem.sBrandCd = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "BRAND_CD")); + // 복합매장일 경우를 대비하여 점포코드에는 서브점포코드를 넣는다.(2017.02.10) + cKDSItem.sStorCd = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "SUB_STOR_CD")); + cKDSItem.sPosNo = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "POS_NO")); + cKDSItem.sTradeNo = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "TRADE_NO")); + cKDSItem.sSaleDt = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "SALE_DT")); + cKDSItem.sPosType = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "POS_TYPE")); + cKDSItem.sItemCd = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "ITEM_CD")); + cKDSItem.sItemDiv = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "ITEM_DIV")); + // KDS, KVS 의 경우 부가메뉴 표시 문자를 삭제 함(안호성C, 20170420) + cKDSItem.sItemNm = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "SHTCUT_ITEMNM")).TrimStart(new char[] {'>'}); + cKDSItem.nQty = CmUtil.GetDataRowInt(dr, "SALE_QTY"); + cKDSItem.sPackDiv = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "PACK_DIV")); + cKDSItem.sSetMenuCd = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "SET_MENU_CD")); + cKDSItem.sOrdTime = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "ORD_TIME")); + cKDSItem.sCancelDiv = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "CANCEL_DIV")); + cKDSItem.sOrgBillPosNo = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "ORG_BILL_POSNO")); + cKDSItem.sOrgBillDt = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "ORG_BILL_DT")); + cKDSItem.sOrgBillNo = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "ORG_BILL_NO")); + cKDSItem.sKtchSysUseDiv = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "KTCH_SYS_USE_DIV")); + cKDSItem.sKtchKdsIp = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "KTCH_DSP_IP")); + cKDSItem.sKtchKdsPort = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "KTCH_DSP_PORT")); + cKDSItem.sResendYn = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "RESEND_YN")); + cKDSItem.sFiller1 = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "FILLER1")); + cKDSItem.sFiller2 = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "FILLER2")); + cKDSItem.sFiller3 = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "FILLER3")); + cKDSItem.sFiller4 = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "FILLER4")); + cKDSItem.sFiller5 = CmUtil.StringNullEmpty(CmUtil.GetDataRowStr(dr, "FILLER5")); + + cKDSItem.sSendYn = "0"; + cKDSItem.sErrorCd = "0000"; + + htKDSSendingItem.Add(htKDSSendingItem.Count, cKDSItem); + } + + if (htKDSSendingItem.Count > 0) + { + InsertIntoKDS(htKDSSendingItem); + bRtn = true; + } + } + } + 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 bRtn; + } + /// + /// Insert into MST_KDS_ORD_MSG + /// + /// + private void InsertIntoKDS(Hashtable htKDSItem) + { + string sQuery = ""; + + try + { + if(htKDSItem.Count > 0) + { + //#20170111 트랜젝션 위치 변경 start + //기존 + //sqlDb.DBBeginTransaction(); + //#20170111 트랜젝션 위치 변경 end + + for(int nLoop = 0;nLoop < htKDSItem.Count;nLoop++) + { + KDSItem cKDSItem = (KDSItem)htKDSItem[nLoop]; + + sQuery = "INSERT INTO POSMST..MST_KDS_ORD_MSG "; + sQuery += " ( ORD_DIV, FLOOR_CD, TBL_NO, KTCH_SYS_CD, SEQ, CMP_CD, BRAND_CD, STOR_CD, POS_NO, TRADE_NO, SALE_DT, POS_TYPE, ITEM_CD, ITEM_DIV, SHTCUT_ITEMNM "; + sQuery += " , SALE_QTY, PACK_DIV, SET_MENU_CD, ORD_TIME, CANCEL_DIV, ORG_BILL_POSNO, ORG_BILLDT "; + sQuery += " , ORG_BILL_NO, KTCH_SYS_USE_DIV, KTCH_KDS_IP, KTCH_KDS_PORT, ERROR_CD, SEND_YN, RESEND_YN "; + sQuery += " , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5, UPD_DT, REG_DT ) "; + sQuery += "VALUES "; + sQuery += " ( '{0}', '{1}', '{2}', '{3}', {4}, '{5}', '{6}', '{7}', '{8}', '{9}', '{10}', '{11}', '{12}', '{13}', N'{14}' "; + sQuery += " , {15}, '{16}', '{17}', '{18}', '{19}', '{20}', '{21}' "; + sQuery += " , '{22}', '{23}', '{24}', '{25}', '{26}', '{27}', '{28}' "; + sQuery += " , '{29}', '{30}', '{31}', '{32}', '{33}', '{34}', '{35}' ) "; + + string[] saQuery = new string[1]; + saQuery[0] = string.Format(sQuery + , cKDSItem.sOrderType + , cKDSItem.sFloorCd + , cKDSItem.sTableNo + , cKDSItem.sKtchSysCd + , cKDSItem.nSeq + , cKDSItem.sCmpCd + , cKDSItem.sBrandCd + , cKDSItem.sStorCd + , cKDSItem.sPosNo + , cKDSItem.sTradeNo + , cKDSItem.sSaleDt + , cKDSItem.sPosType + , cKDSItem.sItemCd + , cKDSItem.sItemDiv + , cKDSItem.sItemNm + , cKDSItem.nQty + , cKDSItem.sPackDiv + , cKDSItem.sSetMenuCd + , cKDSItem.sOrdTime + , cKDSItem.sCancelDiv + , cKDSItem.sOrgBillPosNo + , cKDSItem.sOrgBillDt + , cKDSItem.sOrgBillNo + , cKDSItem.sKtchSysUseDiv + , cKDSItem.sKtchKdsIp + , cKDSItem.sKtchKdsPort + , cKDSItem.sErrorCd + , "0" + , cKDSItem.sResendYn + , cKDSItem.sFiller1 + , cKDSItem.sFiller2 + , cKDSItem.sFiller3 + , cKDSItem.sFiller4 + , cKDSItem.sFiller5 + , DateTime.Now.ToString("yyyyMMddHHmmss") + , DateTime.Now.ToString("yyyyMMddHHmmss") + ); + + //#20170111 트랜젝션 위치 변경 start + //변경 + + //#20180302 KDS 처리시 트랜젝션 제거 start + //적용시 아래 소스주석 + //sqlDb.DBBeginTransaction(); + //#20180302 KDS 처리시 트랜젝션 제거 end + + //#20170111 트랜젝션 위치 변경 end + + if (sqlDb.DBExecuteNonQuery(saQuery, CommandType.Text, (SqlParameter[])null) != UserCom.OK) + { + // Rollback + + //#20180302 KDS 처리시 트랜젝션 제거 start + //적용시 아래 소스주석 + //sqlDb.DBTransactionRollback(); + //#20180302 KDS 처리시 트랜젝션 제거 end + + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_LEVEL, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (클래스명) + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (함수명) + "Query=" + sQuery); + + //#20170111 트랜젝션 위치 변경 start + //변경 + + //#20180302 KDS 처리시 트랜젝션 제거 start + //적용시 아래 소스주석 + //sqlDb.DBBeginTransaction(); + //#20180302 KDS 처리시 트랜젝션 제거 end + + sQuery = "UPDATE POSMST..MST_KTCH_ORD_MSG "; + sQuery += " SET KDS_SEND_YN = '1' "; + sQuery += " WHERE TRAIN_MODE_YN = '" + ItemConst.TRAINING_FLAG.TRAINING_NO + "' "; // Add, 2017.03.03, 연습모드 + sQuery += " AND ORD_DIV = '" + cKDSItem.sOrderType + "' "; + sQuery += " AND FLOOR_CD = '" + cKDSItem.sFloorCd + "' "; + sQuery += " AND TBL_NO = '" + cKDSItem.sTableNo + "' "; + sQuery += " AND SEQ = " + cKDSItem.nSeq + " "; + + if (sqlDb.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null) != UserCom.OK) + { + // Rollback + + //#20180302 KDS 처리시 트랜젝션 제거 start + //적용시 아래 소스주석 + //sqlDb.DBTransactionRollback(); + //#20180302 KDS 처리시 트랜젝션 제거 end + + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_LEVEL, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (클래스명) + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (함수명) + "Query=" + sQuery); + return; + } + + //#20180302 KDS 처리시 트랜젝션 제거 start + //적용시 아래 소스주석 + //sqlDb.DBTransactionCommit(); + //#20180302 KDS 처리시 트랜젝션 제거 end + + //#20170111 트랜젝션 위치 변경 end + + //#20170929 KDS 데이터 INSERT 실패해도 상태 업데이트 하도록 수정(key error) start + //#20180105 트랜젝션 오류로 원복 start + //기존 + return; + //#20170929 KDS 데이터 INSERT 실패해도 상태 업데이트 하도록 수정(key error) end + } + + sQuery = "UPDATE POSMST..MST_KTCH_ORD_MSG "; + sQuery += " SET KDS_SEND_YN = '1' "; + sQuery += " WHERE TRAIN_MODE_YN = '" + ItemConst.TRAINING_FLAG.TRAINING_NO + "' "; // Add, 2017.03.03, 연습모드 + sQuery += " AND ORD_DIV = '" + cKDSItem.sOrderType + "' "; + sQuery += " AND FLOOR_CD = '" + cKDSItem.sFloorCd + "' "; + sQuery += " AND TBL_NO = '" + cKDSItem.sTableNo + "' "; + sQuery += " AND SEQ = " + cKDSItem.nSeq + " "; + + if(sqlDb.DBExecuteNonQuery(new string[] {sQuery}, CommandType.Text, (SqlParameter[])null) != UserCom.OK) + { + // Rollback + + //#20180302 KDS 처리시 트랜젝션 제거 start + //적용시 아래 소스주석 + //sqlDb.DBTransactionRollback(); + //#20180302 KDS 처리시 트랜젝션 제거 end + + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_LEVEL, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (클래스명) + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (함수명) + "Query=" + sQuery); + return; + } + + //#20170111 트랜젝션 위치 변경 start + //변경 + + //#20180302 KDS 처리시 트랜젝션 제거 start + //적용시 아래 소스주석 + //sqlDb.DBTransactionCommit(); + //#20180302 KDS 처리시 트랜젝션 제거 end + + //#20170111 트랜젝션 위치 변경 end + } + + // Commit + //#20170111 트랜젝션 위치 변경 start + //기존 + //sqlDb.DBTransactionCommit(); + //#20170111 트랜젝션 위치 변경 end + } + } + catch (Exception ex) + { + // Rollback + + //#20180302 KDS 처리시 트랜젝션 제거 start + //적용시 아래 소스주석 + //sqlDb.DBTransactionRollback(); + //#20180302 KDS 처리시 트랜젝션 제거 end + + 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); + } + } + #endregion 데이터 이행 처리(주방주문데이터 -> KDS) + + #region 전송 데이터 생성 + /// + /// KDS 전송 데이터 생성 + /// + /// + /// + private Hashtable GetKDSSendItem(ref Hashtable htKDSSendItem, ref string sIp, ref int iPort, ref string[] saKey) + { + string sQuery = ""; + + DataTable dtKey = null; + DataTable dtData = null; + + Hashtable htSendData = null; + try + { + Hashtable htCommHeader = null; + Hashtable htOrderHeader = null; + Hashtable[] htOrderItem = null; + Hashtable[] htOrderMsg = new Hashtable[3]; + + #region 01.전송할 거래 조회 + + //#20180202 KDS 전송 실패시 3회 재시도, 최초 한번 영수증 출력 start + //기존 + /* + sQuery = "SELECT TOP 1 ORD_DIV, FLOOR_CD, TBL_NO, KTCH_SYS_CD "; + sQuery += " FROM POSMST..MST_KDS_ORD_MSG "; + sQuery += " WHERE SEND_YN IN ('0', '9') "; + sQuery += " AND RESEND_YN ='0' ";//17.08.22 dkshin SS 해피오더 - KDS 전송 체크 + sQuery += " ORDER BY SEND_YN "; + */ + //변경 + sQuery = "SELECT TOP 1 ORD_DIV, FLOOR_CD, TBL_NO, KTCH_SYS_CD, ISNULL(F_CNT,0) F_CNT "; + sQuery += " FROM POSMST..MST_KDS_ORD_MSG "; + sQuery += " WHERE SEND_YN IN ('0', '9') "; + sQuery += " AND RESEND_YN ='0' ";//17.08.22 dkshin SS 해피오더 - KDS 전송 체크 + sQuery += " AND F_CNT <= 3 "; + sQuery += " ORDER BY SEND_YN "; + //#20180202 KDS 전송 실패시 3회 재시도, 최초 한번 영수증 출력 end + + if(sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtKey) != UserCom.OK) + { + if (dtKey != null && dtKey.Rows.Count != 0) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_LEVEL, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (클래스명) + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (함수명) + "Query=" + sQuery); + } + return htSendData; + } + + saKey[0] = CmUtil.GetDataRowStr(dtKey.Rows[0], "ORD_DIV"); + saKey[1] = CmUtil.GetDataRowStr(dtKey.Rows[0], "FLOOR_CD"); + saKey[2] = CmUtil.GetDataRowStr(dtKey.Rows[0], "TBL_NO"); + saKey[3] = CmUtil.GetDataRowStr(dtKey.Rows[0], "KTCH_SYS_CD"); + //#20180202 KDS 전송 실패시 3회 재시도, 최초 한번 영수증 출력 start + saKey[4] = CmUtil.GetDataRowStr(dtKey.Rows[0], "F_CNT"); + //#20180202 KDS 전송 실패시 3회 재시도, 최초 한번 영수증 출력 end + + #endregion 01.전송할 거래 조회 + + #region 02.동일 거래의 데이터 조회 + sQuery = "SELECT ORD_DIV, FLOOR_CD, TBL_NO, KTCH_SYS_CD, SEQ, CMP_CD, BRAND_CD, STOR_CD, POS_NO, TRADE_NO, SALE_DT, POS_TYPE, ITEM_CD, ITEM_DIV, SHTCUT_ITEMNM, SALE_QTY "; + sQuery += " , PACK_DIV, SET_MENU_CD, ORD_TIME, CANCEL_DIV, ORG_BILL_POSNO, ORG_BILLDT, ORG_BILL_NO, KTCH_SYS_USE_DIV "; + sQuery += " , KTCH_KDS_IP, KTCH_KDS_PORT, ERROR_CD, SEND_YN, RESEND_YN, FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 "; + sQuery += " FROM POSMST..MST_KDS_ORD_MSG "; + sQuery += " WHERE ORD_DIV = '" + CmUtil.GetDataRowStr(dtKey.Rows[0], "ORD_DIV") + "' "; + sQuery += " AND FLOOR_CD = '" + CmUtil.GetDataRowStr(dtKey.Rows[0], "FLOOR_CD") + "' "; + sQuery += " AND TBL_NO = '" + CmUtil.GetDataRowStr(dtKey.Rows[0], "TBL_NO") + "' "; + sQuery += " AND KTCH_SYS_CD = '" + CmUtil.GetDataRowStr(dtKey.Rows[0], "KTCH_SYS_CD") + "' "; + //17.08.22 dkshin SS 해피오더 + sQuery += " AND SEND_YN IN ('0', '9') "; + sQuery += " AND RESEND_YN ='0' "; + + sQuery += " ORDER BY KTCH_SYS_CD, ORD_DIV, FLOOR_CD, TBL_NO, CANCEL_DIV, SEQ "; + + if(sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) != UserCom.OK) + { + if (dtData != null && dtData.Rows.Count != 0) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_LEVEL, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (클래스명) + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (함수명) + "Query=" + sQuery); + } + return htSendData; + } + + sIp = CmUtil.GetDataRowStr(dtData.Rows[0], "KTCH_KDS_IP"); + iPort = CmUtil.GetDataRowInt(dtData.Rows[0], "KTCH_KDS_PORT"); + #endregion 02.동일 거래의 데이터 조회 + + #region 03.COMM_HEADER - 통신헤더 생성 + // 통신 헤더 생성 + htCommHeader = new Hashtable(); + htCommHeader.Add(Column.IQ_KDS_HEADER_REQ.DATA.MSG_TYPE, "70"); + //17.08.22 dkshin SS 해피오더 + //170914 dkshin KDS: PC, KVS: PCKR + //htCommHeader.Add(Column.IQ_KDS_HEADER_REQ.DATA.CO_CD, CmUtil.GetDataRowStr(dtData.Rows[0], "CMP_CD")); + if (CmUtil.GetDataRowStr(dtData.Rows[0], "KTCH_SYS_USE_DIV") == PosConst.KTCH_SYS_DIV.KDS) + { + if (CmUtil.GetDataRowStr(dtData.Rows[0], "CMP_CD") == "PCKR") + htCommHeader.Add(Column.IQ_KDS_HEADER_REQ.DATA.CO_CD, "PC"); + } + else + htCommHeader.Add(Column.IQ_KDS_HEADER_REQ.DATA.CO_CD, CmUtil.GetDataRowStr(dtData.Rows[0], "CMP_CD")); + + htCommHeader.Add(Column.IQ_KDS_HEADER_REQ.DATA.BRAND_CD, CmUtil.GetDataRowStr(dtData.Rows[0], "BRAND_CD")); + htCommHeader.Add(Column.IQ_KDS_HEADER_REQ.DATA.STORE_CD, CmUtil.GetDataRowStr(dtData.Rows[0], "STOR_CD")); + htCommHeader.Add(Column.IQ_KDS_HEADER_REQ.DATA.POS_NO, CmUtil.GetDataRowStr(dtData.Rows[0], "POS_NO")); + htCommHeader.Add(Column.IQ_KDS_HEADER_REQ.DATA.TRAN_NO, CmUtil.GetDataRowStr(dtData.Rows[0], "TBL_NO")); + htCommHeader.Add(Column.IQ_KDS_HEADER_REQ.DATA.TRAN_YMD, CmUtil.GetDataRowStr(dtData.Rows[0], "SALE_DT")); + htCommHeader.Add(Column.IQ_KDS_HEADER_REQ.DATA.SYS_YMD, DateTime.Now.ToString("yyyyMMdd")); + htCommHeader.Add(Column.IQ_KDS_HEADER_REQ.DATA.SYS_HMS, DateTime.Now.ToString("HHmmss")); + htCommHeader.Add(Column.IQ_KDS_HEADER_REQ.DATA.ERR_CD, "000"); + #endregion 03.COMM_HEADER - 통신헤더 생성 + + #region 04.ORDER_HEADER - 주문헤더 생성 + // 주문 헤더 생성 + htOrderHeader = new Hashtable(); + htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.TR_HEADER_ID, "70"); + htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.POS_NO, CmUtil.GetDataRowStr(dtData.Rows[0], "FLOOR_CD")); + // 주문번호를 사용하면 TRAN_NO에 주문번호 대입, 아닐 경우 TRAN_NO에 거래번호 대입 + if (PosMstManager.GetPosOption(POS_OPTION.OPT008) == "1") + { + htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.TRAN_NO, CmUtil.GetDataRowStr(dtData.Rows[0], "TRADE_NO")); + } + else + { + htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.TRAN_NO, CmUtil.GetDataRowStr(dtData.Rows[0], "TBL_NO")); + } + htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.DEAL_TY, CmUtil.GetDataRowStr(dtData.Rows[0], "CANCEL_DIV")); + htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.POS_TY, CmUtil.GetDataRowStr(dtData.Rows[0], "POS_TYPE")); + //17.08.22 dkshin SS 해피오더 + //htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.TABLE_NM, ""); + + htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.ORDER_CUST_NM, ""); + //htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.VIP_TY, CmUtil.GetDataRowStr(dtData.Rows[0], "FILLER3")); + //17.08.22 dkshin SS 해피오더 + //htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.VIP_TY, CmUtil.GetDataRowStr(dtData.Rows[0], "FILLER4")); + if (CmUtil.GetDataRowStr(dtData.Rows[0], "FILLER2") == "2") + { + htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.TABLE_NM, CmUtil.GetDataRowStr(dtData.Rows[0], "ORD_TIME"));//픽업시간 ex) 03-29 17:30 + htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.VIP_TY, "3"); + htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.ORDER_TY, "2"); + } + else + { + htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.TABLE_NM, ""); + htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.VIP_TY, CmUtil.GetDataRowStr(dtData.Rows[0], "FILLER4")); + htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.ORDER_TY, CmUtil.GetDataRowStr(dtData.Rows[0], "PACK_DIV")); + } + //17.08.22 dkshin SS 해피오더 + //htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.ORDER_TY, CmUtil.GetDataRowStr(dtData.Rows[0], "PACK_DIV")); + + htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.ORG_POS_NO, CmUtil.GetDataRowStr(dtData.Rows[0], "ORG_BILL_POSNO")); + htOrderHeader.Add(Column.IQ_KDS_ORDER_HEADER_REQ.DATA.ORG_TRAN_NO, CmUtil.GetDataRowStr(dtData.Rows[0], "ORG_BILL_NO")); + #endregion 04.ORDER_HEADER - 주문헤더 생성 + + #region 05.ORDER_ITEM - 주문명세 생성 + // 주문 명세 생성 + htOrderItem = new Hashtable[dtData.Rows.Count]; + for(int nLoop = 0;nLoop < dtData.Rows.Count;nLoop++) + { + DataRow dr = dtData.Rows[nLoop]; + htOrderItem[nLoop] = new Hashtable(); + htOrderItem[nLoop].Add(Column.IQ_KDS_ORDER_ITEM_REQ.DATA.TR_ITEM_ID, "71"); + htOrderItem[nLoop].Add(Column.IQ_KDS_ORDER_ITEM_REQ.DATA.SEQ_NO, (nLoop + 1).ToString()); + htOrderItem[nLoop].Add(Column.IQ_KDS_ORDER_ITEM_REQ.DATA.DEAL_TY, CmUtil.GetDataRowStr(dr, "CANCEL_DIV")); + switch(CmUtil.GetDataRowStr(dr, "ITEM_DIV")) + { + case ItemConst.PLU_ITEM_DIV.NORMAL: + case ItemConst.PLU_ITEM_DIV.SET_DIS: + case ItemConst.PLU_ITEM_DIV.GIFT: + htOrderItem[nLoop].Add(Column.IQ_KDS_ORDER_ITEM_REQ.DATA.MENU_TY, "1"); // 제품 + break; + case ItemConst.PLU_ITEM_DIV.OPT_MENU: + htOrderItem[nLoop].Add(Column.IQ_KDS_ORDER_ITEM_REQ.DATA.MENU_TY, "2"); // 부가메뉴 + break; + case ItemConst.PLU_ITEM_DIV.SET_MAIN: + case ItemConst.PLU_ITEM_DIV.SET_DETL: + htOrderItem[nLoop].Add(Column.IQ_KDS_ORDER_ITEM_REQ.DATA.MENU_TY, "3"); // 세트 + break; + } + htOrderItem[nLoop].Add(Column.IQ_KDS_ORDER_ITEM_REQ.DATA.ITEM_CD, CmUtil.GetDataRowStr(dr, "ITEM_CD")); + htOrderItem[nLoop].Add(Column.IQ_KDS_ORDER_ITEM_REQ.DATA.ITEM_NM, CmUtil.GetDataRowStr(dr, "SHTCUT_ITEMNM")); + htOrderItem[nLoop].Add(Column.IQ_KDS_ORDER_ITEM_REQ.DATA.ITEM_QTY, CmUtil.GetDataRowInt(dr, "SALE_QTY")); + htOrderItem[nLoop].Add(Column.IQ_KDS_ORDER_ITEM_REQ.DATA.MSG_1, ""); + htOrderItem[nLoop].Add(Column.IQ_KDS_ORDER_ITEM_REQ.DATA.MSG_2, ""); + htOrderItem[nLoop].Add(Column.IQ_KDS_ORDER_ITEM_REQ.DATA.MSG_3, ""); + } + #endregion 05.ORDER_ITEM - 주문명세 생성 + + #region 06.ORDER_MESSAGE - 주문 전달 메시지 생성 + // 주문 전달 메시지 생성 + for(int nLoop = 0;nLoop < 3;nLoop++) + { + htOrderMsg[nLoop] = new Hashtable(); + } + #endregion 06.ORDER_MESSAGE - 주문 전달 메시지 생성 + + #region 07.JSON 데이터 생성 + htSendData = new Hashtable(); + htSendData.Add("HEADER", htCommHeader); + htSendData.Add("ORDERHEADER", htOrderHeader); + htSendData.Add("ORDER_ITEM", htOrderItem); + htSendData.Add("ORDERMSG", htOrderMsg); + #endregion 07.JSON 데이터 생성 + } + 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 htSendData; + } + #endregion 전송 데이터 생성 + + #region KDS 전송 플래그 업데이트 처리 + public int UpdateKDSSendFlag(string sOrdDiv, string sFloorCd, string sTblNo, string sKtchSysCd, string sSendFlag) + { + int iRet = UserCom.NG; + string sQuery = ""; + try + { + if (sOrdDiv.Trim() == "") return iRet; + if (sFloorCd.Trim() == "") return iRet; + if (sTblNo.Trim() == "") return iRet; + if (sKtchSysCd.Trim() == "") return iRet; + + sQuery += " UPDATE POSMST..MST_KDS_ORD_MSG "; + sQuery += " SET SEND_YN = '" + sSendFlag + "' "; + sQuery += " , RESEND_YN = '1' ";//17.08.22 dkshin SS 해피오더 - KDS 전송 체크 + sQuery += " , UPD_DT = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + //#20180202 KDS 전송 실패시 3회 재시도, 최초 한번 영수증 출력 start + sQuery += " , F_CNT = CASE WHEN '" + sSendFlag + "' = '9' THEN ISNULL(F_CNT,0) + 1 ELSE ISNULL(F_CNT,0) END "; + //#20180202 KDS 전송 실패시 3회 재시도, 최초 한번 영수증 출력 end + sQuery += " WHERE ORD_DIV = '" + sOrdDiv + "' "; + sQuery += " AND FLOOR_CD = '" + sFloorCd + "' "; + sQuery += " AND TBL_NO = '" + sTblNo + "' "; + sQuery += " AND KTCH_SYS_CD = '" + sKtchSysCd + "' "; + + if (sqlDb.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null) != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_DEBUG, + UserCom.WARNING_LEVEL, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (클래스명) + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (함수명) + "Query=" + sQuery); + } + else + { + iRet = UserCom.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 iRet; + } + #endregion KDS 전송 플래그 업데이트 처리 + + #region 전송 모듈 + private string SendProcess(string sSvrIp, int iPort, int iTimeout, Hashtable htSendData) + { + string sRet = UserCom.RST_ERR; + + try + { + // JSON 객체로 변환 + string sJsonSendData = JsonConvert.SerializeObject(htSendData); + // JSON string 길이를 구하기 위해 byte로 변환 + //Byte[] arTempData = Encoding.ASCII.GetBytes(sJsonSendData); + Byte[] arTempData = (Encoding.GetEncoding("euc-kr")).GetBytes(sJsonSendData); + + string header = string.Format("KDS{0:00000}", arTempData.Length); + + string sJsonRecvData = string.Empty; + + int iRet = DataSendReceive(sSvrIp, iPort, iTimeout, header + sJsonSendData); + + if(iRet == UserCom.OK) + { + 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; + } + + private int DataSendReceive(string sIp, int iPort, int iTimeout, string sSendData) + { + int iRet = UserCom.NG; + int nRecvLen = 0; + string sRecvData = string.Empty; + + try + { + m_sendSocket = new TcpSocket(sIp, iPort); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)), + CmUtil.RPadH("[SEND" + ":" + sIp + ":" + iPort, 27) + "] " + sSendData); + + // Data Send & Receive + nRecvLen = m_sendSocket.KDSSendReceiveData(sSendData, ref sRecvData, m_iTimeout, DATA_LEN_SIZE, 3); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)), + CmUtil.RPadH("[RECV" + ":" + sIp + ":" + iPort, 27) + "] " + sRecvData); + + if(sRecvData.Length > 0) + { + //Hashtable htJsonRecvData = JsonConvert.DeserializeObject(sRecvData); + + //if(htJsonRecvData["HEADER"].ToString().Length > 0) + //{ + // Hashtable htCommHeader = JsonConvert.DeserializeObject(htJsonRecvData["HEADER"].ToString()); + + // if (htCommHeader.ContainsKey("ERR_CD") == true) + // { + // if(htCommHeader["ERR_CD"].ToString() == "000") + // { + // iRet = UserCom.OK; + // } + // } + //} + + if(sRecvData.Substring(8, 5).Equals("OK!!!") == true) + { + iRet = UserCom.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 iRet; + } + #endregion + } +} diff --git a/Agent/KDS/Properties/AssemblyInfo.cs b/Agent/KDS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e29ea34 --- /dev/null +++ b/Agent/KDS/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("KDS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("KDS")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("cca78233-98fd-4127-8d4a-4f468cedfe3f")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Agent/KPS/Activator.cs b/Agent/KPS/Activator.cs new file mode 100644 index 0000000..46fc39d --- /dev/null +++ b/Agent/KPS/Activator.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : KPS 관련 클래스 Activator +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.Service +{ + public class Activator : InitServiceAbstract + { + /// + /// Define main entrance point of project load. (프로젝트 로드의 주진입점을 정의합니다.) + /// + public Activator() + { + + } + + /// + /// + /// + /// + /// + public override object InitServiceInstance(string sClassNm) + { + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Starting !!!"); + + object retObj = null; + + //클래스 찾아오기 위함 + switch (sClassNm) + { + case ServiceLists.AGENT_KPS.KPS_MAIN: + { + Cosmos.KPS.KPSMain agentClass = new Cosmos.KPS.KPSMain(); + retObj = agentClass; + break; + } + } + + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Completed !!!"); + + return retObj; + + } + } +} diff --git a/Agent/KPS/Common.cs b/Agent/KPS/Common.cs new file mode 100644 index 0000000..cdceea2 --- /dev/null +++ b/Agent/KPS/Common.cs @@ -0,0 +1,595 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Cosmos.KPS +{ + /// + /// Kitchen Device Status + /// + public class KTCH_SYS_STATUS + { + public string sSubShopCd; + public string sKtchSysCd; + public int nErrorCd; + } + + public class KPSItem + { + /// + /// 연습모드구분 0:일반, 1:연습모드 + /// + public string sTrainMode; + + public string sOrderType; + public string sFloorCd; + public string sTableNo; + public string sSubShopCd; // Add, 2017.02.06 + public string sKtchSysCd; + public int nSeq; + public string sOrderNo; + public string sPosType; + public string sItemCd; + public string sItemNm; + /// + /// 상품구분(0:일반, 1:세트, 2:세트자식, 3:부가상품, 4:세트할인, 5:상품권(추가)) + /// + public string sItemDiv; + public int nQty; + public string sPackDiv; + public string sSetMenuCd; + public string sOrdTime; + public string sCancelDiv; + /// + /// 0:정상 1:재전송 + /// + public string sResendYn; + public string sKtchSysUseDiv; + public int nKpsComPort; + public int nKpsComBaudrate; + public string sKpsOposName; + public string sKpsIp; + public string sKpsPort; + + /// + /// 0:미전송 1:전송 + /// 7:영수증프린터출력(주방프린터와 영수증프린터가 동일장치) + /// 8:영수증프린터출력(주방출력오류) + /// + public string sSendYn; + /// + /// 0000 : 정상 + /// + /// + public string sErrorCd; + + //public string sKpsCdBackup1; + //public string sKpsCdBackup2; + //public string sKpsCdBackup3; + //public string sKpsCdBackup4; + //public string sKpsCdBackup5; + //public string sKpsCdBackup6; + + /// + /// 반복출력 횟수 + /// + public string sFiller1; + /// + /// 기타주문구분 + /// 1:후불일반판매, 2:해피오더 + /// + public string sFiller2; + /// + /// 추가주문구분 (NEW,ADD,DEL) + /// + public string sFiller3; + /// + /// 부가메뉴구분 (SUBPRC_MENU_KEY_DIV) + /// + /// + public string sFiller4; + public string sFiller5; + + /// + /// 수동출력일때 주방메모 + /// + public string sKtchMemo = string.Empty; + /// + /// 상품메모 + /// + public string sItemMemo = string.Empty; + /// + /// 주문담당자 + /// + public string sOrdPicNm = string.Empty; + /// + /// 장치명 + /// + public string sKtchSysNm = string.Empty; // Add, 2017.04.07 + /// + /// 최종주문POS + /// + public string sOrdPosNo = string.Empty; // Add, 2017.04.10 + // 2017.09.06 레시피 추가 + /// + /// 레시피 + /// + public string sRecipe= string.Empty; + + //#20180515 KPS 출력시 라벨프린터 출력 start + /// + /// 라벨프린터 출력여부(0:미전송, 1:전송) + /// + public string sLblSendYn = string.Empty; + + /// + /// 라벨프린터 총출력 해야 할 건수 + /// + public int iTOTCNT = 0; + + /// + /// 라벨프린터 QRCODE URL + /// + public string sQrcodeUrl = ""; + + /// + /// 라벨프린터 QRCODE MSG + /// + public string sQrcodeMsg = ""; + + /// + /// 라벨프린터 TOP MSG + /// + public string sTopMsg = ""; + + /// + /// 라벨프린터 BTM MSG + /// + public string sBtmMsg = ""; + //#20180515 KPS 출력시 라벨프린터 출력 end + + } + + /// + /// Table Master + /// + public class TableMaster + { + public string sFloorCd; + public string sTableNo; + public string sTableNm; + public string sTableDispDiv; + } + + //public class TABLE_DISP_FLAG + //{ + // public const string TABLE_NO = "0"; // 테이블 번호 + // public const string TABLE_NAME = "1"; // 테이블 이름 + // public const string TABLE_NO_NAME = "2"; // 테이블 번호 + 이름 + //} + + public class KPSOrderMessage + { + /// + /// 연습모드구분 0:일반, 1:연습모드 + /// + public string sTrainMode; // Add, 2017.03.03 + + public string sOrderType; + public string sFloorCd; + public string sTableNo; + public int nSeq; + public string sSubShopCd; // Add, 2017.02.06 + public string sKtchSysCd; + public string sItemCd; + public string sItemNm; + public string sMsgId; + public string sMsg1; + public string sMsg2; + public string sMsg3; + public string sMsgRegTime; + public string sKtchSysUseDiv; + public int nKpsComPort; + public int nKpsComBaudrate; + public string sKpsOposName; + public string sKpsIp; + public string sKpsPort; + public string sSendYn; + public string sResendYn; + public string sErrorCd; + public int printCount = 1; + + //public string sKpsCdBackup1; + //public string sKpsCdBackup2; + //public string sKpsCdBackup3; + //public string sKpsCdBackup4; + //public string sKpsCdBackup5; + //public string sKpsCdBackup6; + + public string sRegDate; + /// + /// 장치명 + /// + public string sKtchSysNm = string.Empty; // Add, 2017.04.07 + /// + /// 마지막주문POS + /// + public string sOrdPosNo = string.Empty; // Add, 2017.04.10 + } + + public class OPOS + { + public const int CASH_SUE_DRAWERCLOSED = 0; + public const int CASH_SUE_DRAWEROPEN = 1; + public const int CHAN_STATUS_ASYNC = 91; + public const int CHAN_STATUS_EMPTY = 11; + public const int CHAN_STATUS_EMPTYOK = 13; + public const int CHAN_STATUS_FULL = 21; + public const int CHAN_STATUS_FULLOK = 23; + public const int CHAN_STATUS_JAM = 31; + public const int CHAN_STATUS_JAMOK = 32; + public const int CHAN_STATUS_NEAREMPTY = 12; + public const int CHAN_STATUS_NEARFULL = 22; + public const int CHAN_STATUS_OK = 0; + public const int COIN_STATUS_EMPTY = 2; + public const int COIN_STATUS_JAM = 4; + public const int COIN_STATUS_NEAREMPTY = 3; + public const int COIN_STATUS_OK = 1; + public const int DISP_CB_BLINKALL = 1; + public const int DISP_CB_BLINKEACH = 2; + public const int DISP_CB_NOBLINK = 0; + public const int DISP_CCS_ALPHA = 1; + public const int DISP_CCS_ASCII = 998; + public const int DISP_CCS_KANA = 10; + public const int DISP_CCS_KANJI = 11; + public const int DISP_CCS_NUMERIC = 0; + public const int DISP_CS_ASCII = 998; + public const int DISP_CS_WINDOWS = 999; + public const int DISP_DT_BLINK = 1; + public const int DISP_DT_NORMAL = 0; + public const int DISP_MF_PLACE = 1; + public const int DISP_MF_WALK = 0; + public const int DISP_MT_DOWN = 2; + public const int DISP_MT_INIT = 5; + public const int DISP_MT_LEFT = 3; + public const int DISP_MT_NONE = 0; + public const int DISP_MT_RIGHT = 4; + public const int DISP_MT_UP = 1; + public const int DISP_SD_BLINK = 2; + public const int DISP_SD_OFF = 0; + public const int DISP_SD_ON = 1; + public const int DISP_ST_DOWN = 2; + public const int DISP_ST_LEFT = 3; + public const int DISP_ST_RIGHT = 4; + public const int DISP_ST_UP = 1; + public const int FPTR_AT_AMOUNT_DISCOUNT = 1; + public const int FPTR_AT_AMOUNT_SURCHARGE = 2; + public const int FPTR_AT_PERCENTAGE_DISCOUNT = 3; + public const int FPTR_AT_PERCENTAGE_SURCHARGE = 4; + public const int FPTR_CC_BRAZIL = 1; + public const int FPTR_CC_GREECE = 2; + public const int FPTR_CC_HUNGARY = 3; + public const int FPTR_CC_ITALY = 4; + public const int FPTR_CC_POLAND = 5; + public const int FPTR_CC_TURKEY = 6; + public const int FPTR_EL_BLOCKED = 4; + public const int FPTR_EL_FATAL = 3; + public const int FPTR_EL_NONE = 1; + public const int FPTR_EL_RECOVERABLE = 2; + public const int FPTR_GD_CURRENT_TOTAL = 1; + public const int FPTR_GD_DAILY_TOTAL = 2; + public const int FPTR_GD_FIRMWARE = 10; + public const int FPTR_GD_GRAND_TOTAL = 8; + public const int FPTR_GD_MID_VOID = 6; + public const int FPTR_GD_NOT_PAID = 5; + public const int FPTR_GD_PRINTER_ID = 9; + public const int FPTR_GD_RECEIPT_NUMBER = 3; + public const int FPTR_GD_REFUND = 4; + public const int FPTR_GD_RESTART = 11; + public const int FPTR_GD_Z_REPORT = 7; + public const int FPTR_PS_FISCAL_DOCUMENT = 5; + public const int FPTR_PS_FISCAL_RECEIPT = 2; + public const int FPTR_PS_FISCAL_RECEIPT_ENDING = 4; + public const int FPTR_PS_FISCAL_RECEIPT_TOTAL = 3; + public const int FPTR_PS_FIXED_OUTPUT = 6; + public const int FPTR_PS_ITEM_LIST = 7; + public const int FPTR_PS_LOCKED = 8; + public const int FPTR_PS_MONITOR = 1; + public const int FPTR_PS_NONFISCAL = 9; + public const int FPTR_PS_REPORT = 10; + public const int FPTR_RT_DATE = 2; + public const int FPTR_RT_ORDINAL = 1; + public const int FPTR_S_JOURNAL = 1; + public const int FPTR_S_RECEIPT = 2; + public const int FPTR_S_SLIP = 4; + public const int FPTR_SS_FULL_LENGTH = 1; + public const int FPTR_SS_VALIDATION = 2; + public const int FPTR_SUE_COVER_OK = 12; + public const int FPTR_SUE_COVER_OPEN = 11; + public const int FPTR_SUE_IDLE = 1001; + public const int FPTR_SUE_JRN_EMPTY = 21; + public const int FPTR_SUE_JRN_NEAREMPTY = 22; + public const int FPTR_SUE_JRN_PAPEROK = 23; + public const int FPTR_SUE_REC_EMPTY = 24; + public const int FPTR_SUE_REC_NEAREMPTY = 25; + public const int FPTR_SUE_REC_PAPEROK = 26; + public const int FPTR_SUE_SLP_EMPTY = 27; + public const int FPTR_SUE_SLP_NEAREMPTY = 28; + public const int FPTR_SUE_SLP_PAPEROK = 29; + public const int KBD_ET_DOWN = 1; + public const int KBD_ET_DOWN_UP = 2; + public const int KBD_KET_KEYDOWN = 1; + public const int KBD_KET_KEYUP = 2; + public const int LOCK_KP_ANY = 0; + public const int LOCK_KP_LOCK = 1; + public const int LOCK_KP_NORM = 2; + public const int LOCK_KP_SUPR = 3; + public const int MICR_CC_CANADA = 2; + public const int MICR_CC_MEXICO = 3; + public const int MICR_CC_UNKNOWN = 99; + public const int MICR_CC_USA = 1; + public const int MICR_CT_BUSINESS = 2; + public const int MICR_CT_PERSONAL = 1; + public const int MICR_CT_UNKNOWN = 99; + public const int MSR_ERT_CARD = 0; + public const int MSR_ERT_TRACK = 1; + public const int MSR_TR_1 = 1; + public const int MSR_TR_2 = 2; + public const int MSR_TR_3 = 4; + public const int OPOS_BC_DECIMAL = 2; + public const int OPOS_BC_NIBBLE = 1; + public const int OPOS_BC_NONE = 0; + public const int OPOS_CH_EXTERNAL = 2; + public const int OPOS_CH_INTERACTIVE = 3; + public const int OPOS_CH_INTERNAL = 1; + public const int OPOS_E_BUSY = 113; + public const int OPOS_E_CLAIMED = 102; + public const int OPOS_E_CLOSED = 101; + public const int OPOS_E_DISABLED = 105; + public const int OPOS_E_EXISTS = 110; + public const int OPOS_E_EXTENDED = 114; + public const int OPOS_E_FAILURE = 111; + public const int OPOS_E_ILLEGAL = 106; + public const int OPOS_E_NOEXIST = 109; + public const int OPOS_E_NOHARDWARE = 107; + public const int OPOS_E_NOSERVICE = 104; + public const int OPOS_E_NOTCLAIMED = 103; + public const int OPOS_E_OFFLINE = 108; + public const int OPOS_E_TIMEOUT = 112; + public const int OPOS_ECHAN_OVERDISPENSE = 201; + public const int OPOS_EFPTR_BAD_DATE = 219; + public const int OPOS_EFPTR_BAD_ITEM_AMOUNT = 214; + public const int OPOS_EFPTR_BAD_ITEM_DESCRIPTION = 215; + public const int OPOS_EFPTR_BAD_ITEM_QUANTITY = 213; + public const int OPOS_EFPTR_BAD_PRICE = 218; + public const int OPOS_EFPTR_BAD_VAT = 217; + public const int OPOS_EFPTR_CLOCK_ERROR = 209; + public const int OPOS_EFPTR_COVER_OPEN = 201; + public const int OPOS_EFPTR_FISCAL_MEMORY_DISCONNECTED = 211; + public const int OPOS_EFPTR_FISCAL_MEMORY_FULL = 210; + public const int OPOS_EFPTR_FISCAL_TOTALS_ERROR = 212; + public const int OPOS_EFPTR_JRN_EMPTY = 202; + public const int OPOS_EFPTR_MISSING_DEVICES = 206; + public const int OPOS_EFPTR_NEGATIVE_TOTAL = 220; + public const int OPOS_EFPTR_REC_EMPTY = 203; + public const int OPOS_EFPTR_RECEIPT_TOTAL_OVERFLOW = 216; + public const int OPOS_EFPTR_SLP_EMPTY = 204; + public const int OPOS_EFPTR_SLP_FORM = 205; + public const int OPOS_EFPTR_TECHNICAL_ASSISTANCE = 208; + public const int OPOS_EFPTR_WORD_NOT_ALLOWED = 221; + public const int OPOS_EFPTR_WRONG_STATE = 207; + public const int OPOS_EL_INPUT = 2; + public const int OPOS_EL_INPUT_DATA = 3; + public const int OPOS_EL_OUTPUT = 1; + public const int OPOS_EMICR_CHECK = 202; + public const int OPOS_EMICR_NOCHECK = 201; + public const int OPOS_EMSR_END = 202; + public const int OPOS_EMSR_LRC = 204; + public const int OPOS_EMSR_PARITY = 203; + public const int OPOS_EMSR_START = 201; + public const int OPOS_EPTR_BADFORMAT = 207; + public const int OPOS_EPTR_COVER_OPEN = 201; + public const int OPOS_EPTR_JRN_EMPTY = 202; + public const int OPOS_EPTR_REC_EMPTY = 203; + public const int OPOS_EPTR_SLP_EMPTY = 204; + public const int OPOS_EPTR_SLP_FORM = 205; + public const int OPOS_EPTR_TOOBIG = 206; + public const int OPOS_ER_CLEAR = 12; + public const int OPOS_ER_CONTINUEINPUT = 13; + public const int OPOS_ER_RETRY = 11; + public const int OPOS_EROD_BADCLK = 201; + public const int OPOS_EROD_NOBUFFERS = 204; + public const int OPOS_EROD_NOCLOCKS = 202; + public const int OPOS_EROD_NOREGION = 203; + public const int OPOS_EROD_NOROOM = 205; + public const int OPOS_ESCAL_OVERWEIGHT = 201; + public const int OPOS_ETOT_NOROOM = 201; + public const int OPOS_ETOT_VALIDATION = 202; + public const int OPOS_FOREVER = -1; + public const int OPOS_PN_DISABLED = 0; + public const int OPOS_PN_ENABLED = 1; + public const int OPOS_PR_ADVANCED = 2; + public const int OPOS_PR_NONE = 0; + public const int OPOS_PR_STANDARD = 1; + public const int OPOS_PS_OFF = 2002; + public const int OPOS_PS_OFF_OFFLINE = 2004; + public const int OPOS_PS_OFFLINE = 2003; + public const int OPOS_PS_ONLINE = 2001; + public const int OPOS_PS_UNKNOWN = 2000; + public const int OPOS_S_BUSY = 3; + public const int OPOS_S_CLOSED = 1; + public const int OPOS_S_ERROR = 4; + public const int OPOS_S_IDLE = 2; + public const int OPOS_SUCCESS = 0; + public const int OPOS_SUE_POWER_OFF = 2002; + public const int OPOS_SUE_POWER_OFF_OFFLINE = 2004; + public const int OPOS_SUE_POWER_OFFLINE = 2003; + public const int OPOS_SUE_POWER_ONLINE = 2001; + public const int OPOSERR = 100; + public const int OPOSERREXT = 200; + public const int PPAD_CANCEL = 2; + public const int PPAD_DISP_PINRESTRICTED = 2; + public const int PPAD_DISP_RESTRICTEDLIST = 3; + public const int PPAD_DISP_RESTRICTEDORDER = 4; + public const int PPAD_DISP_UNRESTRICTED = 1; + public const int PPAD_EFT_ABNORMAL = 2; + public const int PPAD_EFT_NORMAL = 1; + public const int PPAD_LANG_NONE = 1; + public const int PPAD_LANG_ONE = 2; + public const int PPAD_LANG_PINRESTRICTED = 3; + public const int PPAD_LANG_UNRESTRICTED = 4; + public const int PPAD_MSG_AMOUNTOK = 8; + public const int PPAD_MSG_APPROVED = 5; + public const int PPAD_MSG_CANCELED = 7; + public const int PPAD_MSG_DECLINED = 6; + public const int PPAD_MSG_ENTERPIN = 1; + public const int PPAD_MSG_ENTERVALIDPIN = 3; + public const int PPAD_MSG_IDLE = 10; + public const int PPAD_MSG_INSERTCARD = 12; + public const int PPAD_MSG_NOTREADY = 9; + public const int PPAD_MSG_PLEASEWAIT = 2; + public const int PPAD_MSG_RETRIESEXCEEDED = 4; + public const int PPAD_MSG_SELECTCARDTYPE = 13; + public const int PPAD_MSG_SLIDE_CARD = 11; + public const int PPAD_SUCCESS = 1; + public const int PPAD_TRANS_ADMIN = 5; + public const int PPAD_TRANS_CREDIT = 2; + public const int PPAD_TRANS_DEBIT = 1; + public const int PPAD_TRANS_INQ = 3; + public const int PPAD_TRANS_RECONCILE = 4; + public const int PTR_BC_CENTER = -2; + public const int PTR_BC_LEFT = -1; + public const int PTR_BC_RIGHT = -3; + public const int PTR_BC_TEXT_ABOVE = -12; + public const int PTR_BC_TEXT_BELOW = -13; + public const int PTR_BC_TEXT_NONE = -11; + public const int PTR_BCS_Codabar = 107; + public const int PTR_BCS_Code128 = 110; + public const int PTR_BCS_Code39 = 108; + public const int PTR_BCS_Code93 = 109; + public const int PTR_BCS_EAN128 = 120; + public const int PTR_BCS_EAN13 = 104; + public const int PTR_BCS_EAN13_S = 119; + public const int PTR_BCS_EAN8 = 103; + public const int PTR_BCS_EAN8_S = 118; + public const int PTR_BCS_ITF = 106; + public const int PTR_BCS_JAN13 = 104; + public const int PTR_BCS_JAN8 = 103; + public const int PTR_BCS_MAXICODE = 202; + public const int PTR_BCS_OCRA = 121; + public const int PTR_BCS_OCRB = 122; + public const int PTR_BCS_OTHER = 501; + public const int PTR_BCS_PDF417 = 201; + public const int PTR_BCS_TF = 105; + public const int PTR_BCS_UPCA = 101; + public const int PTR_BCS_UPCA_S = 111; + public const int PTR_BCS_UPCD1 = 113; + public const int PTR_BCS_UPCD2 = 114; + public const int PTR_BCS_UPCD3 = 115; + public const int PTR_BCS_UPCD4 = 116; + public const int PTR_BCS_UPCD5 = 117; + public const int PTR_BCS_UPCE = 102; + public const int PTR_BCS_UPCE_S = 112; + public const int PTR_BM_ASIS = -11; + public const int PTR_BM_CENTER = -2; + public const int PTR_BM_LEFT = -1; + public const int PTR_BM_RIGHT = -3; + public const int PTR_CCS_ALPHA = 1; + public const int PTR_CCS_ASCII = 998; + public const int PTR_CCS_KANA = 10; + public const int PTR_CCS_KANJI = 11; + public const int PTR_CP_FULLCUT = 100; + public const int PTR_CS_ASCII = 998; + public const int PTR_CS_WINDOWS = 999; + public const int PTR_EL_FATAL = 3; + public const int PTR_EL_NONE = 1; + public const int PTR_EL_RECOVERABLE = 2; + public const int PTR_L_BOTTOM = 2; + public const int PTR_L_TOP = 1; + public const int PTR_MM_DOTS = 1; + public const int PTR_MM_ENGLISH = 3; + public const int PTR_MM_METRIC = 4; + public const int PTR_MM_TWIPS = 2; + public const char PTR_RP_LEFT90 = 'f'; + public const char PTR_RP_NORMAL = ''; + public const char PTR_RP_RIGHT90 = 'e'; + public const char PTR_RP_ROTATE180 = 'g'; + public const int PTR_S_JOURNAL = 1; + public const int PTR_S_RECEIPT = 2; + public const int PTR_S_SLIP = 4; + public const int PTR_SUE_COVER_OK = 12; + public const int PTR_SUE_COVER_OPEN = 11; + public const int PTR_SUE_IDLE = 1001; + public const int PTR_SUE_JRN_EMPTY = 21; + public const int PTR_SUE_JRN_NEAREMPTY = 22; + public const int PTR_SUE_JRN_PAPEROK = 23; + public const int PTR_SUE_REC_EMPTY = 24; + public const int PTR_SUE_REC_NEAREMPTY = 25; + public const int PTR_SUE_REC_PAPEROK = 26; + public const int PTR_SUE_SLP_EMPTY = 27; + public const int PTR_SUE_SLP_NEAREMPTY = 28; + public const int PTR_SUE_SLP_PAPEROK = 29; + public const int PTR_TP_NORMAL = 12; + public const int PTR_TP_TRANSACTION = 11; + public const int ROD_BDR_DOUBLE = 2; + public const int ROD_BDR_SINGLE = 1; + public const int ROD_BDR_SOLID = 3; + public const int ROD_CLK_MOVE = 4; + public const int ROD_CLK_PAUSE = 2; + public const int ROD_CLK_RESUME = 3; + public const int ROD_CLK_START = 1; + public const int ROD_CLK_STOP = 5; + public const int ROD_CRS_BLOCK = 3; + public const int ROD_CRS_BLOCK_BLINK = 4; + public const int ROD_CRS_LINE = 1; + public const int ROD_CRS_LINE_BLINK = 2; + public const int ROD_CRS_OFF = 5; + public const int ROD_CS_ASCII = 998; + public const int ROD_CS_WINDOWS = 999; + public const char ROD_DE_TOUCH_DOWN = ''; + public const char ROD_DE_TOUCH_MOVE = ''; + public const char ROD_DE_TOUCH_UP = ''; + public const int ROD_TD_NORMAL = 12; + public const int ROD_TD_TRANSACTION = 11; + public const int ROD_UA_BLINK_OFF = 7; + public const int ROD_UA_BLINK_ON = 6; + public const int ROD_UA_INTENSITY_OFF = 3; + public const int ROD_UA_INTENSITY_ON = 2; + public const int ROD_UA_REVERSE_OFF = 5; + public const int ROD_UA_REVERSE_ON = 4; + public const int ROD_UA_SET = 1; + public const int SCAL_WU_GRAM = 1; + public const int SCAL_WU_KILOGRAM = 2; + public const int SCAL_WU_OUNCE = 3; + public const int SCAL_WU_POUND = 4; + public const int SCAN_SDT_Codabar = 107; + public const int SCAN_SDT_Code128 = 110; + public const int SCAN_SDT_Code39 = 108; + public const int SCAN_SDT_Code93 = 109; + public const int SCAN_SDT_EAN128 = 120; + public const int SCAN_SDT_EAN13 = 104; + public const int SCAN_SDT_EAN13_S = 119; + public const int SCAN_SDT_EAN8 = 103; + public const int SCAN_SDT_EAN8_S = 118; + public const int SCAN_SDT_ITF = 106; + public const int SCAN_SDT_JAN13 = 104; + public const int SCAN_SDT_JAN8 = 103; + public const int SCAN_SDT_MAXICODE = 202; + public const int SCAN_SDT_OCRA = 121; + public const int SCAN_SDT_OCRB = 122; + public const int SCAN_SDT_OTHER = 501; + public const int SCAN_SDT_PDF417 = 201; + public const int SCAN_SDT_TF = 105; + public const int SCAN_SDT_UNKNOWN = 0; + public const int SCAN_SDT_UPCA = 101; + public const int SCAN_SDT_UPCA_S = 111; + public const int SCAN_SDT_UPCD1 = 113; + public const int SCAN_SDT_UPCD2 = 114; + public const int SCAN_SDT_UPCD3 = 115; + public const int SCAN_SDT_UPCD4 = 116; + public const int SCAN_SDT_UPCD5 = 117; + public const int SCAN_SDT_UPCE = 102; + public const int SCAN_SDT_UPCE_S = 112; + } +} diff --git a/Agent/KPS/KPS.csproj b/Agent/KPS/KPS.csproj new file mode 100644 index 0000000..9b3b853 --- /dev/null +++ b/Agent/KPS/KPS.csproj @@ -0,0 +1,122 @@ + + + + + Debug + AnyCPU + {5D91CC0D-EB29-405A-BF21-3C52ADA8CC76} + Library + Properties + Cosmos.KPS + Agent.KPS + v4.0 + 512 + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\BIN\Cosmos.BaseFrame.dll + + + ..\..\..\BIN\Cosmos.ServiceProvider.dll + + + ..\..\..\BIN\Cosmos.UserFrame.dll + + + + + + + + + + + + + + + + Form + + + frmKPS.cs + + + + + + + + + + + + frmKPS.cs + + + + + {CCB90150-B81E-11D2-AB74-0040054C3719} + 1 + 0 + 0 + aximp + False + + + {CCB90150-B81E-11D2-AB74-0040054C3719} + 1 + 0 + 0 + tlbimp + False + True + + + + + {670a81be-cee3-4c29-846d-a37652ca270d} + CommonManager + + + {a5b7accd-79eb-4261-bd36-01ab484ad8e3} + Common + + + + + copy .\IC\Agent.KPS.dll .\Agent.KPS.dll + + + copy .\Agent.KPS.dll .\IC\Agent.KPS.dll + + + \ No newline at end of file diff --git a/Agent/KPS/KPSMain.cs b/Agent/KPS/KPSMain.cs new file mode 100644 index 0000000..f08abad --- /dev/null +++ b/Agent/KPS/KPSMain.cs @@ -0,0 +1,3986 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Data.SqlClient; +using System.Data; + +using Cosmos.Common; +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.CommonManager; +using Cosmos.ServiceProvider; +using System.Text.RegularExpressions; + +namespace Cosmos.KPS +{ + public class KPSMain : IKPSMain + { + /// + /// StateServer Object (StateServer 객체) + /// + private StateServer StateObject = (StateServer)StateServer.GetInstance(); + + /// + /// POS Status Value (POS 상태값) + /// + private PosStatus m_cPosStatus = null; + + private TranStatus m_cTrnStatus = null; + private DeviceStatus m_cDevStatus = null; + + /// + /// KPS Thread (KPS 스레드) + /// + private Thread m_tKPSProc = null; + + /// + /// KPS Proc Operation Yes/No (KPS Proc 작동여부) + /// + private bool m_KPSProcRunning = true; + + /// + /// MSSQL DB 관련 객체 + /// + private static SqlDB sqlDb = null; + + // 대기시간 + //private int WAIT_TIME = 3000; + //private int WAIT_TIME = 2000; + private int WAIT_TIME = 1000; + + private Hashtable m_htFloor; + private Hashtable m_htTable; + + //#20180515 KPS 출력시 라벨프린터 출력 start + private LabelPrinter m_cLabelPrtDevice = null; + //#20180515 KPS 출력시 라벨프린터 출력 end + + + public KPSMain() + { + m_cPosStatus = (PosStatus)StateObject.POS; + m_cTrnStatus = (TranStatus)StateObject.TRAN; + m_cDevStatus = (DeviceStatus)StateObject.DEVICE; + + m_htFloor = new Hashtable(); + m_htTable = new Hashtable(); + + //#20180515 KPS 출력시 라벨프린터 출력 start + m_cLabelPrtDevice = new LabelPrinter(); + //#20180515 KPS 출력시 라벨프린터 출력 end + + } + + public void StartKPS() + { + try + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "KPS Start"); + + // Database Connection + sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, m_cPosStatus.Base.LocalDbCatalog, m_cPosStatus.Base.LocalDbUserID, m_cPosStatus.Base.LocalDbPassword); + + m_tKPSProc = new Thread(new ThreadStart(KPSExecuteProc)); + m_KPSProcRunning = true; + m_tKPSProc.Start(); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + } + + /// + /// Get Floor Master + /// + /// + private void SelectFloor() + { + string sQuery = string.Empty; + DataTable dtData = null; + try + { + m_htFloor.Clear(); + sQuery = "SELECT FLOOR_CD, FLOOR_NM FROM POSMST..MST_FLOOR WITH(NOLOCK) " + + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' " + + " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' " + + " ORDER BY FLOOR_CD "; + + // 조회 + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK) + { + foreach (DataRow dr in dtData.Rows) + { + m_htFloor.Add(CmUtil.GetDataRowStr(dr, "FLOOR_CD"), CmUtil.GetDataRowStr(dr, "FLOOR_NM")); + } + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + } + + /// + /// Get Floor Name + /// + /// + /// + private String GetFloorName(string sFloorCd) + { + string sFloorName = sFloorCd; + + try + { + if (m_htFloor.Contains(sFloorCd)) + { + sFloorName = (string)m_htFloor[sFloorCd]; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + + return sFloorName; + } + + /// + /// Get Table Master + /// + /// + private void SelectTable() + { + string sQuery = string.Empty; + DataTable dtData = null; + + try + { + m_htTable.Clear(); + sQuery = "SELECT FLOOR_CD, TBL_NO, TBL_NM, TBL_DISP_DIV " + + " FROM POSMST..MST_TBL WITH(NOLOCK) " + + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' " + + " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' " + + " AND TRAIN_MODE_YN = '" + ItemConst.TRAINING_FLAG.TRAINING_NO + "' " + + " ORDER BY FLOOR_CD, TBL_NO "; + + // 조회 + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK) + { + foreach (DataRow dr in dtData.Rows) + { + TableMaster cTableMaster = new TableMaster(); + cTableMaster.sFloorCd = CmUtil.GetDataRowStr(dr, "FLOOR_CD"); + cTableMaster.sTableNo = CmUtil.GetDataRowStr(dr, "TBL_NO"); + cTableMaster.sTableNm = CmUtil.GetDataRowStr(dr, "TBL_NM"); + cTableMaster.sTableDispDiv = CmUtil.GetDataRowStr(dr, "TBL_DISP_DIV"); + + //if (string.IsNullOrWhiteSpace(cTableMaster.sTableDispDiv)) cTableMaster.sTableDispDiv = PosConst.TABLE_DISP_FLAG.TABLE_NAME; + cTableMaster.sTableDispDiv = PosConst.TABLE_DISP_FLAG.TABLE_NAME; + if (string.IsNullOrWhiteSpace(cTableMaster.sTableNm)) cTableMaster.sTableNm = cTableMaster.sTableNo; + + m_htTable.Add(m_htTable.Count, cTableMaster); + } + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + } + + /// + /// Get Table Name + /// + /// + /// + /// + private string GetTableName(string sFloorCd, string sTableNo) + { + string sTableName = sTableNo; + + try + { + for (int nLoop = 0; nLoop < m_htTable.Count; nLoop++) + { + TableMaster cTableMaster = (TableMaster)m_htTable[nLoop]; + + if (cTableMaster.sFloorCd == sFloorCd && cTableMaster.sTableNo == sTableNo) + { + //switch(cTableMaster.sTableDispDiv) + //{ + // case TABLE_DISP_FLAG.TABLE_NO: + // sTableName = cTableMaster.sTableNo; + // break; + // case TABLE_DISP_FLAG.TABLE_NAME: + // sTableName = cTableMaster.sTableNm; + // break; + // case TABLE_DISP_FLAG.TABLE_NO_NAME: + // sTableName = cTableMaster.sTableNo + cTableMaster.sTableNm; + // break; + //} + sTableName = cTableMaster.sTableNm; + break; + } + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + + return sTableName; + } + + private string GetCustInfo(string trainMode, string floorCd, string tableNo) + { + string retValue = string.Empty; + try + { + retValue = MessageManager.GetLabelMessage(POS_MESSAGE.PRINT.MSG_0159); + int totCnt = 0; + int mCnt = 0; + int fCnt = 0; + + DataTable dtData = null; + string sql = "SELECT CUST_CNT, FILLER2 FROM POSMST..MST_TBL WITH(NOLOCK) " + + " WHERE TRAIN_MODE_YN = '" + trainMode + "' " + + " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' " + + " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' " + + " AND FLOOR_CD = '" + floorCd + "' " + + " AND TBL_NO = '" + tableNo + "' " + ; + if (sqlDb.DBDataTableSelect(sql, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK) + { + var temp = string.Empty; + + temp = CmUtil.GetDataRowStr(dtData.Rows[0], "CUST_CNT"); + if (string.IsNullOrWhiteSpace(temp) == false) + { + totCnt = CmUtil.IntParse(temp); + } + + temp = CmUtil.GetDataRowStr(dtData.Rows[0], "FILLER2"); + if (string.IsNullOrWhiteSpace(temp) == false) + { + totCnt = 0; + var custList = temp.Split('|'); + for (var i = 0; i < custList.Count(); i++) + { + int cnt = CmUtil.IntParse(custList[i]); + totCnt += cnt; + if (i < 6) mCnt += cnt; else fCnt += cnt; + } + } + } + + if (totCnt > 0 && mCnt + fCnt == 0) + { + retValue = totCnt.ToString(); + } + else + { + retValue = string.Format(MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0159), totCnt, mCnt, fCnt); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + return retValue; + } + + private string GetAddOrderString(string type) + { + string retValue = type; + try + { + switch (m_cPosStatus.Base.Country + type) + { + case "ko-KRNEW": retValue = "신규"; break; + case "ko-KRADD": retValue = "추가"; break; + case "ko-KRDEL": retValue = "취소"; break; + } + } + catch { } + return retValue; + } + + private void KPSExecuteProc() + { + int nSelectCount = 60; + + while (m_KPSProcRunning) + { + try + { + string ktchErrorCode = string.Empty; + Hashtable htKPSSendingItem = new Hashtable(); + Hashtable htKtchDeviceStatus = new Hashtable(); + + // Set Wait Time + //Thread.Sleep(WAIT_TIME); + //nSelectCount += (WAIT_TIME / 1000); + + // Get Print Message + if (nSelectCount >= 60) + { + if (m_cPosStatus.Base.PosType == PosConst.POS_TYPE.DEFERRED_PAYMENT) + { + //SelectFloor(); + //SelectTable(); + } + nSelectCount = 0; + } + + // KPS Send Item Make + KPSSendItemMake(); + + // Get item sending to KPS + htKPSSendingItem = new Hashtable(); + GetKPSSendItem(ref htKPSSendingItem); + + if (htKPSSendingItem.Count > 0) + { + // KPS Print + htKtchDeviceStatus = new Hashtable(); + KPSPrintProc(ref htKPSSendingItem, ref htKtchDeviceStatus, ref ktchErrorCode); + + // KPS Print Status Update + KPSPrintStatusUpdate(htKPSSendingItem, htKtchDeviceStatus); + } + + // Get KPS Order Message + htKPSSendingItem = new Hashtable(); + GetKPSOrderMessage(ref htKPSSendingItem); + + if (htKPSSendingItem.Count > 0) + { + // KPS Order Message Print + htKtchDeviceStatus = new Hashtable(); + KPSOrderMessagePrintProc(ref htKPSSendingItem, ref htKtchDeviceStatus, ref ktchErrorCode); + + // KPS Order Message + KPSOrderMessagePrintStatusDelete(htKPSSendingItem, htKtchDeviceStatus); + } + + //#20180515 KPS 출력시 라벨프린터 출력 start + // Get item sending to Label print + + if (m_cDevStatus.LabelPrinter.UseYn == true) + { + htKPSSendingItem = new Hashtable(); + GetLBLPRTSendItem(ref htKPSSendingItem); + + if (htKPSSendingItem.Count > 0) + { + // Label Print + htKtchDeviceStatus = new Hashtable(); + LBLPRTPrintProc(ref htKPSSendingItem); + + // KPS Print Status Update + LBLPRTPrintStatusUpdate(htKPSSendingItem, htKtchDeviceStatus); + } + } + //#20180515 KPS 출력시 라벨프린터 출력 end + + // Add, 2017.02.15, 영수증프린터로 주문서 출력을 위해 장치오류코드 설정 + if (string.IsNullOrWhiteSpace(ktchErrorCode) == false) + { + if (string.IsNullOrWhiteSpace(m_cPosStatus.Sale.KtchPrintErrorCode) || m_cPosStatus.Sale.KtchPrintErrorCode == "XXXX") + { + m_cPosStatus.Sale.KtchPrintErrorCode = ktchErrorCode; + } + } + + int nNowSleepTerm = 0; + while (nNowSleepTerm < WAIT_TIME) + { + if (m_KPSProcRunning == false) break; + Thread.Sleep(100); + nNowSleepTerm += 100; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + } + } + + public void StopKPS() + { + try + { + m_KPSProcRunning = false; + + int count = 0; + while (count < 10) + { + if (m_tKPSProc != null && m_tKPSProc.IsAlive) m_KPSProcRunning = false; + else break; + + count++; + Thread.Sleep(100); + } + + if (count == 10) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.INFO_LEVEL, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "Force KPS Agent Stop!!!"); + m_tKPSProc.Abort(); + } + + // DB Close + sqlDb.DBClose(); + + UserLog.WriteLogFile(UserCom.LOG_IOS, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "KPS Stop"); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + } + + private bool KPSSendItemMake() + { + bool bRet = false; + string sQuery = string.Empty; + + Hashtable htKPSSendingItem = new Hashtable(); + + try + { + #region (주석) 수동출력옵션 적용 이전버전 + //sQuery = "SELECT A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, B.KTCH_SYS_CD, A.SEQ "; + //sQuery += " , A.TRADE_NO, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM "; + //sQuery += " , A.SALE_QTY, A.PACK_DIV, A.SET_MENU_CD, A.ORD_TIME, A.CANCEL_DIV, A.SUB_MEMO_DIV "; + //sQuery += " , A.RESEND_YN, C.KTCH_SYS_USE_DIV, C.KTCH_PRINTER_COMM_PORT, C.KTCH_PRINTER_COMM_SPEED, C.KTCH_PRINTER_OPOS_NM "; + //sQuery += " , C.KTCH_PRINTER_IP, C.KTCH_PRINTER_PORT, C.KTCH_PRINTER_BAK1, C.KTCH_PRINTER_BAK2, C.KTCH_PRINTER_BAK3 "; + //sQuery += " , C.KTCH_PRINTER_BAK4, C.KTCH_PRINTER_BAK5, C.KTCH_PRINTER_BAK6, C.FILLER1, C.FILLER2 "; + //sQuery += " , C.FILLER3, C.FILLER4, C.FILLER5 "; + //sQuery += " FROM POSMST..MST_KTCH_ORD_MSG A "; + //sQuery += " , POSMST..MST_KTCH_DEVICE_ITEM B "; + //sQuery += " , POSMST..MST_KTCH_DEVICE C "; + //sQuery += " WHERE A.SEND_YN = '0' "; + //sQuery += " AND A.ITEM_DIV IN ('0', '1', '2', '3', '4') "; // '0':일반, '1':세트, '2':세트자식, '3':부가상품, '4':세트할인 + //sQuery += " AND B.ITEM_CD = A.ITEM_CD "; + //sQuery += " AND (B.FLOOR_CD = A.FLOOR_CD OR B.FLOOR_CD = '999') "; + //sQuery += " AND B.KTCH_SYS_CD = C.KTCH_SYS_CD "; + //sQuery += " AND C.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + //sQuery += " AND C.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + //sQuery += " AND C.KTCH_SYS_DIV = '1' "; // '1':KPS, '2':KVS + //sQuery += " AND C.USE_YN = '1' "; + #endregion + + #region (주석) 복합매장 적용 이전 버전 + // 주방프린터 자동출력 여부 0:자동 1:수동(프린터선택, 99:전체) 2:수동(상품선택) + //if (PosMstManager.GetPosOption(POS_OPTION.OPT425) == "1") + //{ + // 1:수동(프린터선택, 99:전체) + // sQuery = "SELECT A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, C.KTCH_SYS_CD, A.SEQ \n" + // + " , A.TRADE_NO, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM \n" + // + " , A.SALE_QTY, A.PACK_DIV, A.SET_MENU_CD, A.ORD_TIME, A.CANCEL_DIV, A.SUB_MEMO_DIV \n" + // + " , A.RESEND_YN, C.KTCH_SYS_USE_DIV, C.KTCH_PRINTER_COMM_PORT, C.KTCH_PRINTER_COMM_SPEED, C.KTCH_PRINTER_OPOS_NM \n" + // + " , C.KTCH_PRINTER_IP, C.KTCH_PRINTER_PORT, C.KTCH_PRINTER_BAK1, C.KTCH_PRINTER_BAK2, C.KTCH_PRINTER_BAK3, C.KTCH_PRINTER_BAK4, C.KTCH_PRINTER_BAK5, C.KTCH_PRINTER_BAK6 \n" + // //+ " , C.FILLER1, C.FILLER2, C.FILLER3, C.FILLER4, C.FILLER5 \n" + // + " , C.FILLER1, C.FILLER3, C.FILLER4, C.FILLER5 \n" + // + " , A.MSG1, A.MSG2, A.MSG3, A.FILLER2 AS ETC_ORD_FLAG \n" + // + " FROM POSMST..MST_KTCH_ORD_MSG A \n" + // + " , POSMST..MST_KTCH_DEVICE_ITEM B \n" + // + " , POSMST..MST_KTCH_DEVICE C \n" + // + " WHERE A.SEND_YN = '0' \n" + // + " AND A.ITEM_DIV IN ('0', '1', '2', '3', '4') \n" // '0':일반, '1':세트, '2':세트자식, '3':부가상품, '4':세트할인 + // + " AND B.ITEM_CD = A.ITEM_CD \n" + // + " AND (B.FLOOR_CD = A.FLOOR_CD OR B.FLOOR_CD = '999') \n" + + // //+ " AND B.KTCH_SYS_CD = A.FILLER1 \n" + // //+ " AND CASE WHEN A.FILLER1 = '99' THEN 1 ELSE B.KTCH_SYS_CD END \n" + // //+ " = CASE WHEN A.FILLER1 = '99' THEN 1 ELSE C.KTCH_SYS_CD END \n" + // + " AND B.SUB_STOR_CD + B.KTCH_SYS_CD = A.FILLER1 \n" + // + " AND CASE WHEN A.FILLER1 = '99' THEN 1 ELSE B.SUB_STOR_CD + B.KTCH_SYS_CD END \n" + // + " = CASE WHEN A.FILLER1 = '99' THEN 1 ELSE C.SUB_STOR_CD + C.KTCH_SYS_CD END \n" + + // + " AND C.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + // + " AND C.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + // + " AND C.KTCH_SYS_DIV = '1' \n" // '1':KPS, '2':KVS + // + " AND C.USE_YN = '1' \n" + // + " AND B.USE_YN = '1' \n" + // + " AND C.KTCH_SYS_CD <> '99' \n" + // ; + //} + //else if (PosMstManager.GetPosOption(POS_OPTION.OPT425) == "2") + //{ + // 2:수동(상품선택) + // sQuery = "SELECT A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, B.KTCH_SYS_CD, A.SEQ \n" + // + " , A.TRADE_NO, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM \n" + // + " , A.SALE_QTY, A.PACK_DIV, A.SET_MENU_CD, A.ORD_TIME, A.CANCEL_DIV, A.SUB_MEMO_DIV \n" + // + " , A.RESEND_YN, C.KTCH_SYS_USE_DIV, C.KTCH_PRINTER_COMM_PORT, C.KTCH_PRINTER_COMM_SPEED, C.KTCH_PRINTER_OPOS_NM \n" + // + " , C.KTCH_PRINTER_IP, C.KTCH_PRINTER_PORT, C.KTCH_PRINTER_BAK1, C.KTCH_PRINTER_BAK2, C.KTCH_PRINTER_BAK3, C.KTCH_PRINTER_BAK4, C.KTCH_PRINTER_BAK5, C.KTCH_PRINTER_BAK6 \n" + // //+ " , C.FILLER1, C.FILLER2, C.FILLER3, C.FILLER4, C.FILLER5 \n" + // + " , C.FILLER1, C.FILLER3, C.FILLER4, C.FILLER5 \n" + // + " , A.MSG1, A.MSG2, A.MSG3, A.FILLER2 AS ETC_ORD_FLAG \n" + // + " FROM POSMST..MST_KTCH_ORD_MSG A \n" + // + " , POSMST..MST_KTCH_DEVICE_ITEM B \n" + // + " , POSMST..MST_KTCH_DEVICE C \n" + // + " WHERE A.SEND_YN = '0' \n" + // + " AND A.ITEM_DIV IN ('0', '1', '2', '3', '4') \n" // '0':일반, '1':세트, '2':세트자식, '3':부가상품, '4':세트할인 + // + " AND B.ITEM_CD = A.ITEM_CD \n" + // + " AND (B.FLOOR_CD = A.FLOOR_CD OR B.FLOOR_CD = '999') \n" + + // + " AND B.SUB_STOR_CD = C.SUB_STOR_CD \n" + // + " AND B.KTCH_SYS_CD = C.KTCH_SYS_CD \n" + + // + " AND C.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + // + " AND C.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + // + " AND C.KTCH_SYS_DIV = '1' \n" // '1':KPS, '2':KVS + // + " AND C.USE_YN = '1' \n" + // + " AND B.USE_YN = '1' \n" + + // //+ " AND A.ITEM_CD = A.FILLER1 \n" // 선택한 상품만 출력 + // + " AND A.SUB_STOR_CD + A.ITEM_CD = A.FILLER1 \n" // 선택한 상품만 출력 + + // + " AND B.KTCH_SYS_CD <> '99' \n" // 99번 장치관련 상품은 출력하지 않는다. + // + " AND C.KTCH_SYS_CD <> '99' \n" + // ; + //} + //else + //{ + // 0:자동 + // sQuery = "SELECT A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, B.KTCH_SYS_CD, A.SEQ \n" + // + " , A.TRADE_NO, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM \n" + // + " , A.SALE_QTY, A.PACK_DIV, A.SET_MENU_CD, A.ORD_TIME, A.CANCEL_DIV, A.SUB_MEMO_DIV \n" + // + " , A.RESEND_YN, C.KTCH_SYS_USE_DIV, C.KTCH_PRINTER_COMM_PORT, C.KTCH_PRINTER_COMM_SPEED, C.KTCH_PRINTER_OPOS_NM \n" + // + " , C.KTCH_PRINTER_IP, C.KTCH_PRINTER_PORT, C.KTCH_PRINTER_BAK1, C.KTCH_PRINTER_BAK2, C.KTCH_PRINTER_BAK3, C.KTCH_PRINTER_BAK4, C.KTCH_PRINTER_BAK5, C.KTCH_PRINTER_BAK6 \n" + // //+ " , C.FILLER1, C.FILLER2, C.FILLER3, C.FILLER4, C.FILLER5 \n" + // + " , C.FILLER1, C.FILLER3, C.FILLER4, C.FILLER5 \n" + // + " , A.MSG1, A.MSG2, A.MSG3, A.FILLER2 AS ETC_ORD_FLAG \n" + // + " FROM POSMST..MST_KTCH_ORD_MSG A \n" + // + " , POSMST..MST_KTCH_DEVICE_ITEM B \n" + // + " , POSMST..MST_KTCH_DEVICE C \n" + // + " WHERE A.SEND_YN = '0' \n" + // + " AND A.ITEM_DIV IN ('0', '1', '2', '3', '4') \n" // '0':일반, '1':세트, '2':세트자식, '3':부가상품, '4':세트할인 + // //+ " AND B.ITEM_CD = A.ITEM_CD \n" + // + " AND A.SUB_STOR_CD = B.SUB_STOR_CD \n" + // + " AND A.ITEM_CD = B.ITEM_CD \n" + // + " AND (B.FLOOR_CD = A.FLOOR_CD OR B.FLOOR_CD = '999') \n" + // + " AND B.KTCH_SYS_CD = C.KTCH_SYS_CD \n" + // + " AND C.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + // + " AND C.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + // + " AND C.KTCH_SYS_DIV = '1' \n" // '1':KPS, '2':KVS + // + " AND C.USE_YN = '1' \n" + // + " AND B.USE_YN = '1' \n" + // //+ " AND B.KTCH_SYS_CD <> '99' \n" // 99번 장치관련 상품은 출력하지 않는다. + // + " AND C.KTCH_SYS_CD <> '99' \n" + // ; + //} + #endregion + + + #region (주석) 기존 POS 로직 + + // 주방프린터 자동출력 여부 0:자동 1:수동(프린터선택, 99:전체) 2:수동(상품선택) + //if (PosMstManager.GetPosOption(POS_OPTION.OPT425) == "1") + //{ + // // 1:수동(프린터선택, 99:전체) + // sQuery = "SELECT DISTINCT \n" + // //+ " A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ, A.TRADE_NO, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM \n" // Add, 2017.03.03, 연습모드 + // + " A.TRAIN_MODE_YN, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ, A.TRADE_NO, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM \n" + // + " , A.SALE_QTY, A.PACK_DIV, A.SET_MENU_CD, A.ORD_TIME, A.CANCEL_DIV, A.SUB_MEMO_DIV, A.RESEND_YN \n" + // + " , A.MSG1, A.MSG2, A.MSG3, A.FILLER2 AS ETC_ORD_FLAG, A.FILLER3 AS ADD_ORD_FLAG \n" + // + " , C.POS_NO \n" // Add, 2017.06.14 POS별 주방프린터 설정 + // + " , C.SUB_STOR_CD, C.KTCH_SYS_CD \n" + // + " , C.KTCH_SYS_USE_DIV, C.KTCH_PRINTER_COMM_PORT, C.KTCH_PRINTER_COMM_SPEED, C.KTCH_PRINTER_OPOS_NM, C.KTCH_PRINTER_IP, C.KTCH_PRINTER_PORT \n" + // + " , C.FILLER1, C.FILLER3, C.FILLER4, C.FILLER5, ISNULL(C.PRT_CNT, 1) AS PRT_CNT \n" + // + " , A.KTCH_MSG \n" // Add, 2017.03.21 + // + " , A.ORD_PIC_NM \n" // Add, 2017.03.28, 주문담당자 + // + " , A.ORG_QTY \n" // Add, 2017.03.31 + // + " , A.ORD_POS_NO \n" // Add, 2017.04.10 + // + " , A.FILLER5 AS ORDER_SEQ \n" // Add, 2017.04.11 + // + " FROM POSMST..MST_KTCH_ORD_MSG A \n" + // + " , POSMST..MST_KTCH_DEVICE_ITEM B WITH(NOLOCK) \n" + // + " , POSMST..MST_KTCH_DEVICE C WITH(NOLOCK) \n" + // + " WHERE A.CMP_CD = B.CMP_CD AND A.STOR_CD = B.STOR_CD AND A.SUB_STOR_CD = B.SUB_STOR_CD AND A.ITEM_CD = B.ITEM_CD \n" + // + " AND (A.FLOOR_CD = B.FLOOR_CD OR '999' = B.FLOOR_CD) \n" + + // //#20180221 복합매장인 경우 주방출력상품을 장치코드 99에 등록하면 여러장 출력되는 증상 수정 start + // //기존 + // //+ " AND B.CMP_CD = C.CMP_CD AND B.STOR_CD = C.STOR_CD \n" + // //변경 + // + " AND B.CMP_CD = C.CMP_CD AND B.STOR_CD = C.STOR_CD AND B.SUB_STOR_CD = C.SUB_STOR_CD \n" + // //#20180221 복합매장인 경우 주방출력상품을 장치코드 99에 등록하면 여러장 출력되는 증상 수정 end + + // + " AND CASE WHEN B.KTCH_SYS_CD = '99' OR A.FILLER1 = '99' THEN '1' ELSE B.SUB_STOR_CD + B.KTCH_SYS_CD END \n" + // + " = CASE WHEN B.KTCH_SYS_CD = '99' OR A.FILLER1 = '99' THEN '1' ELSE C.SUB_STOR_CD + C.KTCH_SYS_CD END \n" + // + " AND CASE WHEN A.FILLER1 = '99' THEN '1' ELSE A.FILLER1 END \n" // 선택장치조건 + // + " = CASE WHEN A.FILLER1 = '99' THEN '1' ELSE C.SUB_STOR_CD + C.KTCH_SYS_CD END \n" + // + " AND A.TRAIN_MODE_YN IN ('0', '1') " // Add, 2017.03.03, 연습모드 + // + " AND A.ORD_DIV = '0' \n" + // + " AND A.SEND_YN = '0' \n" + // + " AND A.ITEM_DIV IN ('0', '1', '2', '3', '4') \n" + // + " AND A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + // + " AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + // + " AND A.ORD_POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n" // Add, 2017.04.10 + // + " AND B.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" + // + " AND C.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" + // + " AND C.KTCH_SYS_DIV = '" + PosConst.KTCH_SYS_DIV.KPS + "' \n" + // + " AND C.KTCH_SYS_CD <> '99' \n" + // + " ORDER BY C.SUB_STOR_CD, C.KTCH_SYS_CD \n" + // ; + //} + //else if (PosMstManager.GetPosOption(POS_OPTION.OPT425) == "2") + //{ + // // 2:수동(상품선택) + // sQuery = "SELECT DISTINCT \n" + // //+ " A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ, A.TRADE_NO, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM \n" // Add, 2017.03.03, 연습모드 + // + " A.TRAIN_MODE_YN, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ, A.TRADE_NO, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM \n" + // + " , A.SALE_QTY, A.PACK_DIV, A.SET_MENU_CD, A.ORD_TIME, A.CANCEL_DIV, A.SUB_MEMO_DIV, A.RESEND_YN \n" + // + " , A.MSG1, A.MSG2, A.MSG3, A.FILLER2 AS ETC_ORD_FLAG, A.FILLER3 AS ADD_ORD_FLAG \n" + // + " , C.POS_NO \n" // Add, 2017.06.14 POS별 주방프린터 설정 + // + " , C.SUB_STOR_CD, C.KTCH_SYS_CD \n" + // + " , C.KTCH_SYS_USE_DIV, C.KTCH_PRINTER_COMM_PORT, C.KTCH_PRINTER_COMM_SPEED, C.KTCH_PRINTER_OPOS_NM, C.KTCH_PRINTER_IP, C.KTCH_PRINTER_PORT \n" + // + " , C.FILLER1, C.FILLER3, C.FILLER4, C.FILLER5, ISNULL(C.PRT_CNT, 1) AS PRT_CNT \n" + // + " , A.KTCH_MSG \n" // Add, 2017.03.21 + // + " , A.ORD_PIC_NM \n" // Add, 2017.03.28, 주문담당자 + // + " , A.ORG_QTY \n" // Add, 2017.03.31 + // + " , A.ORD_POS_NO \n" // Add, 2017.04.10 + // + " , A.FILLER5 AS ORDER_SEQ \n" // Add, 2017.04.11 + // + " FROM POSMST..MST_KTCH_ORD_MSG A \n" + // + " , POSMST..MST_KTCH_DEVICE_ITEM B WITH(NOLOCK) \n" + // + " , POSMST..MST_KTCH_DEVICE C WITH(NOLOCK) \n" + // + " WHERE A.CMP_CD = B.CMP_CD AND A.STOR_CD = B.STOR_CD AND A.SUB_STOR_CD = B.SUB_STOR_CD AND A.ITEM_CD = B.ITEM_CD \n" + // + " AND (A.FLOOR_CD = B.FLOOR_CD OR '999' = B.FLOOR_CD) \n" + + // //#20180221 복합매장인 경우 주방출력상품을 장치코드 99에 등록하면 여러장 출력되는 증상 수정 start + // //기존 + // //+ " AND B.CMP_CD = C.CMP_CD AND B.STOR_CD = C.STOR_CD \n" + // //변경 + // + " AND B.CMP_CD = C.CMP_CD AND B.STOR_CD = C.STOR_CD AND B.SUB_STOR_CD = C.SUB_STOR_CD \n" + // //#20180221 복합매장인 경우 주방출력상품을 장치코드 99에 등록하면 여러장 출력되는 증상 수정 end + + // + " AND CASE WHEN B.KTCH_SYS_CD = '99' THEN '1' ELSE B.SUB_STOR_CD + B.KTCH_SYS_CD END \n" + // + " = CASE WHEN B.KTCH_SYS_CD = '99' THEN '1' ELSE C.SUB_STOR_CD + C.KTCH_SYS_CD END \n" + // + " AND A.FILLER1 = 'PRINT' \n" // 선택한 상품만 출력 + // + " AND A.TRAIN_MODE_YN IN ('0', '1') " // Add, 2017.03.03, 연습모드 + // + " AND A.ORD_DIV = '0' \n" + // + " AND A.SEND_YN = '0' \n" + // + " AND A.ITEM_DIV IN ('0', '1', '2', '3', '4') \n" + // + " AND A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + // + " AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + // + " AND A.ORD_POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n" // Add, 2017.04.10 + // + " AND B.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" + // + " AND C.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" + // + " AND C.KTCH_SYS_DIV = '" + PosConst.KTCH_SYS_DIV.KPS + "' \n" + // + " AND C.KTCH_SYS_CD <> '99' \n" + // + " ORDER BY C.SUB_STOR_CD, C.KTCH_SYS_CD \n" + // ; + //} + //else + //{ + // // 0:자동 + // sQuery = "SELECT DISTINCT \n" + // //+ " A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ, A.TRADE_NO, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM \n" // Add, 2017.03.03, 연습모드 + // + " A.TRAIN_MODE_YN, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ, A.TRADE_NO, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM \n" + // + " , A.SALE_QTY, A.PACK_DIV, A.SET_MENU_CD, A.ORD_TIME, A.CANCEL_DIV, A.SUB_MEMO_DIV, A.RESEND_YN \n" + // + " , A.MSG1, A.MSG2, A.MSG3, A.FILLER2 AS ETC_ORD_FLAG, A.FILLER3 AS ADD_ORD_FLAG \n" + // + " , C.POS_NO \n" // Add, 2017.06.12, POS별 주방프린터 설정 + // + " , C.SUB_STOR_CD, C.KTCH_SYS_CD \n" + // + " , C.KTCH_SYS_USE_DIV, C.KTCH_PRINTER_COMM_PORT, C.KTCH_PRINTER_COMM_SPEED, C.KTCH_PRINTER_OPOS_NM, C.KTCH_PRINTER_IP, C.KTCH_PRINTER_PORT \n" + // + " , C.FILLER1, C.FILLER3, C.FILLER4, C.FILLER5, ISNULL(C.PRT_CNT, 1) AS PRT_CNT \n" + // + " , A.KTCH_MSG \n" // Add, 2017.03.21 + // + " , A.ORD_PIC_NM \n" // Add, 2017.03.28, 주문담당자 + // + " , A.ORG_QTY \n" // Add, 2017.03.31 + // + " , A.ORD_POS_NO \n" // Add, 2017.04.10 + // + " , A.FILLER5 AS ORDER_SEQ \n" // Add, 2017.04.11 + // + " FROM POSMST..MST_KTCH_ORD_MSG A \n" + // + " , POSMST..MST_KTCH_DEVICE_ITEM B WITH(NOLOCK) \n" + // + " , POSMST..MST_KTCH_DEVICE C WITH(NOLOCK) \n" + // + " WHERE A.CMP_CD = B.CMP_CD AND A.STOR_CD = B.STOR_CD AND A.SUB_STOR_CD = B.SUB_STOR_CD AND A.ITEM_CD = B.ITEM_CD \n" + // + " AND (A.FLOOR_CD = B.FLOOR_CD OR '999' = B.FLOOR_CD) \n" + + // //#20180221 복합매장인 경우 주방출력상품을 장치코드 99에 등록하면 여러장 출력되는 증상 수정 start + // //기존 + // //+ " AND B.CMP_CD = C.CMP_CD AND B.STOR_CD = C.STOR_CD \n" + // //변경 + // + " AND B.CMP_CD = C.CMP_CD AND B.STOR_CD = C.STOR_CD AND B.SUB_STOR_CD = C.SUB_STOR_CD \n" + // //#20180221 복합매장인 경우 주방출력상품을 장치코드 99에 등록하면 여러장 출력되는 증상 수정 end + + // + " AND CASE WHEN B.KTCH_SYS_CD = '99' THEN '1' ELSE B.SUB_STOR_CD + B.KTCH_SYS_CD END \n" + // + " = CASE WHEN B.KTCH_SYS_CD = '99' THEN '1' ELSE C.SUB_STOR_CD + C.KTCH_SYS_CD END \n" + // + " AND A.TRAIN_MODE_YN IN ('0', '1') " // Add, 2017.03.03, 연습모드 + // + " AND A.ORD_DIV = '0' \n" + // + " AND A.SEND_YN = '0' \n" + // + " AND A.ITEM_DIV IN ('0', '1', '2', '3', '4') \n" + // + " AND A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + // + " AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + // + " AND A.ORD_POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n" // Add, 2017.04.10 + // + " AND B.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" + // + " AND C.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" + // + " AND C.KTCH_SYS_DIV = '" + PosConst.KTCH_SYS_DIV.KPS + "' \n" + // + " AND C.KTCH_SYS_CD <> '99' \n" + // + " ORDER BY C.SUB_STOR_CD, C.KTCH_SYS_CD \n" + // ; + //} + #endregion + + + #region 해피스테이션 로직 + + sQuery = "SELECT DISTINCT \n" + + " A.TRAIN_MODE_YN, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ, A.TRADE_NO, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM \n" + + " , A.SALE_QTY, A.PACK_DIV, A.SET_MENU_CD, A.ORD_TIME, A.CANCEL_DIV, A.SUB_MEMO_DIV, A.RESEND_YN \n" + + " , A.MSG1, A.MSG2, A.MSG3, A.FILLER2 AS ETC_ORD_FLAG, A.FILLER3 AS ADD_ORD_FLAG \n" + + " , C.POS_NO \n" // Add, 2017.06.12, POS별 주방프린터 설정 + + " , C.SUB_STOR_CD, C.KTCH_SYS_CD \n" + + " , C.KTCH_SYS_USE_DIV, C.KTCH_PRINTER_COMM_PORT, C.KTCH_PRINTER_COMM_SPEED, C.KTCH_PRINTER_OPOS_NM, C.KTCH_PRINTER_IP, C.KTCH_PRINTER_PORT \n" + + " , C.FILLER1, C.FILLER3, C.FILLER4, C.FILLER5, ISNULL(C.PRT_CNT, 1) AS PRT_CNT \n" + + " , A.KTCH_MSG \n" // Add, 2017.03.21 + + " , A.ORD_PIC_NM \n" // Add, 2017.03.28, 주문담당자 + + " , A.ORG_QTY \n" // Add, 2017.03.31 + + " , A.ORD_POS_NO \n" // Add, 2017.04.10 + + " , A.FILLER5 AS ORDER_SEQ \n" // Add, 2017.04.11 + + " FROM POSMST..MST_KTCH_ORD_MSG A \n" + + " , POSMST..MST_KTCH_DEVICE_ITEM B WITH(NOLOCK) \n" + + " , POSMST..MST_KTCH_DEVICE C WITH(NOLOCK) \n" + + " WHERE A.CMP_CD = B.CMP_CD AND A.STOR_CD = B.STOR_CD AND A.SUB_STOR_CD = B.SUB_STOR_CD AND A.ITEM_CD = B.ITEM_CD \n" + + " AND (A.FLOOR_CD = B.FLOOR_CD OR '999' = B.FLOOR_CD) \n" + + + " AND B.CMP_CD = C.CMP_CD AND B.STOR_CD = C.STOR_CD AND B.SUB_STOR_CD = C.SUB_STOR_CD \n" + + + " AND CASE WHEN B.KTCH_SYS_CD = '99' THEN '1' ELSE B.SUB_STOR_CD + B.KTCH_SYS_CD END \n" + + " = CASE WHEN B.KTCH_SYS_CD = '99' THEN '1' ELSE C.SUB_STOR_CD + C.KTCH_SYS_CD END \n" + + " AND A.TRAIN_MODE_YN IN ('0', '1') " // Add, 2017.03.03, 연습모드 + + " AND A.ORD_DIV = '0' \n" + + " AND A.SEND_YN = '0' \n" + + " AND A.ITEM_DIV IN ('0', '1', '2', '3', '4') \n" + + " AND A.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + + " AND A.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + + " AND A.ORD_POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n" // Add, 2017.04.10 + + " AND B.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" + + " AND C.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" + + " AND C.KTCH_SYS_DIV = '" + PosConst.KTCH_SYS_DIV.KPS + "' \n" + + " AND C.KTCH_SYS_CD <> '99' \n" + + " ORDER BY C.SUB_STOR_CD, C.KTCH_SYS_CD \n" + ; + #endregion + + // 조회 + DataTable dtData = null; + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) != UserCom.OK) + { + return false; + } + + if(dtData == null || dtData.Rows.Count == 0) + { + return false; + } + + DataRow[] arRows = null; + arRows = dtData.Select("POS_NO = '" + m_cPosStatus.Base.PosNo + "'"); + if (arRows.Length == 0) + arRows = dtData.Select("POS_NO = '00'"); + + + //foreach (DataRow dr in dtData.Rows) + foreach (DataRow dr in arRows) + { + KPSItem cKPSItem = new KPSItem(); + + cKPSItem.sTrainMode = CmUtil.GetDataRowStr(dr, "TRAIN_MODE_YN"); // Add, 2017.03.03, 연습모드 + + cKPSItem.sOrderType = CmUtil.GetDataRowStr(dr, "ORD_DIV"); + cKPSItem.sFloorCd = CmUtil.GetDataRowStr(dr, "FLOOR_CD"); + cKPSItem.sTableNo = CmUtil.GetDataRowStr(dr, "TBL_NO"); + + cKPSItem.sSubShopCd = CmUtil.GetDataRowStr(dr, "SUB_STOR_CD"); + cKPSItem.sKtchSysCd = CmUtil.GetDataRowStr(dr, "KTCH_SYS_CD"); + + cKPSItem.nSeq = CmUtil.GetDataRowInt(dr, "SEQ"); + cKPSItem.sOrderNo = CmUtil.GetDataRowStr(dr, "TRADE_NO"); + + if (string.IsNullOrWhiteSpace(CmUtil.GetDataRowStr(dr, "ORDER_SEQ")) == false) // Add, 2017.04.11, 후불테이블 일때 주문번호-주문차수 처리 + { + cKPSItem.sOrderNo = CmUtil.GetDataRowStr(dr, "TRADE_NO") + "-" + CmUtil.GetDataRowStr(dr, "ORDER_SEQ"); + } + + cKPSItem.sPosType = CmUtil.GetDataRowStr(dr, "POS_TYPE"); + cKPSItem.sItemCd = CmUtil.GetDataRowStr(dr, "ITEM_CD"); + cKPSItem.sItemDiv = CmUtil.GetDataRowStr(dr, "ITEM_DIV"); + cKPSItem.sItemNm = CmUtil.GetDataRowStr(dr, "SHTCUT_ITEMNM"); + + // Mod, 2017.03.31 + //cKPSItem.nQty = CmUtil.GetDataRowInt(dr, "SALE_QTY"); + cKPSItem.nQty = CmUtil.GetDataRowInt(dr, "SALE_QTY") - CmUtil.GetDataRowInt(dr, "ORG_QTY"); + + cKPSItem.sPackDiv = CmUtil.GetDataRowStr(dr, "PACK_DIV"); + cKPSItem.sSetMenuCd = CmUtil.GetDataRowStr(dr, "SET_MENU_CD"); + cKPSItem.sOrdTime = CmUtil.GetDataRowStr(dr, "ORD_TIME"); + cKPSItem.sCancelDiv = CmUtil.GetDataRowStr(dr, "CANCEL_DIV"); + cKPSItem.sResendYn = CmUtil.GetDataRowStr(dr, "RESEND_YN"); + cKPSItem.sKtchSysUseDiv = CmUtil.GetDataRowStr(dr, "KTCH_SYS_USE_DIV"); + cKPSItem.nKpsComPort = CmUtil.GetDataRowInt(dr, "KTCH_PRINTER_COMM_PORT"); + cKPSItem.nKpsComBaudrate = CmUtil.GetDataRowInt(dr, "KTCH_PRINTER_COMM_SPEED"); + cKPSItem.sKpsOposName = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_OPOS_NM"); + cKPSItem.sKpsIp = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_IP"); + cKPSItem.sKpsPort = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_PORT"); + cKPSItem.sFiller1 = CmUtil.GetDataRowStr(dr, "PRT_CNT"); // Add, 2017.01.10, 출력횟수 + cKPSItem.sFiller2 = CmUtil.GetDataRowStr(dr, "ETC_ORD_FLAG"); // Add, 2017.01.26, 기타주문구분 1:후불일반판매, 2:해피오더 + cKPSItem.sFiller3 = CmUtil.GetDataRowStr(dr, "ADD_ORD_FLAG"); // Add, 2017.02.09, 추가주문구분 (NEW,ADD,DEL) + cKPSItem.sFiller4 = CmUtil.GetDataRowStr(dr, "FILLER4"); + cKPSItem.sFiller5 = CmUtil.GetDataRowStr(dr, "FILLER5"); + + + // 부가메뉴구분이 속성이면, 수량=0으로변경, 주문서에 수량을 출력 하지 않는다. // Add, 2017.02.09 + // 부가메뉴구분(1:속성,2:업차지,3:선택메뉴) + //if (CmUtil.GetDataRowStr(dr, "SUB_MEMO_DIV") == "1") cKPSItem.nQty = 0; // Mod, 2017.04.13, 속성도 수량출력 :: 커피웍스 + + #region Mod, 2017.04.25, 주방메모 출력 + // Add, 2017.01.23 + // 주방프린터 수동출력(상품선택) 옵션처리 + //cKPSItem.sKtchMemo = string.Empty; + //if (PosMstManager.GetPosOption(POS_OPTION.OPT425) == "2") + //{ + // cKPSItem.sKtchMemo = CmUtil.GetDataRowStr(dr, "KTCH_MSG"); // Mod, 2017.03.21 + //} + #endregion + + + cKPSItem.sKtchMemo = CmUtil.GetDataRowStr(dr, "KTCH_MSG").Trim(); + + cKPSItem.sItemMemo = (CmUtil.GetDataRowStr(dr, "MSG1") + " " + + CmUtil.GetDataRowStr(dr, "MSG2") + " " + + CmUtil.GetDataRowStr(dr, "MSG3")).Trim(); // Add, 2017.03.21 + cKPSItem.sOrdPicNm = CmUtil.GetDataRowStr(dr, "ORD_PIC_NM").Trim(); // Add, 2017.03.28, 주문담당자 + cKPSItem.sOrdPosNo = CmUtil.GetDataRowStr(dr, "ORD_POS_NO").Trim(); // Add, 2017.04.10 + + cKPSItem.sSendYn = "0"; + cKPSItem.sErrorCd = "0000"; + + //#20180515 KPS 출력시 라벨프린터 출력 start + cKPSItem.sLblSendYn = "0"; + //#20180515 KPS 출력시 라벨프린터 출력 end + + htKPSSendingItem.Add(htKPSSendingItem.Count, cKPSItem); + } + + // 주방인쇄상품 존재시 + if (htKPSSendingItem.Count > 0) + { + sqlDb.DBBeginTransaction(); + + for (int nLoop = 0; nLoop < htKPSSendingItem.Count; nLoop++) + { + KPSItem cKPSItem = (KPSItem)htKPSSendingItem[nLoop]; + + #region (주석) 기존코드 + //sQuery = " INSERT INTO POSMST..MST_KPS_ORD_MSG "; + //sQuery += " ( ORD_DIV, FLOOR_CD, TBL_NO, KTCH_SYS_CD, SEQ "; + //sQuery += " , ORDER_NO, POS_TYPE, ITEM_CD, ITEM_DIV, SHTCUT_ITEMNM "; + //sQuery += " , SALE_QTY, PACK_DIV, SET_MENU_CD, ORD_TIME, CANCEL_DIV "; + //sQuery += " , SEND_YN, RESEND_YN, KTCH_SYS_USE_DIV, KTCH_PRINTER_COMM_PORT, KTCH_PRINTER_COMM_SPEED "; + //sQuery += " , KTCH_PRINTER_OPOS_NM, KTCH_PRINTER_IP, KTCH_PRINTER_PORT, ERROR_CD, KTCH_PRINTER_BAK1 "; + //sQuery += " , KTCH_PRINTER_BAK2, KTCH_PRINTER_BAK3, KTCH_PRINTER_BAK4, KTCH_PRINTER_BAK5, KTCH_PRINTER_BAK6 "; + //sQuery += " , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 "; + //sQuery += " , UPD_DT, REG_DT ) "; + //sQuery += " VALUES "; + //sQuery += " ( '" + cKPSItem.sOrderType +"' "; + //sQuery += " , '" + cKPSItem.sFloorCd + "' "; + //sQuery += " , '" + cKPSItem.sTableNo + "' "; + //sQuery += " , '" + cKPSItem.sKtchSysCd + "' "; + //sQuery += " , " + cKPSItem.nSeq + " "; + //sQuery += " , '" + cKPSItem.sOrderNo + "' "; + //sQuery += " , '" + cKPSItem.sPosType + "' "; + //sQuery += " , '" + cKPSItem.sItemCd + "' "; + //sQuery += " , '" + cKPSItem.sItemDiv + "' "; + //sQuery += " , N'" + cKPSItem.sItemNm + "' "; + //sQuery += " , " + cKPSItem.nQty + " "; + //sQuery += " , '" + cKPSItem.sPackDiv + "' "; + //sQuery += " , '" + cKPSItem.sSetMenuCd + "' "; + //sQuery += " , '" + cKPSItem.sOrdTime + "' "; + //sQuery += " , '" + cKPSItem.sCancelDiv + "' "; + //sQuery += " , '0' "; + //sQuery += " , '" + cKPSItem.sResendYn + "' "; + //sQuery += " , '" + cKPSItem.sKtchSysUseDiv + "' "; + //sQuery += " , " + cKPSItem.nKpsComPort + " "; + //sQuery += " , " + cKPSItem.nKpsComBaudrate + " "; + //sQuery += " , '" + cKPSItem.sKpsOposName + "' "; + //sQuery += " , '" + cKPSItem.sKpsIp + "' "; + //sQuery += " , '" + cKPSItem.sKpsPort + "' "; + //sQuery += " , '" + cKPSItem.sErrorCd + "' "; + //sQuery += " , '" + cKPSItem.sKpsCdBackup1 + "' "; + //sQuery += " , '" + cKPSItem.sKpsCdBackup2 + "' "; + //sQuery += " , '" + cKPSItem.sKpsCdBackup3 + "' "; + //sQuery += " , '" + cKPSItem.sKpsCdBackup4 + "' "; + //sQuery += " , '" + cKPSItem.sKpsCdBackup5 + "' "; + //sQuery += " , '" + cKPSItem.sKpsCdBackup6 + "' "; + //sQuery += " , '" + cKPSItem.sFiller1 + "' "; + //sQuery += " , '" + cKPSItem.sFiller2 + "' "; + //sQuery += " , '" + cKPSItem.sFiller3 + "' "; + //sQuery += " , '" + cKPSItem.sFiller4 + "' "; + //sQuery += " , '" + cKPSItem.sFiller5 + "' "; + //sQuery += " , '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + //sQuery += " , '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' ) "; + + //if(sqlDb.DBExecuteNonQuery(new string[] {sQuery}, CommandType.Text, (SqlParameter[])null) != UserCom.OK) + //{ + // sQuery = " UPDATE POSMST..MST_KPS_ORD_MSG "; + // sQuery += " SET SEND_YN = '0' "; + // sQuery += " , RESEND_YN = '1' "; + // sQuery += " , PACK_DIV = '" + cKPSItem.sPackDiv + "' "; + // sQuery += " , CANCEL_DIV = '" + cKPSItem.sCancelDiv + "' "; + // sQuery += " , KTCH_PRINTER_BAK1 = '" + cKPSItem.sKpsCdBackup1 + "' "; + // sQuery += " , KTCH_PRINTER_BAK2 = '" + cKPSItem.sKpsCdBackup2 + "' "; + // sQuery += " , KTCH_PRINTER_BAK3 = '" + cKPSItem.sKpsCdBackup3 + "' "; + // sQuery += " , KTCH_PRINTER_BAK4 = '" + cKPSItem.sKpsCdBackup4 + "' "; + // sQuery += " , KTCH_PRINTER_BAK5 = '" + cKPSItem.sKpsCdBackup5 + "' "; + // sQuery += " , KTCH_PRINTER_BAK6 = '" + cKPSItem.sKpsCdBackup6 + "' "; + // sQuery += " , FILLER1 = '" + cKPSItem.sFiller1 + "' "; + // sQuery += " , FILLER2 = '" + cKPSItem.sFiller2 + "' "; + // sQuery += " , FILLER3 = '" + cKPSItem.sFiller3 + "' "; + // sQuery += " , FILLER4 = '" + cKPSItem.sFiller4 + "' "; + // sQuery += " , FILLER5 = '" + cKPSItem.sFiller5 + "' "; + // sQuery += " , UPD_DT = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + // sQuery += " WHERE ORD_DIV = '" + cKPSItem.sOrderType + "' "; + // sQuery += " AND FLOOR_CD = '" + cKPSItem.sFloorCd + "' "; + // sQuery += " AND TBL_NO = '" + cKPSItem.sTableNo + "' "; + // sQuery += " AND KTCH_SYS_CD = '" + cKPSItem.sKtchSysCd + "' "; + // sQuery += " AND SEQ = " + cKPSItem.nSeq + " "; + + // if(sqlDb.DBExecuteNonQuery(new string[] {sQuery}, CommandType.Text, (SqlParameter[])null) != UserCom.OK) + // { + // // Rollback + // sqlDb.DBTransactionRollback(); + + // return; + // } + //} + + //sQuery = " UPDATE POSMST..MST_KTCH_ORD_MSG "; + //sQuery += " SET SEND_YN = '1' "; + //sQuery += " WHERE ORD_DIV = '" + cKPSItem.sOrderType + "' "; + //sQuery += " AND FLOOR_CD = '" + cKPSItem.sFloorCd + "' "; + //sQuery += " AND TBL_NO = '" + cKPSItem.sTableNo + "' "; + //sQuery += " AND SEQ = " + cKPSItem.nSeq + " "; + + //if (sqlDb.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null) != UserCom.OK) + //{ + // // Rollback + // sqlDb.DBTransactionRollback(); + + // return; + //} + #endregion + + string[] sql = new string[2]; + + #region (삭제) + //sql[0] = "UPDATE POSMST..MST_KPS_ORD_MSG \n" + // + " SET SEND_YN = '0' \n" + // + " , RESEND_YN = '0' \n" + // + " , PACK_DIV = '" + cKPSItem.sPackDiv + "' \n" + // + " , CANCEL_DIV = '" + cKPSItem.sCancelDiv + "' \n" + // + " , SALE_QTY = " + cKPSItem.nQty + "\n" // Add, 2017.03.29, 이런 !!! + // //+ " , KTCH_PRINTER_BAK1 = '" + cKPSItem.sKpsCdBackup1 + "' \n" // Del, 2017.02.09 + // //+ " , KTCH_PRINTER_BAK2 = '" + cKPSItem.sKpsCdBackup2 + "' \n" + // //+ " , KTCH_PRINTER_BAK3 = '" + cKPSItem.sKpsCdBackup3 + "' \n" + // //+ " , KTCH_PRINTER_BAK4 = '" + cKPSItem.sKpsCdBackup4 + "' \n" + // //+ " , KTCH_PRINTER_BAK5 = '" + cKPSItem.sKpsCdBackup5 + "' \n" + // //+ " , KTCH_PRINTER_BAK6 = '" + cKPSItem.sKpsCdBackup6 + "' \n" + // + " , FILLER1 = '" + cKPSItem.sFiller1 + "' \n" + // + " , FILLER2 = '" + cKPSItem.sFiller2 + "' \n" + // + " , FILLER3 = '" + cKPSItem.sFiller3 + "' \n" + // + " , FILLER4 = '" + cKPSItem.sFiller4 + "' \n" + // + " , FILLER5 = '" + cKPSItem.sFiller5 + "' \n" + // //+ " , MSG = N'" + cKPSItem.sKtchMemo + "' \n" + // + " , MSG = N'" + ConvertDBStr(cKPSItem.sItemMemo) + "' \n" // Mod, 2017.03.21 + // + " , KTCH_MSG = N'" + ConvertDBStr(cKPSItem.sKtchMemo) + "' \n" // Add, 2017.03.21 + // + " , ORD_PIC_NM = N'" + ConvertDBStr(cKPSItem.sOrdPicNm) + "' \n" // Add, 2017.03.27, 주문담당자 + // + " , UPD_DT = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' \n" + // + " WHERE TRAIN_MODE_YN = '" + cKPSItem.sTrainMode + "' \n" // Add, 2017.03.03, 연습모드 + // + " AND ORD_DIV = '" + cKPSItem.sOrderType + "' \n" + // + " AND FLOOR_CD = '" + cKPSItem.sFloorCd + "' \n" + // + " AND TBL_NO = '" + cKPSItem.sTableNo + "' \n" + // + " AND SUB_STOR_CD = '" + cKPSItem.sSubShopCd + "' \n" // Add, 2017.02.07 + // + " AND KTCH_SYS_CD = '" + cKPSItem.sKtchSysCd + "' \n" + // + " AND SEQ = " + cKPSItem.nSeq + " \n" + // + "IF @@ROWCOUNT = 0 \n" + // + " INSERT INTO POSMST..MST_KPS_ORD_MSG ( \n" + // //+ " ORD_DIV, FLOOR_CD, TBL_NO, KTCH_SYS_CD, SEQ \n" + // //+ " ORD_DIV, FLOOR_CD, TBL_NO, SUB_STOR_CD, KTCH_SYS_CD, SEQ \n" // Add, 2017.02.07 + // + " TRAIN_MODE_YN, ORD_DIV, FLOOR_CD, TBL_NO, SUB_STOR_CD, KTCH_SYS_CD, SEQ \n" // Add, 2017.03.03, 연습모드 + // + " , ORDER_NO, POS_TYPE, ITEM_CD, ITEM_DIV, SHTCUT_ITEMNM \n" + // + " , SALE_QTY, PACK_DIV, SET_MENU_CD, ORD_TIME, CANCEL_DIV \n" + // + " , SEND_YN, RESEND_YN, KTCH_SYS_USE_DIV, KTCH_PRINTER_COMM_PORT, KTCH_PRINTER_COMM_SPEED \n" + + // //+ " , KTCH_PRINTER_OPOS_NM, KTCH_PRINTER_IP, KTCH_PRINTER_PORT, ERROR_CD, KTCH_PRINTER_BAK1 \n" + // //+ " , KTCH_PRINTER_BAK2, KTCH_PRINTER_BAK3, KTCH_PRINTER_BAK4, KTCH_PRINTER_BAK5, KTCH_PRINTER_BAK6 \n" + // + " , KTCH_PRINTER_OPOS_NM, KTCH_PRINTER_IP, KTCH_PRINTER_PORT, ERROR_CD \n" + + // + " , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n" + // + " , MSG \n" + // + " , KTCH_MSG \n" // Add, 2017.03.21 + // + " , ORD_PIC_NM \n" // Add, 2017.03.28, 주문담당자 + // + " , UPD_DT, REG_DT \n" + // + " ) VALUES ( \n" + // + " '" + cKPSItem.sTrainMode + "' \n" // Add, 2017.03.03, 연습모드 + // + " , '" + cKPSItem.sOrderType + "' \n" + // + " , '" + cKPSItem.sFloorCd + "' \n" + // + " , '" + cKPSItem.sTableNo + "' \n" + + // + " , '" + cKPSItem.sSubShopCd + "' \n" // Add, 2017.02.07 + // + " , '" + cKPSItem.sKtchSysCd + "' \n" + + // + " , " + cKPSItem.nSeq + " \n" + // + " , '" + cKPSItem.sOrderNo + "' \n" + // + " , '" + cKPSItem.sPosType + "' \n" + // + " , '" + cKPSItem.sItemCd + "' \n" + // + " , '" + cKPSItem.sItemDiv + "' \n" + // + " , N'" + cKPSItem.sItemNm + "' \n" + // + " , " + cKPSItem.nQty + " \n" + // + " , '" + cKPSItem.sPackDiv + "' \n" + // + " , '" + cKPSItem.sSetMenuCd + "' \n" + // + " , '" + cKPSItem.sOrdTime + "' \n" + // + " , '" + cKPSItem.sCancelDiv + "' \n" + + // + " , '" + cKPSItem.sSendYn + "' \n" + + // + " , '" + cKPSItem.sResendYn + "' \n" + // + " , '" + cKPSItem.sKtchSysUseDiv + "' \n" + // + " , " + cKPSItem.nKpsComPort + " \n" + // + " , " + cKPSItem.nKpsComBaudrate + " \n" + // + " , '" + cKPSItem.sKpsOposName + "' \n" + // + " , '" + cKPSItem.sKpsIp + "' \n" + // + " , '" + cKPSItem.sKpsPort + "' \n" + // + " , '" + cKPSItem.sErrorCd + "' \n" + // + " , '" + cKPSItem.sFiller1 + "' \n" + // + " , '" + cKPSItem.sFiller2 + "' \n" + // + " , '" + cKPSItem.sFiller3 + "' \n" + // + " , '" + cKPSItem.sFiller4 + "' \n" + // + " , '" + cKPSItem.sFiller5 + "' \n" + // + " , N'" + ConvertDBStr(cKPSItem.sItemMemo) + "' \n" // Add, 2017.03.21 + // + " , N'" + ConvertDBStr(cKPSItem.sKtchMemo) + "' \n" + // + " , N'" + ConvertDBStr(cKPSItem.sOrdPicNm) + "' \n" // Add, 2017.03.28, 주문담당자 + // + " , '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' \n" + // + " , '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' ) " + // ; + #endregion + + #region ### POSMST..MST_KPS_ORD_MSG + + sql[0] = " INSERT INTO POSMST..MST_KPS_ORD_MSG ( \n" + + " TRAIN_MODE_YN, ORD_DIV, FLOOR_CD, TBL_NO, SUB_STOR_CD, KTCH_SYS_CD, SEQ \n" // Add, 2017.03.03, 연습모드 + + " , ORDER_NO, POS_TYPE, ITEM_CD, ITEM_DIV, SHTCUT_ITEMNM \n" + + " , SALE_QTY, PACK_DIV, SET_MENU_CD, ORD_TIME, CANCEL_DIV \n" + + " , SEND_YN, RESEND_YN, KTCH_SYS_USE_DIV, KTCH_PRINTER_COMM_PORT, KTCH_PRINTER_COMM_SPEED \n" + + " , KTCH_PRINTER_OPOS_NM, KTCH_PRINTER_IP, KTCH_PRINTER_PORT, ERROR_CD \n" + + " , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n" + + " , MSG \n" + + " , KTCH_MSG \n" // Add, 2017.03.21 + + " , ORD_PIC_NM \n" // Add, 2017.03.28, 주문담당자 + + " , ORD_POS_NO \n" // Add, 2017.04.10 + + " , UPD_DT, REG_DT \n" + //#20180515 KPS 출력시 라벨프린터 출력 start + + " , LBLSEND_YN \n" + //#20180515 KPS 출력시 라벨프린터 출력 end + + " ) SELECT \n" + + " '" + cKPSItem.sTrainMode + "' \n" // Add, 2017.03.03, 연습모드 + + " , '" + cKPSItem.sOrderType + "' \n" + + " , '" + cKPSItem.sFloorCd + "' \n" + + " , '" + cKPSItem.sTableNo + "' \n" + + " , '" + cKPSItem.sSubShopCd + "' \n" // Add, 2017.02.07 + + " , '" + cKPSItem.sKtchSysCd + "' \n" + //+ " , " + cKPSItem.nSeq + " \n" + + " , (SELECT ISNULL(MAX(SEQ), 0) + 1 FROM POSMST..MST_KPS_ORD_MSG \n" + + " WHERE TRAIN_MODE_YN = '" + cKPSItem.sTrainMode + "' \n" + + " AND ORD_DIV = '" + cKPSItem.sOrderType + "' \n" + + " AND FLOOR_CD = '" + cKPSItem.sFloorCd + "' \n" + + " AND TBL_NO = '" + cKPSItem.sTableNo + "' \n" + + " AND SUB_STOR_CD = '" + cKPSItem.sSubShopCd + "' \n" + + " AND KTCH_SYS_CD = '" + cKPSItem.sKtchSysCd + "') \n" + + " , '" + cKPSItem.sOrderNo + "' \n" + + " , '" + cKPSItem.sPosType + "' \n" + + " , '" + cKPSItem.sItemCd + "' \n" + + " , '" + cKPSItem.sItemDiv + "' \n" + + " , N'" + cKPSItem.sItemNm + "' \n" + + " , " + cKPSItem.nQty + " \n" + + " , '" + cKPSItem.sPackDiv + "' \n" + + " , '" + cKPSItem.sSetMenuCd + "' \n" + + " , '" + cKPSItem.sOrdTime + "' \n" + + " , '" + cKPSItem.sCancelDiv + "' \n" + + " , '" + cKPSItem.sSendYn + "' \n" + + " , '" + cKPSItem.sResendYn + "' \n" + + " , '" + cKPSItem.sKtchSysUseDiv + "' \n" + + " , " + cKPSItem.nKpsComPort + " \n" + + " , " + cKPSItem.nKpsComBaudrate + " \n" + + " , '" + cKPSItem.sKpsOposName + "' \n" + + " , '" + cKPSItem.sKpsIp + "' \n" + + " , '" + cKPSItem.sKpsPort + "' \n" + + " , '" + cKPSItem.sErrorCd + "' \n" + + " , '" + cKPSItem.sFiller1 + "' \n" + + " , '" + cKPSItem.sFiller2 + "' \n" + + " , '" + cKPSItem.sFiller3 + "' \n" + + " , '" + cKPSItem.sFiller4 + "' \n" + + " , '" + cKPSItem.sFiller5 + "' \n" + + " , N'" + ConvertDBStr(cKPSItem.sItemMemo) + "' \n" // Add, 2017.03.21 + + " , N'" + ConvertDBStr(cKPSItem.sKtchMemo) + "' \n" + + " , N'" + ConvertDBStr(cKPSItem.sOrdPicNm) + "' \n" // Add, 2017.03.28, 주문담당자 + + " , '" + cKPSItem.sOrdPosNo + "' \n" // Add, 2017.04.10 + + " , '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' \n" + + " , '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' \n" + //#20180515 KPS 출력시 라벨프린터 출력 start + + " , '" + cKPSItem.sLblSendYn + "' \n" + //#20180515 KPS 출력시 라벨프린터 출력 end + ; + #endregion + + #region ### POSMST..MST_KTCH_ORD_MSG + sql[1] = "UPDATE POSMST..MST_KTCH_ORD_MSG \n" + + " SET SEND_YN = '1' \n" + + " WHERE TRAIN_MODE_YN = '" + cKPSItem.sTrainMode + "' \n" + + " AND ORD_DIV = '" + cKPSItem.sOrderType + "' \n" + + " AND FLOOR_CD = '" + cKPSItem.sFloorCd + "' \n" + + " AND TBL_NO = '" + cKPSItem.sTableNo + "' \n" + + " AND SEQ = " + cKPSItem.nSeq + " \n" + ; + #endregion + + if (sqlDb.DBExecuteNonQuery(sql, CommandType.Text, (SqlParameter[])null) != UserCom.OK) + { + // Rollback + sqlDb.DBTransactionRollback(); + return false; + } + } + // Commit + sqlDb.DBTransactionCommit(); + } + + bRet = true; + } + 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 bRet; + } + + private void GetKPSSendItem(ref Hashtable htKPSSendingItem) + { + string sQuery = string.Empty; + + DataTable dtData = null; + + try + { + #region (주석) 복합매장 적용 이전 + //sQuery = " SELECT ORD_DIV, FLOOR_CD, TBL_NO, KTCH_SYS_CD, SEQ "; + //sQuery += " , ORDER_NO, POS_TYPE, ITEM_CD, ITEM_DIV, SHTCUT_ITEMNM "; + //sQuery += " , SALE_QTY, PACK_DIV, SET_MENU_CD, ORD_TIME, CANCEL_DIV "; + //sQuery += " , SEND_YN, RESEND_YN, KTCH_SYS_USE_DIV, KTCH_PRINTER_COMM_PORT, KTCH_PRINTER_COMM_SPEED "; + //sQuery += " , KTCH_PRINTER_OPOS_NM, KTCH_PRINTER_IP, KTCH_PRINTER_PORT, ERROR_CD, KTCH_PRINTER_BAK1, KTCH_PRINTER_BAK2 "; + //sQuery += " , KTCH_PRINTER_BAK3, KTCH_PRINTER_BAK4, KTCH_PRINTER_BAK5, KTCH_PRINTER_BAK6, FILLER1 "; + //sQuery += " , FILLER2, FILLER3, FILLER4, FILLER5 "; + //sQuery += " , MSG "; + //sQuery += " FROM POSMST..MST_KPS_ORD_MSG "; + //sQuery += " WHERE SEND_YN = '0' "; + //sQuery += " ORDER BY KTCH_SYS_CD, ORD_DIV, FLOOR_CD, TBL_NO, CANCEL_DIV, SEQ "; + #endregion + + #region (주석) 연습모드 적용 이전, 2017.03.03 + //sQuery = "SELECT ORD_DIV, FLOOR_CD, TBL_NO, SUB_STOR_CD, KTCH_SYS_CD, SEQ \n" + // + " , ORDER_NO, POS_TYPE, ITEM_CD, ITEM_DIV, SHTCUT_ITEMNM \n" + // + " , SALE_QTY, PACK_DIV, SET_MENU_CD, ORD_TIME, CANCEL_DIV \n" + // + " , SEND_YN, RESEND_YN, KTCH_SYS_USE_DIV, KTCH_PRINTER_COMM_PORT, KTCH_PRINTER_COMM_SPEED \n" + // + " , KTCH_PRINTER_OPOS_NM, KTCH_PRINTER_IP, KTCH_PRINTER_PORT, ERROR_CD \n" + // + " , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5, MSG \n" + // + " FROM POSMST..MST_KPS_ORD_MSG \n" + // + " WHERE SEND_YN = '0' \n" + // + " ORDER BY SUB_STOR_CD, KTCH_SYS_CD, ORD_DIV, FLOOR_CD, TBL_NO, SEQ \n" + // ; + #endregion + + #region (주석) + // Mod, 2017.03.03, 연습모드 + //sQuery = "SELECT TRAIN_MODE_YN, ORD_DIV, FLOOR_CD, TBL_NO, SUB_STOR_CD, KTCH_SYS_CD, SEQ \n" + // + " , ORDER_NO, POS_TYPE, ITEM_CD, ITEM_DIV, SHTCUT_ITEMNM \n" + // + " , SALE_QTY, PACK_DIV, SET_MENU_CD, ORD_TIME, CANCEL_DIV \n" + // + " , SEND_YN, RESEND_YN, KTCH_SYS_USE_DIV, KTCH_PRINTER_COMM_PORT, KTCH_PRINTER_COMM_SPEED \n" + // + " , KTCH_PRINTER_OPOS_NM, KTCH_PRINTER_IP, KTCH_PRINTER_PORT, ERROR_CD \n" + // + " , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5, MSG, KTCH_MSG \n" + // + " , ORD_PIC_NM \n" // Add, 2017.03.28, 주문담당자 + // + " FROM POSMST..MST_KPS_ORD_MSG \n" + // + " WHERE SEND_YN = '0' \n" + // + " ORDER BY TRAIN_MODE_YN, SUB_STOR_CD, KTCH_SYS_CD, ORD_DIV, FLOOR_CD, TBL_NO, SEQ \n" + // ; + #endregion + + #region (주석) 이전코드 2017.09.06 + /* + sQuery = "SELECT A.TRAIN_MODE_YN, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SUB_STOR_CD, A.KTCH_SYS_CD, A.SEQ \n" + + " , A.ORDER_NO, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM \n" + + " , A.SALE_QTY, A.PACK_DIV, A.SET_MENU_CD, A.ORD_TIME, A.CANCEL_DIV \n" + + " , A.SEND_YN, A.RESEND_YN, A.KTCH_SYS_USE_DIV, A.KTCH_PRINTER_COMM_PORT, A.KTCH_PRINTER_COMM_SPEED \n" + + " , A.KTCH_PRINTER_OPOS_NM, A.KTCH_PRINTER_IP, A.KTCH_PRINTER_PORT, A.ERROR_CD \n" + + " , A.FILLER1, A.FILLER2, A.FILLER3, A.FILLER4, A.FILLER5, A.MSG \n" + + " , B.POS_NO \n" // Add, 2017.06.13, POS별 주방프린터 설정 + + " , A.KTCH_MSG \n" + + " , A.ORD_PIC_NM \n" // Add, 2017.03.28, 주문담당자 + + " , B.KTCH_SYS_NM \n" // Add, 2017.04.07 + + " , A.ORD_POS_NO \n" // Add, 2017.04.10 + + " FROM POSMST..MST_KPS_ORD_MSG A \n" + + " LEFT JOIN POSMST..MST_KTCH_DEVICE B WITH(NOLOCK) \n" + + " ON A.SUB_STOR_CD = B.SUB_STOR_CD \n" + + " AND A.KTCH_SYS_CD = B.KTCH_SYS_CD \n" + + " AND B.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + + " AND B.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + + " AND B.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" // Add, 2017.06.12 POS별 주방프린터 설정 + + " WHERE A.SEND_YN = '0' \n" + + " AND A.ORD_POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n" // Add, 2017.04.10 + + " ORDER BY A.TRAIN_MODE_YN, A.SUB_STOR_CD, A.KTCH_SYS_CD, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ \n" + ; + */ +#endregion + + sQuery = "SELECT A.TRAIN_MODE_YN, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SUB_STOR_CD, A.KTCH_SYS_CD, A.SEQ \n" + + " , A.ORDER_NO, A.POS_TYPE, A.ITEM_CD, A.ITEM_DIV, A.SHTCUT_ITEMNM \n" + + " , A.SALE_QTY, A.PACK_DIV, A.SET_MENU_CD, A.ORD_TIME, A.CANCEL_DIV \n" + + " , A.SEND_YN, A.RESEND_YN, A.KTCH_SYS_USE_DIV, A.KTCH_PRINTER_COMM_PORT, A.KTCH_PRINTER_COMM_SPEED \n" + + " , A.KTCH_PRINTER_OPOS_NM, A.KTCH_PRINTER_IP, A.KTCH_PRINTER_PORT, A.ERROR_CD \n" + + " , A.FILLER1, A.FILLER2, A.FILLER3, A.FILLER4, A.FILLER5, A.MSG \n" + + " , B.POS_NO \n" // Add, 2017.06.13, POS별 주방프린터 설정 + + " , A.KTCH_MSG \n" + + " , A.ORD_PIC_NM \n" // Add, 2017.03.28, 주문담당자 + + " , B.KTCH_SYS_NM \n" // Add, 2017.04.07 + + " , A.ORD_POS_NO \n" // Add, 2017.04.10 + + " , C.ITEM_INFO \n" // Add, 2017.09.06 레시피 추가 + + " FROM POSMST..MST_KPS_ORD_MSG A \n" + + " LEFT JOIN POSMST..MST_KTCH_DEVICE B WITH(NOLOCK) \n" + + " ON A.SUB_STOR_CD = B.SUB_STOR_CD \n" + + " AND A.KTCH_SYS_CD = B.KTCH_SYS_CD \n" + + " AND B.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + + " AND B.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + + " AND B.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" // Add, 2017.06.12 POS별 주방프린터 설정 + + " LEFT JOIN POSMST..MST_KTCH_ITEM_INFO C WITH(NOLOCK) \n" + + " ON A.ITEM_CD = C.ITEM_CD \n" + + " AND C.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" + + " WHERE A.SEND_YN = '0' \n" + + " AND A.ORD_POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n" // Add, 2017.04.10 + //#20171102 start + + //#20171103 주방영수증 출력시 부가메뉴가 위로 출력되는 증상 start + //기존 + //+ " ORDER BY A.TRAIN_MODE_YN, A.SUB_STOR_CD, A.KTCH_SYS_CD, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ DESC \n"; + //변경 + + " ORDER BY A.TRAIN_MODE_YN, A.SUB_STOR_CD, A.KTCH_SYS_CD, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ \n"; + //#20171103 주방영수증 출력시 부가메뉴가 위로 출력되는 증상 end + + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) != UserCom.OK) + { + return; + } + + string itemKey = string.Empty; + + Hashtable htKPSSendingItemTemp = new Hashtable(); + + DataRow[] arRows = null; + arRows = dtData.Select("POS_NO = '" + m_cPosStatus.Base.PosNo + "'"); + if (arRows.Length == 0) + arRows = dtData.Select("POS_NO = '00'"); + + //foreach (DataRow dr in dtData.Rows) + foreach (DataRow dr in arRows) + { + KPSItem cKPSItem = new KPSItem(); + + cKPSItem.sTrainMode = CmUtil.GetDataRowStr(dr, "TRAIN_MODE_YN"); // Add, 2017.03.03, 연습모드 + + cKPSItem.sOrderType = CmUtil.GetDataRowStr(dr, "ORD_DIV"); + cKPSItem.sFloorCd = CmUtil.GetDataRowStr(dr, "FLOOR_CD"); + cKPSItem.sTableNo = CmUtil.GetDataRowStr(dr, "TBL_NO"); + + cKPSItem.sSubShopCd = CmUtil.GetDataRowStr(dr, "SUB_STOR_CD"); // Add, 2017.02.07 + cKPSItem.sKtchSysCd = CmUtil.GetDataRowStr(dr, "KTCH_SYS_CD"); + cKPSItem.sKtchSysNm = CmUtil.GetDataRowStr(dr, "KTCH_SYS_NM"); // Add, 2017.04.07 + + cKPSItem.nSeq = CmUtil.GetDataRowInt(dr, "SEQ"); + cKPSItem.sOrderNo = CmUtil.GetDataRowStr(dr, "ORDER_NO"); + cKPSItem.sPosType = CmUtil.GetDataRowStr(dr, "POS_TYPE"); + cKPSItem.sItemCd = CmUtil.GetDataRowStr(dr, "ITEM_CD"); + cKPSItem.sItemDiv = CmUtil.GetDataRowStr(dr, "ITEM_DIV"); + cKPSItem.sItemNm = CmUtil.GetDataRowStr(dr, "SHTCUT_ITEMNM"); + cKPSItem.nQty = CmUtil.GetDataRowInt(dr, "SALE_QTY"); + cKPSItem.sPackDiv = CmUtil.GetDataRowStr(dr, "PACK_DIV"); + cKPSItem.sSetMenuCd = CmUtil.GetDataRowStr(dr, "SET_MENU_CD"); + cKPSItem.sOrdTime = CmUtil.GetDataRowStr(dr, "ORD_TIME"); + cKPSItem.sCancelDiv = CmUtil.GetDataRowStr(dr, "CANCEL_DIV"); + cKPSItem.sResendYn = CmUtil.GetDataRowStr(dr, "RESEND_YN"); + cKPSItem.sKtchSysUseDiv = CmUtil.GetDataRowStr(dr, "KTCH_SYS_USE_DIV"); + cKPSItem.nKpsComPort = CmUtil.GetDataRowInt(dr, "KTCH_PRINTER_COMM_PORT"); + cKPSItem.nKpsComBaudrate = CmUtil.GetDataRowInt(dr, "KTCH_PRINTER_COMM_SPEED"); + cKPSItem.sKpsOposName = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_OPOS_NM"); + cKPSItem.sKpsIp = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_IP"); + cKPSItem.sKpsPort = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_PORT"); + cKPSItem.sErrorCd = CmUtil.GetDataRowStr(dr, "ERROR_CD"); + cKPSItem.sFiller1 = CmUtil.GetDataRowStr(dr, "FILLER1"); + cKPSItem.sFiller2 = CmUtil.GetDataRowStr(dr, "FILLER2"); + cKPSItem.sFiller3 = CmUtil.GetDataRowStr(dr, "FILLER3"); + cKPSItem.sFiller4 = CmUtil.GetDataRowStr(dr, "FILLER4"); + cKPSItem.sFiller5 = CmUtil.GetDataRowStr(dr, "FILLER5"); + + //cKPSItem.sKtchMemo = CmUtil.GetDataRowStr(dr, "MSG"); + cKPSItem.sItemMemo = CmUtil.GetDataRowStr(dr, "MSG"); // Mod, 2017.03.21 + cKPSItem.sKtchMemo = CmUtil.GetDataRowStr(dr, "KTCH_MSG"); // Add, 2017.03.21 + cKPSItem.sOrdPicNm = CmUtil.GetDataRowStr(dr, "ORD_PIC_NM"); // Add, 2017.03.27, 주문담당자 + cKPSItem.sOrdPosNo = CmUtil.GetDataRowStr(dr, "ORD_POS_NO"); // Add, 2017.04.10 + //2017.09.06 레시피 추가. + cKPSItem.sRecipe = CmUtil.GetDataRowStr(dr, "ITEM_INFO"); // Add, 2017.09.06 + + cKPSItem.sSendYn = "0"; + + // Mod, 2017.03.03, 연습모드 + //string checkKey = cKPSItem.sSubShopCd + cKPSItem.sKtchSysCd + cKPSItem.sFloorCd + cKPSItem.sTableNo; + string checkKey = cKPSItem.sTrainMode + cKPSItem.sSubShopCd + cKPSItem.sKtchSysCd + cKPSItem.sFloorCd + cKPSItem.sTableNo; + if (itemKey != checkKey) + { + if (htKPSSendingItemTemp.Count != 0) + { + htKPSSendingItem.Add(htKPSSendingItem.Count, htKPSSendingItemTemp); + } + itemKey = checkKey; + + htKPSSendingItemTemp = new Hashtable(); + } + + htKPSSendingItemTemp.Add(htKPSSendingItemTemp.Count, cKPSItem); + } + + if (htKPSSendingItemTemp.Count != 0) + { + htKPSSendingItem.Add(htKPSSendingItem.Count, htKPSSendingItemTemp); + } + } + 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); + } + } + + /// + /// 주방 주문서 출력 + /// + /// + /// + /// + private void KPSPrintProc(ref Hashtable htKPSSendingItem, ref Hashtable htKtchDeviceStatus ,ref string ktchErrorCode) + { + try + { + var nReturn = 0; + var nPrintOkIndex = 0; + var bKtchDeviceStatusSerchFlag = false; + + //string sCancelFlag = string.Empty; + //string sResendFlag = string.Empty; + + for (int nLoop = 0; nLoop < htKPSSendingItem.Count; nLoop++) + { + Hashtable htKPSSendingItemTemp = (Hashtable)htKPSSendingItem[nLoop]; + + if (htKPSSendingItemTemp.Count == 0) + { + continue; + } + + KPSItem cKPSItem = (KPSItem)htKPSSendingItemTemp[0]; + var sTrainMode = cKPSItem.sTrainMode; // Add, 2017.03.03, 연습모드 + var sSubShopCd = cKPSItem.sSubShopCd; + var sKtchSysCd = cKPSItem.sKtchSysCd; + var sKtchUseDiv = cKPSItem.sKtchSysUseDiv; + var nKpsComPort = cKPSItem.nKpsComPort; + var nKpsComBaudrate = cKPSItem.nKpsComBaudrate; + var sKpsIp = cKPSItem.sKpsIp; + var sKpsPort = cKPSItem.sKpsPort; + var sResendFlag = "0"; + + // Add, 2017.02.14, 주방프린트와 영수증프린트(시리얼)가 동일장비 인경우 + if (m_cDevStatus.Printer.UseYn == true) + { + bool isEquals = true; + + if (m_cPosStatus.Base.OlePosPrinterController != PosConst.POS_DEVICE_CONTROLLER.RS232) isEquals = false; + if (cKPSItem.sKtchSysUseDiv != PosConst.KTCH_SYS_USE_DIV.RS232) isEquals = false; + if (m_cPosStatus.Base.OlePosPrinterSerialPortNumber.ToUpper().Trim() != "COM" + cKPSItem.nKpsComPort.ToString()) isEquals = false; + + if (isEquals) + { + for (var i = 0; i < htKPSSendingItemTemp.Count; i ++) + { + ((KPSItem)htKPSSendingItemTemp[i]).sSendYn = "7"; + } + if (string.IsNullOrWhiteSpace(ktchErrorCode)) ktchErrorCode = "XXXX"; + + continue; + } + } + + // 지정취소 + var sCancelFlag = cKPSItem.sCancelDiv; + + // Add, 2017.02.10, 반복출력횟수 + var prtCnt = CmUtil.IntParse(cKPSItem.sFiller1); + if (prtCnt == 0) prtCnt = 1; + + nPrintOkIndex = -1; + if (sKtchUseDiv == PosConst.KTCH_SYS_USE_DIV.RS232) // Serial + { + nReturn = KPSSerialPrintProc(sCancelFlag, sResendFlag, nKpsComPort, nKpsComBaudrate, prtCnt, ref nPrintOkIndex, ref htKPSSendingItemTemp); + } + else if (sKtchUseDiv == PosConst.KTCH_SYS_USE_DIV.SOCK) // LAN + { + nReturn = KPSLanPrintProc(sCancelFlag, sResendFlag, sKpsIp, sKpsPort, prtCnt, ref nPrintOkIndex, ref htKPSSendingItemTemp); + } + + bKtchDeviceStatusSerchFlag = false; + for (int i = 0; i < htKtchDeviceStatus.Count; i++) + { + KTCH_SYS_STATUS cKtchSysStatus = (KTCH_SYS_STATUS)htKtchDeviceStatus[i]; + + //if(cKtchSysStatus.sKtchSysCd == sKtchSysCd) + if (cKtchSysStatus.sSubShopCd == sSubShopCd || cKtchSysStatus.sKtchSysCd == sKtchSysCd) + { + cKtchSysStatus.nErrorCd = nReturn; + htKtchDeviceStatus[i] = cKtchSysStatus; + bKtchDeviceStatusSerchFlag = true; + break; + } + } + + if (bKtchDeviceStatusSerchFlag == false) + { + KTCH_SYS_STATUS cKtchSysStatus = new KTCH_SYS_STATUS(); + cKtchSysStatus.sSubShopCd = sSubShopCd; + cKtchSysStatus.sKtchSysCd = sKtchSysCd; + cKtchSysStatus.nErrorCd = nReturn; + htKtchDeviceStatus.Add(htKtchDeviceStatus.Count, cKtchSysStatus); + } + + if (nReturn != 0 && nPrintOkIndex >= 0) + { + for (int i = 0; i <= nPrintOkIndex; i++) + { + if (htKPSSendingItemTemp.Contains(i) == true) + { + KPSItem cKPSTemp = (KPSItem)htKPSSendingItemTemp[i]; + cKPSTemp.sSendYn = "1"; + cKPSTemp.sErrorCd = "0000"; + htKPSSendingItemTemp[i] = cKPSTemp; + } + } + } + + if (nReturn == 0) // 정상 + { + for (int i = 0; i < htKPSSendingItemTemp.Count; i++) + { + if (htKPSSendingItemTemp.Contains(i) == true) + { + KPSItem cKPSTemp = (KPSItem)htKPSSendingItemTemp[i]; + cKPSTemp.sSendYn = "1"; + cKPSTemp.sErrorCd = "0000"; + htKPSSendingItemTemp[i] = cKPSTemp; + } + } + } + else // 에러 + { + for (int i = nPrintOkIndex + 1; i < htKPSSendingItemTemp.Count; i++) + { + KPSItem cKPSTemp = (KPSItem)htKPSSendingItemTemp[i]; + + // Mod, 2017.02.14 + //cKPSTemp.sSendYn = "0"; + cKPSTemp.sSendYn = (cKPSTemp.sSendYn == "0") ? "8" : cKPSTemp.sSendYn; + + if (string.IsNullOrWhiteSpace(cKPSTemp.sErrorCd) || cKPSTemp.sErrorCd == "0000") + { + switch (nReturn) + { + case -1: cKPSTemp.sErrorCd = "0001"; break; // Print Open Error + case -2: cKPSTemp.sErrorCd = "0002"; break; // Print Claim Error + case -3: cKPSTemp.sErrorCd = "0003"; break; // Print Power Off Error + case -4: cKPSTemp.sErrorCd = "0004"; break; // Cover Open Error + case -5: cKPSTemp.sErrorCd = "0005"; break; // No Paper Error + default: cKPSTemp.sErrorCd = "9999"; break; // Etc Error + } + } + + // Add, 2017.02.15 + //ktchErrorCode = cKPSTemp.sErrorCd; + ktchErrorCode = string.Format("{0}|{1}|{2}", cKPSTemp.sErrorCd, cKPSTemp.sKtchSysCd, cKPSTemp.sKtchSysNm); + + htKPSSendingItemTemp[i] = cKPSTemp; + } + } + + htKPSSendingItem[nLoop] = htKPSSendingItemTemp; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + } + + /// + /// 주방 메시지 출력 + /// + /// + /// + /// + private void KPSOrderMessagePrintProc(ref Hashtable htKPSSendingItem, ref Hashtable htKtchDeviceStatus, ref string ktchErrorCode) + { + try + { + var nPrintOkIndex = 0; + var nReturn = 0; + + var bKtchDeviceStatusSearchFlag = false; + htKtchDeviceStatus = new Hashtable(); + + for (int nLoop = 0; nLoop < htKPSSendingItem.Count; nLoop++) + { + Hashtable htKPSSendingITemp = (Hashtable)htKPSSendingItem[nLoop]; + if (htKPSSendingITemp.Count == 0) continue; + + KPSOrderMessage cKPSOrderMessage = (KPSOrderMessage)htKPSSendingITemp[0]; + + var sSubShopCd = cKPSOrderMessage.sSubShopCd; // Add, 2017.02.07 + var sKtchSysCd = cKPSOrderMessage.sKtchSysCd; + var sKtchSysUseDiv = cKPSOrderMessage.sKtchSysUseDiv; + var sKpsIp = cKPSOrderMessage.sKpsIp; + var sKpsPort = cKPSOrderMessage.sKpsPort; + var nKpsComPort = cKPSOrderMessage.nKpsComPort; + var nKpsComBaudrate = cKPSOrderMessage.nKpsComBaudrate; + var sResendFlag = "0"; + + // Add, 2017.02.14, 주방프린트와 영수증프린트(시리얼)가 동일장비 인경우 + if (m_cDevStatus.Printer.UseYn == true) + { + bool isEquals = true; + + if (m_cPosStatus.Base.OlePosPrinterController != PosConst.POS_DEVICE_CONTROLLER.RS232) isEquals = false; + if (cKPSOrderMessage.sKtchSysUseDiv != PosConst.KTCH_SYS_USE_DIV.RS232) isEquals = false; + if (m_cPosStatus.Base.OlePosPrinterSerialPortNumber.ToUpper().Trim() != "COM" + cKPSOrderMessage.nKpsComPort.ToString()) isEquals = false; + + if (isEquals) + { + for (var i = 0; i < htKPSSendingITemp.Count; i++) + { + ((KPSOrderMessage)htKPSSendingITemp[i]).sSendYn = "7"; + } + if (string.IsNullOrWhiteSpace(ktchErrorCode)) ktchErrorCode = "XXXX"; + + continue; + } + } + + nPrintOkIndex = -1; + + if (sKtchSysUseDiv == PosConst.KTCH_SYS_USE_DIV.RS232) // Serial + { + nReturn = KPSOrderMessageSerialPrintProc(sResendFlag, nKpsComPort, nKpsComBaudrate, cKPSOrderMessage.printCount, ref nPrintOkIndex, ref htKPSSendingITemp); + } + else if (sKtchSysUseDiv == PosConst.KTCH_SYS_USE_DIV.SOCK) // LAN + { + nReturn = KPSOrderMessageLanPrintProc(sResendFlag, sKpsIp, sKpsPort, cKPSOrderMessage.printCount, ref nPrintOkIndex, ref htKPSSendingITemp); + } + + bKtchDeviceStatusSearchFlag = false; + for (int i = 0; i < htKtchDeviceStatus.Count; i++) + { + KTCH_SYS_STATUS cKtchSysStatus = (KTCH_SYS_STATUS)htKtchDeviceStatus[i]; + + //if (cKtchSysStatus.sKtchSysCd == sKtchSysCd) + if (cKtchSysStatus.sSubShopCd != sSubShopCd || cKtchSysStatus.sKtchSysCd != sKtchSysCd) // Add, 2017.02.07 + { + cKtchSysStatus.nErrorCd = nReturn; + htKtchDeviceStatus[i] = cKtchSysStatus; + bKtchDeviceStatusSearchFlag = true; + break; + } + } + + if (bKtchDeviceStatusSearchFlag == false) + { + KTCH_SYS_STATUS cKtchSysStatus = new KTCH_SYS_STATUS(); + cKtchSysStatus.sSubShopCd = sSubShopCd; + cKtchSysStatus.sKtchSysCd = sKtchSysCd; + cKtchSysStatus.nErrorCd = nReturn; + htKtchDeviceStatus.Add(htKtchDeviceStatus.Count, cKtchSysStatus); + } + + if (nReturn != 0 && nPrintOkIndex >= 0) + { + for (var i = 0; i <= nPrintOkIndex; i++) + { + if (htKPSSendingITemp.Contains(i)) + { + KPSOrderMessage cTemp = (KPSOrderMessage)htKPSSendingITemp[i]; + cTemp.sSendYn = "1"; + cTemp.sErrorCd = "0000"; + htKPSSendingITemp[i] = cTemp; + } + } + } + + if (nReturn == 0) // 정상 + { + for (var i = 0; i < htKPSSendingITemp.Count; i++) + { + if (htKPSSendingITemp.Contains(i)) + { + KPSOrderMessage cTemp = (KPSOrderMessage)htKPSSendingITemp[i]; + cTemp.sSendYn = "1"; + cTemp.sErrorCd = "0000"; + htKPSSendingITemp[i] = cTemp; + } + } + } + else + { + for (var i = nPrintOkIndex + 1; i < htKPSSendingITemp.Count; i++) + { + KPSOrderMessage cTemp = (KPSOrderMessage)htKPSSendingITemp[i]; + + // Mod, 2017.02.14 + //cTemp.sSendYn = "0"; + cTemp.sSendYn = (cTemp.sSendYn == "0") ? "8" : cTemp.sSendYn; + + if (string.IsNullOrWhiteSpace(cTemp.sErrorCd) || cTemp.sErrorCd == "0000") + { + switch (nReturn) + { + case -1: cTemp.sErrorCd = "0001"; break; // Print Open Error + case -2: cTemp.sErrorCd = "0002"; break; // Print Claim Error + case -3: cTemp.sErrorCd = "0003"; break; // Print Power Off Error + case -4: cTemp.sErrorCd = "0004"; break; // Cover Open Error + case -5: cTemp.sErrorCd = "0005"; break; // No Paper Error + default: cTemp.sErrorCd = "9999"; break; // Etc Error + } + } + + // Add, 2017.02.15 + //ktchErrorCode = cTemp.sErrorCd; + ktchErrorCode = string.Format("{0}|{1}|{2}", cTemp.sErrorCd, cTemp.sKtchSysCd, cTemp.sKtchSysNm); + + htKPSSendingITemp[i] = cTemp; + } + } + htKPSSendingItem[nLoop] = htKPSSendingITemp; + + if (nReturn != 0) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_LEVEL, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + string.Format("Print Error = [{0}][{1}]", cKPSOrderMessage.sKtchSysUseDiv, nReturn)); + } + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + } + + + /// + /// KPS Status Update + /// + /// + /// + private void KPSPrintStatusUpdate(Hashtable htKPSSendingItem, Hashtable htKtchDeviceStatus) + { + try + { + // KPS 인쇄 데이터 전송상태 갱신 + for(int nLoop = 0;nLoop < htKPSSendingItem.Count;nLoop++) + { + Hashtable htKPSSendingItemTemp = (Hashtable)htKPSSendingItem[nLoop]; + + for(int nLoop2 = 0;nLoop2 < htKPSSendingItemTemp.Count;nLoop2++) + { + KPSItem cKPSItem = (KPSItem)htKPSSendingItemTemp[nLoop2]; + + string sQuery = "UPDATE POSMST..MST_KPS_ORD_MSG \n" + + " SET SEND_YN = '" + cKPSItem.sSendYn + "' \n" + + " , RESEND_YN = '" + cKPSItem.sResendYn + "' \n" + + " , ERROR_CD = '" + cKPSItem.sErrorCd + "' \n" + + " WHERE TRAIN_MODE_YN = '" + cKPSItem.sTrainMode + "' \n" // Add, 2017.03.03, 연습모드 + + " AND ORD_DIV = '" + cKPSItem.sOrderType + "' \n" + + " AND FLOOR_CD = '" + cKPSItem.sFloorCd + "' \n" + + " AND TBL_NO = '" + cKPSItem.sTableNo + "' \n" + + " AND SUB_STOR_CD = '" + cKPSItem.sSubShopCd + "' \n" // Add, 2017.02.07 + + " AND KTCH_SYS_CD = '" + cKPSItem.sKtchSysCd + "' \n" + + " AND SEQ = " + cKPSItem.nSeq.ToString() + "\n" + ; + if (sqlDb.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null, true) != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_LEVEL, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "Query=" + sQuery); + } + } + } + + for(int nLoop = 0;nLoop < htKtchDeviceStatus.Count;nLoop++) + { + KTCH_SYS_STATUS cKtchSysStatus = (KTCH_SYS_STATUS)htKtchDeviceStatus[nLoop]; + + string sErrorCd = "0000"; + if(cKtchSysStatus.nErrorCd != 0) + { + switch(cKtchSysStatus.nErrorCd) + { + case -1: sErrorCd = "0001"; break; // Print Open Error + case -2: sErrorCd = "0002"; break; // Print Claim Error + case -3: sErrorCd = "0003"; break; // Print Power Off Error + case -4: sErrorCd = "0004"; break; // Cover Open Error + case -5: sErrorCd = "0005"; break; // No Paper Error + default: sErrorCd = "9999"; break; // Etc Error + } + } + string sQuery = "UPDATE POSMST..MST_KTCH_DEVICE \n" + + " SET FILLER1 = '" + sErrorCd + "' \n" + + " WHERE KTCH_SYS_CD = '" + cKtchSysStatus.sKtchSysCd + "' \n" + + " AND SUB_STOR_CD = '" + cKtchSysStatus.sSubShopCd + "' \n" // Add, 2017.02.07 + ; + if (sqlDb.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null, true) != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_LEVEL, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "Query=" + sQuery); + } + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + } + + private void KPSOrderMessagePrintStatusDelete(Hashtable htKPSSendingItem, Hashtable htKtchDeviceStatus) + { + try + { + for(var i = 0; i < htKPSSendingItem.Count;i++) + { + Hashtable htTemp = (Hashtable)htKPSSendingItem[i]; + + for (var j= 0; j < htTemp.Count; j++) + { + string sql = string.Empty; + KPSOrderMessage cKPSOrderMessage = (KPSOrderMessage)htTemp[j]; + if (cKPSOrderMessage.sSendYn != "1") + { + sql = "UPDATE POSMST..MST_KTCH_ORD_MSG_ADD \n" + + " SET SEND_YN = '" + cKPSOrderMessage.sSendYn + "' \n" + + " WHERE TRAIN_MODE_YN = '" + cKPSOrderMessage.sTrainMode + "' \n" // Add, 2017.03.03, 연습모드 + + " AND ORD_DIV = '" + cKPSOrderMessage.sOrderType + "' \n" + + " AND FLOOR_CD = '" + cKPSOrderMessage.sFloorCd + "' \n" + + " AND TBL_NO = '" + cKPSOrderMessage.sTableNo + "' \n" + + " AND SEQ = " + cKPSOrderMessage.nSeq + " \n" + ; + } + else + { + sql = "DELETE FROM POSMST..MST_KTCH_ORD_MSG_ADD \n" + + " WHERE TRAIN_MODE_YN = '" + cKPSOrderMessage.sTrainMode + "' \n" // Add, 2017.03.03, 연습모드 + + " AND ORD_DIV = '" + cKPSOrderMessage.sOrderType + "' \n" + + " AND FLOOR_CD = '" + cKPSOrderMessage.sFloorCd + "' \n" + + " AND TBL_NO = '" + cKPSOrderMessage.sTableNo + "' \n" + + " AND SEQ = " + cKPSOrderMessage.nSeq + " \n" + ; + } + + if(sqlDb.DBExecuteNonQuery(new string[] {sql}, CommandType.Text, (SqlParameter[])null, true) != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_LEVEL, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "Query=" + sql); + } + } + } + + for(int nLoop = 0;nLoop < htKtchDeviceStatus.Count;nLoop++) + { + KTCH_SYS_STATUS cKtchSysStatus = (KTCH_SYS_STATUS)htKtchDeviceStatus[nLoop]; + + string sErrorCode = "0000"; + if(cKtchSysStatus.nErrorCd != 0) + { + switch(cKtchSysStatus.nErrorCd) + { + case -1: sErrorCode = "0001"; break; // Print Open Error + case -2: sErrorCode = "0002"; break; // Print Claim Error + case -3: sErrorCode = "0003"; break; // Print Power Off Error + case -4: sErrorCode = "0004"; break; // Cover Open Error + case -5: sErrorCode = "0005"; break; // No Paper Error + default: sErrorCode = "9999"; break; // Etc Error + } + } + + string sQuery = " UPDATE POSMST..MST_KTCH_DEVICE \n" + + " SET FILLER1 = '" + sErrorCode + "' \n" + + " WHERE KTCH_SYS_CD = '" + cKtchSysStatus.sKtchSysCd + "' \n" + + " AND SUB_STOR_CD = '" + cKtchSysStatus.sSubShopCd + "' \n" // Add, 2017.02.07 + ; + if (sqlDb.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null, true) != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_LEVEL, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "Query=" + sQuery); + } + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + } + + /// + /// Get KPS Order Message + /// + /// + private void GetKPSOrderMessage(ref Hashtable htKPSSendingItem) + { + string sQuery = string.Empty; + + DataTable dtData = null; + + try + { + #region (주석) 복합매장 적용 이전 버전 + //sQuery = " SELECT A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ, A.KTCH_SYS_CD "; + //sQuery += " , A.ITEM_CD, A.SHTCUT_ITEMNM, A.MSG_DIV, A.MSG1, A.MSG2 "; + //sQuery += " , A.MSG3, A.MSG_REG_TIME, B.KTCH_SYS_USE_DIV, B.KTCH_PRINTER_COMM_PORT, B.KTCH_PRINTER_COMM_SPEED "; + //sQuery += " , B.KTCH_PRINTER_OPOS_NM, B.KTCH_PRINTER_IP, B.KTCH_PRINTER_PORT, B.KTCH_PRINTER_BAK1, B.KTCH_PRINTER_BAK2 "; + //sQuery += " , B.KTCH_PRINTER_BAK3, B.KTCH_PRINTER_BAK4, B.KTCH_PRINTER_BAK5, B.KTCH_PRINTER_BAK6 "; + //sQuery += " FROM POSMST..MST_KTCH_ORD_MSG_ADD A "; + //sQuery += " , POSMST..MST_KTCH_DEVICE B "; + //sQuery += " WHERE A.SEND_YN = '0' "; + //sQuery += " AND A.KTCH_SYS_CD = B.KTCH_SYS_CD "; + //sQuery += " AND B.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + //sQuery += " AND B.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + //sQuery += " AND B.KTCH_SYS_DIV = '1' "; + //sQuery += " ORDER BY B.KTCH_SYS_CD, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ "; + #endregion + + #region (주석) 연습모드 적용 이전 버전, 2017.03.03 + //sQuery = " SELECT A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ, A.SUB_STOR_CD, A.KTCH_SYS_CD \n" + // + " , A.ITEM_CD, A.SHTCUT_ITEMNM, A.MSG_DIV, A.MSG1, A.MSG2 \n" + // + " , A.MSG3, A.MSG_REG_TIME, B.KTCH_SYS_USE_DIV, B.KTCH_PRINTER_COMM_PORT, B.KTCH_PRINTER_COMM_SPEED \n" + // + " , B.KTCH_PRINTER_OPOS_NM, B.KTCH_PRINTER_IP, B.KTCH_PRINTER_PORT, ISNULL(B.PRT_CNT, 1) PRT_CNT, A.REG_DT \n" + // + " FROM POSMST..MST_KTCH_ORD_MSG_ADD A \n" + // + " , POSMST..MST_KTCH_DEVICE B \n" + // + " WHERE A.SEND_YN = '0' \n" + // + " AND A.SUB_STOR_CD = B.SUB_STOR_CD \n" // Add, 2017.02.06 + // + " AND A.KTCH_SYS_CD = B.KTCH_SYS_CD \n" + // + " AND B.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + // + " AND B.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + // + " AND B.KTCH_SYS_DIV = '1' \n" + // + " AND B.KTCH_SYS_CD <> '99' \n" + // + " ORDER BY A.SUB_STOR_CD, B.KTCH_SYS_CD, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ \n" + // ; + #endregion + + #region (주석) + // Mod, 2017.03.03, 연습모드 + //sQuery = " SELECT A.TRAIN_MODE_YN, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ, A.SUB_STOR_CD, A.KTCH_SYS_CD \n" + // + " , A.ITEM_CD, A.SHTCUT_ITEMNM, A.MSG_DIV, A.MSG1, A.MSG2 \n" + // + " , A.MSG3, A.MSG_REG_TIME, B.KTCH_SYS_USE_DIV, B.KTCH_PRINTER_COMM_PORT, B.KTCH_PRINTER_COMM_SPEED \n" + // + " , B.KTCH_PRINTER_OPOS_NM, B.KTCH_PRINTER_IP, B.KTCH_PRINTER_PORT, ISNULL(B.PRT_CNT, 1) PRT_CNT, A.REG_DT \n" + // + " FROM POSMST..MST_KTCH_ORD_MSG_ADD A \n" + // + " , POSMST..MST_KTCH_DEVICE B WITH(NOLOCK) \n" + // + " WHERE A.SEND_YN = '0' \n" + // + " AND A.SUB_STOR_CD = B.SUB_STOR_CD \n" + // + " AND A.KTCH_SYS_CD = B.KTCH_SYS_CD \n" + // + " AND B.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + // + " AND B.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + // + " AND B.KTCH_SYS_DIV = '" + PosConst.KTCH_SYS_DIV.KPS + "' \n" + // + " AND B.KTCH_SYS_CD <> '99' \n" + // + " ORDER BY A.TRAIN_MODE_YN, A.SUB_STOR_CD, B.KTCH_SYS_CD, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ \n" + // ; + #endregion + + sQuery = " SELECT A.TRAIN_MODE_YN, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ, A.SUB_STOR_CD, A.KTCH_SYS_CD \n" + + " , A.ITEM_CD, A.SHTCUT_ITEMNM, A.MSG_DIV, A.MSG1, A.MSG2 \n" + + " , A.MSG3, A.MSG_REG_TIME, B.KTCH_SYS_USE_DIV, B.KTCH_PRINTER_COMM_PORT, B.KTCH_PRINTER_COMM_SPEED \n" + + " , B.KTCH_PRINTER_OPOS_NM, B.KTCH_PRINTER_IP, B.KTCH_PRINTER_PORT, ISNULL(B.PRT_CNT, 1) PRT_CNT, A.REG_DT \n" + + " , B.KTCH_SYS_NM \n" + + " , A.ORD_POS_NO \n" + + " FROM POSMST..MST_KTCH_ORD_MSG_ADD A \n" + + " , POSMST..MST_KTCH_DEVICE B WITH(NOLOCK) \n" + + " WHERE A.SEND_YN = '0' \n" + + " AND A.SUB_STOR_CD = B.SUB_STOR_CD \n" + + " AND A.KTCH_SYS_CD = B.KTCH_SYS_CD \n" + + " AND A.ORD_POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n" + + " AND B.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + + " AND B.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + + " AND B.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" // Add, 20170612 POS별 주방프린터 설정 + + " AND B.KTCH_SYS_DIV = '" + PosConst.KTCH_SYS_DIV.KPS + "' \n" + + " AND B.KTCH_SYS_CD <> '99' \n" + + " ORDER BY A.TRAIN_MODE_YN, A.SUB_STOR_CD, B.KTCH_SYS_CD, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SEQ \n" + ; + + + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) != UserCom.OK) + { + return; + } + + var itemKey = string.Empty; + + Hashtable htTemp = new Hashtable(); + foreach (DataRow dr in dtData.Rows) + { + KPSOrderMessage cKPSOrderMsg = new KPSOrderMessage(); + + cKPSOrderMsg.sTrainMode = CmUtil.GetDataRowStr(dr, "TRAIN_MODE_YN"); // Add, 2017.03.03, 연습모드 + + cKPSOrderMsg.sOrderType = CmUtil.GetDataRowStr(dr, "ORD_DIV"); + cKPSOrderMsg.sFloorCd = CmUtil.GetDataRowStr(dr, "FLOOR_CD"); + cKPSOrderMsg.sTableNo = CmUtil.GetDataRowStr(dr, "TBL_NO"); + cKPSOrderMsg.nSeq = CmUtil.GetDataRowInt(dr, "SEQ"); + + cKPSOrderMsg.sSubShopCd = CmUtil.GetDataRowStr(dr, "SUB_STOR_CD"); // Add, 2017.02.06 + cKPSOrderMsg.sKtchSysCd = CmUtil.GetDataRowStr(dr, "KTCH_SYS_CD"); + cKPSOrderMsg.sKtchSysNm = CmUtil.GetDataRowStr(dr, "KTCH_SYS_NM"); // Add, 2017.04.07 + + cKPSOrderMsg.sItemCd = CmUtil.GetDataRowStr(dr, "ITEM_CD"); + cKPSOrderMsg.sItemNm = CmUtil.GetDataRowStr(dr, "SHTCUT_ITEMNM"); + cKPSOrderMsg.sMsgId = CmUtil.GetDataRowStr(dr, "MSG_DIV"); + cKPSOrderMsg.sMsg1 = CmUtil.GetDataRowStr(dr, "MSG1"); + cKPSOrderMsg.sMsg2 = CmUtil.GetDataRowStr(dr, "MSG2"); + cKPSOrderMsg.sMsg3 = CmUtil.GetDataRowStr(dr, "MSG3"); + cKPSOrderMsg.sMsgRegTime = CmUtil.GetDataRowStr(dr, "MSG_REG_TIME"); + cKPSOrderMsg.sKtchSysUseDiv = CmUtil.GetDataRowStr(dr, "KTCH_SYS_USE_DIV"); + cKPSOrderMsg.nKpsComPort = CmUtil.GetDataRowInt(dr, "KTCH_PRINTER_COMM_PORT"); + cKPSOrderMsg.nKpsComBaudrate = CmUtil.GetDataRowInt(dr, "KTCH_PRINTER_COMM_SPEED"); + cKPSOrderMsg.sKpsOposName = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_OPOS_NM"); + cKPSOrderMsg.sKpsIp = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_IP"); + cKPSOrderMsg.sKpsPort = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_PORT"); + + cKPSOrderMsg.sSendYn = "0"; + + // Add, 2017.02.14, 반복출력횟수 + cKPSOrderMsg.printCount = CmUtil.GetDataRowInt(dr, "PRT_CNT"); + if (cKPSOrderMsg.printCount == 0) cKPSOrderMsg.printCount = 1; + + //cKPSOrderMsg.sKpsCdBackup1 = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_BAK1"); + //cKPSOrderMsg.sKpsCdBackup2 = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_BAK2"); + //cKPSOrderMsg.sKpsCdBackup3 = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_BAK3"); + //cKPSOrderMsg.sKpsCdBackup4 = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_BAK4"); + //cKPSOrderMsg.sKpsCdBackup5 = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_BAK5"); + //cKPSOrderMsg.sKpsCdBackup6 = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_BAK6"); + + // Add, 2017.02.14 + var temp = CmUtil.GetDataRowStr(dr, "REG_DT").Trim(); + cKPSOrderMsg.sRegDate = temp.Length > 8 ? temp.Substring(0, 8) : m_cPosStatus.Base.SaleDate; + + // Mod, 2017.02.10 + //htKPSSendingItem.Add(htKPSSendingItem.Count, cKPSOrderMsg); + //var checkKey = cKPSOrderMsg.sSubShopCd + cKPSOrderMsg.sKtchSysCd + cKPSOrderMsg.sFloorCd + cKPSOrderMsg.sTableNo + cKPSOrderMsg.sMsgId; + //var checkKey = cKPSOrderMsg.sTrainMode + cKPSOrderMsg.sSubShopCd + cKPSOrderMsg.sKtchSysCd + cKPSOrderMsg.sFloorCd + cKPSOrderMsg.sTableNo + cKPSOrderMsg.sMsgId; + + var checkKey = string.Empty; + switch (cKPSOrderMsg.sMsgId) + { + case PosConst.KPS_ORD_MSG_ID.ITEM_MEMO: + //case PosConst.KPS_ORD_MSG_ID.FIRE_KEY: + checkKey = cKPSOrderMsg.sTrainMode + cKPSOrderMsg.sSubShopCd + cKPSOrderMsg.sKtchSysCd + cKPSOrderMsg.sFloorCd + cKPSOrderMsg.sTableNo + cKPSOrderMsg.sMsgId + cKPSOrderMsg.sItemCd; + break; + case PosConst.KPS_ORD_MSG_ID.FIRE_KEY: + default: + checkKey = cKPSOrderMsg.sTrainMode + cKPSOrderMsg.sSubShopCd + cKPSOrderMsg.sKtchSysCd + cKPSOrderMsg.sFloorCd + cKPSOrderMsg.sTableNo + cKPSOrderMsg.sMsgId; + break; + } + + if (itemKey != checkKey) + { + if (htTemp.Count != 0) + { + htKPSSendingItem.Add(htKPSSendingItem.Count, htTemp); + } + + itemKey = checkKey; + + htTemp = new Hashtable(); + } + htTemp.Add(htTemp.Count, cKPSOrderMsg); + } + + if (htTemp.Count != 0) + { + htKPSSendingItem.Add(htKPSSendingItem.Count, htTemp); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + } + + /// + /// Get KPS Send Ok Count (미사용) + /// + /// + /// + /// + /// + /// + private int GetKpsSendOkCount(string sOrderType, string sFloorCd, string sTableNo) + { + int nKpsSendCount = 0; + string sDbSource = string.Empty; + string sDbCatalog = string.Empty; + string sDbUserId = string.Empty; + string sDbPassword = string.Empty; + DataTable dtData = null; + try + { + + string sQuery = string.Empty; + sQuery = " SELECT COUNT(1) AS COUNT"; + sQuery += " FROM POSMST..MST_KTCH_ORD_MSG "; + sQuery += " WHERE ORD_DIV = '" + sOrderType + "' "; + sQuery += " AND FLOOR_CD = '" + sFloorCd + "' "; + sQuery += " AND TBL_NO = '" + sTableNo + "' "; + sQuery += " AND SEND_YN = '1' "; + + // 조회 + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK) + { + nKpsSendCount = CmUtil.GetDataRowInt(dtData.Rows[0], "COUNT"); + } + + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + + return nKpsSendCount; + } + + private int KPSSerialPrintProc(string sCancelFlag, string sResendFlag, int iKpsComPort, int iKpsComBaudrate, int prtCount, ref int nPrintOkIndex, ref Hashtable htKPSSendingItem) + { + var iRet = -99; + + var sPrtBar1 = new string('-', 42); + var sPrtBar2 = new string('=', 42); + var sPrtDat1 = string.Empty; + var sPrtDat2 = string.Empty; + + SerialPrint cPrint = new SerialPrint(); + + try + { + nPrintOkIndex = -1; + + cPrint.DeviceOpen("COM" + iKpsComPort.ToString(), iKpsComBaudrate); + + if (cPrint.IsPortOpened == false) + { + cPrint.DeviceClose(); + return -9; + } + + // Cover Check + iRet = cPrint.PrinterStatusCheckBySerial("CHK1"); + if (iRet != UserCom.OK) + { + cPrint.DeviceClose(); + return -4; + } + + // Paper Check + iRet = cPrint.PrinterStatusCheckBySerial("CHK2"); + if (iRet != UserCom.OK) + { + cPrint.DeviceClose(); + return -5; + } + + for (var cnt = 0; cnt < prtCount; cnt++) + { + var itemKey = string.Empty; + var ktchMemo = string.Empty; + var orderNo1 = string.Empty; + var orderNo2 = string.Empty; + + // 주문상품 인쇄 + for (int nLoop = 0; nLoop < htKPSSendingItem.Count; nLoop++) + { + KPSItem cKPSItem = (KPSItem)htKPSSendingItem[nLoop]; + + // 이미 전송 완료 건 제외 + if (cKPSItem.sSendYn == "1") + { + continue; + } + + // Add, 2017.03.03, 연습모드 + //var checkKey = cKPSItem.sOrderType + cKPSItem.sFloorCd + cKPSItem.sTableNo; + var checkKey = cKPSItem.sTrainMode + cKPSItem.sOrderType + cKPSItem.sFloorCd + cKPSItem.sTableNo; + if (itemKey != checkKey) + { + //if (sOrgOrderType != "") + if (string.IsNullOrWhiteSpace(itemKey) == false) + { + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.CutPaper(4); + + // 인쇄 완료 인덱스 + nPrintOkIndex = nLoop - 1; + } + + // 원정보 설정 + itemKey = checkKey; + + // 제목 + sPrtDat1 = string.Format("<< {0} >>", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0154)); + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_2, true); + + // 연습모드 // Add, 2017.03.03, + if (cKPSItem.sTrainMode == ItemConst.TRAINING_FLAG.TRAINING_YES) + { + sPrtDat1 = MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0033); + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + } + + // 복합매장-서브매장명 + if (string.IsNullOrWhiteSpace(m_cPosStatus.Base.SubShopNm) == false) + { + sPrtDat1 = m_cPosStatus.Base.SubShopNm; + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + } + cPrint.TextPrint("", PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + + // 반복횟수 + var prtCnt = prtCount > 1 ? string.Format(" ({0}/{1})", cnt + 1, prtCount) : string.Empty; + // 주문시간 + sPrtDat1 = string.Format("{0} : {1} {2} {3}", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0155) + , m_cPosStatus.Global.DateToCulture(m_cPosStatus.Base.SaleDate) + , CmUtil.StrToTime(cKPSItem.sOrdTime) + , prtCnt); + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + + // 주문번호 + if (cKPSItem.sFiller2 == "2") + { + // 해피오더 + sPrtDat1 = string.Format("{0} : {1}", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0158), cKPSItem.sOrderNo); + } + //else if (cKPSItem.sPosType == PosConst.POS_TYPE.DEFERRED_PAYMENT) + //{ + // // 후불 + // sPrtDat1 = string.Format("{0} : {1}-{2}", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0156), cKPSItem.sFloorCd, cKPSItem.sTableNo); + //} + else + { + sPrtDat1 = string.Format("{0} : {1}", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0156), cKPSItem.sOrderNo); + } + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + + // 주문담당자 + if (string.IsNullOrWhiteSpace(cKPSItem.sOrdPicNm) == false) + { + sPrtDat1 = string.Format("{0} : {1}", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0189), cKPSItem.sOrdPicNm.Trim()); + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + } + + // 인원 + if (cKPSItem.sPosType == PosConst.POS_TYPE.DEFERRED_PAYMENT) + { + sPrtDat1 = GetCustInfo(cKPSItem.sTrainMode, cKPSItem.sFloorCd, cKPSItem.sTableNo); + if (string.IsNullOrWhiteSpace(sPrtDat1) == false) + { + sPrtDat1 = string.Format("{0} : {1}", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0157), sPrtDat1); + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + } + } + + // 주문번호/테이블 + // Mod, 2017.05.08, 주분번호 후불=상단, 선불=하단 출력 + sPrtDat1 = string.Empty; + sPrtDat2 = string.Empty; + orderNo1 = string.Empty; + orderNo2 = string.Empty; + if (cKPSItem.sPosType == PosConst.POS_TYPE.DEFERRED_PAYMENT) + { + #region (주문번호 상단 출력) + + if (cKPSItem.sPosType == PosConst.POS_TYPE.DEFERRED_PAYMENT && string.IsNullOrWhiteSpace(cKPSItem.sFiller2)) + { + sPrtDat1 = string.Format("[ {0} ]", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0148)); + sPrtDat2 = string.Format("{0}-{1}", GetFloorName(cKPSItem.sFloorCd), GetTableName(cKPSItem.sFloorCd, cKPSItem.sTableNo)); + } + else if (string.IsNullOrWhiteSpace(cKPSItem.sOrderNo) == false) + { + sPrtDat1 = string.Format("[ {0} ]", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0097)); + sPrtDat2 = string.Format("{0}", cKPSItem.sOrderNo); + } + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + cPrint.TextPrint(sPrtDat2, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_2 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + cPrint.TextPrint(sPrtBar2, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + + #endregion + } + else + { + #region (주문번호 하단 출력) + + if (cKPSItem.sPosType == PosConst.POS_TYPE.DEFERRED_PAYMENT && string.IsNullOrWhiteSpace(cKPSItem.sFiller2)) + { + orderNo1 = string.Format("{0}-{1}", GetFloorName(cKPSItem.sFloorCd), GetTableName(cKPSItem.sFloorCd, cKPSItem.sTableNo)); + orderNo2 = string.Format("[ {0} ]", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0148)); + + } + else if (string.IsNullOrWhiteSpace(cKPSItem.sOrderNo) == false) + { + orderNo1 = string.Format("{0}", cKPSItem.sOrderNo); + orderNo2 = string.Format("[ {0} ]", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0097)); + } + cPrint.TextPrint(sPrtBar2, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + + #endregion + } + } + + // 상품/수량 + var sign = cKPSItem.sCancelDiv == "1" ? -1 : 1; + var type = GetAddOrderString(cKPSItem.sFiller3); + var qty = cKPSItem.nQty == 0 ? string.Empty : (sign * cKPSItem.nQty).ToString(); + sPrtDat1 = CmUtil.RPadH(cKPSItem.sItemNm, 30) + CmUtil.RPadH(type, 5) + CmUtil.LPadH(qty, 6); + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + + //2017.09.07 레시피 출력 + if(cKPSItem.sRecipe.ToString().Trim().Length > 0) + { + string Recipe = cKPSItem.sRecipe.Replace("@", "\r").Replace("$","\n").ToString(); + string[] RecipeData = Recipe.Split(new string[] { "\r\n", "\n", "\r" }, StringSplitOptions.None); + + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + foreach(var dt in RecipeData) + { + cPrint.TextPrint(dt.Trim(), PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + } + } + + // Add, 2017.03.21, 상품메모 + if (string.IsNullOrWhiteSpace(cKPSItem.sItemMemo) == false) + { + var lst = this.GetParserMemo(cKPSItem.sItemMemo); + foreach (var msg in lst) + { + cPrint.TextPrint(" " + msg.Trim(), PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + } + } + + // Add, 2017.04.10, 상품구분라인 + var nextIdx = nLoop + 1; + if (nextIdx < htKPSSendingItem.Count) + { + var NextItemDiv = ((KPSItem)htKPSSendingItem[nextIdx]).sItemDiv; + switch (NextItemDiv) + { + case ItemConst.PLU_ITEM_DIV.NORMAL: + case ItemConst.PLU_ITEM_DIV.SET_MAIN: + case ItemConst.PLU_ITEM_DIV.SET_DIS: + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + break; + } + } + + #region Mod, 2017.04.25, 주방메모 출력 + // Add, 2017.01.23 + // 주방프린터 수동출력(상품선택) 옵션시 주방메모 + //if (PosMstManager.GetPosOption(POS_OPTION.OPT425) == "2") + //{ + // ktchMemo = cKPSItem.sKtchMemo; + //} + #endregion + ktchMemo = cKPSItem.sKtchMemo; + } + + // Add, 2017.01.23, 수동출력옵션 시 주방메모 출력 + if (string.IsNullOrWhiteSpace(ktchMemo) == false) + { + cPrint.TextPrint(sPrtBar2, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint("Memo: ", PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + var lst = this.GetParserMemo(ktchMemo); + foreach (var msg in lst) + { + cPrint.TextPrint(" " + msg.Trim(), PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + } + } + + // Add, 2017.04.07 + if (string.IsNullOrWhiteSpace(orderNo1) == false) + { + cPrint.TextPrint(sPrtBar2, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint(orderNo1, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_2 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + cPrint.TextPrint(orderNo2, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + } + + // Cutting + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.CutPaper(4); + } + + // 인쇄 완료 인덱스 설정 + nPrintOkIndex = htKPSSendingItem.Count - 1; + + // Port Close + cPrint.DeviceClose(); + } + catch (Exception ex) + { + cPrint.DeviceClose(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + return -99; + } + + return 0; + } + + private int KPSOrderMessageSerialPrintProc(string sResendFlag, int iKpsComPort, int iKpsComBaudrate, int prtCount, ref int nPrintOkIndex, ref Hashtable htKPSOrderMessage) + { + var iRet = UserCom.NG; + + var sPrtBar1 = new string('-', 42); + var sPrtData = string.Empty; + + SerialPrint cPrint = new SerialPrint(); + + try + { + nPrintOkIndex = -1; + + iRet = cPrint.DeviceOpen("COM" + iKpsComPort.ToString(), iKpsComBaudrate); + if (iRet != UserCom.OK) + { + cPrint.DeviceClose(); + return -9; + } + + // Cover Check + iRet = cPrint.PrinterStatusCheckBySerial("CHK1"); + if (iRet != UserCom.OK) + { + cPrint.DeviceClose(); + return -4; + } + + // Paper Check + iRet = cPrint.PrinterStatusCheckBySerial("CHK2"); + if (iRet != UserCom.OK) + { + cPrint.DeviceClose(); + return -5; + } + + + for (var cnt = 0; cnt < prtCount; cnt++) + { + var itemKey = string.Empty; + + for (int nLoop = 0; nLoop < htKPSOrderMessage.Count; nLoop++) + { + KPSOrderMessage cKPSMessage = (KPSOrderMessage)htKPSOrderMessage[nLoop]; + + if (cKPSMessage.sSendYn == "1") + { + continue; + } + + var checkKey = cKPSMessage.sTrainMode + cKPSMessage.sOrderType + cKPSMessage.sFloorCd + cKPSMessage.sTableNo + cKPSMessage.sMsgId; + if (itemKey != checkKey) + { + if (itemKey != "") + { + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.CutPaper(4); + + // 인쇄 완료 인덱스 + nPrintOkIndex = nLoop - 1; + } + + itemKey = checkKey; + + + #region ### 헤더 출력 + string sPrintTitle = this.GetOrderMessageTitle(cKPSMessage.sMsgId); + switch (cKPSMessage.sMsgId) + { + case PosConst.KPS_ORD_MSG_ID.TABLE_COMBINE: + case PosConst.KPS_ORD_MSG_ID.TABLE_MOVE: + case PosConst.KPS_ORD_MSG_ID.MENU_MOVE: + sPrtData = string.Format("[{0}{1}]", sPrintTitle, (sResendFlag == "1") ? " (R)" : ""); + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + + // 연습모드 // Add, 2017.03.03, + if (cKPSMessage.sTrainMode == ItemConst.TRAINING_FLAG.TRAINING_YES) + { + sPrtData = MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0033); + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + } + + cPrint.TextPrint("", PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + sPrtData = sPrintTitle + " : " + + GetFloorName(cKPSMessage.sFloorCd) + "-" + GetTableName(cKPSMessage.sFloorCd, cKPSMessage.sTableNo) + " -> " + + GetFloorName(cKPSMessage.sMsg1) + "-" + GetTableName(cKPSMessage.sMsg1, cKPSMessage.sMsg2); + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + break; + default: + sPrtData = string.Format("[{0}{1}]", sPrintTitle, (sResendFlag == "1") ? " (R)" : ""); + if (cKPSMessage.sMsgId == PosConst.KPS_ORD_MSG_ID.FIRE_KEY) + { + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1 + , PrinterCommand.TextBold.Nomal, PrinterCommand.TextUnderLine.Nomal, PrinterCommand.TextReverseMode.ReverseMode, true); + } + else + { + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + } + + // 연습모드 // Add, 2017.03.03, + if (cKPSMessage.sTrainMode == ItemConst.TRAINING_FLAG.TRAINING_YES) + { + sPrtData = MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0033); + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + } + + cPrint.TextPrint("", PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + sPrtData = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0176) + " : " + + GetFloorName(cKPSMessage.sFloorCd) + "-" + GetTableName(cKPSMessage.sFloorCd, cKPSMessage.sTableNo); + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + break; + } + #endregion + + #region ### 상품정보 출력 + switch (cKPSMessage.sMsgId) + { + case PosConst.KPS_ORD_MSG_ID.ITEM_MEMO: + //case PosConst.KPS_ORD_MSG_ID.FIRE_KEY: + cPrint.TextPrint(cKPSMessage.sItemNm.Trim(), PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + break; + + case PosConst.KPS_ORD_MSG_ID.FIRE_KEY: // Add, 2017.03.22 + for (var i = nLoop; i < htKPSOrderMessage.Count; i++) + { + KPSOrderMessage cKPSOrderSubMsg = (KPSOrderMessage)htKPSOrderMessage[i]; + + sPrtData = string.Format("{0}{1}", CmUtil.RPadH(cKPSOrderSubMsg.sItemNm, 37), CmUtil.LPadH(cKPSOrderSubMsg.sMsg1, 5)); + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + + // Main Index 동기화 + nLoop = i; + } + break; + + case PosConst.KPS_ORD_MSG_ID.MENU_MOVE: + for (var i = nLoop; i < htKPSOrderMessage.Count; i++) + { + KPSOrderMessage cKPSOrderSubMsg = (KPSOrderMessage)htKPSOrderMessage[i]; + if (cKPSOrderSubMsg.sSendYn == "1") break; ; + if (cKPSMessage.sMsgId != cKPSOrderSubMsg.sMsgId) break; + if (cKPSMessage.sFloorCd != cKPSOrderSubMsg.sFloorCd) break; + if (cKPSMessage.sTableNo != cKPSOrderSubMsg.sTableNo) break; + if (cKPSMessage.sOrderType != cKPSOrderSubMsg.sOrderType) break; + if (cKPSMessage.sKtchSysCd != cKPSOrderSubMsg.sKtchSysCd) break; + if (cKPSMessage.sMsg1.Trim() != cKPSOrderSubMsg.sMsg1.Trim()) break; + if (cKPSMessage.sMsg2.Trim() != cKPSOrderSubMsg.sMsg2.Trim()) break; + + // 메뉴이동 상품정보 출력 + sPrtData = string.Format("{0}{1}", CmUtil.RPadH(cKPSOrderSubMsg.sItemNm, 37), CmUtil.LPadH(cKPSOrderSubMsg.sMsg3, 5)); + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + + //// 전송완료설정 + //cKPSOrderSubMsg.sSendYn = "1"; + + // Main Index 동기화 + nLoop = i; + } + + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + break; + } + #endregion + + #region ### 메시지 출력 + switch (cKPSMessage.sMsgId) + { + case PosConst.KPS_ORD_MSG_ID.ITEM_MEMO: + //case PosConst.KPS_ORD_MSG_ID.FIRE_KEY: // Del, 2017.03.22 + case PosConst.KPS_ORD_MSG_ID.SEAT_MEMO: + if (cKPSMessage.sMsg1.Trim() != "") + { + cPrint.TextPrint(" " + cKPSMessage.sMsg1.Trim(), PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + } + if (cKPSMessage.sMsg2.Trim() != "") + { + cPrint.TextPrint(" " + cKPSMessage.sMsg2.Trim(), PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + } + if (cKPSMessage.sMsg3.Trim() != "") + { + cPrint.TextPrint(" " + cKPSMessage.sMsg3.Trim(), PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + } + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + break; + } + #endregion + + #region ### 꼬리 출력 + // 반복횟수 + var prtCnt = prtCount > 1 ? string.Format(" ({0}/{1})", cnt + 1, prtCount) : string.Empty; + // 주문시간 + sPrtData = string.Format("{0} : {1} {2} {3}", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0085) + , m_cPosStatus.Global.DateToCulture(cKPSMessage.sRegDate) + , CmUtil.StrToTime(cKPSMessage.sMsgRegTime) + , prtCnt); + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + #endregion + + // Cutting + cPrint.CutPaper(4); + } + //// 전송완료설정 + //cKPSMessage.sSendYn = "1"; + } + } + + // 인쇄 완료 인덱스 + nPrintOkIndex = htKPSOrderMessage.Count - 1; + + // Port Close + Thread.Sleep(200); + cPrint.DeviceClose(); + } + catch (Exception ex) + { + cPrint.DeviceClose(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + return -99; + } + + return 0; + } + + + private int KPSLanPrintProc(string sCancelFlag, string sResendFlag, string sKpsIp, string sKpsPort, int prtCount, ref int nPrintOkIndex, ref Hashtable htKPSSendingItem) + { + var iRet = UserCom.NG; + + var sPrtBar1 = new string('-', 42); + var sPrtBar2 = new string('=', 42); + var sPrtDat1 = string.Empty; + var sPrtDat2 = string.Empty; + + LANPrint cPrint = new LANPrint(); + + try + { + iRet = cPrint.OpenDevice(sKpsIp, int.Parse(sKpsPort)); + if (iRet != UserCom.OK) + { + cPrint.CloseDevice(); + return -9; + } + + // Cover Check + iRet = cPrint.PrinterStatusCheckByLan("CHK1"); + if (iRet != UserCom.OK) + { + cPrint.CloseDevice(); + return -4; + } + + // Paper Check + iRet = cPrint.PrinterStatusCheckByLan("CHK2"); + if (iRet != UserCom.OK) + { + cPrint.CloseDevice(); + return -5; + } + + for (var cnt = 0; cnt < prtCount; cnt++) + { + var ktchMemo = string.Empty; + var itemKey = string.Empty; + var orderNo1 = string.Empty; + var orderNo2 = string.Empty; + + // 주문상품 인쇄(주방장치코드가 같은 상품들) + for (int nLoop = 0; nLoop < htKPSSendingItem.Count; nLoop++) + { + KPSItem cKPSItem = (KPSItem)htKPSSendingItem[nLoop]; + + // 이미 전송 완료 건 제외 + if (cKPSItem.sSendYn == "1") + { + continue; + } + + // Add, 2017.03.03, 연습모드 + //var checkKey = cKPSItem.sOrderType + cKPSItem.sFloorCd + cKPSItem.sTableNo; + var checkKey = cKPSItem.sTrainMode + cKPSItem.sOrderType + cKPSItem.sFloorCd + cKPSItem.sTableNo; + if (itemKey != checkKey) + { + //if (sOrgOrderType != "") + if (string.IsNullOrWhiteSpace(itemKey) == false) + { + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.CutPaper(4); + + // 인쇄 완료 인덱스 + nPrintOkIndex = nLoop - 1; + } + + // 원정보 설정 + itemKey = checkKey; + + // 제목 + sPrtDat1 = string.Format("<< {0} >>", "주 문 서"); //MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0154)); + + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_2, true); + + cPrint.TextPrint(cKPSItem.sOrderNo, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_3, PrinterCommand.CharactersizeH.H_3 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + + + // 연습모드 Add, 2017.03.03, + if (cKPSItem.sTrainMode == ItemConst.TRAINING_FLAG.TRAINING_YES) + { + sPrtDat1 = MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0033); + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + } + + // 복합매장-서브매장명 + if (string.IsNullOrWhiteSpace(m_cPosStatus.Base.SubShopNm) == false) + { + sPrtDat1 = m_cPosStatus.Base.SubShopNm; + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + } + cPrint.TextPrint("", PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + + // 반복횟수 + var prtCnt = prtCount > 1 ? string.Format(" ({0}/{1})", cnt + 1, prtCount) : string.Empty; + // 주문시간 + sPrtDat1 = string.Format("{0} : {1} {2} {3}", "주문시간" //MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0155) + , m_cPosStatus.Global.DateToCulture(m_cPosStatus.Base.SaleDate) + , CmUtil.StrToTime(cKPSItem.sOrdTime) + , prtCnt); + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + + // 주문번호 + if (cKPSItem.sFiller2 == "2") + { + // 해피오더 + sPrtDat1 = string.Format("{0} : {1}", "주문번호" //MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0158) + , cKPSItem.sOrderNo); + } + //else if (cKPSItem.sPosType == PosConst.POS_TYPE.DEFERRED_PAYMENT) + //{ + // // 후불 + // sPrtDat1 = string.Format("{0} : {1}-{2}", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0156), cKPSItem.sFloorCd, cKPSItem.sTableNo); + //} + else + { + sPrtDat1 = string.Format("{0} : {1}", "주문번호"// MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0156) + , cKPSItem.sOrderNo); + } + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + + // 주문담당자 + if (string.IsNullOrWhiteSpace(cKPSItem.sOrdPicNm) == false) + { + sPrtDat1 = string.Format("{0} : {1}", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0189), cKPSItem.sOrdPicNm.Trim()); + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + } + + // 인원 + if (cKPSItem.sPosType == PosConst.POS_TYPE.DEFERRED_PAYMENT) + { + sPrtDat1 = GetCustInfo(cKPSItem.sTrainMode, cKPSItem.sFloorCd, cKPSItem.sTableNo); + if (string.IsNullOrWhiteSpace(sPrtDat1) == false) + { + sPrtDat1 = string.Format("{0} : {1}", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0157), sPrtDat1); + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + } + } + + // 주문번호/테이블 + // Mod, 2017.05.08, 주분번호 후불=상단, 선불=하단 출력 + sPrtDat1 = string.Empty; + sPrtDat2 = string.Empty; + orderNo1 = string.Empty; + orderNo2 = string.Empty; + if (cKPSItem.sPosType == PosConst.POS_TYPE.DEFERRED_PAYMENT) + { + #region (주문번호 상단 출력) + + if (cKPSItem.sPosType == PosConst.POS_TYPE.DEFERRED_PAYMENT && string.IsNullOrWhiteSpace(cKPSItem.sFiller2)) + { + sPrtDat1 = string.Format("[ {0} ]", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0148)); + sPrtDat2 = string.Format("{0}-{1}", GetFloorName(cKPSItem.sFloorCd), GetTableName(cKPSItem.sFloorCd, cKPSItem.sTableNo)); + } + else if (string.IsNullOrWhiteSpace(cKPSItem.sOrderNo) == false) + { + sPrtDat1 = string.Format("[ {0} ]", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0097)); + sPrtDat2 = string.Format("{0}", cKPSItem.sOrderNo); + } + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + cPrint.TextPrint(sPrtDat2, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_2 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + cPrint.TextPrint(sPrtBar2, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + + #endregion + } + else + { + #region (주문번호 하단 출력) + if (cKPSItem.sPosType == PosConst.POS_TYPE.DEFERRED_PAYMENT && string.IsNullOrWhiteSpace(cKPSItem.sFiller2)) + { + orderNo1 = string.Format("{0}-{1}", GetFloorName(cKPSItem.sFloorCd), GetTableName(cKPSItem.sFloorCd, cKPSItem.sTableNo)); + orderNo2 = string.Format("[ {0} ]", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0148)); + + } + else if (string.IsNullOrWhiteSpace(cKPSItem.sOrderNo) == false) + { + orderNo1 = string.Format("{0}", cKPSItem.sOrderNo); + orderNo2 = string.Format("[ {0} ]", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0097)); + } + cPrint.TextPrint(sPrtBar2, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + #endregion + } + } + + // 상품/수량 + var sign = cKPSItem.sCancelDiv == "1" ? -1 : 1; + var type = GetAddOrderString(cKPSItem.sFiller3); + var qty = cKPSItem.nQty == 0 ? string.Empty : (sign * cKPSItem.nQty).ToString(); + sPrtDat1 = CmUtil.RPadH(cKPSItem.sItemNm, 30) + CmUtil.RPadH(type, 5) + CmUtil.LPadH(qty, 6); + cPrint.TextPrint(sPrtDat1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + + + //2017.09.07 레시피 출력 + if (cKPSItem.sRecipe.ToString().Trim().Length > 0) + { + string Recipe = cKPSItem.sRecipe.Replace("@", "\r").Replace("$", "\n").ToString(); + string[] RecipeData = Recipe.Split(new string[] { "\r\n", "\n", "\r" }, StringSplitOptions.None); + + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + foreach (var dt in RecipeData) + { + cPrint.TextPrint(dt.Trim(), PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + } + } + + + + // Add, 2017.03.21, 상품메모 + if (string.IsNullOrWhiteSpace(cKPSItem.sItemMemo) == false) + { + var lst = this.GetParserMemo(cKPSItem.sItemMemo); + foreach (var msg in lst) + { + cPrint.TextPrint(" " + msg.Trim(), PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + } + } + + // Add, 2017.04.10, 상품구분라인 + var nextIdx = nLoop + 1; + if (nextIdx < htKPSSendingItem.Count) + { + var NextItemDiv = ((KPSItem)htKPSSendingItem[nextIdx]).sItemDiv; + switch (NextItemDiv) + { + case ItemConst.PLU_ITEM_DIV.NORMAL: + case ItemConst.PLU_ITEM_DIV.SET_MAIN: + case ItemConst.PLU_ITEM_DIV.SET_DIS: + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + break; + } + } + + #region Mod, 2017.04.25, 주방메모 출력 + // Add, 2017.01.23 + // 주방프린터 수동출력(상품선택) 옵션시 주방메모 + //if (PosMstManager.GetPosOption(POS_OPTION.OPT425) == "2") + //{ + // ktchMemo = cKPSItem.sKtchMemo; + //} + #endregion + ktchMemo = cKPSItem.sKtchMemo; + } + + // Add, 2017.01.23, 수동출력옵션 시 주방메모 출력 + if (string.IsNullOrWhiteSpace(ktchMemo) == false) + { + cPrint.TextPrint(sPrtBar2, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint("Memo: ", PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + var lst = this.GetParserMemo(ktchMemo); + foreach (string msg in lst) + { + cPrint.TextPrint(" " + msg.Trim(), PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + } + } + + // Add, 2017.04.07 + if (string.IsNullOrWhiteSpace(orderNo1) == false) + { + cPrint.TextPrint(sPrtBar2, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint(orderNo1, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_3, PrinterCommand.CharactersizeH.H_3 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + cPrint.TextPrint(orderNo2, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + } + + // Cutting + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + + cPrint.TextPrint("", PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint("", PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint("", PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint("", PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint("", PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint("", PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + + cPrint.CutPaper(12); + } + + // 인쇄 완료 인덱스 설정 + nPrintOkIndex = htKPSSendingItem.Count - 1; + + // Port Close + + + cPrint.CloseDevice(); + } + catch (Exception ex) + { + cPrint.CloseDevice(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + return -99; + } + + return 0; + } + + private int KPSOrderMessageLanPrintProc(string sResendFlag, string sKpsIp, string sKpsPort, int prtCount, ref int nPrintOkIndex, ref Hashtable htKPSOrderMessage) + { + var iRet = UserCom.NG; + + var sPrtBar1 = new string('-', 42); + var sPrtBar2 = new string('=', 42); + var sPrtData = string.Empty; + + LANPrint cPrint = new LANPrint(); + + try + { + nPrintOkIndex = -1; + + iRet = cPrint.OpenDevice(sKpsIp, int.Parse(sKpsPort)); + if (iRet != UserCom.OK) + { + cPrint.CloseDevice(); + return -9; + } + + // Cover Check + iRet = cPrint.PrinterStatusCheckByLan("CHK1"); + if (iRet != UserCom.OK) + { + cPrint.CloseDevice(); + return -4; + } + + // Paper Check + iRet = cPrint.PrinterStatusCheckByLan("CHK2"); + if (iRet != UserCom.OK) + { + cPrint.CloseDevice(); + return -5; + } + + for (var cnt = 0; cnt < prtCount; cnt++) + { + var itemKey = string.Empty; + + for (int nLoop = 0; nLoop < htKPSOrderMessage.Count; nLoop++) + { + KPSOrderMessage cKPSMessage = (KPSOrderMessage)htKPSOrderMessage[nLoop]; + + if (cKPSMessage.sSendYn == "1") + { + continue; + } + + var checkKey = cKPSMessage.sTrainMode + cKPSMessage.sOrderType + cKPSMessage.sFloorCd + cKPSMessage.sTableNo + cKPSMessage.sMsgId; + if (itemKey != checkKey) + { + if (itemKey != "") + { + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.CutPaper(4); + + // 인쇄 완료 인덱스 + nPrintOkIndex = nLoop - 1; + } + + itemKey = checkKey; + + #region ### 헤더 출력 + string sPrintTitle = this.GetOrderMessageTitle(cKPSMessage.sMsgId); + switch (cKPSMessage.sMsgId) + { + case PosConst.KPS_ORD_MSG_ID.TABLE_COMBINE: + case PosConst.KPS_ORD_MSG_ID.TABLE_MOVE: + case PosConst.KPS_ORD_MSG_ID.MENU_MOVE: + sPrtData = string.Format("[{0}{1}]", sPrintTitle, (sResendFlag == "1") ? " (R)" : ""); + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + + // 연습모드 Add, 2017.03.03, + if (cKPSMessage.sTrainMode == ItemConst.TRAINING_FLAG.TRAINING_YES) + { + sPrtData = MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0033); + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + } + + cPrint.TextPrint("", PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + sPrtData = sPrintTitle + " : " + GetFloorName(cKPSMessage.sFloorCd) + "-" + GetTableName(cKPSMessage.sFloorCd, cKPSMessage.sTableNo) + " -> " + + GetFloorName(cKPSMessage.sMsg1) + "-" + GetTableName(cKPSMessage.sMsg1, cKPSMessage.sMsg2); + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint(sPrtBar2, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + break; + default: + sPrtData = string.Format("[{0}{1}]", sPrintTitle, (sResendFlag == "1") ? " (R)" : ""); + if (cKPSMessage.sMsgId == PosConst.KPS_ORD_MSG_ID.FIRE_KEY) + { + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1 + , PrinterCommand.TextBold.Nomal, PrinterCommand.TextUnderLine.Nomal, PrinterCommand.TextReverseMode.ReverseMode, true); + } + else + { + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + } + + // 연습모드 Add, 2017.03.03, + if (cKPSMessage.sTrainMode == ItemConst.TRAINING_FLAG.TRAINING_YES) + { + sPrtData = MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0033); + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1 + , PrinterCommand.TextBold.Bold, PrinterCommand.TextUnderLine.Nomal, true); + } + + cPrint.TextPrint("", PrinterCommand.Alignment.Center, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + sPrtData = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0176) + " : " + + GetFloorName(cKPSMessage.sFloorCd) + "-" + GetTableName(cKPSMessage.sFloorCd, cKPSMessage.sTableNo); + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint(sPrtBar2, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + break; + } + #endregion + + #region ### 상품정보 출력 + switch (cKPSMessage.sMsgId) + { + case PosConst.KPS_ORD_MSG_ID.ITEM_MEMO: + //case PosConst.KPS_ORD_MSG_ID.FIRE_KEY: + cPrint.TextPrint(cKPSMessage.sItemNm.Trim(), PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + break; + + case PosConst.KPS_ORD_MSG_ID.FIRE_KEY: // Add, 2017.03.22 + for (var i = nLoop; i < htKPSOrderMessage.Count; i++) + { + KPSOrderMessage cKPSOrderSubMsg = (KPSOrderMessage)htKPSOrderMessage[i]; + sPrtData = string.Format("{0}{1}", CmUtil.RPadH(cKPSOrderSubMsg.sItemNm, 37), CmUtil.LPadH(cKPSOrderSubMsg.sMsg1, 5)); + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + + // Main Index 동기화 + nLoop = i; + } + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + break; + + case PosConst.KPS_ORD_MSG_ID.MENU_MOVE: + for (var i = nLoop; i < htKPSOrderMessage.Count; i++) + { + KPSOrderMessage cKPSOrderSubMsg = (KPSOrderMessage)htKPSOrderMessage[i]; + if (cKPSOrderSubMsg.sSendYn == "1") break; ; + if (cKPSMessage.sMsgId != cKPSOrderSubMsg.sMsgId) break; + if (cKPSMessage.sFloorCd != cKPSOrderSubMsg.sFloorCd) break; + if (cKPSMessage.sTableNo != cKPSOrderSubMsg.sTableNo) break; + if (cKPSMessage.sOrderType != cKPSOrderSubMsg.sOrderType) break; + if (cKPSMessage.sKtchSysCd != cKPSOrderSubMsg.sKtchSysCd) break; + if (cKPSMessage.sMsg1.Trim() != cKPSOrderSubMsg.sMsg1.Trim()) break; + if (cKPSMessage.sMsg2.Trim() != cKPSOrderSubMsg.sMsg2.Trim()) break; + + // 메뉴이동 상품정보 출력 + sPrtData = string.Format("{0}{1}", CmUtil.RPadH(cKPSOrderSubMsg.sItemNm, 37), CmUtil.LPadH(cKPSOrderSubMsg.sMsg3, 5)); + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + + //// 전송완료설정 + //cKPSOrderSubMsg.sSendYn = "1"; + + // Main Index 동기화 + nLoop = i; + } + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + break; + } + #endregion + + #region ### 메시지 출력 + switch (cKPSMessage.sMsgId) + { + case PosConst.KPS_ORD_MSG_ID.ITEM_MEMO: + //case PosConst.KPS_ORD_MSG_ID.FIRE_KEY: // Del, 2017.03.22 + case PosConst.KPS_ORD_MSG_ID.SEAT_MEMO: + var memo = (string.IsNullOrWhiteSpace(cKPSMessage.sMsg1) ? "" : cKPSMessage.sMsg1.Trim() + Environment.NewLine) + + (string.IsNullOrWhiteSpace(cKPSMessage.sMsg2) ? "" : cKPSMessage.sMsg2.Trim() + Environment.NewLine) + + (string.IsNullOrWhiteSpace(cKPSMessage.sMsg3) ? "" : cKPSMessage.sMsg3.Trim()); + if (string.IsNullOrWhiteSpace(memo) == false) + { + var lst = GetParserMemo(memo.Trim()); + foreach (var msg in lst) + { + cPrint.TextPrint(" " + msg.Trim(), PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_2, PrinterCommand.CharactersizeH.H_1, true); + } + } + cPrint.TextPrint(sPrtBar1, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + break; + } + #endregion + + #region ### 꼬리 출력 + // 반복횟수 + var prtCnt = prtCount > 1 ? string.Format(" ({0}/{1})", cnt + 1, prtCount) : string.Empty; + // 주문시간 + sPrtData = string.Format("{0} : {1} {2} {3}", MessageManager.GetPrintMessage(POS_MESSAGE.PRINT.MSG_0085) + , m_cPosStatus.Global.DateToCulture(cKPSMessage.sRegDate) + , CmUtil.StrToTime(cKPSMessage.sMsgRegTime) + , prtCnt); + cPrint.TextPrint(sPrtData, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, true); + #endregion + + // Cutting + cPrint.CutPaper(4); + } + //// 전송완료설정 + //cKPSMessage.sSendYn = "1"; + } + } + + // 인쇄 완료 인덱스 + nPrintOkIndex = htKPSOrderMessage.Count - 1; + + // Port Close + Thread.Sleep(200); + cPrint.CloseDevice(); + } + catch (Exception ex) + { + cPrint.CloseDevice(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + return -99; + } + + return 0; + } + + private int PrinterStatusCheckByLan(TcpSocket socket, string sType) + { + int iRet = 0; + string sRet = string.Empty; + + byte[] recvData = null; + + try + { + #region Printer CHK1 + if (sType == "CHK1") + { + iRet = socket.SendReceiveFoodPrintData(PosConst.ESCP_COMMAND.TRANSMIT_OFFLINE_STATUS, ref recvData, 5000); + + if (recvData != null) + { + if (recvData[0] == PosConst.ESCP_COMMAND.STATUS_OK[0]) + { + iRet = UserCom.OK; + } + else + { + 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 (함수명)) + "COVER Opened"); + } + } + return iRet; + } + #endregion + + #region Printer CHK2 + if (sType == "CHK2") + { + iRet = socket.SendReceiveFoodPrintData(PosConst.ESCP_COMMAND.TRANSMIT_CONTINUOUS_PAPER_DETECTOR_STATUS, ref recvData, 5000); + + if (recvData != null) + { + if (recvData[0] == PosConst.ESCP_COMMAND.STATUS_OK[0]) + { + iRet = UserCom.OK; + } + else + { + string sRecvData = Encoding.Default.GetString(recvData); + + string NEAR_END = Encoding.Default.GetString(new byte[] { 0x1E }); + string NOT_PRESENT = Encoding.Default.GetString(new byte[] { 0x72 }); + + string sErrMsg = string.Empty; + if (sRecvData == NEAR_END) sErrMsg = "PAPER_NEAR_END"; + else if (sRecvData == NOT_PRESENT) sErrMsg = "PAPER_NOT_PRESENT"; + else sErrMsg = "ETC_ERROR"; + + 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 (함수명)) + sErrMsg); + } + } + + return iRet; + } + #endregion + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "StatusCheck 실패"); + } + return iRet; + } + + public bool KPSLanStatusCheck(string sKpsIp, string sKpsPort) + { + int iRet = UserCom.NG; + + // 용지 센서 상태 송신 명령어 + byte[] ESC_REQ_SUATUS_PAPER_SENSOR = { 0x1D, 0x72, 0x01 }; + byte[] reqByte = new byte[2049]; + + TcpSocket socket = null; + + try + { + socket = new TcpSocket(sKpsIp, CmUtil.IntParse(sKpsPort)); + if (socket == null) + { + return false; + } + + // 주방프린터 접속 3회 시도 + //for (int nLoop = 0; nLoop < 3; nLoop++) + for (int nLoop = 0; nLoop < 1; nLoop++) + { + try + { + iRet = socket.Connect(5000); + } + catch (Exception ex) + { + socket.Close(); + continue; + } + + // 접속 실패 + if (iRet != UserCom.OK) + { + socket.Close(); + continue; + } + + break; + } + + if (iRet != UserCom.OK) return false; + + // 성공하면 주방프린터 상태 체크함 + iRet = socket.SendReceiveFoodPrintData(ESC_REQ_SUATUS_PAPER_SENSOR, ref reqByte, 10); + return iRet == UserCom.OK ? true : false; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + return false; + } + finally + { + if (socket != null) socket.Close(); + } + } + + private string GetOrderMessageTitle(string msgId) + { + string retValue = string.Empty; + try + { + switch (msgId) + { + //case PosConst.KPS_ORD_MSG_ID.TRADE_STOP: retValue = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0232); break; + case PosConst.KPS_ORD_MSG_ID.ITEM_MEMO: retValue = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0233); break; + case PosConst.KPS_ORD_MSG_ID.SEAT_MEMO: retValue = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0234); break; + case PosConst.KPS_ORD_MSG_ID.TABLE_COMBINE: retValue = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0235); break; + case PosConst.KPS_ORD_MSG_ID.TABLE_MOVE: retValue = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0236); break; + case PosConst.KPS_ORD_MSG_ID.MENU_MOVE: retValue = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0124); break; + case PosConst.KPS_ORD_MSG_ID.FIRE_KEY: retValue = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0628); break; + } + } + catch { } + return retValue; + } + + private List GetParserMemo(string memo, string headChar = "") + { + List retValue = new List(); + try + { + const int COL_LEN = 40; + + var tmp = memo; + var lines = tmp.Trim().Split(new string[] { Environment.NewLine }, StringSplitOptions.None); + + for (var i = 0; i < lines.Length; i++) + { + var line = lines[i].Trim(); + while (string.IsNullOrWhiteSpace(line) == false) + { + var msg = CmUtil.LeftH(line, COL_LEN).Trim(); + if (string.IsNullOrWhiteSpace(msg) == false) retValue.Add(msg); + + var start = CmUtil.LenH(msg); + var length = CmUtil.LenH(line) - CmUtil.LenH(msg); + line = CmUtil.MidH(line, start, length); + } + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + return retValue; + } + + private string ConvertDBStr(string str) + { + return str.Replace("'", "''"); + } + + //#20180515 KPS 출력시 라벨프린터 출력 start + private void GetLBLPRTSendItem(ref Hashtable htKPSSendingItem) + { + string sQuery = string.Empty; + + DataTable dtData = null; + + try + { + sQuery = "WITH LBLTEMP AS \n" + + "( \n" + + "SELECT A.TRAIN_MODE_YN, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SUB_STOR_CD \n" + + " , MAX(A.ORDER_NO) AS ORDER_NO, MAX(A.ITEM_CD) AS ITEM_CD, MAX(A.SHTCUT_ITEMNM) AS SHTCUT_ITEMNM \n" + + " , MAX(A.SET_MENU_CD) AS SET_MENU_CD, MAX(A.FILLER2) AS FILLER2 \n" + + " , MAX(A.SALE_QTY) AS SALE_QTY, MAX(A.SEQ) AS SEQ, MAX(A.ITEM_DIV) AS ITEM_DIV, MAX(C.ITEM_INFO) AS ITEM_INFO \n" + + " , MAX(C.LBL_QRCODE_URL) AS LBL_QRCODE_URL, MAX(C.LBL_QRCODE_MSG) AS LBL_QRCODE_MSG \n" + + " , MAX(C.LBL_TOP_MSG) AS LBL_TOP_MSG, MAX(C.LBL_BTM_MSG) AS LBL_BTM_MSG \n" + + " FROM POSMST..MST_KPS_ORD_MSG A \n" + + " LEFT JOIN POSMST..MST_KTCH_DEVICE B WITH(NOLOCK) \n" + + " ON A.SUB_STOR_CD = B.SUB_STOR_CD \n" + + " AND A.KTCH_SYS_CD = B.KTCH_SYS_CD \n" + + " AND B.CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + + " AND B.STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + + " AND B.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" + + " LEFT JOIN POSMST..MST_KTCH_ITEM_INFO C WITH(NOLOCK) \n" + + " ON A.ITEM_CD = C.ITEM_CD \n" + + " AND C.USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n" + + " WHERE A.LBLSEND_YN IN ('0','9') \n" + + " AND A.CANCEL_DIV = '0' \n" + + " AND A.ORD_POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n" + + " GROUP BY A.TRAIN_MODE_YN, A.ORD_DIV, A.FLOOR_CD, A.TBL_NO, A.SUB_STOR_CD, A.SEQ \n" + + ") \n" + + + "SELECT E.TRAIN_MODE_YN, E.ORD_DIV, E.FLOOR_CD, E.TBL_NO, E.SUB_STOR_CD \n" + + " , E.ORDER_NO, E.ITEM_CD, E.SHTCUT_ITEMNM, E.SALE_QTY, E.SEQ \n" + + " , E.LBL_QRCODE_URL, E.LBL_QRCODE_MSG, E.LBL_TOP_MSG, E.LBL_BTM_MSG \n" + + " , E.ITEM_INFO, E.ITEM_DIV, E.FILLER2 \n" + + " , (CASE WHEN E.SET_MENU_CD = '' THEN E.ITEM_CD ELSE E.SET_MENU_CD END) AS SET_MENU_CD \n" + + " , (SELECT ISNULL(SUM(SALE_QTY),0) FROM LBLTEMP \n" + + " WHERE TRAIN_MODE_YN = E.TRAIN_MODE_YN \n" + + " AND ORD_DIV = E.ORD_DIV \n" + + " AND FLOOR_CD = E.FLOOR_CD \n" + + " AND TBL_NO = E.TBL_NO \n" + + " AND SUB_STOR_CD = E.SUB_STOR_CD \n" + + " AND ITEM_DIV = '0') AS TOTCNT \n" + + " FROM LBLTEMP E \n" + + " ORDER BY E.TRAIN_MODE_YN, E.ORD_DIV, E.FLOOR_CD, E.TBL_NO, E.SUB_STOR_CD, E.SEQ \n"; + + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) != UserCom.OK) + { + return; + } + + string itemKey = string.Empty; + + Hashtable htKPSSendingItemTemp = new Hashtable(); + + //if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtData) == UserCom.OK) + //{ + // foreach (DataRow dr in dtData.Rows) + // { + + + //DataRow[] arRows = null; + //arRows = dtData.Select(); + //arRows = dtData.Select("POS_NO = '" + m_cPosStatus.Base.PosNo + "'"); + //if (arRows.Length == 0) + // arRows = dtData.Select("POS_NO = '00'"); + + //foreach (DataRow dr in dtData.Rows) + foreach (DataRow dr in dtData.Rows) + { + KPSItem cKPSItem = new KPSItem(); + + cKPSItem.sTrainMode = CmUtil.GetDataRowStr(dr, "TRAIN_MODE_YN"); + cKPSItem.sOrderType = CmUtil.GetDataRowStr(dr, "ORD_DIV"); + cKPSItem.sFloorCd = CmUtil.GetDataRowStr(dr, "FLOOR_CD"); + cKPSItem.sTableNo = CmUtil.GetDataRowStr(dr, "TBL_NO"); + cKPSItem.sSubShopCd = CmUtil.GetDataRowStr(dr, "SUB_STOR_CD"); + + //cKPSItem.sKtchSysCd = CmUtil.GetDataRowStr(dr, "KTCH_SYS_CD"); + //cKPSItem.sKtchSysNm = CmUtil.GetDataRowStr(dr, "KTCH_SYS_NM"); + cKPSItem.nSeq = CmUtil.GetDataRowInt(dr, "SEQ"); + cKPSItem.sOrderNo = CmUtil.GetDataRowStr(dr, "ORDER_NO"); + //cKPSItem.sPosType = CmUtil.GetDataRowStr(dr, "POS_TYPE"); + + cKPSItem.sItemCd = CmUtil.GetDataRowStr(dr, "ITEM_CD"); + cKPSItem.sItemDiv = CmUtil.GetDataRowStr(dr, "ITEM_DIV"); + cKPSItem.sItemNm = CmUtil.GetDataRowStr(dr, "SHTCUT_ITEMNM"); + cKPSItem.nQty = CmUtil.GetDataRowInt(dr, "SALE_QTY"); + //cKPSItem.sPackDiv = CmUtil.GetDataRowStr(dr, "PACK_DIV"); + + cKPSItem.sSetMenuCd = CmUtil.GetDataRowStr(dr, "SET_MENU_CD"); + //cKPSItem.sOrdTime = CmUtil.GetDataRowStr(dr, "ORD_TIME"); + //cKPSItem.sCancelDiv = CmUtil.GetDataRowStr(dr, "CANCEL_DIV"); + //cKPSItem.sResendYn = CmUtil.GetDataRowStr(dr, "RESEND_YN"); + //cKPSItem.sKtchSysUseDiv = CmUtil.GetDataRowStr(dr, "KTCH_SYS_USE_DIV"); + + //cKPSItem.nKpsComPort = CmUtil.GetDataRowInt(dr, "KTCH_PRINTER_COMM_PORT"); + //cKPSItem.nKpsComBaudrate = CmUtil.GetDataRowInt(dr, "KTCH_PRINTER_COMM_SPEED"); + //cKPSItem.sKpsOposName = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_OPOS_NM"); + //cKPSItem.sKpsIp = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_IP"); + //cKPSItem.sKpsPort = CmUtil.GetDataRowStr(dr, "KTCH_PRINTER_PORT"); + + //cKPSItem.sErrorCd = CmUtil.GetDataRowStr(dr, "ERROR_CD"); + //cKPSItem.sFiller1 = CmUtil.GetDataRowStr(dr, "FILLER1"); + //cKPSItem.sFiller2 = CmUtil.GetDataRowStr(dr, "FILLER2"); + //cKPSItem.sFiller3 = CmUtil.GetDataRowStr(dr, "FILLER3"); + //cKPSItem.sFiller4 = CmUtil.GetDataRowStr(dr, "FILLER4"); + + //cKPSItem.sFiller5 = CmUtil.GetDataRowStr(dr, "FILLER5"); + //cKPSItem.sItemMemo = CmUtil.GetDataRowStr(dr, "MSG"); + //cKPSItem.sKtchMemo = CmUtil.GetDataRowStr(dr, "KTCH_MSG"); + //cKPSItem.sOrdPicNm = CmUtil.GetDataRowStr(dr, "ORD_PIC_NM"); + //cKPSItem.sOrdPosNo = CmUtil.GetDataRowStr(dr, "ORD_POS_NO"); + + cKPSItem.sRecipe = CmUtil.GetDataRowStr(dr, "ITEM_INFO"); + //cKPSItem.sSendYn = "0"; + cKPSItem.sLblSendYn = CmUtil.GetDataRowStr(dr, "LBLSEND_YN"); //라벨프린터 출력여부(0:미전송, 1:전송) + cKPSItem.iTOTCNT = CmUtil.GetDataRowInt(dr, "TOTCNT"); //라벨프린터 총출력 해야 할 건수 + + cKPSItem.sQrcodeUrl = CmUtil.GetDataRowStr(dr, "LBL_QRCODE_URL"); //라벨프린터 QRCODE URL + cKPSItem.sQrcodeMsg = CmUtil.GetDataRowStr(dr, "LBL_QRCODE_MSG"); //라벨프린터 QRCODE MSG + cKPSItem.sTopMsg = CmUtil.GetDataRowStr(dr, "LBL_TOP_MSG"); //라벨프린터 TOP MSG + cKPSItem.sBtmMsg = CmUtil.GetDataRowStr(dr, "LBL_BTM_MSG"); //라벨프린터 BTM MSG + + string checkKey = cKPSItem.sTrainMode + cKPSItem.sOrderType + cKPSItem.sFloorCd + cKPSItem.sTableNo + cKPSItem.sSubShopCd + cKPSItem.sSetMenuCd; + if (itemKey != checkKey) + { + if (htKPSSendingItemTemp.Count != 0) + { + htKPSSendingItem.Add(htKPSSendingItem.Count, htKPSSendingItemTemp); + } + itemKey = checkKey; + + htKPSSendingItemTemp = new Hashtable(); + } + + htKPSSendingItemTemp.Add(htKPSSendingItemTemp.Count, cKPSItem); + } + + if (htKPSSendingItemTemp.Count != 0) + { + htKPSSendingItem.Add(htKPSSendingItem.Count, htKPSSendingItemTemp); + } + } + 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); + } + } + //#20180515 KPS 출력시 라벨프린터 출력 end + + //#20180515 KPS 출력시 라벨프린터 출력 start + /// + /// KPS Status Update + /// + /// + /// + private void LBLPRTPrintStatusUpdate(Hashtable htKPSSendingItem, Hashtable htKtchDeviceStatus) + { + try + { + // Label Print 인쇄 데이터 전송상태 갱신 + for (int nLoop = 0; nLoop < htKPSSendingItem.Count; nLoop++) + { + Hashtable htKPSSendingItemTemp = (Hashtable)htKPSSendingItem[nLoop]; + + for (int nLoop2 = 0; nLoop2 < htKPSSendingItemTemp.Count; nLoop2++) + { + KPSItem cKPSItem = (KPSItem)htKPSSendingItemTemp[nLoop2]; + + string sQuery = "UPDATE POSMST..MST_KPS_ORD_MSG \n" + + " SET LBLSEND_YN = '" + cKPSItem.sLblSendYn + "' \n" + + " , RESEND_YN = '" + cKPSItem.sResendYn + "' \n" + + " , ERROR_CD = '" + cKPSItem.sErrorCd + "' \n" + + " WHERE TRAIN_MODE_YN = '" + cKPSItem.sTrainMode + "' \n" // Add, 2017.03.03, 연습모드 + + " AND ORD_DIV = '" + cKPSItem.sOrderType + "' \n" + + " AND FLOOR_CD = '" + cKPSItem.sFloorCd + "' \n" + + " AND TBL_NO = '" + cKPSItem.sTableNo + "' \n" + + " AND SUB_STOR_CD = '" + cKPSItem.sSubShopCd + "' \n" // Add, 2017.02.07 + //+ " AND KTCH_SYS_CD = '" + cKPSItem.sKtchSysCd + "' \n" + + " AND SEQ = " + cKPSItem.nSeq.ToString() + "\n" + ; + if (sqlDb.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null, true) != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_LEVEL, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "Query=" + sQuery); + } + } + } + + /* + for (int nLoop = 0; nLoop < htKtchDeviceStatus.Count; nLoop++) + { + KTCH_SYS_STATUS cKtchSysStatus = (KTCH_SYS_STATUS)htKtchDeviceStatus[nLoop]; + + string sErrorCd = "0000"; + if (cKtchSysStatus.nErrorCd != 0) + { + switch (cKtchSysStatus.nErrorCd) + { + case -1: sErrorCd = "0001"; break; // Print Open Error + case -2: sErrorCd = "0002"; break; // Print Claim Error + case -3: sErrorCd = "0003"; break; // Print Power Off Error + case -4: sErrorCd = "0004"; break; // Cover Open Error + case -5: sErrorCd = "0005"; break; // No Paper Error + default: sErrorCd = "9999"; break; // Etc Error + } + } + string sQuery = "UPDATE POSMST..MST_KTCH_DEVICE \n" + + " SET FILLER1 = '" + sErrorCd + "' \n" + + " WHERE KTCH_SYS_CD = '" + cKtchSysStatus.sKtchSysCd + "' \n" + + " AND SUB_STOR_CD = '" + cKtchSysStatus.sSubShopCd + "' \n" // Add, 2017.02.07 + ; + if (sqlDb.DBExecuteNonQuery(new string[] { sQuery }, CommandType.Text, (SqlParameter[])null, true) != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_LEVEL, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "Query=" + sQuery); + } + } + */ + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + } + //#20180515 KPS 출력시 라벨프린터 출력 end + + //#20180515 KPS 출력시 라벨프린터 출력 start + /// + /// 라벨프린터 출력 + /// + /// + private void LBLPRTPrintProc(ref Hashtable htKPSSendingItem) + { + try + { + bool nReturn = false; + int LblPrtCnt = 0; + + for (int nLoop = 0; nLoop < htKPSSendingItem.Count; nLoop++) + { + Hashtable htKPSSendingItemTemp = (Hashtable)htKPSSendingItem[nLoop]; + + if (htKPSSendingItemTemp.Count == 0) + { + continue; + } + + // 수량 만큼 출력 하기 위해 + KPSItem cKPSTemp = (KPSItem)htKPSSendingItemTemp[0]; + + for (int i = 1; i <= cKPSTemp.nQty; i++) + { + LblPrtCnt = LblPrtCnt + 1; + + nReturn = LBLPRTSerialPrintProc(htKPSSendingItemTemp, LblPrtCnt); + + if (nReturn == true) + { + cKPSTemp.sLblSendYn = "1"; + htKPSSendingItemTemp[0] = cKPSTemp; + } + else + { + cKPSTemp.sLblSendYn = "9"; + htKPSSendingItemTemp[0] = cKPSTemp; + } + + htKPSSendingItem[nLoop] = htKPSSendingItemTemp; + } + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + } + //#20180515 KPS 출력시 라벨프린터 출력 end + + //#20180515 KPS 출력시 라벨프린터 출력 start + #region 라벨프린터 출력 함수 + public bool LBLPRTSerialPrintProc(Hashtable htKPSSendingItem, int LblPrtCnt) + { + bool bRet = false; + string sPrtData = ""; + string sEnter = "\r\n"; + + string sOrdGB = ""; + string sCntOfTotCnt = ""; + string sWaitNo = ""; + string sItemNm = ""; + string[] sItemNmA = new string[2]; + string[] sSubItemNmA = new string[3]; + string sQRcode = ""; + string sQRcodeMsg = ""; + string sTopMsgTemp = ""; + string[] sTopMsg = new string[2]; + string[] sTopMsgA = new string[2]; + string sBtmMsg = ""; + string sOptionTemp = ""; + string[] sOption = new string[8]; + string[] sOptionA = new string[8]; + string sPrtTime = ""; + int iSubCnt = 0; + + try + { + // 라벨프린터 Open + bRet = m_cLabelPrtDevice.OpenLabelPrinter(m_cPosStatus.Base.OlePosLabelPrinterSerialPortNumber, m_cPosStatus.Base.OlePosLabelPrinterSerialBaudRate); + + if (bRet == false) + { + return bRet; + } + + // 주문상품 인쇄 + for (int nLoop = 0; nLoop < htKPSSendingItem.Count; nLoop++) + { + KPSItem cKPSItem = (KPSItem)htKPSSendingItem[nLoop]; + + //메인 상품 + if (cKPSItem.sItemDiv == "0") + { + sOrdGB = (cKPSItem.sFiller2 == "2") ? "> H <" : "> P <"; + sCntOfTotCnt = LblPrtCnt.ToString() + " of " + cKPSItem.iTOTCNT.ToString(); + sWaitNo = cKPSItem.sOrderNo; + + // 상품명 + sItemNm = cKPSItem.sItemNm; + if (sItemNm.Length > 12) + { + sItemNmA[0] = sItemNm.Substring(0, 12); + sItemNmA[1] = sItemNm.Substring(12, sItemNm.Length - sItemNmA[0].Length); + } + else + { + sItemNmA[0] = sItemNm.Substring(0, sItemNm.Length); + sItemNmA[1] = ""; + } + + // qr코드 + sQRcode = cKPSItem.sQrcodeUrl; + + // qr코드 하단 메세지 + /* + if (cKPSItem.sQrcodeMsg.Length > 12) + { + sQRcodeMsg = cKPSItem.sQrcodeMsg.Substring(0, 12); + } + */ + sQRcodeMsg = cKPSItem.sQrcodeMsg; + + // 주방상품정보 + //sOptionTemp = cKPSItem.sRecipe.Replace("@$", "|"); + //sOption = sOptionTemp.Split('|'); + + sOptionTemp = cKPSItem.sRecipe.Replace("@", "\r").Replace("$", "\n").ToString(); + sOption = sOptionTemp.Split(new string[] { "\r\n", "\n", "\r" }, StringSplitOptions.None); + + // 상단메세지 + //sTopMsgTemp = cKPSItem.sTopMsg.Replace("@$", "|"); + //sTopMsg = sTopMsgTemp.Split('|'); + + sTopMsgTemp = cKPSItem.sTopMsg.Replace("@", "\r").Replace("$", "\n").ToString(); + sTopMsg = sTopMsgTemp.Split(new string[] { "\r\n", "\n", "\r" }, StringSplitOptions.None); + + //하단 메세지 + /* + if (cKPSItem.sBtmMsg.Length > 12) + { + sBtmMsg = cKPSItem.sBtmMsg.Substring(0, 12); + } + */ + sBtmMsg = cKPSItem.sBtmMsg; + + // 출력시간 + sPrtTime = DateTime.Now.ToString("HH:mm:ss tt"); + } + + //부가 상품 + if (cKPSItem.sItemDiv == "3") + { + /* + if (cKPSItem.sItemNm.Length > 11) + { + sSubItemNmA[iSubCnt] = cKPSItem.sItemNm.Substring(0, 11); + } + */ + sSubItemNmA[iSubCnt] = cKPSItem.sItemNm; + iSubCnt = iSubCnt + 1; + } + } + + for (int i = sItemNmA.Length; i < 2; i++) + { + sItemNmA[i] = ""; + } + + for (int i = sSubItemNmA.Length; i < 3; i++) + { + sSubItemNmA[i] = ""; + } + + for (int i = 0; i < 2; i++) + { + sTopMsgA[i] = ""; + } + + for (int i = 0; i < sTopMsg.Length; i++) + { + sTopMsgA[i] = sTopMsg[i]; + } + + for (int i = 0; i < 8; i++) + { + sOptionA[i] = ""; + } + + for (int i = 0; i < sOption.Length; i++) + { + sOptionA[i] = sOption[i]; + } + + sPrtData = "CLL"; + sPrtData += sEnter + "NEW"; + sPrtData += sEnter + "SETUP \"MEDIA,MEDIA SIZE,WIDTH,300\""; + sPrtData += sEnter + "SETUP \"MEDIA,MEDIA SIZE,LENGTH,1200\""; + sPrtData += sEnter + "SETUP \"MEDIA,MEDIA SIZE,XSTART,0\""; + + sPrtData += sEnter + "CLIP ON"; + sPrtData += sEnter + "NASC 949"; + + sPrtData += sEnter + "FONT \"HYGothic-Medium\",9"; + sPrtData += sEnter + "PP 5, 360:PT \"" + sWaitNo + "\""; + + sPrtData += sEnter + "PP 225, 360:PT \"" + sCntOfTotCnt + "\""; + + sPrtData += sEnter + "PP 5, 350:DIR 1:PL 300,1"; + + sPrtData += sEnter + "PP 0, 315:PT \"" + sItemNmA[0] + "\""; + sPrtData += sEnter + "PP 0, 285:PT \"" + sItemNmA[1] + "\""; + + sPrtData += sEnter + "PP 5, 275:DIR 1:PL 300,1"; + + sPrtData += sEnter + "FONT \"HYGothic-Medium\",8"; + sPrtData += sEnter + "PP 5, 240:PT \"" + sSubItemNmA[0] + "\""; + sPrtData += sEnter + "PP 5, 210:PT \"" + sSubItemNmA[1] + "\""; + sPrtData += sEnter + "PP 5, 180:PT \"" + sSubItemNmA[2] + "\""; + + if (sQRcode != "") + { + sPrtData += sEnter + "BF OFF"; + sPrtData += sEnter + "PP 5,70"; + sPrtData += sEnter + "BARSET \"QRCODE\",1,1,4,2,2"; + sPrtData += sEnter + "PB \"" + sQRcode + "\""; + + sPrtData += sEnter + "FONT \"HYGothic-Medium\",7"; + sPrtData += sEnter + "PP 5, 40:PT \"" + sQRcodeMsg + "\""; + } + else + { + sPrtData += sEnter + "FONT \"HYGothic-Medium\",10"; + sPrtData += sEnter + "PP 5,100:PT \"" + sTopMsgA[0] + "\""; + sPrtData += sEnter + "PP 5, 70:PT \"" + sTopMsgA[1] + "\""; + + sPrtData += sEnter + "FONT \"HYGothic-Medium\",7"; + sPrtData += sEnter + "PP 5, 40:PT \"" + sBtmMsg + "\""; + } + + sPrtData += sEnter + "PP 5, 40:DIR 1:PL 300,1"; + + sPrtData += sEnter + "FONT \"HYGothic-Medium\",9"; + sPrtData += sEnter + "PP 5,5:PT \"" + sPrtTime + "\""; + + sPrtData += sEnter + "PP 240,5:PT \"" + sOrdGB + "\""; + + sPrtData += sEnter + "PP 260,240:PT \"" + sOptionA[0] + "\""; + sPrtData += sEnter + "PP 260,212:PT \"" + sOptionA[1] + "\""; + sPrtData += sEnter + "PP 260,184:PT \"" + sOptionA[2] + "\""; + sPrtData += sEnter + "PP 260,156:PT \"" + sOptionA[3] + "\""; + sPrtData += sEnter + "PP 260,128:PT \"" + sOptionA[4] + "\""; + sPrtData += sEnter + "PP 260,100:PT \"" + sOptionA[5] + "\""; + sPrtData += sEnter + "PP 260,72:PT \"" + sOptionA[6] + "\""; + sPrtData += sEnter + "PP 260,44:PT \"" + sOptionA[7] + "\""; + + sPrtData += sEnter + "PF"; + sPrtData += sEnter; + + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ LabelPrt: [" + sPrtData + "]"); + + m_cLabelPrtDevice.PrintLabelInfo(sPrtData); + + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [CLOSE]"); + + // 라벨프린터 Close + bRet = m_cLabelPrtDevice.CloseLabelPrinter(); + + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 bRet; + } + #endregion + //#20180515 KPS 출력시 라벨프린터 출력 end + + } +} diff --git a/Agent/KPS/LANPrint.cs b/Agent/KPS/LANPrint.cs new file mode 100644 index 0000000..259395d --- /dev/null +++ b/Agent/KPS/LANPrint.cs @@ -0,0 +1,548 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Cosmos.Common; +using Cosmos.UserFrame; +using Cosmos.BaseFrame; + +namespace Cosmos.KPS +{ + class LANPrint + { + PrinterCommand prtCmd = new PrinterCommand(); + + private TcpSocket m_cKtchSocket = null; + + #region Printer OPEN / CLOSE + public int OpenDevice(string sIp, int iPort) + { + int iRet = UserCom.NG; + try + { + // PING 테스트로 프린터 가능여부 확인(2017.05.30) + if (CmUtil.PingTest(sIp) == false) + { + if (CmUtil.PingTest(sIp) == false) return iRet; + } + + m_cKtchSocket = new TcpSocket(sIp, iPort, 5000); + + if(m_cKtchSocket == null) + { + return -9; + } + + // 주방프린터 접속 3회 시도 + for(int nLoop = 0;nLoop < 1;nLoop++) + { + try + { + iRet = m_cKtchSocket.Connect(-1); + } + catch (Exception ex) + { + iRet = UserCom.NG; + UserLog.WriteLogFile(UserCom.LOG_IOS, 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 (함수명)) + "KPS Exception Error=" + ex.Message); + m_cKtchSocket.Close(); + continue; + } + // 접속 실패 + if (iRet != UserCom.OK) + { + iRet = UserCom.NG; + UserLog.WriteLogFile(UserCom.LOG_IOS, 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 (함수명)) + "KPS(Ethernet) Connect Error"); + m_cKtchSocket.Close(); + continue; + } + /* + // Cover Check + iRet = PrinterStatusCheckByLan("CHK1"); + if (iRet != UserCom.OK) + { + iRet = UserCom.NG; + 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 (함수명)) + "KPS(Ethernet) Cover Check Error"); + m_cKtchSocket.Close(); + continue; + } + + // Paper Check + iRet = PrinterStatusCheckByLan("CHK2"); + if (iRet != UserCom.OK) + { + iRet = UserCom.NG; + 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 (함수명)) + "KPS(Ethernet) Paper Check Error"); + m_cKtchSocket.Close(); + continue; + } + */ + break; + } + + return iRet; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)) + ex.Message); + return -99; + } + } + + public void CloseDevice() + { + try + { + if(m_cKtchSocket != null) + { + m_cKtchSocket.Close(); + m_cKtchSocket = null; + } + } + catch(Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 Status Check + public int PrinterStatusCheckByLan(string sType) + { + int iRet = 0; + string sRet = string.Empty; + + byte[] recvData = null; + + try + { + #region Printer CHK1 + if (sType == "CHK1") + { + iRet = m_cKtchSocket.SendReceiveFoodPrintData(PosConst.ESCP_COMMAND.TRANSMIT_OFFLINE_STATUS, ref recvData, 5000); + + if (recvData != null) + { + if (recvData[0] == PosConst.ESCP_COMMAND.STATUS_OK[0]) + { + iRet = UserCom.OK; + } + else + { + iRet = UserCom.NG; + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "COVER Opened"); + } + } + return iRet; + } + #endregion + + #region Printer CHK2 + if (sType == "CHK2") + { + iRet = m_cKtchSocket.SendReceiveFoodPrintData(PosConst.ESCP_COMMAND.TRANSMIT_CONTINUOUS_PAPER_DETECTOR_STATUS, ref recvData, 5000); + + if (recvData != null) + { + if (recvData[0] == PosConst.ESCP_COMMAND.STATUS_OK[0]) + { + iRet = UserCom.OK; + } + else + { + iRet = UserCom.NG; + string sRecvData = Encoding.Default.GetString(recvData); + + string NEAR_END = Encoding.Default.GetString(new byte[] { 0x1E }); + string NOT_PRESENT = Encoding.Default.GetString(new byte[] { 0x72 }); + + string sErrMsg = string.Empty; + if (sRecvData == NEAR_END) + { + iRet = UserCom.OK; + sErrMsg = "PAPER_NEAR_END"; + } + else if (sRecvData == NOT_PRESENT) sErrMsg = "PAPER_NOT_PRESENT"; + else sErrMsg = "ETC_ERROR"; + + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + sErrMsg); + } + } + + return iRet; + } + #endregion + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "StatusCheck Failed"); + } + return iRet; + } + #endregion + + #region Cut Paper + public bool CutPaper(int LineFeedCnt) + { + long nRet = -1; + try + { + for(int i = 0;i < LineFeedCnt;i++) + { + nRet = m_cKtchSocket.SendFoodPrintData(Encoding.Default.GetBytes("\r\n")); + } + + if(m_cKtchSocket.SendFoodPrintData(PosConst.ESCP_COMMAND.PAPER_CUT) == BaseCom.OK) + { + nRet = m_cKtchSocket.SendFoodPrintData(Encoding.Default.GetBytes("\r\n")); + } + + // BEEP 커맨더 전송(2017.05.30) + byte[] bytBEEP = new byte[] { 0x1B, 0x70, 0x01, 0x20, 0x80 }; + m_cKtchSocket.SendFoodPrintData(bytBEEP); + } + catch(Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Cut Paper Exception"); + } + return nRet == BaseCom.OK ? true : false; + } + #endregion + + #region 문자열 출력 + /// + /// Print Text + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public bool TextPrint(string sValue, PrinterCommand.Alignment eAlignment, PrinterCommand.CharactersizeV eVerticalSize, PrinterCommand.CharactersizeH eHorizontalSize, PrinterCommand.TextBold eBold, PrinterCommand.TextUnderLine eTextUnderLine, PrinterCommand.TextReverseMode eTextReverseMode, bool bLineFeed) + { + bool bRet = false; + string sCmdctrlTmp = ""; + + try + { + // 확대 Command를 설정 + sCmdctrlTmp = GetCharactersizeCmd(eVerticalSize, eHorizontalSize); + + // UnerLine + sCmdctrlTmp += GetUnderLineCmd(eTextUnderLine); + + // Bold + sCmdctrlTmp += GetBoldCmd(eBold); + + // 정렬 + sCmdctrlTmp += GetAlignment(eAlignment); + + // Reverse + sCmdctrlTmp += GetReverseCmd(eTextReverseMode); + + // 출력 + byte[] byteCmdctrl = Encoding.Default.GetBytes(sCmdctrlTmp); + if (m_cKtchSocket.SendFoodPrintData(byteCmdctrl) != BaseCom.OK) bRet = false; // Command 전송 + + byte[] byteData = Encoding.Default.GetBytes(sValue); + if (m_cKtchSocket.SendFoodPrintData(byteData) != BaseCom.OK) bRet = false; // 출력 Data 전송 + + if (bLineFeed == true && m_cKtchSocket.SendFoodPrintData(Encoding.Default.GetBytes("\n")) != BaseCom.OK) bRet = false; + } + catch(Exception ex) + { + + } + + return bRet; + } + /// + /// Print Text + /// + /// + /// + /// + /// + /// + /// + /// + /// + public bool TextPrint(string sValue, PrinterCommand.Alignment eAlignment, PrinterCommand.CharactersizeV eVerticalSize, PrinterCommand.CharactersizeH eHorizontalSize, PrinterCommand.TextBold eBold, PrinterCommand.TextUnderLine eTextUnderLine, bool bLineFeed) + { + return TextPrint(sValue, eAlignment, eVerticalSize, eHorizontalSize, eBold, eTextUnderLine, PrinterCommand.TextReverseMode.Nomal, bLineFeed); + } + /// + /// Print Text + /// + /// + /// + /// + public bool TextPrint(string sValue, bool bLineFeed) + { + return TextPrint(sValue, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, PrinterCommand.TextBold.Nomal, PrinterCommand.TextUnderLine.Nomal, PrinterCommand.TextReverseMode.Nomal, bLineFeed); + } + /// + /// Print Text + /// + /// + /// + /// + /// + public bool TextPrint(string sValue, PrinterCommand.Alignment eAlignment, bool bLineFeed) + { + return TextPrint(sValue, eAlignment, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, PrinterCommand.TextBold.Nomal, PrinterCommand.TextUnderLine.Nomal, PrinterCommand.TextReverseMode.Nomal, bLineFeed); + } + /// + /// Print Text + /// + /// + /// + /// + /// + /// + /// + public bool TextPrint(string sValue, PrinterCommand.Alignment eAlignment, PrinterCommand.CharactersizeV eVerticalSize, PrinterCommand.CharactersizeH eHorizontalSize, bool bLineFeed) + { + return TextPrint(sValue, eAlignment, eVerticalSize, eHorizontalSize, PrinterCommand.TextBold.Nomal, PrinterCommand.TextUnderLine.Nomal, PrinterCommand.TextReverseMode.Nomal, bLineFeed); + } + /// + /// Print Text + /// + /// + /// + /// + /// + /// + public bool TextPrint(string sValue, PrinterCommand.Alignment eAlignment, PrinterCommand.TextBold eBold, bool bLineFeed) + { + return TextPrint(sValue, eAlignment, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, eBold, PrinterCommand.TextUnderLine.Nomal, PrinterCommand.TextReverseMode.Nomal, bLineFeed); + } + /// + /// Print Text + /// + /// + /// + /// + /// + /// + public bool TextPrint(string sValue, PrinterCommand.Alignment eAlignment, PrinterCommand.TextUnderLine eTextUnderLine, bool bLineFeed) + { + return TextPrint(sValue, eAlignment, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, PrinterCommand.TextBold.Nomal, eTextUnderLine, PrinterCommand.TextReverseMode.Nomal, bLineFeed); + } + /// + /// Print Text + /// + /// + /// + /// + /// + /// + public bool TextPrint(string sValue, PrinterCommand.Alignment eAlignment, PrinterCommand.TextReverseMode eTextReverseMode, bool bLineFeed) + { + return TextPrint(sValue, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, PrinterCommand.TextBold.Nomal, PrinterCommand.TextUnderLine.Nomal, eTextReverseMode, bLineFeed); + } + + private string GetCharactersizeCmd(PrinterCommand.CharactersizeV eVerticalSize, PrinterCommand.CharactersizeH eHorizontalSize) + { + string sRet = ""; + + try + { + int Hvalue = 0; + int Vvalue = 0; + + switch(eVerticalSize) + { + case PrinterCommand.CharactersizeV.V_1: Vvalue = 0; break; + case PrinterCommand.CharactersizeV.V_2: Vvalue = 1; break; + case PrinterCommand.CharactersizeV.V_3: Vvalue = 2; break; + case PrinterCommand.CharactersizeV.V_4: Vvalue = 3; break; + case PrinterCommand.CharactersizeV.V_5: Vvalue = 4; break; + case PrinterCommand.CharactersizeV.V_6: Vvalue = 5; break; + case PrinterCommand.CharactersizeV.V_7: Vvalue = 6; break; + case PrinterCommand.CharactersizeV.V_8: Vvalue = 7; break; + default: Vvalue = 0; break; + } + + switch(eHorizontalSize) + { + case PrinterCommand.CharactersizeH.H_1: Hvalue = 16 * 0; break; + case PrinterCommand.CharactersizeH.H_2: Hvalue = 16 * 1; break; + case PrinterCommand.CharactersizeH.H_3: Hvalue = 16 * 2; break; + case PrinterCommand.CharactersizeH.H_4: Hvalue = 16 * 3; break; + case PrinterCommand.CharactersizeH.H_5: Hvalue = 16 * 4; break; + case PrinterCommand.CharactersizeH.H_6: Hvalue = 16 * 5; break; + case PrinterCommand.CharactersizeH.H_7: Hvalue = 16 * 6; break; + case PrinterCommand.CharactersizeH.H_8: Hvalue = 16 * 7; break; + default: Hvalue = 16 * 0; break; + } + sRet = Encoding.Default.GetString(prtCmd.ESC_VHMAG) + Convert.ToChar(Vvalue + Hvalue).ToString(); + } + catch (Exception ex) + { + + } + + return sRet; + } + /// + /// 진한 문자(Bold) + /// + /// + /// + private string GetBoldCmd(PrinterCommand.TextBold eBold) + { + string sRet = ""; + try + { + switch(eBold) + { + case PrinterCommand.TextBold.Nomal: sRet = Encoding.Default.GetString(prtCmd.ESC_BOLD_OFF); break; + case PrinterCommand.TextBold.Bold: sRet = Encoding.Default.GetString(prtCmd.ESC_BOLD_ON); break; + default: sRet = Encoding.Default.GetString(prtCmd.ESC_BOLD_OFF); break; + } + } + catch (Exception ex) + { + + } + + return sRet; + } + /// + /// UnderLine + /// + /// + /// + /// + private string GetUnderLineCmd(PrinterCommand.TextUnderLine eUnderLine, int nDot) + { + string sRet = ""; + try + { + if(eUnderLine == PrinterCommand.TextUnderLine.UnderLine) + { + if(nDot == 2) + { + sRet = Encoding.Default.GetString(prtCmd.ESC_UNDERLINEON1DOT); + } + else + { + sRet = Encoding.Default.GetString(prtCmd.ESC_UNDERLINEON2DOT); + } + } + else + { + sRet = Encoding.Default.GetString(prtCmd.ESC_UNDERLINEOFF); + } + } + catch(Exception ex) + { + + } + + return sRet; + } + /// + /// UnderLine Text + /// + /// + /// + private string GetUnderLineCmd(PrinterCommand.TextUnderLine eUnderLine) + { + return GetUnderLineCmd(eUnderLine, 1); + } + /// + /// 반전 텍스트 + /// + /// + /// + private string GetReverseCmd(PrinterCommand.TextReverseMode eTextReverseMode) + { + string sRet = ""; + try + { + switch(eTextReverseMode) + { + case PrinterCommand.TextReverseMode.ReverseMode: sRet = Encoding.Default.GetString(prtCmd.ESC_REVERSE_MODE_ON); break; + default: sRet = Encoding.Default.GetString(prtCmd.ESC_REVERSE_MODE_OFF); break; + } + } + catch(Exception ex) + { + + } + + return sRet; + } + /// + /// 정렬 Command를 가져온다. + /// + /// + /// + private string GetAlignment(PrinterCommand.Alignment eAlignment) + { + string sRet = ""; + try + { + switch(eAlignment) + { + case PrinterCommand.Alignment.Center: + sRet = Encoding.Default.GetString(prtCmd.ESC_CENTER); + break; + case PrinterCommand.Alignment.Right: + sRet = Encoding.Default.GetString(prtCmd.ESC_RIGHT); + break; + case PrinterCommand.Alignment.Left: + default: + sRet = Encoding.Default.GetString(prtCmd.ESC_LEFT); + break; + } + } + catch (Exception ex) + { + + } + + return sRet; + } + #endregion + } +} diff --git a/Agent/KPS/LabelPrinter.cs b/Agent/KPS/LabelPrinter.cs new file mode 100644 index 0000000..0439891 --- /dev/null +++ b/Agent/KPS/LabelPrinter.cs @@ -0,0 +1,385 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO.Ports; +using System.ComponentModel; + +using Cosmos.CommonManager; +using Cosmos.UserFrame; + +namespace Cosmos.KPS +{ + public class LabelPrinter + { + #region 클래스 변수 선언 + private static SerialPort m_cSerialPort = null; + #endregion 클래스 변수 선언 + + #region 생성자 + public LabelPrinter() + { + + } + #endregion 생성자 + + #region OPEN / CLOSE 처리 함수 + public bool OpenLabelPrinter(string sSerialPort, long lBaudrate) + { + bool bRet = false; + + try + { + #region log + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [OPEN]"); + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + #endregion + if (m_cSerialPort != null) + { + //grayber@20180307 시리얼 포트 flush 추가 start - Open 함수 Input Output 버퍼 삭제 (주석처리) + // 추가 + if (m_cSerialPort.IsOpen != true) // 시리얼포트 오픈 실패 + { + m_cSerialPort.Open(); // 시리얼포트 오픈 + } + //m_cSerialPort.DiscardOutBuffer(); + //m_cSerialPort.DiscardInBuffer(); + //UserLog.WriteLogFile(UserCom.LOG_OP, + // 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 (함수명)) + // "▶▶ [Open InOut Buffer Clear]"); + + bRet = true; + //grayber@20180307 시리얼 포트 flush 추가 end + return bRet; + } + + if(m_cSerialPort == null) + { + m_cSerialPort = new SerialPort(); + if(m_cSerialPort == null) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + "SERIAL PORT ERROR"); + return bRet; + } + + m_cSerialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived); + m_cSerialPort.PinChanged += new SerialPinChangedEventHandler(serialPort_PinChanged); + m_cSerialPort.ErrorReceived += new SerialErrorReceivedEventHandler(serialPort_ErrorReceived); + + m_cSerialPort.NewLine = "\r\n"; + m_cSerialPort.Encoding = System.Text.Encoding.GetEncoding("ks_c_5601-1987"); + + m_cSerialPort.WriteBufferSize = 1024 * 1024; + m_cSerialPort.PortName = sSerialPort; + m_cSerialPort.BaudRate = (int)lBaudrate; + m_cSerialPort.DataBits = 8; + m_cSerialPort.StopBits = StopBits.One; + m_cSerialPort.Parity = Parity.None; + m_cSerialPort.Handshake = Handshake.None; + m_cSerialPort.ReadTimeout = 500; + m_cSerialPort.WriteTimeout = 2000; + + m_cSerialPort.Open(); + if(m_cSerialPort.IsOpen == false) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + "SERIAL PORT OPEN ERROR"); + + return bRet; + } + + bRet = true; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + + #region log + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [OPEN]" + bRet); + + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + #endregion + return bRet; + } + + public bool CloseLabelPrinter() + { + bool bRet = false; + try + { + if (m_cSerialPort == null) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Close fail(m_cSerialPort == null)"); + return bRet; + } + + //grayber@20180307 시리얼 포트 flush 추가 start - Close 함수 Input Output 버퍼 삭제 + // 추가 + m_cSerialPort.DiscardOutBuffer(); + m_cSerialPort.DiscardInBuffer(); + //grayber@20180307 시리얼 포트 flush 추가 end + + m_cSerialPort.Close(); + bRet = true; + //grayber@20180307 시리얼 포트 flush 추가 start - try 문 밖으로 이동 (기존) + //m_cSerialPort = null; + //grayber@20180307 시리얼 포트 flush 추가 end + + + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + + #region log + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [CLOSE] Close InOut Buffer Clear :" + bRet); + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + #endregion + //grayber@20180307 시리얼 포트 flush 추가 start - try 문 밖으로 이동 (변경) + m_cSerialPort = null; + //grayber@20180307 시리얼 포트 flush 추가 end + + return bRet; + } + #endregion OPEN / CLOSE 처리 함수 + + #region SerialPort 이벤트 + private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) + { + SerialPort serialPort = (SerialPort)sender; + + try + { + byte[] bytRecvBuf = new byte[serialPort.BytesToRead]; + + //grayber@20180307 시리얼 포트 flush 추가 start - DataReceived 시리얼 포트 null check + // 기존 + //serialPort.Read(bytRecvBuf, 0, bytRecvBuf.Length); + // 변경 + if (serialPort != null && serialPort.IsOpen == true) // 시리얼포트 객체 및 오픈 확인 + { + serialPort.Read(bytRecvBuf, 0, bytRecvBuf.Length); + + #region log + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [RECV] " + Encoding.UTF8.GetString(bytRecvBuf)); + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + #endregion + } + //grayber@20180307 시리얼 포트 flush 추가 end + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + } + + private void serialPort_PinChanged(object sender, SerialPinChangedEventArgs e) + { + + } + + private void serialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e) + { + + } + #endregion SerialPort 이벤트 + + #region 출력 함수 + /// + /// 중량 출력 + /// + /// 상품명 : 중량g + /// 중량 + /// YYYY-MM-DD HH:MM:SS + /// 점포명 + public void PrintLabelInfoPrintWeightInfo(string sContent, string sDateTime, string sStoreNm) + { + string[] sCommands = null; + + try + { + + sCommands = new string[] { "CLL\r\n" // 메모리 클리어 + , "NEW\r\n" // 새로운 명령어 시작 + , "CLIP ON\r\n" + , "FONT \"HYGothic-Medium\",12\r\n" + , "NASC 949\r\n" // intermec 한글폰트 설정 + , "PRPOS 0,150\r\n" + , "PRTXT \"" + sContent + "\"\r\n" + , "FONT \"HYGothic-Medium\",9\r\n" + , "PRPOS 0,110\r\n" + , "PRTXT \"" + sDateTime + "\"\r\n" + , "PRPOS 0,70\r\n" + , "PRTXT \"" + sStoreNm + "\"\r\n" + , "PRPOS 0,30\r\n" + , "PRTXT \"배달은 해피오더 / 1670-3131\"\r\n" //#10856_[BR] 저울 중량 라벨프린터 양식 변경_hs + , "PF\r\n" }; + + if (sCommands != null) + WriteCommand(sCommands); + + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 PrintWeightInfo(string sContent, string sFlavour1, string sFlavour2, string sOrdDateTime, string sPckDateTime) + { + string[] sCommands = null; + + try + { + // EX) + // 패밀리 / 980g (5516) + // 플레이버1/플레이버2/플레이버3 + // 플레이버4/플레이버5/플레이버6 + // + // 주문 YYYY-MM-DD HH시MM분 + // 포장 YYYY-MM-DD HH시MM분 + sCommands = new string[] { "CLL\r\n" // 메모리 클리어 + , "NEW\r\n" // 새로운 명령어 시작 + , "CLIP ON\r\n" + , "FONT \"HYGothic-Medium\",12\r\n" + , "NASC 949\r\n" + , "PRPOS 0,190\r\n" + , "PRTXT \"" + sContent + "\"\r\n" + , "FONT \"HYGothic-Medium\",9\r\n" + , "PRPOS 0,150\r\n" + , "PRTXT \"" + sFlavour1 + "\"\r\n" + , "PRPOS 0,110\r\n" + , "PRTXT \"" + sFlavour2 + "\"\r\n" + , "PRPOS 0,50\r\n" + , "PRTXT \"" + sOrdDateTime + "\"\r\n" + , "PRPOS 0,10\r\n" + , "PRTXT \"" + sPckDateTime + "\"\r\n" + , "PF\r\n" }; + + if (sCommands != null) + WriteCommand(sCommands); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 출력 함수 + + //#20180515 KPS 출력시 라벨프린터 출력 start + #region KPS 출력시 라벨프린터 출력 함수 + /// + /// 중량 출력KPS 출력시 라벨프린터 출력 + /// + /// 출력데이터 + public void PrintLabelInfo(string sContent) + { + string[] sCommands = null; + + try + { + sCommands = new string[] { sContent }; + + if (sCommands != null) + WriteCommand(sCommands); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 출력 함수 + //#20180515 KPS 출력시 라벨프린터 출력 end + + #region 명령어 전송 함수 + /// + /// 시리얼포트에 명령어를 전송 + /// + /// + private void WriteCommand(string[] sCommands) + { + try + { + foreach(string cmd in sCommands) + { + m_cSerialPort.Write(cmd); + } + + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 명령어 전송 함수 + } +} diff --git a/Agent/KPS/OPOSPrint.cs b/Agent/KPS/OPOSPrint.cs new file mode 100644 index 0000000..a44610d --- /dev/null +++ b/Agent/KPS/OPOSPrint.cs @@ -0,0 +1,333 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Cosmos.KPS +{ + class OPOSPrint + { + #region 위치 + public enum Position + { + Top, + Buttom, + TopAndButtom + } + public enum Alignment + { + Center, + Left, + Right + } + #endregion + + #region Character size/Filter + /// + /// Character size horizontal [넓이 배율 1~8] + /// + public enum CharactersizeH + { + H_1, + H_2, + H_3, + H_4, + H_5, + H_6, + H_7, + H_8 + } + /// + /// Character size vertical [높이 배율 1~8] + /// + public enum CharactersizeV + { + V_1, + V_2, + V_3, + V_4, + V_5, + V_6, + V_7, + V_8 + } + + /// + /// Bold 체 여부 + /// + public enum TextBold + { + Nomal, + Bold + } + + /// + /// 밑줄(UnderLine) + /// + public enum TextUnderLine + { + Nomal, + UnderLine + } + + /// + /// 반전 Text 효과 + /// + public enum TextReverseMode + { + Nomal, + ReverseMode + } + + #endregion + + #region OposPrint + /// + /// Text Print + /// 문자열을 출력 합니다. + /// + /// 출력할 문자 + /// 정렬(Left, Center, Right) + /// 세로확대(1배~8배) + /// 가로확대(1배~8배) + /// 굵은글씨(BOLD) + /// 밑줄(UnderLine) + /// LineFeed 여부 + /// + public static bool OposTextPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue, Alignment eAlignment, CharactersizeV eVerticalSize, CharactersizeH eHorizontalSize, TextBold eBold, TextUnderLine eTextUnderLine, TextReverseMode eTextReverseMode, bool bLineFeed) + { + bool bRet = false; + string sCmdctrlTmp = ""; + + string ESC = String.Format("{0}", (char)27); + string SP = String.Format("{0}", (char)20); + //string ESC_CUT = Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + ESC + "|P"; + //string ESC_FEEDCUT = Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + ESC + "|fP"; + string ESC_CUT = ESC + "|50P"; + string ESC_FEEDCUT = ESC + "|100fP"; + + string ESC_BITMAP1 = ESC + "|1B"; + string ESC_BITMAP2 = ESC + "|2B"; + string ESC_TOPLOGO = ESC + "|tL"; + string ESC_BTMLOGO = ESC + "|bL"; + string ESC_LINEFEED = ESC + "|lF"; + string ESC_FEED = ESC + "|uF"; + //string ESC_BOLD = ESC + "|bC"; + //string ESC_NOT_BOLD = ESC + "|!bC"; + string ESC_UNDERLINE = ESC + "|uC"; + string ESC_COLOR = ESC + "|rC"; + //string ESC_REVERSE = ESC + "|rvC"; + //string ESC_NOT_REVERSE = ESC + "|!rvC"; + string ESC_1MAG = ESC + "|1C"; + string ESC_2MAG = ESC + "|4C"; + string ESC_HMAG = ESC + "|2C"; + string ESC_VMAG = ESC + "|3C"; + + string ESC_H1MAG = ESC + "|1hC"; + string ESC_V1MAG = ESC + "|1vC"; + string ESC_H2MAG = ESC + "|2hC"; + string ESC_V2MAG = ESC + "|2vC"; + string ESC_H3MAG = ESC + "|3hC"; + string ESC_V3MAG = ESC + "|3vC"; + string ESC_H4MAG = ESC + "|4hC"; + string ESC_V4MAG = ESC + "|4vC"; + string ESC_H5MAG = ESC + "|5hC"; + string ESC_V5MAG = ESC + "|5vC"; + string ESC_H6MAG = ESC + "|6hC"; + string ESC_V6MAG = ESC + "|6vC"; + string ESC_H7MAG = ESC + "|7hC"; + string ESC_V7MAG = ESC + "|7vC"; + string ESC_H8MAG = ESC + "|8hC"; + string ESC_V8MAG = ESC + "|8vC"; + string ESC_CENTER = ESC + "|cA"; + string ESC_RIGHT = ESC + "|rA"; + string ESC_NORMAL = ESC + "|N"; + + + sCmdctrlTmp = ""; + + //정렬 + switch (eAlignment) + { + case Alignment.Center: sCmdctrlTmp += ESC_CENTER; break; + case Alignment.Right: sCmdctrlTmp += ESC_RIGHT; break; + case Alignment.Left: sCmdctrlTmp += ESC_NORMAL; break; + } + + //확대 Command를 설정. + //sCmdctrlTmp = GetCharactersizeCmd(eVerticalSize, eHorizontalSize); + + switch (eVerticalSize) + { + case CharactersizeV.V_2: sCmdctrlTmp += ESC_V2MAG; break; + case CharactersizeV.V_3: sCmdctrlTmp += ESC_V3MAG; break; + case CharactersizeV.V_4: sCmdctrlTmp += ESC_V3MAG; break; + case CharactersizeV.V_5: sCmdctrlTmp += ESC_V4MAG; break; + case CharactersizeV.V_6: sCmdctrlTmp += ESC_V5MAG; break; + case CharactersizeV.V_7: sCmdctrlTmp += ESC_V7MAG; break; + case CharactersizeV.V_8: sCmdctrlTmp += ESC_V8MAG; break; + default: sCmdctrlTmp += ESC_V1MAG; break; + } + switch (eHorizontalSize) + { + case CharactersizeH.H_2: sCmdctrlTmp += ESC_H2MAG; break; + case CharactersizeH.H_3: sCmdctrlTmp += ESC_H3MAG; break; + case CharactersizeH.H_4: sCmdctrlTmp += ESC_H3MAG; break; + case CharactersizeH.H_5: sCmdctrlTmp += ESC_H4MAG; break; + case CharactersizeH.H_6: sCmdctrlTmp += ESC_H5MAG; break; + case CharactersizeH.H_7: sCmdctrlTmp += ESC_H7MAG; break; + case CharactersizeH.H_8: sCmdctrlTmp += ESC_H8MAG; break; + default: sCmdctrlTmp += ESC_H1MAG; break; + } + + //UnderLine + if (eTextUnderLine == TextUnderLine.UnderLine) + sCmdctrlTmp += ESC_UNDERLINE; + + //Bold + //if (TextBold.Bold == eBold) + // sCmdctrlTmp += ESC_BOLD; + //else + // sCmdctrlTmp += ESC_NOT_BOLD; + + //Reverse + //if (TextReverseMode.ReverseMode == eTextReverseMode) + // sCmdctrlTmp += ESC_REVERSE; + //else + // sCmdctrlTmp += ESC_NOT_REVERSE; + + if (sValue != "") + { + + } + + if (bLineFeed == true) + { + sValue = sCmdctrlTmp + sValue + "\r\n"; + } + + //출력 + int nRet = pOPOSPrint.PrintNormal(OPOS.PTR_S_RECEIPT, sValue); + + return bRet; + } + + /// + /// Text Print + /// 문자열을 출력 합니다. + /// + /// 출력할 문자 + /// 정렬(Left, Center, Right) + /// 세로확대(1배~8배) + /// 가로확대(1배~8배) + /// 굵은글씨(BOLD) + /// 밑줄(UnderLine) + /// LineFeed 여부 + /// + public static bool OposTextPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue, Alignment eAlignment, CharactersizeV eVerticalSize, CharactersizeH eHorizontalSize, TextBold eBold, TextUnderLine eTextUnderLine, bool bLineFeed) + { + return OposTextPrint(pOPOSPrint, sValue, eAlignment, eVerticalSize, eHorizontalSize, eBold, eTextUnderLine, TextReverseMode.Nomal, bLineFeed); + } + /// + /// 문자열을 출력 합니다. + /// + /// 출력할 문자 + /// LineFeed 여부 + /// + public static bool OposTextPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue, bool bLineFeed) + { + return OposTextPrint(pOPOSPrint, sValue, Alignment.Left, CharactersizeV.V_1, CharactersizeH.H_1, TextBold.Nomal, TextUnderLine.Nomal, TextReverseMode.Nomal, bLineFeed); + } + /// + /// 문자열을 출력 합니다. + /// + /// 출력할 문자 + /// 정렬(Left, Center, Right) + /// LineFeed 여부 + /// + public static bool OposTextPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue, Alignment eAlignment, bool bLineFeed) + { + return OposTextPrint(pOPOSPrint, sValue, eAlignment, CharactersizeV.V_1, CharactersizeH.H_1, TextBold.Nomal, TextUnderLine.Nomal, TextReverseMode.Nomal, bLineFeed); + } + /// + /// 문자열을 출력 합니다. + /// + /// 출력할 문자 + /// 정렬(Left, Center, Right) + /// 세로확대(1배~8배) + /// 가로확대(1배~8배) + /// LineFeed 여부 + /// + public static bool OposTextPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue, Alignment eAlignment, CharactersizeV eVerticalSize, CharactersizeH eHorizontalSize, bool bLineFeed) + { + return OposTextPrint(pOPOSPrint, sValue, eAlignment, eVerticalSize, eHorizontalSize, TextBold.Nomal, TextUnderLine.Nomal, TextReverseMode.Nomal, bLineFeed); + } + /// + /// 문자열을 출력 합니다. + /// 진한문자열을 출력 할 수 있습니다. + /// + /// 출력할 문자 + /// 정렬(Left, Center, Right) + /// 굵은글씨(BOLD) + /// LineFeed 여부 + /// + public static bool OposTextPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue, Alignment eAlignment, TextBold eBold, bool bLineFeed) + { + return OposTextPrint(pOPOSPrint, sValue, eAlignment, CharactersizeV.V_1, CharactersizeH.H_1, eBold, TextUnderLine.Nomal, TextReverseMode.Nomal, bLineFeed); + } + /// + /// 문자열을 출력 합니다. + /// 진한문자열을 출력 할 수 있습니다. + /// + /// 출력할 문자 + /// 정렬(Left, Center, Right) + /// 굵은글씨(BOLD) + /// LineFeed 여부 + /// + public static bool OposTextPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue, Alignment eAlignment, TextUnderLine eTextUnderLine, bool bLineFeed) + { + return OposTextPrint(pOPOSPrint, sValue, eAlignment, CharactersizeV.V_1, CharactersizeH.H_1, TextBold.Nomal, eTextUnderLine, TextReverseMode.Nomal, bLineFeed); + } + + /// + /// 문자열을 출력 합니다. + /// 역상 출력을 합니다. + /// + /// 출력 할 문자 + /// 정렬(Left, Center, Right) + /// 반전출력 모드 설정(Reverse Mode) + /// + /// + public static bool OposTextPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue, Alignment eAlignment, TextReverseMode eTextReverseMode, bool bLineFeed) + { + return OposTextPrint(pOPOSPrint, sValue, Alignment.Left, CharactersizeV.V_1, CharactersizeH.H_1, TextBold.Nomal, TextUnderLine.Nomal, eTextReverseMode, bLineFeed); + } + #endregion + + + /// + /// 문자열을 출력 합니다. + /// 역상 출력을 합니다. + /// + /// 출력 할 문자 + /// 정렬(Left, Center, Right) + /// 반전출력 모드 설정(Reverse Mode) + /// + /// + public static bool OposBarPrint(AxOposPOSPrinter_CCO.AxOPOSPOSPrinter pOPOSPrint, string sValue) + { + int nStat = 0; + + if (sValue.Length % 2 == 0) + { + nStat = pOPOSPrint.PrintBarCode(OPOS.PTR_S_RECEIPT, sValue, OPOS.PTR_BCS_ITF, 50, 368, OPOS.PTR_BC_CENTER, OPOS.PTR_BC_TEXT_BELOW); + } + else + { + nStat = pOPOSPrint.PrintBarCode(OPOS.PTR_S_RECEIPT, "0" + sValue, OPOS.PTR_BCS_ITF, 50, 368, OPOS.PTR_BC_CENTER, OPOS.PTR_BC_TEXT_BELOW); + } + + return true; + } + } +} diff --git a/Agent/KPS/PrinterCommand.cs b/Agent/KPS/PrinterCommand.cs new file mode 100644 index 0000000..fe2dbea --- /dev/null +++ b/Agent/KPS/PrinterCommand.cs @@ -0,0 +1,878 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; + +namespace Cosmos.KPS +{ + [Serializable] + public class PrinterCommand + { + #region 위치 + public enum Position + { + Top, + Buttom, + TopAndButtom, + None + } + public enum Alignment + { + Center, + Left, + Right + } + #endregion + + #region Character size/Filter + /// + /// Character size horizontal [넓이 배율 1~8] + /// + public enum CharactersizeH + { + H_1, + H_2, + H_3, + H_4, + H_5, + H_6, + H_7, + H_8 + } + /// + /// Character size vertical [높이 배율 1~8] + /// + public enum CharactersizeV + { + V_1, + V_2, + V_3, + V_4, + V_5, + V_6, + V_7, + V_8 + } + + /// + /// Bold 체 여부 + /// + public enum TextBold + { + Nomal, + Bold + } + + /// + /// 밑줄(UnderLine) + /// + public enum TextUnderLine + { + Nomal, + UnderLine + } + + /// + /// 반전 Text 효과 + /// + public enum TextReverseMode + { + Nomal, + ReverseMode + } + + #endregion + + #region Barcode Type + /// + /// Print Barcode + /// 1Dh, 6BH, m, d1, ...dk, 00H [0 ≤ m ≤ 6, 32 ≤ k ≤ 126, 1 ≤ k ≤ 255] + /// 1Dh, 6BH, m, n, d1, ...dn [65 ≤ m ≤ 73, 1 ≤ n ≤ 255, 0 ≤ d ≤ 127] + /// + public enum BarcodeType : int + { + UPC_A = 0, //m = 0, 65, + UPC_E = 1, //m = 1, 66 + EAN13_KAN13 = 2, //m = 2, 67 + EAN8_KAN8 = 3, //m = 3, 68 + COE39 = 4, //m = 4, 69 + ITF = 5, //m = 5, 70 + CODEBAR = 6, //m = 6, 71 + CODE93 = 72, //m = 72 + CODE128 = 73 //m = 73 + } + #endregion + + #region Error Code + public const int PRT_SUCCESS = 0; + #endregion + + #region "StatusUpdateEvent" Event: "Data" Parameter Constants + public const int PTR_SUE_COVER_OPEN = 11; + public const int PTR_SUE_COVER_OK = 12; + public const int PTR_SUE_JRN_EMPTY = 21; + public const int PTR_SUE_JRN_NEAREMPTY = 22; + public const int PTR_SUE_JRN_PAPEROK = 23; + public const int PTR_SUE_REC_EMPTY = 24; + public const int PTR_SUE_REC_NEAREMPTY = 25; + public const int PTR_SUE_REC_PAPEROK = 26; + public const int PTR_SUE_SLP_EMPTY = 27; + public const int PTR_SUE_SLP_NEAREMPTY = 28; + public const int PTR_SUE_SLP_PAPEROK = 29; + public const int PTR_SUE_JRN_CARTRIDGE_EMPTY = 41; + public const int PTR_SUE_JRN_CARTRIDGE_NEAREMPTY = 42; + public const int PTR_SUE_JRN_HEAD_CLEANING = 43; + public const int PTR_SUE_JRN_CARTRIDGE_OK = 44; + public const int PTR_SUE_REC_CARTRIDGE_EMPTY = 45; + public const int PTR_SUE_REC_CARTRIDGE_NEAREMPTY = 46; + public const int PTR_SUE_REC_HEAD_CLEANING = 47; + public const int PTR_SUE_REC_CARTRIDGE_OK = 48; + public const int PTR_Sue_Slp_CARTRIDGE_EMPTY = 49; + public const int PTR_Sue_Slp_CARTRIDGE_NEAREMPTY = 50; + public const int PTR_SUE_SLP_HEAD_CLEANING = 51; + public const int PTR_SUE_SLP_CARTRIDGE_OK = 52; + + public const int PTR_SUE_IDLE = 1001; + #endregion + + #region Default + public byte ESC = 0x1B; + public byte SP = 0x14; + + public byte ESC_CR = 0x0D; + public byte ESC_LF = 0x0A; + public byte ESC_FF = 0xFF; + + public byte[] ESC_INITPRINTER = { 0x1B, 0x40 }; //Printer 초기화 + + //1BH, 74H, n n=1(Katakana) + //1BH, 52H, n n=0(USA), n=8(Japan), n=13(korea) 'Select an international characer set + //1CH, 43H, n n=0,48 JIS code system , n=1,49 Shift JIS code system. + public byte[] ESC_LANGE = { 0x1B, 0x74, 0x01, + 0x1B, 0x52, 0x08, + 0x1C, 0x43, 0x01, + 0x1C, 0x26 }; + + /// + /// Buffer clear + /// [10H, 14H, 08H, d1......d7] + /// [d1=1, d2=3, d3=20, d4=1, d5=6, d6=2, d7=8] + /// + public byte[] ESC_BUFFERCLEAR = { 0x10, 0x14, 0x08, 0x01, 0x03, 0x14, 0x01, 0x06, 0x02, 0x08 }; + #endregion + + #region Request Status (상태 전송) + public byte[] ESC_REQ_SUATUS_PAPER_SENSOR = { 0x1D, 0x72, 0x01 }; //용지 센서 상태를 송신합니다 + public byte[] ESC_REQ_SUATUS_PAPER_SENSOR1 = { 0x1D, 0x72, 0x31 }; //용지 센서 상태를 송신합니다 + + public byte[] ESC_REQ_SUATUS_DRAW_CON = { 0x1D, 0x72, 0x02 }; //캐쉬 드로어 커넥터 상태를 송신 합니다. + public byte[] ESC_REQ_SUATUS_DRAW_CON1 = { 0x1D, 0x72, 0x32 }; //캐쉬 드로어 커넥터 상태를 송신 합니다. + + //public byte[] ESC_REQ_SUATUS_PAPER_SENSOR2 = { 0x1B, 0x63, 0x33 }; //용지 센서 상태를 송신합니다 + #endregion + + #region BarCode Commad + //Select printing position for HRI character + /// + /// HRI Print 안함 + /// + public byte[] ESC_HRI_NOTPRINT = { 0x1D, 0x48, 0x00 }; + /// + /// Barcode 상단에 HRI Print + /// + public byte[] ESC_HRI_TOPPRINT = { 0x1D, 0x48, 0x01 }; + /// + /// Barcode 아래에 HRI Print + /// + public byte[] ESC_HRI_BELOWPRINT = { 0x1D, 0x48, 0x02 }; + /// + /// Barcode 위,아래에 HRI Print + /// + public byte[] ESC_HRI_TOPANDBELOWPRINT = { 0x1D, 0x48, 0x03 }; + + #endregion + + #region Alignment + public byte[] ESC_CENTER = { 0x1B, 0x61, 0x01 }; // CENTER 정렬 + public byte[] ESC_RIGHT = { 0x1B, 0x61, 0x02 }; // 오른쪽 정렬 + public byte[] ESC_LEFT = { 0x1B, 0x61, 0x00 }; // 왼쪽 정렬 + #endregion + + #region Text + + public byte[] ESC_NORMAL = { 0x1B, 0x21, 0x00, 0x1C, 0x21, 0x00 }; //보통문자 + + #region Select print mode + // [Format] 1BH, 21H, n + // [Valid limits] 0<=n<=255 + // [Initial value] n=0 + //┌──┬────────────┬────────────────────┐ + //│ │ │ Value │ + //│Bit │ Function ├─────────┬──────────┤ + //│ │ │ 0 │ 1 │ + //├──┼────────────┼─────────┼──────────┤ + //│ 0 │Character font │Font A is selected│Font B/C is selected│ + //├──┼────────────┼─────────┼──────────┤ + //│ 1 │To be defined │ -- │ -- │ + //├──┼────────────┼─────────┼──────────┤ + //│ 2 │To be defined │ -- │ -- │ + //├──┼────────────┼─────────┼──────────┤ + //│ 3 │Emphasized printing │ Candel │ Specify │ + //├──┼────────────┼─────────┼──────────┤ + //│ 4 │Double character height │ Candel │ Specify │ + //├──┼────────────┼─────────┼──────────┤ + //│ 5 │Double character width │ Candel │ Specify │ + //├──┼────────────┼─────────┼──────────┤ + //│ 6 │To be defined │ -- │ -- │ + //├──┼────────────┼─────────┼──────────┤ + //│ 7 │Underline │ Candel │ Specify │ + //└──┴────────────┴─────────┴──────────┘ + + + public byte[] ESC_FontA = { 0x1B, 0x21, 0x00 }; // Font A 인쇄 + public byte[] ESC_FontBC = { 0x1B, 0x21, 0x01 }; // Font B/C 인쇄 + + public byte[] ESC_DOUBLE = { 0x1B, 0x21, 0x30, 0x1C, 0x57, 0x01 }; // 가로세로 2배 확대 + public byte[] ESC_DBLHEIGH = { 0x1B, 0x21, 0x10, 0x1C, 0x21, 0x08 }; // 세로 2배 확대 + public byte[] ESC_DBLWIDTH = { 0x1B, 0x21, 0x20, 0x1C, 0x21, 0x04 }; // 가로 2배 확대 ESC + "|2hC" + + public byte[] ESC_UNDERLINE = { 0x1B, 0x21, 0x80 }; // UnderLine ESC + "|uC" + public byte[] ESC_UNDERLINEON1DOT = { 0x1B, 0x2D, 0x01 }; // UnderLine Mode On 1Dot + public byte[] ESC_UNDERLINEON2DOT = { 0x1B, 0x2D, 0x02 }; // UnderLine Mode On 2Dot + public byte[] ESC_UNDERLINEOFF = { 0x1B, 0x2D, 0x00 }; // UnderLine Mode Off + #endregion + + #region Set Character size + public byte[] ESC_VHMAG = { 0x1D, 0x21 }; // 배율확대확대 인쇄(FontSize) + + public byte[] ESC_H1MAG = { 0x1D, 0x21, 0x00 }; // 가로 1배확대 인쇄(FontSize) + public byte[] ESC_V1MAG = { 0x1D, 0x21, 0x00 }; // 세로 1배확대 인쇄(FontSize) + + public byte[] ESC_H2Y2MAG = { 0x1D, 0x21, 0x11 }; // 가로/세로 2배 확대 + public byte[] ESC_H2MAG = { 0x1D, 0x21, 0x10 }; // 가로 2배확대 인쇄(FontSize) + public byte[] ESC_V2MAG = { 0x1D, 0x21, 0x01 }; // 세로 2배확대 인쇄(FontSize) + + public byte[] ESC_H3MAG = { 0x1D, 0x21, 0x20 }; // 가로 3배확대 인쇄(FontSize) + public byte[] ESC_V3MAG = { 0x1D, 0x21, 0x02 }; // 세로 3배확대 인쇄(FontSize) + + public byte[] ESC_H4MAG = { 0x1D, 0x21, 0x30 }; // 가로 4배확대 인쇄(FontSize) + public byte[] ESC_V4MAG = { 0x1D, 0x21, 0x03 }; // 세로 4배확대 인쇄(FontSize) + + public byte[] ESC_H5MAG = { 0x1D, 0x21, 0x40 }; // 가로 5배확대 인쇄(FontSize) + public byte[] ESC_V5MAG = { 0x1D, 0x21, 0x04 }; // 세로 5배확대 인쇄(FontSize) + + public byte[] ESC_H6MAG = { 0x1D, 0x21, 0x50 }; // 가로 6배확대 인쇄(FontSize) + public byte[] ESC_V6MAG = { 0x1D, 0x21, 0x05 }; // 세로 6배확대 인쇄(FontSize) + + public byte[] ESC_H7MAG = { 0x1D, 0x21, 0x60 }; // 가로 7배확대 인쇄(FontSize) + public byte[] ESC_V7MAG = { 0x1D, 0x21, 0x06 }; // 세로 7배확대 인쇄(FontSize) + + public byte[] ESC_H8MAG = { 0x1D, 0x21, 0x70 }; // 가로 8배확대 인쇄(FontSize) + public byte[] ESC_V8MAG = { 0x1D, 0x21, 0x07 }; // 세로 8배확대 인쇄(FontSize) + #endregion + + #region Set Bold On/Off + public byte[] ESC_BOLD_ON = { 0x1B, 0x45, 0x01 }; // 진하게 인쇄선언 + public byte[] ESC_BOLD_OFF = { 0x1B, 0x45, 0x00 }; // 진하게 인쇄선언해제 + public byte[] ESC_BOLD = { 0x1B, 0x21, 0x08 }; //'진하게 ESC + "|bC" + #endregion + + #region Set Reverse Mode On/Off + /// + /// On Reverse Mode + /// + public byte[] ESC_REVERSE_MODE_ON = { 0x1D, 0x42, 0x01 };//ESC + "|rvC" + /// + /// Off Revers Mode + /// + public byte[] ESC_REVERSE_MODE_OFF = { 0x1D, 0x42, 0x00 };//ESC + "|!rvC" + #endregion + + /* + 'ESC_CUT = Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + ESC + "|P" + ESC_CUT = ESC + "|50P" + 'ESC_FEEDCUT = Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + Chr(&HA) + ESC + "|fP" + ESC_FEEDCUT = ESC + "|100fP" + + + ESC_BITMAP1 = ESC + "|1B" + ESC_BITMAP2 = ESC + "|2B" + ESC_TOPLOGO = ESC + "|tL" + ESC_BTMLOGO = ESC + "|bL" + ESC_LINEFEED = ESC + "|lF" + ESC_FEED = ESC + "|uF" + + ESC_NOT_BOLD = ESC + "|!bC" + ESC_COLOR = ESC + "|rC" + + ESC_1MAG = ESC + "|1C" + ESC_2MAG = ESC + "|4C" + ESC_HMAG = ESC + "|2C" + ESC_VMAG = ESC + "|3C" + ESC_CENTER = ESC + "|cA" + ESC_RIGHT = ESC + "|rA" + + */ + + #endregion + + #region Cut paper + [Browsable(false), Category("Exception"), + Description("Cutting Command"), + DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] + [AmbientValue("")] + public byte[] ESC_CUT = { 0x1D, 0x56, 0x31 }; //Convert.ToByte(49) }; + public byte[] ESC_FULLCUT = { 0x1B, 0x69 }; + public byte[] ESC_PARTCUT = { 0x1B, 0x6D }; + + #endregion + + #region Paper sensor to outpu paper out signals + //용지부족/용지없음 Sensor + public byte[] ESC_PAPERSENSOR_OFF = { 0x1B, 0x63, 0x33, 0x00 }; + public byte[] ESC_PAPERSENSOR_ON = { 0x1B, 0x63, 0x33, 0x0F }; + #endregion + + #region Paper sensor to stop printing + /// + /// Paper near end detector Valid + /// + public byte[] ESC_PAPER_NEAREND_0N = { 0x1B, 0x63, 0x34, 0x01 }; + /// + /// Paper near end detector InValid + /// + public byte[] ESC_PAPER_NEAREND_0FF = { 0x1B, 0x63, 0x34, 0x01 }; + #endregion + + #region Real-time status transmission + public byte[] ESC_TRANS_STATUS = { 0x10, 0x04, 0x01 }; + /// + /// Cover 상태 체크 명령어 + /// + public byte[] ESC_TRANS_OFFLINE = { 0x10, 0x04, 0x02 }; + public byte[] ESC_TRANS_ERR_STUS = { 0x10, 0x04, 0x03 }; + /// + /// Paper 상태 체크 명령어 + /// + public byte[] ESC_TRANS_CONTI_STATUS = { 0x10, 0x04, 0x04 }; + #endregion + + #region Enable/disable automatic status back + public byte[] ESC_STATUSBACK = { 0x1d, 0x61, 0xCF }; + #endregion + + #region Select peripheral device + public byte[] ESC_DEVICE_PRT = { 0x1B, 0x3D, 0x01 }; + #endregion + + #region Open CashDrawer + public byte[] cmd_OpenCashDraerBox = { 0x1B, 0x70, 0x30 }; + #endregion + + #region Print Type + public enum PRT_CMD + { + NONE, //미지원 형식 + PRT_IMG, //Image + PRT_BAR, //바코드 + PRT_CUT, //CUT + PRT_NOR, //일반 문자 + PRT_BLD, //진하게 + PRT_VER, //세로확대 + PRT_HOR, //가로확대 + PRT_BIG, //가로/세로확대 + PRT_CNT, //가로확대+가운데 정렬 + PRT_JNL, //저널데이터 + PRT_DRW, //돈통열림 + ERROR //Error + } + + public string PRT_IMG = "[IMG]"; //Image + public string PRT_BAR = "[BAR]"; //바코드 + public string PRT_CUT = "[CUT]"; //CUT + public string PRT_NOR = "[NOR]"; //일반 문자 + public string PRT_BLD = "[BLD]"; //진하게 + public string PRT_VER = "[VER]"; //세로확대 + public string PRT_HOR = "[HOR]"; //가로확대 + public string PRT_BIG = "[BIG]"; //가로/세로확대 + public string PRT_CNT = "[CNT]"; //가로확대+가운데 정렬 + public string PRT_JNL = "[JNL]"; //저널데이터 + public string PRT_DRW = "[DRW]"; //돈통열림 + #endregion + + #region 상태체크 + /// + /// 상태체크(Paper, Drawer 상태 ) + /// Drawer 상태는 상태체크가 가능한 돈통에 한함. + /// + public enum CHK_PRT_STATUS + { + CHK_PAPER, + CHK_DRAWER + } + #endregion + } + + + /// + /// Printer Status Information + /// + [Serializable] + public class PrinterInformation + { + #region Printer Event + private bool[,] Infomation = new bool[8 * 4, 2]; + private enum eStatusInfo : int + { + //Event First Byte + /// + /// State of the drawer kick connector pin 3 [false:Low, true: High] + /// + DrwKickLH = 7 - 2, + /// + /// Online.offline [false: Online, true: Offline] + /// + OnOffLine = 7 - 3, + /// + /// Cover state [false:Closed, true : Open] + /// + Coverstate = 7 - 5, + /// + /// Paper feed by paper feed switch [false:Stopped, true : Operation] + /// + feedswitch = 7 - 6, + + //Event Second Byte(error information) + /// + /// Macro executing [false:Not execute, true : execute] + /// + MacroExecuting = 8 + 7 - 0, + /// + /// Panel switch[false:Off, true:On] + /// + Panelswitch = 8 + 7 - 1, + /// + /// Mechanical error(cover Open, Cutter Jam) [false:No, true: Yes] + /// + MechanicalErr = 8 * 7 - 2, + /// + /// Cutter jam [false:No, true: Yes] + /// + CutterJam = 8 * 7 - 3, + /// + /// Unrecoverable error[false:No, true:Yes] + /// + UnrecoverableErr = 8 + 7 - 5, + /// + /// Auto-recoverrable error detected [false:No, true:Yes] + /// + AutoRecoverableErr = 8 + 7 - 6, + + //Third byte(paper detector information) + /// + /// Roll Paper Near end detecter[false:Paper present, true Nopaper] + /// + PaperNearEnd_1 = 16 + 7 - 0, + /// + /// Roll Paper Near end detecter[false:Paper present, true Nopaper] + /// + PaperNearEnd_2 = 16 + 7 - 0, + /// + /// Roll Paper end detecter[false:Paper present, true Nopaper] + /// + PaperEnd_1 = 16 + 7 - 2, + /// + /// Roll Paper end detecter[false:Paper present, true Nopaper] + /// + PaperEnd_2 = 16 + 7 - 3, + + //Fourth byte (paper detector information) + /// + /// F/W down load Fail[false: Not Fail, true: Fail] + /// + FWdownLoadFail = 24 + 7 - 5 + } + public enum eSetStatusType : int + { + /// + /// PRINTER STATUS[First Byte] + /// + PRT_PRINTERINFOMATION, + /// + /// ERROR INFOMATION[Second Byte] + /// + PRT_ERRINFOMATION, + /// + /// Paper Status[Third Byte] + /// + PRT_PAPERINFOMATION, + /// + /// Firm Ware[Fourth Byte] + /// + PRT_FIRMWAREDOWN + } + #endregion + + #region All Set + public void SetAllData(char[] szData) + { + char[] szEvt = szData; + + //string bitStringFirst = str2bitstr(szData[0].ToString(), 1); + //string bitStringSecond = str2bitstr(szData[1].ToString(), 1); + //string bitStringThird = str2bitstr(szData[2].ToString(), 1); + //string bitStringFourth = str2bitstr(szData[3].ToString(), 1); + //string sBitInfo = bitStringFirst + bitStringSecond + bitStringThird + bitStringFourth; + + string sBitInfo = ""; + sBitInfo = str2bitstr(szData[0].ToString(), 1); + sBitInfo += str2bitstr(szData[1].ToString(), 1); + sBitInfo += str2bitstr(szData[2].ToString(), 1); + sBitInfo += str2bitstr(szData[3].ToString(), 1); + + + string sValue = ""; + for (int nRow = 0; nRow < Infomation.GetLength(0); nRow++) + { + sValue = sBitInfo.Substring(nRow, 1); + + Infomation[nRow, 1] = Infomation[nRow, 0] == (sValue == "1" ? true : false) ? false : true; + Infomation[nRow, 0] = sValue == "1" ? true : false; + } + + //bool DrawerKick = Infomation[eStatusInfo.DrwKickLH]; + } + public char[] GetAllData() + { + string sRet = ""; + string szTemp = ""; + + for (int nRow = 0; nRow < Infomation.Length; nRow++) + { + szTemp += Infomation[nRow, 1] == true ? "1" : "0"; + } + return sRet.ToCharArray(); + } + #endregion + + #region Printer Status First/Second/Third/Fourth Byte Set + public void SetPrintStatus(eSetStatusType eType, char szData) + { + string sBitInfo = str2bitstr(szData.ToString(), 1); + + int nStart = 0; + switch (eType) + { + case eSetStatusType.PRT_PRINTERINFOMATION: nStart = 0; break; + case eSetStatusType.PRT_ERRINFOMATION: nStart = 8; break; + case eSetStatusType.PRT_PAPERINFOMATION: nStart = 16; break; + case eSetStatusType.PRT_FIRMWAREDOWN: nStart = 24; break; + default: return; + } + string sValue = ""; + for (int nRow = 0; nRow < 8; nRow++) + { + sValue = sBitInfo.Substring(nRow, 1); + + Infomation[nStart + nRow, 1] = Infomation[nStart + nRow, 0] == (sValue == "1" ? true : false) ? false : true; + Infomation[nStart + nRow, 0] = sValue == "1" ? true : false; + } + } + #endregion + + #region First Byte(Printer Infomation) + /// + /// [Printer Status Infomation] + /// State of the drawer kick connector pin3 + /// FALSE: Low, TRUE : High + /// + public bool IsDrawerKickLoHi { get { return Infomation[(int)eStatusInfo.DrwKickLH, 0]; } set { Infomation[(int)eStatusInfo.DrwKickLH, 0] = value; } } + public bool IsDrawerKickLoHiChange { get { bool bRet = Infomation[(int)eStatusInfo.DrwKickLH, 1]; Infomation[(int)eStatusInfo.DrwKickLH, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.DrwKickLH, 1] = value; } } + /// + /// [Printer Status Infomation] + /// OnLine / OffLine + /// FALSE : OnLine, TRUE ; OffLine + /// + public bool IsOffLine { get { return Infomation[(int)eStatusInfo.OnOffLine, 0]; } set { Infomation[(int)eStatusInfo.OnOffLine, 0] = value; } } + public bool IsOffLineChange { get { bool bRet = Infomation[(int)eStatusInfo.OnOffLine, 1]; Infomation[(int)eStatusInfo.OnOffLine, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.OnOffLine, 1] = value; } } + /// + /// [Printer Status Infomation] + /// Cover Open + /// FALSE : Closed, TRUE : Open + /// + public bool IsCoverOpen { get { return Infomation[(int)eStatusInfo.Coverstate, 0]; } set { Infomation[(int)eStatusInfo.Coverstate, 0] = value; } } + public bool IsCoverOpenChange { get { bool bRet = Infomation[(int)eStatusInfo.Coverstate, 1]; Infomation[(int)eStatusInfo.Coverstate, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.Coverstate, 1] = value; } } + /// + /// [Printer Status Infomation] + /// Feed Switch + /// FALSE : stop, TRUE : operating + /// + public bool Isfeedswitch { get { return Infomation[(int)eStatusInfo.feedswitch, 0]; } set { Infomation[(int)eStatusInfo.feedswitch, 0] = value; } } + public bool IsfeedswitchChange { get { bool bRet = Infomation[(int)eStatusInfo.feedswitch, 1]; Infomation[(int)eStatusInfo.feedswitch, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.feedswitch, 1] = value; } } + #endregion + + #region Second Byte(error information) + /// + /// [Error Information] + /// IsMacroExecuting + /// FALSE : Not Excuting, TRUE : Excuting + /// + public bool IsMacroExecuting { get { return Infomation[(int)eStatusInfo.MacroExecuting, 0]; } set { Infomation[(int)eStatusInfo.MacroExecuting, 0] = value; } } + public bool IsMacroExecutingChange { get { bool bRet = Infomation[(int)eStatusInfo.MacroExecuting, 1]; Infomation[(int)eStatusInfo.MacroExecuting, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.MacroExecuting, 1] = value; } } + /// + /// [Error Information] + /// Panel switch + /// FALSE : OFF, TRUE : ON + /// + public bool IsPanelswitch { get { return Infomation[(int)eStatusInfo.Panelswitch, 0]; } set { Infomation[(int)eStatusInfo.Panelswitch, 0] = value; } } + public bool IsPanelswitchChange { get { bool bRet = Infomation[(int)eStatusInfo.Panelswitch, 1]; Infomation[(int)eStatusInfo.Panelswitch, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.Panelswitch, 1] = value; } } + /// + /// [Error Information] + /// Mechanical Error + /// (Cover oen, Cutter jam) + /// FALSE : No, TRUE : Yes + /// + public bool IsMechanicalError { get { return Infomation[(int)eStatusInfo.MechanicalErr, 0]; } set { Infomation[(int)eStatusInfo.MechanicalErr, 0] = value; } } + public bool IsMechanicalErrorChange { get { bool bRet = Infomation[(int)eStatusInfo.MechanicalErr, 1]; Infomation[(int)eStatusInfo.MechanicalErr, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.MechanicalErr, 1] = value; } } + /// + /// [Error Information] + /// Cutter jam + /// FALSE : No, TRUE : Yes + /// + public bool IsCutterJam { get { return Infomation[(int)eStatusInfo.CutterJam, 0]; } set { Infomation[(int)eStatusInfo.CutterJam, 0] = value; } } + public bool IsCutterJamChange { get { bool bRet = Infomation[(int)eStatusInfo.CutterJam, 1]; Infomation[(int)eStatusInfo.CutterJam, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.CutterJam, 1] = value; } } + /// + /// [Error Information] + /// Unrecoverable Error + /// FALSE : No, TRUE : Yes + /// + public bool IsUnrecoverableErr { get { return Infomation[(int)eStatusInfo.UnrecoverableErr, 0]; } set { Infomation[(int)eStatusInfo.UnrecoverableErr, 0] = value; } } + public bool IsUnrecoverableErrChange { get { bool bRet = Infomation[(int)eStatusInfo.UnrecoverableErr, 1]; Infomation[(int)eStatusInfo.UnrecoverableErr, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.UnrecoverableErr, 1] = value; } } + /// + /// [Error Information] + /// Auto-Recoverable Error detected + /// FALSE : No, TRUE : Yes + /// + public bool IsAutoRecoverableErr { get { return Infomation[(int)eStatusInfo.AutoRecoverableErr, 0]; } set { Infomation[(int)eStatusInfo.AutoRecoverableErr, 0] = value; } } + public bool IsAutoRecoverableErrChange { get { bool bRet = Infomation[(int)eStatusInfo.AutoRecoverableErr, 1]; Infomation[(int)eStatusInfo.AutoRecoverableErr, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.AutoRecoverableErr, 1] = value; } } + #endregion + + #region Third byte(paper detector information) + /// + /// [paper detector information] + /// Roll paper near end detector + /// FALSE : Paper present , TRUE : No paper + /// + private bool IsPaperNearEnd_1 { get { return Infomation[(int)eStatusInfo.PaperNearEnd_1, 0]; } set { Infomation[(int)eStatusInfo.PaperNearEnd_1, 0] = value; } } + private bool IsPaperNearEnd_1Change { get { bool bRet = Infomation[(int)eStatusInfo.PaperNearEnd_1, 1]; Infomation[(int)eStatusInfo.PaperNearEnd_1, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.PaperNearEnd_1, 1] = value; } } + /// + /// [paper detector information] + /// Roll paper near end detector + /// FALSE : Paper present , TRUE : No paper + /// + private bool IsPaperNearEnd_2 { get { return Infomation[(int)eStatusInfo.PaperNearEnd_2, 0]; } set { Infomation[(int)eStatusInfo.PaperNearEnd_2, 0] = value; } } + private bool IsPaperNearEnd_2Change { get { bool bRet = Infomation[(int)eStatusInfo.PaperNearEnd_2, 1]; Infomation[(int)eStatusInfo.PaperNearEnd_2, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.PaperNearEnd_2, 1] = value; } } + /// + /// [paper detector information] + /// Roll paper near end detector + /// FALSE : Paper present , TRUE : No paper + /// + public bool IsPaperNearEnd { get { if (IsPaperNearEnd_1 && IsPaperNearEnd_2)return true; else return false; } set { IsPaperNearEnd_1 = value; IsPaperNearEnd_2 = value; } } + public bool IsPaperNearEndChange { get { if (IsPaperNearEnd_1Change && IsPaperNearEnd_2Change)return true; else return false; } set { IsPaperNearEnd_1Change = value; IsPaperNearEnd_2Change = value; } } + + /// + /// [paper detector information] + /// Roll paper end detector + /// FALSE : Paper present , TRUE : No paper + /// + private bool IsPaperEnd_1 { get { return Infomation[(int)eStatusInfo.PaperEnd_1, 0]; } set { Infomation[(int)eStatusInfo.PaperEnd_1, 0] = value; } } + private bool IsPaperEnd_1Change { get { bool bRet = Infomation[(int)eStatusInfo.PaperEnd_1, 1]; Infomation[(int)eStatusInfo.PaperEnd_1, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.PaperEnd_1, 1] = value; } } + /// + /// [paper detector information] + /// Roll paper end detector + /// FALSE : Paper present, TRUE : No paper + /// + private bool IsPaperEnd_2 { get { return Infomation[(int)eStatusInfo.PaperEnd_2, 0]; } set { Infomation[(int)eStatusInfo.PaperEnd_2, 0] = value; } } + private bool IsPaperEnd_2Change { get { bool bRet = Infomation[(int)eStatusInfo.PaperEnd_2, 1]; Infomation[(int)eStatusInfo.PaperEnd_2, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.PaperEnd_2, 1] = value; } } + /// + /// [paper detector information] + /// Roll paper end detector + /// FALSE : Paper present, TRUE : No paper + /// + public bool IsPaperEnd { get { if (IsPaperEnd_1 && IsPaperEnd_2) return true; else return false; } set { IsPaperEnd_1 = value; IsPaperEnd_2 = value; } } + public bool IsPaperEndChange { get { if (IsPaperEnd_1Change && IsPaperEnd_2Change) return true; else return false; } set { IsPaperEnd_1Change = value; IsPaperEnd_2Change = value; } } + #endregion + + #region Fourth byte (paper detector information) + /// + /// [paper detector information] + /// paper detector information + /// FW down load Fail + /// FALSE : Not Fail, TRUE : Fail + /// + public bool IsFWdownLoadFail { get { return Infomation[(int)eStatusInfo.FWdownLoadFail, 0]; } set { Infomation[(int)eStatusInfo.FWdownLoadFail, 0] = value; } } + public bool IsFWdownLoadFailChange { get { bool bRet = Infomation[(int)eStatusInfo.FWdownLoadFail, 1]; Infomation[(int)eStatusInfo.FWdownLoadFail, 1] = false; return bRet; } set { Infomation[(int)eStatusInfo.FWdownLoadFail, 1] = value; } } + #endregion + + #region 형변환 + private long chararry2Hexstr(char[] src, int st, out string dest) + { + long nRet = 0; + char[] temp = null; + + dest = ""; + + if (src.Length < 1) + return 0; + + temp = new char[src.Length - st]; + for (int i = 0; i < src.Length - st; i++) + { + temp[i] = src[i + st]; + string tt = src[i + st].ToString(); + dest += String.Format("{0:X}", tt); + } + //temp.CopyTo(src, st); + + //bit + //string sbit = int.Parse("0100", System.Globalization.NumberStyles.AllowHexSpecifier) & (2 ^ 0); + + return nRet; + } + + // String To Hex + private int string2Hex(string src) + { + return int.Parse(src, System.Globalization.NumberStyles.HexNumber); + } + public string string2Hexstr(string src) + { + string sRet = ""; + char[] values = src.ToCharArray(); + foreach (char letter in values) + { + uint value = Convert.ToUInt32(letter); + string hexstr = string.Format("{0:X2}", value); + sRet += hexstr; + } + return sRet; + } + // Hex To String + private string Hex2string(int number) + { + return Convert.ToString(number, 16).ToUpper().PadLeft(2, '0'); + } + // Byte[] To UInt32 + private UInt32 Byte2UInt32SmallEndian(byte[] src, int i) + { + return Convert.ToUInt32(src[i] + (src[i + 1] << 8) + (src[i + 2] << 16) + (src[i + 3] << 24)); + } + // Byte[] To UInt32 + private UInt32 Byte2UInt32BigEndian(byte[] src, int i) + { + return Convert.ToUInt32(src[i + 3] + (src[i + 2] << 8) + (src[i + 1] << 16) + (src[i] << 24)); + } + + //UInt32 To Byte[] Small-Endian + private void Uint322Byte(byte[] dstByte, UInt32 srcuint, int start) + { + dstByte[3 + start] = (byte)((srcuint & 0xff000000) >> 24); + dstByte[2 + start] = (byte)((srcuint & 0x00ff0000) >> 16); + dstByte[1 + start] = (byte)((srcuint & 0x0000ff00) >> 8); + dstByte[0 + start] = (byte)((srcuint & 0x000000ff)); + } + //UInt32 To Byte[] Big-Endian + private void UInt32ToByteBif(byte[] dstByte, UInt32 srcuint, int start) + { + dstByte[0 + start] = (byte)((srcuint & 0xff000000) >> 24); + dstByte[1 + start] = (byte)((srcuint & 0x00ff0000) >> 16); + dstByte[2 + start] = (byte)((srcuint & 0x0000ff00) >> 8); + dstByte[3 + start] = (byte)((srcuint & 0x000000ff)); + } + + //byte[] To string + public String Byte2string(byte[] src) + { + //string sRet = Encoding.Default.GetString(src); + return Encoding.Default.GetString(src);// UnicodeEncoding.ASCII.GetString(src); + } + public String Byte2string(byte[] src, int index, int size) + { + string sRet = ""; + char sz; + for (int i = index; i < src.Length; i++) + { + sz = Convert.ToChar(src[i]); + sRet += sz.ToString(); + } + return sRet;// UnicodeEncoding.ASCII.GetString(src, index, size); + } + + //string To Byte[] + public Byte[] string2byte(String src) + { + return Encoding.Default.GetBytes(src); //UnicodeEncoding.ASCII.GetBytes(src); + } + //string To Byte[] + public int string2byte(String src, int sindex, int slength, byte[] dst, int bindex) + { + return UnicodeEncoding.ASCII.GetBytes(src, sindex, slength, dst, bindex); + } + + /// + /// 문자열을 byte[]으로 변환 + /// + /// + /// + private byte[] ConvertToByteArrayFromString(string str) + { + byte[] temp = Encoding.Default.GetBytes(str); + + if (temp.Length % 16 != 0) + { + byte[] temp2 = new byte[((temp.Length / 16) + 1) * 16]; + Buffer.BlockCopy(temp, 0, temp2, 0, temp.Length); + return temp2; + } + else + { + return temp; + } + } + + public byte[] hex2Byte(string hex) + { + byte[] bytes = new byte[hex.Length / 2]; + for (int i = 0; i < bytes.Length; i++) + { + try + { + bytes[i] = Convert.ToByte(hex.Substring(i * 2, 2), 16); + } + catch + { + throw new ArgumentException("hex is not a valid hex number!", "hex"); + } + } return bytes; + } + + public string str2bitstr(string sValue, int nByteLen) + { + //char bit; + + string sRet = ""; + + string hexstr = string2Hexstr(sValue); + long value = string2Hex(hexstr); + sRet += Convert.ToString(value, 2).PadLeft(8, '0'); + + int d = Math.Abs((sRet.Length % 8) - 8); + if (d != 8 && d != 0) + sRet = sRet.PadLeft(d + sRet.Length, '0'); + + return sRet; + } + #endregion + } +} diff --git a/Agent/KPS/Properties/AssemblyInfo.cs b/Agent/KPS/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d468b1d --- /dev/null +++ b/Agent/KPS/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("KPS")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("KPS")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("aff75872-6f40-425a-8ddc-1126ea9b3a9c")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Agent/KPS/SerialPrint.cs b/Agent/KPS/SerialPrint.cs new file mode 100644 index 0000000..71ec4ef --- /dev/null +++ b/Agent/KPS/SerialPrint.cs @@ -0,0 +1,587 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO.Ports; + +using Cosmos.Common; +using Cosmos.UserFrame; +using Cosmos.BaseFrame; + +namespace Cosmos.KPS +{ + class SerialPrint + { + PrinterCommand prtCmd = new PrinterCommand(); + + private SerialPort ComPort; + public bool IsPortOpened + { + get { if (ComPort == null) { return false; } else { return ComPort.IsOpen; } } + } + + #region Printer OPEN / CLOSE + public int DeviceOpen(string sPortNum, int iBaudRate) + { + int iRet = UserCom.NG; + try + { + if(ComPort == null) + { + ComPort = new SerialPort(); + + ComPort.DataReceived += new SerialDataReceivedEventHandler(ComPort_DataReceived); + ComPort.PinChanged += new SerialPinChangedEventHandler(ComPort_PinChanged); + ComPort.ErrorReceived += new SerialErrorReceivedEventHandler(ComPort_ErrorReceived); + + ComPort.NewLine = "\r\n"; + ComPort.Encoding = System.Text.Encoding.GetEncoding("ks_c_5601-1987"); + } + + if (!IsPortOpened) DeviceClose(); + + ComPort.WriteBufferSize = 1024 * 1024; + ComPort.PortName = sPortNum; + ComPort.BaudRate = iBaudRate; + ComPort.DataBits = 8; + ComPort.StopBits = StopBits.One; + ComPort.Parity = Parity.None; + ComPort.Handshake = Handshake.RequestToSend; + + ComPort.ReadTimeout = 500; + ComPort.WriteTimeout = 2000; + + ComPort.RtsEnable = true; + ComPort.DtrEnable = true; + + if(!ComPort.IsOpen) + { + ComPort.Open(); + } + + iRet = ComPort.IsOpen == true ? UserCom.OK : UserCom.NG; + + return iRet; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)) + ex.Message); + return -99; + } + } + + public int DeviceClose() + { + int iRet = UserCom.NG; + try + { + if(!IsPortOpened) + { + return UserCom.OK; + } + + ComPort.Close(); + if(IsPortOpened) + { + System.Threading.Thread.Sleep(1000); + ComPort.Close(); + } + + iRet = IsPortOpened == false ? UserCom.OK : UserCom.NG; + + return iRet; + } + 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 -99; + } + } + #endregion + + #region Serial Port Event + void ComPort_DataReceived(object sender, SerialDataReceivedEventArgs e) + { + + } + + void ComPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e) + { + } + + void ComPort_PinChanged(object sender, SerialPinChangedEventArgs e) + { + } + #endregion + + #region Status Check + public int PrinterStatusCheckBySerial(string sType) + { + int iRet = UserCom.NG; + string sResp = ""; + + try + { + #region Printer CHK1 + if(sType == "CHK1") + { + // 프린터 초기화 + TransmitCommand(PosConst.ESCP_COMMAND.INITIALIZE_PRINTER); + System.Threading.Thread.Sleep(50); + + // Cover Check + TransmitCommand(PosConst.ESCP_COMMAND.TRANSMIT_OFFLINE_STATUS); + System.Threading.Thread.Sleep(50); + sResp = ComPort.ReadExisting(); + if(sResp.Length > 0) + { + byte[] respByte = Encoding.Default.GetBytes(sResp); + if(respByte[0] == PosConst.ESCP_COMMAND.STATUS_OK[0]) + { + iRet = UserCom.OK; + } + else + { + iRet = UserCom.NG; + 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 (함수명)) + "COVER Opened"); + } + } + return iRet; + } + #endregion + + #region Printer CHK2 + if(sType == "CHK2") + { + // 프린터 초기화 + TransmitCommand(PosConst.ESCP_COMMAND.INITIALIZE_PRINTER); + System.Threading.Thread.Sleep(50); + + // Paper Check + TransmitCommand(PosConst.ESCP_COMMAND.TRANSMIT_CONTINUOUS_PAPER_DETECTOR_STATUS); + System.Threading.Thread.Sleep(50); + sResp = ComPort.ReadExisting(); + if(sResp.Length > 0) + { + byte[] respByte = Encoding.Default.GetBytes(sResp); + if(respByte[0] == PosConst.ESCP_COMMAND.STATUS_OK[0]) + { + iRet = UserCom.OK; + } + else + { + iRet = UserCom.NG; + + String sRecvData = Encoding.Default.GetString(respByte); + + string NEAR_END = Encoding.Default.GetString(new byte[] { 0x1E }); + string NOT_PRESENT = Encoding.Default.GetString(new byte[] { 0x72 }); + + string sErrMsg = ""; + if (sRecvData == NEAR_END) sErrMsg = "PAPER_NEAR_END"; + else if (sRecvData == NOT_PRESENT) sErrMsg = "PAPER_NOT_PRESENT"; + else sErrMsg = "ERC_ERROR"; + + 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 (함수명)) + sErrMsg); + } + } + return iRet; + } + #endregion + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, 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 (함수명)) + "StatusCheck 실패"); + } + return iRet; + } + #endregion + + #region 공통 모듈 + private void TransmitCommand(byte[] aCmd) + { + if(IsPortOpened) + { + ComPort.Write(aCmd, 0, aCmd.Length); + } + } + #endregion + + #region Cut Paper + public bool CutPaper(int LineFeedCnt) + { + long nRet = -1; + try + { + for (int i = 0; i < LineFeedCnt; i++) + { + TransmitCommand(PosConst.ESCP_COMMAND.LINE_FEED); + } + + TransmitCommand(PosConst.ESCP_COMMAND.PAPER_CUT); + System.Threading.Thread.Sleep(10); + TransmitCommand(PosConst.ESCP_COMMAND.LINE_FEED); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Cut Paper Exception"); + } + return nRet == BaseCom.OK ? true : false; + } + #endregion + + #region 문자열 출력 + /// + /// Print Text + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public bool TextPrint(string sValue, PrinterCommand.Alignment eAlignment, PrinterCommand.CharactersizeV eVerticalSize, PrinterCommand.CharactersizeH eHorizontalSize, PrinterCommand.TextBold eBold, PrinterCommand.TextUnderLine eTextUnderLine, PrinterCommand.TextReverseMode eTextReverseMode, bool bLineFeed) + { + bool bRet = false; + string sCmdctrlTmp = ""; + + try + { + // 확대 Command를 설정 + sCmdctrlTmp = GetCharactersizeCmd(eVerticalSize, eHorizontalSize); + + // UnerLine + sCmdctrlTmp += GetUnderLineCmd(eTextUnderLine); + + // Bold + sCmdctrlTmp += GetBoldCmd(eBold); + + // 정렬 + sCmdctrlTmp += GetAlignment(eAlignment); + + // Reverse + sCmdctrlTmp += GetReverseCmd(eTextReverseMode); + + // 출력 + byte[] byteCmdctrl = Encoding.Default.GetBytes(sCmdctrlTmp); + TransmitCommand(byteCmdctrl); // Command 전송 + + byte[] byteData = Encoding.Default.GetBytes(sValue); + TransmitCommand(byteData); // 출력 Data 전송 + + if(bLineFeed == true) + { + TransmitCommand(PosConst.ESCP_COMMAND.LINE_FEED); + + } + + bRet = true; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRet; + } + /// + /// Print Text + /// + /// + /// + /// + /// + /// + /// + /// + /// + public bool TextPrint(string sValue, PrinterCommand.Alignment eAlignment, PrinterCommand.CharactersizeV eVerticalSize, PrinterCommand.CharactersizeH eHorizontalSize, PrinterCommand.TextBold eBold, PrinterCommand.TextUnderLine eTextUnderLine, bool bLineFeed) + { + return TextPrint(sValue, eAlignment, eVerticalSize, eHorizontalSize, eBold, eTextUnderLine, PrinterCommand.TextReverseMode.Nomal, bLineFeed); + } + /// + /// Print Text + /// + /// + /// + /// + public bool TextPrint(string sValue, bool bLineFeed) + { + return TextPrint(sValue, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, PrinterCommand.TextBold.Nomal, PrinterCommand.TextUnderLine.Nomal, PrinterCommand.TextReverseMode.Nomal, bLineFeed); + } + /// + /// Print Text + /// + /// + /// + /// + /// + public bool TextPrint(string sValue, PrinterCommand.Alignment eAlignment, bool bLineFeed) + { + return TextPrint(sValue, eAlignment, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, PrinterCommand.TextBold.Nomal, PrinterCommand.TextUnderLine.Nomal, PrinterCommand.TextReverseMode.Nomal, bLineFeed); + } + /// + /// Print Text + /// + /// + /// + /// + /// + /// + /// + public bool TextPrint(string sValue, PrinterCommand.Alignment eAlignment, PrinterCommand.CharactersizeV eVerticalSize, PrinterCommand.CharactersizeH eHorizontalSize, bool bLineFeed) + { + return TextPrint(sValue, eAlignment, eVerticalSize, eHorizontalSize, PrinterCommand.TextBold.Nomal, PrinterCommand.TextUnderLine.Nomal, PrinterCommand.TextReverseMode.Nomal, bLineFeed); + } + /// + /// Print Text + /// + /// + /// + /// + /// + /// + public bool TextPrint(string sValue, PrinterCommand.Alignment eAlignment, PrinterCommand.TextBold eBold, bool bLineFeed) + { + return TextPrint(sValue, eAlignment, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, eBold, PrinterCommand.TextUnderLine.Nomal, PrinterCommand.TextReverseMode.Nomal, bLineFeed); + } + /// + /// Print Text + /// + /// + /// + /// + /// + /// + public bool TextPrint(string sValue, PrinterCommand.Alignment eAlignment, PrinterCommand.TextUnderLine eTextUnderLine, bool bLineFeed) + { + return TextPrint(sValue, eAlignment, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, PrinterCommand.TextBold.Nomal, eTextUnderLine, PrinterCommand.TextReverseMode.Nomal, bLineFeed); + } + /// + /// Print Text + /// + /// + /// + /// + /// + /// + public bool TextPrint(string sValue, PrinterCommand.Alignment eAlignment, PrinterCommand.TextReverseMode eTextReverseMode, bool bLineFeed) + { + return TextPrint(sValue, PrinterCommand.Alignment.Left, PrinterCommand.CharactersizeV.V_1, PrinterCommand.CharactersizeH.H_1, PrinterCommand.TextBold.Nomal, PrinterCommand.TextUnderLine.Nomal, eTextReverseMode, bLineFeed); + } + + private string GetCharactersizeCmd(PrinterCommand.CharactersizeV eVerticalSize, PrinterCommand.CharactersizeH eHorizontalSize) + { + string sRet = ""; + + try + { + int Hvalue = 0; + int Vvalue = 0; + + switch (eVerticalSize) + { + case PrinterCommand.CharactersizeV.V_1: Vvalue = 0; break; + case PrinterCommand.CharactersizeV.V_2: Vvalue = 1; break; + case PrinterCommand.CharactersizeV.V_3: Vvalue = 2; break; + case PrinterCommand.CharactersizeV.V_4: Vvalue = 3; break; + case PrinterCommand.CharactersizeV.V_5: Vvalue = 4; break; + case PrinterCommand.CharactersizeV.V_6: Vvalue = 5; break; + case PrinterCommand.CharactersizeV.V_7: Vvalue = 6; break; + case PrinterCommand.CharactersizeV.V_8: Vvalue = 7; break; + default: Vvalue = 0; break; + } + + switch (eHorizontalSize) + { + case PrinterCommand.CharactersizeH.H_1: Hvalue = 16 * 0; break; + case PrinterCommand.CharactersizeH.H_2: Hvalue = 16 * 1; break; + case PrinterCommand.CharactersizeH.H_3: Hvalue = 16 * 2; break; + case PrinterCommand.CharactersizeH.H_4: Hvalue = 16 * 3; break; + case PrinterCommand.CharactersizeH.H_5: Hvalue = 16 * 4; break; + case PrinterCommand.CharactersizeH.H_6: Hvalue = 16 * 5; break; + case PrinterCommand.CharactersizeH.H_7: Hvalue = 16 * 6; break; + case PrinterCommand.CharactersizeH.H_8: Hvalue = 16 * 7; break; + default: Hvalue = 16 * 0; break; + } + sRet = Encoding.Default.GetString(prtCmd.ESC_VHMAG) + Convert.ToChar(Vvalue + Hvalue).ToString(); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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; + } + /// + /// 진한 문자(Bold) + /// + /// + /// + private string GetBoldCmd(PrinterCommand.TextBold eBold) + { + string sRet = ""; + try + { + switch (eBold) + { + case PrinterCommand.TextBold.Nomal: sRet = Encoding.Default.GetString(prtCmd.ESC_BOLD_OFF); break; + case PrinterCommand.TextBold.Bold: sRet = Encoding.Default.GetString(prtCmd.ESC_BOLD_ON); break; + default: sRet = Encoding.Default.GetString(prtCmd.ESC_BOLD_OFF); break; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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; + } + /// + /// UnderLine + /// + /// + /// + /// + private string GetUnderLineCmd(PrinterCommand.TextUnderLine eUnderLine, int nDot) + { + string sRet = ""; + try + { + if (eUnderLine == PrinterCommand.TextUnderLine.UnderLine) + { + if (nDot == 2) + { + sRet = Encoding.Default.GetString(prtCmd.ESC_UNDERLINEON1DOT); + } + else + { + sRet = Encoding.Default.GetString(prtCmd.ESC_UNDERLINEON2DOT); + } + } + else + { + sRet = Encoding.Default.GetString(prtCmd.ESC_UNDERLINEOFF); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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; + } + /// + /// UnderLine Text + /// + /// + /// + private string GetUnderLineCmd(PrinterCommand.TextUnderLine eUnderLine) + { + return GetUnderLineCmd(eUnderLine, 1); + } + /// + /// 반전 텍스트 + /// + /// + /// + private string GetReverseCmd(PrinterCommand.TextReverseMode eTextReverseMode) + { + string sRet = ""; + try + { + switch (eTextReverseMode) + { + case PrinterCommand.TextReverseMode.ReverseMode: sRet = Encoding.Default.GetString(prtCmd.ESC_REVERSE_MODE_ON); break; + default: sRet = Encoding.Default.GetString(prtCmd.ESC_REVERSE_MODE_OFF); break; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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; + } + /// + /// 정렬 Command를 가져온다. + /// + /// + /// + private string GetAlignment(PrinterCommand.Alignment eAlignment) + { + string sRet = ""; + try + { + switch (eAlignment) + { + case PrinterCommand.Alignment.Center: + sRet = Encoding.Default.GetString(prtCmd.ESC_CENTER); + break; + case PrinterCommand.Alignment.Right: + sRet = Encoding.Default.GetString(prtCmd.ESC_RIGHT); + break; + case PrinterCommand.Alignment.Left: + default: + sRet = Encoding.Default.GetString(prtCmd.ESC_LEFT); + break; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 + } +} diff --git a/Agent/KPS/frmKPS.Designer.cs b/Agent/KPS/frmKPS.Designer.cs new file mode 100644 index 0000000..5eb7b29 --- /dev/null +++ b/Agent/KPS/frmKPS.Designer.cs @@ -0,0 +1,64 @@ +namespace Cosmos.KPS +{ + partial class frmKPS + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmKPS)); + this.oposPrinter = new AxOposPOSPrinter_CCO.AxOPOSPOSPrinter(); + ((System.ComponentModel.ISupportInitialize)(this.oposPrinter)).BeginInit(); + this.SuspendLayout(); + // + // oposPrinter + // + this.oposPrinter.Enabled = true; + this.oposPrinter.Location = new System.Drawing.Point(30, 46); + this.oposPrinter.Name = "oposPrinter"; + this.oposPrinter.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("oposPrinter.OcxState"))); + this.oposPrinter.Size = new System.Drawing.Size(129, 52); + this.oposPrinter.TabIndex = 0; + // + // frmKPS + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(284, 262); + this.Controls.Add(this.oposPrinter); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "frmKPS"; + this.ShowInTaskbar = false; + this.Text = "frmKPS"; + ((System.ComponentModel.ISupportInitialize)(this.oposPrinter)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private AxOposPOSPrinter_CCO.AxOPOSPOSPrinter oposPrinter; + } +} \ No newline at end of file diff --git a/Agent/KPS/frmKPS.cs b/Agent/KPS/frmKPS.cs new file mode 100644 index 0000000..8716620 --- /dev/null +++ b/Agent/KPS/frmKPS.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace Cosmos.KPS +{ + public partial class frmKPS : Form + { + public frmKPS() + { + InitializeComponent(); + + base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true); + //this.UpdateStyles(); + } + + public AxOposPOSPrinter_CCO.AxOPOSPOSPrinter OposPrinter + { + get + { + return this.oposPrinter; + } + } + } +} diff --git a/Agent/KPS/frmKPS.resx b/Agent/KPS/frmKPS.resx new file mode 100644 index 0000000..081181b --- /dev/null +++ b/Agent/KPS/frmKPS.resx @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAIQAAAAIB + AAAAAQAAAAAAAAAAAAAAAAwAAAAACQAAVQ0AAGAFAAAL + + + \ No newline at end of file diff --git a/Agent/MasterDown/Activator.cs b/Agent/MasterDown/Activator.cs new file mode 100644 index 0000000..6a7e45b --- /dev/null +++ b/Agent/MasterDown/Activator.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : MasterDown 관련 클래스 Activator +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.Service +{ + public class Activator : InitServiceAbstract + { + /// + /// Define main entrance point of project load. (프로젝트 로드의 주진입점을 정의합니다.) + /// + public Activator() + { + + } + + /// + /// + /// + /// + /// + public override object InitServiceInstance(string sClassNm) + { + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Starting !!!"); + + object retObj = null; + + //클래스 찾아오기 위함 + switch (sClassNm) + { + case ServiceLists.AGENT_BACKGROUND_DOWN.BACKGROUND_DOWN_MAIN: + { + Cosmos.BackgroundDown.BackgroundDownMain agentClass = new Cosmos.BackgroundDown.BackgroundDownMain(); + retObj = agentClass; + break; + } + } + + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Completed !!!"); + + return retObj; + + } + } +} diff --git a/Agent/MasterDown/BackgroundDown.csproj b/Agent/MasterDown/BackgroundDown.csproj new file mode 100644 index 0000000..2a4c691 --- /dev/null +++ b/Agent/MasterDown/BackgroundDown.csproj @@ -0,0 +1,110 @@ + + + + + Debug + AnyCPU + {791617B7-64DA-4743-B8F1-CA413607FC31} + Library + Properties + Cosmos.BackgroundDown + Agent.BackgroundDown + v4.0 + 512 + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\BIN\Cosmos.BaseFrame.dll + + + False + ..\..\..\BIN\Cosmos.ServiceProvider.dll + + + ..\..\..\BIN\Cosmos.UserFrame.dll + + + False + ..\..\..\BIN\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + Form + + + frmPosIrtMessage.cs + + + + + + + + + + {670a81be-cee3-4c29-846d-a37652ca270d} + CommonManager + + + {a5b7accd-79eb-4261-bd36-01ab484ad8e3} + Common + + + + + frmPosIrtMessage.cs + + + + + + + + copy .\IC\Agent.BackgroundDown.dll .\Agent.BackgroundDown.dll + + + copy .\Agent.BackgroundDown.dll .\IC\Agent.BackgroundDown.dll + + + \ No newline at end of file diff --git a/Agent/MasterDown/BackgroundDownMain.cs b/Agent/MasterDown/BackgroundDownMain.cs new file mode 100644 index 0000000..3e4ee1f --- /dev/null +++ b/Agent/MasterDown/BackgroundDownMain.cs @@ -0,0 +1,2300 @@ +using System; +using System.Collections.Generic; +using System.Collections; +using System.Linq; +using System.Text; +using System.Threading; +using System.Reflection; + +using Newtonsoft.Json; + +using Cosmos.Common; +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using System.Data; +using Cosmos.CommonManager; +using System.IO; + +namespace Cosmos.BackgroundDown +{ + class BackgroundDownMain : IWatcher, IWatcherBack + { + #region 클래스 변수 선언 + /// + /// StateServer Object (StateServer 객체) + /// + private StateServer StateObject = (StateServer)StateServer.GetInstance(); + + /// + /// POS Status Value (POS 상태값) + /// + private PosStatus m_cPosStatus = null; + + /// + /// Master Down Thread (Master Down 스레드) + /// + private Thread m_tBGDownProc = null; + + /// + /// Master Down Proc Operation Yes/No (Master Down Proc 작동여부) + /// + private bool m_BGDOWNProcRunning = false; + + /// + /// Thread Waiting Time (스레드 대기시간 ms) + /// + private int m_ThreadSleepTerm = 1000 * 60 * 60; + + /// + /// 다운로드 모듈 + /// + private Svr2Tran m_cSvr2Tran = null; + /// + /// 데이터베이스 모듈 + /// + private DatabaseMssql m_cSqlDbService = null; + /// + /// FTP 모듈 + /// + private NetworkFtp m_cNetworkFTP = null; + + /// + /// MSSQL DB 관련 객체 + /// + private static SqlDB sqlDb = null; + + /// + /// POS 프로그램 재기동 여부 체크용 + /// + private static bool m_bPGMReboot = false; + + // 전송 소켓 + private static TcpSocket m_sendSocket = null; + + private Hashtable m_htBGMasterList = null; + #endregion 클래스 변수 선언 + + #region 생성자 + public BackgroundDownMain() + { + SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출 + + m_cPosStatus = (PosStatus)StateObject.POS; + + m_cSqlDbService = new DatabaseMssql(); + m_cSvr2Tran = new Svr2Tran(); + m_cNetworkFTP = new NetworkFtp(); + } + #endregion + + #region Master Down 데몬 기동/종료 + public void Start() + { + try + { + m_tBGDownProc = new Thread(new ThreadStart(ThreadBackgroundDownRun)); + m_BGDOWNProcRunning = true; + m_tBGDownProc.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_BGDOWNProcRunning = false; + + int count = 0; + while(count < 10) + { + if (m_tBGDownProc != null && m_tBGDownProc.IsAlive) m_BGDOWNProcRunning = false; + else break; + + count++; + Thread.Sleep(100); + } + + 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 BackgroundDown Service Stop!!!"); + m_tBGDownProc.Abort(); + } + } + 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 프로그램 적용을 위한 재부팅 채크 + public bool PGMReBootCheck() + { + return m_bPGMReboot; + } + #endregion + + #region BackgroundDown Main + private void ThreadBackgroundDownRun() + { + int iResult = UserCom.NG1; + string sRet = UserCom.RST_ERR; + try + { + while(m_BGDOWNProcRunning) + { + 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 (함수명)) + "Backgroup Master Down Running"); + + #region 1 - 마스터 Download + // 선불POS 이거나 후불MAIN POS 일 경우에만 백그라운드 마스터 다운로드 + if (m_cPosStatus.Base.PosType != PosConst.POS_TYPE.DEFERRED_PAYMENT || + (m_cPosStatus.Base.PosType == PosConst.POS_TYPE.DEFERRED_PAYMENT && m_cPosStatus.Base.PosCommunicationType == PosConst.MAIN_POS_DIV.MAIN_POS)) + { + if (m_cPosStatus.Base.MasterDown == "1") + { + // 마스터 배치 적용 성공 시 갱신될 시간 + String sToBeMstBatchDownTime = DateTime.Now.ToString("yyyyMMddHHmmss"); + Hashtable htBackgroundMaster = MasterListManager.GetBackgroundMaster(); + int nFailedCnt = 0; + int nSuccessCnt = 0; + bool bResult = false; + + int nTotalMstCnt = htBackgroundMaster.Count; + for (int nLoop = 0; nLoop < nTotalMstCnt; nLoop++) + { + // Dynamically call method. + Type type = typeof(BackgroundDownMain); + MethodInfo method = type.GetMethod(htBackgroundMaster[nLoop].ToString()); + + iResult = (int)method.Invoke(this, new object[] { m_cPosStatus.Base.MstBatchDownDate + , m_cPosStatus.Base.StoreNo + , m_cPosStatus.Base.BrandCd + , m_cPosStatus.Base.StoreNo }); + if (iResult < 0) + { + nFailedCnt++; + 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 (함수명)) + htBackgroundMaster[nLoop].ToString() + " Master(Background) download and insert failure"); + } + else if (iResult > 0) + { + nSuccessCnt++; + } + } + + if (nFailedCnt == 0 && nSuccessCnt > 0) + { + m_cPosStatus.Base.MstBatchDownDate = sToBeMstBatchDownTime; + + // PosSaleInfo.ini 저장 + UpdatePosSaleInfo(); + } + } + } + #endregion + + #region 2 - 프로그램 Download + { + sRet = UserCom.RST_ERR; + sRet = LF_ProgramDownLoad_Search(); // DownLoad 목록 조회 + sRet = LF_ProgramDownLoad(); // DownLoad 실행 + //sRet = PGMUpdate_Apply(PosConst.PGM_UPDATE_DOWN_DIV.UPDATE); // 프로그램 적용 + } + #endregion + + #region 마스터 수신 SQL 보정시 삭제 + // update by wani(20170818) - Background Master Download Break; + m_BGDOWNProcRunning = false; + #endregion + + int nNowSleepTerm = 0; + while(nNowSleepTerm < m_ThreadSleepTerm) + { + if (m_BGDOWNProcRunning == false) break; + Thread.Sleep(100); + nNowSleepTerm += 100; + } + } + } + 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 Hashtable GetPosMasterReqData(string sMasterDiv, string sUpdDt, string sStoreCd, string sSubStoreCd, string ProcCd) + { + Hashtable htReqData = null; + try + { + htReqData = new Hashtable(); + + // INQ Type 설정 + htReqData.Add(Column.IQ_POSMASTER_REQ.DATA.InqType, ItemConst.IRT_INQ_TYPE.POSMASTER_REQ); + // 마스터 요청 구분 설정 + htReqData.Add(Column.IQ_POSMASTER_REQ.DATA.MasterDiv, sMasterDiv); + // 점포코드 설정 + htReqData.Add(Column.IQ_POSMASTER_REQ.DATA.StorCd, sStoreCd); + // SUB 점포코드 설정 + htReqData.Add(Column.IQ_POSMASTER_REQ.DATA.SubStorCd, sSubStoreCd); + // 변경 일시 설정 + htReqData.Add(Column.IQ_POSMASTER_REQ.DATA.UpdDt, sUpdDt); + // 전송데이터 Count 설정 + htReqData.Add(Column.IQ_POSMASTER_REQ.DATA.DataCount, string.Empty); + // 요청코드 설정 + htReqData.Add(Column.IQ_POSMASTER_REQ.DATA.ProcCd, ProcCd); + // 응답코드 설정 + htReqData.Add(Column.IQ_POSMASTER_REQ.DATA.ResCd, string.Empty); + } + 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 htReqData; + } + #endregion 마스터 요청 전문 생성 + + #region 마스터 요청/응답 전문 송수신 모듈 + /// + /// 마스터 요청 전문 SEND / RECEIVE + /// + /// + /// + /// + /// + /// + /// + /// + private int MstIRTSendReceive(string sIp, int iPort, int iTimeout, string sCommData, Hashtable htData, ref StringBuilder sbRecvData) + { + int nStat = BaseCom.NG1; + string sRecvCommHeader = string.Empty; + string sRecvData = string.Empty; + + try + { + string sJsonSendData = ""; + string sJsonReceiveData = ""; + Hashtable htRecvData = null; + + sbRecvData = new StringBuilder(); + + m_sendSocket = new TcpSocket(sIp, iPort, iTimeout); + + // Delay time to close connection is unlimited. + nStat = m_sendSocket.Connect(-1); + + if(nStat == BaseCom.OK) + { + while(true) + { + sJsonSendData = JsonConvert.SerializeObject(htData); + + // sJsonSendData 암호화 처리는 이 곳에서... + + Byte[] sBytTempBuff = Encoding.UTF8.GetBytes(sJsonSendData); + string sDataLen = string.Format("{0:000000}", sBytTempBuff.Length); + + sCommData = sDataLen + sCommData.Substring(TcpSocket.COMM_MSGLEN); + + // 마스터 송수신 로그 제거(20170524) + //UserLog.WriteLogFile(UserCom.LOG_SOCK, + // UserCom.WARNING_LEVEL, + // System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + // System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + // CmUtil.RPadH("[SEND" + ":" + sIp + ":" + iPort, 27) + "] " + sCommData + sJsonSendData); + + // 전문 송신 + nStat = SendReceiveMstData(sCommData + sJsonSendData, ref sJsonReceiveData); + if(nStat == BaseCom.OK) + { + // 마스터 송수신 로그 제거(20170524) + //UserLog.WriteLogFile(UserCom.LOG_SOCK, + // UserCom.WARNING_LEVEL, + // System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + // System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + // CmUtil.RPadH("[RECV" + ":" + sIp + ":" + iPort, 27) + "] " + sJsonReceiveData); + + if(sJsonReceiveData != null && sJsonReceiveData != string.Empty) + { + sRecvCommHeader = sJsonReceiveData.Substring(0, TcpSocket.COMM_HEAD_LEN); + sRecvData = sJsonReceiveData.Substring(TcpSocket.COMM_HEAD_LEN); + + // sRecvData 복호화 처리는 이 곳에서... + + htRecvData = JsonConvert.DeserializeObject(sRecvData); + + if(int.Parse(htRecvData[Column.IQ_POSMASTER_RSP.DATA.Count].ToString().Trim()) != 0) + { + // StringBuilder에 추가 + sbRecvData.Append(htRecvData[Column.IQ_POSMASTER_RSP.DATA.Data].ToString()); + } + else + { + break; + } + // 요청전문의 요청 코드 변경 + htData[Column.IQ_POSMASTER_REQ.DATA.ProcCd] = "1"; + } + } + else + { + return BaseCom.NG1; + } + } + + nStat = BaseCom.OK; + } + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.IRTSendReceive()", e.ToString()); + } + finally + { + m_sendSocket.Close(); + } + + return nStat; + } + private int SendReceiveMstData(string pSendData, ref string pRecvData) + { + int nRecvLen = 0; + int nStat = BaseCom.NG; + try + { + nRecvLen = m_sendSocket.SendReceiveMstData(pSendData, ref pRecvData); + if (nRecvLen > 0) + { + nStat = BaseCom.OK; + } + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + e.ToString()); + } + + return nStat; + } + #endregion 마스터 요청/응답 전문 송수신 모듈 + + #region 긴급공지 상태 변경 + /// + /// 긴급공지 상태 변경 + /// + /// + /// + /// + /// + private int EmgNoteFlgUpdate(string sStartDT, string sMsgCode, string sMsgDiv, string sDownFlag) + { + int iRet = UserCom.NG; + string sQuery = string.Empty; + try + { + + if (sStartDT.Trim() == "" || sMsgCode.Trim() == "" || sMsgDiv.Trim() == "") return iRet; + + sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, + m_cPosStatus.Base.LocalDbCatalog, + m_cPosStatus.Base.LocalDbUserID, + m_cPosStatus.Base.LocalDbPassword); + + sQuery += " UPDATE POSMST..MST_EMG_NOTE \n"; + sQuery += " SET DOWN_YN = '" + sDownFlag + "' \n"; + sQuery += " , UPD_DT = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' \n"; + + sQuery += " WHERE 1 = 1 \n"; + sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"; + sQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n"; + sQuery += " AND START_DT = '" + sStartDT + "' \n"; + sQuery += " AND MSG_CODE = '" + sMsgCode + "' \n"; + sQuery += " AND MSG_DIV = '" + sMsgDiv + "' \n"; + sQuery = sQuery.Replace("\t", " "); + + //iRet = m_cSqlDbService.DBExecuteNonQuery (sQuery); + + iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + + } + 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 iRet; + } + #endregion + + #region Master Download 처리 + + #region 19 - 상품 마스터 Download / Insert + public int MST_ITEM(string sUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd) + { + string sIrtData = string.Empty; + string sRecvData = string.Empty; + Hashtable htReqData = null; + StringBuilder sbRecvData = null; + int iReturn = BaseCom.NG; + + try + { + htReqData = new Hashtable(); + + // 마스터 요청 Hashtable Data 생성 + htReqData = GetPosMasterReqData(MasterLists.MST_ITEM.DIV, sUpdateDT, sStoreCd, sSubStoreCd, "0"); + + // 마스터 전문 송수신 + iReturn = this.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp, + (int)m_cPosStatus.Base.MstPort, + 10000, + ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd), + htReqData, + ref sbRecvData); + + if(iReturn == BaseCom.OK) + { + // 행구분자(#~)로 구분한 Row Data를 string array에 저장 + string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries); + + //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString()); + + // DB Insert + iReturn = UpdateMST_ITEM(aRowDatas); + + //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff")); + } + + return iReturn; + } + 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 UserCom.NG1; + } + } + + private int UpdateMST_ITEM(string[] aRowDatas) + { + string sQuery = string.Empty; + //string sInsQuery = string.Empty; + //string sUpdQuery = string.Empty; + string sSQL = string.Empty; + string[] aParams = null; + + try + { + #region UPDATE / INSERT Query + sQuery = "UPDATE POSMST..MST_ITEM \n" + + " SET L_CLSS = '{4}', M_CLSS = '{5}', S_CLSS = '{6}', FLAVOUR_DIV = '{7}', FLAVOUR_QTY = {8} \n" + + " , FLAVOUR_STOCK = {9}, SHTCUT_ITEMNM = N'{10}', ITEM_NM = N'{11}', TAKE_IN_SALE_AMT = {12}, TAKE_OUT_SALE_AMT = {13} \n" + + " , IF_MENU1 = '{14}', IF_MENU2 = '{15}', OPEN_ITEM_DIV = '{16}', DISPO_ITEM_DIV = '{17}', SUB_SET_MNG_TYPE = '{18}' \n" + + " , ITEM_TAX_AMT_DIV = '{19}', TAKE_IN_VAT_CD = '{20}', TAKE_OUT_VAT_CD = '{21}', ITEM_COST = {22} \n" + + " , SALE_PRMT_YN = '{23}', SALE_NOQ = {24}, FREE_GIFT_YN = '{25}', DC_PRMT_YN = '{26}', ACCUM_PRMT_YN = '{27}' \n" + + " , SVC_FEE_TRGT_YN = '{28}', BTN_ITEM_IMG = '{29}', NEW_ITEM_START_DT = '{30}', NEW_ITEM_FNSH_DT = '{31}', ITEM_TYPE = '{32}' \n" + + " , TIME_BAR_CD_YN = '{33}', DISTBT_EXPIRE_NOD = '{34}', ALCOHOL_ITEM_TYPE = '{35}', SALE_START_DT = '{36}', SALE_FNSH_DT = '{37}' \n" + + " , COOP_CARD_DC_NOADM_YN = '{38}', CAKE_EXCHNG_CPN_USE_POSS_YN = '{39}', ITEM_INFO = N'{40}', CALORY_INFO = N'{41}', SALE_IMG_FILE_NM = '{42}' \n" + + " , FILLER1 = '{43}', FILLER2 = '{44}', FILLER3 = '{45}', FILLER4 = '{46}', FILLER5 = '{47}' \n" + + " , USE_YN = '{48}', UPD_DT = '{49}' \n" + + " WHERE CMP_CD = '{0}' \n" + + " AND STOR_CD = '{1}' \n" + + " AND SUB_STOR_CD = '{2}' \n" + + " AND ITEM_CD = '{3}' \n" + + "IF @@ROWCOUNT = 0 \n" + + "INSERT INTO POSMST..MST_ITEM \n" + + " ( CMP_CD, STOR_CD, SUB_STOR_CD, ITEM_CD, L_CLSS \n" + + " , M_CLSS, S_CLSS, FLAVOUR_DIV, FLAVOUR_QTY, FLAVOUR_STOCK \n" + + " , SHTCUT_ITEMNM, ITEM_NM, TAKE_IN_SALE_AMT, TAKE_OUT_SALE_AMT, IF_MENU1 \n" + + " , IF_MENU2, OPEN_ITEM_DIV, DISPO_ITEM_DIV, SUB_SET_MNG_TYPE, ITEM_TAX_AMT_DIV \n" + + " , TAKE_IN_VAT_CD, TAKE_OUT_VAT_CD, ITEM_COST, SALE_PRMT_YN, SALE_NOQ \n" + + " , FREE_GIFT_YN, DC_PRMT_YN, ACCUM_PRMT_YN, SVC_FEE_TRGT_YN, BTN_ITEM_IMG \n" + + " , NEW_ITEM_START_DT, NEW_ITEM_FNSH_DT, ITEM_TYPE, TIME_BAR_CD_YN, DISTBT_EXPIRE_NOD \n" + + " , ALCOHOL_ITEM_TYPE, SALE_START_DT, SALE_FNSH_DT, COOP_CARD_DC_NOADM_YN, CAKE_EXCHNG_CPN_USE_POSS_YN \n" + + " , ITEM_INFO, CALORY_INFO, SALE_IMG_FILE_NM, FILLER1, FILLER2 \n" + + " , FILLER3, FILLER4, FILLER5, USE_YN, REG_DT ) \n" + + "VALUES \n" + + " ( '{0}', '{1}', '{2}', '{3}', '{4}' \n" + + " , '{5}', '{6}', '{7}', {8}, {9} \n" + + " , N'{10}', N'{11}', {12}, {13}, '{14}' \n" + + " , '{15}', '{16}', '{17}', '{18}', '{19}' \n" + + " , '{20}', '{21}', {22}, '{23}', {24} \n" + + " , '{25}', '{26}', '{27}', '{28}', '{29}' \n" + + " , '{30}', '{31}', '{32}', '{33}', '{34}' \n" + + " , '{35}', '{36}', '{37}', '{38}', '{39}' \n" + + " , N'{40}', N'{41}', '{42}', '{43}', '{44}' \n" + + " , '{45}', '{46}', '{47}', '{48}', '{49}' ) \n"; + #endregion UPDATE / INSERT Query + + if (aRowDatas.Length > 0) + { + // 현재 Row Counting + int nCnt = 0; + + sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, + m_cPosStatus.Base.LocalDbCatalog, + m_cPosStatus.Base.LocalDbUserID, + m_cPosStatus.Base.LocalDbPassword); + + int iRet = UserCom.NG; + + foreach (string sRowData in aRowDatas) + { + nCnt++; + aParams = sRowData.Split('|'); + + sSQL = string.Format( sQuery + , aParams[0], m_cPosStatus.Base.StoreNo, aParams[2], aParams[3], aParams[4] + , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9] + , aParams[10], aParams[11], aParams[12], aParams[13], aParams[14] + , aParams[15], aParams[16], aParams[17], aParams[18], aParams[19] + , aParams[20], aParams[21], aParams[22], aParams[23], aParams[24] + , aParams[25], aParams[26], aParams[27], aParams[28], aParams[29] + , aParams[30], aParams[31], aParams[32], aParams[33], aParams[34] + , aParams[35], aParams[36], aParams[37], aParams[38], aParams[39] + , aParams[40], aParams[41], aParams[42], aParams[43], aParams[44] + , aParams[45], aParams[46], aParams[47], aParams[48], DateTime.Now.ToString("yyyyMMddHHmmsss")); + + iRet = sqlDb.DBExecuteNonQuery(sSQL, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + if (iRet != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + sSQL); + + return UserCom.NG1; + } + } + return UserCom.OK; + } + else + { + return UserCom.NG; + } + } + 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 UserCom.NG1; + } + } + #endregion 19 - 상품 마스터 Download / Insert + + #region 36 - 캠페인 상품 그룹관리 마스터 Download / Insert + public int MST_CPI_COMPNT(string sUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd) + { + string sIrtData = string.Empty; + string sRecvData = string.Empty; + Hashtable htReqData = null; + StringBuilder sbRecvData = null; + int iReturn = BaseCom.NG; + + try + { + htReqData = new Hashtable(); + + // 마스터 요청 Hashtable Data 생성 + htReqData = GetPosMasterReqData(MasterLists.MST_CPI_COMPNT.DIV, sUpdateDT, sStoreCd, sSubStoreCd, "0"); + + // 마스터 전문 송수신 + iReturn = this.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp, + (int)m_cPosStatus.Base.MstPort, + 10000, + ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd), + htReqData, + ref sbRecvData); + + if (iReturn == BaseCom.OK) + { + // 행구분자(#~)로 구분한 Row Data를 string array에 저장 + string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries); + + //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString()); + + // DB Insert + iReturn = UpdateMST_CPI_COMPNT(aRowDatas); + + //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff")); + } + + return iReturn; + } + 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 UserCom.NG1; + } + } + + private int UpdateMST_CPI_COMPNT(string[] aRowDatas) + { + string sQuery = string.Empty; + string sSQL = string.Empty; + //string sInsQuery = string.Empty; + //string sUpdQuery = string.Empty; + string[] aParams = null; + + try + { + #region UPDATE / INSERT Query + sQuery = "UPDATE POSMST..MST_CPI_COMPNT \n" + + " SET CPI_COND_TYPE = '{4}', QTY_AMT = {5}, CPI_DC_TYPE = '{6}', DC_RATE_QTY_AMT = {7}, DC_MAX_AMT = {8} \n" + + " , FILLER1 = '{9}', FILLER2 = '{10}', FILLER3 = '{11}', FILLER4 = '{12}', FILLER5 = '{13}' \n" + + " , USE_YN = '{14}', UPD_DT = '{15}' \n" + + " WHERE CMP_CD = '{0}' \n" + + " AND STOR_CD = '{1}' \n" + + " AND CPI_CD = '{2}' \n" + + " AND CPI_ITEM_GRP_CD = '{3}' \n" + + "IF @@ROWCOUNT = 0 \n" + + "INSERT INTO POSMST..MST_CPI_COMPNT \n" + + " ( CMP_CD, STOR_CD, CPI_CD, CPI_ITEM_GRP_CD, CPI_COND_TYPE \n" + + " , QTY_AMT, CPI_DC_TYPE, DC_RATE_QTY_AMT, DC_MAX_AMT, FILLER1 \n" + + " , FILLER2, FILLER3, FILLER4, FILLER5, USE_YN \n" + + " , REG_DT ) \n" + + "VALUES \n" + + " ( '{0}', '{1}', '{2}', '{3}', '{4}' \n" + + " , {5}, '{6}', {7}, {8}, '{9}' \n" + + " , '{10}', '{11}', '{12}', '{13}', '{14}' \n" + + " , '{15}' ) \n"; + #endregion UPDATE / INSERT Query + + if (aRowDatas.Length > 0) + { + // 현재 Row Counting + int nCnt = 0; + + sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, + m_cPosStatus.Base.LocalDbCatalog, + m_cPosStatus.Base.LocalDbUserID, + m_cPosStatus.Base.LocalDbPassword); + + int iRet = UserCom.NG; + + foreach (string sRowData in aRowDatas) + { + nCnt++; + aParams = sRowData.Split('|'); + + sSQL = string.Format( sQuery + , aParams[0], aParams[1], aParams[2], aParams[3], aParams[4] + , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9] + , aParams[10], aParams[11], aParams[12], aParams[13], aParams[14] + , DateTime.Now.ToString("yyyyMMddHHmmsss")); + + iRet = sqlDb.DBExecuteNonQuery(sSQL, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + if (iRet != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + sSQL); + + return UserCom.NG1; + } + } + return UserCom.OK; + } + else + { + return UserCom.NG; + } + } + 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 UserCom.NG1; + } + } + #endregion 36 - 캠페인 상품 그룹관리 마스터 Download / Insert + + #region 37 - 캠페인 마스터 Download / Insert + public int MST_CPI(string sUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd) + { + string sIrtData = string.Empty; + string sRecvData = string.Empty; + Hashtable htReqData = null; + StringBuilder sbRecvData = null; + int iReturn = BaseCom.NG; + + try + { + htReqData = new Hashtable(); + + // 마스터 요청 Hashtable Data 생성 + htReqData = GetPosMasterReqData(MasterLists.MST_CPI.DIV, sUpdateDT, sStoreCd, sSubStoreCd, "0"); + + // 마스터 전문 송수신 + iReturn = this.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp, + (int)m_cPosStatus.Base.MstPort, + 10000, + ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd), + htReqData, + ref sbRecvData); + + if (iReturn == BaseCom.OK) + { + // 행구분자(#~)로 구분한 Row Data를 string array에 저장 + string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries); + + //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString()); + + // DB Insert + iReturn = UpdateMST_CPI(aRowDatas); + + //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff")); + } + + return iReturn; + } + 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 UserCom.NG1; + } + } + + private int UpdateMST_CPI(string[] aRowDatas) + { + string sQuery = string.Empty; + string sSQL = string.Empty; + //string sInsQuery = string.Empty; + //string sUpdQuery = string.Empty; + string[] aParams = null; + + try + { + #region UPDATE / INSERT Query + sQuery = "UPDATE POSMST..MST_CPI \n" + + " SET CPI_NM = N'{3}', STARTDAY = '{4}', FNSHDAY = '{5}', REPT_YN = '{6}', REPT_APPNT_TYPE = '{7}' \n" + + " , REPT_WEEK = '{8}', REPT_DT = '{9}', DUP_APPLY_YN = '{10}', BASIC_RULE_EXCEP_YN = '{11}', TELECOM_COOP_DUP_PRMT_YN = '{12}' \n" + + " , PRRTY = {13}, TRGT_CUST_TYPE = '{14}', CPI_CUST_BNFT_TYPE = '{15}', ITEM_APPLY_METHD = '{16}', CUST_PAY_TYPE = '{17}' \n" + + " , TRGT_AMT_TYPE = '{18}', TRGT_AMT = {19}, QTY_LMT_YN = '{20}', LMT_QTY = {21}, QTY_LMT_STD = '{22}' \n" + + " , HP_CUST_JOIN_LMT_YN = '{23}', HP_CUST_MAX_JOIN_CNT = {24}, HP_CUST_JOIN_LMT_STD = '{25}', BASIC_HP_ACCUM_YN = '{26}', BASIC_HP_ACCUM_STD = '{27}' \n" + + " , ADD_HP_ACCUM_TELECOM_DIV = '{28}', ADD_HP_ACCUM_TRGT_STD = '{29}', ADD_HP_ACCUM_RATE = {30}, ADD_HP_ACCUM_AF_DIV = '{31}', ADD_HP_ACCUM_CD1 = '{32}' \n" + + " , ADD_HP_ACCUM_CD2 = '{33}', OFFER_ID = '{34}', FREE_GIFT_PROVD_STD = '{35}', FREE_GIFT_STD_AMT = {36}, FREE_GIFT_PROVD_QTY = {37} \n" + + " , FREE_GIFT_ADD_SALE_YN = '{38}', CPI_INFO = N'{39}', CPI_EXPLN = N'{40}', LTTR_MAX_GRADE = {41}, CUST_DSP_FILE_DIV = '{42}' \n" + + " , CUST_DSP_FILENM = '{43}', STAMP_QTY = {44}, SOUND_FILE_DIV = '{45}', SOUND_FILE_NM = '{46}', TTS_DSCRP = N'{47}' \n" + + " , SOUND_FILE_PLAY_CHK_PNT = '{48}', USE_YN = '{49}', FILLER1 = '{50}', FILLER2 = '{51}', FILLER3 = '{52}' \n" + + " , FILLER4 = '{53}', FILLER5 = '{54}', UPD_DT = '{55}', JOIN_QUSTN_YN = '{56}', PRGRS_STATUS = '{57}' \n" + + " , ITEM_DUP_PRMT_YN = '{58}', LTTR_MULTI_PRT_YN = '{59}', CPI_DC_PAY_WAY = '{60}', CPI_BILL_NM = N'{61}', QTY_LIMIT_MSG = N'{62}' \n" + + " , HP_CUST_LVL = '{63}', DC_NOADM_PASS_YN = '{64}' \n" + + //#15583 캠페인 기능 개선 요청 start + + " , MOBILE_CPN_DUP_PRMT_YN = '{65}', HPY_CPN_DUP_PRMT_YN = '{66}' \n" + //#15583 캠페인 기능 개선 요청 end + + + " WHERE CMP_CD = '{0}' \n" + + " AND STOR_CD = '{1}' \n" + + " AND CPI_CD = '{2}' \n" + + "IF @@ROWCOUNT = 0 \n" + + "INSERT INTO POSMST..MST_CPI \n" + + " ( CMP_CD, STOR_CD, CPI_CD, CPI_NM, STARTDAY \n" + + " , FNSHDAY, REPT_YN, REPT_APPNT_TYPE, REPT_WEEK, REPT_DT \n" + + " , DUP_APPLY_YN, BASIC_RULE_EXCEP_YN, TELECOM_COOP_DUP_PRMT_YN, PRRTY, TRGT_CUST_TYPE \n" + + " , CPI_CUST_BNFT_TYPE, ITEM_APPLY_METHD, CUST_PAY_TYPE, TRGT_AMT_TYPE, TRGT_AMT \n" + + " , QTY_LMT_YN, LMT_QTY, QTY_LMT_STD, HP_CUST_JOIN_LMT_YN, HP_CUST_MAX_JOIN_CNT \n" + + " , HP_CUST_JOIN_LMT_STD, BASIC_HP_ACCUM_YN, BASIC_HP_ACCUM_STD, ADD_HP_ACCUM_TELECOM_DIV, ADD_HP_ACCUM_TRGT_STD \n" + + " , ADD_HP_ACCUM_RATE, ADD_HP_ACCUM_AF_DIV, ADD_HP_ACCUM_CD1, ADD_HP_ACCUM_CD2, OFFER_ID \n" + + " , FREE_GIFT_PROVD_STD, FREE_GIFT_STD_AMT, FREE_GIFT_PROVD_QTY, FREE_GIFT_ADD_SALE_YN, CPI_INFO \n" + + " , CPI_EXPLN, LTTR_MAX_GRADE, CUST_DSP_FILE_DIV, CUST_DSP_FILENM, STAMP_QTY \n" + + " , SOUND_FILE_DIV, SOUND_FILE_NM, TTS_DSCRP, SOUND_FILE_PLAY_CHK_PNT, USE_YN \n" + + " , FILLER1, FILLER2, FILLER3, FILLER4, FILLER5 \n" + + " , REG_DT, JOIN_QUSTN_YN, PRGRS_STATUS, ITEM_DUP_PRMT_YN, LTTR_MULTI_PRT_YN \n" + + //#15583 캠페인 기능 개선 요청 start + //기존 + //+ " , CPI_DC_PAY_WAY, CPI_BILL_NM, QTY_LIMIT_MSG, HP_CUST_LVL, DC_NOADM_PASS_YN ) \n" + //변경 + + " , CPI_DC_PAY_WAY, CPI_BILL_NM, QTY_LIMIT_MSG, HP_CUST_LVL, DC_NOADM_PASS_YN \n" + + " , MOBILE_CPN_DUP_PRMT_YN, HPY_CPN_DUP_PRMT_YN ) \n" + //#15583 캠페인 기능 개선 요청 end + + + "VALUES \n" + + " ( '{0}', '{1}', '{2}', N'{3}', '{4}' \n" + + " , '{5}', '{6}', '{7}', '{8}', '{9}' \n" + + " , '{10}', '{11}', '{12}', {13}, '{14}' \n" + + " , '{15}', '{16}', '{17}', '{18}', {19} \n" + + " , '{20}', {21}, '{22}', '{23}', {24} \n" + + " , '{25}', '{26}', '{27}', '{28}', '{29}' \n" + + " , {30}, '{31}', '{32}', '{33}', '{34}' \n" + + " , '{35}', {36}, {37}, '{38}', N'{39}' \n" + + " , N'{40}', {41}, '{42}', '{43}', {44} \n" + + " , '{45}', '{46}', N'{47}', '{48}', '{49}' \n" + + " , '{50}', '{51}', '{52}', '{53}', '{54}' \n" + + " , '{55}', '{56}', '{57}', '{58}', '{59}' \n" + + //#15583 캠페인 기능 개선 요청 start + //기존 + //+ " , '{60}', N'{61}', N'{62}', {63}, '{64}' ) \n"; + //변경 + + " , '{60}', N'{61}', N'{62}', {63}, '{64}' \n" + + " , '{65}', '{66}' ) \n"; + //#15583 캠페인 기능 개선 요청 end + + #endregion UPDATE / INSERT Query + + if (aRowDatas.Length > 0) + { + // 현재 Row Counting + int nCnt = 0; + + sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, + m_cPosStatus.Base.LocalDbCatalog, + m_cPosStatus.Base.LocalDbUserID, + m_cPosStatus.Base.LocalDbPassword); + + int iRet = UserCom.NG; + + foreach (string sRowData in aRowDatas) + { + nCnt++; + aParams = sRowData.Split('|'); + + sSQL = string.Format( sQuery + , aParams[0], aParams[1], aParams[2], aParams[3], aParams[4] + , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9] + , aParams[10], aParams[11], aParams[12], aParams[13], aParams[14] + , aParams[15], aParams[16], aParams[17], aParams[18], aParams[19] + , aParams[20], aParams[21], aParams[22], aParams[23], aParams[24] + , aParams[25], aParams[26], aParams[27], aParams[28], aParams[29] + , aParams[30], aParams[31], aParams[32], aParams[33], aParams[34] + , aParams[35], aParams[36], aParams[37], aParams[38], aParams[39] + , aParams[40], aParams[41], aParams[42], aParams[43], aParams[44] + , aParams[45], aParams[46], aParams[47], aParams[48], aParams[49] + , aParams[50], aParams[51], aParams[52], aParams[53], aParams[54] + , DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[57], aParams[58], aParams[59], aParams[60] + + //#15583 캠페인 기능 개선 요청 start + //기존 + //, aParams[61], aParams[62], aParams[63], aParams[64], aParams[65]); + //변경 + , aParams[61], aParams[62], aParams[63], aParams[64], aParams[65] + , aParams[66], aParams[67]); + //#15583 캠페인 기능 개선 요청 end + + iRet = sqlDb.DBExecuteNonQuery(sSQL, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + if (iRet != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + sSQL); + + return UserCom.NG1; + } + } + return UserCom.OK; + } + else + { + return UserCom.NG; + } + } + 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 UserCom.NG1; + } + } + #endregion 37 - 캠페인 마스터 Download / Insert + + #region 38 - 캠페인 시간 마스터 Download / Insert + public int MST_CPI_HOUR(string sUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd) + { + string sIrtData = string.Empty; + string sRecvData = string.Empty; + Hashtable htReqData = null; + StringBuilder sbRecvData = null; + int iReturn = BaseCom.NG; + + try + { + htReqData = new Hashtable(); + + // 마스터 요청 Hashtable Data 생성 + htReqData = GetPosMasterReqData(MasterLists.MST_CPI_HOUR.DIV, sUpdateDT, sStoreCd, sSubStoreCd, "0"); + + // 마스터 전문 송수신 + iReturn = this.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp, + (int)m_cPosStatus.Base.MstPort, + 10000, + ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd), + htReqData, + ref sbRecvData); + + if (iReturn == BaseCom.OK) + { + // 행구분자(#~)로 구분한 Row Data를 string array에 저장 + string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries); + + //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString()); + + // DB Insert + iReturn = UpdateMST_CPI_HOUR(aRowDatas); + + //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff")); + } + + return iReturn; + } + 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 UserCom.NG1; + } + } + + private int UpdateMST_CPI_HOUR(string[] aRowDatas) + { + string sQuery = string.Empty; + string sSQL = string.Empty; + //string sInsQuery = string.Empty; + //string sUpdQuery = string.Empty; + string[] aParams = null; + + try + { + #region UPDATE / INSERT Query + sQuery = "UPDATE POSMST..MST_CPI_HOUR \n" + + " SET START_HOUR = '{4}', FNSH_HOUR = '{5}', FILLER1 = '{6}', FILLER2 = '{7}', FILLER3 = '{8}' \n" + + " , FILLER4 = '{9}', FILLER5 = '{10}', UPD_DT = '{11}', USE_YN = '{12}' \n" + + " WHERE CMP_CD = '{0}' \n" + + " AND STOR_CD = '{1}' \n" + + " AND CPI_CD = '{2}' \n" + + " AND DOW_DIV = '{3}' \n" + + "IF @@ROWCOUNT = 0 \n" + + "INSERT INTO POSMST..MST_CPI_HOUR \n" + + " ( CMP_CD, STOR_CD, CPI_CD, DOW_DIV, START_HOUR \n" + + " , FNSH_HOUR, FILLER1, FILLER2, FILLER3, FILLER4 \n" + + " , FILLER5, REG_DT, USE_YN ) \n" + + "VALUES \n" + + " ( '{0}', '{1}', '{2}', '{3}', '{4}' \n" + + " , '{5}', '{6}', '{7}', '{8}', '{9}' \n" + + " , '{10}', '{11}', '{12}' ) \n"; + #endregion UPDATE / INSERT Query + + if (aRowDatas.Length > 0) + { + // 현재 Row Counting + int nCnt = 0; + + sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, + m_cPosStatus.Base.LocalDbCatalog, + m_cPosStatus.Base.LocalDbUserID, + m_cPosStatus.Base.LocalDbPassword); + + int iRet = UserCom.NG; + + foreach (string sRowData in aRowDatas) + { + nCnt++; + aParams = sRowData.Split('|'); + + sSQL = string.Format( sQuery + , aParams[0], aParams[1], aParams[2], aParams[3], aParams[4] + , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9] + , aParams[10], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[13]); + + iRet = sqlDb.DBExecuteNonQuery(sSQL, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + if (iRet != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + sSQL); + + return UserCom.NG1; + } + } + return UserCom.OK; + } + else + { + return UserCom.NG; + } + } + 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 UserCom.NG1; + } + } + #endregion 38 - 캠페인 시간 마스터 Download / Insert + + #region 39 - 캠페인 상품 마스터 Download / Insert + public int MST_CPI_ITEM(string sUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd) + { + string sIrtData = string.Empty; + string sRecvData = string.Empty; + Hashtable htReqData = null; + StringBuilder sbRecvData = null; + int iReturn = BaseCom.NG; + + try + { + htReqData = new Hashtable(); + + // 마스터 요청 Hashtable Data 생성 + htReqData = GetPosMasterReqData(MasterLists.MST_CPI_ITEM.DIV, sUpdateDT, sStoreCd, sSubStoreCd, "0"); + + // 마스터 전문 송수신 + iReturn = this.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp, + (int)m_cPosStatus.Base.MstPort, + 10000, + ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd), + htReqData, + ref sbRecvData); + + if (iReturn == BaseCom.OK) + { + // 행구분자(#~)로 구분한 Row Data를 string array에 저장 + string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries); + + //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString()); + + // DB Insert + iReturn = UpdateMST_CPI_ITEM(aRowDatas); + + //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff")); + } + + return iReturn; + } + 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 UserCom.NG1; + } + } + + private int UpdateMST_CPI_ITEM(string[] aRowDatas) + { + string sQuery = string.Empty; + string sSQL = string.Empty; + //string sInsQuery = string.Empty; + //string sUpdQuery = string.Empty; + string[] aParams = null; + + try + { + #region UPDATE / INSERT Query + sQuery = "UPDATE POSMST..MST_CPI_ITEM \n" + + " SET CPI_DC_TYPE = '{7}', DC_RATE_AMT = {8}, FILLER1 = '{9}', FILLER2 = '{10}', FILLER3 = '{11}' \n" + + " , FILLER4 = '{12}', FILLER5 = '{13}', UPD_DT = '{14}', USE_YN = '{15}' \n" + + " WHERE CMP_CD = '{0}' \n" + + " AND STOR_CD = '{1}' \n" + + " AND CPI_CD = '{2}' \n" + + " AND SUB_STOR_CD = '{3}' \n" + + " AND CPI_ITEM_GRP_CD = '{4}' \n" + + " AND ITEM_LVL = '{5}' \n" + + " AND ITEM_CD = '{6}' \n" + + "IF @@ROWCOUNT = 0 \n" + + "INSERT INTO POSMST..MST_CPI_ITEM \n" + + " ( CMP_CD, STOR_CD, CPI_CD, SUB_STOR_CD, CPI_ITEM_GRP_CD \n" + + " , ITEM_LVL, ITEM_CD, CPI_DC_TYPE, DC_RATE_AMT, FILLER1 \n" + + " , FILLER2, FILLER3, FILLER4, FILLER5, REG_DT \n" + + " , USE_YN ) \n" + + "VALUES \n" + + " ( '{0}', '{1}', '{2}', '{3}', '{4}' \n" + + " , '{5}', '{6}', '{7}', {8}, '{9}' \n" + + " , '{10}', '{11}', '{12}', '{13}', '{14}' \n" + + " , '{15}' ) \n"; + #endregion UPDATE / INSERT Query + + if (aRowDatas.Length > 0) + { + // 현재 Row Counting + int nCnt = 0; + + sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, + m_cPosStatus.Base.LocalDbCatalog, + m_cPosStatus.Base.LocalDbUserID, + m_cPosStatus.Base.LocalDbPassword); + + int iRet = UserCom.NG; + + foreach (string sRowData in aRowDatas) + { + nCnt++; + aParams = sRowData.Split('|'); + + sSQL = string.Format( sQuery + , aParams[0], m_cPosStatus.Base.StoreNo, aParams[2], aParams[3], aParams[4] + , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9] + , aParams[10], aParams[11], aParams[12], aParams[13], DateTime.Now.ToString("yyyyMMddHHmmsss") + , aParams[16]); + + iRet = sqlDb.DBExecuteNonQuery(sSQL, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + if (iRet != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + sSQL); + + return UserCom.NG1; + } + } + return UserCom.OK; + } + else + { + return UserCom.NG; + } + } + 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 UserCom.NG1; + } + } + #endregion 39 - 캠페인 상품 마스터 Download / Insert + + #region 40 - 캠페인 출력메시지 마스터 Download / Insert + public int MST_CPI_PRT_MSG(string sUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd) + { + string sIrtData = string.Empty; + string sRecvData = string.Empty; + Hashtable htReqData = null; + StringBuilder sbRecvData = null; + int iReturn = BaseCom.NG; + + try + { + htReqData = new Hashtable(); + + // 마스터 요청 Hashtable Data 생성 + htReqData = GetPosMasterReqData(MasterLists.MST_CPI_PRT_MSG.DIV, sUpdateDT, sStoreCd, sSubStoreCd, "0"); + + // 마스터 전문 송수신 + iReturn = this.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp, + (int)m_cPosStatus.Base.MstPort, + 10000, + ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd), + htReqData, + ref sbRecvData); + + if (iReturn == BaseCom.OK) + { + // 행구분자(#~)로 구분한 Row Data를 string array에 저장 + string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries); + + //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString()); + + // DB Insert + iReturn = UpdateMST_CPI_PRT_MSG(aRowDatas); + + //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff")); + } + + return iReturn; + } + 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 UserCom.NG1; + } + } + + private int UpdateMST_CPI_PRT_MSG(string[] aRowDatas) + { + string sQuery = string.Empty; + string sSQL = string.Empty; + //string sInsQuery = string.Empty; + //string sUpdQuery = string.Empty; + string[] aParams = null; + + try + { + #region UPDATE / INSERT Query + sQuery = "UPDATE POSMST..MST_CPI_PRT_MSG \n" + + " SET PRT_EXPAND_TYPE = '{5}', BOLD_YN = '{6}', ALIGN_TYPE = '{7}', MSG_VAL = N'{8}', FILLER1 = '{9}' \n" + + " , FILLER2 = '{10}', FILLER3 = '{11}', FILLER4 = '{12}', FILLER5 = '{13}', UPD_DT = '{14}', PRT_YN = '{15}' \n" + + " WHERE CMP_CD = '{0}' \n" + + " AND STOR_CD = '{1}' \n" + + " AND CPI_CD = '{2}' \n" + + " AND CPI_BILL_PRT_AREA_TYPE = '{3}' \n" + + " AND PRT_SEQ = {4} \n" + + "IF @@ROWCOUNT = 0 \n" + + "INSERT INTO POSMST..MST_CPI_PRT_MSG \n" + + " ( CMP_CD, STOR_CD, CPI_CD, CPI_BILL_PRT_AREA_TYPE, PRT_SEQ \n" + + " , PRT_EXPAND_TYPE, BOLD_YN, ALIGN_TYPE, MSG_VAL, FILLER1 \n" + + " , FILLER2, FILLER3, FILLER4, FILLER5, REG_DT \n" + + " , PRT_YN ) \n" + + "VALUES \n" + + " ( '{0}', '{1}', '{2}', '{3}', {4} \n" + + " , '{5}', '{6}', '{7}', N'{8}', '{9}' \n" + + " , '{10}', '{11}', '{12}', '{13}', '{14}' \n" + + " , '{15}' ) \n"; + #endregion UPDATE / INSERT Query + + if (aRowDatas.Length > 0) + { + // 현재 Row Counting + int nCnt = 0; + + sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, + m_cPosStatus.Base.LocalDbCatalog, + m_cPosStatus.Base.LocalDbUserID, + m_cPosStatus.Base.LocalDbPassword); + + int iRet = UserCom.NG; + + foreach (string sRowData in aRowDatas) + { + nCnt++; + aParams = sRowData.Split('|'); + + sSQL = string.Format( sQuery + , aParams[0], aParams[1], aParams[2], aParams[3], aParams[4] + , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9] + , aParams[10], aParams[11], aParams[12], aParams[13], DateTime.Now.ToString("yyyyMMddHHmmsss") + , aParams[16]); + + iRet = sqlDb.DBExecuteNonQuery(sSQL, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + if (iRet != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + sSQL); + + return UserCom.NG1; + } + } + return UserCom.OK; + } + else + { + return UserCom.NG; + } + } + 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 UserCom.NG1; + } + } + #endregion 40 - 캠페인 출력메시지 마스터 Download / Insert + + #region 41 - 캠페인 카드 마스터 Downlaod / Insert + public int MST_CPI_CARD(string sUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd) + { + string sIrtData = string.Empty; + string sRecvData = string.Empty; + Hashtable htReqData = null; + StringBuilder sbRecvData = null; + int iReturn = BaseCom.NG; + + try + { + htReqData = new Hashtable(); + + // 마스터 요청 Hashtable Data 생성 + htReqData = GetPosMasterReqData(MasterLists.MST_CPI_CARD.DIV, sUpdateDT, sStoreCd, sSubStoreCd, "0"); + + // 마스터 전문 송수신 + iReturn = this.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp, + (int)m_cPosStatus.Base.MstPort, + 10000, + ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd), + htReqData, + ref sbRecvData); + + if (iReturn == BaseCom.OK) + { + // 행구분자(#~)로 구분한 Row Data를 string array에 저장 + string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries); + + //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString()); + + // DB Insert + iReturn = UpdateMST_CPI_CARD(aRowDatas); + + //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff")); + } + + return iReturn; + } + 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 UserCom.NG1; + } + } + + private int UpdateMST_CPI_CARD(string[] aRowDatas) + { + string sQuery = string.Empty; + string sSQL = string.Empty; + //string sInsQuery = string.Empty; + //string sUpdQuery = string.Empty; + string[] aParams = null; + + try + { + #region UPDATE / INSERT Query + sQuery = "UPDATE POSMST..MST_CPI_CARD \n" + + " SET CHECK_VAL = '{4}', LOC = {5}, FILLER1 = '{6}', FILLER2 = '{7}', FILLER3 = '{8}' \n" + + " , FILLER4 = '{9}', FILLER5 = '{10}', UPD_DT = '{11}', USE_YN = '{12}' \n" + + " WHERE CMP_CD = '{0}' \n" + + " AND STOR_CD = '{1}' \n" + + " AND CPI_CD = '{2}' \n" + + " AND CARD_PRFX_CD = '{3}' \n" + + "IF @@ROWCOUNT = 0 \n" + + "INSERT INTO POSMST..MST_CPI_CARD \n" + + " ( CMP_CD, STOR_CD, CPI_CD, CARD_PRFX_CD, CHECK_VAL \n" + + " , LOC, FILLER1, FILLER2, FILLER3, FILLER4 \n" + + " , FILLER5, REG_DT, USE_YN ) \n" + + "VALUES \n" + + " ( '{0}', '{1}', '{2}', '{3}', '{4}' \n" + + " , {5}, '{6}', '{7}' ,'{8}', '{9}' \n" + + " , '{10}', '{11}', '{12}' ) \n"; + #endregion UPDATE / INSERT Query + + if (aRowDatas.Length > 0) + { + // 현재 Row Counting + int nCnt = 0; + + sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, + m_cPosStatus.Base.LocalDbCatalog, + m_cPosStatus.Base.LocalDbUserID, + m_cPosStatus.Base.LocalDbPassword); + + int iRet = UserCom.NG; + + foreach (string sRowData in aRowDatas) + { + nCnt++; + aParams = sRowData.Split('|'); + + sSQL = string.Format( sQuery + , aParams[0], aParams[1], aParams[2], aParams[3], aParams[4] + , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9] + , aParams[10], DateTime.Now.ToString("yyyyMMddHHmmsss"), aParams[13]); + + iRet = sqlDb.DBExecuteNonQuery(sSQL, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + if (iRet != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + sSQL); + + return UserCom.NG1; + } + } + return UserCom.OK; + } + else + { + return UserCom.NG; + } + } + 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 UserCom.NG1; + } + } + #endregion 41 - 캠페인 카드 마스터 Downlaod / Insert + + #region 42 - 캠페인 복권 출력 메시지 관리 마스터 Download / Insert + public int MST_CPI_LTTR_PRT(string sUpdateDT, string sStoreCd, string sSubBrandCd, string sSubStoreCd) + { + string sIrtData = string.Empty; + string sRecvData = string.Empty; + Hashtable htReqData = null; + StringBuilder sbRecvData = null; + int iReturn = BaseCom.NG; + + try + { + htReqData = new Hashtable(); + + // 마스터 요청 Hashtable Data 생성 + htReqData = GetPosMasterReqData(MasterLists.MST_CPI_LTTR_PRT.DIV, sUpdateDT, sStoreCd, sSubStoreCd, "0"); + + // 마스터 전문 송수신 + iReturn = this.MstIRTSendReceive(m_cPosStatus.Base.CommSvrIp, + (int)m_cPosStatus.Base.MstPort, + 10000, + ItemColumn.MakeCommHeader(0, ItemConst.COMM_MSG_TYPE.MSTIRT, sSubBrandCd), + htReqData, + ref sbRecvData); + + if (iReturn == BaseCom.OK) + { + // 행구분자(#~)로 구분한 Row Data를 string array에 저장 + string[] aRowDatas = (sbRecvData.ToString()).Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries); + + //System.Console.WriteLine("{0} - start({1})", DateTime.Now.ToString("HH:mm:ss.fff"), aRowDatas.Length.ToString()); + + // DB Insert + iReturn = UpdateMST_CPI_LTTR_PRT(aRowDatas); + + //System.Console.WriteLine("{0} - end)", DateTime.Now.ToString("HH:mm:ss.fff")); + } + + return iReturn; + } + 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 UserCom.NG1; + } + } + + private int UpdateMST_CPI_LTTR_PRT(string[] aRowDatas) + { + string sQuery = string.Empty; + string sSQL = string.Empty; + //string sInsQuery = string.Empty; + //string sUpdQuery = string.Empty; + string[] aParams = null; + + try + { + #region UPDATE / INSERT Query + sQuery = "UPDATE POSMST..MST_CPI_LTTR_PRT \n" + + " SET MSG_VAL = N'{5}', PRT_EXPAND_TYPE = '{6}', BOLD_YN = '{7}', ALIGN_TYPE = '{8}', FILLER1 = '{9}' \n" + + " , FILLER2 = '{10}', FILLER3 = '{11}', FILLER4 = '{12}', FILLER5 = '{13}', PRT_YN = '{14}' \n" + + " , UPD_DT = '{15}' \n" + + " WHERE CMP_CD = '{0}' \n" + + " AND STOR_CD = '{1}' \n" + + " AND CPI_CD = '{2}' \n" + + " AND GRADE = {3} \n" + + " AND PRT_SEQ = {4} \n" + + "IF @@ROWCOUNT = 0 \n" + + "INSERT INTO POSMST..MST_CPI_LTTR_PRT \n" + + " ( CMP_CD, STOR_CD, CPI_CD, GRADE, PRT_SEQ \n" + + " , MSG_VAL, PRT_EXPAND_TYPE, BOLD_YN, ALIGN_TYPE, FILLER1 \n" + + " , FILLER2, FILLER3, FILLER4, FILLER5, PRT_YN \n" + + " , REG_DT ) \n" + + "VALUES \n" + + " ( '{0}', '{1}', '{2}', {3}, {4} \n" + + " , N'{5}', '{6}', '{7}', '{8}', '{9}' \n" + + " , '{10}', '{11}', '{12}', '{13}', '{14}' \n" + + " , '{15}' ) \n"; + #endregion UPDATE / INSERT Query + + if (aRowDatas.Length > 0) + { + // 현재 Row Counting + int nCnt = 0; + + sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, + m_cPosStatus.Base.LocalDbCatalog, + m_cPosStatus.Base.LocalDbUserID, + m_cPosStatus.Base.LocalDbPassword); + + int iRet = UserCom.NG; + + foreach (string sRowData in aRowDatas) + { + nCnt++; + aParams = sRowData.Split('|'); + + sSQL = string.Format( sQuery + , aParams[0], aParams[1], aParams[2], aParams[3], aParams[4] + , aParams[5], aParams[6], aParams[7], aParams[8], aParams[9] + , aParams[10], aParams[11], aParams[12], aParams[13], aParams[14] + , DateTime.Now.ToString("yyyyMMddHHmmsss")); + + iRet = sqlDb.DBExecuteNonQuery(sSQL, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + if (iRet != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + sSQL); + + return UserCom.NG1; + } + } + return UserCom.OK; + } + else + { + return UserCom.NG; + } + } + 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 UserCom.NG1; + } + } + #endregion 42 - 캠페인 복권 출력 메시지 관리 마스터 Download / Insert + + #endregion Master Download 처리 + + #region PosSaleInfo.INI 저장 처리 + private string UpdatePosSaleInfo() + { + string sRet = UserCom.RST_ERR; + try + { + CmMessage cmPosSaleInfo = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosSaleInfo); + + cmPosSaleInfo.GetMessage("CHECKOVER").MakeMessageOverWrite("MstBatchDownDate", m_cPosStatus.Base.MstBatchDownDate); + + // 파일저장 + cmPosSaleInfo.MakeFileFromMessage(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosSaleInfo); + + 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 프로그램 백그라운드 다운로드 대상 조회 요청 + /// + /// 프로그램 백그라운드 다운로드 대상 조회 요청 + /// + /// + private string LF_ProgramDownLoad_Search() + { + string sGroup = PosConst.PGM_UPDATE_TYPE.POSDOWN_GROUP_20; + string sKind = PosConst.PGM_UPDATE_TYPE.POSDOWN_GROUP_20_DIV.ALL_PGM; + string sDownDiv = "A"; + + Hashtable htRecvData = new Hashtable(); // 프로그램 업데이트 FTP 서버 정보 + string[] sRecvData = {""}; // 프로그램 업데이트 목록 + + string sRet = UserCom.RST_ERR; + DataTable dtData = new DataTable(); + string sQuery = ""; + string sLocalPath = BaseCom.NxDownPath; + + string[] aRecvData = null; + + string sFTP_IP = ""; + int iFTP_Port = 0; + string sFTP_ID = ""; + string sFTP_Pwd = ""; + + string sApplyDate = ""; + string sApplyTime = ""; + string sFilePath = ""; + string sFileNm = ""; + string sFileVer = ""; + string sFileSeq = ""; + string sDeployDate = ""; + string sDeployTime = ""; + string sDeployDT = ""; + string sUseYn = ""; + string sData = ""; + + int iRet = -1; + + try + { + // DB Connect + //m_cSqlDbService.SetDBConnectionString(m_cPosStatus.Base.LocalDbSource, m_cPosStatus.Base.LocalDbCatalog, m_cPosStatus.Base.LocalDbUserID, m_cPosStatus.Base.LocalDbPassword); + + sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, + m_cPosStatus.Base.LocalDbCatalog, + m_cPosStatus.Base.LocalDbUserID, + m_cPosStatus.Base.LocalDbPassword); + + // 프로그램 배포 조회 + sQuery = ""; + sQuery += "SELECT * \n"; + sQuery += " FROM POSMST..MST_EMG_NOTE \n"; + sQuery += " WHERE \n"; + sQuery += " CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"; + sQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n"; + sQuery += " AND MSG_DIV = '" + ItemConst.NOTE_MSG_DIV.EMG + "' \n"; + sQuery += " AND MSG_TYPE = '1' \n"; // 구분 (0:일반, 1:재시작) + sQuery += " AND DOWN_YN <> '1' \n"; // 다운로드 구분 (1:다운로드 완료, 0:미처리) + sQuery += " AND START_DT >= '" + DateTime.Now.ToString("yyyyMMdd") + "' \n"; // 영업일로 하게되면 개점 이전에 적용되지 않아 서버에서 받은 시스템 일자로 조회 + sQuery += " AND USE_YN = '" + PosConst.MST_USE_YN.YES + "' \n"; + sQuery += " ORDER BY REG_DT \n"; + sQuery = sQuery.Replace("\t", " "); + + //iRet = m_cSqlDbService.DBSelect(sQuery, out dtData); + + iRet = sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (System.Data.SqlClient.SqlParameter[])null, out dtData); + + if (dtData != null && dtData.Rows.Count > 0) + { + foreach (DataRow dr in dtData.Rows) + { + // 서버 조회 + sRet = m_cSvr2Tran.PGMUpdate(sGroup + sKind, sDownDiv, ref sRecvData, ref htRecvData); + if (sRet == UserCom.RST_OK) + { + sData = htRecvData[Column.IQ_PGMUPDATE_RSP.DATA.VALUE].ToString(); + if (CmUtil.IsNull(sData) == true || sData.Trim().Length <= 0) + { + // 상태값 변경 + // 프로그램이 아니고 일반 재시작 필요시 + EmgNoteFlgUpdate(CmUtil.GetDataRowStr(dr, "START_DT"), CmUtil.GetDataRowStr(dr, "MSG_CODE"), CmUtil.GetDataRowStr(dr, "MSG_DIV"), "1"); + } + + for (int iLoop = 0; iLoop < sRecvData.Length; iLoop++) + { + sData = sRecvData[iLoop].ToString(); + if (CmUtil.IsNull(sData) == true || sData.Trim().Length <= 0) continue; + + sFTP_IP = htRecvData[Column.IQ_PGMUPDATE_RSP.DATA.FTP_IP].ToString(); + iFTP_Port = CmUtil.IntParse(htRecvData[Column.IQ_PGMUPDATE_RSP.DATA.FTP_PORT].ToString()); + sFTP_ID = htRecvData[Column.IQ_PGMUPDATE_RSP.DATA.FTP_ID].ToString(); + sFTP_Pwd = htRecvData[Column.IQ_PGMUPDATE_RSP.DATA.FTP_PWD].ToString(); + + aRecvData = sRecvData[iLoop].Split(new string[] { "|" }, StringSplitOptions.None); + sGroup = aRecvData[0].ToString(); // 그룹 + sKind = aRecvData[1].ToString(); // 배포구분 : 01:프로그램, 02:프로그램(기타), 03:객면 컨텐츠, 04:상품이미지, 20:영수증 로고 이미지, 21:서명패드 펌웨어, 22:서명패드 동영상, 23:서명패드 이미지 + sApplyDate = aRecvData[3].ToString(); // 적용일자 + sApplyTime = aRecvData[10].ToString(); // 적용시간 + sFilePath = aRecvData[4].ToString(); // 파일위치 + if (CmUtil.RightH(sFilePath, 1) != "/") sFilePath += "/"; + sFileNm = aRecvData[5].ToString(); // 파일명 + sFileVer = aRecvData[6].ToString(); // 파일버전 + sFileSeq = aRecvData[7].ToString(); // 파일Seq + sDeployDate = aRecvData[8].ToString(); // 다운일자 + sDeployTime = aRecvData[9].ToString(); // 다운시간 + sDeployDT = aRecvData[11].ToString(); // 배포일자 + sUseYn = "1"; // 사용유무 + + // 다운로드 이력 저장 + sRet = m_cSvr2Tran.PGMUpdate_History_Isert(sGroup + sKind, sFileSeq, sFileVer, sFileNm, sApplyDate, sApplyTime, "", sDeployDate, sDeployTime, sFTP_IP, iFTP_Port.ToString(), sFTP_ID, sFTP_Pwd, sFilePath, "0", sDeployDT, sUseYn); + } + + if (sRet != UserCom.RST_ERR) + { + // 다운로드 목록 체크 + sRet = LF_ProgramDownLoad(); + + if (sRet != UserCom.RST_ERR) + { + // 상태값 변경 + EmgNoteFlgUpdate(CmUtil.GetDataRowStr(dr, "START_DT"), CmUtil.GetDataRowStr(dr, "MSG_CODE"), CmUtil.GetDataRowStr(dr, "MSG_DIV"), "1"); + } + } + } + else + { + // 프로그램이 아니고 일반 재시작 필요시 + EmgNoteFlgUpdate(CmUtil.GetDataRowStr(dr, "START_DT"), CmUtil.GetDataRowStr(dr, "MSG_CODE"), CmUtil.GetDataRowStr(dr, "MSG_DIV"), "1"); + } + } + } + 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 프로그램 백그라운드 다운로드 + /// + /// 프로그램 백그라운드 다운로드 대상 조회 요청 + /// + /// + private string LF_ProgramDownLoad() + { + string sKind = ""; + string sDownDiv = "A"; + + string sRet = UserCom.RST_ERR; + DataTable dtData = new DataTable(); + string sQuery = ""; + string sLocalPath = BaseCom.NxDownPath; + string sApplyType = ""; + + string sFTP_IP = ""; + int iFTP_Port = 0; + string sFTP_ID = ""; + string sFTP_Pwd = ""; + + string sApplyDate = ""; + string sApplyTime = ""; + string sFilePath = ""; + string sFileNm = ""; + string sFileVer = ""; + string sFileSeq = ""; + string sDeployDate = ""; + string sDeployTime = ""; + string sDeployDT = ""; + string sUseYn = ""; + int iRet = -1; + + string sMsg = ""; + + try + { + // DB Connect + //m_cSqlDbService.SetDBConnectionString(m_cPosStatus.Base.LocalDbSource, m_cPosStatus.Base.LocalDbCatalog, m_cPosStatus.Base.LocalDbUserID, m_cPosStatus.Base.LocalDbPassword); + + sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, + m_cPosStatus.Base.LocalDbCatalog, + m_cPosStatus.Base.LocalDbUserID, + m_cPosStatus.Base.LocalDbPassword); + + // 프로그램 다운로드 이력조회 후 다운로드 시작 + sQuery = ""; + sQuery += "SELECT * \n"; + sQuery += " FROM POSMST..MST_PGM_VER_NEW \n"; + sQuery += " WHERE \n"; + sQuery += " CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'\n"; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'\n"; + sQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "'\n"; + sQuery += " AND APP_TYPE NOT IN('2') \n"; // 적용구분(1:다운완료, 2:적용완료, F:다운실패, E:적용실패) + sQuery += " AND DOWN_DIV <> '1' \n"; + sQuery += " AND ISNULL(DEPLOY_DATE, '') + ISNULL(DEPLOY_TIME, '') <= '" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmm") + "'\n"; + sQuery += " AND ISNULL(USE_YN, '1') = '" + PosConst.MST_USE_YN.YES + "' \n"; + sQuery += " ORDER BY 1, 2, 3, 4, 5, 6 \n"; + sQuery = sQuery.Replace("\t", " "); + + //iRet = m_cSqlDbService.DBSelect(sQuery, out dtData); + iRet = sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (System.Data.SqlClient.SqlParameter[])null, out dtData); + + if (dtData != null && dtData.Rows.Count > 0) + { + foreach (DataRow dr in dtData.Rows) + { + sKind = CmUtil.GetDataRowStr(dr, PosMst.MST_PGM_VER.DATA.KIND); + + sFTP_IP = CmUtil.GetDataRowStr(dr, "FTP_IP"); + iFTP_Port = CmUtil.IntParse(CmUtil.GetDataRowStr(dr, "FTP_PORT")); + sFTP_ID = CmUtil.GetDataRowStr(dr, "FTP_ID"); + sFTP_Pwd = CmUtil.GetDataRowStr(dr, "FTP_PWD"); + + sApplyDate = CmUtil.GetDataRowStr(dr, "APPLY_DATE"); // 적용일자 + sApplyTime = CmUtil.GetDataRowStr(dr, "APPLY_TIME"); // 적용시간 + sFilePath = CmUtil.GetDataRowStr(dr, "FTP_FILEPATH"); // 파일위치 + if (CmUtil.RightH(sFilePath, 1) != "/") sFilePath += "/"; + sFileNm = CmUtil.GetDataRowStr(dr, "FILE_NM"); // 파일명 + sFileVer = CmUtil.GetDataRowStr(dr, "FILE_VER"); // 파일버전 + sFileSeq = CmUtil.GetDataRowStr(dr, "FILE_SEQ"); // 파일Seq + sDeployDate = CmUtil.GetDataRowStr(dr, "DEPLOY_DATE"); // 다운로드일자 + sDeployTime = CmUtil.GetDataRowStr(dr, "DEPLOY_TIME"); // 다운로드시간 + sDeployDT = CmUtil.GetDataRowStr(dr, "DEPLOY_DT"); // 배포일자 + sUseYn = "1"; // 사용유무 + + // 이전에 받은파일이 있는지 체크 + if (CmUtil.Exists(BaseCom.NxBackPath + PosConst.BACKUP_PATH.PGM + sFileNm) != true) + { + if (m_cNetworkFTP.Connect(sFTP_IP, sFTP_ID, sFTP_Pwd, 10, iFTP_Port) == 0) + { + // FTP 다운로드 + CmUtil.FileDelete(sLocalPath + sFileNm); + iRet = m_cNetworkFTP.Download(sFilePath, sLocalPath, sFileNm, ref sMsg, m_cPosStatus.Base.FtpConnType); + + if (iRet != 0) + { + sApplyType = ItemConst.PGM_DOWN_STATE.DownLoad_Fail; + + 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 (함수명)) + MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0282) + "\n" + sMsg); + } + else + { + // 다운로드만 적용 + sApplyType = ItemConst.PGM_DOWN_STATE.DownLoad_OK; + } + } + else + { + // 다운로드 실패 + sApplyType = ItemConst.PGM_DOWN_STATE.DownLoad_Fail; + } + } + else + { + // 다운로드만 적용 + sApplyType = ItemConst.PGM_DOWN_STATE.DownLoad_OK; + + // 백업된 파일을 다운로드 폴더에 복사 + CmUtil.FileCopy(sFileNm, BaseCom.NxBackPath + PosConst.BACKUP_PATH.PGM, sLocalPath, ""); + } + + // 다운로드 이력 저장 + sRet = m_cSvr2Tran.PGMUpdate_History_Isert(sKind, sFileSeq, sFileVer, sFileNm, sApplyDate, sApplyTime, sApplyType, sDeployDate, sDeployTime, sFTP_IP, iFTP_Port.ToString(), sFTP_ID, sFTP_Pwd, sFilePath, "1", sDeployDT, sUseYn); + + // 수신 상태 전송 + sRet = m_cSvr2Tran.PGMUpdate_Complete(sKind, sApplyType, sFileNm, sFileSeq, sFileVer, sDownDiv, sDeployDate, sDeployDT); + } + } + } + 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 다운로드 프로그램 적용 + /// + /// 다운로드 프로그램 적용 + /// + /// + private string PGMUpdate_Apply(string sDownDiv) + { + string sRet = UserCom.RST_ERR; + string sApplyType = ""; + int iRet = -1; + + string sUnzip_RCPTLOGO_Path = BaseCom.NxImgPath + @"RCPTLOGO\"; + string sUnzip_SIGNPAD_Path = BaseCom.NxDonglePath; + string sUnzip_PGM_Path = BaseCom.NxDownPath + @"PGM\"; + string sUnzip_IMG_Path = BaseCom.NxDownPath; + + string sDelete_CAMPAIGN_Path = BaseCom.NxDownPath + @"CDP\CAMPAIGN\"; + string sDelete_CDP_COM_Path = BaseCom.NxDownPath + @"CDP\CDP_COM\"; + string sDelete_CUSTOMER_Path = BaseCom.NxDownPath + @"CDP\CUSTOMER\"; + string sDelete_ITEM_Path = BaseCom.NxDownPath + @"CDP\ITEM\"; + string sDelete_TEST_MODE_Path = BaseCom.NxDownPath + @"CDP\TEST_MODE\"; + string sDelete_ETC_Path = BaseCom.NxDownPath + @"CDP\ETC\"; + string sUnzipPath = ""; + DataTable dtData = new DataTable(); + + string sGroup = ""; + string sKind = ""; + + string sFTP_IP = ""; + int iFTP_Port = 0; + string sFTP_ID = ""; + string sFTP_Pwd = ""; + + string sApplyDate = ""; + string sApplyTime = ""; + string sFilePath = ""; + string sFileNm = ""; + string sFileVer = ""; + string sFileSeq = ""; + string sDeployDate = ""; + string sDeployTime = ""; + string sDeployDT = ""; + string sUseYn = ""; + + bool bUnZIp = false; + try + { + // DB Connect + m_cSqlDbService.SetDBConnectionString(m_cPosStatus.Base.LocalDbSource, m_cPosStatus.Base.LocalDbCatalog, m_cPosStatus.Base.LocalDbUserID, m_cPosStatus.Base.LocalDbPassword); + + string sQuery = ""; + sQuery = ""; + sQuery += "SELECT * \n"; + sQuery += " FROM POSMST..MST_PGM_VER_NEW \n"; + sQuery += " WHERE \n"; + sQuery += " CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"; + sQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n"; + sQuery += " AND APP_TYPE = '1' \n"; // 적용구분(1:다운완료, 2:적용완료, F:다운실패, E:적용실패) + //sQuery += " AND ISNULL(APPLY_DATE, '') <= '" + m_cPosStatus.Base.SaleDate + "'\n"; // 영업일로 하게되면 개점 이전에 적용되지 않아 서버에서 받은 시스템 일자로 조회 + //sQuery += " AND ISNULL(APPLY_DATE, '') + ISNULL(APPLY_TIME, '0000') <= '" + m_cPosStatus.Base.SaleDate + DateTime.Now.ToString("HHmm") + "'\n"; // 영업일로 하게되면 개점 이전에 적용되지 않아 서버에서 받은 시스템 일자로 조회 + sQuery += " AND ISNULL(APPLY_DATE, '') + ISNULL(APPLY_TIME, '') <= '" + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmm") + "'\n"; // 영업일로 하게되면 개점 이전에 적용되지 않아 서버에서 받은 시스템 일자로 조회 + sQuery += " AND ISNULL(USE_YN, '1') = '" + PosConst.MST_USE_YN.YES + "' \n"; + sQuery += " ORDER BY 1, 2, 3, 4, 5, 6 \n"; + sQuery = sQuery.Replace("\t", " "); + + iRet = m_cSqlDbService.DBSelect(sQuery, out dtData); + + if (dtData != null && dtData.Rows.Count > 0) + { + foreach (DataRow dr in dtData.Rows) + { + sGroup = CmUtil.MidH(CmUtil.GetDataRowStr(dr, PosMst.MST_PGM_VER.DATA.KIND), 0, 2); + sKind = CmUtil.GetDataRowStr(dr, PosMst.MST_PGM_VER.DATA.KIND); + + sFTP_IP = CmUtil.GetDataRowStr(dr, "FTP_IP"); + iFTP_Port = CmUtil.IntParse(CmUtil.GetDataRowStr(dr, "FTP_PORT")); + sFTP_ID = CmUtil.GetDataRowStr(dr, "FTP_ID"); + sFTP_Pwd = CmUtil.GetDataRowStr(dr, "FTP_PWD"); + + sApplyDate = CmUtil.GetDataRowStr(dr, "APPLY_DATE"); // 적용일자 + sApplyTime = CmUtil.GetDataRowStr(dr, "APPLY_TIME"); // 적용시간 + sFilePath = CmUtil.GetDataRowStr(dr, "FTP_FILEPATH"); // 파일위치 + if (CmUtil.RightH(sFilePath, 1) != "/") sFilePath += "/"; + sFileNm = CmUtil.GetDataRowStr(dr, "FILE_NM"); // 파일명 + sFileVer = CmUtil.GetDataRowStr(dr, "FILE_VER"); // 파일버전 + sFileSeq = CmUtil.GetDataRowStr(dr, "FILE_SEQ"); // 파일Seq + sDeployDate = CmUtil.GetDataRowStr(dr, "DEPLOY_DATE"); // 다운로드일자 + sDeployTime = CmUtil.GetDataRowStr(dr, "DEPLOY_TIME"); // 다운로드시간 + sDeployDT = CmUtil.GetDataRowStr(dr, "DEPLOY_DT"); // 배포일자 + sUseYn = "1"; // 사용유무 + + if (sFileNm.Trim() == "") continue; + + CmUtil.CreateDirectory(sUnzip_PGM_Path); + CmUtil.CreateDirectory(sUnzip_IMG_Path); + CmUtil.CreateDirectory(BaseCom.NxBackPath + PosConst.BACKUP_PATH.PGM); + + if (CmUtil.RightH(sFileNm, 3).ToUpper() == "ZIP") + { + if (sGroup == PosConst.PGM_UPDATE_TYPE.POSDOWN_GROUP_10) + sUnzipPath = sUnzip_IMG_Path; // 이미지 + else if (sGroup == PosConst.PGM_UPDATE_TYPE.POSDOWN_GROUP_20) + sUnzipPath = sUnzip_PGM_Path; // POS 프로그램 + else if (sGroup == PosConst.PGM_UPDATE_TYPE.POSDOWN_GROUP_30) + sUnzipPath = sUnzip_RCPTLOGO_Path; // 영수증 로고 이미지 + else if (sGroup == PosConst.PGM_UPDATE_TYPE.POSDOWN_GROUP_40 || sGroup == PosConst.PGM_UPDATE_TYPE.POSDOWN_GROUP_50 || sGroup == PosConst.PGM_UPDATE_TYPE.POSDOWN_GROUP_60) + sUnzipPath = sUnzip_SIGNPAD_Path; // 서명패드 + else sUnzipPath = sUnzip_PGM_Path; // 프로그램 + + + // 파일 존재 여부 체크 + if (File.Exists(BaseCom.NxDownPath + sFileNm) != true) + { + // 적용 상태 + sApplyType = ItemConst.PGM_DOWN_STATE.Update_Fail; + + // 다운로드 이력 저장 + sRet = m_cSvr2Tran.PGMUpdate_History_Isert(sKind, sFileSeq, sFileVer, sFileNm, sApplyDate, sApplyTime, sApplyType, sDeployDate, sDeployTime, sFTP_IP, iFTP_Port.ToString(), sFTP_ID, sFTP_Pwd, sFilePath, "1", sDeployDT, sUseYn); + if (sRet != UserCom.RST_OK) continue; + + // 수신 상태 전송 + sRet = m_cSvr2Tran.PGMUpdate_Complete(sKind, sApplyType, sFileNm, sFileSeq, sFileVer, sDownDiv, sDeployDate, sDeployDT); + if (sRet != UserCom.RST_OK) continue; + + continue; + } + + // 압축 해제 + CmUtil.UnZipFile(sUnzipPath, BaseCom.NxDownPath + sFileNm); + + + // 압축 파일 BACKUP으로 이동 + if (sGroup == PosConst.PGM_UPDATE_TYPE.POSDOWN_GROUP_20) + { + // PGM인 경우 차후 복구용으로 별도 위치로 이동한다. + CmUtil.FileMove(BaseCom.NxDownPath + sFileNm, BaseCom.NxBackPath + PosConst.BACKUP_PATH.PGM + sFileNm); + + // POSSTART.EXE가 존재하면 BIN폴더에 덮어쓴다. + CmUtil.FileCopy("PosStart.exe", sUnzipPath, BaseCom.NxBinPath, ""); + + bUnZIp = true; + } + else + { + // 적용후 zip 파일 삭제 + CmUtil.FileDelete(BaseCom.NxDownPath + sFileNm); + } + } + else + { + // 일반 파일이면 적용폴더로 그대로 이동 + CmUtil.FileMove(BaseCom.NxDownPath + sFileNm, sUnzipPath + sFileNm); + } + + // 적용 상태 + sApplyType = ItemConst.PGM_DOWN_STATE.Update_OK; + + // 다운로드 이력 저장 + sRet = m_cSvr2Tran.PGMUpdate_History_Isert(sKind, sFileSeq, sFileVer, sFileNm, sApplyDate, sApplyTime, sApplyType, sDeployDate, sDeployTime, sFTP_IP, iFTP_Port.ToString(), sFTP_ID, sFTP_Pwd, sFilePath, "1", sDeployDT, sUseYn); + if (sRet != UserCom.RST_OK) continue; + + // 수신 상태 전송 + sRet = m_cSvr2Tran.PGMUpdate_Complete(sKind, sApplyType, sFileNm, sFileSeq, sFileVer, sDownDiv, sDeployDate, sDeployDT); + if (sRet != UserCom.RST_OK) continue; + + if (sGroup == PosConst.PGM_UPDATE_TYPE.POSDOWN_GROUP_20) + { + // 이전 파일 삭제 + PGM_FileDelete(sKind, sFileVer, sFileSeq); + + // 프로그램 버전정보 설정 + SetProgramVerIni(sKind, sFileVer, sFileSeq); + } + } + } + + // 사용자 알림 메시지 체크용 설정 + m_bPGMReboot = bUnZIp; + } + catch (Exception ex) + { + WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); + + // 수신 상태 전송 + sApplyType = ItemConst.PGM_DOWN_STATE.Update_Fail; + sRet = m_cSvr2Tran.PGMUpdate_Complete(sKind, sApplyType, sFileNm, sFileSeq, sFileVer, sDownDiv, sDeployDate, sDeployDT); + } + return sRet; + } + #endregion + + #region 다운로드 프로그램 삭제 (현재 버전과 이전 버전 이외 삭제) + /// + /// 다운로드 프로그램 삭제 (현재 버전과 이전 버전 이외 삭제) + /// + /// + private string PGM_FileDelete(string sKind, string sFileVer, string sFileSeq) + { + string sRet = UserCom.RST_ERR; + string sUnzipPath = BaseCom.NxBackPath + PosConst.BACKUP_PATH.PGM; + int iRet = -1; + DataTable dtData = new DataTable(); + + string sFileNm = ""; + + try + { + // DB Connect + m_cSqlDbService.SetDBConnectionString(m_cPosStatus.Base.LocalDbSource + , m_cPosStatus.Base.LocalDbCatalog + , m_cPosStatus.Base.LocalDbUserID + , m_cPosStatus.Base.LocalDbPassword); + string sQuery = ""; + sQuery = ""; + sQuery += "SELECT \n"; + sQuery += " KIND \n"; + sQuery += " , FILE_VER \n"; + sQuery += " , FILE_SEQ \n"; + sQuery += " , FILE_NM \n"; + sQuery += "FROM POSMST..MST_PGM_VER_NEW \n"; + sQuery += "WHERE \n"; + sQuery += " CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'\n"; + sQuery += "AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'\n"; + sQuery += "AND POS_NO = '" + m_cPosStatus.Base.PosNo + "'\n"; + sQuery += "AND KIND = '" + sKind + "'\n"; + sQuery += "AND APP_TYPE <> '1' \n"; // 적용구분(1:다운완료, 2:적용완료, F:다운실패, E:적용실패) + sQuery += "AND FILE_VER + CONVERT(VARCHAR(5), FILE_SEQ) < '" + sFileVer + sFileSeq + "'\n"; + sQuery += "AND FILE_VER + CONVERT(VARCHAR(5), FILE_SEQ) NOT IN(SELECT ISNULL(MAX(FILE_VER + CONVERT(VARCHAR(5), FILE_SEQ)), 0) \n"; + sQuery += " FROM POSMST..MST_PGM_VER_NEW \n"; + sQuery += " WHERE \n"; + sQuery += " CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'\n"; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'\n"; + sQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "'\n"; + sQuery += " AND KIND = '" + sKind + "'\n"; + sQuery += " AND APP_TYPE <> '1' \n"; // 적용구분(1:다운완료, 2:적용완료, F:다운실패, E:적용실패) + sQuery += " AND FILE_VER + CONVERT(VARCHAR(5), FILE_SEQ) <> '" + sFileVer + sFileSeq + "'\n"; + sQuery += " AND ISNULL(USE_YN, '1') = '" + PosConst.MST_USE_YN.YES + "' \n"; + sQuery += " ) \n"; + sQuery += "AND ISNULL(USE_YN, '1') = '" + PosConst.MST_USE_YN.YES + "' \n"; + sQuery += "ORDER BY 1, 2, 3 \n"; + + sQuery = sQuery.Replace("\t", " "); + + iRet = m_cSqlDbService.DBSelect(sQuery, out dtData); + + if (dtData != null && dtData.Rows.Count > 0) + { + foreach (DataRow dr in dtData.Rows) + { + sKind = CmUtil.GetDataRowStr(dr, PosMst.MST_PGM_VER.DATA.KIND); + sFileNm = CmUtil.GetDataRowStr(dr, PosMst.MST_PGM_VER.DATA.FILE_NM); + + if (sFileNm.Trim() == "") continue; + + // 이전 파일 삭제 + CmUtil.FileDelete(sUnzipPath + sFileNm); + } + } + } + catch (Exception ex) + { + WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); + } + return sRet; + } + #endregion + + #region 프로그램 버전 ini 저장 + private string SetProgramVerIni(string sKind, string sVer, string sSeq) + { + string sRet = UserCom.RST_ERR; + + try + { + // 프로그램 버전정보 설정 + switch (sKind) + { + case PosConst.PGM_UPDATE_TYPE.POSDOWN_GROUP_20 + PosConst.PGM_UPDATE_TYPE.POSDOWN_GROUP_20_DIV.POS_PGM10: + { + m_cPosStatus.Ver.ProgramVer = sVer; + m_cPosStatus.Ver.ProgramVerSeq = sSeq; + break; + } + } + + // 프로그램 버전 INI 파일 설정 + CmMessage cmPosConfig = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosConfig); + cmPosConfig.GetMessage("PGMVER").MakeMessageOverWrite("ProgramVer" + CmUtil.MidH(sKind, 2, 2), sVer); + cmPosConfig.GetMessage("PGMVER").MakeMessageOverWrite("ProgramVerSeq" + CmUtil.MidH(sKind, 2, 2), sSeq); + cmPosConfig.MakeFileFromMessage(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosConfig); + sRet = UserCom.RST_OK; + + } + catch (Exception ex) + { + WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); + } + + return sRet; + } + #endregion + } +} diff --git a/Agent/MasterDown/DatabaseMssql.cs b/Agent/MasterDown/DatabaseMssql.cs new file mode 100644 index 0000000..7639925 --- /dev/null +++ b/Agent/MasterDown/DatabaseMssql.cs @@ -0,0 +1,132 @@ +using System.Data.SqlClient; +using System.Data; +using System.Diagnostics; + +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : MSSQL DB 관련 처리 +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.BackgroundDown +{ + public class DatabaseMssql + { + private SqlDB sqlDb = null; + + public bool Begin() + { + return sqlDb.DBBeginTransaction(); + } + + public bool Commit() + { + return sqlDb.DBTransactionCommit(); + } + + public bool Rollback() + { + return sqlDb.DBTransactionRollback(); + } + + public void Close() + { + sqlDb.DBClose(); + } + + /// + /// SQL DataTable를 이용한 Select + /// return -> 1:OK, -1:Connection 정보 에러, -2:SQL 에러, -3:기타 에러, 0:Select 결과 없음 + /// + /// + /// + /// + public int DBSelect(string sQuery, out DataTable outDtReturn) + { + int iReturn = -9; + DataTable dtReturn = null; + + string strCommand = sQuery; + CommandType sqlCommandType = CommandType.Text; + + //System.Diagnostics.Debug.Print("SQL=" + sQuery); + iReturn = sqlDb.DBDataTableSelect(strCommand, sqlCommandType, (SqlParameter[])null, out dtReturn); + + outDtReturn = dtReturn; + return iReturn; + } + + /// + /// return -> 1:OK, -1:Connection 에러, -2:SQL 에러, -3:기타 에러, -4:적용된 Row 없음 + /// + /// + /// + public int DBExecuteNonQuery(string sQuery) + { + int iReturn = 0; + + CommandType sqlCommandType = CommandType.Text; + + iReturn = sqlDb.DBExecuteNonQuery(sQuery, sqlCommandType, (SqlParameter[])null); + + return iReturn; + } + + /// + /// return -> 1:OK, -1:Connection 에러, -2:SQL 에러, -3:기타 에러, -4:적용된 Row 없음 + /// + /// + /// + public int DBExecuteNonQuery(string[] sQuery) + { + int iReturn = 0; + + CommandType sqlCommandType = CommandType.Text; + + iReturn = sqlDb.DBExecuteNonQuery(sQuery, sqlCommandType, (SqlParameter[])null); + + return iReturn; + } + + /// + /// return -> 1:OK, -1:Connection 에러, -2:SQL 에러, -3:기타 에러, -4:적용된 Row 없음 + /// + /// + /// + public int DBExecuteNonQuery(string[] sQuery, bool bStandAlone) + { + int iReturn = 0; + + CommandType sqlCommandType = CommandType.Text; + + iReturn = sqlDb.DBExecuteNonQuery(sQuery, sqlCommandType, (SqlParameter[])null, bStandAlone); + + return iReturn; + } + + /// + /// MSSQL Database Conntction String + /// + /// + /// + /// + /// + public bool SetDBConnectionString(string pDataSource, string pInitialCatalog, string pUID, string pPassword) + { + bool bReturn = false; + + if(sqlDb != null) + { + if (sqlDb.IsDBOpen()) sqlDb.DBClose(); + } + + sqlDb = new SqlDB(pDataSource, pInitialCatalog, pUID, pPassword); + + bReturn = sqlDb.IsDBOpen(); + + return bReturn; + } + + } +} diff --git a/Agent/MasterDown/NetworkFtp.cs b/Agent/MasterDown/NetworkFtp.cs new file mode 100644 index 0000000..ab58574 --- /dev/null +++ b/Agent/MasterDown/NetworkFtp.cs @@ -0,0 +1,181 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Net; +using System.Collections; +using System.Diagnostics; +using System.Runtime.Serialization.Formatters.Binary; +using System.Data; + +using System.Net.Sockets; +using System.Threading; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : FTP 다운로드 +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.BackgroundDown +{ + public class NetworkFtp : INetworkFTP + { + private readonly string LOCAL_DOWN_PATH = BaseCom.NxRootPath + @"DOWN\"; //Download File Location (다운로드 파일위치) + + /// + /// StateServer Object (StateServer 객체) + /// + public StateServer StateObject = (StateServer)StateServer.GetInstance(); + /// + /// POS Status Value (POS 상태값) + /// + private PosStatus m_cPosStatus = null; + + private FTP m_ClsFtp; + + public NetworkFtp() + { + m_cPosStatus = (PosStatus)StateObject.POS; + } + + /// + /// FTP 서버에 Connect + /// + /// + /// + /// + /// + /// + /// 0 : 정상접속, -1:시간초과, -2:로그인 실패, -3:서버접속 실패, -4:지원하지 않는 시스템 + public int Connect(string sServer, string sUserId, string sPassword, int iTimeOutSeconds, int iPort) + { + int nReturn = -9; + + try + { + m_ClsFtp = new FTP((iPort == 0) ? sServer : sServer + ":" + iPort, sUserId, sPassword); + + if (m_ClsFtp != null) nReturn = 0; + else nReturn = -1; + + ////m_ClsFtp = new ClsFtp(sServer, sUserId, sPassword, iTimeOutSeconds, iPort); + + ////if ((nReturn = m_ClsFtp.Connect()) != 0) + ////{ + //// //MessageBox.Show("FTP Server Connect Error !!! [" + nReturn.ToString() + "]"); + //// return nReturn; + ////} + + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkFtp.Connect()", e.Message); + return nReturn; + } + + return nReturn; + } + + /// + /// + /// + /// + /// + /// + /// 0:정상종료, -1:Not Connected, -2:Binary Mode set failed, -3: failed local file Create, -4:socket 에러, -5:remote file 없슴, -6:정상수신실패, -7: 파일사이즈 틀림 + public int Download(string sSvrDirectory, string sLocalDirectory, string sFileNm, string sFtpMode = PosConst.FTP_CONN_TYPE.PASSIVE) + { + string sMsg = ""; + return Download(sSvrDirectory, sLocalDirectory, sFileNm, ref sMsg, sFtpMode); + } + public int Download(string sSvrDirectory, string sLocalDirectory, string sFileNm, ref string sMsg, string sFtpMode = PosConst.FTP_CONN_TYPE.PASSIVE) + { + int nReturn = -9; + bool bRet = false; + try + { + if (CmUtil.RightH(sLocalDirectory, 1) != "\\") sLocalDirectory += "\\"; + + if (Directory.Exists(sLocalDirectory) == false) Directory.CreateDirectory(sLocalDirectory); + + bRet = m_ClsFtp.Download(sSvrDirectory + sFileNm, sLocalDirectory + sFileNm, ref sMsg, sFtpMode); + + if (bRet) nReturn = 0; + else nReturn = -1; + ////if ((nReturn = m_ClsFtp.Connect()) != 0) + ////{ + //// return nReturn; + ////} + + ////string sDir = m_ClsFtp.ChangeDir(sSvrDirectory); + + ////nReturn = m_ClsFtp.Download(sLocalDirectory, sFileNm, true); + ////if (nReturn < 0 && File.Exists(BaseCom.NxDownPath + sFileNm + ".ftp") == true) + ////{ + //// File.Delete(BaseCom.NxDownPath + sFileNm + ".ftp"); + ////} + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkFtp.Download()", e.Message); + + sMsg = sFileNm + " " + e.Message; + return nReturn; + } + + return nReturn; + } + + /// + /// FTP서버와의 연결을 종료 + /// + public void Disconnect() + { + //m_ClsFtp.Close(); + //m_ClsFtp.cleanup(); + } + + /// + /// 정해진 디렉토리에 정해진 파일을 업로드 + /// + /// + /// + /// + /// 0:정상완료, -1:Not Connected, -2: data socket create error, -3: file write 실패, -4:socket error, -5: 정상처리 실패(서버) + public int Upload(string sSvrDirectory, string sLocalDirectory, string sFileNm) + { + int nReturn = -9; + bool bRet = false; + + try + { + bRet = m_ClsFtp.Upload(sLocalDirectory + sFileNm, sSvrDirectory + sFileNm); + + if (bRet) nReturn = 0; + else nReturn = -1; + ////if ((nReturn = m_ClsFtp.Connect()) != 0) + ////{ + //// return nReturn; + ////} + + ////string sDir = m_ClsFtp.ChangeDir(sSvrDirectory); + + ////nReturn = m_ClsFtp.Upload(sLocalDirectory, sFileNm, true); + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkFtp.Upload()", e.Message); + + return nReturn; + } + return nReturn; + } + } +} diff --git a/Agent/MasterDown/NetworkIRT.cs b/Agent/MasterDown/NetworkIRT.cs new file mode 100644 index 0000000..f2bd159 --- /dev/null +++ b/Agent/MasterDown/NetworkIRT.cs @@ -0,0 +1,669 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.Collections; +using System.Net.NetworkInformation; +using System.Runtime.InteropServices; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : SC / HQ IRT Request (SC / 본부 IRT 요청) +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.BackgroundDown +{ + public class NetworkIRT + { + private SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출 + private StateServer StateObject = (StateServer)StateServer.GetInstance(); // StateObject : StateServer Object (객체) + private PosStatus m_cPosStatus; // 기본정보 참조 + private DeviceStatus m_cDevStatus; // 장비정보 참조 + + /// + /// Sending Socket (전송 소켓) + /// + private static TcpSocket m_IrtSocket = null; + + /// + /// IP + /// + private string m_ServerIp = ""; + + /// + /// Port + /// + private int m_ServerPort = 0; + + /// + /// TimeOut + /// + private int m_ServerTimeout = 10000; + + /// --------------------------------------------------------------------------------------------- + /// + /// Constructor (생성자) + /// + /// --------------------------------------------------------------------------------------------- + public NetworkIRT() + { + m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 + m_cDevStatus = (DeviceStatus)StateObject.DEVICE; // POS 장치정보 (PDA) + } + + #region OnLine 상태체크 + /// + /// Get network online status with Ping check. (Ping체크로 network Online상태를 취득한다,) + /// + /// Ip address + /// True : online false : Offline + private int CheckNetworkOnline(string pHostAddress) + { + //Ping Check (Ping 체크) + Ping pingSender = new Ping(); + PingOptions optins = new PingOptions(); + optins.DontFragment = true; + string data = "aaa"; + byte[] buffer = Encoding.ASCII.GetBytes(data); + int timeout = 120; + PingReply reply = pingSender.Send(pHostAddress, timeout, buffer, optins); + + if (reply.Status == IPStatus.Success) + return UserCom.OK; + else + return UserCom.NG; + } + #endregion + + #region 암호화 편집 + /// + /// 암호화 위해 전문 편집 + /// + /// 평문 + /// 암호문, 에러시 평문 리턴 + private byte[] EncryptData(byte[] plainData) + { + int nNowPos = 0; + + //통신헤더전문편집 + string[] aCommHead = new string[Column.COMM_HEADER.LEN.Length]; + ItemColumn.ParseMessage(Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE, plainData, ref nNowPos, ref aCommHead); + + string sPosNo = aCommHead[Column.COMM_HEADER.SEQ.PosNo].ToString(); + //string sRegNo = aCommHead[Column.COMM_HEADER.SEQ.RegNo].ToString(); + string sRegNo = ""; + string sMsgLen = aCommHead[Column.COMM_HEADER.SEQ.MsgLen].ToString(); + string sEncType = aCommHead[Column.COMM_HEADER.SEQ.EncType].ToString(); + byte[] byteEncryptData = null; + byte[] editedAllData = null; + + if (sEncType == "0") // "0" 평문 + { + //Tran헤더 포함 전문 데이터 + byte[] tranBytes = new byte[plainData.Length - nNowPos]; + + Array.Copy(plainData, nNowPos, tranBytes, 0, plainData.Length - nNowPos); + + //암호화 + byteEncryptData = AES.DynamicKeyEncrypt(sPosNo, sRegNo, tranBytes); + + int iMsgLen = nNowPos + byteEncryptData.Length; + + aCommHead[Column.COMM_HEADER.SEQ.MsgLen] = iMsgLen.ToString(); //공통헤더와 암호문 더해진 길이 + aCommHead[Column.COMM_HEADER.SEQ.EncType] = "1"; //0:평문 1:암호화 + + string sChangedCommHeader = ItemColumn.MakeMessage(aCommHead, Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE); + byte[] byteCommHeader = Encoding.UTF8.GetBytes(sChangedCommHeader); + + editedAllData = new byte[iMsgLen]; + Array.Copy(byteCommHeader, editedAllData, byteCommHeader.Length); + Array.Copy(byteEncryptData, 0, editedAllData, byteCommHeader.Length, byteEncryptData.Length); + + return editedAllData; + } + else // "1" 암호문 + { + return plainData; + } + + } + + #endregion + + #region 복호화 편집 + /// + /// 복호화 위해 전문 편집 + /// + /// + /// + private byte[] DecryptData(byte[] EncryptData) + { + int nNowPos = 0; + + //통신헤더전문편집 + string[] aCommHead = new string[Column.COMM_HEADER.LEN.Length]; + ItemColumn.ParseMessage(Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE, EncryptData, ref nNowPos, ref aCommHead); + + string sPosNo = aCommHead[Column.COMM_HEADER.SEQ.PosNo].ToString(); + //string sRegNo = aCommHead[Column.COMM_HEADER.SEQ.RegNo].ToString(); + string sRegNo = ""; + string sMsgLen = aCommHead[Column.COMM_HEADER.SEQ.MsgLen].ToString(); + string sEncType = aCommHead[Column.COMM_HEADER.SEQ.EncType].ToString(); + byte[] bytePlainData = null; + byte[] editedAllData = null; + + if (sEncType == "1") //복호화 + { + //Tran헤더 포함 전문 데이터 + byte[] tranBytes = new byte[EncryptData.Length - nNowPos]; + + Array.Copy(EncryptData, nNowPos, tranBytes, 0, tranBytes.Length); + + //복호화 + bytePlainData = AES.DynamicKeyDecrypt(sPosNo, sRegNo, tranBytes); + + int iMsgLen = nNowPos + bytePlainData.Length; + + aCommHead[Column.COMM_HEADER.SEQ.MsgLen] = iMsgLen.ToString(); //공통헤더와 암호문 더해진 길이 + aCommHead[Column.COMM_HEADER.SEQ.EncType] = "0"; //0:평문 1:암호화 + + string sChangedCommHeader = ItemColumn.MakeMessage(aCommHead, Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE); + + byte[] byteCommHeader = Encoding.Default.GetBytes(sChangedCommHeader); + editedAllData = new byte[byteCommHeader.Length + bytePlainData.Length]; + + Array.Copy(byteCommHeader, editedAllData, byteCommHeader.Length); + Array.Copy(bytePlainData, 0, editedAllData, byteCommHeader.Length, bytePlainData.Length); + + return editedAllData; + + } + else + { + return EncryptData; + } + + } + + #endregion + + #region IRT Send/Receive + /// + /// IRT전문의 Send/Receive + /// + /// + /// + /// + private int SendReceiveData(byte[] pSendData, ref byte[] pRecvData) + { + int nRecvLen = 0; + int nStat = BaseCom.NG; + byte[] rRecvData = null; + + try + { + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + // Data Send & Receive + nRecvLen = m_IrtSocket.SendReceiveData(pSendData, ref rRecvData, m_ServerTimeout); + + if (nRecvLen > 0) + { + pRecvData = rRecvData; + nStat = BaseCom.OK; + } + else + { + pRecvData = null; + } + m_IrtSocket.Close(); + } + catch (Exception e) + { + if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkIRT.SendReceiveData()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + finally + { + } + System.Threading.Thread.Sleep(100); + return nStat; + } + + /// + /// IRT전문의 Send/Receive + /// + /// + /// + /// + private int SendReceiveData(string pSendData, ref string pRecvData) + { + int nRecvLen = 0; + int nStat = BaseCom.NG; + string rRecvData = ""; + + try + { + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + // Data Send & Receive + nRecvLen = m_IrtSocket.SendReceiveData(pSendData, ref rRecvData, m_ServerTimeout); + + if (nRecvLen > 0) + { + pRecvData = rRecvData; + nStat = BaseCom.OK; + } + else + { + pRecvData = ""; + nStat = nRecvLen; + } + m_IrtSocket.Close(); + } + catch (Exception e) + { + if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkIRT.SendReceiveData()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + finally + { + } + + System.Threading.Thread.Sleep(100); + return nStat; + } + #endregion + + #region IRT 암호화/복화화 전송 + /// + /// IRT String로의 Send/Recv + /// + /// + /// + /// + /// + /// + /// + public int IRTSendReceive(string sIP, int iPort, int iTimeOut, string sComm, ref string sRecvData) + { + int nStat = 9; + string sReturn = string.Empty; + + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + byte[] bEditedSendData = null; + + if (m_ServerIp != "" && m_ServerPort != 0) + { + //암호화 + if (sComm.Length != 0) + { + //bEditedSendData = EncryptData(Encoding.Default.GetBytes(sComm)); + bEditedSendData = Encoding.Default.GetBytes(sComm); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceive()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sComm); + } + else + { + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceive()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] SendData is Null"); + } + + //SendReceive + nStat = SendReceiveData(Encoding.Default.GetString(bEditedSendData, 0, bEditedSendData.Length), ref sReturn); + + //복호화 + if (sReturn.Length != 0) + { + byte[] byteRecv = DecryptData(Encoding.Default.GetBytes(sReturn)); + sRecvData = Encoding.Default.GetString(byteRecv, 0, byteRecv.Length); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceive()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sRecvData); + } + else + { + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceive()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] RecvData Is Null"); + } + } + + return nStat; + } + + /// + /// IRT Byte로의 Send/Recv + /// + /// + /// + /// + /// + /// + /// + public int IRTSendReceive(string sIP, int iPort, int iTimeOut, byte[] comm, ref byte[] sRecvData) + { + int nStat = 9; + string sReturn = string.Empty; + + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + byte[] bEditedSendData = null; + + if (m_ServerIp != "" && m_ServerPort != 0) + { + //암호화 + if (comm != null) + { + bEditedSendData = EncryptData(comm); + + string sTmpLog = Encoding.Default.GetString(comm, 0, comm.Length); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceive()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sTmpLog); + } + else + { + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceive()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] SendData Is Null"); + } + + //SendReceive + nStat = SendReceiveData(bEditedSendData, ref sRecvData); + + //복호화 + if (sRecvData != null) + { + byte[] sDecryptRecvData = DecryptData(sRecvData); + + sRecvData = sDecryptRecvData; + + string sTmpLog = Encoding.Default.GetString(sDecryptRecvData, 0, sDecryptRecvData.Length); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceive()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sTmpLog); + } + else + { + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceive()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] RecvData Is Null"); + } + } + + return nStat; + } + #endregion + + #region IRT 전송 - 외부 VAN + /// + /// IRT String로의 Send/Recv - 외부 Van + /// + /// + /// + /// + /// + /// + /// + /// + /// + public int IRTSendReceiveEx(string sIP, int iPort, int iTimeOut, string sSendData, ref string sRecvData, int nRecvDataLen, string sAckData) + { + return IRTSendReceiveEx(sIP, iPort, iTimeOut, sSendData, ref sRecvData, nRecvDataLen, sAckData, false); + } + + public int IRTSendReceiveEx(string sIP, int iPort, int iTimeOut, string sSendData, ref string sRecvData, int nRecvDataLen, string sAckData, bool bErrorSkip) + { + int nStat = BaseCom.NG; + try + { + sRecvData = ""; + if (sIP == "" || iPort == 0) return nStat; + + // Connect 설정 + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveEx()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sSendData); + + // Data Send & Receive + System.Diagnostics.Debug.Print("요청=" + sSendData); + nStat = m_IrtSocket.SendReceiveData(sSendData, ref sRecvData, m_ServerTimeout, nRecvDataLen, sAckData, bErrorSkip); + System.Diagnostics.Debug.Print("응답=" + sRecvData); + + if (nStat > 0) nStat = BaseCom.OK; + + m_IrtSocket.Close(); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveSEx()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sRecvData); + } + catch (Exception e) + { + if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkIRT.SendReceiveDataEx()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + + System.Threading.Thread.Sleep(100); + return nStat; + } + + /// + /// IRT Byte로의 Send/Recv - 외부 Van + /// + /// + /// + /// + /// + /// + /// + /// + /// + public int IRTSendReceiveEx(string sIP, int iPort, int iTimeOut, byte[] bSendData, ref byte[] bRecvData, int nRecvDataLen, byte[] sAckData) + { + int nStat = BaseCom.NG; + try + { + bRecvData[0] = 0; + if (sIP == "" || iPort == 0) return nStat; + + // Connect 설정 + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveEx()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + Encoding.Default.GetString(bSendData, 0, bSendData.Length)); + + // Data Send & Receive + System.Diagnostics.Debug.Print("요청=" + Encoding.Default.GetString(bSendData, 0, bSendData.Length)); + nStat = m_IrtSocket.SendReceiveData(bSendData, ref bRecvData, m_ServerTimeout, nRecvDataLen, sAckData); + System.Diagnostics.Debug.Print("응답=" + Encoding.Default.GetString(bRecvData, 0, bRecvData.Length)); + if (nStat > 0) nStat = BaseCom.OK; + + m_IrtSocket.Close(); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveEx()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + Encoding.Default.GetString(bRecvData, 0, bRecvData.Length)); + } + catch (Exception e) + { + if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkIRT.SendReceiveDataEx()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + return nStat; + } + #endregion + + #region IRT 전송 - 외부 VAN (전문길이 위치지정) + + /// + /// IRT String로의 Send/Recv - 외부 Van (길이 위치지정) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public int IRTSendReceiveLen(string sIP, int iPort, int iTimeOut, string sSendData, ref string sRecvData, bool bFullSize, int nRecvDataLen, int nRecvDataStartPosion) + { + int nStat = BaseCom.NG; + try + { + sRecvData = ""; + if (sIP == "" || iPort == 0) return nStat; + + // Connect 설정 + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveLen()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sSendData); + + // Data Send & Receive + System.Diagnostics.Debug.Print("요청=" + sSendData); + nStat = m_IrtSocket.SendReceiveData(sSendData, ref sRecvData, m_ServerTimeout, bFullSize, nRecvDataLen, "", nRecvDataStartPosion, false ); + System.Diagnostics.Debug.Print("응답=" + sRecvData); + + if (nStat > 0) nStat = BaseCom.OK; + + m_IrtSocket.Close(); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveLen()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sRecvData); + } + catch (Exception e) + { + if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkIRT.SendReceiveDataEx()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + + System.Threading.Thread.Sleep(100); + return nStat; + } + + /// + /// IRT Byte로의 Send/Recv - 외부 Van (전문길이 위치지정) + /// + /// + /// + /// + /// + /// + /// + /// + /// + public int IRTSendReceiveLen(string sIP, int iPort, int iTimeOut, byte[] bSendData, ref byte[] bRecvData, int nRecvDataLen, int nRecvDataStartPosion) + { + int nStat = BaseCom.NG; + try + { + bRecvData[0] = 0; + if (sIP == "" || iPort == 0) return nStat; + + // Connect 설정 + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveLen()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + Encoding.Default.GetString(bSendData, 0, bSendData.Length)); + + // Data Send & Receive + System.Diagnostics.Debug.Print("요청=" + Encoding.Default.GetString(bSendData, 0, bSendData.Length)); + nStat = m_IrtSocket.SendReceiveData(bSendData, ref bRecvData, m_ServerTimeout, nRecvDataLen, null, nRecvDataStartPosion); + System.Diagnostics.Debug.Print("응답=" + Encoding.Default.GetString(bRecvData, 0, bRecvData.Length)); + if (nStat > 0) nStat = BaseCom.OK; + + m_IrtSocket.Close(); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveLen()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + Encoding.Default.GetString(bRecvData, 0, bRecvData.Length)); + } + catch (Exception e) + { + if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkIRT.SendReceiveDataLen()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + return nStat; + } + #endregion + + #region IRT Byte로의 Send/Recv - 외부 Van (Bypass Byte) + /// + /// IRT Byte로의 Send/Recv - 외부 Van (Bypass Byte) + /// + /// + /// + /// + /// + /// + /// + /// + public int ByPassSendReceiveData(string sIP, int iPort, int iTimeOut, byte[] bSendData, ref byte[] bRecvData, int nRecvDataLen) + { + int nStat = BaseCom.NG; + try + { + //bRecvData[0] = 0; + if (sIP == "" || iPort == 0) return nStat; + + // Connect 설정 + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveLen()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + Encoding.Default.GetString(bSendData, 0, bSendData.Length)); + + // Data Send & Receive + System.Diagnostics.Debug.Print("요청=" + Encoding.Default.GetString(bSendData, 0, bSendData.Length)); + nStat = m_IrtSocket.ByPassSendReceiveData(bSendData, nRecvDataLen, ref bRecvData, m_ServerTimeout); + System.Diagnostics.Debug.Print("응답=" + Encoding.Default.GetString(bRecvData, 0, bRecvData.Length)); + if (nStat > 0) nStat = BaseCom.OK; + + m_IrtSocket.Close(); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveLen()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + Encoding.Default.GetString(bRecvData, 0, bRecvData.Length)); + } + catch (Exception e) + { + if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkIRT.SendReceiveDataLen()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + return nStat; + } + #endregion + } +} diff --git a/Agent/MasterDown/NetworkJSON.cs b/Agent/MasterDown/NetworkJSON.cs new file mode 100644 index 0000000..f117dfa --- /dev/null +++ b/Agent/MasterDown/NetworkJSON.cs @@ -0,0 +1,581 @@ +//#define LOG_TRACE //@@ 2017.11.01;로그 확인시 사용;girak.kim +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.Collections; +using System.Net.NetworkInformation; +using System.Runtime.InteropServices; + +using Newtonsoft.Json; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : SC / HQ IRT Request (SC / 본부 IRT 요청) +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.BackgroundDown +{ + public class NetworkJSON + { + private SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출 + private StateServer StateObject = (StateServer)StateServer.GetInstance(); // StateObject : StateServer Object (객체) + private PosStatus m_cPosStatus; // 기본정보 참조 + private DeviceStatus m_cDevStatus; // 장비정보 참조 + + /// + /// Sending Socket (전송 소켓) + /// + private static TcpSocket m_IrtSocket = null; + + /// + /// IP + /// + private string m_ServerIp = ""; + + /// + /// Port + /// + private int m_ServerPort = 0; + + /// + /// Recv Timeout + /// + private int m_ServerTimeout = 5000; + + + /// --------------------------------------------------------------------------------------------- + /// + /// Constructor (생성자) + /// + /// --------------------------------------------------------------------------------------------- + public NetworkJSON() + { + m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 + m_cDevStatus = (DeviceStatus)StateObject.DEVICE; // POS 장치정보 + } + + /// + /// Get network online status with Ping check. (Ping체크로 network Online상태를 취득한다,) + /// + /// Ip address + /// True : online false : Offline + private int CheckNetworkOnline(string pHostAddress) + { + //Ping Check (Ping 체크) + Ping pingSender = new Ping(); + PingOptions optins = new PingOptions(); + optins.DontFragment = true; + string data = "aaa"; + byte[] buffer = Encoding.ASCII.GetBytes(data); + int timeout = 120; + PingReply reply = pingSender.Send(pHostAddress, timeout, buffer, optins); + + if (reply.Status == IPStatus.Success) + return UserCom.OK; + else + return UserCom.NG; + } +/* + #region 암호화 편집 + /// + /// 암호화 위해 전문 편집 + /// + /// 평문 + /// 암호문, 에러시 평문 리턴 + private byte[] EncryptData(byte[] plainData) + { + int nNowPos = 0; + + //통신헤더전문편집 + string[] aCommHead = new string[Column.COMM_HEADER.LEN.Length]; + ItemColumn.ParseMessage(Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE, plainData, ref nNowPos, ref aCommHead); + + string sPosNo = aCommHead[Column.COMM_HEADER.SEQ.PosNo].ToString(); + //string sRegNo = aCommHead[Column.COMM_HEADER.SEQ.RegNo].ToString(); + string sRegNo = ""; + string sMsgLen = aCommHead[Column.COMM_HEADER.SEQ.MsgLen].ToString(); + string sEncType = aCommHead[Column.COMM_HEADER.SEQ.EncType].ToString(); + byte[] byteEncryptData = null; + byte[] editedAllData = null; + + if (sEncType == "0") // "0" 평문 + { + //Tran헤더 포함 전문 데이터 + byte[] tranBytes = new byte[plainData.Length - nNowPos]; + + Array.Copy(plainData, nNowPos, tranBytes, 0, plainData.Length - nNowPos); + + //암호화 + byteEncryptData = AES.DynamicKeyEncrypt(sPosNo, sRegNo, tranBytes); + + int iMsgLen = nNowPos + byteEncryptData.Length; + + aCommHead[Column.COMM_HEADER.SEQ.MsgLen] = iMsgLen.ToString(); //공통헤더와 암호문 더해진 길이 + aCommHead[Column.COMM_HEADER.SEQ.EncType] = "1"; //0:평문 1:암호화 + + string sChangedCommHeader = ItemColumn.MakeMessage(aCommHead, Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE); + byte[] byteCommHeader = Encoding.Default.GetBytes(sChangedCommHeader); + + editedAllData = new byte[iMsgLen]; + Array.Copy(byteCommHeader, editedAllData, byteCommHeader.Length); + Array.Copy(byteEncryptData, 0, editedAllData, byteCommHeader.Length, byteEncryptData.Length); + + return editedAllData; + } + else // "1" 암호문 + { + return plainData; + } + + } + + #endregion + + #region 복호화 편집 + /// + /// 복호화 위해 전문 편집 + /// + /// + /// + private byte[] DecryptData(byte[] EncryptData) + { + int nNowPos = 0; + + //통신헤더전문편집 + string[] aCommHead = new string[Column.COMM_HEADER.LEN.Length]; + ItemColumn.ParseMessage(Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE, EncryptData, ref nNowPos, ref aCommHead); + + string sPosNo = aCommHead[Column.COMM_HEADER.SEQ.PosNo].ToString(); + //string sRegNo = aCommHead[Column.COMM_HEADER.SEQ.RegNo].ToString(); + string sRegNo = ""; + string sMsgLen = aCommHead[Column.COMM_HEADER.SEQ.MsgLen].ToString(); + string sEncType = aCommHead[Column.COMM_HEADER.SEQ.EncType].ToString(); + byte[] bytePlainData = null; + byte[] editedAllData = null; + + if (sEncType == "1") //복호화 + { + //Tran헤더 포함 전문 데이터 + byte[] tranBytes = new byte[EncryptData.Length - nNowPos]; + + Array.Copy(EncryptData, nNowPos, tranBytes, 0, tranBytes.Length); + + //복호화 + bytePlainData = AES.DynamicKeyDecrypt(sPosNo, sRegNo, tranBytes); + + int iMsgLen = nNowPos + bytePlainData.Length; + + aCommHead[Column.COMM_HEADER.SEQ.MsgLen] = iMsgLen.ToString(); //공통헤더와 암호문 더해진 길이 + aCommHead[Column.COMM_HEADER.SEQ.EncType] = "0"; //0:평문 1:암호화 + + string sChangedCommHeader = ItemColumn.MakeMessage(aCommHead, Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE); + + byte[] byteCommHeader = Encoding.Default.GetBytes(sChangedCommHeader); + editedAllData = new byte[byteCommHeader.Length + bytePlainData.Length]; + + Array.Copy(byteCommHeader, editedAllData, byteCommHeader.Length); + Array.Copy(bytePlainData, 0, editedAllData, byteCommHeader.Length, bytePlainData.Length); + + return editedAllData; + + } + else + { + return EncryptData; + } + + } + + #endregion +*/ + /// + /// POS 마스터 요청 시 사용하는 Connect 함수 + /// + /// + private int Connect(int iKeepTime = 5000) + { + int iReturn = BaseCom.NG; + try + { + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + // Delay time to close connection is 5 sec. + iReturn = m_IrtSocket.Connect(iKeepTime); + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.Connect()", e.ToString()); + } + + return iReturn; + } + + private void Close() + { + m_IrtSocket.Close(); + } + + + + /// + /// IRT전문의 Send/Receive + /// + /// + /// + /// + private int SendReceiveData(byte[] pSendData, ref byte[] pRecvData) + { + int nRecvLen = 0; + int nStat = BaseCom.NG; + byte[] rRecvData = null; + + try + { + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + // Data Send & Receive + nRecvLen = m_IrtSocket.SendReceiveData(pSendData, ref rRecvData, m_ServerTimeout); + + if (nRecvLen > 0) + { + pRecvData = rRecvData; + nStat = BaseCom.OK; + } + else + { + pRecvData = null; + } + m_IrtSocket.Close(); + } + catch (Exception e) + { + if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.SendReceiveData()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + finally + { + } + System.Threading.Thread.Sleep(100); + return nStat; + } + + /// + /// IRT전문의 Send/Receive + /// + /// + /// + /// + private int SendReceiveData(string pSendData, ref string pRecvData, bool bIsDmbIf = false) + { + int nRecvLen = 0; + int nStat = BaseCom.NG; + string rRecvData = ""; + + try + { + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + // Data Send & Receive + //System.Diagnostics.Debug.Print("요청:" + pSendData); + nRecvLen = m_IrtSocket.SendReceiveData(pSendData, ref rRecvData, m_ServerTimeout, bIsDmbIf); + //System.Diagnostics.Debug.Print("응답:" + rRecvData); + + if (nRecvLen > 0) + { + pRecvData = rRecvData; + nStat = BaseCom.OK; + } + else + { + pRecvData = ""; + nStat = nRecvLen; + } + m_IrtSocket.Close(); + } + catch (Exception e) + { + if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.SendReceiveData()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + finally + { + } + + System.Threading.Thread.Sleep(100); + return nStat; + } + + private int SendReceiveMstData(string pSendData, ref string pRecvData) + { + int nRecvLen = 0; + int nStat = BaseCom.NG; + try + { + nRecvLen = m_IrtSocket.SendReceiveMstData(pSendData, ref pRecvData); + if (nRecvLen > 0) + { + nStat = BaseCom.OK; + } + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + e.ToString()); + } + + return nStat; + } + + /// + /// IRT Byte로의 Send/Recv + /// (공통헤더의 전문길이 0으로 세팅해서 송신. 자동 계산) + /// + /// + public int IRTSendReceive(string sIP, int iPort, int iTimeOut, string sCommData, Hashtable htData, ref Hashtable htRecvData) + { + int nStat = 9; + string sReturn = string.Empty; + string sRecvCommHeader = string.Empty; + string sRecvData = string.Empty; + + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + string sJsonSendData = ""; + string sJsonReceiveData = ""; + + try + { + if (m_ServerIp != "" && m_ServerPort != 0) + { + if (htData != null) + { + sJsonSendData = JsonConvert.SerializeObject(htData); + + //sJsonSendData 암호화 처리 ... + + Byte[] sBytTempBuff = Encoding.UTF8.GetBytes(sJsonSendData); + string sDataLen = string.Format("{0:000000}", sBytTempBuff.Length); + + sCommData = sDataLen + sCommData.Substring(TcpSocket.COMM_MSGLEN); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkJSON.IRTSendReceive()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sCommData + sJsonSendData); + } + + //Send Receive + nStat = SendReceiveData(sCommData + sJsonSendData, ref sJsonReceiveData); + + if (sJsonReceiveData != null && sJsonReceiveData != "") + { + sRecvCommHeader = sJsonReceiveData.Substring(0, TcpSocket.COMM_HEAD_LEN); + sRecvData = sJsonReceiveData.Substring(TcpSocket.COMM_HEAD_LEN); + //sJsonReceiveData 복호화 처리 ... + + htRecvData = JsonConvert.DeserializeObject(sRecvData); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkJSON.IRTSendReceive()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sRecvCommHeader + sRecvData); + } + } + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.IRTSendReceive()", e.ToString()); + } + + return nStat; + } + /// + /// 디지털메뉴보드 I/F용 send/receive + /// + /// + /// + /// + /// + /// + /// + /// + public int DmbIRTSendReceive(string sIP, int iPort, int iTimeOut, string sCommData, Hashtable htData, ref string sRecvedData) + { + int nStat = 9; + string sReturn = string.Empty; + string sRecvCommHeader = string.Empty; + string sRecvData = string.Empty; + + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + string sJsonSendData = ""; + string sJsonReceiveData = ""; + + try + { + if (m_ServerIp != "" && m_ServerPort != 0) + { + if (htData != null) + { + sJsonSendData = JsonConvert.SerializeObject(htData); + + //sJsonSendData 암호화 처리 ... + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkJSON.IRTSendReceive()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sCommData + sJsonSendData); + } + + byte[] bytes = Encoding.UTF8.GetBytes(sCommData + sJsonSendData); + string sUTF8String = Encoding.UTF8.GetString(bytes); + + //Send Receive + //nStat = SendReceiveData(sCommData + sJsonSendData, ref sJsonReceiveData, true); + nStat = SendReceiveData(sUTF8String, ref sJsonReceiveData, true); + + if (sJsonReceiveData != null && sJsonReceiveData != "") + { + sRecvCommHeader = sJsonReceiveData.Substring(0, 60); + sRecvData = sJsonReceiveData.Substring(60); + + sRecvedData = sRecvCommHeader; + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkJSON.IRTSendReceive()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sRecvCommHeader + sRecvData); + } + } + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.IRTSendReceive()", e.ToString()); + } + + return nStat; + } + + /// + /// 마스터 요청을 위한 string으로의 send/receive + /// + /// + /// + /// + /// + /// + /// + /// + public int MstIRTSendReceive(string sIp, int iPort, int iTimeOut, string sCommData, Hashtable htData, ref StringBuilder sbRecvData) + { + int nStat = BaseCom.NG; + string sRecvCommHeader = string.Empty; + string sRecvData = string.Empty; + + try + { + m_ServerIp = sIp; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + string sJsonSendData = string.Empty; + string sJsonReceiveData = string.Empty; + Hashtable htRecvData = null; + + sbRecvData = new StringBuilder(); + + nStat = Connect(-1); + + if(nStat == BaseCom.OK) + { + while (true) + { + sJsonSendData = JsonConvert.SerializeObject(htData); + + //sJsonSendData 암호화 처리 ... + + Byte[] sBytTempBuff = Encoding.UTF8.GetBytes(sJsonSendData); + string sDataLen = string.Format("{0:000000}", sBytTempBuff.Length); + + sCommData = sDataLen + sCommData.Substring(TcpSocket.COMM_MSGLEN); + + // 마스터 송수신 로그 제거(20170520) + //UserLog.WriteLogFile(UserCom.LOG_SOCK, + // UserCom.WARNING_LEVEL, + // System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + // System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + // CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sCommData + sJsonSendData); + + #if(LOG_TRACE) ////@@ 로그 확인 용 + UserLog.WriteLogFile(UserCom.LOG_OP, "Background NetJson SendData : ", System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + "," + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", sCommData + sJsonSendData); + #endif + // 전문 송신 + nStat = SendReceiveMstData(sCommData + sJsonSendData, ref sJsonReceiveData); + + #if(LOG_TRACE) ////@@ 로그 확인 용 + UserLog.WriteLogFile(UserCom.LOG_OP, "Background NetJson RecvData : ", System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + "," + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", sJsonReceiveData); + #endif + + if (nStat == BaseCom.OK) + { + // 마스터 송수신 로그 제거(20170520) + //UserLog.WriteLogFile(UserCom.LOG_SOCK, + // UserCom.WARNING_LEVEL, + // System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + // System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + // CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sJsonReceiveData); + + if (sJsonReceiveData != null && sJsonReceiveData != string.Empty) + { + sRecvCommHeader = sJsonReceiveData.Substring(0, TcpSocket.COMM_HEAD_LEN); + sRecvData = sJsonReceiveData.Substring(TcpSocket.COMM_HEAD_LEN); + + //sRecvData 복호화 처리 ... + + htRecvData = JsonConvert.DeserializeObject(sRecvData); + + if (int.Parse(htRecvData[Column.IQ_POSMASTER_RSP.DATA.Count].ToString().Trim()) != 0) + { + // StringBuilder에 추가 + sbRecvData.Append(htRecvData[Column.IQ_POSMASTER_RSP.DATA.Data].ToString()); + } + else + { + break; + } + // 요청전문의 요청 코드 변경 + htData[Column.IQ_POSMASTER_REQ.DATA.ProcCd] = "1"; + } + } + else + { + return BaseCom.NG1; + } + } + + nStat = BaseCom.OK; + } + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.MstIRTSendReceive()", e.ToString()); + } + finally + { + Close(); + } + + return nStat; + } + } +} diff --git a/Agent/MasterDown/Properties/AssemblyInfo.cs b/Agent/MasterDown/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..0177548 --- /dev/null +++ b/Agent/MasterDown/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("MasterDown")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("MasterDown")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("47a0e994-6a5c-41dd-b706-354c244b7380")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Agent/MasterDown/Svr2Tran.cs b/Agent/MasterDown/Svr2Tran.cs new file mode 100644 index 0000000..4d79d24 --- /dev/null +++ b/Agent/MasterDown/Svr2Tran.cs @@ -0,0 +1,436 @@ +using System; +using System.Text; +using System.Collections; +using System.Data; + +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; +using Cosmos.CommonManager; +using Cosmos.BaseFrame; +using System.Threading; + +using Newtonsoft.Json; +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : 영수증 반품 / 서버 시간 조회 처리 +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.BackgroundDown +{ + class Svr2Tran + { + #region 변수 선언 및 생성자 + /// + /// StateServer Object (StateServer 객체) + /// + private StateServer StateObject = (StateServer)StateServer.GetInstance(); + + private NetworkJSON m_cNetJSONService; + private DatabaseMssql m_cSqlDbService = null; + Hashtable m_htRecvData = null; // 통신 수신 데이터 (JSON) + private frmPosIrtMessage m_cfPosIrtMsg = null; + + /// + /// POS Status Value (POS 상태값) + /// + private PosStatus m_cPosStatus = null; + + private bool m_bIRTComplete = false; + /// + /// 생성자 + /// + public Svr2Tran() + { + SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출 + + m_cPosStatus = (PosStatus)StateObject.POS; + + m_cNetJSONService = new NetworkJSON(); + m_cSqlDbService = new DatabaseMssql(); + m_cfPosIrtMsg = new frmPosIrtMessage(); + + m_bIRTComplete = false; + } + #endregion + + #region 서버 시간 조회 + /// + /// 서버 시간 조회 + /// + /// + public string ServerSysDateTime() + { + Hashtable htRecvData = new Hashtable(); + Hashtable htSendData = new Hashtable(); + + string sRet = UserCom.RST_ERR; + string sGetDate = ""; + + try + { + // 서버 조회 + htSendData.Add(Column.IQ_SYSDATE_REQ.DATA.INQ_TYPE, ItemConst.IRT_INQ_TYPE.SYSDATETIME); + htSendData.Add(Column.IQ_SYSDATE_REQ.DATA.RES_CD, ""); + htSendData.Add(Column.IQ_SYSDATE_REQ.DATA.POS_HOUR, ""); + htSendData.Add(Column.IQ_SYSDATE_REQ.DATA.REG_NO, ""); + htSendData.Add(Column.IQ_SYSDATE_REQ.DATA.TRADE_NO, ""); + htSendData.Add(Column.IQ_SYSDATE_REQ.DATA.SYS_YMDHMS, ""); + + sRet = ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.SysInfoPort, 5000, htSendData, ref htRecvData, false); + if (sRet == UserCom.RST_OK) + { + if (htRecvData[Column.IQ_SYSDATE_REQ.DATA.RES_CD].ToString() == "00") + { + sGetDate = htRecvData[Column.IQ_SYSDATE_REQ.DATA.SYS_YMDHMS].ToString(); + + if (sGetDate.Trim().Length == 14) BsUtil.SetSystemDateTime(sGetDate); + + sRet = UserCom.RST_OK; + } + } + } + catch (Exception ex) + { + WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); + } + return sRet; + } + #endregion + + #region 프로그램 업데이트 목록 조회 + /// + /// 프로그램 업데이트 목록 조회 + /// + /// + /// + /// + /// + /// + public string PGMUpdate(string sKind, string sDownDiv, ref string[] aRecvData, ref Hashtable htRecvData) + { + Hashtable htSendData = new Hashtable(); + + string sRet = UserCom.RST_ERR; + + try + { + // 서버 조회 + htSendData.Add(Column.IQ_PGMUPDATE_REQ.DATA.INQ_TYPE, ItemConst.IRT_INQ_TYPE.PGMUPDATE); + htSendData.Add(Column.IQ_PGMUPDATE_REQ.DATA.FILE_GROUP, CmUtil.MidH(sKind, 0, 2)); + htSendData.Add(Column.IQ_PGMUPDATE_REQ.DATA.FILE_KIND, CmUtil.MidH(sKind, 2, 2)); + htSendData.Add(Column.IQ_PGMUPDATE_REQ.DATA.FILE_APP_TY, "0"); + htSendData.Add(Column.IQ_PGMUPDATE_REQ.DATA.FILE_YMDHMS, DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmmss")); + htSendData.Add(Column.IQ_PGMUPDATE_REQ.DATA.DOWN_DIV, sDownDiv); + + sRet = ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.SysInfoPort, 10000, htSendData, ref htRecvData, false); + if (sRet == UserCom.RST_OK) + { + if (htRecvData[Column.IQ_PGMUPDATE_RSP.DATA.RES_CD].ToString() == "00" || htRecvData[Column.IQ_PGMUPDATE_RSP.DATA.RES_CD].ToString() == "01") + { + // 00:정상, 01:데이터 없음 + aRecvData = htRecvData[Column.IQ_PGMUPDATE_RSP.DATA.VALUE].ToString().Split(new string[] { "#~" }, StringSplitOptions.None); + + sRet = UserCom.RST_OK; + } + else + { + sRet = UserCom.RST_ERR; + } + } + } + catch (Exception ex) + { + WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); + } + return sRet; + } + #endregion + + #region 파일 변경 완료 요청 + /// + /// 파일 변경 완료 요청 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public string PGMUpdate_Complete(string sKind, string sAppType, string sFileName, string sFileSeq, string sFileVer, string sDownDiv, string sDeployDate, string sDeployDT) + { + Hashtable htSendData = new Hashtable(); + Hashtable htRecvData = new Hashtable(); + + string sRet = UserCom.RST_ERR; + + try + { + if (sFileVer.Trim() == "") return sRet; + + // 서버 조회 + htSendData.Add(Column.IQ_PGMUPDATE_COMPLETE_REQ.DATA.INQ_TYPE, ItemConst.IRT_INQ_TYPE.PGMUPDATECOMPLTE); + htSendData.Add(Column.IQ_PGMUPDATE_COMPLETE_REQ.DATA.FILE_GROUP, CmUtil.MidH(sKind, 0, 2)); + htSendData.Add(Column.IQ_PGMUPDATE_COMPLETE_REQ.DATA.FILE_KIND, CmUtil.MidH(sKind, 2, 2)); + htSendData.Add(Column.IQ_PGMUPDATE_COMPLETE_REQ.DATA.FILE_APP_TY, sAppType); + htSendData.Add(Column.IQ_PGMUPDATE_COMPLETE_REQ.DATA.FILE_NM, sFileName); + htSendData.Add(Column.IQ_PGMUPDATE_COMPLETE_REQ.DATA.FILE_VER, sFileVer); + htSendData.Add(Column.IQ_PGMUPDATE_COMPLETE_REQ.DATA.FILE_SEQ, sFileSeq); + htSendData.Add(Column.IQ_PGMUPDATE_COMPLETE_REQ.DATA.RES_CD, ""); + htSendData.Add(Column.IQ_PGMUPDATE_COMPLETE_REQ.DATA.DOWN_DIV, sDownDiv); + htSendData.Add(Column.IQ_PGMUPDATE_COMPLETE_REQ.DATA.DEPLOY_DT, sDeployDate); + htSendData.Add(Column.IQ_PGMUPDATE_COMPLETE_REQ.DATA.REG_DT, sDeployDT); + + sRet = ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.SysInfoPort, 10000, htSendData, ref htRecvData, false); + if (sRet == UserCom.RST_OK) + { + if (htRecvData[Column.IQ_PGMUPDATE_COMPLETE_REQ.DATA.RES_CD].ToString() == "00") + { + sRet = UserCom.RST_OK; + } + } + } + catch (Exception ex) + { + WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); + } + return sRet; + } + #endregion + + #region 프로그램 적용 및 이력 관리 + /// + /// 프로그램 이력 관리 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public string PGMUpdate_History_Isert(string sKind, string sFileSeq, string sFileVer, string sFileNm, string sApplyDate, string sApplyTime, string sApplyType, string sDeployDate, string sDeployTime, string sFTP_IP, string sFTP_Port, string sFTP_ID, string sFTP_Pwd, string sFTP_FILEPATH, string sDOWN_DIV, string sDeployDT, string sUseYn) + { + string sRet = UserCom.RST_ERR; + int iRet = -1; + + try + { + string sQuery = ""; + sQuery = ""; + sQuery += "IF EXISTS(SELECT CMP_CD \n"; + sQuery += " FROM POSMST..MST_PGM_VER_NEW \n"; + sQuery += " WHERE \n"; + sQuery += " CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"; + sQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n"; + sQuery += " AND KIND = '" + sKind.Trim() + "' \n"; + sQuery += " AND FILE_SEQ = '" + sFileSeq.Trim() + "' \n"; + sQuery += " AND FILE_VER = '" + sFileVer.Trim() + "') \n"; + sQuery += " BEGIN \n"; + sQuery += " UPDATE POSMST..MST_PGM_VER_NEW \n"; + sQuery += " SET \n"; + sQuery += " FILE_NM = '" + sFileNm.Trim() + "' \n"; + sQuery += " , APPLY_DATE = '" + sApplyDate.Trim() + "' \n"; + sQuery += " , APPLY_TIME = '" + sApplyTime.Trim() + "' \n"; + sQuery += " , APP_TYPE = '" + sApplyType + "' \n"; + sQuery += " , DEPLOY_DATE = '" + sDeployDate.Trim() + "' \n"; + sQuery += " , DEPLOY_TIME = '" + sDeployTime.Trim() + "' \n"; + sQuery += " , FTP_IP = '" + sFTP_IP.Trim() + "' \n"; + sQuery += " , FTP_PORT = '" + sFTP_Port.Trim() + "' \n"; + sQuery += " , FTP_ID = '" + sFTP_ID.Trim() + "' \n"; + sQuery += " , FTP_PWD = '" + sFTP_Pwd.Trim() + "' \n"; + sQuery += " , FTP_FILEPATH = '" + sFTP_FILEPATH.Trim() + "' \n"; + sQuery += " , DOWN_DIV = '" + sDOWN_DIV.Trim() + "' \n"; + sQuery += " , UPD_DT = CONVERT(VARCHAR(8), GETDATE(), 112) + REPLACE(CONVERT(VARCHAR(8), GETDATE(), 108), ':', '') \n"; + sQuery += " , DEPLOY_DT = '" + sDeployDT.Trim() + "' \n"; + sQuery += " , USE_YN = '" + sUseYn.Trim() + "' \n"; + sQuery += " WHERE \n"; ; + sQuery += " CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n"; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n"; + sQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "' \n"; + sQuery += " AND KIND = '" + sKind.Trim() + "' \n"; + sQuery += " AND FILE_SEQ = '" + sFileSeq.Trim() + "' \n"; + sQuery += " AND FILE_VER = '" + sFileVer.Trim() + "' \n"; + sQuery += " END \n"; + sQuery += "ELSE \n"; + sQuery += " BEGIN \n"; + sQuery += " INSERT INTO POSMST..MST_PGM_VER_NEW \n"; + sQuery += " (CMP_CD, STOR_CD, POS_NO, KIND, FILE_SEQ, FILE_VER, FILE_NM, APPLY_DATE, APPLY_TIME, APP_TYPE, DEPLOY_DATE, DEPLOY_TIME, FTP_IP, FTP_PORT, FTP_ID, FTP_PWD, FTP_FILEPATH, DOWN_DIV, REG_DT, DEPLOY_DT, USE_YN) \n"; + sQuery += " VALUES( \n"; + sQuery += " '" + m_cPosStatus.Base.CmpCd + "' \n"; + sQuery += " , '" + m_cPosStatus.Base.StoreNo + "' \n"; + sQuery += " , '" + m_cPosStatus.Base.PosNo + "' \n"; + sQuery += " , '" + sKind.Trim() + "' \n"; + sQuery += " , '" + sFileSeq.Trim() + "' \n"; + sQuery += " , '" + sFileVer.Trim() + "' \n"; + sQuery += " , '" + sFileNm.Trim() + "' \n"; + sQuery += " , '" + sApplyDate.Trim() + "' \n"; + sQuery += " , '" + sApplyTime.Trim() + "' \n"; + sQuery += " , '" + sApplyType + "' \n"; + sQuery += " , '" + sDeployDate.Trim() + "' \n"; + sQuery += " , '" + sDeployTime.Trim() + "' \n"; + sQuery += " , '" + sFTP_IP.Trim() + "' \n"; + sQuery += " , '" + sFTP_Port.Trim() + "' \n"; + sQuery += " , '" + sFTP_ID.Trim() + "' \n"; + sQuery += " , '" + sFTP_Pwd.Trim() + "' \n"; + sQuery += " , '" + sFTP_FILEPATH.Trim() + "' \n"; + sQuery += " , '" + sDOWN_DIV.Trim() + "' \n"; + sQuery += " , CONVERT(VARCHAR(8), GETDATE(), 112) + REPLACE(CONVERT(VARCHAR(8), GETDATE(), 108), ':', '') \n"; + sQuery += " , '" + sDeployDT.Trim() + "' \n"; + sQuery += " , '" + sUseYn.Trim() + "' \n"; + sQuery += " ) \n"; + sQuery += " END \n"; + sQuery = sQuery.Replace("\t", " "); + + m_cSqlDbService.SetDBConnectionString(m_cPosStatus.Base.LocalDbSource, m_cPosStatus.Base.LocalDbCatalog, m_cPosStatus.Base.LocalDbUserID, m_cPosStatus.Base.LocalDbPassword); + iRet = m_cSqlDbService.DBExecuteNonQuery(new string[] { sQuery }); + + if (iRet == 1) sRet = UserCom.RST_OK; + } + catch (Exception ex) + { + WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); + } + return sRet; + } + #endregion + + #region POS IRT 전문 송/수신 + /// + /// POS IRT 전문 송/수신(점포서버 송수신: 제이슨 이용) + /// + public string ExecutePosIrt(string sMsgType, string sSvrIP, int nSvrPort, int nTimeout, Hashtable htSendData, ref Hashtable htRecvData, bool bVisibleMode) + { + string sRet = UserCom.RST_ERR; + + try + { + string sCommHead = ItemColumn.MakeCommHeader(0, sMsgType); // 통신해더 생성 + + if (bVisibleMode == false) + { + // 팝업 화면 미표시 + m_bIRTComplete = true; + m_htRecvData = null; + + Thread thrSecondDisp = new Thread(() => sRet = OnNetworkIRT(sSvrIP, nSvrPort, nTimeout, sCommHead, htSendData)); + thrSecondDisp.Start(); + + while (m_bIRTComplete == true) + { + Thread.Sleep(100); + } + htRecvData = m_htRecvData; + } + else + { + string sDispName = string.Format(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0231), ""); + + m_cfPosIrtMsg.PosMessageStr = sDispName; + m_cfPosIrtMsg.ServerIp = sSvrIP; + m_cfPosIrtMsg.ServerPort = nSvrPort; + m_cfPosIrtMsg.TimeOut = nTimeout; + m_cfPosIrtMsg.CommHead = sCommHead; + m_cfPosIrtMsg.SendData = htSendData; + + m_cfPosIrtMsg.ShowDialog(); + + if (m_cfPosIrtMsg.RecvRet != UserCom.OK) + { + sRet = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0158); + // 통신 실패 로그 + UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + string.Format("SOCKET ERROR,{0},{1}, RET={2}", sSvrIP, nSvrPort, m_cfPosIrtMsg.RecvRet)); + return sRet; + } + htRecvData = m_cfPosIrtMsg.RecvData; + + sRet = UserCom.RST_OK; + } + } + catch (Exception ex) + { + WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); + } + return sRet; + } + #endregion + + + #region POS IRT 전문 송수신 - 화면 미표시용 + private string OnNetworkIRT(string sServerIp, int nServerPort, int nTimeOut, string sCommHead, Hashtable htSendData) + { + string sRet = UserCom.RST_ERR; + int nRecvRet = -1; + try + { + m_bIRTComplete = true; + + nRecvRet = m_cNetJSONService.IRTSendReceive(sServerIp, nServerPort, nTimeOut, sCommHead, htSendData, ref m_htRecvData); + + if (nRecvRet == BaseCom.OK) sRet = UserCom.RST_OK; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "Process Exception !!! " + ex.Message); + } + finally + { + m_bIRTComplete = false; + } + return sRet; + } + #endregion + + #region 설정 파일 읽기 + /// + /// 설정 파일 읽기 + /// + /// + /// + /// + /// + private string GetConfigInfo(CmMessage cCfgInfo, string sGroup, string sValueName) + { + return GetConfigInfo(cCfgInfo, sGroup, sValueName, ""); + } + private string GetConfigInfo(CmMessage cCfgInfo, string sGroup, string sValueName, string sDefault) + { + try + { + string sValue = cCfgInfo.GetMessage(sGroup).GetMessageValue(sValueName); + if (sValue == null) + return sDefault; + else + return sValue; + } + catch { } + + return sDefault; + } + #endregion + } + + +} diff --git a/Agent/MasterDown/frmPosIrtMessage.Designer.cs b/Agent/MasterDown/frmPosIrtMessage.Designer.cs new file mode 100644 index 0000000..c0e6223 --- /dev/null +++ b/Agent/MasterDown/frmPosIrtMessage.Designer.cs @@ -0,0 +1,99 @@ +namespace Cosmos.BackgroundDown +{ + partial class frmPosIrtMessage + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.components = new System.ComponentModel.Container(); + this.tmrStart = new System.Windows.Forms.Timer(this.components); + this.textBox1 = new System.Windows.Forms.TextBox(); + this.lblMessage = new System.Windows.Forms.Label(); + this.picSearchMessage = new System.Windows.Forms.PictureBox(); + ((System.ComponentModel.ISupportInitialize)(this.picSearchMessage)).BeginInit(); + this.SuspendLayout(); + // + // tmrStart + // + this.tmrStart.Interval = 50; + this.tmrStart.Tick += new System.EventHandler(this.tmrStart_Tick); + // + // textBox1 + // + this.textBox1.Location = new System.Drawing.Point(697, 274); + this.textBox1.Name = "textBox1"; + this.textBox1.Size = new System.Drawing.Size(73, 21); + this.textBox1.TabIndex = 1; + // + // lblMessage + // + this.lblMessage.BackColor = System.Drawing.Color.White; + this.lblMessage.Font = new System.Drawing.Font("나눔스퀘어 Bold", 20.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(129))); + this.lblMessage.Location = new System.Drawing.Point(12, 16); + this.lblMessage.Name = "lblMessage"; + this.lblMessage.Size = new System.Drawing.Size(764, 179); + this.lblMessage.TabIndex = 5; + this.lblMessage.Text = "조회 중 입니다. 잠시만 기다려 주세요."; + this.lblMessage.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + // + // picSearchMessage + // + this.picSearchMessage.BackColor = System.Drawing.Color.White; + this.picSearchMessage.Location = new System.Drawing.Point(0, 0); + this.picSearchMessage.Name = "picSearchMessage"; + this.picSearchMessage.Size = new System.Drawing.Size(788, 212); + this.picSearchMessage.TabIndex = 4; + this.picSearchMessage.TabStop = false; + // + // frmPosIrtMessage + // + this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi; + this.BackColor = System.Drawing.Color.Black; + this.ClientSize = new System.Drawing.Size(788, 212); + this.Controls.Add(this.lblMessage); + this.Controls.Add(this.picSearchMessage); + this.Controls.Add(this.textBox1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "frmPosIrtMessage"; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; + this.Text = "조회중"; + this.Load += new System.EventHandler(this.frmPosIrtMessage_Load); + ((System.ComponentModel.ISupportInitialize)(this.picSearchMessage)).EndInit(); + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Timer tmrStart; + private System.Windows.Forms.TextBox textBox1; + private System.Windows.Forms.Label lblMessage; + private System.Windows.Forms.PictureBox picSearchMessage; + } +} \ No newline at end of file diff --git a/Agent/MasterDown/frmPosIrtMessage.cs b/Agent/MasterDown/frmPosIrtMessage.cs new file mode 100644 index 0000000..72d58fd --- /dev/null +++ b/Agent/MasterDown/frmPosIrtMessage.cs @@ -0,0 +1,224 @@ +using System; +using System.Windows.Forms; +using System.Threading; +using System.Collections; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; +using Cosmos.CommonManager; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : 점포서버 IRT 통신 처리(제이슨 방식) +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.BackgroundDown +{ + public partial class frmPosIrtMessage : Form + { + private SManager sManager = new SManager(); //이 객체를 통해 업무 Service 호출 + + private INetworkJSON m_cNetService = null; + + private bool m_bSecondDisp = false; //초 표시여부 + private int m_nSecondCount = 0; //초(경과) + + string m_sMessageStr; + /// + /// 화면표시 메시지 + /// + public string PosMessageStr + { + get { return this.m_sMessageStr; } + set + { + this.m_sMessageStr = value; + try + { + lblMessage.Text = m_sMessageStr; + } + catch { } + } + } + + string m_sServerIp; + /// + /// 서버IP + /// + public string ServerIp + { + get { return this.m_sServerIp; } + set { this.m_sServerIp = value; } + } + + int m_nServerPort; + /// + /// 서버PORT + /// + public int ServerPort + { + get { return this.m_nServerPort; } + set { this.m_nServerPort = value; } + } + + int m_nTimeOut; + /// + /// 서버 Timeout + /// + public int TimeOut + { + get { return this.m_nTimeOut; } + set { this.m_nTimeOut = value; } + } + + string m_sCommHead; + /// + /// 송신데이터(공통해더) + /// + public string CommHead + { + get { return this.m_sCommHead; } + set { this.m_sCommHead = value; } + } + + Hashtable m_htSendData; + /// + /// 송신데이터 + /// + public Hashtable SendData + { + get { return this.m_htSendData; } + set { this.m_htSendData = value; } + } + + Hashtable m_htRecvData; + /// + /// 수신데이터 + /// + public Hashtable RecvData + { + get { return this.m_htRecvData; } + set { this.m_htRecvData = value; } + } + + int m_nRecvRet; + /// + /// 수신리턴값 + /// + public int RecvRet + { + get { return this.m_nRecvRet; } + set { this.m_nRecvRet = value; } + } + + public frmPosIrtMessage() + { + InitializeComponent(); + + base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true); + //this.UpdateStyles(); + + m_cNetService = (INetworkJSON)sManager.InitServiceInstance(ServiceLists.AGENT_NETWORK.DLL, ServiceLists.AGENT_NETWORK.NETWORK_JSON); + } + + private void frmPosIrtMessage_Load(object sender, EventArgs e) + { + try + { + CmMessage m_PosConfig = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + "PosConfig.INI"); + string sFont = m_PosConfig.GetMessage("GLOBAL").GetMessageValue("Font"); + FormManager.SetFormAllControlFont(this, sFont); + long nScreenSizeUser = CmUtil.LongParse(m_PosConfig.GetMessage("GLOBAL").GetMessageValue("ScreenSizeUser")); + FormManager.MovePopUpForm(this, false, nScreenSizeUser); + + picSearchMessage.Image = ImageManager.GetImage(BaseCom.NxImgPath, ImageManager.SCH_MESSAGE_BOX); + + if (m_sMessageStr != "") lblMessage.Text = m_sMessageStr; + + this.m_htRecvData = null; + this.m_nRecvRet = 0; + this.TopMost = true; + + tmrStart.Enabled = true; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "Process Exception !!! " + ex.Message); + } + } + + private void tmrStart_Tick(object sender, EventArgs e) + { + try + { + tmrStart.Enabled = false; + + m_bSecondDisp = true; + m_nSecondCount = 0; + + Thread thrSecondDisp = new Thread(new ThreadStart(OnNetworkIRT)); + thrSecondDisp.Start(); + + OnSecondDisplay(); + } + catch(Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "Process Exception !!! " + ex.Message); + } + finally + { + this.Close(); + } + } + + private void OnSecondDisplay() + { + try + { + while(m_bSecondDisp == true) + { + m_nSecondCount++; + if(m_nSecondCount % 10 == 0) + { + lblMessage.Text = m_sMessageStr + " (" + (int)(m_nSecondCount / 10) + ")"; + lblMessage.Update(); + } + Thread.Sleep(100); + } + } + catch(Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "Process Exception !!! " + ex.Message); + } + } + + private void OnNetworkIRT() + { + try + { + m_bSecondDisp = true; + if (m_cNetService == null) m_cNetService = (INetworkJSON)sManager.InitServiceInstance(ServiceLists.AGENT_NETWORK.DLL, ServiceLists.AGENT_NETWORK.NETWORK_IRT); + m_nRecvRet = m_cNetService.IRTSendReceive(m_sServerIp, m_nServerPort, m_nTimeOut, m_sCommHead, m_htSendData, ref m_htRecvData); + } + catch(Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "Process Exception !!! " + ex.Message); + } + finally + { + m_bSecondDisp = false; + } + } + + } +} diff --git a/Agent/MasterDown/frmPosIrtMessage.resx b/Agent/MasterDown/frmPosIrtMessage.resx new file mode 100644 index 0000000..731c392 --- /dev/null +++ b/Agent/MasterDown/frmPosIrtMessage.resx @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + 17, 17 + + \ No newline at end of file diff --git a/Agent/Measuring/Activator.cs b/Agent/Measuring/Activator.cs new file mode 100644 index 0000000..a292bec --- /dev/null +++ b/Agent/Measuring/Activator.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : 전자저울->라벨프린터 관련 클래스 Activator +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.Service +{ + public class Activator : InitServiceAbstract + { + public Activator() + { + + } + + public override object InitServiceInstance(string sClassNm) + { + object retObj = null; + + //클래스 찾아오기 위함 + switch (sClassNm) + { + case ServiceLists.AGENT_MEASURING.MEASURING_MAIN: + { + Cosmos.Measuring.MeasuringMain agentClass = new Cosmos.Measuring.MeasuringMain(); + retObj = agentClass; + break; + } + } + + return retObj; + } + } +} diff --git a/Agent/Measuring/LabelPrinter.cs b/Agent/Measuring/LabelPrinter.cs new file mode 100644 index 0000000..3073061 --- /dev/null +++ b/Agent/Measuring/LabelPrinter.cs @@ -0,0 +1,355 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO.Ports; +using System.ComponentModel; + +using Cosmos.CommonManager; +using Cosmos.UserFrame; + +namespace Cosmos.Measuring +{ + public class LabelPrinter + { + #region 클래스 변수 선언 + private static SerialPort m_cSerialPort = null; + #endregion 클래스 변수 선언 + + #region 생성자 + public LabelPrinter() + { + + } + #endregion 생성자 + + #region OPEN / CLOSE 처리 함수 + public bool OpenLabelPrinter(string sSerialPort, long lBaudrate) + { + bool bRet = false; + + try + { + #region log + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [OPEN]"); + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + #endregion + if (m_cSerialPort != null) + { + //grayber@20180307 시리얼 포트 flush 추가 start - Open 함수 Input Output 버퍼 삭제 (주석처리) + // 추가 + if (m_cSerialPort.IsOpen != true) // 시리얼포트 오픈 실패 + { + m_cSerialPort.Open(); // 시리얼포트 오픈 + } + //m_cSerialPort.DiscardOutBuffer(); + //m_cSerialPort.DiscardInBuffer(); + //UserLog.WriteLogFile(UserCom.LOG_OP, + // 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 (함수명)) + // "▶▶ [Open InOut Buffer Clear]"); + + bRet = true; + //grayber@20180307 시리얼 포트 flush 추가 end + return bRet; + } + + if(m_cSerialPort == null) + { + m_cSerialPort = new SerialPort(); + if(m_cSerialPort == null) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + "SERIAL PORT ERROR"); + return bRet; + } + + m_cSerialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived); + m_cSerialPort.PinChanged += new SerialPinChangedEventHandler(serialPort_PinChanged); + m_cSerialPort.ErrorReceived += new SerialErrorReceivedEventHandler(serialPort_ErrorReceived); + + m_cSerialPort.NewLine = "\r\n"; + m_cSerialPort.Encoding = System.Text.Encoding.GetEncoding("ks_c_5601-1987"); + + m_cSerialPort.WriteBufferSize = 1024 * 1024; + m_cSerialPort.PortName = sSerialPort; + m_cSerialPort.BaudRate = (int)lBaudrate; + m_cSerialPort.DataBits = 8; + m_cSerialPort.StopBits = StopBits.One; + m_cSerialPort.Parity = Parity.None; + m_cSerialPort.Handshake = Handshake.None; + m_cSerialPort.ReadTimeout = 500; + m_cSerialPort.WriteTimeout = 2000; + + m_cSerialPort.Open(); + if(m_cSerialPort.IsOpen == false) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + "SERIAL PORT OPEN ERROR"); + + return bRet; + } + + bRet = true; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + + #region log + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [OPEN]" + bRet); + + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + #endregion + return bRet; + } + + public bool CloseLabelPrinter() + { + bool bRet = false; + try + { + if (m_cSerialPort == null) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Close fail(m_cSerialPort == null)"); + return bRet; + } + + //grayber@20180307 시리얼 포트 flush 추가 start - Close 함수 Input Output 버퍼 삭제 + // 추가 + m_cSerialPort.DiscardOutBuffer(); + m_cSerialPort.DiscardInBuffer(); + //grayber@20180307 시리얼 포트 flush 추가 end + + m_cSerialPort.Close(); + bRet = true; + //grayber@20180307 시리얼 포트 flush 추가 start - try 문 밖으로 이동 (기존) + //m_cSerialPort = null; + //grayber@20180307 시리얼 포트 flush 추가 end + + + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + + #region log + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [CLOSE] Close InOut Buffer Clear :" + bRet); + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + #endregion + //grayber@20180307 시리얼 포트 flush 추가 start - try 문 밖으로 이동 (변경) + m_cSerialPort = null; + //grayber@20180307 시리얼 포트 flush 추가 end + + return bRet; + } + #endregion OPEN / CLOSE 처리 함수 + + #region SerialPort 이벤트 + private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) + { + SerialPort serialPort = (SerialPort)sender; + byte[] bytRecvBuf = new byte[serialPort.BytesToRead]; + + try + { + //grayber@20180307 시리얼 포트 flush 추가 start - DataReceived 시리얼 포트 null check + // 기존 + //serialPort.Read(bytRecvBuf, 0, bytRecvBuf.Length); + // 변경 + if (serialPort != null && serialPort.IsOpen == true) // 시리얼포트 객체 및 오픈 확인 + { + serialPort.Read(bytRecvBuf, 0, bytRecvBuf.Length); + + #region log + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [RECV] " + Encoding.UTF8.GetString(bytRecvBuf)); + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + #endregion + } + //grayber@20180307 시리얼 포트 flush 추가 end + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + } + + private void serialPort_PinChanged(object sender, SerialPinChangedEventArgs e) + { + + } + + private void serialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e) + { + + } + #endregion SerialPort 이벤트 + + #region 출력 함수 + /// + /// 중량 출력 + /// + /// 상품명 : 중량g + /// 중량 + /// YYYY-MM-DD HH:MM:SS + /// 점포명 + public void PrintWeightInfo(string sContent, string sDateTime, string sStoreNm) + { + string[] sCommands = null; + + try + { + + sCommands = new string[] { "CLL\r\n" // 메모리 클리어 + , "NEW\r\n" // 새로운 명령어 시작 + , "CLIP ON\r\n" + , "FONT \"HYGothic-Medium\",12\r\n" + , "NASC 949\r\n" // intermec 한글폰트 설정 + , "PRPOS 0,150\r\n" + , "PRTXT \"" + sContent + "\"\r\n" + , "FONT \"HYGothic-Medium\",9\r\n" + , "PRPOS 0,110\r\n" + , "PRTXT \"" + sDateTime + "\"\r\n" + , "PRPOS 0,70\r\n" + , "PRTXT \"" + sStoreNm + "\"\r\n" + , "PRPOS 0,30\r\n" + , "PRTXT \"배달은 해피오더 / 1670-3131\"\r\n" //#10856_[BR] 저울 중량 라벨프린터 양식 변경_hs + , "PF\r\n" }; + + if (sCommands != null) + WriteCommand(sCommands); + + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 PrintWeightInfo(string sContent, string sFlavour1, string sFlavour2, string sOrdDateTime, string sPckDateTime) + { + string[] sCommands = null; + + try + { + // EX) + // 패밀리 / 980g (5516) + // 플레이버1/플레이버2/플레이버3 + // 플레이버4/플레이버5/플레이버6 + // + // 주문 YYYY-MM-DD HH시MM분 + // 포장 YYYY-MM-DD HH시MM분 + sCommands = new string[] { "CLL\r\n" // 메모리 클리어 + , "NEW\r\n" // 새로운 명령어 시작 + , "CLIP ON\r\n" + , "FONT \"HYGothic-Medium\",12\r\n" + , "NASC 949\r\n" + , "PRPOS 0,190\r\n" + , "PRTXT \"" + sContent + "\"\r\n" + , "FONT \"HYGothic-Medium\",9\r\n" + , "PRPOS 0,150\r\n" + , "PRTXT \"" + sFlavour1 + "\"\r\n" + , "PRPOS 0,110\r\n" + , "PRTXT \"" + sFlavour2 + "\"\r\n" + , "PRPOS 0,50\r\n" + , "PRTXT \"" + sOrdDateTime + "\"\r\n" + , "PRPOS 0,10\r\n" + , "PRTXT \"" + sPckDateTime + "\"\r\n" + , "PF\r\n" }; + + if (sCommands != null) + WriteCommand(sCommands); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 void WriteCommand(string[] sCommands) + { + try + { + foreach(string cmd in sCommands) + { + m_cSerialPort.Write(cmd); + } + + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 명령어 전송 함수 + } +} diff --git a/Agent/Measuring/Measuring.csproj b/Agent/Measuring/Measuring.csproj new file mode 100644 index 0000000..d158ec4 --- /dev/null +++ b/Agent/Measuring/Measuring.csproj @@ -0,0 +1,86 @@ + + + + + Debug + AnyCPU + {C1D7E706-7F5B-4DF3-85DD-E3F2A097144B} + Library + Properties + Cosmos.Measuring + Agent.Measuring + v4.0 + 512 + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\BIN\Cosmos.BaseFrame.dll + + + False + ..\..\..\BIN\Cosmos.UserFrame.dll + + + + + + + + + + + + + + + + + + + + {670a81be-cee3-4c29-846d-a37652ca270d} + CommonManager + + + {a5b7accd-79eb-4261-bd36-01ab484ad8e3} + Common + + + + + copy .\IC\Agent.Measuring.dll .\Agent.Measuring.dll + + + copy .\Agent.Measuring.dll .\IC\Agent.Measuring.dll + + + \ No newline at end of file diff --git a/Agent/Measuring/MeasuringMain.cs b/Agent/Measuring/MeasuringMain.cs new file mode 100644 index 0000000..356d095 --- /dev/null +++ b/Agent/Measuring/MeasuringMain.cs @@ -0,0 +1,696 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.IO.Ports; +using System.ComponentModel; + +using Cosmos.Common; +using Cosmos.CommonManager; +using Cosmos.BaseFrame; +using Cosmos.UserFrame; + + +namespace Cosmos.Measuring +{ + public class MeasuringMain : IMeasuring + { + #region 클래스 변수 선언 + /// + /// StateServer Object (StateServer 객체) + /// + public StateServer StateObject = (StateServer)StateServer.GetInstance(); + /// + /// POS Status Value (POS 상태값) + /// + private PosStatus m_cPosStatus = null; + /// + /// POS 주변장치 + /// + private DeviceStatus m_cDevStatus = null; + + /// + /// 중량 출력 모드 + /// + private PosConst.MEASURING_AGENT_PRINT_MODE PrintMode; + + /// + /// 출력용 핸드폰번호 + /// + private string m_sCPNum = ""; + public string CPNum { get { return m_sCPNum; } set { m_sCPNum = value; } } + /// + /// 출력용 플레이버 + /// + private string m_sFlavour1 = ""; + public string Flavour1 { get { return m_sFlavour1; } set { m_sFlavour1 = value; } } + private string m_sFlavour2 = ""; + public string Flavour2 { get { return m_sFlavour2; } set { m_sFlavour2 = value; } } + /// + /// 출력용 주문시간 + /// + private string m_sOrdDT = ""; + public string OrdDT { get { return m_sOrdDT; } set { m_sOrdDT = value; } } + + private Scale m_cScaleDevice = null; + private LabelPrinter m_cLabelPrtDevice = null; + private ScalePoleDisplay m_cScalePoleDisplay = null; + + private string m_sOldOrdDate = ""; + private string m_sOldOrdTime = ""; + + /// + /// MSSQL DB 관련 객체 + /// + private static SqlDB sqlDb = null; + + /// + /// Measuring Thread 작동 여부 + /// + private bool m_MeasuringRunning = true; + + /// + /// Measuring Thread + /// + private Thread m_tMeasuring = null; + + /// + /// 대기시간 + /// + private int WAIT_TIME = 60000 * 30; + + /// + /// 저울 델리게이트 + /// + /// + /// + /// + /// + public delegate void DelegateScaleDevice(bool bPrintYn, int iWeight, string sUnit, string sItemNm); + + public delegate void DelegateScaleDeviceRaw(string sScaleData); + + public static DelegateScaleDevice m_delegateScaleDev = null; + public static DelegateScaleDeviceRaw m_delegateScaleDevRaw = null; + + private bool m_bOncePrint = false; + #endregion 클래스 변수 선언 + + #region 생성자 + public MeasuringMain() + { + m_cPosStatus = (PosStatus)StateObject.POS; + m_cDevStatus = (DeviceStatus)StateObject.DEVICE; + + m_cScaleDevice = new Scale(); + m_cLabelPrtDevice = new LabelPrinter(); + m_cScalePoleDisplay = new ScalePoleDisplay(); + } + + public void Initialize() + { + // Default 출력 모드는 일반중량출력 + PrintMode = PosConst.MEASURING_AGENT_PRINT_MODE.NORMAL; + + CPNum = ""; + Flavour1 = ""; + Flavour2 = ""; + OrdDT = ""; + } + #endregion 생성자 + + #region Measuring 데몬 기동/종료 + public void StartMeasuring() + { + try + { + Initialize(); + + // 저울 델리게이트 생성 + m_delegateScaleDev = new DelegateScaleDevice(OnScaleDeviceEvent); + // 저울 RAW Data 델리게이트 생성 + m_delegateScaleDevRaw = new DelegateScaleDeviceRaw(OnScaleDataEvent); + + if (m_tMeasuring == null) + { + m_tMeasuring = new Thread(new ThreadStart(ThreadMeasuringRun)); + m_MeasuringRunning = true; + m_tMeasuring.Start(); + } + } + 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); + } + } + + public void StopMeasuring() + { + try + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "Measuring Service Stop!!!"); + + m_MeasuringRunning = false; + + int count = 0; + while(count < 10) + { + if (m_tMeasuring != null && m_tMeasuring.IsAlive) m_MeasuringRunning = false; + else break; + + count++; + Thread.Sleep(300); + } + + if(count >= 10) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 Measuring Service Stop!!!"); + m_tMeasuring.Abort(); + } + + m_tMeasuring = null; + + // 저울 델리게이트 Release + m_delegateScaleDev = null; + + // 전자저울 SerialPort Close + m_cScaleDevice.CloseScale(); + } + 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); + } + } + #endregion Measuring 데몬 기동/종료 + + #region Measuring Main + private void ThreadMeasuringRun() + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "Measuring Service Run!!"); + + while(m_MeasuringRunning) + { + try + { + // 전자저울 SerialPort Open + bool bReturn = m_cScaleDevice.OpenScale(m_cPosStatus.Base.OlePosScaleSerialPortNumber, m_cPosStatus.Base.OlePosScaleSerialBaudRate); + // 2017.05.17 + Thread.Sleep(500); + + if (bReturn == true) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "Scale port open succeed"); + } + else + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "Scale port open failed"); + } + + int nNowSleepTerm = 0; + while(nNowSleepTerm < WAIT_TIME) + { + if (m_MeasuringRunning == false) break; + Thread.Sleep(100); + nNowSleepTerm += 100; + } + m_cScaleDevice.CloseScale(); + + // 2017.05.17 + Thread.Sleep(500); + } + 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 (함수명)) + "Measuring Service Exception : " + ex.Message); + break; + } + } + + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "Measuring Service Exit!!"); + } + #endregion + + #region 중량 출력 모드 변경 + public void SetPrintMode(PosConst.MEASURING_AGENT_PRINT_MODE sMode) + { + try + { + PrintMode = sMode; + + if(PrintMode == PosConst.MEASURING_AGENT_PRINT_MODE.NORMAL) + { + Initialize(); + } + } + 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); + } + } + #endregion 중량 출력 모드 변경 + + #region 플레이버 내용 등록(출력용) + public void SetHappyOrderData(string[] sData) + { + try + { + if (sData.Length == 1) + { + CPNum = sData[0]; + Flavour1 = ""; + Flavour2 = ""; + } + else if (sData.Length == 2) + { + CPNum = sData[0]; + Flavour1 = sData[1]; + Flavour2 = ""; + } + else if(sData.Length > 2) + { + CPNum = sData[0]; + Flavour1 = sData[1]; + Flavour2 = sData[2]; + OrdDT = sData[3]; + } + } + 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); + } + } + #endregion 플레이버 내용 등록(출력용) + + #region Scale Device Event 관련 + public void OnScaleDeviceEvent(bool bPrintYn, int iWeight, string sUnit, string sItemNm) + { + try + { + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start +#if true // 로그추가 + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [OPEN]"); +#endif + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + if (m_bOncePrint == false) + { + m_bOncePrint = true; + string sCurDT = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + string sScaleDate = sCurDT.Substring(0, 10).Replace("-", ""); + string sScaleTime = sCurDT.Substring(11, 8).Replace(":", ""); + + if (m_sOldOrdTime == "" || (m_sOldOrdTime.Equals(sScaleTime) == false)) + { + m_sOldOrdDate = sScaleDate; + m_sOldOrdTime = sScaleTime; + + // 정상중량일 경우에만 라벨프린터 출력함 + if (bPrintYn == true) + { + if (PrintMode == PosConst.MEASURING_AGENT_PRINT_MODE.NORMAL) + ProcWeightInfo(sItemNm, iWeight, sUnit, sCurDT); + else + ProcWeightInfoOnHappyOrder(sItemNm, iWeight, sUnit, sCurDT); + } + + // 저울 데이터 저장 + // 중량 미달일 경우에도 저울 데이터는 저장 + InsertScaleLog(sScaleDate, sScaleTime, iWeight, sItemNm, bPrintYn ? "1" : "0"); + } + } + } + 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); + } + finally + { + m_bOncePrint = false; + } + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start +#if true // 로그추가 + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [CLOSE]"); +#endif + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + } + + public void OnScaleDataEvent(string sScaleData) + { + try + { + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start +#if true // 로그추가 + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [OPEN]"); +#endif + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + // ScalePoleDisplay 사용일 경우에만 출력 + if(m_cDevStatus.ScalePoleDisplay.UseYn == true) + { + ProcScalePoleDisplay(sScaleData); + } + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start +#if true // 로그추가 + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [CLOSE]"); +#endif + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + } + 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); + } + } + #endregion Device Event 관련 + + #region DB 관련 + public void InsertScaleLog(string sDate, string sTime, int iWeight, string sItemNm, string sNormalYn) + { + string sQuery = ""; + string sInsQuery = ""; + sqlDb = null; + + try + { + sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, m_cPosStatus.Base.LocalDbCatalog, m_cPosStatus.Base.LocalDbUserID, m_cPosStatus.Base.LocalDbPassword); + + sQuery = "INSERT INTO POSLOG..ETC_SCALE_LOG "; + sQuery += " ( CMP_CD, BRAND_CD, SALE_DT, STOR_CD, POS_NO "; + sQuery += " , SCALE_DT, SCALE_TM, WEIGHT, ITEM_NM, NORMAL_YN "; + sQuery += " , SEND_YN, REG_DATE, UPD_DATE ) "; + sQuery += "VALUES "; + sQuery += " ( '{0}', '{1}', '{2}', '{3}', '{4}' "; + sQuery += " , '{5}', '{6}', {7}, N'{8}', '{9}' "; + sQuery += " , '{10}', '{11}', '{12}' ) "; + + sInsQuery = string.Format( sQuery + , m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.BrandCd, m_cPosStatus.Base.SaleDate, m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.PosNo + , sDate, sTime, iWeight, sItemNm, sNormalYn + , "0", DateTime.Now.ToString("yyyyMMddHHmmss"), DateTime.Now.ToString("yyyyMMddHHmmss")); + + int iRet = sqlDb.DBExecuteNonQuery(sInsQuery, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + if(iRet != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + "Insert Failed!! " + "[" + sInsQuery + "]"); + } + } + 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); + } + finally + { + if (sqlDb != null) + { + sqlDb.DBClose(); + } + } + } + #endregion + + #region 라벨프린터 출력 함수 + public void ProcWeightInfo(string sItemNm, int iWeight, string sUnit, string sCurTime) + { + bool bRet = false; + try + { + //if (m_bOncePrint == false) + //{ + + // 라벨프린터 Open + bRet = m_cLabelPrtDevice.OpenLabelPrinter(m_cPosStatus.Base.OlePosLabelPrinterSerialPortNumber, m_cPosStatus.Base.OlePosLabelPrinterSerialBaudRate); + + if(bRet == false) + { + return; + } + + //m_bOncePrint = true; + //grayber@20180228 중량 라벨 출력 변경 start + //기존 + //string sContent = sItemNm + " : " + iWeight.ToString() + sUnit; + //변경 + string sContent = sItemNm + " : " + string.Format( "{0:#,###}",iWeight) + sUnit; + //grayber@20180228 중량 라벨 출력 변경 start + + string sDateTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); + + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start +#if true // 로그추가 + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ LabelPrt: [" + sContent + "]"); +#endif + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + // 중량정보 출력 + + //grayber@20180228 중량 라벨 출력 변경 start + // 기존 + //m_cLabelPrtDevice.PrintWeightInfo(sContent, sDateTime, CmUtil.GetDataRowStr(PosMstManager.GetMstStore(), PosMst.MST_STORE.DATA.STORNM)); + // 변경 + m_cLabelPrtDevice.PrintWeightInfo(sContent, sDateTime, CmUtil.GetDataRowStr(PosMstManager.GetMstStore(), PosMst.MST_STORE.DATA.STORNM) + " 점"); + //grayber@20180228 중량 라벨 출력 변경 end + + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start +#if true // 로그추가 + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [CLOSE]"); +#endif + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + + // 라벨프린터 Close + bRet = m_cLabelPrtDevice.CloseLabelPrinter(); + + //m_bOncePrint = false; + //} + } + 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); + } + } + + public void ProcWeightInfoOnHappyOrder(string sItemNm, int iWeight, string sUnit, string sCurTime) + { + bool bRet = false; + try + { + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start +#if true // 로그추가 + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [OPEN]"); +#endif + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + // 라벨프린터 Open + bRet = m_cLabelPrtDevice.OpenLabelPrinter(m_cPosStatus.Base.OlePosLabelPrinterSerialPortNumber, m_cPosStatus.Base.OlePosLabelPrinterSerialBaudRate); + + if (bRet == false) + { + return; + } + + m_bOncePrint = true; + + string sContent = sItemNm + " / " + iWeight.ToString() + sUnit + " (" + CPNum + ")"; + string sOrdDateTime = "주문 " + OrdDT; + string sPckDateTime = "포장 " + sCurTime; + + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start +#if true // 로그추가 + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ LabelPrt: [" + sContent + "]"); +#endif + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + + // 중량정보 출력 + m_cLabelPrtDevice.PrintWeightInfo(sContent, Flavour1, Flavour2, sOrdDateTime, sPckDateTime); + + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start +#if true // 로그추가 + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [CLOSE]"); +#endif + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + + // 라벨프린터 Close + bRet = m_cLabelPrtDevice.CloseLabelPrinter(); + + m_bOncePrint = false; + } + 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); + } + } + #endregion 라벨프린터 출력 함수 + + #region ScalePoleDisplay 출력 함수 + /// + /// ScalePoleDisplay 출력 + /// + /// 저울에서 입력된 값 Ex) ST,+00000.00__g + public void ProcScalePoleDisplay(string sScaleData) + { + try + { + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start +#if true // 로그추가 + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [OPEN]"); +#endif + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + m_cScalePoleDisplay.OpenScalePoleDisplay(m_cPosStatus.Base.OleScalePoleDisplayPortNumber, m_cPosStatus.Base.OleScalePoleDisplayBaudRate); + + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start +#if true // 로그추가 + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ " + "PoleDisplay: " + "[" + sScaleData + "]"); +#endif + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + + m_cScalePoleDisplay.WriteToScalePoleDisplay(sScaleData); + + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start +#if true // 로그추가 + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ CLOSE"); +#endif + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + + m_cScalePoleDisplay.CloseScalePoleDisplay(); + } + 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); + } + } + #endregion ScalePoleDisplay 출력 함수 + } +} diff --git a/Agent/Measuring/Properties/AssemblyInfo.cs b/Agent/Measuring/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..01708f2 --- /dev/null +++ b/Agent/Measuring/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("Measuring")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Measuring")] +[assembly: AssemblyCopyright("Copyright © 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("652f0e60-5407-4be2-b7c4-62bff0636cf2")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Agent/Measuring/Scale.cs b/Agent/Measuring/Scale.cs new file mode 100644 index 0000000..71bb718 --- /dev/null +++ b/Agent/Measuring/Scale.cs @@ -0,0 +1,425 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO.Ports; +using System.ComponentModel; + +using Cosmos.CommonManager; +using Cosmos.UserFrame; + +namespace Cosmos.Measuring +{ + public class Scale + { + #region 클래스 변수 선언 + /// + /// 전자저울과의 RS232 통신을 위한 시리얼포트 객체 + /// + private SerialPort m_cSerialPort = null; + /// + /// 전자저울 이벤트 수신 후 처리할 작업용 스레드 작업(라벨프린터 출력) + /// + private BackgroundWorker bw = null; + #endregion 클래스 변수 선언 + + #region 생성자 + public Scale() + { + bw = new BackgroundWorker(); + } + #endregion 생성자 + + #region OPEN / CLOSE 처리 함수 + public bool OpenScale(string sSerialPort, long lBaudrate) + { + bool bRet = false; + + try + { + if (m_cSerialPort != null) + { + //grayber@20180307 시리얼 포트 flush 추가 start - Open 함수 Input Output 버퍼 삭제 (주석처리) + //m_cSerialPort.DiscardInBuffer(); + //m_cSerialPort.DiscardOutBuffer(); + //grayber@20180307 시리얼 포트 flush 추가 end + m_cSerialPort.Close(); + System.Threading.Thread.Sleep(50); + m_cSerialPort = null; + } + + if (m_cSerialPort == null) + { + m_cSerialPort = new SerialPort(); + if (m_cSerialPort == null) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + "SERIAL PORT ERROR"); + return bRet; + } + + m_cSerialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived); + m_cSerialPort.PinChanged += new SerialPinChangedEventHandler(serialPort_PinChanged); + m_cSerialPort.ErrorReceived += new SerialErrorReceivedEventHandler(serialPort_ErrorReceived); + + m_cSerialPort.NewLine = "\r\n"; + m_cSerialPort.Encoding = Encoding.ASCII; + m_cSerialPort.WriteBufferSize = 512; + m_cSerialPort.PortName = sSerialPort; + m_cSerialPort.BaudRate = (int)lBaudrate; + m_cSerialPort.DataBits = 7; + m_cSerialPort.StopBits = StopBits.One; + m_cSerialPort.Parity = Parity.Even; + m_cSerialPort.Handshake = Handshake.None; + m_cSerialPort.ReadTimeout = 5000; + m_cSerialPort.WriteTimeout = 5000; + + m_cSerialPort.Open(); + if (m_cSerialPort.IsOpen == false) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + "SERIAL PORT OPEN ERROR"); + + return bRet; + } + + // BackgroundWorker 이벤트 함수 등록 + bw.DoWork += DeviceEventHandler; + bRet = true; + } + } + 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 bRet; + } + + public bool CloseScale() + { + bool bRet = false; + try + { + if (m_cSerialPort == null) + { + 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 (함수명)) + "Close fail(m_cSerialPort_Scale == null)"); + return bRet; + } + //grayber@20180307 시리얼 포트 flush 추가 start - Close 함수 Input Output 버퍼 삭제 + m_cSerialPort.DiscardInBuffer(); + m_cSerialPort.DiscardOutBuffer(); + //grayber@20180307 시리얼 포트 flush 추가 end + + m_cSerialPort.Close(); + bRet = true; + //grayber@20180307 시리얼 포트 flush 추가 start - try 문 밖으로 이동 (기존) + //m_cSerialPort = null; + //grayber@20180307 시리얼 포트 flush 추가 end + // BackgroundWorker 이벤트 함수 제거 + bw.DoWork -= DeviceEventHandler; + } + 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); + } + //grayber@20180307 시리얼 포트 flush 추가 start - try 문 밖으로 이동 (변경) + m_cSerialPort = null; + //grayber@20180307 시리얼 포트 flush 추가 end + + return bRet; + } + #endregion OPEN / CLOSE 처리 함수 + + #region SerialPort Alive 체크 + public bool IsPortOpend() + { + bool bRet = false; + try + { + if(m_cSerialPort == null) + { + return false; + } + + if(m_cSerialPort.IsOpen == false) + { + return false; + } + + bRet = true; + } + 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); + bRet = false; + } + + return bRet; + } + #endregion + + #region SerialPort 이벤트 + private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) + { + SerialPort serialPort = (SerialPort)sender; + string sHeader = ""; + + try + { + if ((SerialPort)sender == m_cSerialPort) + { + if (!bw.IsBusy) + { + // 데이터의 Terminator는 개행문자(\r\n)이므로 개행문자 까지 값을 읽는 ReadLine으로 수신 + string sScaleData = serialPort.ReadLine(); + sHeader = sScaleData.Substring(0, 2); + + // ST:계량모드, QT:계수모드, US:데이터가 안정되지 않다, OL:데이터가 오버되어 있다.(계량범위를 넘었다.) + if (sHeader.Equals("ST")) + { + bw.RunWorkerAsync(sScaleData); + } + else if (sHeader.Equals("QT")) + { + + } + else + { + + } + + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start +#if true // 로그추가 + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ " + "Recv: " + "[" + sScaleData + "]"); +#endif + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + } + else + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + "저울 이벤트 처리 전 이벤트 발생 불가"); + } + } + } + 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); + } + } + + private void serialPort_PinChanged(object sender, SerialPinChangedEventArgs e) + { + + } + + private void serialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e) + { + + } + #endregion SerialPort 이벤트 + + #region Event Handler + private void DeviceEventHandler(object sender, DoWorkEventArgs e) + { + string sScaleData = ""; + string sHeader = ""; + string sWeight = ""; + string sUnit = ""; + string sItemNm = ""; + bool bPrintYn = false; + + try + { + // Ex) ST,+00000.00__g + sScaleData = (string)e.Argument; + + sHeader = sScaleData.Substring(0, 2); + sWeight = sScaleData.Substring(3, 9); + sUnit = sScaleData.Substring(12, 3).Trim(); + bPrintYn = GetItemNameByWeight(Convert.ToInt32(sWeight), ref sItemNm); + + // 저울 입력 이벤트 전달 + if (MeasuringMain.m_delegateScaleDev != null) + MeasuringMain.m_delegateScaleDev(bPrintYn, Convert.ToInt32(sWeight), sUnit, sItemNm); + else + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + "MeasuringMain.m_delegateScaleDev is null."); + } + + // 저울 입력 데이터 전달 + if(MeasuringMain.m_delegateScaleDevRaw != null) + { + MeasuringMain.m_delegateScaleDevRaw(sScaleData); + } + else + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + "MeasuringMain.m_delegateScaleDevRaw is null."); + } + } + 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); + } + } + #endregion Event Handler + + #region 중량데이터로 상품명 얻기 + /// + /// 측정된 중량으로 상품명 가져오기 + /// + /// + /// + /// + private bool GetItemNameByWeight(int iWeight, ref string sItemNm) + { + bool bIsOk = false; + sItemNm = string.Empty; + try + { + if (iWeight >= 236 && iWeight <= 335) + { + sItemNm = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0545); + bIsOk = false; + } + + //else if (iWeight >= 336 && iWeight <= 434) + //{ + // sItemNm = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0545); + // bIsOk = true; + //} + //else if (iWeight >= 435 && iWeight <= 534) + //{ + // sItemNm = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0546); + // bIsOk = true; + //} + //#10856] (신규) [BR] 저울 중량 라벨프린터 양식 변경 + //스타워즈 파인트 제외 + else if (iWeight >= 336 && iWeight <= 534) + { + sItemNm = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0545); + bIsOk = true; + } + else if (iWeight >= 545 && iWeight <= 642) + { + sItemNm = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0547); + bIsOk = false; + } + else if (iWeight >= 643 && iWeight <= 742) + { + sItemNm = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0547); + bIsOk = true; + } + else if (iWeight >= 889 && iWeight <= 988) + { + sItemNm = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0548); + bIsOk = false; + } + else if (iWeight >= 989 && iWeight <= 1088) + { + sItemNm = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0548); + bIsOk = true; + } + //grayber@20180213 [BR] 핸드팩 중량 출력 대상 제품 추가 요청 start + // 추가 + else if (iWeight >= 1104 && iWeight <= 1199) + { + sItemNm = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_1095); + bIsOk = true; + } + // 기존 + //else if (iWeight >= 1137 && iWeight <= 1236) + // 변경 + else if (iWeight >= 1200 && iWeight <= 1236) + { + sItemNm = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0549); + bIsOk = false; + } + //grayber@20180213 [BR] 핸드팩 중량 출력 대상 제품 추가 요청 end + + else if (iWeight >= 1237 && iWeight <= 1536) + { + sItemNm = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0549); + bIsOk = true; + } + else if (iWeight >= 1700 && iWeight <= 1999) + { + sItemNm = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0550); + bIsOk = false; + } + else if (iWeight >= 2000 && iWeight <= 2300) + { + sItemNm = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0550); + bIsOk = true; + } + else + { + sItemNm = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0551); + bIsOk = false; + } + } + 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 bIsOk; + } + #endregion + } +} diff --git a/Agent/Measuring/ScalePoleDisplay.cs b/Agent/Measuring/ScalePoleDisplay.cs new file mode 100644 index 0000000..7a3a5ef --- /dev/null +++ b/Agent/Measuring/ScalePoleDisplay.cs @@ -0,0 +1,155 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO.Ports; + +using Cosmos.UserFrame; + +namespace Cosmos.Measuring +{ + class ScalePoleDisplay + { + #region 클래스 변수 선언 + private static SerialPort m_cSerialPort = null; + #endregion 클래스 변수 선언 + + #region 생성자 + #endregion 생성자 + + #region OPEN / CLOSE 처리 함수 + public bool OpenScalePoleDisplay(string sSerialPort, long lBaudrate) + { + bool bRet = false; + + try + { + if(m_cSerialPort != null) + { + //grayber@20180307 시리얼 포트 flush 추가 start - Open 함수 Input Output 버퍼 삭제(주석처리) + m_cSerialPort.DiscardInBuffer(); + m_cSerialPort.DiscardOutBuffer(); + //grayber@20180307 시리얼 포트 flush 추가 end + + m_cSerialPort.Close(); + System.Threading.Thread.Sleep(50); + m_cSerialPort = null; + } + + m_cSerialPort = new SerialPort(); + + m_cSerialPort.NewLine = "\r\n"; + m_cSerialPort.Encoding = Encoding.Default; + m_cSerialPort.WriteBufferSize = 512; + m_cSerialPort.PortName = sSerialPort; + m_cSerialPort.BaudRate = (int)lBaudrate; + m_cSerialPort.ReadTimeout = 500; + m_cSerialPort.WriteTimeout = 2000; + m_cSerialPort.DataBits = 8; + m_cSerialPort.StopBits = StopBits.One; + m_cSerialPort.Parity = Parity.None; + m_cSerialPort.Handshake = Handshake.None; + + m_cSerialPort.Open(); + if(m_cSerialPort.IsOpen == false) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + "SERIAL PORT OPEN ERROR"); + return bRet; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 start +#if true // 로그추가 + //grayber@20171222 디버그 로그 추가 - 저울 디버그 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "▶▶ [OPEN]" + bRet); +#endif + //grayber@20171222 저울,라벨프린터, PoleDisplay 디버그 로그 추가 end + + return bRet; + } + + public bool CloseScalePoleDisplay() + { + bool bRet = false; + try + { + if(m_cSerialPort == null) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Close fail(m_cSerialPort_Scale == null)"); + return bRet; + } + + //grayber@20180307 시리얼 포트 flush 추가 start - Close 함수 Input Output 버퍼 삭제 + m_cSerialPort.DiscardInBuffer(); + m_cSerialPort.DiscardOutBuffer(); + //grayber@20180307 시리얼 포트 flush 추가 end + + m_cSerialPort.Close(); + bRet = true; + //grayber@20180307 시리얼 포트 flush 추가 start - try 문 밖으로 이동 (기존) + //m_cSerialPort = null; + //grayber@20180307 시리얼 포트 flush 추가 end + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + //grayber@20180307 시리얼 포트 flush 추가 start - try 문 밖으로 이동 (변경) + m_cSerialPort = null; + //grayber@20180307 시리얼 포트 flush 추가 end + return bRet; + } + #endregion OPEN / CLOSE 처리 함수 + + #region 출력 함수 + public void WriteToScalePoleDisplay(string sScaleData) + { + try + { + + m_cSerialPort.WriteLine(sScaleData); + System.Threading.Thread.Sleep(500); + + m_cSerialPort.WriteLine(sScaleData); + System.Threading.Thread.Sleep(500); + + m_cSerialPort.WriteLine(sScaleData); + System.Threading.Thread.Sleep(500); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 출력 함수 + } +} diff --git a/Agent/Network/Activator.cs b/Agent/Network/Activator.cs new file mode 100644 index 0000000..cfc38b2 --- /dev/null +++ b/Agent/Network/Activator.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : Network 관련 클래스 Activator +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.Service +{ + /// + /// Load BaseFrame and save information (BaseFrame의 로드하고 정보를 보관한다) + /// + public class Activator : InitServiceAbstract + { + /// + /// Define main entrance point of project load. (프로젝트 로드의 주진입점을 정의합니다.) + /// + public Activator() + { + } + + /// + /// + /// + /// + /// + public override object InitServiceInstance(string sClassNm) + { + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Starting !!!"); + + object retObj = null; + + //클래스 찾아오기 위함 + switch (sClassNm) + { + case ServiceLists.AGENT_NETWORK.NETWORK_FTP: + { + Cosmos.Network.NetworkFtp agentClass = new Cosmos.Network.NetworkFtp(); + retObj = agentClass; + break; + } + case ServiceLists.AGENT_NETWORK.NETWORK_IRT: + { + Cosmos.Network.NetworkIRT agentClass = new Cosmos.Network.NetworkIRT(); + retObj = agentClass; + break; + } + case ServiceLists.AGENT_NETWORK.NETWORK_JSON: + { + Cosmos.Network.NetworkJSON agentClass = new Cosmos.Network.NetworkJSON(); + retObj = agentClass; + break; + } + case ServiceLists.AGENT_NETWORK.NETWORK_VAN_SPCN: + { + Cosmos.Network.NetworkVanSPCN agentClass = new Cosmos.Network.NetworkVanSPCN(); + retObj = agentClass; + break; + } + case ServiceLists.AGENT_NETWORK.NETWORK_HTTP: + { + Cosmos.Network.NetworkHttp agentClass = new Cosmos.Network.NetworkHttp(); + retObj = agentClass; + break; + } + } + + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Completed !!!"); + + return retObj; + } + } +} diff --git a/Agent/Network/Network.csproj b/Agent/Network/Network.csproj new file mode 100644 index 0000000..b6583bf --- /dev/null +++ b/Agent/Network/Network.csproj @@ -0,0 +1,93 @@ + + + + + Debug + AnyCPU + {233E83BF-BFFE-495D-9E3C-3583F9CD2773} + Library + Properties + Cosmos.Network + Agent.Network + v4.0 + 512 + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + ..\..\..\BIN\Agent.Network.XML + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\BIN\Cosmos.BaseFrame.dll + + + False + ..\..\..\BIN\Cosmos.ServiceProvider.dll + + + False + ..\..\..\BIN\Cosmos.UserFrame.dll + + + False + ..\..\..\BIN\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + {a5b7accd-79eb-4261-bd36-01ab484ad8e3} + Common + + + + + copy .\IC\Agent.Network.dll .\Agent.Network.dll + + + copy .\Agent.Network.dll .\IC\Agent.Network.dll + + + \ No newline at end of file diff --git a/Agent/Network/NetworkFtp.cs b/Agent/Network/NetworkFtp.cs new file mode 100644 index 0000000..092b8b6 --- /dev/null +++ b/Agent/Network/NetworkFtp.cs @@ -0,0 +1,181 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Net; +using System.Collections; +using System.Diagnostics; +using System.Runtime.Serialization.Formatters.Binary; +using System.Data; + +using System.Net.Sockets; +using System.Threading; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : FTP 다운로드 +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.Network +{ + public class NetworkFtp : INetworkFTP + { + private readonly string LOCAL_DOWN_PATH = BaseCom.NxRootPath + @"DOWN\"; //Download File Location (다운로드 파일위치) + + /// + /// StateServer Object (StateServer 객체) + /// + public StateServer StateObject = (StateServer)StateServer.GetInstance(); + /// + /// POS Status Value (POS 상태값) + /// + private PosStatus m_cPosStatus = null; + + private FTP m_ClsFtp; + + public NetworkFtp() + { + m_cPosStatus = (PosStatus)StateObject.POS; + } + + /// + /// FTP 서버에 Connect + /// + /// + /// + /// + /// + /// + /// 0 : 정상접속, -1:시간초과, -2:로그인 실패, -3:서버접속 실패, -4:지원하지 않는 시스템 + public int Connect(string sServer, string sUserId, string sPassword, int iTimeOutSeconds, int iPort) + { + int nReturn = -9; + + try + { + m_ClsFtp = new FTP((iPort == 0) ? sServer : sServer + ":" + iPort, sUserId, sPassword); + + if (m_ClsFtp != null) nReturn = 0; + else nReturn = -1; + + ////m_ClsFtp = new ClsFtp(sServer, sUserId, sPassword, iTimeOutSeconds, iPort); + + ////if ((nReturn = m_ClsFtp.Connect()) != 0) + ////{ + //// //MessageBox.Show("FTP Server Connect Error !!! [" + nReturn.ToString() + "]"); + //// return nReturn; + ////} + + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkFtp.Connect()", e.Message); + return nReturn; + } + + return nReturn; + } + + /// + /// + /// + /// + /// + /// + /// 0:정상종료, -1:Not Connected, -2:Binary Mode set failed, -3: failed local file Create, -4:socket 에러, -5:remote file 없슴, -6:정상수신실패, -7: 파일사이즈 틀림 + public int Download(string sSvrDirectory, string sLocalDirectory, string sFileNm, string sFtpMode = PosConst.FTP_CONN_TYPE.PASSIVE) + { + string sMsg = ""; + return Download(sSvrDirectory, sLocalDirectory, sFileNm, ref sMsg, sFtpMode); + } + public int Download(string sSvrDirectory, string sLocalDirectory, string sFileNm, ref string sMsg, string sFtpMode = PosConst.FTP_CONN_TYPE.PASSIVE) + { + int nReturn = -9; + bool bRet = false; + try + { + if (CmUtil.RightH(sLocalDirectory, 1) != "\\") sLocalDirectory += "\\"; + + if (Directory.Exists(sLocalDirectory) == false) Directory.CreateDirectory(sLocalDirectory); + + bRet = m_ClsFtp.Download(sSvrDirectory + sFileNm, sLocalDirectory + sFileNm, ref sMsg, sFtpMode); + + if (bRet) nReturn = 0; + else nReturn = -1; + ////if ((nReturn = m_ClsFtp.Connect()) != 0) + ////{ + //// return nReturn; + ////} + + ////string sDir = m_ClsFtp.ChangeDir(sSvrDirectory); + + ////nReturn = m_ClsFtp.Download(sLocalDirectory, sFileNm, true); + ////if (nReturn < 0 && File.Exists(BaseCom.NxDownPath + sFileNm + ".ftp") == true) + ////{ + //// File.Delete(BaseCom.NxDownPath + sFileNm + ".ftp"); + ////} + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkFtp.Download()", e.Message); + + sMsg = sFileNm + " " + e.Message; + return nReturn; + } + + return nReturn; + } + + /// + /// FTP서버와의 연결을 종료 + /// + public void Disconnect() + { + //m_ClsFtp.Close(); + //m_ClsFtp.cleanup(); + } + + /// + /// 정해진 디렉토리에 정해진 파일을 업로드 + /// + /// + /// + /// + /// 0:정상완료, -1:Not Connected, -2: data socket create error, -3: file write 실패, -4:socket error, -5: 정상처리 실패(서버) + public int Upload(string sSvrDirectory, string sLocalDirectory, string sFileNm) + { + int nReturn = -9; + bool bRet = false; + + try + { + bRet = m_ClsFtp.Upload(sLocalDirectory + sFileNm, sSvrDirectory + sFileNm); + + if (bRet) nReturn = 0; + else nReturn = -1; + ////if ((nReturn = m_ClsFtp.Connect()) != 0) + ////{ + //// return nReturn; + ////} + + ////string sDir = m_ClsFtp.ChangeDir(sSvrDirectory); + + ////nReturn = m_ClsFtp.Upload(sLocalDirectory, sFileNm, true); + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkFtp.Upload()", e.Message); + + return nReturn; + } + return nReturn; + } + } +} diff --git a/Agent/Network/NetworkHttp.cs b/Agent/Network/NetworkHttp.cs new file mode 100644 index 0000000..d7888f5 --- /dev/null +++ b/Agent/Network/NetworkHttp.cs @@ -0,0 +1,564 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Collections; +using System.Net; +using System.IO; + +using Newtonsoft.Json; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; + + +using System.Net.Security; +using System.Security.Cryptography.X509Certificates; + + +namespace Cosmos.Network +{ + public class NetworkHttp : INetworkHttp + { + private SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출 + private StateServer StateObject = (StateServer)StateServer.GetInstance(); // StateObject : StateServer Object (객체) + private PosStatus m_cPosStatus; // 기본정보 참조 + private DeviceStatus m_cDevStatus; // 장비정보 참조 + + public NetworkHttp() + { + m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 + m_cDevStatus = (DeviceStatus)StateObject.DEVICE; // POS 장치정보 + } + + /// + /// 해피오더 POST방식 Request + /// + /// + /// + /// + /// + /// + public int HttpJsonPOST_SendReceive(string sUrl, string sWorkType, Hashtable htReqData, ref Hashtable htRspData, ref string sRespJsonData) + { + int iRet = BaseCom.NG; + string sRespString = string.Empty; + + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl + sWorkType); + + string sSendJsonData = JsonConvert.SerializeObject(htReqData); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, + 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 (함수명)) + sSendJsonData); + + byte[] reqByte = Encoding.UTF8.GetBytes(sSendJsonData); + + req.Method = "POST"; + req.ContentType = "application/json"; + 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(); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, + 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 (함수명)) + respFromServer); + + Hashtable temp = JsonConvert.DeserializeObject(respFromServer); + + foreach (string key in temp.Keys) + { + string jsonString = temp[key].ToString(); + if (key.Equals("status")) + { + Hashtable htHeader = JsonConvert.DeserializeObject(jsonString); + if (htHeader["status"].ToString().Equals("200")) + { + iRet = BaseCom.OK; + } + htRspData = htHeader; + } + else + { + sRespJsonData = jsonString; + } + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.ToString()); + } + + return iRet; + } + /// + /// 해피오더 GET방식 Request + /// + /// 서버URL + /// 작업구분 + /// 요청Data + /// JSON String 형태의 응답 데이터 + /// + public int HttpJsonGET_SendReceive(string sUrl, string sWorkType, string sReqData, ref string sRespJsonData) + { + int iRet = BaseCom.NG; + string sRespString = string.Empty; + + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl + sWorkType + "?" + sReqData); + req.Method = "GET"; + + UserLog.WriteLogFile(UserCom.LOG_SOCK, + 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 (함수명)) + sUrl + sWorkType + "?" + sReqData); + + using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse()) + { + Stream stream = resp.GetResponseStream(); + //StreamReader streamReader = new StreamReader(stream, Encoding.GetEncoding("UTF-8")); + StreamReader streamReader = new StreamReader(stream, Encoding.GetEncoding("ks_c_5601-1987")); + sRespString = streamReader.ReadToEnd(); + streamReader.Close(); + } + + UserLog.WriteLogFile(UserCom.LOG_SOCK, + 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 (함수명)) + sRespString); + + Hashtable temp = JsonConvert.DeserializeObject(sRespString); + + foreach (string key in temp.Keys) + { + string jsonString = temp[key].ToString(); + if (key.Equals("status")) + { + Hashtable htHeader = JsonConvert.DeserializeObject(jsonString); + if (htHeader["status"].ToString().Equals("200")) + { + iRet = BaseCom.OK; + } + } + else + { + sRespJsonData = jsonString; + } + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.ToString()); + } + + return iRet; + } + + /// + /// GET방식 Request + /// + /// 서버URL + /// 작업구분 + /// 요청Data + /// JSON String 형태의 응답 데이터 + /// + public int HttpGET_SendReceive(string sUrl, string sWorkType, string sReqData, string sEncodingFlag, ref string sRespData) + { + int iRet = BaseCom.NG; + string sRespString = string.Empty; + StreamReader streamReader = null; + + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl + sWorkType + "?" + sReqData); + req.Method = "GET"; + + using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse()) + { + Stream stream = resp.GetResponseStream(); + + if (sEncodingFlag == PosConst.ENCODING_FLAG.UTF) + { + streamReader = new StreamReader(stream, Encoding.GetEncoding("UTF-8")); + } + else + { + streamReader = new StreamReader(stream, Encoding.GetEncoding("ks_c_5601-1987")); + } + + sRespString = streamReader.ReadToEnd(); + streamReader.Close(); + } + + iRet = BaseCom.OK; + + sRespData = sRespString; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.ToString()); + } + + return iRet; + } + + /// + /// 해피버즈 http 통신 + /// + /// + /// + /// + /// + /// + /// + public int HttpJsonPOST_SendReceiveForBuzz(string sUrl, string sWorkType, Hashtable htReqData, ref Hashtable htRspData) + { + int iRet = BaseCom.NG; + string sRespString = string.Empty; + + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl + sWorkType); + + string sSendJsonData = JsonConvert.SerializeObject(htReqData); + byte[] reqByte = Encoding.UTF8.GetBytes(sSendJsonData); + + req.Method = "POST"; + req.ContentType = "application/json"; + 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(); + + htRspData = JsonConvert.DeserializeObject(respFromServer); + + if (htRspData["result"].Equals(true)) + { + iRet = BaseCom.OK; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.ToString()); + } + + return iRet; + } + + /// + /// 관공서 방문 알림 통신 + /// + /// + /// + /// + /// + /// + /// + public int HttpPOST_SendReceiveForGoverVisit(string sUrl, string sWorkType, Hashtable htReqData, ref Hashtable htRspData) + { + int iRet = BaseCom.NG; + string sRespString = string.Empty; + + try + { + // 요청 String -> 요청 Byte 변환 + byte[] byteDataParams = UTF8Encoding.UTF8.GetBytes(htReqData.ToString()); + + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl + sWorkType); + + req.Method = "POST"; // 기본값 "GET" + req.ContentType = "application/x-www-form-urlencoded"; + req.ContentLength = byteDataParams.Length; + + // 요청 Byte -> 요청 Stream 변환 + Stream stDataParams = req.GetRequestStream(); + stDataParams.Write(byteDataParams, 0, byteDataParams.Length); + stDataParams.Close(); + + // 요청, 응답 받기 + HttpWebResponse response = (HttpWebResponse)req.GetResponse(); + + + if (response.StatusCode == HttpStatusCode.OK) + { + iRet = BaseCom.OK; + } + + //HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl + sWorkType); + + //string sSendJsonData = JsonConvert.SerializeObject(htReqData); + //byte[] reqByte = Encoding.UTF8.GetBytes(sSendJsonData); + + //req.Method = "POST"; + //req.ContentType = "application/json"; + //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(); + + //htRspData = JsonConvert.DeserializeObject(respFromServer); + + //if (htRspData["result"].Equals(true)) + //{ + // iRet = BaseCom.OK; + //} + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.ToString()); + } + + return iRet; + } + + // #20170616, 해피앱 스탬프 Start + /// + /// 해피앱 스탬프 http 통신 + /// + /// + /// + /// + /// + public int HttpJsonPOST_SendReceiveForStamp(string sUrl, Hashtable htReqData, ref Hashtable htRspData) + { + int iRet = BaseCom.NG; + string sRespString = string.Empty; + + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl); + + string sSendJsonData = JsonConvert.SerializeObject(htReqData); + UserLog.WriteLogFile(UserCom.LOG_SOCK, + 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 (함수명)) + sSendJsonData); + + byte[] reqByte = Encoding.UTF8.GetBytes(sSendJsonData); + + req.Method = "post"; + req.ContentType = "application/json"; + req.ContentLength = reqByte.Length; + //#20171117 해피앱 스탬프 timeout 설정 start + req.Timeout = 3000; + //#20171117 해피앱 스탬프 timeout 설정 end + + // 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(); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, + 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 (함수명)) + respFromServer); + + htRspData = JsonConvert.DeserializeObject(respFromServer); + + if (htRspData["result"].Equals("00")) + { + iRet = BaseCom.OK; + } + + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.ToString()); + } + + return iRet; + } + // #20170616, 해피앱 스탬프 End + + //contentType 에 따른 HTTP Post 전송, girak.kim , 2017.09.11 + + public static bool CheckValidationResult(object sender, X509Certificate certficate, X509Chain chain, SslPolicyErrors errors) + { + return true; + } + + + #region HTTP Post 전송 + + //#20170911.001, Http post 통신 추가 start;girak.kim; + + /// + /// + /// + /// 경로 + /// 전송 컨텐츠 타입 + /// 전송 데이타 + /// 결과 데이타 + /// + public int HttpPOST_SendReceive(string sUrl, string sContentType, string sReqString, ref string sRespData) + { + int iRet = BaseCom.NG; + + string result = ""; + int nConnecLimit = 200; + + HttpWebRequest request = null; + HttpWebResponse response = null; + Stream reqStream = null; + + try + { + ServicePointManager.DefaultConnectionLimit = nConnecLimit;//동시 연결 + if (sUrl.StartsWith("https", StringComparison.OrdinalIgnoreCase))//ssl 일 경우 인증서 무시 + { + ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); + } + + Uri uri = new Uri(sUrl); + + request = (HttpWebRequest)WebRequest.Create(uri); + request.Method = "POST"; + request.Timeout = 30000;//30sec + request.ContentType = sContentType;// "text/xml";// "text/xml; encoding='UTF-8'"; + + //request.KeepAlive = false; + + byte[] bData = System.Text.Encoding.UTF8.GetBytes(sReqString); + request.ContentLength = bData.Length; + + reqStream = request.GetRequestStream(); + reqStream.Write(bData, 0, bData.Length); + reqStream.Close(); + + response = (HttpWebResponse)request.GetResponse(); + + StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8); + result = sr.ReadToEnd().Trim(); + sr.Close(); + + sRespData = result; + iRet = BaseCom.OK; + + } + catch (System.Threading.ThreadAbortException e) + { + //e.Message + // System.Threading.Thread.ResetAbort(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + e.ToString()); + } + catch (WebException e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + e.ToString()); + + if (e.Status == WebExceptionStatus.ProtocolError) + { + // (HttpWebResponse)e.Response).StatusCode; + //(HttpWebResponse)e.Response).StatusDescription; + } + //throw new Exception(e.ToString()); + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + e.ToString()); + //throw new Exception(e.ToString()); + } + finally + { + if (response != null) response.Close(); + if (request != null) request.Abort(); + } + + sRespData = result; + return iRet; + + } + + //#20170911.001, Http post 통신 추가 end;girak.kim; + #endregion + } +} diff --git a/Agent/Network/NetworkIRT.cs b/Agent/Network/NetworkIRT.cs new file mode 100644 index 0000000..48e02fa --- /dev/null +++ b/Agent/Network/NetworkIRT.cs @@ -0,0 +1,670 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.Collections; +using System.Net.NetworkInformation; +using System.Runtime.InteropServices; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : SC / HQ IRT Request (SC / 본부 IRT 요청) +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.Network +{ + public class NetworkIRT : INetworkIRT + { + private SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출 + private StateServer StateObject = (StateServer)StateServer.GetInstance(); // StateObject : StateServer Object (객체) + private PosStatus m_cPosStatus; // 기본정보 참조 + private DeviceStatus m_cDevStatus; // 장비정보 참조 + + /// + /// Sending Socket (전송 소켓) + /// + private TcpSocket m_IrtSocket = null; + //private static TcpSocket m_IrtSocket = null; + + /// + /// IP + /// + private string m_ServerIp = ""; + + /// + /// Port + /// + private int m_ServerPort = 0; + + /// + /// TimeOut + /// + private int m_ServerTimeout = 10000; + + /// --------------------------------------------------------------------------------------------- + /// + /// Constructor (생성자) + /// + /// --------------------------------------------------------------------------------------------- + public NetworkIRT() + { + m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 + m_cDevStatus = (DeviceStatus)StateObject.DEVICE; // POS 장치정보 (PDA) + } + + #region OnLine 상태체크 + /// + /// Get network online status with Ping check. (Ping체크로 network Online상태를 취득한다,) + /// + /// Ip address + /// True : online false : Offline + private int CheckNetworkOnline(string pHostAddress) + { + //Ping Check (Ping 체크) + Ping pingSender = new Ping(); + PingOptions optins = new PingOptions(); + optins.DontFragment = true; + string data = "aaa"; + byte[] buffer = Encoding.ASCII.GetBytes(data); + int timeout = 120; + PingReply reply = pingSender.Send(pHostAddress, timeout, buffer, optins); + + if (reply.Status == IPStatus.Success) + return UserCom.OK; + else + return UserCom.NG; + } + #endregion + + #region 암호화 편집 + /// + /// 암호화 위해 전문 편집 + /// + /// 평문 + /// 암호문, 에러시 평문 리턴 + private byte[] EncryptData(byte[] plainData) + { + int nNowPos = 0; + + //통신헤더전문편집 + string[] aCommHead = new string[Column.COMM_HEADER.LEN.Length]; + ItemColumn.ParseMessage(Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE, plainData, ref nNowPos, ref aCommHead); + + string sPosNo = aCommHead[Column.COMM_HEADER.SEQ.PosNo].ToString(); + //string sRegNo = aCommHead[Column.COMM_HEADER.SEQ.RegNo].ToString(); + string sRegNo = ""; + string sMsgLen = aCommHead[Column.COMM_HEADER.SEQ.MsgLen].ToString(); + string sEncType = aCommHead[Column.COMM_HEADER.SEQ.EncType].ToString(); + byte[] byteEncryptData = null; + byte[] editedAllData = null; + + if (sEncType == "0") // "0" 평문 + { + //Tran헤더 포함 전문 데이터 + byte[] tranBytes = new byte[plainData.Length - nNowPos]; + + Array.Copy(plainData, nNowPos, tranBytes, 0, plainData.Length - nNowPos); + + //암호화 + byteEncryptData = AES.DynamicKeyEncrypt(sPosNo, sRegNo, tranBytes); + + int iMsgLen = nNowPos + byteEncryptData.Length; + + aCommHead[Column.COMM_HEADER.SEQ.MsgLen] = iMsgLen.ToString(); //공통헤더와 암호문 더해진 길이 + aCommHead[Column.COMM_HEADER.SEQ.EncType] = "1"; //0:평문 1:암호화 + + string sChangedCommHeader = ItemColumn.MakeMessage(aCommHead, Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE); + byte[] byteCommHeader = Encoding.UTF8.GetBytes(sChangedCommHeader); + + editedAllData = new byte[iMsgLen]; + Array.Copy(byteCommHeader, editedAllData, byteCommHeader.Length); + Array.Copy(byteEncryptData, 0, editedAllData, byteCommHeader.Length, byteEncryptData.Length); + + return editedAllData; + } + else // "1" 암호문 + { + return plainData; + } + + } + + #endregion + + #region 복호화 편집 + /// + /// 복호화 위해 전문 편집 + /// + /// + /// + private byte[] DecryptData(byte[] EncryptData) + { + int nNowPos = 0; + + //통신헤더전문편집 + string[] aCommHead = new string[Column.COMM_HEADER.LEN.Length]; + ItemColumn.ParseMessage(Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE, EncryptData, ref nNowPos, ref aCommHead); + + string sPosNo = aCommHead[Column.COMM_HEADER.SEQ.PosNo].ToString(); + //string sRegNo = aCommHead[Column.COMM_HEADER.SEQ.RegNo].ToString(); + string sRegNo = ""; + string sMsgLen = aCommHead[Column.COMM_HEADER.SEQ.MsgLen].ToString(); + string sEncType = aCommHead[Column.COMM_HEADER.SEQ.EncType].ToString(); + byte[] bytePlainData = null; + byte[] editedAllData = null; + + if (sEncType == "1") //복호화 + { + //Tran헤더 포함 전문 데이터 + byte[] tranBytes = new byte[EncryptData.Length - nNowPos]; + + Array.Copy(EncryptData, nNowPos, tranBytes, 0, tranBytes.Length); + + //복호화 + bytePlainData = AES.DynamicKeyDecrypt(sPosNo, sRegNo, tranBytes); + + int iMsgLen = nNowPos + bytePlainData.Length; + + aCommHead[Column.COMM_HEADER.SEQ.MsgLen] = iMsgLen.ToString(); //공통헤더와 암호문 더해진 길이 + aCommHead[Column.COMM_HEADER.SEQ.EncType] = "0"; //0:평문 1:암호화 + + string sChangedCommHeader = ItemColumn.MakeMessage(aCommHead, Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE); + + byte[] byteCommHeader = Encoding.Default.GetBytes(sChangedCommHeader); + editedAllData = new byte[byteCommHeader.Length + bytePlainData.Length]; + + Array.Copy(byteCommHeader, editedAllData, byteCommHeader.Length); + Array.Copy(bytePlainData, 0, editedAllData, byteCommHeader.Length, bytePlainData.Length); + + return editedAllData; + + } + else + { + return EncryptData; + } + + } + + #endregion + + #region IRT Send/Receive + /// + /// IRT전문의 Send/Receive + /// + /// + /// + /// + private int SendReceiveData(byte[] pSendData, ref byte[] pRecvData) + { + int nRecvLen = 0; + int nStat = BaseCom.NG; + byte[] rRecvData = null; + + try + { + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + // Data Send & Receive + nRecvLen = m_IrtSocket.SendReceiveData(pSendData, ref rRecvData, m_ServerTimeout); + + if (nRecvLen > 0) + { + pRecvData = rRecvData; + nStat = BaseCom.OK; + } + else + { + pRecvData = null; + } + //m_IrtSocket.Close(); + } + catch (Exception e) + { + //if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkIRT.SendReceiveData()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + finally + { + } + System.Threading.Thread.Sleep(100); + return nStat; + } + + /// + /// IRT전문의 Send/Receive + /// + /// + /// + /// + private int SendReceiveData(string pSendData, ref string pRecvData) + { + int nRecvLen = 0; + int nStat = BaseCom.NG; + string rRecvData = ""; + + try + { + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + // Data Send & Receive + nRecvLen = m_IrtSocket.SendReceiveData(pSendData, ref rRecvData, m_ServerTimeout); + + if (nRecvLen > 0) + { + pRecvData = rRecvData; + nStat = BaseCom.OK; + } + else + { + pRecvData = ""; + nStat = nRecvLen; + } + //m_IrtSocket.Close(); + } + catch (Exception e) + { + //if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkIRT.SendReceiveData()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + finally + { + } + + System.Threading.Thread.Sleep(100); + return nStat; + } + #endregion + + #region IRT 암호화/복화화 전송 + /// + /// IRT String로의 Send/Recv + /// + /// + /// + /// + /// + /// + /// + public int IRTSendReceive(string sIP, int iPort, int iTimeOut, string sComm, ref string sRecvData) + { + int nStat = 9; + string sReturn = string.Empty; + + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + byte[] bEditedSendData = null; + + if (m_ServerIp != "" && m_ServerPort != 0) + { + //암호화 + if (sComm.Length != 0) + { + //bEditedSendData = EncryptData(Encoding.Default.GetBytes(sComm)); + bEditedSendData = Encoding.Default.GetBytes(sComm); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceive()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sComm); + } + else + { + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceive()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] SendData is Null"); + } + + //SendReceive + nStat = SendReceiveData(Encoding.Default.GetString(bEditedSendData, 0, bEditedSendData.Length), ref sReturn); + + //복호화 + if (sReturn.Length != 0) + { + byte[] byteRecv = DecryptData(Encoding.Default.GetBytes(sReturn)); + sRecvData = Encoding.Default.GetString(byteRecv, 0, byteRecv.Length); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceive()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sRecvData); + } + else + { + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceive()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] RecvData Is Null"); + } + } + + return nStat; + } + + /// + /// IRT Byte로의 Send/Recv + /// + /// + /// + /// + /// + /// + /// + public int IRTSendReceive(string sIP, int iPort, int iTimeOut, byte[] comm, ref byte[] sRecvData) + { + int nStat = 9; + string sReturn = string.Empty; + + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + byte[] bEditedSendData = null; + + if (m_ServerIp != "" && m_ServerPort != 0) + { + //암호화 + if (comm != null) + { + bEditedSendData = EncryptData(comm); + + string sTmpLog = Encoding.Default.GetString(comm, 0, comm.Length); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceive()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sTmpLog); + } + else + { + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceive()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] SendData Is Null"); + } + + //SendReceive + nStat = SendReceiveData(bEditedSendData, ref sRecvData); + + //복호화 + if (sRecvData != null) + { + byte[] sDecryptRecvData = DecryptData(sRecvData); + + sRecvData = sDecryptRecvData; + + string sTmpLog = Encoding.Default.GetString(sDecryptRecvData, 0, sDecryptRecvData.Length); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceive()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sTmpLog); + } + else + { + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceive()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] RecvData Is Null"); + } + } + + return nStat; + } + #endregion + + #region IRT 전송 - 외부 VAN + /// + /// IRT String로의 Send/Recv - 외부 Van + /// + /// + /// + /// + /// + /// + /// + /// + /// + public int IRTSendReceiveEx(string sIP, int iPort, int iTimeOut, string sSendData, ref string sRecvData, int nRecvDataLen, string sAckData) + { + return IRTSendReceiveEx(sIP, iPort, iTimeOut, sSendData, ref sRecvData, nRecvDataLen, sAckData, false); + } + + public int IRTSendReceiveEx(string sIP, int iPort, int iTimeOut, string sSendData, ref string sRecvData, int nRecvDataLen, string sAckData, bool bErrorSkip) + { + int nStat = BaseCom.NG; + try + { + sRecvData = ""; + if (sIP == "" || iPort == 0) return nStat; + + // Connect 설정 + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveEx()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sSendData); + + // Data Send & Receive + System.Diagnostics.Debug.Print("요청=" + sSendData); + nStat = m_IrtSocket.SendReceiveData(sSendData, ref sRecvData, m_ServerTimeout, nRecvDataLen, sAckData, bErrorSkip); + System.Diagnostics.Debug.Print("응답=" + sRecvData); + + if (nStat > 0) nStat = BaseCom.OK; + + //m_IrtSocket.Close(); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveSEx()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sRecvData); + } + catch (Exception e) + { + //if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkIRT.SendReceiveDataEx()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + + System.Threading.Thread.Sleep(100); + return nStat; + } + + /// + /// IRT Byte로의 Send/Recv - 외부 Van + /// + /// + /// + /// + /// + /// + /// + /// + /// + public int IRTSendReceiveEx(string sIP, int iPort, int iTimeOut, byte[] bSendData, ref byte[] bRecvData, int nRecvDataLen, byte[] sAckData) + { + int nStat = BaseCom.NG; + try + { + bRecvData[0] = 0; + if (sIP == "" || iPort == 0) return nStat; + + // Connect 설정 + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveEx()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + Encoding.Default.GetString(bSendData, 0, bSendData.Length)); + + // Data Send & Receive + System.Diagnostics.Debug.Print("요청=" + Encoding.Default.GetString(bSendData, 0, bSendData.Length)); + nStat = m_IrtSocket.SendReceiveData(bSendData, ref bRecvData, m_ServerTimeout, nRecvDataLen, sAckData); + System.Diagnostics.Debug.Print("응답=" + Encoding.Default.GetString(bRecvData, 0, bRecvData.Length)); + if (nStat > 0) nStat = BaseCom.OK; + + //m_IrtSocket.Close(); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveEx()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + Encoding.Default.GetString(bRecvData, 0, bRecvData.Length)); + } + catch (Exception e) + { + //if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkIRT.SendReceiveDataEx()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + return nStat; + } + #endregion + + #region IRT 전송 - 외부 VAN (전문길이 위치지정) + + /// + /// IRT String로의 Send/Recv - 외부 Van (길이 위치지정) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public int IRTSendReceiveLen(string sIP, int iPort, int iTimeOut, string sSendData, ref string sRecvData, bool bFullSize, int nRecvDataLen, int nRecvDataStartPosion) + { + int nStat = BaseCom.NG; + try + { + sRecvData = ""; + if (sIP == "" || iPort == 0) return nStat; + + // Connect 설정 + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveLen()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sSendData); + + // Data Send & Receive + System.Diagnostics.Debug.Print("요청=" + sSendData); + nStat = m_IrtSocket.SendReceiveData(sSendData, ref sRecvData, m_ServerTimeout, bFullSize, nRecvDataLen, "", nRecvDataStartPosion, false ); + System.Diagnostics.Debug.Print("응답=" + sRecvData); + + if (nStat > 0) nStat = BaseCom.OK; + + //m_IrtSocket.Close(); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveLen()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sRecvData); + } + catch (Exception e) + { + //if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkIRT.SendReceiveDataEx()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + + System.Threading.Thread.Sleep(100); + return nStat; + } + + /// + /// IRT Byte로의 Send/Recv - 외부 Van (전문길이 위치지정) + /// + /// + /// + /// + /// + /// + /// + /// + /// + public int IRTSendReceiveLen(string sIP, int iPort, int iTimeOut, byte[] bSendData, ref byte[] bRecvData, int nRecvDataLen, int nRecvDataStartPosion) + { + int nStat = BaseCom.NG; + try + { + bRecvData[0] = 0; + if (sIP == "" || iPort == 0) return nStat; + + // Connect 설정 + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveLen()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + Encoding.Default.GetString(bSendData, 0, bSendData.Length)); + + // Data Send & Receive + System.Diagnostics.Debug.Print("요청=" + Encoding.Default.GetString(bSendData, 0, bSendData.Length)); + nStat = m_IrtSocket.SendReceiveData(bSendData, ref bRecvData, m_ServerTimeout, nRecvDataLen, null, nRecvDataStartPosion); + System.Diagnostics.Debug.Print("응답=" + Encoding.Default.GetString(bRecvData, 0, bRecvData.Length)); + if (nStat > 0) nStat = BaseCom.OK; + + //m_IrtSocket.Close(); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveLen()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + Encoding.Default.GetString(bRecvData, 0, bRecvData.Length)); + } + catch (Exception e) + { + //if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkIRT.SendReceiveDataLen()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + return nStat; + } + #endregion + + #region IRT Byte로의 Send/Recv - 외부 Van (Bypass Byte) + /// + /// IRT Byte로의 Send/Recv - 외부 Van (Bypass Byte) + /// + /// + /// + /// + /// + /// + /// + /// + public int ByPassSendReceiveData(string sIP, int iPort, int iTimeOut, byte[] bSendData, ref byte[] bRecvData, int nRecvDataLen) + { + int nStat = BaseCom.NG; + try + { + //bRecvData[0] = 0; + if (sIP == "" || iPort == 0) return nStat; + + // Connect 설정 + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveLen()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + Encoding.Default.GetString(bSendData, 0, bSendData.Length)); + + // Data Send & Receive + System.Diagnostics.Debug.Print("요청=" + Encoding.Default.GetString(bSendData, 0, bSendData.Length)); + nStat = m_IrtSocket.ByPassSendReceiveData(bSendData, nRecvDataLen, ref bRecvData, m_ServerTimeout); + System.Diagnostics.Debug.Print("응답=" + Encoding.Default.GetString(bRecvData, 0, bRecvData.Length)); + if (nStat > 0) nStat = BaseCom.OK; + + //m_IrtSocket.Close(); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkIRT.IRTSendReceiveLen()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + Encoding.Default.GetString(bRecvData, 0, bRecvData.Length)); + } + catch (Exception e) + { + //if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkIRT.SendReceiveDataLen()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + return nStat; + } + #endregion + } +} diff --git a/Agent/Network/NetworkJSON.cs b/Agent/Network/NetworkJSON.cs new file mode 100644 index 0000000..f21292c --- /dev/null +++ b/Agent/Network/NetworkJSON.cs @@ -0,0 +1,1087 @@ +//#define LOG_TRACE //@@ 로그 확인시 사용;girak.kim;20171011 + +using System; +using System.Collections.Generic; +using System.Text; +using System.Threading; +using System.Collections; +using System.Net.NetworkInformation; +using System.Runtime.InteropServices; + +using Newtonsoft.Json; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : SC / HQ IRT Request (SC / 본부 IRT 요청) +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.Network +{ + public class NetworkJSON : INetworkJSON + { + private SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출 + private StateServer StateObject = (StateServer)StateServer.GetInstance(); // StateObject : StateServer Object (객체) + private PosStatus m_cPosStatus; // 기본정보 참조 + private DeviceStatus m_cDevStatus; // 장비정보 참조 + + /// + /// Sending Socket (전송 소켓) + /// + private static TcpSocket m_IrtSocket = null; + + /// + /// IP + /// + private string m_ServerIp = ""; + + /// + /// Port + /// + private int m_ServerPort = 0; + + /// + /// Recv Timeout + /// + private int m_ServerTimeout = 5000; + + + /// --------------------------------------------------------------------------------------------- + /// + /// Constructor (생성자) + /// + /// --------------------------------------------------------------------------------------------- + public NetworkJSON() + { + m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 + m_cDevStatus = (DeviceStatus)StateObject.DEVICE; // POS 장치정보 + } + + /// + /// Get network online status with Ping check. (Ping체크로 network Online상태를 취득한다,) + /// + /// Ip address + /// True : online false : Offline + private int CheckNetworkOnline(string pHostAddress) + { + //Ping Check (Ping 체크) + Ping pingSender = new Ping(); + PingOptions optins = new PingOptions(); + optins.DontFragment = true; + string data = "aaa"; + byte[] buffer = Encoding.ASCII.GetBytes(data); + int timeout = 120; + PingReply reply = pingSender.Send(pHostAddress, timeout, buffer, optins); + + if (reply.Status == IPStatus.Success) + return UserCom.OK; + else + return UserCom.NG; + } +/* + #region 암호화 편집 + /// + /// 암호화 위해 전문 편집 + /// + /// 평문 + /// 암호문, 에러시 평문 리턴 + private byte[] EncryptData(byte[] plainData) + { + int nNowPos = 0; + + //통신헤더전문편집 + string[] aCommHead = new string[Column.COMM_HEADER.LEN.Length]; + ItemColumn.ParseMessage(Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE, plainData, ref nNowPos, ref aCommHead); + + string sPosNo = aCommHead[Column.COMM_HEADER.SEQ.PosNo].ToString(); + //string sRegNo = aCommHead[Column.COMM_HEADER.SEQ.RegNo].ToString(); + string sRegNo = ""; + string sMsgLen = aCommHead[Column.COMM_HEADER.SEQ.MsgLen].ToString(); + string sEncType = aCommHead[Column.COMM_HEADER.SEQ.EncType].ToString(); + byte[] byteEncryptData = null; + byte[] editedAllData = null; + + if (sEncType == "0") // "0" 평문 + { + //Tran헤더 포함 전문 데이터 + byte[] tranBytes = new byte[plainData.Length - nNowPos]; + + Array.Copy(plainData, nNowPos, tranBytes, 0, plainData.Length - nNowPos); + + //암호화 + byteEncryptData = AES.DynamicKeyEncrypt(sPosNo, sRegNo, tranBytes); + + int iMsgLen = nNowPos + byteEncryptData.Length; + + aCommHead[Column.COMM_HEADER.SEQ.MsgLen] = iMsgLen.ToString(); //공통헤더와 암호문 더해진 길이 + aCommHead[Column.COMM_HEADER.SEQ.EncType] = "1"; //0:평문 1:암호화 + + string sChangedCommHeader = ItemColumn.MakeMessage(aCommHead, Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE); + byte[] byteCommHeader = Encoding.Default.GetBytes(sChangedCommHeader); + + editedAllData = new byte[iMsgLen]; + Array.Copy(byteCommHeader, editedAllData, byteCommHeader.Length); + Array.Copy(byteEncryptData, 0, editedAllData, byteCommHeader.Length, byteEncryptData.Length); + + return editedAllData; + } + else // "1" 암호문 + { + return plainData; + } + + } + + #endregion + + #region 복호화 편집 + /// + /// 복호화 위해 전문 편집 + /// + /// + /// + private byte[] DecryptData(byte[] EncryptData) + { + int nNowPos = 0; + + //통신헤더전문편집 + string[] aCommHead = new string[Column.COMM_HEADER.LEN.Length]; + ItemColumn.ParseMessage(Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE, EncryptData, ref nNowPos, ref aCommHead); + + string sPosNo = aCommHead[Column.COMM_HEADER.SEQ.PosNo].ToString(); + //string sRegNo = aCommHead[Column.COMM_HEADER.SEQ.RegNo].ToString(); + string sRegNo = ""; + string sMsgLen = aCommHead[Column.COMM_HEADER.SEQ.MsgLen].ToString(); + string sEncType = aCommHead[Column.COMM_HEADER.SEQ.EncType].ToString(); + byte[] bytePlainData = null; + byte[] editedAllData = null; + + if (sEncType == "1") //복호화 + { + //Tran헤더 포함 전문 데이터 + byte[] tranBytes = new byte[EncryptData.Length - nNowPos]; + + Array.Copy(EncryptData, nNowPos, tranBytes, 0, tranBytes.Length); + + //복호화 + bytePlainData = AES.DynamicKeyDecrypt(sPosNo, sRegNo, tranBytes); + + int iMsgLen = nNowPos + bytePlainData.Length; + + aCommHead[Column.COMM_HEADER.SEQ.MsgLen] = iMsgLen.ToString(); //공통헤더와 암호문 더해진 길이 + aCommHead[Column.COMM_HEADER.SEQ.EncType] = "0"; //0:평문 1:암호화 + + string sChangedCommHeader = ItemColumn.MakeMessage(aCommHead, Column.COMM_HEADER.LEN, Column.COMM_HEADER.TYPE); + + byte[] byteCommHeader = Encoding.Default.GetBytes(sChangedCommHeader); + editedAllData = new byte[byteCommHeader.Length + bytePlainData.Length]; + + Array.Copy(byteCommHeader, editedAllData, byteCommHeader.Length); + Array.Copy(bytePlainData, 0, editedAllData, byteCommHeader.Length, bytePlainData.Length); + + return editedAllData; + + } + else + { + return EncryptData; + } + + } + + #endregion +*/ + /// + /// POS 마스터 요청 시 사용하는 Connect 함수 + /// + /// + private int Connect(int iKeepTime = 5000) + { + int iReturn = BaseCom.NG; + try + { + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + // Delay time to close connection is 5 sec. + iReturn = m_IrtSocket.Connect(iKeepTime); + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.Connect()", e.ToString()); + } + + return iReturn; + } + + private void Close() + { + m_IrtSocket.Close(); + } + + + + /// + /// IRT전문의 Send/Receive + /// + /// + /// + /// + private int SendReceiveData(byte[] pSendData, ref byte[] pRecvData) + { + int nRecvLen = 0; + int nStat = BaseCom.NG; + byte[] rRecvData = null; + + try + { + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + // Data Send & Receive + nRecvLen = m_IrtSocket.SendReceiveData(pSendData, ref rRecvData, m_ServerTimeout); + + if (nRecvLen > 0) + { + pRecvData = rRecvData; + nStat = BaseCom.OK; + } + else + { + pRecvData = null; + } + m_IrtSocket.Close(); + } + catch (Exception e) + { + if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.SendReceiveData()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + finally + { + } + System.Threading.Thread.Sleep(100); + return nStat; + } + + /// + /// IRT전문의 Send/Receive + /// + /// + /// + /// + private int SendReceiveData(string pSendData, ref string pRecvData, bool bIsDmbIf = false) + { + int nRecvLen = 0; + int nStat = BaseCom.NG; + string rRecvData = ""; + + try + { + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + // Data Send & Receive + //System.Diagnostics.Debug.Print("요청:" + pSendData); + nRecvLen = m_IrtSocket.SendReceiveData(pSendData, ref rRecvData, m_ServerTimeout, bIsDmbIf); + //System.Diagnostics.Debug.Print("응답:" + rRecvData); + + if (nRecvLen > 0) + { + pRecvData = rRecvData; + nStat = BaseCom.OK; + } + else + { + pRecvData = ""; + nStat = nRecvLen; + } + m_IrtSocket.Close(); + } + catch (Exception e) + { + if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.SendReceiveData()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + finally + { + } + + System.Threading.Thread.Sleep(100); + return nStat; + } + + /// + /// IRT전문의 Send/Receive (고정사이즈) + /// + /// + /// + /// + /// + /// + /// + private int SendReceiveDataFixSiz(string pSendData, ref string pRecvData, bool bIsDmbIf = false, bool bFix = false, int nFixSize = 0) + { + int nRecvLen = 0; + int nStat = BaseCom.NG; + string rRecvData = ""; + + try + { + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + // Data Send & Receive + //System.Diagnostics.Debug.Print("요청:" + pSendData); + if (bFix == true) + nRecvLen = m_IrtSocket.SendReceiveData(pSendData, ref rRecvData, m_ServerTimeout, nFixSize, "", true); + else + nRecvLen = m_IrtSocket.SendReceiveData(pSendData, ref rRecvData, m_ServerTimeout, bIsDmbIf); + //System.Diagnostics.Debug.Print("응답:" + rRecvData); + + if (nRecvLen > 0) + { + pRecvData = rRecvData; + nStat = BaseCom.OK; + } + else + { + pRecvData = ""; + nStat = nRecvLen; + } + m_IrtSocket.Close(); + } + catch (Exception e) + { + if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.SendReceiveData()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + finally + { + } + + System.Threading.Thread.Sleep(100); + return nStat; + } + + private int SendReceiveMstData(string pSendData, ref string pRecvData) + { + int nRecvLen = 0; + int nStat = BaseCom.NG; + try + { + nRecvLen = m_IrtSocket.SendReceiveMstData(pSendData, ref pRecvData); + if (nRecvLen > 0) + { + nStat = BaseCom.OK; + } + else + { + //2018.01.11;수신 데이터 길이가 0 이하일 경우 로그 추가;girak.kim;Start + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "[SendData] : " + pSendData + + "[RecvData(Head)] : " + pRecvData + + "[RecvLen] : " + nRecvLen.ToString()); + //2018.01.11;수신 데이터 길이가 0 이하일 경우 로그 추가;girak.kim;End + } + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + e.ToString()); + } + + return nStat; + } + + /// + /// IRT Byte로의 Send/Recv + /// (공통헤더의 전문길이 0으로 세팅해서 송신. 자동 계산) + /// + /// + public int IRTSendReceive(string sIP, int iPort, int iTimeOut, string sCommData, Hashtable htData, ref Hashtable htRecvData) + { + int nStat = 9; + string sReturn = string.Empty; + string sRecvCommHeader = string.Empty; + string sRecvData = string.Empty; + + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + string sJsonSendData = ""; + string sJsonReceiveData = ""; + + try + { + if (m_ServerIp != "" && m_ServerPort != 0) + { + if (htData != null) + { + sJsonSendData = JsonConvert.SerializeObject(htData); + + //sJsonSendData 암호화 처리 ... + + Byte[] sBytTempBuff = Encoding.UTF8.GetBytes(sJsonSendData); + string sDataLen = string.Format("{0:000000}", sBytTempBuff.Length); + + sCommData = sDataLen + sCommData.Substring(TcpSocket.COMM_MSGLEN); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkJSON.IRTSendReceive()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sCommData + sJsonSendData); + } + + //Send Receive + nStat = SendReceiveData(sCommData + sJsonSendData, ref sJsonReceiveData); + + if (sJsonReceiveData != null && sJsonReceiveData != "") + { + sRecvCommHeader = sJsonReceiveData.Substring(0, TcpSocket.COMM_HEAD_LEN); + sRecvData = sJsonReceiveData.Substring(TcpSocket.COMM_HEAD_LEN); + //sJsonReceiveData 복호화 처리 ... + + htRecvData = JsonConvert.DeserializeObject(sRecvData); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkJSON.IRTSendReceive()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sRecvCommHeader + sRecvData); + } + } + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.IRTSendReceive()", e.ToString()); + } + + return nStat; + } + /// + /// 디지털메뉴보드 I/F용 send/receive + /// + /// + /// + /// + /// + /// + /// + /// + public int DmbIRTSendReceive(string sIP, int iPort, int iTimeOut, string sCommData, Hashtable htData, ref string sRecvedData) + { + int nStat = 9; + string sReturn = string.Empty; + string sRecvCommHeader = string.Empty; + string sRecvData = string.Empty; + + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + string sJsonSendData = ""; + string sJsonReceiveData = ""; + + try + { + if (m_ServerIp != "" && m_ServerPort != 0) + { + if (htData != null) + { + sJsonSendData = JsonConvert.SerializeObject(htData); + + //sJsonSendData 암호화 처리 ... + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkJSON.IRTSendReceive()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sCommData + sJsonSendData); + } + + byte[] bytes = Encoding.UTF8.GetBytes(sCommData + sJsonSendData); + string sUTF8String = Encoding.UTF8.GetString(bytes); + + //Send Receive + //nStat = SendReceiveData(sCommData + sJsonSendData, ref sJsonReceiveData, true); + nStat = SendReceiveData(sUTF8String, ref sJsonReceiveData, true); + + if (sJsonReceiveData != null && sJsonReceiveData != "") + { + sRecvCommHeader = sJsonReceiveData.Substring(0, 60); + sRecvData = sJsonReceiveData.Substring(60); + + //#16569 파스쿠찌 드라이브 스루 기능 개발 요청 start + //기존 + /* + sRecvedData = sRecvCommHeader; + */ + //변경 + sRecvedData = sRecvCommHeader + sRecvData; + //#16569 파스쿠찌 드라이브 스루 기능 개발 요청 end + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkJSON.IRTSendReceive()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sRecvCommHeader + sRecvData); + } + } + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.IRTSendReceive()", e.ToString()); + } + + return nStat; + } + + /// + /// 마스터 요청을 위한 string으로의 send/receive + /// + /// + /// + /// + /// + /// + /// + /// + public int MstIRTSendReceive(string sIp, int iPort, int iTimeOut, string sCommData, Hashtable htData, ref StringBuilder sbRecvData) + { + int nStat = BaseCom.NG; + string sRecvCommHeader = string.Empty; + string sRecvData = string.Empty; + + IMasterDownUs cMstDownSrv = null; + + try + { + m_ServerIp = sIp; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + string sJsonSendData = string.Empty; + string sJsonReceiveData = string.Empty; + Hashtable htRecvData = null; + + sbRecvData = new StringBuilder(); + + nStat = Connect(-1); + + if(nStat == BaseCom.OK) + { + cMstDownSrv = (IMasterDownUs)sManager.InitServiceInstance(ServiceLists.BSV_BASIC.DLL, ServiceLists.BSV_BASIC.MASTER_DOWN); + + while (true) + { + if (cMstDownSrv.IsAborted == true) + { + return BaseCom.NG2; + } + + sJsonSendData = JsonConvert.SerializeObject(htData); + + //sJsonSendData 암호화 처리 ... + + Byte[] sBytTempBuff = Encoding.UTF8.GetBytes(sJsonSendData); + string sDataLen = string.Format("{0:000000}", sBytTempBuff.Length); + + sCommData = sDataLen + sCommData.Substring(TcpSocket.COMM_MSGLEN); + + // 마스터 송수신 로그 제거(20170520) + //UserLog.WriteLogFile(UserCom.LOG_SOCK, + // UserCom.WARNING_LEVEL, + // System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + // System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + // CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sCommData + sJsonSendData); + + // 전문 송신 + +#if(LOG_TRACE) ////@@ 로그 확인 용 + UserLog.WriteLogFile(UserCom.LOG_OP, "NetJson SendData : ", System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + "," + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", sCommData + sJsonSendData); +#endif + + nStat = SendReceiveMstData(sCommData + sJsonSendData, ref sJsonReceiveData); + +#if(LOG_TRACE) ////@@ 로그 확인 용 + UserLog.WriteLogFile(UserCom.LOG_OP, "NetJson RecvData : ", System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + "," + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", sJsonReceiveData); +#endif + + if (nStat == BaseCom.OK) + { + // 마스터 송수신 로그 제거(20170520) + //UserLog.WriteLogFile(UserCom.LOG_SOCK, + // UserCom.WARNING_LEVEL, + // System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + // System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + // CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sJsonReceiveData); + + if (sJsonReceiveData != null && sJsonReceiveData != string.Empty) + { + sRecvCommHeader = sJsonReceiveData.Substring(0, TcpSocket.COMM_HEAD_LEN); + sRecvData = sJsonReceiveData.Substring(TcpSocket.COMM_HEAD_LEN); + + //sRecvData 복호화 처리 ... + + htRecvData = JsonConvert.DeserializeObject(sRecvData); + + if (int.Parse(htRecvData[Column.IQ_POSMASTER_RSP.DATA.Count].ToString().Trim()) != 0) + { + // StringBuilder에 추가 + sbRecvData.Append(htRecvData[Column.IQ_POSMASTER_RSP.DATA.Data].ToString()); + } + else + { + break; + } + // 요청전문의 요청 코드 변경 + htData[Column.IQ_POSMASTER_REQ.DATA.ProcCd] = "1"; + } + } + else + { + return BaseCom.NG1; + } + } + + nStat = BaseCom.OK; + } + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.MstIRTSendReceive()", e.ToString()); + } + finally + { + Close(); + } + + return nStat; + } + + + + /// + /// 2019-03-20 - 1997fx11 : Kiosk 관련 요청을 위한 string으로의 send/receive + /// 고객구매이력 외 + /// + /// + /// + /// + /// + /// + /// + /// + /// + public int CmsIRTSendReceive(string sIp, int iPort, int iTimeOut, string sCommData, Hashtable htData, ref StringBuilder sbRecvData, ref string sUpDate) + { + int nStat = BaseCom.NG; + string sRecvCommHeader = string.Empty; + string sRecvData = string.Empty; + + IMasterDownUs cMstDownSrv = null; + + try + { + m_ServerIp = sIp; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + string sJsonSendData = string.Empty; + string sJsonReceiveData = string.Empty; + Hashtable htRecvData = null; + + sbRecvData = new StringBuilder(); + + nStat = Connect(-1); + + if (nStat == BaseCom.OK) + { + cMstDownSrv = (IMasterDownUs)sManager.InitServiceInstance(ServiceLists.BSV_BASIC.DLL, ServiceLists.BSV_BASIC.MASTER_DOWN); + + if (cMstDownSrv.IsAborted == true) + { + return BaseCom.NG2; + } + + sJsonSendData = JsonConvert.SerializeObject(htData); + + //sJsonSendData 암호화 처리 ... + Byte[] sBytTempBuff = Encoding.UTF8.GetBytes(sJsonSendData); + string sDataLen = string.Format("{0:000000}", sBytTempBuff.Length); + + sCommData = sDataLen + sCommData.Substring(TcpSocket.COMM_MSGLEN); + + // 전문 송신 + +#if (LOG_TRACE) ////@@ 로그 확인 용 + UserLog.WriteLogFile(UserCom.LOG_OP, "NetJson SendData : ", System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + "," + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", sCommData + sJsonSendData); +#endif + + nStat = SendReceiveMstData(sCommData + sJsonSendData, ref sJsonReceiveData); + +#if (LOG_TRACE) ////@@ 로그 확인 용 + UserLog.WriteLogFile(UserCom.LOG_OP, "NetJson RecvData : ", System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + "," + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", sJsonReceiveData); +#endif + + if (nStat == BaseCom.OK) + { + if (sJsonReceiveData != null && sJsonReceiveData != string.Empty) + { + sRecvCommHeader = sJsonReceiveData.Substring(0, TcpSocket.COMM_HEAD_LEN); + sRecvData = sJsonReceiveData.Substring(TcpSocket.COMM_HEAD_LEN); + + //sRecvData 복호화 처리 ... + htRecvData = JsonConvert.DeserializeObject(sRecvData); + + // IRQ_TYPE - 01 : 고객구매이력, 02 : 신상품목록 + if (htRecvData[Column.IQ_KIOSK_REQ.DATA.InqType].ToString() == "01") + { + if ((htData[Column.IQ_KIOSK_REQ.DATA.HpcCustCd].ToString() == htRecvData[Column.IQ_KIOSK_REQ.DATA.HpcCustCd].ToString())) + { + sbRecvData.Append(htRecvData["VALUE"].ToString()); + } + + if (htRecvData[Column.IQ_KIOSK_REQ.DATA.ResCd].ToString() == "00") + { + // 요청전문의 요청 코드 변경 + htData[Column.IQ_POSMASTER_REQ.DATA.ProcCd] = "1"; + } + else + { + return BaseCom.NG1; + } + } + else if (htRecvData[Column.IQ_KIOSK_REQ.DATA.InqType].ToString() == "02") + { + sbRecvData.Append(htRecvData["VALUE"].ToString()); + sUpDate = htRecvData["LAST_UPD_TIME"].ToString(); // Last Update Date + + if (htRecvData[Column.IQ_KIOSK_REQ.DATA.ResCd].ToString() == "00") + { + // 요청전문의 요청 코드 변경 + htData[Column.IQ_POSMASTER_REQ.DATA.ProcCd] = "1"; + } + else + { + return BaseCom.NG1; + } + } + else if (htRecvData[Column.IQ_KIOSK_REQ.DATA.InqType].ToString() == "04") + { + if (htRecvData[Column.IQ_KIOSK_REQ.DATA.ResCd].ToString() == "00") + { + // 요청전문의 요청 코드 변경 + htData[Column.IQ_POSMASTER_REQ.DATA.ProcCd] = "1"; + } + else + { + return BaseCom.NG1; + } + } + else if (htRecvData[Column.IQ_KIOSK_REQ.DATA.InqType].ToString() == "05") + { + if (htRecvData[Column.IQ_KIOSK_REQ.DATA.ResCd].ToString() == "00") + { + // 요청전문의 요청 코드 변경 + htData[Column.IQ_POSMASTER_REQ.DATA.ProcCd] = "1"; + } + else + { + return BaseCom.NG1; + } + } + + //if (htRecvData[Column.IQ_KIOSK_REQ.DATA.ResCd].ToString() == "00") + //{ + // // 요청전문의 요청 코드 변경 + // htData[Column.IQ_POSMASTER_REQ.DATA.ProcCd] = "1"; + //} + //else + //{ + // return BaseCom.NG1; + //} + } + } + else + { + return BaseCom.NG1; + } + + nStat = BaseCom.OK; + } + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name,"NetworkJSON.CmsIRTSendReceive()", e.ToString()); + } + finally + { + Close(); + } + + return nStat; + } + + + /// + /// 중국 - 알리페이/위챗페이 승인 데몬과 통신 + /// + /// + /// + /// + /// + /// + /// + public int ChinaIRTSendReceive(string sIP, int iPort, int iTimeOut, string sData, ref Hashtable htRecvData) + { + int nStat = 9; + string sReturn = string.Empty; + string sRecvCommHeader = string.Empty; + string sRecvData = string.Empty; + + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + string sJsonSendData = ""; + string sJsonReceiveData = ""; + + try + { + if (m_ServerIp != "" && m_ServerPort != 0) + { + if (sData != "") + { + sJsonSendData = sData; + //sJsonSendData = JsonConvert.SerializeObject(htData); + + //sJsonSendData 암호화 처리 ... + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkJSON.ChinaIRTSendReceive()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sJsonSendData); + } + + byte[] bytes = Encoding.UTF8.GetBytes(sJsonSendData); + string sUTF8String = Encoding.UTF8.GetString(bytes); + + //Send Receive + //nStat = SendReceiveData(sUTF8String, ref sJsonReceiveData, false); + nStat = SendReceiveDataFixSiz(sUTF8String, ref sJsonReceiveData, false, true, 4096); + + if (sJsonReceiveData != null && sJsonReceiveData != "") + { + sRecvData = sJsonReceiveData; + htRecvData = JsonConvert.DeserializeObject(sRecvData); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkJSON.ChinaIRTSendReceive()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sRecvData); + } + } + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.ChinaIRTSendReceive()", e.ToString()); + } + + return nStat; + } + + //#20180322 휴게소pos매출연동 start,phj + /// + /// JSON 파일 생성 + /// + /// 자료 형태 + /// 경로 + 파일 + /// 자료 + /// string + public string SaveJsonFile(string sType, string sFile, string sJsonData) + { + string sRet = UserCom.RST_ERR; + try + { + using (System.IO.StreamWriter file = new System.IO.StreamWriter(sFile)) + { + file.WriteLine(sJsonData); + } + sRet = UserCom.RST_OK; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.SaveJsonFile()", ex.ToString()); + } + + return sRet; + } + + /// + /// HashTable 데이터를 JSON String 으로 변환 + /// + /// + /// + /// string + public string HashToJsonString(Hashtable htData, ref string sJson) + { + string sRet = UserCom.RST_ERR; + try + { + sJson = JsonConvert.SerializeObject(htData); + sRet = UserCom.RST_OK; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.HashToJsonString()", ex.ToString()); + } + + return sRet; + } + //#20180322 휴게소pos매출연동 end,phj + + /// + /// 2019-05-29 - 1997fx11 : 알림톡 전송 + /// + /// + /// + public int Send_NoticeTalk(string sIp, int iPort, int iTimeOut, string sCommData, Hashtable htData, ref string sUpDate, ref StringBuilder sbRecvData) + { + int nStat = BaseCom.NG; + string sRecvCommHeader = string.Empty; + string sRecvData = string.Empty; + sbRecvData = new StringBuilder(); + + IMasterDownUs cMstDownSrv = null; + + try + { + m_ServerIp = sIp; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + string sJsonSendData = string.Empty; + string sJsonReceiveData = string.Empty; + Hashtable htRecvData = null; + + nStat = Connect(-1); + + if (nStat == BaseCom.OK) + { + cMstDownSrv = (IMasterDownUs)sManager.InitServiceInstance(ServiceLists.BSV_BASIC.DLL, ServiceLists.BSV_BASIC.MASTER_DOWN); + + if (cMstDownSrv.IsAborted == true) + { + return BaseCom.NG2; + } + + sJsonSendData = JsonConvert.SerializeObject(htData); + + //sJsonSendData 암호화 처리 ... + Byte[] sBytTempBuff = Encoding.UTF8.GetBytes(sJsonSendData); + string sDataLen = string.Format("{0:000000}", sBytTempBuff.Length); + + sCommData = sDataLen + sCommData.Substring(TcpSocket.COMM_MSGLEN); + + // 전문 송신 + +#if (LOG_TRACE) ////@@ 로그 확인 용 + UserLog.WriteLogFile(UserCom.LOG_OP, "NetJson SendData : ", System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + "," + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", sCommData + sJsonSendData); +#endif + + nStat = SendReceiveMstData(sCommData + sJsonSendData, ref sJsonReceiveData); + +#if (LOG_TRACE) ////@@ 로그 확인 용 + UserLog.WriteLogFile(UserCom.LOG_OP, "NetJson RecvData : ", System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + "," + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", sJsonReceiveData); +#endif + + if (nStat == BaseCom.OK) + { + //if (sJsonReceiveData != null && sJsonReceiveData != string.Empty) + //{ + // sRecvCommHeader = sJsonReceiveData.Substring(0, TcpSocket.COMM_HEAD_LEN); + // sRecvData = sJsonReceiveData.Substring(TcpSocket.COMM_HEAD_LEN); + + // //sRecvData 복호화 처리 ... + // htRecvData = JsonConvert.DeserializeObject(sRecvData); + + // // IRQ_TYPE - 01 : 고객구매이력, 02 : 신상품목록 + // if (htRecvData[Column.IQ_KIOSK_REQ.DATA.InqType].ToString() == "01") + // { + // if ((htData[Column.IQ_KIOSK_REQ.DATA.HpcCustCd].ToString() == htRecvData[Column.IQ_KIOSK_REQ.DATA.HpcCustCd].ToString())) + // { + // sbRecvData.Append(htRecvData["VALUE"].ToString()); + // } + + // if (htRecvData[Column.IQ_KIOSK_REQ.DATA.ResCd].ToString() == "00") + // { + // // 요청전문의 요청 코드 변경 + // htData[Column.IQ_POSMASTER_REQ.DATA.ProcCd] = "1"; + // } + // else + // { + // return BaseCom.NG1; + // } + // } + // else if (htRecvData[Column.IQ_KIOSK_REQ.DATA.InqType].ToString() == "02") + // { + // sbRecvData.Append(htRecvData["VALUE"].ToString()); + // sUpDate = htRecvData["LAST_UPD_TIME"].ToString(); // Last Update Date + + // if (htRecvData[Column.IQ_KIOSK_REQ.DATA.ResCd].ToString() == "00") + // { + // // 요청전문의 요청 코드 변경 + // htData[Column.IQ_POSMASTER_REQ.DATA.ProcCd] = "1"; + // } + // else + // { + // return BaseCom.NG1; + // } + // } + // else if (htRecvData[Column.IQ_KIOSK_REQ.DATA.InqType].ToString() == "04") + // { + // if (htRecvData[Column.IQ_KIOSK_REQ.DATA.ResCd].ToString() == "00") + // { + // // 요청전문의 요청 코드 변경 + // htData[Column.IQ_POSMASTER_REQ.DATA.ProcCd] = "1"; + // } + // else + // { + // return BaseCom.NG1; + // } + // } + + // //if (htRecvData[Column.IQ_KIOSK_REQ.DATA.ResCd].ToString() == "00") + // //{ + // // // 요청전문의 요청 코드 변경 + // // htData[Column.IQ_POSMASTER_REQ.DATA.ProcCd] = "1"; + // //} + // //else + // //{ + // // return BaseCom.NG1; + // //} + //} + } + else + { + return BaseCom.NG1; + } + + nStat = BaseCom.OK; + } + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, "NetworkJSON.CmsIRTSendReceive()", e.ToString()); + } + finally + { + Close(); + } + + return nStat; + } + } +} diff --git a/Agent/Network/NetworkVanSPCN.cs b/Agent/Network/NetworkVanSPCN.cs new file mode 100644 index 0000000..82bf97f --- /dev/null +++ b/Agent/Network/NetworkVanSPCN.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.Runtime.InteropServices; +using System.Collections; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; + +namespace Cosmos.Network +{ + class NetworkVanSPCN : INetworkVanSPCN + { + //카드 리더 처리 클래스 통합 2016-06-17 SBSEO + + } +} diff --git a/Agent/Network/Properties/AssemblyInfo.cs b/Agent/Network/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..e3d401e --- /dev/null +++ b/Agent/Network/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("Network")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Network")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("6c2b4bd7-4335-44af-a2d7-f89369063e96")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Agent/NetworkCheckOver/Activator.cs b/Agent/NetworkCheckOver/Activator.cs new file mode 100644 index 0000000..0c77f01 --- /dev/null +++ b/Agent/NetworkCheckOver/Activator.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; + +namespace Cosmos.Service +{ + /// + /// Load BaseFrame and save information (BaseFrame의 로드하고 정보를 보관한다) + /// + public class Activator : InitServiceAbstract + { + /// + /// Define main entrance point of project load. (프로젝트 로드의 주진입점을 정의합니다.) + /// + public Activator() + { + + } + + /// + /// + /// + /// + /// + public override object InitServiceInstance(string sClassNm) + { + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Starting !!!"); + + object retObj = null; + + //클래스 찾아오기 위함 + switch (sClassNm) + { + case ServiceLists.AGENT_NETWORK_CHECKOVER.NetworkCheckOver: + { + Cosmos.Network.NetworkCheckOver agentClass = new Cosmos.Network.NetworkCheckOver(); + retObj = agentClass; + break; + } + } + + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Completed !!!"); + + return retObj; + + } + } +} diff --git a/Agent/NetworkCheckOver/CheckOverDetail.cs b/Agent/NetworkCheckOver/CheckOverDetail.cs new file mode 100644 index 0000000..8bfa627 --- /dev/null +++ b/Agent/NetworkCheckOver/CheckOverDetail.cs @@ -0,0 +1,553 @@ +using System; +using System.Collections.Generic; +using System.Collections; +using System.Linq; +using System.Text; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; +using Cosmos.CommonManager; + +namespace Cosmos.Network +{ + class CheckOverDetail : ICheckOverUs + { + private PosStatus m_cPosStatus = new PosStatus(); // 기본정보 참조 + private StateServer StateObject = (StateServer)StateServer.GetInstance(); // StateObject : StateServer Object (객체) + + /// + /// 생성자 + /// + public CheckOverDetail() + { + m_cPosStatus = (PosStatus)StateObject.POS; + } + + /// + /// 해피오더 - 주문 상태별 건수 조회 + /// + /// + /// + ///grayber@20180306 해피오더 주문가능 상태 추가 start - 함수 인자 추가 SelectHappyOrderCountByOrderStatus HashTable 인자추가 + /// 기존 + ///public string SelectHappyOrderCountByOrderStatus(Hashtable[] htOrderStatus) + /// 변경 + public string SelectHappyOrderCountByOrderStatus(Hashtable[] htOrderStatus , ref Hashtable htRspData) + //grayber@20180306 해피오더 주문가능 상태 추가 end + { + // 주문접수-일반 + int iOrderRegNormalCnt = 0; + // 주문접수-배달 + int iOrderRegDeliveryCnt = 0; + // 주문접수-예약 + int iOrderRegReservedCnt = 0; + // 총 주문접수 건수 + int iTotOrderRegCnt = 0; + int iProductReadyCnt = 0; + int iPreReservedCnt = 0; + int iPickupWaitCnt = 0; + int iPickupDelayCnt = 0; + int iNoPickupAndDelayCnt = 0; + int iDeliveryRequestCnt = 0; + int iDeliveryRegCnt = 0; + int iDeliveryingCnt = 0; + + //#20180328 직접배달 처리 후 배달완료시 매출 생성 안되는 증상 수정 start + int iDeliveryDirectCnt = 0; + //#20180328 직접배달 처리 후 배달완료시 매출 생성 안되는 증상 수정 end + + //#20180605 해피오더 개선 start + + //즉시주문, 예약주문 알림 + //즉시픽업 건수 + int iOrdCnt_Direct = 0; + //즉시배달 건수 + int iOrdCnt_Reserv = 0; + + //#20180605 해피오더 개선 end + + //#20180910 배달의 상품준비가 픽업 건들으로 집계되는 현상 수정 start + int iDeliveryProductReadyCnt = 0; + //#20180910 배달의 상품준비가 픽업 건들으로 집계되는 현상 수정 end + + string sRet = UserCom.RST_ERR; + try + { + foreach(Hashtable htData in htOrderStatus) + { + string sOrderType = htData["type"].ToString(); + + switch(htData["status"].ToString()) + { + case ItemConst.HAPPYORDER_STATUS.ORDER_REG: // "4" : 주문접수 + // 일반 주문건수 계산 + if(sOrderType == ItemConst.ORDER_TYPE.SHOP_DIRECT || + sOrderType == ItemConst.ORDER_TYPE.SHOP_TIME) + { + iOrderRegNormalCnt += int.Parse(htData["count"].ToString()); + } + // 배달 주문건수 계산 + else if(sOrderType == ItemConst.ORDER_TYPE.INNER_DELIVERY || + sOrderType == ItemConst.ORDER_TYPE.OUTTER_DELIVERY) + { + iOrderRegDeliveryCnt += int.Parse(htData["count"].ToString()); + } + // 예약 주문건수 계산 + else if(sOrderType == ItemConst.ORDER_TYPE.RESERVED_ORDER || + sOrderType == ItemConst.ORDER_TYPE.PRE_RESERVED) + { + iOrderRegReservedCnt += int.Parse(htData["count"].ToString()); + } + + //#20180605 해피오더 개선 start + //즉시주문, 예약주문 알림 + //즉시픽업 건수 계산 + else if(sOrderType == ItemConst.ORDER_TYPE.DIRECT_ORDER) + { + iOrdCnt_Direct += int.Parse(htData["count"].ToString()); + } + //즉시배달 건수 계산 + else if(sOrderType == ItemConst.ORDER_TYPE.RESERV_ORDER) + { + iOrdCnt_Reserv += int.Parse(htData["count"].ToString()); + } + //#20180605 해피오더 개선 end + + break; + case ItemConst.HAPPYORDER_STATUS.PRODUCT_READY: // "5" : 상품준비 + //#20180905 즉시픽업,즉시배달 제외 start + if ((sOrderType == ItemConst.ORDER_TYPE.DIRECT_ORDER) || (sOrderType == ItemConst.ORDER_TYPE.RESERV_ORDER)) continue; + //#20180905 즉시픽업,즉시배달 제외 end + + + //#20180910 배달의 상품준비가 픽업 건들으로 집계되는 현상 수정 start + //기존 + //iProductReadyCnt += int.Parse(htData["count"].ToString()); + //변경 + if (sOrderType != ItemConst.ORDER_TYPE.OUTTER_DELIVERY && sOrderType != ItemConst.ORDER_TYPE.INNER_DELIVERY) + { + iProductReadyCnt += int.Parse(htData["count"].ToString()); + } + else + { + iDeliveryProductReadyCnt += int.Parse(htData["count"].ToString()); + } + //#20180910 배달의 상품준비가 픽업 건들으로 집계되는 현상 수정 end + + break; + case ItemConst.HAPPYORDER_STATUS.PRE_RESERVED: // "6" : 사전예약 + //#20180905 즉시픽업,즉시배달 제외 start + if ((sOrderType == ItemConst.ORDER_TYPE.DIRECT_ORDER) || (sOrderType == ItemConst.ORDER_TYPE.RESERV_ORDER)) continue; + //#20180905 즉시픽업,즉시배달 제외 end + iPreReservedCnt += int.Parse(htData["count"].ToString()); + break; + case ItemConst.HAPPYORDER_STATUS.PICKUP_WAIT: // "7" : 픽업대기 + //#20180905 즉시픽업,즉시배달 제외 start + if ((sOrderType == ItemConst.ORDER_TYPE.DIRECT_ORDER) || (sOrderType == ItemConst.ORDER_TYPE.RESERV_ORDER)) continue; + //#20180905 즉시픽업,즉시배달 제외 end + iPickupWaitCnt += int.Parse(htData["count"].ToString()); + break; + case ItemConst.HAPPYORDER_STATUS.PICKUP_DELAY: // "2000" : 픽업지연 + //#20180905 즉시픽업,즉시배달 제외 start + if ((sOrderType == ItemConst.ORDER_TYPE.DIRECT_ORDER) || (sOrderType == ItemConst.ORDER_TYPE.RESERV_ORDER)) continue; + //#20180905 즉시픽업,즉시배달 제외 end + iPickupDelayCnt += int.Parse(htData["count"].ToString()); + break; + case ItemConst.HAPPYORDER_STATUS.NO_PICKUP_AND_DELAY: // "2018" : 픽업지연미픽업 + //#20180905 즉시픽업,즉시배달 제외 start + if ((sOrderType == ItemConst.ORDER_TYPE.DIRECT_ORDER) || (sOrderType == ItemConst.ORDER_TYPE.RESERV_ORDER)) continue; + //#20180905 즉시픽업,즉시배달 제외 end + iNoPickupAndDelayCnt += int.Parse(htData["count"].ToString()); + break; + case ItemConst.HAPPYORDER_STATUS.DELIVERY_REQ: // "9004" : 배달요청 + //#20180905 즉시픽업,즉시배달 제외 start + if ((sOrderType == ItemConst.ORDER_TYPE.DIRECT_ORDER) || (sOrderType == ItemConst.ORDER_TYPE.RESERV_ORDER)) continue; + //#20180905 즉시픽업,즉시배달 제외 end + + //#20180910 배달의 상품준비가 픽업 건들으로 집계되는 현상 수정 start + if (sOrderType != ItemConst.ORDER_TYPE.OUTTER_DELIVERY && sOrderType != ItemConst.ORDER_TYPE.INNER_DELIVERY) continue; + //#20180910 배달의 상품준비가 픽업 건들으로 집계되는 현상 수정 end + + iDeliveryRequestCnt += int.Parse(htData["count"].ToString()); + break; + case ItemConst.HAPPYORDER_STATUS.DELIVERY_REG: // "9005" : 배달접수 + //#20180905 즉시픽업,즉시배달 제외 start + if ((sOrderType == ItemConst.ORDER_TYPE.DIRECT_ORDER) || (sOrderType == ItemConst.ORDER_TYPE.RESERV_ORDER)) continue; + //#20180905 즉시픽업,즉시배달 제외 end + + //#20180910 배달의 상품준비가 픽업 건들으로 집계되는 현상 수정 start + if (sOrderType != ItemConst.ORDER_TYPE.OUTTER_DELIVERY && sOrderType != ItemConst.ORDER_TYPE.INNER_DELIVERY) continue; + //#20180910 배달의 상품준비가 픽업 건들으로 집계되는 현상 수정 end + + iDeliveryRegCnt += int.Parse(htData["count"].ToString()); + break; + case ItemConst.HAPPYORDER_STATUS.DELIVERY_ING: // "9007" : 배달중 + //#20180905 즉시픽업,즉시배달 제외 start + if ((sOrderType == ItemConst.ORDER_TYPE.DIRECT_ORDER) || (sOrderType == ItemConst.ORDER_TYPE.RESERV_ORDER)) continue; + //#20180905 즉시픽업,즉시배달 제외 end + + //#20180910 배달의 상품준비가 픽업 건들으로 집계되는 현상 수정 start + if (sOrderType != ItemConst.ORDER_TYPE.OUTTER_DELIVERY && sOrderType != ItemConst.ORDER_TYPE.INNER_DELIVERY) continue; + //#20180910 배달의 상품준비가 픽업 건들으로 집계되는 현상 수정 end + + iDeliveryingCnt += int.Parse(htData["count"].ToString()); + break; + //#20180328 직접배달 처리 후 배달완료시 매출 생성 안되는 증상 수정 start + case ItemConst.HAPPYORDER_STATUS.DELIVERY_DIRECT: // "9003" : 직접배달 + //#20180905 즉시픽업,즉시배달 제외 start + if ((sOrderType == ItemConst.ORDER_TYPE.DIRECT_ORDER) || (sOrderType == ItemConst.ORDER_TYPE.RESERV_ORDER)) continue; + //#20180905 즉시픽업,즉시배달 제외 end + + //#20180910 배달의 상품준비가 픽업 건들으로 집계되는 현상 수정 start + if (sOrderType != ItemConst.ORDER_TYPE.OUTTER_DELIVERY && sOrderType != ItemConst.ORDER_TYPE.INNER_DELIVERY) continue; + //#20180910 배달의 상품준비가 픽업 건들으로 집계되는 현상 수정 end + + iDeliveryDirectCnt += int.Parse(htData["count"].ToString()); + break; + //#20180328 직접배달 처리 후 배달완료시 매출 생성 안되는 증상 수정 end + } + } + + iTotOrderRegCnt = iOrderRegNormalCnt + iOrderRegDeliveryCnt + iOrderRegReservedCnt; + + // 신규 주문 알림 팝업 Show 여부 + // 최초 신규 주문 건수 가져올 시 주문 알림 팝업 Show - 문성진D 요청(BR, PC 합의 사항) + //if((m_cPosStatus.Sale.HappyOrderRegCnt != string.Empty && int.Parse(m_cPosStatus.Sale.HappyOrderRegCnt) != iOrderRegCnt) || + // (m_cPosStatus.Sale.HappyOrderPickupDelayCnt != string.Empty && int.Parse(m_cPosStatus.Sale.HappyOrderPickupDelayCnt) != iPickupDelayCnt)) + // 신규 주문 건수 타입 별 변경 체크 + //if ((int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderTotRegCnt, "0")) != iTotOrderRegCnt) || + // (int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderPickupDelayCnt, "0")) != iPickupDelayCnt)) + // PC, BRK 에 따라 상단 문구와 팝업알림 로직이 달라짐(2017/03/14) + //if ((int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderRegCnt, "0")) != iOrderRegNormalCnt) || + // (int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryRegCnt, "0")) != iOrderRegDeliveryCnt) || + // (int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderReservedRegCnt, "0")) != iOrderRegReservedCnt)) + //{ + // m_cPosStatus.Sale.HappyOrderAlarm = true; + //} + // 연습모드일 경우에는 해피오더 알림팝업이 뜨지 않도록 처리(20170619) + if (m_cPosStatus.Base.TrainingFlag != "1") + { + if (m_cPosStatus.Mst.CorpDiv == ItemConst.CORP_DIV.PC) + { + // 신규주문 건수, 픽업미처리 건수, 배달미처리 건수 변경 시 팝업 알림 + //#20180328 직접배달 처리 후 배달완료시 매출 생성 안되는 증상 수정 start + //기존 + /* + if ((int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderTotRegCnt, "0")) != iOrderRegNormalCnt + iOrderRegReservedCnt + iOrderRegDeliveryCnt) || + (int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderProductReadyCnt, "0")) + int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderPickupWaitCnt, "0")) != iProductReadyCnt + iPickupWaitCnt) || + (int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryRequestCnt, "0")) + int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryRegCnt, "0")) + int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryingCnt, "0")) != iDeliveryRequestCnt + iDeliveryRegCnt + iDeliveryingCnt)) + { + m_cPosStatus.Sale.HappyOrderAlarm = true; + } + */ + //변경 + if ((int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderTotRegCnt, "0")) != iOrderRegNormalCnt + iOrderRegReservedCnt + iOrderRegDeliveryCnt) || + (int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderProductReadyCnt, "0")) + int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderPickupWaitCnt, "0")) != iProductReadyCnt + iPickupWaitCnt) || + //#20180910 배달의 상품준비가 픽업 건들으로 집계되는 현상 수정 start + //기존 + /* + (int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryRequestCnt, "0")) + + int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryRegCnt, "0")) + + int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryingCnt, "0")) + + int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryDirectCnt, "0")) != iDeliveryRequestCnt + iDeliveryRegCnt + iDeliveryingCnt + iDeliveryDirectCnt)) + */ + //변경 + (int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryRequestCnt, "0")) + + int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryRegCnt, "0")) + + //int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryingCnt, "0")) + + int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryDirectCnt, "0")) + + int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryProductReadyCnt, "0")) != + iDeliveryRequestCnt + + iDeliveryRegCnt + + //iDeliveryingCnt + + iDeliveryDirectCnt + + iDeliveryProductReadyCnt)) + //#20180910 배달의 상품준비가 픽업 건들으로 집계되는 현상 수정 end + + { + m_cPosStatus.Sale.HappyOrderAlarm = true; + } + //#20180328 직접배달 처리 후 배달완료시 매출 생성 안되는 증상 수정 end + + } + else + { + // 일반 건수, 배달 건수, 예약 건수 변경 시 팝업 알림 + if (int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderRegCnt, "0")) != iOrderRegNormalCnt || + int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderDeliveryOrderRegCnt, "0")) != iOrderRegDeliveryCnt || + int.Parse(CmUtil.IsNull(m_cPosStatus.Sale.HappyOrderReservedRegCnt, "0")) != iOrderRegReservedCnt) + { + m_cPosStatus.Sale.HappyOrderAlarm = true; + } + } + } + + // 해피오더 일반 주문접수 건수 갱신 + m_cPosStatus.Sale.HappyOrderRegCnt = Convert.ToString(iOrderRegNormalCnt); + // 해피오더 예약 주문접수 건수 갱신 + m_cPosStatus.Sale.HappyOrderReservedRegCnt = Convert.ToString(iOrderRegReservedCnt); + // 해피오더 배달 주문접수 건수 갱신 + m_cPosStatus.Sale.HappyOrderDeliveryOrderRegCnt = Convert.ToString(iOrderRegDeliveryCnt); + // 해피오더 총 주문접수 건수 갱신 + m_cPosStatus.Sale.HappyOrderTotRegCnt = Convert.ToString(iTotOrderRegCnt); + + // 해피오더 상품준비 건수 갱신 + m_cPosStatus.Sale.HappyOrderProductReadyCnt = Convert.ToString(iProductReadyCnt); + + //#20180910 배달의 상품준비가 픽업 건들으로 집계되는 현상 수정 start + m_cPosStatus.Sale.HappyOrderDeliveryProductReadyCnt = Convert.ToString(iDeliveryProductReadyCnt); + //#20180910 배달의 상품준비가 픽업 건들으로 집계되는 현상 수정 end + + // 해피오더 픽업대기 건수 갱신 + m_cPosStatus.Sale.HappyOrderPickupWaitCnt = Convert.ToString(iPickupWaitCnt); + // 해피오더 픽업지연 건수 갱신 + m_cPosStatus.Sale.HappyOrderPickupDelayCnt = Convert.ToString(iPickupDelayCnt); + // 해피오더 픽업지연미픽업 건수 갱신 + m_cPosStatus.Sale.HappyOrderNoPickupAndDelayCnt = Convert.ToString(iNoPickupAndDelayCnt); + // 해피오더 배달요청 건수 갱신 + m_cPosStatus.Sale.HappyOrderDeliveryRequestCnt = Convert.ToString(iDeliveryRequestCnt); + // 해피오더 배달접수 건수 갱신 + m_cPosStatus.Sale.HappyOrderDeliveryRegCnt = Convert.ToString(iDeliveryRegCnt); + + //#20180328 직접배달 처리 후 배달완료시 매출 생성 안되는 증상 수정 start + // 해피오더 직접배달 건수 갱신 + m_cPosStatus.Sale.HappyOrderDeliveryDirectCnt = Convert.ToString(iDeliveryDirectCnt); + //#20180328 직접배달 처리 후 배달완료시 매출 생성 안되는 증상 수정 end + + // 해피오더 배달중 건수 갱신 + m_cPosStatus.Sale.HappyOrderDeliveryingCnt = Convert.ToString(iDeliveryingCnt); + + //grayber@20180306 해피오더 주문가능 상태 추가 start - 해피오더 배달 가능 상태 전역변수에 값 설정 + m_cPosStatus.Sale.DeliverySupport = string.Empty; // 기본값 string.Empty + if (CmUtil.IsNull(htRspData) != true ) + { + if (CmUtil.IsNull(htRspData["deliverySupport"]) != true) + {// 전역변수에 값 추가 + m_cPosStatus.Sale.DeliverySupport = htRspData["deliverySupport"].ToString(); // Y:N + } + } + //System.Diagnostics.Debug.WriteLine(DateTime.Now.ToShortTimeString() + " ▶▶▶ m_cPosStatus.Sale.DeliverySupport:" + m_cPosStatus.Sale.DeliverySupport); // Debug output console + //grayber@20180306 해피오더 주문가능 상태 추가 end + + //#20180605 해피오더 개선 start + + //즉시주문, 예약주문 알림 + // 즉시픽업 건수 + m_cPosStatus.Sale.HappyOrderDirectCnt = Convert.ToString(iOrdCnt_Direct); + // 즉시배달 건수 + m_cPosStatus.Sale.HappyOrderReservCnt = Convert.ToString(iOrdCnt_Reserv); + + ////#15058 해피오더 버튼 변경 start,phj + //m_cPosStatus.Sale.SaleMainRepeat = true; + //m_cPosStatus.Sale.PosMainRepeat = true; + //m_cPosStatus.Sale.TableMainRepeat = true; + ////#15058 해피오더 버튼 변경 end,phj + + //#20180605 해피오더 개선 end + + + } + 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; + } + /// + /// 빚은몰 주문 건수 조회 + /// + /// + /// + public string SelectBizeunOrderCount(string sRespData) + { + string sRet = UserCom.RST_ERR; + try + { + if(CmUtil.IsNumber(sRespData.Trim()) == true) + { + m_cPosStatus.Sale.BizeunOrderCnt = sRespData.Trim(); + } + else + { + m_cPosStatus.Sale.BizeunOrderCnt = "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; + } + /// + /// 이지웰 주문건수 조회 + /// + /// + /// + public string SelectEzwelOrderCount(string sRespData) + { + string sRet = UserCom.RST_ERR; + try + { + if (CmUtil.IsNumber(sRespData.Trim()) == true) + { + m_cPosStatus.Sale.EzwelOrderCnt = sRespData.Trim(); + } + else + { + m_cPosStatus.Sale.EzwelOrderCnt = "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; + } + + /// + /// 온도정보 Http 통신 + /// + /// + /// + public string SelectStoreTempInfo (string sRespData) + { + string sRet = UserCom.RST_ERR; + string sTempInfo = string.Empty; + string[] sTempSep = null; + int iTotCnt = 0; + + int iStartCnt = 0; + int iEndCnt = 0; + + try + { + string sResp = string.Empty; + if (sRespData.Trim().Length > 0) + { + iTotCnt = Convert.ToInt16(sRespData.Substring(0, 2)); + + sRespData = sRespData.Remove(0, 2); + + if (iTotCnt > 2) + { + // 첫번째 온도 정보 + iStartCnt = sRespData.IndexOf("["); + iEndCnt = sRespData.IndexOf("]"); + + if (iEndCnt != 0) + { + sTempInfo = sRespData.Substring(iStartCnt, iEndCnt + 1).Replace("[", "").Replace("]", ""); + + sTempSep = sTempInfo.Split('|'); + + // 코드1 + m_cPosStatus.Temp.Code1 = sTempSep[0]; + // 이름1 + m_cPosStatus.Temp.Name1 = sTempSep[1]; + // 온도1 + m_cPosStatus.Temp.Temperature1 = sTempSep[2]; + // 알람1 + m_cPosStatus.Temp.Alarm1 = sTempSep[3]; + // 경고1 + m_cPosStatus.Temp.Warning1 = sTempSep[4]; + // 미수신1 + m_cPosStatus.Temp.receiveYN1 = sTempSep[5]; + // 최종온도수집1 + m_cPosStatus.Temp.CollectionTime1 = sTempSep[6]; + + sRespData = sRespData.Remove(iStartCnt, iEndCnt + 1); + } + + // 두번째 온도 정보 + iStartCnt = sRespData.IndexOf("["); + iEndCnt = sRespData.IndexOf("]"); + + if (iEndCnt != 0) + { + sTempInfo = sRespData.Substring(iStartCnt, iEndCnt + 1).Replace("[", "").Replace("]", ""); + + sTempSep = sTempInfo.Split('|'); + + // 코드2 + m_cPosStatus.Temp.Code2 = sTempSep[0]; + // 이름2 + m_cPosStatus.Temp.Name2 = sTempSep[1]; + // 온도2 + m_cPosStatus.Temp.Temperature2 = sTempSep[2]; + // 알람2 + m_cPosStatus.Temp.Alarm2 = sTempSep[3]; + // 경고2 + m_cPosStatus.Temp.Warning2 = sTempSep[4]; + // 미수신2 + m_cPosStatus.Temp.receiveYN2 = sTempSep[5]; + // 최종온도수집2 + m_cPosStatus.Temp.CollectionTime2 = sTempSep[6]; + + sRespData = sRespData.Remove(iStartCnt, iEndCnt + 1); + } + + iStartCnt = sRespData.IndexOf("["); + iEndCnt = sRespData.IndexOf("]"); + + if (iEndCnt != 0) + { + sTempInfo = sRespData.Substring(iStartCnt, iEndCnt + 1).Replace("[", "").Replace("]", ""); + + sTempSep = sTempInfo.Split('|'); + + // 세번째 온도 정보 + // 코드3 + m_cPosStatus.Temp.Code3 = sTempSep[0]; + // 이름3 + m_cPosStatus.Temp.Name3 = sTempSep[1]; + // 온도3 + m_cPosStatus.Temp.Temperature3 = sTempSep[2]; + // 알람3 + m_cPosStatus.Temp.Alarm3 = sTempSep[3]; + // 경고3 + m_cPosStatus.Temp.Warning3 = sTempSep[4]; + // 미수신3 + m_cPosStatus.Temp.receiveYN3 = sTempSep[5]; + // 최종온도수집3 + m_cPosStatus.Temp.CollectionTime3 = sTempSep[6]; + + sRespData = sRespData.Remove(iStartCnt, iEndCnt + 1); + } + } + } + + 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; + } + } +} diff --git a/Agent/NetworkCheckOver/NetworkCheckOver.cs b/Agent/NetworkCheckOver/NetworkCheckOver.cs new file mode 100644 index 0000000..60b79c5 --- /dev/null +++ b/Agent/NetworkCheckOver/NetworkCheckOver.cs @@ -0,0 +1,2833 @@ +using System; +using System.Collections.Generic; +using System.Collections; +using System.Linq; +using System.Text; +using System.Threading; +using System.Net; +using System.IO; +using System.Data; + +using Newtonsoft.Json; + +using Cosmos.Common; +using Cosmos.CommonManager; +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using ICSharpCode.SharpZipLib.Zip; + + +namespace Cosmos.Network +{ + public class NetworkCheckOver : IWatcher + { + private SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출 + + /// + /// StateServer Object (StateServer 객체) + /// + private StateServer StateObject = (StateServer)StateServer.GetInstance(); + + /// + /// POS Status Value (POS 상태값) + /// + private PosStatus m_cPosStatus = null; + + /// + /// Sending Socket (전송 소켓) + /// + private static TcpSocket m_sendSocket = null; + + /// + /// MSSQL DB 관련 객체 + /// + private static SqlDB sqlDb = null; + + private ICheckOverUs m_cCheckOverDetail = null; + + /// + /// 웹정보 서비스 + /// + private IDataServiceUs m_cWebBiz = null; + + /// + /// Server SEND Thread (Server SEND 스레드) + /// + private Thread m_tCheckOver = null; + + /// + /// Thread Waiting Time (스레드 대기시간 ms) + /// + private int m_ThreadSleepTerm = 60000; + + /// + /// Network CheckOver Operation Yes/No (작동여부) + /// + private bool m_NetworkCheckOverRunning = true; + + /// + /// 해피오더 조회/상태변경/취소 URL + /// + private string m_sHappyOrderURL; + /// + /// 빚은몰 주문 건수 조회 URL + /// + private string m_sBizeunSelectURL; + /// + /// 이지웰 주문 건수 조회 URL + /// + private string m_sEzwelSelectURL; + /// + /// 온도정보 URL + /// + private string m_sTempURL; + + //17.08.22 dkshin SS 해피오더 + Hashtable[] m_htOrderLists; + IHappyOrderList m_cHappyOrder = null;// 해피오더 서비스 처리 + private TranStatus m_cTrnStatus;//거래정보 참조 + + //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 start + private IDataCommonUs m_cDataCommon = null; + //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 end + + //#15884 해피오더 실시간 추가재고 등록메뉴 및 알람기능 개발 start + private int iInventoryDispCnt = -1; + //#15884 해피오더 실시간 추가재고 등록메뉴 및 알람기능 개발 end + + public NetworkCheckOver() + { + m_cPosStatus = (PosStatus)StateObject.POS; + + m_cWebBiz = (IDataServiceUs)sManager.InitServiceInstance(ServiceLists.BSV_BASIC.DLL, ServiceLists.BSV_BASIC.WEB_POS); + + m_cCheckOverDetail = new CheckOverDetail(); + + // 승인업체 코드 조회 + string sVanCD = PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.ORDER_ITEM, ItemConst.TR_ITEM_ID.ORDER.HAPPYORDER_PAY, PosMst.MST_PAY_DC.DATA.APPR_VEND_CD); + // 승인 URL 조회 + m_sHappyOrderURL = PosMstManager.GetMstVan(sVanCD, PosMst.MST_VAN.DATA.IP); + + sVanCD = PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.ETC_INFO_ITEM, ItemConst.TR_ITEM_ID.ETC_INFO.BIZEUN, PosMst.MST_PAY_DC.DATA.APPR_VEND_CD); + m_sBizeunSelectURL = PosMstManager.GetMstVan(sVanCD, PosMst.MST_VAN.DATA.IP); + + sVanCD = PosMstManager.GetMstPayDc(ItemConst.TR_ITEM_ID.ETC_INFO_ITEM, ItemConst.TR_ITEM_ID.ETC_INFO.EZWEL, PosMst.MST_PAY_DC.DATA.APPR_VEND_CD); + m_sEzwelSelectURL = PosMstManager.GetMstVan(sVanCD, PosMst.MST_VAN.DATA.IP); + + m_sTempURL = (string)m_cWebBiz.GetData(new string[] { PosKey.MENU_KEY.WEB_TMPRT }); + + //17.08.22 dkshin SS 해피오더 + m_cHappyOrder = (IHappyOrderList)sManager.InitServiceInstance(ServiceLists.BSV_SALE.DLL, ServiceLists.BSV_SALE.HAPPY_ORDER_LIST); + m_cTrnStatus = (TranStatus)StateObject.TRAN; //거래정보 + + //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 start + m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON); + //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 end + } + + #region CheckOver Thread START / STOP + public void Start() + { + try + { + sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, + m_cPosStatus.Base.LocalDbCatalog, + m_cPosStatus.Base.LocalDbUserID, + m_cPosStatus.Base.LocalDbPassword); + + m_tCheckOver = new Thread(new ThreadStart(ThreadCheckOverRun)); + m_NetworkCheckOverRunning = true; + m_tCheckOver.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 + { + // 통신서버 Send Terminated (SC Send 종료) + m_NetworkCheckOverRunning = false; + + int count = 0; + while (count < 10) + { + if (m_tCheckOver != null && m_tCheckOver.IsAlive) m_NetworkCheckOverRunning = false; + else break; + + count++; + Thread.Sleep(100); + } + + 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 NetworkTranSend Service Stop!!!"); + m_tCheckOver.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 CheckOver Thread START / STOP + + #region CheckOver Main + private void ThreadCheckOverRun() + { + string sReqData = string.Empty; + string sRespData = string.Empty; + string sReturn = string.Empty; + int iRet = 0; + int iSubCount_1 = 0; + int iSubCount_2 = 0; + Hashtable htSendData = null; + Hashtable htRecvData = null; + try + { + while (m_NetworkCheckOverRunning) + { + try + { + // 해피오더 제일 먼저 조회 - 문성진D 요청 + #region 5 - 해피오더 주문 건수 조회 + // 4 - 해피오더 + + if (PosMstManager.GetPosOption(POS_OPTION.OPT035) == "1") + { + //#20180228 해피오더 주문 건수 조회 기능 에러시 다른 기능 동작 되도록 수정 start + //기존 + /* + sReqData = string.Format("storeCode={0}&deviceType=POS", m_cPosStatus.Base.StoreNo); + //sReqData = string.Format("storeCode={0}&deviceType=POS", "11101"); + iRet = this.HttpJsonGET_SendReceive(m_sHappyOrderURL, ItemConst.HAPPYORDER_WORK_TYPE.SELECT_STATUS_COUNT, sReqData, ref sRespData); + if (iRet == BaseCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_DEBUG, + UserCom.WARNING_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 (함수명)) + sRespData); + + sReturn = m_cCheckOverDetail.SelectHappyOrderCountByOrderStatus(JsonConvert.DeserializeObject(sRespData)); + } + */ + //변경 + HappyOrderCntChk(); + //#20180228 해피오더 주문 건수 조회 기능 에러시 다른 기능 동작 되도록 수정 end + } + + + #endregion + + #region 1 - 공지사항 요청(점주/알바모드, 위해상품 메시지, 입고등록 확인, 배송정보, 기념일 배송) - 30분 단위 + // 1 - 공지사항 요청(점주/알바모드, 위해상품 메시지, 입고등록 확인, 배송정보, 기념일 배송) + if (iSubCount_1 == 10) + { + // 전문 생성 + htSendData = this.MakeMessageSendingReqData(ItemConst.IRT_INQ_TYPE.NOTICE_INQ_REQ, null); + + // 전문 요청 + iRet = IRTSendReceive(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.BizInqPort), + (int)5000, htSendData, ref htRecvData); + + if (iRet == BaseCom.OK) + { + if (htRecvData[Column.IQ_NOTICE_INQ_RSP.DATA.RES_CD].ToString() == "00") + { + DataTable dtNotice = ParseMsgValueField(htRecvData[Column.IQ_NOTICE_INQ_RSP.DATA.MSG_VALUE].ToString()); + + // 서브 업무 처리 + DoSubProc(dtNotice); + } + } + } + #endregion 1 - 공지사항 요청(점주/알바모드, 위해상품 메시지, 입고등록 확인, 배송정보, 기념일 배송) + + #region 2 - 일반 공지사항 요청 + // 2 - 일반 공지사항 요청 + if(iSubCount_2 == 30) + { + htSendData = this.MakeMessageSendingReqData(ItemConst.IRT_INQ_TYPE.MSG_TRANSFER_REQ, new string[] { "0" + , m_cPosStatus.Base.RegularNoticeUpdateDT + , m_cPosStatus.Base.EmergencyNoticeUpdateDT + , m_cPosStatus.Base.SaleNoticeUpdateDT1 + , m_cPosStatus.Base.SaleNoticeUpdateDT2 }); + + // 전문 요청 + iRet = IRTSendReceive(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.SysInfoPort), + (int)5000, htSendData, ref htRecvData); + + if (iRet == BaseCom.OK) + { + if (htRecvData[Column.IQ_MSG_SND_RSP.DATA.RES_CD].ToString() == "00") + { + if (InsertIntoEMG_NOTE(htRecvData) != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_DEBUG, + UserCom.WARNING_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 (함수명)) + "Failed to insert into MST_EMG_NOTE ( " + + "[MSG_CD]=" + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_CD].ToString() + + "[MSG_DIV]=" + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_DIV].ToString() + + "[MSG_TITLE]=" + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_TITLE].ToString() + " )"); + } + else + { + // 업데이트 시간 갱신 + UpdateNoticesDateTime(htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_DIV].ToString(), htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_TYPE].ToString(), htRecvData[Column.IQ_MSG_SND_RSP.DATA.UPD_DATE].ToString()); + + // MSG_DIV = '00'(긴급) 이고 MSG_TYPE = '1'(마스터) 이면 + // 긴급 적용 마스터 리스트 Update + if (htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_DIV].ToString() == "00" && + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_TYPE].ToString() == "1") + { + + htSendData.Clear(); + htSendData = MakePOSMASTERLISTReqData(); + + // 전문 요청 + iRet = IRTSendReceive(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.BizInqPort), + (int)5000, htSendData, + ref htRecvData); + + if (iRet == BaseCom.OK) + { + if (htRecvData[Column.IQ_POSMASTERLIST_REQ.DATA.DOWN_DIV].ToString() == "2") + { + string[] arMasterList = (htRecvData[Column.IQ_POSMASTERLIST_REQ.DATA.MASTER_LIST].ToString()).Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + + if (UpdateMasterTableList(arMasterList) != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_DEBUG, + UserCom.WARNING_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 (함수명)) + "Failed to update emergency master list [" + htRecvData[Column.IQ_POSMASTERLIST_REQ.DATA.MASTER_LIST].ToString() + "]"); + } + } + } + } + } + } + } + } + #endregion 2 - 긴급 공지 요청(긴급공지, 주문긴급공지, 관공서 방문 점검 공지, 오늘의 할 일) + + #region 3 - 긴급 공지사항 요청 + // 3 - 긴급 공지사항 요청 + { + htSendData = this.MakeMessageSendingReqData(ItemConst.IRT_INQ_TYPE.MSG_TRANSFER_REQ, new string[] { "2" + , m_cPosStatus.Base.RegularNoticeUpdateDT + , m_cPosStatus.Base.EmergencyNoticeUpdateDT + , m_cPosStatus.Base.SaleNoticeUpdateDT1 + , m_cPosStatus.Base.SaleNoticeUpdateDT2 }); + + // 전문 요청 + iRet = IRTSendReceive(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.SysInfoPort), + (int)5000, htSendData, ref htRecvData); + + if (iRet == BaseCom.OK) + { + if (htRecvData[Column.IQ_MSG_SND_RSP.DATA.RES_CD].ToString() == "00") + { + if (InsertIntoEMG_NOTE(htRecvData) != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_DEBUG, + UserCom.WARNING_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 (함수명)) + "Failed to insert into MST_EMG_NOTE ( " + + "[MSG_CD]=" + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_CD].ToString() + + "[MSG_DIV]=" + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_DIV].ToString() + + "[MSG_TITLE]=" + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_TITLE].ToString() + " )"); + } + else + { + // 업데이트 시간 갱신 + UpdateNoticesDateTime(htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_DIV].ToString(), htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_TYPE].ToString(), htRecvData[Column.IQ_MSG_SND_RSP.DATA.UPD_DATE].ToString()); + + // MSG_DIV = '00'(긴급) 이고 MSG_TYPE = '1'(마스터) 이면 + // 긴급 적용 마스터 리스트 Update + if (htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_DIV].ToString() == "00" && + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_TYPE].ToString() == "1") + { + + htSendData.Clear(); + htSendData = MakePOSMASTERLISTReqData(); + + // 전문 요청 + iRet = IRTSendReceive(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.BizInqPort), + (int)5000, htSendData, + ref htRecvData); + + if (iRet == BaseCom.OK) + { + if (htRecvData[Column.IQ_POSMASTERLIST_REQ.DATA.DOWN_DIV].ToString() == "2") + { + string[] arMasterList = (htRecvData[Column.IQ_POSMASTERLIST_REQ.DATA.MASTER_LIST].ToString()).Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); + + if (UpdateMasterTableList(arMasterList) != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_DEBUG, + UserCom.WARNING_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 (함수명)) + "Failed to update emergency master list [" + htRecvData[Column.IQ_POSMASTERLIST_REQ.DATA.MASTER_LIST].ToString() + "]"); + } + } + } + } + } + } + } + } + #endregion 3 - 긴급 공지사항 요청 + + #region 4 - 영업 공지 요청(오늘의 할 일, 식품 안전 메시지) - 10분 단위 + // 3 - 영업 공지 요청(오늘의 할 일, 식품 안전 메시지) 1 + if (iSubCount_1 == 10) + { + htSendData = this.MakeMessageSendingReqData(ItemConst.IRT_INQ_TYPE.MSG_TRANSFER_REQ, new string[] { "1" + , m_cPosStatus.Base.RegularNoticeUpdateDT + , m_cPosStatus.Base.EmergencyNoticeUpdateDT + , m_cPosStatus.Base.SaleNoticeUpdateDT1 + , m_cPosStatus.Base.SaleNoticeUpdateDT2 }); + + // 전문 요청 + iRet = IRTSendReceive(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.SysInfoPort), + (int)5000, htSendData, ref htRecvData); + + if (iRet == BaseCom.OK) + { + if (htRecvData[Column.IQ_MSG_SND_RSP.DATA.RES_CD].ToString() == "00") + { + if (InsertIntoEMG_NOTE(htRecvData) != UserCom.OK) + { + UserLog.WriteLogFile(UserCom.LOG_DEBUG, + UserCom.WARNING_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 (함수명)) + "Failed to insert into MST_EMG_NOTE ( " + + "[MSG_CD]=" + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_CD].ToString() + + "[MSG_DIV]=" + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_DIV].ToString() + + "[MSG_TITLE]=" + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_TITLE].ToString() + " )"); + } + else + { + // 업데이트 시간 갱신 + UpdateNoticesDateTime(htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_DIV].ToString(), htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_TYPE].ToString(), htRecvData[Column.IQ_MSG_SND_RSP.DATA.UPD_DATE].ToString()); + } + } + } + } + #endregion 4 - 영업 공지 요청(오늘의 할 일, 식품 안전 메시지) + + + #region 6 - 빚은몰 주문 건수 조회 + // 5 - 빚은몰 + if (PosMstManager.GetPosOption(POS_OPTION.OPT036) == "1") + { + sReqData = string.Format("AMACODE={0}", m_cPosStatus.Base.StoreNo); + iRet = this.HttpGET_SendReceive(m_sBizeunSelectURL, string.Empty, sReqData, PosConst.ENCODING_FLAG.KSC, ref sRespData); + if (iRet == BaseCom.OK) + { + sReturn = m_cCheckOverDetail.SelectBizeunOrderCount(sRespData); + } + } + #endregion + + #region 7 - 이지웰 주문 건수 조회 + // 6 - 이지웰 + if (PosMstManager.GetPosOption(POS_OPTION.OPT037) == "1") + { + sReqData = string.Format("AMACODE={0}", m_cPosStatus.Base.StoreNo); + iRet = this.HttpGET_SendReceive(m_sEzwelSelectURL, string.Empty, sReqData, PosConst.ENCODING_FLAG.KSC, ref sRespData); + if (iRet == BaseCom.OK) + { + sReturn = m_cCheckOverDetail.SelectEzwelOrderCount(sRespData); + } + } + #endregion + + if (m_cPosStatus.Base.PosCommunicationType == PosConst.MAIN_POS_DIV.MAIN_POS) //메인포스만 전송 처리! + { + #region 7 - 점포 방문 이력 전송(제조기사 타임 바코드) + { + + ///////////////////////////////////////////////////////////////// + /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! + ///////////////////////////////////////////////////////////////// + htSendData = new Hashtable(); + + //전송 내역 확인 + DataTable dt = SelectSendDataList(ItemConst.IRT_INQ_TYPE.STOR_VISIT); + + if (!(dt == null || dt.Rows.Count == 0)) + { + DataRow dr = dt.Rows[0]; + + for (int iRow = 0; iRow < dr.Table.Columns.Count; iRow++) + { + htSendData.Add(dr.Table.Columns[iRow].ColumnName, dr[iRow].ToString()); + } + + // 전문 요청 + iRet = IRTSendReceive(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.BizInqPort), + (int)5000, htSendData, ref htRecvData); + string sFlag = "9"; + + if (iRet == BaseCom.OK) + { + if (htRecvData["RES_CD"].ToString() == "00") + { + sFlag = "1"; + } + } + UpdateTableSend(ItemConst.IRT_INQ_TYPE.STOR_VISIT, sFlag, htSendData); + } + + + + } + #endregion 7 - 점포 방문 이력 전송(제조기사 타임 바코드) + + #region 8 - 근태 등록 요청/응답 + { + + ///////////////////////////////////////////////////////////////// + /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! + ///////////////////////////////////////////////////////////////// + + htSendData = new Hashtable(); + + //전송 내역 확인 + DataTable dt = SelectSendDataList(ItemConst.IRT_INQ_TYPE.EMP_COMMUTE); + + if (!(dt == null || dt.Rows.Count == 0)) + { + + DataRow dr = dt.Rows[0]; + + // 전문 생성 + for (int iRow = 0; iRow < dr.Table.Columns.Count; iRow++) + { + htSendData.Add(dr.Table.Columns[iRow].ColumnName, dr[iRow].ToString()); + } + + // 전문 요청 + iRet = IRTSendReceive(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.BizInqPort), + (int)5000, htSendData, ref htRecvData); + string sFlag = "9"; + + if (iRet == BaseCom.OK) + { + if (htRecvData["RES_CD"].ToString() == "00") + { + sFlag = "1"; + } + } + UpdateTableSend(ItemConst.IRT_INQ_TYPE.EMP_COMMUTE, sFlag, htSendData); + } + } + #endregion 8 - 근태 등록 요청/응답 + + #region 9 - 점주/알바 모드 전송 + { + ///////////////////////////////////////////////////////////////// + /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! + ///////////////////////////////////////////////////////////////// + + htSendData = new Hashtable(); + + //전송 내역 확인 + DataTable dt = SelectSendDataList(ItemConst.IRT_INQ_TYPE.ONWER_MODE); + + if (!(dt == null || dt.Rows.Count == 0)) + { + + DataRow dr = dt.Rows[0]; + + // 전문 생성 + for (int iRow = 0; iRow < dr.Table.Columns.Count; iRow++) + { + htSendData.Add(dr.Table.Columns[iRow].ColumnName, dr[iRow].ToString()); + } + + // 전문 요청 + iRet = IRTSendReceive(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.BizInqPort), + (int)5000, htSendData, ref htRecvData); + string sFlag = "9"; + + if (iRet == BaseCom.OK) + { + if (htRecvData["RES_CD"].ToString() == "00") + { + sFlag = "1"; + } + } + UpdateTableSend(ItemConst.IRT_INQ_TYPE.ONWER_MODE, sFlag, htSendData); + } + } + #endregion 9 - 점주/알바 모드 전송 + } + + #region 10 - 유해 상품 읽음 전송 + { + + ///////////////////////////////////////////////////////////////// + /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! + ///////////////////////////////////////////////////////////////// + htSendData = new Hashtable(); + + //전송 내역 확인 + + DataTable dt = SelectSendDataList(ItemConst.IRT_INQ_TYPE.HARMFUL_ITEM_MSG_REQ); + + if (!(dt == null || dt.Rows.Count == 0)) + { + DataRow dr = dt.Rows[0]; + + for (int iRow = 0; iRow < dr.Table.Columns.Count; iRow++) + { + htSendData.Add(dr.Table.Columns[iRow].ColumnName, dr[iRow].ToString()); + } + + // 전문 요청 + iRet = IRTSendReceive(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.SysInfoPort), + (int)5000, htSendData, ref htRecvData); + string sFlag = "9"; + + if (iRet == BaseCom.OK) + { + if (htRecvData["RES_CD"].ToString() == "00") + { + sFlag = "2"; + } + } + UpdateTableSend(ItemConst.IRT_INQ_TYPE.HARMFUL_ITEM_MSG_REQ, sFlag, htSendData); + } + + } + #endregion 10 - 유해 상품 읽음 전송 + + #region 11 - 온도정보 조회 + // 11 - 온도정보 + if (CmUtil.IsNull(PosMstManager.GetPosOption(POS_OPTION.OPT039), "0") == "1") + { + string TempURL = string.Empty; + + if (m_sTempURL.Length > 100) + { + TempURL = CmUtil.MidH(m_sTempURL, 31, 100).Trim(); + + sRespData = string.Empty; + + if (m_cPosStatus.Mst.CntryDiv == ItemConst.CNTRY_DIV.CN) + { + if (m_cPosStatus.Base.StoreNo.Length >= 7) + sReqData = string.Format("COMP_CD=CP&BRAND_CD={0}&STORE_CD={1}", m_cPosStatus.Base.BrandCd, m_cPosStatus.Base.StoreNo.Substring(2, 5)); + else + sReqData = string.Format("COMP_CD=CP&BRAND_CD={0}&STORE_CD={1}", m_cPosStatus.Base.BrandCd, m_cPosStatus.Base.StoreNo); + // 중국 http://si1.paris.co.kr/posLink?COMP_CD=CP&BRAND_CD=5000&STORE_CD=00001 + } + else + { + if (m_cPosStatus.Base.StoreNo.Length >= 7) + sReqData = string.Format("COMP_CD={0}&BRAND_CD={1}&STORE_CD={2}", m_cPosStatus.Base.CmpCd.Substring(0, 2), m_cPosStatus.Base.BrandCd, m_cPosStatus.Base.StoreNo.Substring(2, 5)); + else + sReqData = string.Format("COMP_CD={0}&BRAND_CD={1}&STORE_CD={2}", m_cPosStatus.Base.CmpCd.Substring(0, 2), m_cPosStatus.Base.BrandCd, m_cPosStatus.Base.StoreNo); + //iRet = this.HttpGET_SendReceive("http://si1.paris.co.kr", "/posLink", "COMP_CD=PC&BRAND_CD=002&STORE_CD=17496", PosConst.ENCODING_FLAG.UTF, ref sRespData); + //iRet = this.HttpGET_SendReceive("http://si1.paris.co.kr", "/posLink", sReqData, PosConst.ENCODING_FLAG.UTF, ref sRespData); + //iRet = this.HttpGET_SendReceive("http://si1.paris.co.kr", "/posLink", "COMP_CD=PC&BRAND_CD=002&STORE_CD=17859", PosConst.ENCODING_FLAG.UTF, ref sRespData); + } + iRet = this.HttpGET_SendReceive(TempURL, string.Empty, sReqData, PosConst.ENCODING_FLAG.UTF, ref sRespData); + if (iRet == BaseCom.OK) + { + sReturn = m_cCheckOverDetail.SelectStoreTempInfo(sRespData); + } + } + } + #endregion + + #region 12 - BR팝업 업무 처리 + if (m_cPosStatus.Mst.CorpDiv == ItemConst.CORP_DIV.BR) + BrPopUpBiz(); + #endregion + + #region 13 - LOG 전송 처리 + { + // 전문 생성 + htSendData = this.MakeMessageSendingReqData(ItemConst.IRT_INQ_TYPE.POS_LOGFILE_REQ, new string[] { PosConst.POS_LOGFILE_REQ_TYPE.LOGFILE_REQ, "" }); + + // 전문 요청 + iRet = IRTSendReceive(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.PayInqPort), + (int)5000, htSendData, ref htRecvData); + if(iRet == BaseCom.OK) + { + // 전송할 LOG 데이터 있음 + if(htRecvData[Column.IQ_POS_LOGFILE_REQ.DATA.RES_CD].ToString() == "00") + { + string sFileNm = ""; + + iRet = UploadLogFileProc(htRecvData, ref sFileNm); + + if(iRet == BaseCom.OK) + { + // Upload 성공 + htSendData = this.MakeMessageSendingReqData(ItemConst.IRT_INQ_TYPE.POS_LOGFILE_REQ, new string[] { PosConst.POS_LOGFILE_REQ_TYPE.LOGFILE_UPLOAD, htRecvData[Column.IQ_POS_LOGFILE_REQ.DATA.LOG_DT].ToString() }); + } + else if(iRet == BaseCom.NG1) + { + // Upload 파일 존재하지 않음 + htSendData = this.MakeMessageSendingReqData(ItemConst.IRT_INQ_TYPE.POS_LOGFILE_REQ, new string[] { PosConst.POS_LOGFILE_REQ_TYPE.NO_LOGFILE, htRecvData[Column.IQ_POS_LOGFILE_REQ.DATA.LOG_DT].ToString() }); + } + else + { + // Upload 실패 + htSendData = this.MakeMessageSendingReqData(ItemConst.IRT_INQ_TYPE.POS_LOGFILE_REQ, new string[] { PosConst.POS_LOGFILE_REQ_TYPE.LOGFILE_UPLOAD_FAIL, htRecvData[Column.IQ_POS_LOGFILE_REQ.DATA.LOG_DT].ToString() }); + } + + // 전문 요청 + iRet = IRTSendReceive(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.PayInqPort), + (int)5000, htSendData, ref htRecvData); + } + } + } + #endregion 13 - LOG 전송 처리 + + //17.08.22 dkshin SS 해피오더 + #region 14 - SS 해피오더 자동 처리 + //#20171124 해당 옵션 웹에서 등록 안한 경우 동작 안하도록 수정 start + //기존 + //if (PosMstManager.GetPosOption(POS_OPTION.OPT048) != "0") + //변경 + if (PosMstManager.GetPosOption(POS_OPTION.OPT048) != "0" && + PosMstManager.GetPosOption(POS_OPTION.OPT048) != "") + //#20171124 해당 옵션 웹에서 등록 안한 경우 동작 안하도록 수정 end + { + SSHappyOrderAutoProcess(); + } + #endregion + + //#15884 해피오더 실시간 추가재고 등록메뉴 및 알람기능 개발 start + #region 해피오더 실시간 재고 알람 + + //**************************************************************************************** + //WEB에서 재고 미등록 상태일 때 포스로 Y값을 내려주고 Y로 내려오면 판매화면 상단에 깜빡이는 패널 생성해줌. + //10분마다 조회하고 1분동안 패널 표시해줌 + //**************************************************************************************** + if (PosMstManager.GetPosOption(POS_OPTION.OPT518) == "1") + { + //// 타이머시작 + //iInventoryDispCnt = iInventoryDispCnt + 1; + //// 타이머 전역변수 (초) + //m_cPosStatus.Sale.HappyOrderInventoryTime = iInventoryDispCnt.ToString(); + //// (처음한번)실시간재고알람Y/N 읽어오기 + //if (iInventoryDispCnt == 0) + //{ + // HappyOrderInventoryAlram(); + //} + //// (10분마다)실시간재고알람Y/N 읽어오기 + //else if (iInventoryDispCnt >= 60 * 10) + //{ + // iInventoryDispCnt = 0; + // HappyOrderInventoryAlram(); + //} + + HappyOrderInventoryAlram(); + } + + #endregion + //#15884 해피오더 실시간 추가재고 등록메뉴 및 알람기능 개발 end + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.ERROR_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 (함수명)) + "Exception in NetworkCheckOver Thread" + ex.Message); + } + + int nNowSleepTerm = 0; + while (nNowSleepTerm < m_ThreadSleepTerm) + { + if (m_NetworkCheckOverRunning == false) break; + Thread.Sleep(100); + nNowSleepTerm += 100; + } + if (iSubCount_1 == 10) iSubCount_1 = 0; + else iSubCount_1++; + if (iSubCount_2 == 30) iSubCount_2 = 0; + else iSubCount_2++; + //System.Threading.Thread.Sleep(m_ThreadSleepTerm); + } + } + 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); + } + } + + private void UpdateNoticesDateTime(string sMsgDiv, string sMsgType, string sDateTime) + { + try + { + // 업데이트 시간 갱신 + switch (sMsgDiv) + { + case "00": // 긴급 공지 + m_cPosStatus.Base.EmergencyNoticeUpdateDT = sDateTime; + break; + case "01": // 일반 공지 + m_cPosStatus.Base.RegularNoticeUpdateDT = sDateTime; + break; + case "02": // 영업 공지 + if (sMsgType == "1") + { + // 오늘의 할 일 + m_cPosStatus.Base.SaleNoticeUpdateDT1 = sDateTime; + } + else + { + // 식품안전 메시지 + m_cPosStatus.Base.SaleNoticeUpdateDT2 = sDateTime; + } + break; + } + + // PosSaleInfo.ini 저장 + IServiceUs cSaveConfigInfo = (IServiceUs)sManager.InitServiceInstance(ServiceLists.BSV_OPEN_CLOSE.DLL, ServiceLists.BSV_OPEN_CLOSE.SAVE_CONFIGINFO); + string sRet = cSaveConfigInfo.Execute(new string[] { PosConst.INI_FILE_NAME.PosSaleInfo }); + } + 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); + } + } + + //#20180228 해피오더 주문 건수 조회 기능 에러시 다른 기능 동작 되도록 수정 start + private void HappyOrderCntChk() + { + string sReqData = string.Empty; + string sRespData = string.Empty; + string sReturn = string.Empty; + int iRet = 0; + //grayber@20180306 해피오더 주문가능 상태 추가 start - HashTable 추가 + Hashtable htRspData = null; + //grayber@20180306 해피오더 주문가능 상태 추가 end + try + { + + sReqData = string.Format("storeCode={0}&deviceType=POS", m_cPosStatus.Base.StoreNo); + //sReqData = string.Format("storeCode={0}&deviceType=POS", "11101"); + + + + //#20180605 해피오더 개선 start - 20180618 + //기존 + /* + //grayber@20180306 해피오더 주문가능 상태 추가 start - 공통사용 함수가 아닌 NetworkCheckOver class 의 함수를 사용를 수정 + // 기존 + //iRet = this.HttpJsonGET_SendReceive(m_sHappyOrderURL, ItemConst.HAPPYORDER_WORK_TYPE.SELECT_STATUS_COUNT, sReqData, ref sRespData); + // 변경 + iRet = this.HttpJsonGET_SendReceive(m_sHappyOrderURL, ItemConst.HAPPYORDER_WORK_TYPE.SELECT_STATUS_COUNT, sReqData, ref sRespData, ref htRspData); + //grayber@20180306 해피오더 주문가능 상태 추가 end + */ + + //변경 + if (m_cPosStatus.Base.BrandCd == PosConst.MST_BRAND_CODE.PC_PB) + { + iRet = this.HttpJsonGET_SendReceive(m_sHappyOrderURL, ItemConst.HAPPYORDER_WORK_TYPE.SELECT_STATUS_COUNT_PB, sReqData, ref sRespData, ref htRspData); + } + else + { + iRet = this.HttpJsonGET_SendReceive(m_sHappyOrderURL, ItemConst.HAPPYORDER_WORK_TYPE.SELECT_STATUS_COUNT, sReqData, ref sRespData, ref htRspData); + } + //#20180605 해피오더 개선 end - 20180618 + + + + if (iRet == BaseCom.OK) + { + //grayber@20180306 해피오더 주문가능 상태 추가 start - 함수 HashTable 값 추가 + //기존 + //sReturn = m_cCheckOverDetail.SelectHappyOrderCountByOrderStatus(JsonConvert.DeserializeObject(sRespData)); + //변경 + sReturn = m_cCheckOverDetail.SelectHappyOrderCountByOrderStatus(JsonConvert.DeserializeObject(sRespData) , ref htRspData); + //grayber@20180306 해피오더 주문가능 상태 추가 end + } + } + 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); + } + } + //#20180228 해피오더 주문 건수 조회 기능 에러시 다른 기능 동작 되도록 수정 end + + #endregion CheckOver Main + + #region 공지사항 조회 - 서브 업무 처리 + private void DoSubProc(DataTable dtList) + { + int iRet = UserCom.NG; + try + { + for (int nLoop = 0; nLoop < dtList.Rows.Count; nLoop++) + { + DataRow dr = dtList.Rows[nLoop]; + + switch(CmUtil.GetDataRowStr(dr, "MSG_CODE")) + { + case "01": // 점주/알바 모드 + iRet = InsertIntoNOTICE_MNG(new string[] { "01", CmUtil.GetDataRowStr(dr, "VALUE_1"), CmUtil.GetDataRowStr(dr, "VALUE_2") }); + break; + case "02": // 위해상품 메시지 등록 + if (CmUtil.GetDataRowInt(dr, "VALUE_1") > 0) + { + iRet = ProcHarmfulItemMsgReg(); + } + break; + case "03": // 입고등록 확인 + iRet = InsertIntoNOTICE_MNG(new string[] { "03", CmUtil.GetDataRowStr(dr, "VALUE_3"), CmUtil.GetDataRowStr(dr, "VALUE_4") }); + break; + case "04": // 배송 정보 + iRet = InsertIntoNOTICE_MNG(new string[] { "04", CmUtil.GetDataRowStr(dr, "VALUE_3"), CmUtil.GetDataRowStr(dr, "VALUE_4") }); + break; + case "05": // 기념일 배송 + iRet = InsertIntoNOTICE_MNG(new string[] { "05", CmUtil.GetDataRowStr(dr, "VALUE_1") }); + break; + } + } + } + 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); + } + } + + private int ProcHarmfulItemMsgReg() + { + int iRet = BaseCom.NG; + Hashtable htSendData = null; + Hashtable htRecvData = null; + try + { + // 전문 생성 + htSendData = this.MakeMessageSendingReqData(ItemConst.IRT_INQ_TYPE.HARMFUL_ITEM_MSG_REQ, null); + + // 전문 요청 + iRet = IRTSendReceive(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.SysInfoPort), + (int)5000, htSendData, ref htRecvData); + + if (iRet == BaseCom.OK) + { + if (htRecvData[Column.IQ_FOODMSG_RSP.DATA.RES_CD].ToString() == "00") + { + // DB Insert + iRet = InsertIntoNOTICE_MNG(new string[] { "02", htRecvData[Column.IQ_FOODMSG_RSP.DATA.ISPCTN_ORGAN_CD].ToString(), htRecvData[Column.IQ_FOODMSG_RSP.DATA.DOC_NO].ToString() + , htRecvData[Column.IQ_FOODMSG_RSP.DATA.SEQ].ToString(), htRecvData[Column.IQ_FOODMSG_RSP.DATA.ITEM_NM].ToString() + , htRecvData[Column.IQ_FOODMSG_RSP.DATA.BAR_CD].ToString() }); + } + } + } + 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 iRet; + } + #endregion + + #region 공지사항 조회 응답 中 공지사항구분 필드 파싱 처리 + private DataTable ParseMsgValueField(string sMsgValue) + { + DataTable dtMsgValue = null; + + try + { + dtMsgValue = new DataTable(); + dtMsgValue.Columns.Add(new DataColumn("MSG_CODE", typeof(string))); + dtMsgValue.Columns.Add(new DataColumn("VALUE_1", typeof(string))); + dtMsgValue.Columns.Add(new DataColumn("VALUE_2", typeof(string))); + dtMsgValue.Columns.Add(new DataColumn("VALUE_3", typeof(string))); + dtMsgValue.Columns.Add(new DataColumn("VALUE_4", typeof(string))); + dtMsgValue.Clear(); + + string[] sRows = sMsgValue.Split(new string[] { "#~" }, StringSplitOptions.RemoveEmptyEntries); + foreach(string sRow in sRows) + { + string[] sColumns = sRow.Split(new string[] { "|" }, StringSplitOptions.None); + + DataRow drNew = dtMsgValue.NewRow(); + drNew["MSG_CODE"] = sColumns[0]; + drNew["VALUE_1"] = sColumns[1]; + drNew["VALUE_2"] = sColumns[2]; + drNew["VALUE_3"] = sColumns[3]; + drNew["VALUE_4"] = sColumns[4]; + dtMsgValue.Rows.Add(drNew); + } + } + 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 dtMsgValue; + } + #endregion + + #region IRT 요청 Data 생성 + private Hashtable MakeMessageSendingReqData(string sInqType, string[] sParams) + { + Hashtable htData = new Hashtable(); + + try + { + if (sInqType == ItemConst.IRT_INQ_TYPE.MSG_TRANSFER_REQ) + { + // 01 - INQ 종별("05":공지메시지) + htData.Add(Column.IQ_MSG_SND_REQ.DATA.INQ_TYPE, sInqType); + // 02 - 영업 일자 + htData.Add(Column.IQ_MSG_SND_REQ.DATA.SALE_DT, m_cPosStatus.Base.SaleDate); + // 03 - 점포 코드 + htData.Add(Column.IQ_MSG_SND_REQ.DATA.STOR_CD, m_cPosStatus.Base.StoreNo); + // 04 - 사용자 + htData.Add(Column.IQ_MSG_SND_REQ.DATA.USER_ID, m_cPosStatus.Base.CashierNo); + // 05 - 반환용 메시지 코드 + htData.Add(Column.IQ_MSG_SND_REQ.DATA.MSG_CD, string.Empty); + // 통신서버 측 조회 쿼리가 무거워서 일반과 긴급을 나눔(2017.07.28) + //// 06 - 메시지 구분("0":일반/긴급공지, "1":영업공지) + // 06 - 메시지 구분("0":일반공지, "1":영업공지, "2":긴급공지) + htData.Add(Column.IQ_MSG_SND_REQ.DATA.MSG_DIV, sParams[0]); + // 07 - 업데이트 일자1 + htData.Add(Column.IQ_MSG_SND_REQ.DATA.UPD_DT1, sParams[1]); + // 08 - 업데이트 일자2 + htData.Add(Column.IQ_MSG_SND_REQ.DATA.UPD_DT2, sParams[2]); + // 09 - 업데이트 일자3 + htData.Add(Column.IQ_MSG_SND_REQ.DATA.UPD_DT3, sParams[3]); + // 10 - 업데이트 일자4 + htData.Add(Column.IQ_MSG_SND_REQ.DATA.UPD_DT4, sParams[4]); + } + else if(sInqType == ItemConst.IRT_INQ_TYPE.NOTICE_INQ_REQ) + { + // 01 - INQ 종별("49":공지사항) + htData.Add(Column.IQ_NOTICE_INQ_REQ.DATA.INQ_TYPE, sInqType); + // 02 - 점포 코드 + htData.Add(Column.IQ_NOTICE_INQ_REQ.DATA.STOR_CD, m_cPosStatus.Base.StoreNo); + // 03 - 영업 일자 + htData.Add(Column.IQ_NOTICE_INQ_REQ.DATA.SALE_DT, m_cPosStatus.Base.SaleDate); + // 04 - POS 번호 + htData.Add(Column.IQ_NOTICE_INQ_REQ.DATA.POS_NO, m_cPosStatus.Base.PosNo); + // 05 - 메시지 등록 코드 + htData.Add(Column.IQ_NOTICE_INQ_REQ.DATA.MSG_VALUE, ""); + // 06 - 응답 코드 + htData.Add(Column.IQ_NOTICE_INQ_REQ.DATA.RES_CD, "00"); + } + else if(sInqType == ItemConst.IRT_INQ_TYPE.HARMFUL_ITEM_MSG_REQ) + { + // 01 - INQ 종별("20":공지메시지) + htData.Add(Column.IQ_FOODMSG_REQ.DATA.INQ_TYPE, sInqType); + // 02 - 영업일자 + htData.Add(Column.IQ_FOODMSG_REQ.DATA.SALE_DT, m_cPosStatus.Base.SaleDate); + // 03 - 점포코드 + htData.Add(Column.IQ_FOODMSG_REQ.DATA.STOR_CD, m_cPosStatus.Base.StoreNo); + // 04 - 요청구분 + htData.Add(Column.IQ_FOODMSG_REQ.DATA.REQ_DIV, "1"); + // 05 - 검사 기간코드 + htData.Add(Column.IQ_FOODMSG_REQ.DATA.ISPCTN_ORGAN_CD, ""); + // 06 - 문서번호 + htData.Add(Column.IQ_FOODMSG_REQ.DATA.DOC_NO, ""); + // 07 - 일련번호 + htData.Add(Column.IQ_FOODMSG_REQ.DATA.SEQ, ""); + + } + else if(sInqType == ItemConst.IRT_INQ_TYPE.POS_LOGFILE_REQ) + { + // 01 - INQ 종별("69":POS 로그 파일 송신요청) + htData.Add(Column.IQ_POS_LOGFILE_REQ.DATA.INQ_TYPE, sInqType); + // 02 - 점포코드 + htData.Add(Column.IQ_POS_LOGFILE_REQ.DATA.STOR_CD, m_cPosStatus.Base.StoreNo); + // 03 - POS번호 + htData.Add(Column.IQ_POS_LOGFILE_REQ.DATA.POS_NO, m_cPosStatus.Base.PosNo); + // 04 - 요청 LOG 일자 + htData.Add(Column.IQ_POS_LOGFILE_REQ.DATA.LOG_DT, sParams[1]); + // 05 - 요청구분("1":로그요청 확인, "2":POS수신완료, "3":FTP송신완료) + htData.Add(Column.IQ_POS_LOGFILE_REQ.DATA.REQ_DIV, sParams[0]); + // 06 - 전송할 FTP PATH + htData.Add(Column.IQ_POS_LOGFILE_REQ.DATA.FTP_PATH, ""); + // 07 - FILE_NM + htData.Add(Column.IQ_POS_LOGFILE_REQ.DATA.FILE_NM, ""); + // 08 - 응답코드 + htData.Add(Column.IQ_POS_LOGFILE_REQ.DATA.RES_CD, "00"); + } + } + 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 htData; + } + + private Hashtable MakePOSMASTERLISTReqData() + { + Hashtable htData = new Hashtable(); + + try + { + // 01 - INQ 종별 + htData.Add(Column.IQ_POSMASTERLIST_REQ.DATA.INQ_TYPE, "44"); + // 02 - 다운 구분 + htData.Add(Column.IQ_POSMASTERLIST_REQ.DATA.DOWN_DIV, "1"); + // 03 - 다운 마스터 항목 + htData.Add(Column.IQ_POSMASTERLIST_REQ.DATA.MASTER_LIST, ""); + } + 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 htData; + } + #endregion + + #region DB 관련 처리 + private int InsertIntoNOTICE_MNG(string[] aParam) + { + int iRet = UserCom.NG; + string sUpdQuery = string.Empty; + string sInsQuery = string.Empty; + string sSeqQuery = string.Empty; + string sCntQuery = string.Empty; + string sSql = string.Empty; + + DataTable dtData = null; + + try + { + sUpdQuery = " UPDATE POSLOG..ETC_NOTICE_MNG "; + sUpdQuery += " SET VAL_ENTRY_01 = N'{0}' "; + sUpdQuery += " , VAL_ENTRY_02 = N'{1}' "; + sUpdQuery += " , VAL_ENTRY_03 = N'{2}' "; + sUpdQuery += " , VAL_ENTRY_04 = N'{3}' "; + sUpdQuery += " , VAL_ENTRY_05 = N'{4}' "; + sUpdQuery += " , VAL_ENTRY_06 = N'{5}' "; + sUpdQuery += " , VAL_ENTRY_07 = N'{6}' "; + sUpdQuery += " , VAL_ENTRY_08 = N'{7}' "; + sUpdQuery += " , VAL_ENTRY_09 = N'{8}' "; + sUpdQuery += " , VAL_ENTRY_10 = N'{9}' "; + sUpdQuery += " , SEND_FLAG = '0' "; + sUpdQuery += " WHERE CMP_CD = '{10}' "; + sUpdQuery += " AND STOR_CD = '{11}' "; + sUpdQuery += " AND POS_NO = '{12}' "; + sUpdQuery += " AND MSG_DIV = '{13}' "; + + sSeqQuery = " SELECT MAX(ISNULL(SEQ, 0)) AS SEQ "; + sSeqQuery += " FROM POSLOG..ETC_NOTICE_MNG "; + sSeqQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sSeqQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sSeqQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "' "; + sSeqQuery += " AND MSG_DIV = '02' "; + + sCntQuery = " SELECT COUNT(1) AS CNT "; + sCntQuery += " FROM POSLOG..ETC_NOTICE_MNG "; + sCntQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sCntQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sCntQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "' "; + sCntQuery += " AND MSG_DIV = '{0}' "; + + sInsQuery = " INSERT INTO POSLOG..ETC_NOTICE_MNG "; + sInsQuery += " ( CMP_CD, STOR_CD, POS_NO, MSG_DIV, SEQ "; + sInsQuery += " , VAL_ENTRY_01, VAL_ENTRY_02, VAL_ENTRY_03, VAL_ENTRY_04, VAL_ENTRY_05 "; + sInsQuery += " , VAL_ENTRY_06, VAL_ENTRY_07, VAL_ENTRY_08, VAL_ENTRY_09, VAL_ENTRY_10 "; + sInsQuery += " , REG_DATE, UPD_DATE, SEND_FLAG ) "; + sInsQuery += " VALUES "; + sInsQuery += " ( '{0}', '{1}', '{2}', '{3}', {4} "; + sInsQuery += " , N'{5}', N'{6}', N'{7}', N'{8}', N'{9}' "; + sInsQuery += " , N'{10}', N'{11}', N'{12}', N'{13}', N'{14}' "; + sInsQuery += " , '{15}', '{16}', '0' ) "; + + switch(aParam[0]) + { + case "01": // 점주/알바 모드 + case "03": // 입고등록 확인 + case "04": // 배송정보 + sSql = string.Format(sCntQuery, aParam[0]); + sqlDb.DBDataTableSelect(sSql, CommandType.Text, (System.Data.SqlClient.SqlParameter[])null, out dtData); + if(dtData != null && dtData.Rows.Count > 0) + { + if(CmUtil.GetDataRowInt(dtData.Rows[0], "CNT") == 0) + { + sSql = string.Format(sInsQuery, m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.PosNo, aParam[0], "1" + , aParam[1], aParam[2], "", "", "" + , "", "", "", "", "" + , DateTime.Now.ToString("yyyyMMddHHmmss"), ""); + } + else + { + sSql = string.Format(sUpdQuery, aParam[1], aParam[2], "", "", "", "", "", "", "", "" + , m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.PosNo, aParam[0]); + } + } + break; + case "02": // 위해상품 메시지 등록 + int iSeq = 0; + + sqlDb.DBDataTableSelect(sSeqQuery, CommandType.Text, (System.Data.SqlClient.SqlParameter[])null, out dtData); + if(dtData != null && dtData.Rows.Count > 0) + { + iSeq = CmUtil.GetDataRowInt(dtData.Rows[0], "SEQ") + 1; + } + + sSql = string.Format(sInsQuery, m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.PosNo, aParam[0], iSeq + , aParam[1], aParam[2], aParam[3], aParam[4], aParam[5] + , "", "", "", "", "" + , DateTime.Now.ToString("yyyyMMddHHmmss"), ""); + break; + case "05": // 기념일 배송 + sSql = string.Format(sCntQuery, aParam[0]); + sqlDb.DBDataTableSelect(sSql, CommandType.Text, (System.Data.SqlClient.SqlParameter[])null, out dtData); + if(dtData != null && dtData.Rows.Count > 0) + { + if(CmUtil.GetDataRowInt(dtData.Rows[0], "CNT") == 0) + { + sSql = string.Format(sInsQuery, m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.PosNo, aParam[0], "1" + , aParam[1], "", "", "", "" + , "", "", "", "", "" + , DateTime.Now.ToString("yyyyMMddHHmmss"), ""); + } + else + { + sSql = string.Format(sUpdQuery, aParam[1], "", "", "", "", "", "", "", "", "" + , m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.PosNo, aParam[0]); + } + } + + break; + } + + iRet = sqlDb.DBExecuteNonQuery(sSql, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + } + 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 iRet; + } + private int InsertIntoEMG_NOTE(Hashtable htRecvData) + { + int iRet = UserCom.NG; + //string sUpdQuery = string.Empty; + //string sInsQuery = string.Empty; + string sQuery = string.Empty; + string sSql = string.Empty; + + try + { + //sUpdQuery = " UPDATE POSMST..MST_EMG_NOTE "; + //sUpdQuery += " SET MSG_TITLE = '{0}' "; + //sUpdQuery += " , MSG_CONTENTS = '{1}' "; + //sUpdQuery += " , POS_EXEC_TYPE = '{2}' "; + //sUpdQuery += " , POPUP_YN = '{3}' "; + //sUpdQuery += " , FNSH_HOUR = '{4}' "; + //sUpdQuery += " , READ_YN = '{5}' "; + //sUpdQuery += " , DOWN_YN = '{14}' "; + //sUpdQuery += " , UPD_DT = '{6}' "; + //sUpdQuery += " WHERE CMP_CD = '{7}' "; + //sUpdQuery += " AND STOR_CD = '{8}' "; + //sUpdQuery += " AND POS_NO = '{9}' "; + //sUpdQuery += " AND START_DT = '{10}' "; + //sUpdQuery += " AND MSG_CODE = '{11}' "; + //sUpdQuery += " AND MSG_DIV = '{12}' "; + //sUpdQuery += " AND MSG_TYPE = '{13}' "; + + //sInsQuery = "INSERT INTO POSMST..MST_EMG_NOTE "; + //sInsQuery += " ( CMP_CD, STOR_CD, POS_NO, START_DT, MSG_CODE "; + //sInsQuery += " , MSG_DIV, MSG_TYPE, MSG_TITLE, MSG_CONTENTS, POS_EXEC_TYPE "; + //sInsQuery += " , POPUP_YN, FNSH_HOUR, READ_YN, DOWN_YN, UPD_DT, REG_DT ) "; + //sInsQuery += "VALUES "; + //sInsQuery += " ( '{0}', '{1}', '{2}', '{3}', '{4}' "; + //sInsQuery += " , '{5}', '{6}', '{7}', '{8}', '{9}' "; + //sInsQuery += " , '{10}', '{11}', '{12}', '{13}', '{14}', '{15}' ) "; + + sQuery += "UPDATE POSMST..MST_EMG_NOTE "; + sQuery += " SET MSG_TITLE = N'{7}' "; + sQuery += " , MSG_CONTENTS = N'{8}' "; + sQuery += " , POS_EXEC_TYPE = '{9}' "; + sQuery += " , POPUP_YN = '{10}' "; + sQuery += " , FNSH_HOUR = '{11}' "; + sQuery += " , READ_YN = '{12}' "; + sQuery += " , DOWN_YN = '{13}' "; + sQuery += " , UPD_DT = '{14}' "; + sQuery += " , USE_YN = '{15}' "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND STOR_CD = '{1}' "; + sQuery += " AND POS_NO = '{2}' "; + sQuery += " AND START_DT = '{3}' "; + sQuery += " AND MSG_CODE = '{4}' "; + sQuery += " AND MSG_DIV = '{5}' "; + sQuery += " AND MSG_TYPE = '{6}' "; + sQuery += "IF @@ROWCOUNT = 0 "; + sQuery += "INSERT INTO POSMST..MST_EMG_NOTE "; + sQuery += " ( CMP_CD, STOR_CD, POS_NO, START_DT, MSG_CODE "; + sQuery += " , MSG_DIV, MSG_TYPE, MSG_TITLE, MSG_CONTENTS, POS_EXEC_TYPE "; + sQuery += " , POPUP_YN, FNSH_HOUR, READ_YN, DOWN_YN, REG_DT "; + sQuery += " , USE_YN ) "; + sQuery += "VALUES "; + sQuery += " ( '{0}', '{1}', '{2}', '{3}', '{4}' "; + sQuery += " , '{5}', '{6}', N'{7}', N'{8}', '{9}' "; + sQuery += " , '{10}', '{11}', '{12}', '{13}', '{14}' "; + sQuery += " , '{15}' ) "; + + //sSql = string.Format(sUpdQuery, + // htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_TITLE], + // htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_CONT], + // htRecvData[Column.IQ_MSG_SND_RSP.DATA.POS_EXEC_TYPE], + // htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_POPUP], + // htRecvData[Column.IQ_MSG_SND_RSP.DATA.FNSH_DT], + // "0", + // DateTime.Now.ToString("yyyyMMddHHmmss"), + // m_cPosStatus.Base.CmpCd, + // htRecvData[Column.IQ_MSG_SND_RSP.DATA.STOR_CD], + // m_cPosStatus.Base.PosNo, + // htRecvData[Column.IQ_MSG_SND_RSP.DATA.START_DT], + // htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_CD], + // htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_DIV], + // htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_TYPE], + // "0"); + //iRet = sqlDb.DBExecuteNonQuery(sSql, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + //if (iRet != UserCom.OK) + //{ + // sSql = string.Format(sInsQuery, + //m_cPosStatus.Base.CmpCd, htRecvData[Column.IQ_MSG_SND_RSP.DATA.STOR_CD], m_cPosStatus.Base.PosNo, htRecvData[Column.IQ_MSG_SND_RSP.DATA.START_DT], htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_CD], htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_DIV], + //htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_TYPE], htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_TITLE], htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_CONT], htRecvData[Column.IQ_MSG_SND_RSP.DATA.POS_EXEC_TYPE], + //htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_POPUP], htRecvData[Column.IQ_MSG_SND_RSP.DATA.FNSH_DT], "0", "0", DateTime.Now.ToString("yyyyMMddHHmmss"), DateTime.Now.ToString("yyyyMMddHHmmss")); + + // iRet = sqlDb.DBExecuteNonQuery(sSql, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + //} + sSql = string.Format(sQuery, + m_cPosStatus.Base.CmpCd, + htRecvData[Column.IQ_MSG_SND_RSP.DATA.STOR_CD], + m_cPosStatus.Base.PosNo, + htRecvData[Column.IQ_MSG_SND_RSP.DATA.START_DT], + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_CD], + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_DIV], + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_TYPE], + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_TITLE], + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_CONT], + htRecvData[Column.IQ_MSG_SND_RSP.DATA.POS_EXEC_TYPE], + htRecvData[Column.IQ_MSG_SND_RSP.DATA.MSG_POPUP], + htRecvData[Column.IQ_MSG_SND_RSP.DATA.FNSH_DT], + "0", + "0", + DateTime.Now.ToString("yyyyMMddHHmmss"), + htRecvData[Column.IQ_MSG_SND_RSP.DATA.USE_YN]); + + iRet = sqlDb.DBExecuteNonQuery(sSql, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + } + 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 iRet; + } + + private int UpdateMasterTableList(string[] arList) + { + int iRet = UserCom.NG; + string sSql = string.Empty; + + try + { + sSql = "UPDATE POSMST..MST_POSMST_TABLE_LST "; + sSql += " SET EMG_DIV = '1' "; + sSql += " , UPD_DT = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + sSql += " WHERE 1 = 1 "; + sSql += " AND MST_TBL_CD IN ("; + + int i = 0; + foreach(string sMasterCd in arList) + { + if (i == 0) + { + sSql += " '" + sMasterCd + "'"; + } + else + { + sSql += ", '" + sMasterCd + "'"; + } + + i++; + } + + sSql += " )"; + + iRet = sqlDb.DBExecuteNonQuery(sSql, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + } + 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 iRet; + } + + /// + /// 전송 내역 조회 + /// + /// 전문타입 + /// + private DataTable SelectSendDataList(string sInqType) + { + string sSQL = string.Empty; + + string sSerchTableName = ""; + string sSearchDate = ""; + string sCoumn = ""; + + DataTable dtData = null; + + try + { + + //if (sInqType == ItemConst.IRT_INQ_TYPE.HARMFUL_ITEM_MSG_REQ) //유해 상품이면.... + //{ + // sSQL = " SELECT STOR_CD, '2' AS 'REQ_DIV', '0' AS 'DATA_CNT', VAL_ENTRY_01 AS 'ISPCTN_ORGAN_CD', VAL_ENTRY_02 AS 'DOC_NO' "; + // sSQL += " ,VAL_ENTRY_03 AS 'SEQ', VAL_ENTRY_04 AS '', VAL_ENTRY_05 AS 'ITEM_NM', VAL_ENTRY_06 AS 'BAR_CD','' AS RES_CD "; + // sSQL += " ,CMP_CD, POS_NO,MSG_DIV,SEQ AS 'DISP_SEQ' "; + // sSQL += " FROM POSLOG.dbo.ETC_NOTICE_MNG"; + // sSQL += " WHERE CMP_CD = '{0}'"; + // sSQL += " AND STOR_CD = '{1}'"; + // sSQL += " AND POS_NO = '{2}'"; + // sSQL += " AND MSG_DIV IN ('02') "; + // sSQL += " AND SUBSTRING(REG_DATE,1,8) BETWEEN CONVERT(VARCHAR,GETDATE() - 31,112) AND CONVERT(VARCHAR,GETDATE(),112) "; + // sSQL += " AND SEND_FLAG IN ('1', '9') "; + // sSQL += " ORDER BY SEND_FLAG "; + + // if (sSQL != "") + // { + // sSQL = string.Format(sSQL, m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.PosNo); + // sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (System.Data.SqlClient.SqlParameter[])null, out dtData); + // } + //} + //else + //{ + sSQL = " SELECT TOP 1 '{0}' AS INQ_TYPE, {1} "; + sSQL += " FROM {2} "; + sSQL += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sSQL += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + + if (sInqType == ItemConst.IRT_INQ_TYPE.HARMFUL_ITEM_MSG_REQ) //유해상품이면 + { + sSQL += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "' "; + sSQL += " AND MSG_DIV IN ('02') "; + sSQL += " AND SUBSTRING(REG_DATE,1,8) BETWEEN CONVERT(VARCHAR,GETDATE() - 31,112) AND CONVERT(VARCHAR,GETDATE(),112) "; + sSQL += " AND SEND_FLAG IN ('1', '9') "; + sSQL += " ORDER BY SEND_FLAG "; + } + else + { + sSQL += " AND {3} BETWEEN CONVERT(VARCHAR,GETDATE()-2,112) AND CONVERT(VARCHAR,GETDATE(),112) "; //-2일 전부터 + sSQL += " AND SEND_YN <> '1' "; + sSQL += " ORDER BY SEND_YN "; + } + + + + if (sInqType == ItemConst.IRT_INQ_TYPE.STOR_VISIT) //방문,제조기사 타임바코드 + { + sCoumn = " STOR_CD,VISIT_DT,POS_NO,MNG_CARD_NO,VISIT_START_HOUR,VISIT_FNSH_HOUR,VISIT_USER_ID,JOB_TYPE,PCSMM_SEND_YN,MSR_DIV,ORG_BAR_CD_NO,'' AS SEND_YN "; + sSerchTableName = "POSLOG.dbo.TR_STORE_VISIT "; + sSearchDate = "VISIT_DT"; + } + else if (sInqType == ItemConst.IRT_INQ_TYPE.EMP_COMMUTE) //근태 + { + sCoumn = " STOR_CD,EMP_NO,WORK_DT,ROS_CD,SEQ,HOUR_STAMP,ROS_HOUR,'' AS RES_CD "; + sSerchTableName = "POSLOG.dbo.TR_STOR_EMP "; + sSearchDate = "WORK_DT"; + } + else if (sInqType == ItemConst.IRT_INQ_TYPE.ONWER_MODE) //점주,알바 모드 + { + sCoumn = " STOR_CD,WORK_DT,WORK_HOUR,EMP_DIV,POS_NO,'' AS RES_CD "; + sSerchTableName = "POSLOG.dbo.TR_STOR_EMP_WORK "; + sSearchDate = "WORK_DT"; + } + else if (sInqType == ItemConst.IRT_INQ_TYPE.HARMFUL_ITEM_MSG_REQ) //유해 상품이면.... + { + sCoumn = " STOR_CD, '2' AS REQ_DIV, '0' AS DATA_CNT, VAL_ENTRY_01 AS ISPCTN_ORGAN_CD, VAL_ENTRY_02 AS DOC_NO "; + sCoumn += ",VAL_ENTRY_03 AS SEQ, VAL_ENTRY_04 AS ITEM_NM, VAL_ENTRY_05 AS BAR_CD,'' AS RES_CD "; + //sCoumn += " ,POS_NO,MSG_DIV,SEQ AS 'DISP_SEQ' "; + sSerchTableName = "POSLOG.dbo.ETC_NOTICE_MNG "; + sSearchDate = ""; + } + else + { + sSQL = ""; + } + + //쿼리 실행! + if (sSQL != "") + { + sSQL = string.Format(sSQL, sInqType, sCoumn, sSerchTableName, sSearchDate); + sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (System.Data.SqlClient.SqlParameter[])null, out dtData); + } + } + //} + 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 dtData; + } + + /// + /// 전송 플래그 업데이트 + /// + /// 전송구분 + /// 파라미터 + /// + private int UpdateTableSend(string sInqType, string sFlag, Hashtable htSendData) + { + int iRet = UserCom.NG; + string sSQL = string.Empty; + + try + { + if (sInqType == ItemConst.IRT_INQ_TYPE.STOR_VISIT) //방문,제조기사 타임바코드 + { + sSQL = " UPDATE POSLOG.dbo.TR_STORE_VISIT SET SEND_YN = '" + sFlag + "'"; + sSQL += " WHERE 1 = 1 "; + sSQL += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sSQL += " AND STOR_CD = '" + htSendData["STOR_CD"] + "'"; + sSQL += " AND VISIT_DT = '" + htSendData["VISIT_DT"] + "'"; + sSQL += " AND POS_NO = '" + htSendData["POS_NO"] + "'"; + sSQL += " AND MNG_CARD_NO = '" + htSendData["MNG_CARD_NO"] + "'"; + sSQL += " AND VISIT_START_HOUR = '" + htSendData["VISIT_START_HOUR"] + "'"; + + } + else if (sInqType == ItemConst.IRT_INQ_TYPE.EMP_COMMUTE) //근태 + { + sSQL = " UPDATE POSLOG.dbo.TR_STOR_EMP SET SEND_YN = '" + sFlag + "'"; + sSQL += " WHERE 1 = 1 "; + sSQL += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sSQL += " AND STOR_CD = '" + htSendData["STOR_CD"] + "'"; + sSQL += " AND EMP_NO = '" + htSendData["EMP_NO"] + "'"; + sSQL += " AND WORK_DT = '" + htSendData["WORK_DT"] + "'"; + sSQL += " AND ROS_CD = '" + htSendData["ROS_CD"] + "'"; + sSQL += " AND SEQ = '" + htSendData["SEQ"] + "'"; + sSQL += " AND HOUR_STAMP = '" + htSendData["HOUR_STAMP"] + "'"; + + } + else if (sInqType == ItemConst.IRT_INQ_TYPE.ONWER_MODE) //점주,알바 모드 + { + sSQL = " UPDATE POSLOG.dbo.TR_STOR_EMP_WORK SET SEND_YN = '" + sFlag + "'"; + sSQL += " WHERE 1 = 1 "; + sSQL += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sSQL += " AND STOR_CD = '" + htSendData["STOR_CD"] + "'"; + sSQL += " AND WORK_DT = '" + htSendData["WORK_DT"] + "'"; + sSQL += " AND WORK_HOUR = '" + htSendData["WORK_HOUR"] + "'"; + sSQL += " AND EMP_DIV = '" + htSendData["EMP_DIV"] + "'"; + sSQL += " AND POS_NO = '" + htSendData["POS_NO"] + "'"; + } + else if (sInqType == ItemConst.IRT_INQ_TYPE.HARMFUL_ITEM_MSG_REQ) //유해상품 + { + sSQL = " UPDATE POSLOG.dbo.ETC_NOTICE_MNG SET SEND_FLAG = '" + sFlag + "'"; + sSQL += " WHERE 1 = 1 "; + sSQL += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sSQL += " AND STOR_CD = '" + htSendData["STOR_CD"] + "'"; + sSQL += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "'"; + sSQL += " AND MSG_DIV = '02'"; + sSQL += " AND VAL_ENTRY_01 = '" + htSendData["ISPCTN_ORGAN_CD"] + "'"; + sSQL += " AND VAL_ENTRY_02 = '" + htSendData["DOC_NO"] + "'"; + sSQL += " AND VAL_ENTRY_03 = '" + htSendData["SEQ"] + "'"; + } + else + { + sSQL = ""; + } + + iRet = sqlDb.DBExecuteNonQuery(sSQL, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + } + 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 iRet; + } + + + #endregion + + #region 통신서버 전송 모듈 + /// + /// IRT Json Send/Recv + /// + /// + /// + /// Time to keep the connection(ms) + /// + /// + /// + private int IRTSendReceive(string sSvrIp, int iPort, int iTimeout, Hashtable htSendData, ref Hashtable htRecvData) + { + int nStat = BaseCom.NG; + + try + { + // 전송 데이터를 JSON 객체로 변환 + string sJsonSendData = JsonConvert.SerializeObject(htSendData); + // JSON string 길이를 구하기 위해 byte 변환 + Byte[] arTempData = Encoding.UTF8.GetBytes(sJsonSendData); + // 통신헤더 전문 생성 + string sCommHeader = ItemColumn.MakeCommHeader(arTempData.Length, ItemConst.COMM_MSG_TYPE.POSIRT); + + string sJsonRecvData = string.Empty; + + UserLog.WriteLogFile(UserCom.LOG_SOCK, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)) + CmUtil.RPadH("[SEND" + ":" + sSvrIp + ":" + iPort, 27) + "] " + sCommHeader + sJsonSendData); + + nStat = SendReceiveData(sSvrIp, iPort, iTimeout, sCommHeader + sJsonSendData, ref sJsonRecvData); + + if (sJsonRecvData != null && sJsonRecvData != "") + { + string sRecvCommHeader = sJsonRecvData.Substring(0, TcpSocket.COMM_HEAD_LEN); + string sRecvData = sJsonRecvData.Substring(TcpSocket.COMM_HEAD_LEN); + + htRecvData = JsonConvert.DeserializeObject(sRecvData); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)) + CmUtil.RPadH("[RECV" + ":" + sSvrIp + ":" + iPort, 27) + "] " + sJsonRecvData); + } + } + 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 nStat; + } + /// + /// IRT Send/Receive + /// + /// + /// + /// Time to keep the connection(ms) + /// + /// + /// + private int SendReceiveData(string sSvrIp, int iPort, int iTimeout, string sSendData, ref string sRecvData) + { + int nStat = BaseCom.NG; + int nRecvLen = 0; + + try + { + m_sendSocket = new TcpSocket(sSvrIp, iPort); + + // Data Send & Receive + nRecvLen = m_sendSocket.SendReceiveData(sSendData, ref sRecvData, iTimeout); + + if(nRecvLen > 0) + { + nStat = BaseCom.OK; + } + else + { + sRecvData = string.Empty; + nStat = BaseCom.NG; + } + } + 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); + } + finally + { + if (m_sendSocket != null) m_sendSocket.Close(); + } + + return nStat; + } + #endregion + + #region Http 전송 모듈 + /// + /// 해피오더 GET방식 Request + /// + /// URL + /// 메시지 타입 + /// 요청Data + /// 응답Data(Json) + /// + ///grayber@20180306 해피오더 주문가능 상태 추가 start - 함수 인자 추가 NetworkCheckOver.HttpJsonGET_SendReceive 함수 HashTable 인자추가 + /// 기존 + /// public int HttpJsonGET_SendReceive(string sUrl, string sWorkType, string sReqData, ref string sRespJsonData) + /// 변경 + public int HttpJsonGET_SendReceive(string sUrl, string sWorkType, string sReqData, ref string sRespJsonData, ref Hashtable htRspData) + //grayber@20180306 해피오더 주문가능 상태 추가 end + { + int iRet = BaseCom.NG; + string sRespString = string.Empty; + + try + { + if (sUrl.Trim() == "") return iRet; + + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl + sWorkType + "?" + sReqData); + req.Method = "GET"; + + using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse()) + { + Stream stream = resp.GetResponseStream(); + StreamReader streamReader = new StreamReader(stream, Encoding.GetEncoding("UTF-8")); + sRespString = streamReader.ReadToEnd(); + } + + //#20180228 해피오더 주문 건수 조회 기능 에러시 다른 기능 동작 되도록 수정 start + //건수 조회 응답값 로그 추가 + UserLog.WriteLogFile(UserCom.LOG_DEBUG, + UserCom.WARNING_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 (함수명)) + sRespString); + //#20180228 해피오더 주문 건수 조회 기능 에러시 다른 기능 동작 되도록 수정 end + + Hashtable temp = JsonConvert.DeserializeObject(sRespString); + + foreach (string key in temp.Keys) + { + string jsonString = temp[key].ToString(); + if (key.Equals("status")) + { + Hashtable htHeader = JsonConvert.DeserializeObject(jsonString); + if (htHeader["status"].ToString().Equals("200")) + { + iRet = BaseCom.OK; + } + } + //grayber@20180306 해피오더 주문가능 상태 추가 start - deliverySupport 처리 추가 + + // 20180306 수신 데이터 sample + // http://api.celectory.com/api/ // 리얼 + // {"status":{"status":200,"code":"20000","message":"조회 완료","devMessage":"success","moreInfo":null,"orderNum":null},"orderStatusCount":[{"status":"0","count":1,"type":"5"},{"status":"8","count":110,"type":"1"},{"status":"8","count":453,"type":"2"},{"status":"8","count":223,"type":"3"},{"status":"8","count":122,"type":"6"},{"status":"2000","count":2,"type":"5"},{"status":"2008","count":31,"type":"2"},{"status":"2008","count":10,"type":"3"},{"status":"2008","count":46,"type":"6"},{"status":"9007","count":8,"type":"5"},{"status":"9009","count":126,"type":"5"},{"status":"300000","count":42,"type":"1"},{"status":"300000","count":177,"type":"2"},{"status":"300000","count":501,"type":"3"},{"status":"300000","count":279,"type":"5"},{"status":"300000","count":110,"type":"6"}]} + // http://121.254.240.198:8092/api/ // 개발 + // {"status":{"status":200,"code":"20000","message":"조회 완료","devMessage":"success","moreInfo":null,"orderNum":null},"orderStatusCount":[{"status":"8","count":1,"type":"3"},{"status":"2008","count":1,"type":"3"},{"status":"9007","count":3,"type":"5"},{"status":"9009","count":12,"type":"5"},{"status":"300000","count":25,"type":"3"},{"status":"300000","count":8,"type":"5"}],"deliverySupport":"Y"} + + // 기존 + //else + //{ + // sRespJsonData = jsonString; + //} + // 변경 + else if (key.Equals("deliverySupport")) + { + if (CmUtil.IsNull(htRspData)) + { + htRspData = new Hashtable(); + } + htRspData.Add(key.ToString(), temp[key].ToString()); + } + else if (key.Equals("orderStatusCount")) + { + sRespJsonData = jsonString; + } + //grayber@20180306 해피오더 주문가능 상태 추가 end + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.ToString()); + } + + return iRet; + } + + /// + /// GET방식 Request + /// + /// 서버URL + /// 작업구분 + /// 요청Data + /// JSON String 형태의 응답 데이터 + /// + public int HttpGET_SendReceive(string sUrl, string sWorkType, string sReqData, string sEncodingFlag, ref string sRespData) + { + int iRet = BaseCom.NG; + string sRespString = string.Empty; + StreamReader streamReader = null; + + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl + sWorkType + "?" + sReqData); + req.Method = "GET"; + + using (HttpWebResponse resp = (HttpWebResponse)req.GetResponse()) + { + Stream stream = resp.GetResponseStream(); + + if (sEncodingFlag == PosConst.ENCODING_FLAG.UTF) + { + streamReader = new StreamReader(stream, Encoding.GetEncoding("UTF-8")); + } + else + { + streamReader = new StreamReader(stream, Encoding.GetEncoding("ks_c_5601-1987")); + } + sRespString = streamReader.ReadToEnd(); + } + + iRet = BaseCom.OK; + + sRespData = sRespString; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.ToString()); + } + + return iRet; + } + #endregion + + #region BR 팝업메세지 처리 + private void BrPopUpBiz() + { + string sSQL = ""; + DataTable dtData = null; + + try + { + sSQL = " SELECT * "; + sSQL += " FROM POSLOG.dbo.ETC_BR_POPUP"; + sSQL += " WHERE CMP_CD = '{0}'"; + sSQL += " AND BRAND_CD = '{1}'"; + sSQL += " AND SALE_DT = '{2}'"; + sSQL += " AND STOR_CD = '{3}'"; + sSQL += " AND POS_NO = '{4}'"; + sSQL += " AND READ_FLAG = '0'"; + sSQL += " AND '{5}' BETWEEN START_TM AND END_TM "; + + sSQL = string.Format(sSQL + , m_cPosStatus.Base.CmpCd + , m_cPosStatus.Base.BrandCd + , DateTime.Now.ToString("yyyyMMdd") + , m_cPosStatus.Base.StoreNo + , m_cPosStatus.Base.PosNo + , DateTime.Now.ToString("HHmmss")); + + sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (System.Data.SqlClient.SqlParameter[])null, out dtData); + + + if (dtData == null || dtData.Rows.Count == 0) + { + //처리없음! + } + else + { + foreach (DataRow dr in dtData.Rows) + { + if (dr["CMM_GRP_CD"].ToString() == PosConst.COMMON_CODE_GROUP.Z0015 || dr["CMM_GRP_CD"].ToString() == PosConst.COMMON_CODE_GROUP.Z0018) + { + ExecuteHostIrt(dr); + } + else if (dr["CMM_GRP_CD"].ToString() == PosConst.COMMON_CODE_GROUP.Z0016 || dr["CMM_GRP_CD"].ToString() == PosConst.COMMON_CODE_GROUP.Z0019) + { + + if (dr["CMM_GRP_CD"].ToString() == PosConst.COMMON_CODE_GROUP.Z0016 ) + { + string[] aStr = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0570).ToString().Split(new string[] { "\n" }, StringSplitOptions.RemoveEmptyEntries); + + dr["SHOW_MSG1"] = aStr[0]; + dr["SHOW_MSG2"] = aStr[1]; + dr["SHOW_MSG3"] = aStr[2]; + } + else + { + dr["SHOW_MSG1"] = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0571); + } + + dr["READ_FLAG"] = "1"; + + BrPopupUpdate(dr); + } + } + } + + } + 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); + } + } + + /// + /// 디비 업데이트 + /// + /// + /// + private bool BrPopupUpdate(DataRow dr) + { + + bool bRet = false; + string sSQL = ""; + + try + { + sSQL = " UPDATE POSLOG.dbo.ETC_BR_POPUP "; + sSQL += " SET READ_FLAG = '" + dr["READ_FLAG"] + "'"; + sSQL += " ,SHOW_MSG1 = N'" + dr["SHOW_MSG1"] + "'"; + sSQL += " ,SHOW_MSG2 = N'" + dr["SHOW_MSG2"] + "'"; + sSQL += " ,SHOW_MSG3 = N'" + dr["SHOW_MSG3"] + "'"; + sSQL += " WHERE CMP_CD = '" + dr["CMP_CD"] + "'"; + sSQL += " AND BRAND_CD = '" + dr["BRAND_CD"] + "'"; + sSQL += " AND SALE_DT = '" + dr["SALE_DT"] + "'"; + sSQL += " AND STOR_CD = '" + dr["STOR_CD"] + "'"; + sSQL += " AND POS_NO = '" + dr["POS_NO"] + "'"; + sSQL += " AND CMM_GRP_CD = '" + dr["CMM_GRP_CD"] + "'"; + sSQL += " AND CMM_CD = '" + dr["CMM_CD"] + "'"; + + int iRet = sqlDb.DBExecuteNonQuery(sSQL, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + + if (iRet == 1) + bRet = true; + } + catch (Exception ex) + { + WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); + } + + return bRet; + } + + /// + /// 전문 송수신 + /// + /// + /// + /// + /// + /// + /// + /// + private string ExecuteHostIrt(DataRow dr) + { + string sRet = UserCom.RST_ERR; + Hashtable htSendData = new Hashtable(); + Hashtable htRecvData = new Hashtable(); + + try + { + // 조회 + htSendData.Add(Column.IQ_DATA_SEARCH_REQ.DATA.INQ_TYPE, ItemConst.IRT_INQ_TYPE.SERVER_INTERFACE_SCH); + htSendData.Add(Column.IQ_DATA_SEARCH_REQ.DATA.STOR_CD, m_cPosStatus.Base.StoreNo); + htSendData.Add(Column.IQ_DATA_SEARCH_REQ.DATA.POS_NO, m_cPosStatus.Base.PosNo); + htSendData.Add(Column.IQ_DATA_SEARCH_REQ.DATA.STOR_TY, m_cPosStatus.Mst.DrtFrcsDiv); + htSendData.Add(Column.IQ_DATA_SEARCH_REQ.DATA.PRT_DIV, dr["CMM_GRP_CD"].ToString() == PosConst.COMMON_CODE_GROUP.Z0015 ? "100" : "101"); + htSendData.Add(Column.IQ_DATA_SEARCH_REQ.DATA.START_DT, dr["SALE_DT"].ToString()); + htSendData.Add(Column.IQ_DATA_SEARCH_REQ.DATA.END_DT, dr["SALE_DT"].ToString()); + htSendData.Add(Column.IQ_DATA_SEARCH_REQ.DATA.ORD_SEQ, ""); + htSendData.Add(Column.IQ_DATA_SEARCH_REQ.DATA.ORD_GRP, ""); + htSendData.Add(Column.IQ_DATA_SEARCH_REQ.DATA.DATA_CNT, "0"); + htSendData.Add(Column.IQ_DATA_SEARCH_REQ.DATA.RES_DATA, ""); + + + // 전문 요청 + int iRet = IRTSendReceive(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.BizInqPort), + (int)5000, htSendData, ref htRecvData); + + if (iRet != BaseCom.OK || htRecvData.Count == 0) + { + sRet = UserCom.RST_ERR; + return ""; + } + + if (CmUtil.DoubleParse(htRecvData[Column.IQ_DATA_SEARCH_REQ.DATA.DATA_CNT].ToString()) <= 0) + { + //sRet = UserCom.RST_ERR; + //return ""; + string sLogtemp = string.Format("BizCmmcd : {0}, RecvCount : {1} >> Skip", dr["CMM_GRP_CD"], htRecvData[Column.IQ_DATA_SEARCH_REQ.DATA.DATA_CNT]); + + 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 (함수명)) + sLogtemp); + } + + sRet = htRecvData[Column.IQ_DATA_SEARCH_REQ.DATA.RES_DATA].ToString(); + + if (dr["CMM_GRP_CD"].ToString() == PosConst.COMMON_CODE_GROUP.Z0015) + { + if (sRet.StartsWith("N") == true) // CmUtil.MidH(sRet, 0, 1) == "N") + { + dr["SHOW_MSG1"] = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0572); + dr["READ_FLAG"] = "1"; + } + else + { + dr["READ_FLAG"] = "2"; + } + } + else + { + if (sRet.StartsWith("Y") == true) + { + dr["SHOW_MSG1"] = sRet.Substring(2); + dr["READ_FLAG"] = "1"; + } + else + { + dr["READ_FLAG"] = "2"; + } + } + + BrPopupUpdate(dr); + + sRet = UserCom.RST_OK; + } + catch (Exception ex) + { + WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); + } + return sRet; + } + #endregion + + #region 로그파일 업로드 처리 + private int UploadLogFileProc(Hashtable htRecvData, ref string sFileNm) + { + int iRet = BaseCom.NG; + string sUploadedFileNm = ""; + ZipFile zip = null; + + try + { + // 01 - 요청 받은 로그 파일 압축 + string[] sFiles = Directory.GetFiles(BaseCom.NxLogPath, "*" + htRecvData[Column.IQ_POS_LOGFILE_REQ.DATA.LOG_DT].ToString().Substring(2) + ".log*"); + + if(sFiles.Length > 0) + { + sUploadedFileNm = htRecvData[Column.IQ_POS_LOGFILE_REQ.DATA.LOG_DT].ToString() + "_" + m_cPosStatus.Base.StoreNo + "_" + m_cPosStatus.Base.PosNo + ".zip"; + zip = ZipFile.Create(BaseCom.NxLogPath + sUploadedFileNm); + + zip.BeginUpdate(); + foreach(string sFile in sFiles) + { + zip.Add(sFile, Path.GetFileName(sFile)); + } + zip.CommitUpdate(); + zip.Close(); + zip = null; + } + else + { + // 요청받은 일자의 로그가 없음 + return BaseCom.NG1; + } + + // 02 - 압축 파일 Upload + string sIp = htRecvData[Column.IQ_POS_LOGFILE_REQ.DATA.FTP_IP].ToString(); + string sPort = htRecvData[Column.IQ_POS_LOGFILE_REQ.DATA.FTP_PORT].ToString(); + string sUserId = htRecvData[Column.IQ_POS_LOGFILE_REQ.DATA.FTP_ID].ToString(); + string sUserPwd = htRecvData[Column.IQ_POS_LOGFILE_REQ.DATA.FTP_PWD].ToString(); + + FTP cFtp = new FTP(sIp, sUserId, sUserPwd); + + bool bRtn = cFtp.Upload(BaseCom.NxLogPath + sUploadedFileNm, htRecvData[Column.IQ_POS_LOGFILE_REQ.DATA.FTP_PATH].ToString() + @"/" + sUploadedFileNm ); + + if (bRtn == true) + iRet = BaseCom.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); + } + finally + { + if (zip != null) + zip.Close(); + + if(File.Exists(BaseCom.NxLogPath + sUploadedFileNm) == true) + { + File.Delete(BaseCom.NxLogPath + sUploadedFileNm); + } + } + + return iRet; + } + #endregion 로그파일 업로드 처리 + + //17.08.22 dkshin SS 해피오더 + #region SS 해피오더 자동 처리 + /// + /// 최종 거래번호 설정 + /// + /// + public string LoadLastPosTradeNo(string SSPosno) + { + string sQuery = ""; + string sRet = UserCom.RST_ERR; + DataTable dtTradeInfo = null; + + try + { + // 최종거래번호 로딩 + sQuery = " SELECT ISNULL(MAX(TRADE_NO),0) TRADE_NO FROM POSLOG..TR_SALE_HEADER "; + sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sQuery += " AND SALE_DT = '" + m_cPosStatus.Base.SaleDate + "' "; + sQuery += " AND POS_NO = '" + SSPosno + "' "; + //sQuery += " AND TRADE_KINDPER NOT IN('90','91','92','93') "; + + //DataTable dtTradeInfo = m_cMstService.Select(new string[] { sQuery }); + sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (System.Data.SqlClient.SqlParameter[])null, out dtTradeInfo); + + if (dtTradeInfo != null && dtTradeInfo.Rows.Count > 0) + { + DataRow dr = dtTradeInfo.Rows[0]; + + int nTradeNo = (int)CmUtil.LongParse(CmUtil.GetDataRowStr(dr, "TRADE_NO")); + //if (CmUtil.LongParse(m_cPosStatus.Base.TradeNo) <= nTradeNo) + { + m_cPosStatus.Base.TradeNo = string.Format("{0:D5}", nTradeNo + 1); + } + } + } + catch (Exception ex) + { + WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); + } + + return sRet; + } + + private void SSHappyOrderList() + { + Hashtable htRequest = new Hashtable(); + Hashtable htResponse = new Hashtable(); + int iReturn = BaseCom.NG; + + htRequest.Add("storeCode", m_cPosStatus.Base.StoreNo); + htRequest.Add("status", ItemConst.HAPPYORDER_STATUS.ORDER_REG); + htRequest.Add("deviceType", "POS"); + + //해피오더 주문내역 조회 - 픽업시간 + m_htOrderLists = null; + m_htOrderLists = m_cHappyOrder.SendReceiveForHappyOrder(new object[] { m_sHappyOrderURL, ItemConst.HAPPYORDER_WORK_TYPE.SELECT_ORDER_LIST, htRequest }, ref htResponse, ref iReturn); + + if (iReturn != BaseCom.OK) + { + return; + } + } + + private void SSHappyOrderStatusChange(Column.TR_HPORD.HPORD_HEADER cHeader, string statusValue) + { + Hashtable htRequest = new Hashtable(); + Hashtable htResponse = new Hashtable(); + + int iReturn = BaseCom.NG; + ArrayList m_cHappyOrderItem = new ArrayList(); + + htRequest.Add("deviceType", "POS"); + htRequest.Add("orderNum", cHeader.OrderNum); + //#12504 해피오더 외부채널 직접 주문 관련 수정 start, phj + //htRequest.Add("channel", cHeader.Channel); + //#12504 해피오더 외부채널 직접 주문 관련 수정 end, phj + htRequest.Add("cancelReasonType", ""); + htRequest.Add("status", statusValue); + + // 주문상태변경 + m_cHappyOrder.SendReceiveForHappyOrder(new object[] { m_sHappyOrderURL, ItemConst.HAPPYORDER_WORK_TYPE.UPDATE_STATUS, htRequest }, ref htResponse, ref iReturn); + + if (htResponse == null || htResponse.ContainsKey("status") == false) + { + 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 (함수명)) + "OrderNum = " + cHeader.OrderNum + ", 상태변경 처리 실패"); + + //return false; + } + if (htResponse["status"].ToString().Equals("200") == false) + { + 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 (함수명)) + "OrderNum = " + cHeader.OrderNum + ", 상태변경 처리 실패(" + htResponse["message"].ToString() + ")"); + + //return false; + } + else + { + 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 (함수명)) + "OrderNum = " + cHeader.OrderNum + ", 상태변경 처리 완료"); + + // 정상 처리 + //bReturn = true; + + //#20171019 SS해피오더 배달 start + //기존 + //if (statusValue == ItemConst.HAPPYORDER_STATUS.PICKUP_WAIT) + //변경 + if ((statusValue == ItemConst.HAPPYORDER_STATUS.PICKUP_WAIT) || (statusValue == ItemConst.HAPPYORDER_STATUS.DELIVERY_REQ)) + //#20171019 SS해피오더 배달 end + { + //영양정보 저장? + Hashtable[] aResponse = null; + Hashtable htRequestForNutrition = new Hashtable(); + htResponse = null; + + htRequestForNutrition.Add("orderNum", cHeader.OrderNum); + + aResponse = m_cHappyOrder.SendReceiveForHappyOrder(new object[] { m_sHappyOrderURL, ItemConst.HAPPYORDER_WORK_TYPE.SELECT_PRODUCT_NUTRITION, htRequestForNutrition }, ref htResponse, ref iReturn); + + if (aResponse != null && aResponse.Length > 0) + { + string sMsg = m_cHappyOrder.ParseNutritionMsg(aResponse); + if (sMsg != "") + { + 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 (함수명)) + "OrderNum = " + cHeader.OrderNum + ", 영양정보 = " + sMsg); + + // 영양정보 저장 + //#20180129 SS해피오더 자동처리 DB작업 수정 start + //기존 + //m_cHappyOrder.UpdateHappyOrderData(new string[] { "Message", sMsg, cHeader.OrderNum, cHeader.OrderDate }); + //변경 + UpdateHappyOrderData(new string[] { "Message", sMsg, cHeader.OrderNum, cHeader.OrderDate }); + //#20180129 SS해피오더 자동처리 DB작업 수정 end + } + } + + //grayber@20180202 [BR]해피오더 고객정보 추가 + 원산지 표기 start - 영양정보 호출 함수 처리 + //m_cHappyOrder.GetHappyOrderNurtitionListDetail(sOrderNum, m_sHappyOrderURL, sOrderDt); + //grayber@20180202 [BR]해피오더 고객정보 추가 + 원산지 표기 end + + //매출처리 + //해피오더 리스트 상세 조회 + m_cHappyOrder.GetHappyOrderListDetail(cHeader.OrderNum, m_sHappyOrderURL, ref m_cHappyOrderItem, ref m_htOrderLists); + + int itemCnt = m_cHappyOrderItem.Count; + ArrayList itemList = new ArrayList(); + for (int i = 0; i < itemCnt; i++) + { + Column.TR_HPORD.HPORD_ITEM item = (Column.TR_HPORD.HPORD_ITEM)m_cHappyOrderItem[i]; + item.PickupTime = cHeader.PickupTime; + itemList.Add(item); + } + m_cHappyOrderItem.Clear(); + m_cHappyOrderItem = new ArrayList(itemList); + + + //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 start + + //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 start - 20180723 기존 배달 건만이였지만 픽업건도 동일하게 적용하도록 수정 + //if (statusValue == ItemConst.HAPPYORDER_STATUS.DELIVERY_REQ) + //{ + //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 end - 20180723 기존 배달 건만이였지만 픽업건도 동일하게 적용하도록 수정 + bool bLandomBoxCheck = false; + + DataTable dtData = null; + for (int nLoop = 0; nLoop < m_cHappyOrderItem.Count; nLoop++) + { + Column.TR_HPORD.HPORD_ITEM item = (Column.TR_HPORD.HPORD_ITEM)m_cHappyOrderItem[nLoop]; + + dtData = m_cDataCommon.SeletCommonCode(PosConst.COMMON_CODE_GROUP.T0039, ""); + if (dtData != null && dtData.Rows.Count > 0) + { + foreach (DataRow dr in dtData.Rows) + { + if (item.GoodsCode == CmUtil.GetDataRowStr(dr, PosMst.MST_COMMON.DATA.CHAR_VAL_TITLE_VAL_01)) + { + bLandomBoxCheck = true; + break; + } + } + } + + if (bLandomBoxCheck == true) + { + return; + } + } + //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 start - 20180723 기존 배달 건만이였지만 픽업건도 동일하게 적용하도록 수정 + //} + //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 end - 20180723 기존 배달 건만이였지만 픽업건도 동일하게 적용하도록 수정 + + //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 end + + //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 start + //기존 + //string sRet = m_cHappyOrder.MakeTranItem((Column.TR_HPORD.HPORD_HEADER)cHeader, m_cHappyOrderItem); + //변경 + string sRet = m_cHappyOrder.MakeTranItem((Column.TR_HPORD.HPORD_HEADER)cHeader, m_cHappyOrderItem, null); + //#15746 해피오더 '쇼킹박스' 관련 POS 시스템 개발 요청 end + + if (sRet == UserCom.RST_OK) + { + m_cTrnStatus.Head.TradeKind = ItemConst.TRAN_KIND.FORIGN.O2O; + + //#20171227 인천공항 포스연동 start, phj - 20180310 해피오더 결제완료 start,phj + //m_cPosStatus.Sale.SaleFlow = PosConst.SALE_FLOW.SALE_DOING; + //#20171227 인천공항 포스연동 end, phj - 20180310 해피오더 결제완료 end,phj + + m_cTrnStatus.Head.OrderNo = cHeader.DailyCode;//판매POS의 매출처리시 대기번호도 해당 대기번호로 저장해야 함. + String sPosno = m_cPosStatus.Base.PosNo; + String sTradeNo = m_cPosStatus.Base.TradeNo; + m_cPosStatus.Base.PosNo = PosMstManager.GetPosOption(POS_OPTION.OPT048); + LoadLastPosTradeNo(PosMstManager.GetPosOption(POS_OPTION.OPT048));//별도 포스번호별 거래번호 처리 + m_cTrnStatus.Sale.SSHappyOrderSalePrint = true;//매출 처리 시 영수증 출력 하지 않음 설정. + m_cTrnStatus.Head.HPOrderPickupTime = cHeader.PickupTime;//20170918 dkshin 해피오더 중복 거래 완료처리 수정 + + + IPaymentUs cPaymentUs = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.HAPPYORDER); + + //#11054_[공통] 해피오더 외부채널 표시 방식 변경 적용 요청 + sRet = cPaymentUs.SetPayment(new string[] { ItemConst.TR_ITEM_ID.ORDER.HAPPYORDER_PAY, ItemConst.TR_ITEM_ID.ORDER_TYPE.PICKUP, cHeader.PayMoney, cHeader.OrderNum, cHeader.OrderDate }); + + if (sRet != UserCom.RST_OK) + return; + + // 거래 완료 처리 + ISaleCompleteUs cSaleComplete = (ISaleCompleteUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.SALE_COMPLETE); + sRet = cSaleComplete.PosSaleExecute(new string[] { }); + if (sRet != UserCom.RST_OK) + return; + + // 해피오더 데이터 삭제 + //#20180129 SS해피오더 자동처리 DB작업 수정 start + //기존 + //m_cHappyOrder.DeleteSSHappyOrderData(cHeader.DailyCode, cHeader.OrderDate.Substring(0, 10).Replace("-", "")); + //변경 + DeleteSSHappyOrderData(cHeader.DailyCode, cHeader.OrderDate.Substring(0, 10).Replace("-", "")); + //#20180129 SS해피오더 자동처리 DB작업 수정 end + + // KDS전송 + //20170918 dkshin 해피오더 중복 거래 완료처리 수정 + // 거래완료처리에서 주방주문 데이타 작성 + //m_cHappyOrder.KPSItemProc(ItemConst.TRAN_DIV.NORMAL, m_cHappyOrderItem); + + // 판매상태 변경 + //#20171227 인천공항 포스연동 start, phj - 20180310 해피오더 결제완료 start,phj + //m_cPosStatus.Sale.SaleFlow = PosConst.SALE_FLOW.SALE_WAIT; + //#20171227 인천공항 포스연동 end, phj - 20180310 해피오더 결제완료 end,phj + m_cPosStatus.Base.PosNo = sPosno; + m_cPosStatus.Base.TradeNo = sTradeNo; + + } + else + { + 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 (함수명)) + MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0638)); + } + } + } + + + } + + private void SSHappyOrderAutoProcess() + { + Hashtable htRequest = new Hashtable(); + Hashtable htResponse = new Hashtable(); + ArrayList m_alPickupLists = new ArrayList(); + + DateTime pickupTenMinAgo; + DateTime pickupSevenMinAgo; + DateTime pickuptime; + DateTime nowTime = DateTime.Now; + //DateTime tenMinAgoTime = DateTime.Now.AddMinutes(-10); + //DateTime sevenMinAgoTime = DateTime.Now.AddMinutes(-7); + string s_Pickuptime; + int yyyy, mm, dd, hh, mi; + + SSHappyOrderList();//해피오더 주문내역 조회 - 픽업시간 + + //#20171215, 해피오더 주문리스트 조회 시 해피오더 테이블 데이터 삭제 후 저장하도록 수정 Start + // 해피오더 헤더정보 DB 삭제 + + //#20180129 SS해피오더 자동처리 DB작업 수정 start + //기존 + //m_cHappyOrder.DeleteHappyOrderAllData(); + //변경 + DeleteHappyOrderAllData(); + //#20180129 SS해피오더 자동처리 DB작업 수정 end + + //#20171215, 해피오더 주문리스트 조회 시 해피오더 테이블 데이터 삭제 후 저장하도록 수정 End + + if (m_htOrderLists != null && m_htOrderLists.Length > 0) + { + foreach (Hashtable htData in m_htOrderLists) + { + Column.TR_HPORD.HPORD_HEADER header; + header = m_cHappyOrder.ParseHappyOrderList(htData); + //#20171215, 해피오더 주문리스트 조회 시 해피오더 테이블 데이터 삭제 후 저장하도록 수정 Start + // 해피오더 헤더정보 DB 처리 + + //#20180129 SS해피오더 자동처리 DB작업 수정 start + //기존 + //m_cHappyOrder.SaveHappyOrderData(header); + //변경 + SaveHappyOrderData(header); + //#20180129 SS해피오더 자동처리 DB작업 수정 end + + //#20171215, 해피오더 주문리스트 조회 시 해피오더 테이블 데이터 삭제 후 저장하도록 수정 End + m_alPickupLists.Add(header); + } + } + + Column.TR_HPORD.HPORD_HEADER cHeader; + for (int i = 0; i < m_alPickupLists.Count; i++) + { + s_Pickuptime = ((Column.TR_HPORD.HPORD_HEADER)m_alPickupLists[i]).PickupTime; + yyyy = Convert.ToInt32(s_Pickuptime.Substring(0, 4)); + mm = Convert.ToInt32(s_Pickuptime.Substring(5, 2)); + dd = Convert.ToInt32(s_Pickuptime.Substring(8, 2)); + hh = Convert.ToInt32(s_Pickuptime.Substring(14, 2)); + mi = Convert.ToInt32(s_Pickuptime.Substring(17, 2)); + + + pickuptime = new DateTime(yyyy, mm, dd, hh, mi, 00); + pickupTenMinAgo = pickuptime.AddMinutes(-10); + pickupSevenMinAgo = pickuptime.AddMinutes(-7); + + //픽업시간 10분전 '상품준비'로 상태 변경 + if (DateTime.Compare(pickupTenMinAgo, nowTime) < 0) + { + cHeader = null; + cHeader = (Column.TR_HPORD.HPORD_HEADER)m_alPickupLists[i]; + + if (cHeader.OrderStatus == ItemConst.HAPPYORDER_STATUS.ORDER_REG) + SSHappyOrderStatusChange(cHeader, ItemConst.HAPPYORDER_STATUS.PRODUCT_READY); + } + //픽업시간 7분전 '픽업대기'로 상태 변경 + if (DateTime.Compare(pickupSevenMinAgo, nowTime) < 0) + { + cHeader = null; + cHeader = (Column.TR_HPORD.HPORD_HEADER)m_alPickupLists[i]; + + //OrderStatus 상태값(주문접수:4, 상품준비:5, 픽업대기:7, 픽업완료:8) + //'상품준비' 상태가 아니면 '상품준비'로 상태 변경 (픽업시간 10분전을 지나고 판매포스를 킨경우 상태값이 주문접수이므로 상품준비로 변경) + if (cHeader.OrderStatus == ItemConst.HAPPYORDER_STATUS.ORDER_REG) + { + SSHappyOrderStatusChange(cHeader, ItemConst.HAPPYORDER_STATUS.PRODUCT_READY); + } + + //'상품준비' 상태이면 '픽업대기'로 상태 변경 -> 매출처리 -> KDS 전송 + if (cHeader.OrderStatus == ItemConst.HAPPYORDER_STATUS.PRODUCT_READY) + { + //#20171019 SS해피오더 배달 start + //기존 + //SSHappyOrderStatusChange(cHeader, ItemConst.HAPPYORDER_STATUS.PICKUP_WAIT); + //변경 + if ((cHeader.OrderType == ItemConst.ORDER_TYPE.INNER_DELIVERY) || (cHeader.OrderType == ItemConst.ORDER_TYPE.OUTTER_DELIVERY)) + { + SSHappyOrderStatusChange(cHeader, ItemConst.HAPPYORDER_STATUS.DELIVERY_REQ); + } + else + { + SSHappyOrderStatusChange(cHeader, ItemConst.HAPPYORDER_STATUS.PICKUP_WAIT); + } + //#20171019 SS해피오더 배달 end + } + + //if (cHeader.OrderStatus == ItemConst.HAPPYORDER_STATUS.PICKUP_WAIT) + { + // SSHappyOrderStatusChange(cHeader, ItemConst.HAPPYORDER_STATUS.PICKUP_COMPLETED); + } + } + + + } + + } + + //#20180129 SS해피오더 자동처리 DB작업 수정 start + + /// + /// 해피오더 데이터 갱신 + /// + /// + /// + public int UpdateHappyOrderData(string[] aParam) + { + int iRet = UserCom.NG; + string sUpdQuery = ""; + + try + { + sUpdQuery = " UPDATE POSMST..MST_HPORD "; + if (aParam[0] == "PRINT") + { + sUpdQuery += "SET PRT_YN = '" + aParam[1] + "' "; + } + else + { + //sUpdQuery += "SET NUTRITION_MSG = REPLACE('" + aParam[1] + "', CHAR(10), CHAR(13) + CHAR(10))"; + sUpdQuery += "SET NUTRITION_MSG = '" + aParam[1] + "' "; + } + sUpdQuery += " , UPD_DT = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + sUpdQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sUpdQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sUpdQuery += " AND ORD_DT = '" + aParam[3] + "' "; + sUpdQuery += " AND ORD_NO = '" + aParam[2] + "' "; + + iRet = sqlDb.DBExecuteNonQuery(sUpdQuery, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + + } + 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 iRet; + } + + /// + /// 해피오더 데이터 삭제 MST_HPORD + /// + /// + /// + public int DeleteSSHappyOrderData(string sOrderNum, string sOrderDt) + { + int iRet = UserCom.NG; + string sQuery = ""; + + try + { + sQuery = " DELETE FROM POSMST..MST_HPORD \n" + + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + + " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + + " AND ORD_DT = '" + sOrderDt + "' \n" + + " AND ORD_NO = '" + sOrderNum + "' \n"; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + } + 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 iRet; + } + + /// + /// 해피오더 데이터 전체 삭제 + /// + /// + public int DeleteHappyOrderAllData() + { + int iRet = UserCom.NG; + string sQuery = ""; + + try + { + sQuery = "TRUNCATE TABLE POSMST..MST_HPORD \n"; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + } + 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 iRet; + } + + /// + /// 해피오더 데이터 저장 + /// + /// + /// + public int SaveHappyOrderData(Column.TR_HPORD.HPORD_HEADER header) + { + int iRet = UserCom.NG; + string sQuery = ""; + string sSQL = ""; + + try + { + sQuery = "UPDATE POSMST..MST_HPORD "; + sQuery += " SET ORD_STS = '{0}' "; + sQuery += " , UPD_DT = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + sQuery += " WHERE CMP_CD = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + sQuery += " AND ORD_NO = '{3}' "; + sQuery += "IF @@ROWCOUNT = 0 "; + sQuery += "INSERT INTO POSMST..MST_HPORD "; + sQuery += " ( CMP_CD, STOR_CD, ORD_DT, ORD_NO, ORD_STS "; + sQuery += " , PRT_YN, NUTRITION_MSG, FILLER1, FILLER2, FILLER3 "; + sQuery += " , FILLER4, FILLER5, UPD_DT, REG_DT ) "; + sQuery += "VALUES "; + sQuery += " ( '{4}', '{5}', '{6}', '{7}', '{8}' "; + sQuery += " , '{9}', '{10}', '{11}', '{12}', '{13}' "; + sQuery += " , '{14}', '{15}' ,'{16}', '{17}' ) "; + + //17.08.22 dkshin SS 해피오더 - dailyCode값 대기번호가 TBL_NO으로 저장되므로 ORDER_NO에 대기번호 저장 + string orderNum = header.OrderNum; + if (PosMstManager.GetPosOption(POS_OPTION.OPT048) != "0" || PosMstManager.GetPosOption(POS_OPTION.OPT049) == "1") + { + orderNum = header.DailyCode; + } + sSQL = string.Format(sQuery, + header.OrderStatus, + m_cPosStatus.Base.CmpCd, + m_cPosStatus.Base.StoreNo, + //17.08.22 dkshin SS 해피오더 + //header.OrderNum, + orderNum, + + m_cPosStatus.Base.CmpCd, + m_cPosStatus.Base.StoreNo, + header.OrderDate.Substring(0, 10).Replace("-", ""), + //17.08.22 dkshin SS 해피오더 + //header.OrderNum, + orderNum, + + header.OrderStatus, + "0", + "", + "", "", "", "", "", + DateTime.Now.ToString("yyyyMMddHHmmss"), + DateTime.Now.ToString("yyyyMMddHHmmss")); + + iRet = sqlDb.DBExecuteNonQuery(sSQL, System.Data.CommandType.Text, (System.Data.SqlClient.SqlParameter[])null); + } + 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 iRet; + } + + //#20180129 SS해피오더 자동처리 DB작업 수정 end + + #endregion + + //#15884 해피오더 실시간 추가재고 등록메뉴 및 알람기능 개발 start + #region 해피오더 실시간 추가재고 등록메뉴 및 알람기능 개발 + /// + /// 해피오더 실시간 추가재고 등록메뉴 및 알람기능 개발 + /// + private void HappyOrderInventoryAlram() + { + Hashtable htRecvData = new Hashtable(); + Hashtable htSendData = new Hashtable(); + + //#17317 PB 안산성포 외- 포스사용중 [고객센터로 연락주세요] 팝업뜨는 증상 start + //기존 + //string sRet = UserCom.RST_ERR; + //변경 + int iRet = 0; + //#17317 PB 안산성포 외- 포스사용중 [고객센터로 연락주세요] 팝업뜨는 증상 end + + string sHPO_Inventory_YN = ""; + try + { + htSendData.Add(Column.IQ_HPO_INVENTORY_ALRAM.DATA.INQ_TYPE, ItemConst.IRT_INQ_TYPE.HPO_INVENTORY_ALARM); + htSendData.Add(Column.IQ_HPO_INVENTORY_ALRAM.DATA.RES_YN, ""); + htSendData.Add(Column.IQ_HPO_INVENTORY_ALRAM.DATA.RES_CD, ""); + + //#17317 PB 안산성포 외- 포스사용중 [고객센터로 연락주세요] 팝업뜨는 증상 start + //기존 + //sRet = m_cDataCommon.ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.SysInfoPort, 5000, htSendData, ref htRecvData, false); + //변경 + iRet = IRTSendReceive(m_cPosStatus.Base.CommSvrIp, Convert.ToInt32(m_cPosStatus.Base.SysInfoPort), (int)5000, htSendData, ref htRecvData); + //#17317 PB 안산성포 외- 포스사용중 [고객센터로 연락주세요] 팝업뜨는 증상 end + + //#17317 PB 안산성포 외- 포스사용중 [고객센터로 연락주세요] 팝업뜨는 증상 start + //기존 + //if (sRet == UserCom.RST_OK) + //변경 + if (iRet == BaseCom.OK) + { + //#17317 PB 안산성포 외- 포스사용중 [고객센터로 연락주세요] 팝업뜨는 증상 end + + //#17317 PB 안산성포 외- 포스사용중 [고객센터로 연락주세요] 팝업뜨는 증상 start + if (htRecvData != null) + { + //#17317 PB 안산성포 외- 포스사용중 [고객센터로 연락주세요] 팝업뜨는 증상 end + + if (htRecvData[Column.IQ_HPO_INVENTORY_ALRAM.DATA.RES_CD].ToString() == "00") + { + sHPO_Inventory_YN = htRecvData[Column.IQ_HPO_INVENTORY_ALRAM.DATA.RES_YN].ToString(); + } + + //#17317 PB 안산성포 외- 포스사용중 [고객센터로 연락주세요] 팝업뜨는 증상 start + } + //#17317 PB 안산성포 외- 포스사용중 [고객센터로 연락주세요] 팝업뜨는 증상 end + } + + m_cPosStatus.Sale.HappyOrderInventoryYN = sHPO_Inventory_YN.Trim(); + } + catch (Exception ex) + { + WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + ex.Message); + } + } + #endregion + //#15884 해피오더 실시간 추가재고 등록메뉴 및 알람기능 개발 end + } +} diff --git a/Agent/NetworkCheckOver/NetworkCheckOver.csproj b/Agent/NetworkCheckOver/NetworkCheckOver.csproj new file mode 100644 index 0000000..6a3440f --- /dev/null +++ b/Agent/NetworkCheckOver/NetworkCheckOver.csproj @@ -0,0 +1,96 @@ + + + + + Debug + AnyCPU + {D7F0F611-E694-47D5-AB09-8C5514B04B6F} + Library + Properties + Cosmos.Network + Agent.NetworkCheckOver + v4.0 + 512 + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\BIN\Cosmos.BaseFrame.dll + + + False + ..\..\..\BIN\Cosmos.ServiceProvider.dll + + + False + ..\..\..\BIN\Cosmos.UserFrame.dll + + + False + ..\..\..\BIN\ICSharpCode.SharpZipLib.dll + + + False + ..\..\..\BIN\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + {670a81be-cee3-4c29-846d-a37652ca270d} + CommonManager + + + {a5b7accd-79eb-4261-bd36-01ab484ad8e3} + Common + + + + + copy .\IC\Agent.NetworkCheckOver.dll .\Agent.NetworkCheckOver.dll + + + copy .\Agent.NetworkCheckOver.dll .\IC\Agent.NetworkCheckOver.dll + + + \ No newline at end of file diff --git a/Agent/NetworkCheckOver/Properties/AssemblyInfo.cs b/Agent/NetworkCheckOver/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..19db2ed --- /dev/null +++ b/Agent/NetworkCheckOver/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("NetworkCheckOver")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("NetworkCheckOver")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("e0c7ddd1-3d25-472c-ad5c-7373ebeb2640")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Agent/NetworkTranSend/Activator.cs b/Agent/NetworkTranSend/Activator.cs new file mode 100644 index 0000000..fbba075 --- /dev/null +++ b/Agent/NetworkTranSend/Activator.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : Network 관련 클래스 Activator +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.Service +{ + /// + /// Load BaseFrame and save information (BaseFrame의 로드하고 정보를 보관한다) + /// + public class Activator : InitServiceAbstract + { + /// + /// Define main entrance point of project load. (프로젝트 로드의 주진입점을 정의합니다.) + /// + public Activator() + { + + } + + /// + /// + /// + /// + /// + public override object InitServiceInstance(string sClassNm) + { + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Starting !!!"); + + object retObj = null; + + //클래스 찾아오기 위함 + switch (sClassNm) + { + case ServiceLists.AGENT_NETWORK_TRANSEND.NetworkTranSend: + { + Cosmos.Network.NetworkTranSend agentClass = new Cosmos.Network.NetworkTranSend(); + retObj = agentClass; + break; + } + } + + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Completed !!!"); + + return retObj; + + } + } +} diff --git a/Agent/NetworkTranSend/NetworkTranSend.cs b/Agent/NetworkTranSend/NetworkTranSend.cs new file mode 100644 index 0000000..2915e3f --- /dev/null +++ b/Agent/NetworkTranSend/NetworkTranSend.cs @@ -0,0 +1,7145 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Data; +using System.Data.SqlClient; + +using Cosmos.Common; +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.CommonManager; +using Cosmos.ServiceProvider; + +using Newtonsoft.Json; +using System.Xml; +using System.IO; +using System.Net; +using System.Runtime.InteropServices; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : 통신서버로 +// 01:Tran/02:저널/03:서명/04:전자영수증/05:현금IC/06:기타서명 데이터 100ms간격, 전송 +// 실패시 에러카운트증가시켜 1회 이상부터 5초로 조정. +// 실패시 에러카운트증가시켜 5회 이상부터 1분으로 조정. +// 성공시 에러카운트감소시켜 0으로 초기화 되면 다시 100ms로 조정. +// 전송할 데이터 없을 시 5초로 조정. +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.Network +{ + public class NetworkTranSend : INetworkTranSend + { + #region 한국공항공사 I/F 관련 MKACCLT.dll 함수정의 + ///// + ///// 프로그램 시작 + ///// + ///// + //[DllImport("MKACCLT.dll")] + //public static extern int MKACCLTOpen(); + ///// + ///// 매출저장 + ///// + ///// 매출구분(4) + ///// 계약구분(10) + ///// 영업일자(8) + ///// 매장정보(10) + ///// POS번호(10) + ///// 영수증번호(30) + ///// 매출정보(Variable) + ///// 아이템건수(4) + ///// 아이템정보(Variable) + ///// + //[DllImport("MKACCLT.dll")] + //public static extern int ReceiptDB(string pSendType, string pConNo, string pSaleDt, string pStorCd, string pPosNo, string pReceiptNo, string sTranHeader, int iItemCount, string sTranItem); + ///// + ///// 프로그램 종료 + ///// + ///// + //[DllImport("MKACCLT.dll")] + //public static extern int MKACCLTClose(); + + #endregion 한국공항공사 I/F 관련 MKACCLT.dll 함수정의 + + #region 클래스 변수 선언 + /// + /// Sending Socket (전송 소켓) + /// + private static TcpSocket m_sendSocket = null; + + /// + /// IP + /// + private string m_ServerIp = ""; + + /// + /// Port + /// + private int m_ServerPort = 0; + + /// + /// + /// + private int m_ServerTimeout = 1; + + protected SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출 + + /// + /// StateServer Object (StateServer 객체) + /// + private StateServer StateObject = (StateServer)StateServer.GetInstance(); + + /// + /// POS Status Value (POS 상태값) + /// + private PosStatus m_cPosStatus = null; + + + //#20180322 휴게소pos매출연동 start,phj + private IDataCommonUs m_cDataCommon = null; + //#20180322 휴게소pos매출연동 end,phj + + /// + /// IRT 통신 + /// + private bool m_bIRTComplete = false; // 통신 완료 상태 + Hashtable m_htRecvData = null; // 통신 수신 데이터 (JSON) + /// + /// Sending Socket (전송 소켓) + /// + private static TcpSocket m_IrtSocket = null; + + /// + /// Thread Waiting Time (스레드 대기시간) + /// + private int m_ThreadSleepTerm = 100; + + /// + /// Recv Timeout 정의 + /// + //private int m_RecvTimeout = 10000; + + /// + /// Server Send Operation Yes/No (SVR Send 작동여부) + /// + private bool m_TranSVRSendRunning = true; + + /// + /// Server SEND Thread (Server SEND 스레드) + /// + private Thread m_tSVRSend = null; + /// + /// 전송할 데이터 건수가 0 일 때, 0 설정 + /// + private int iSendDataCnt = 0; + /// + /// CommHeader 길이 + /// + private int CommHeadLen = 0; + + /// + /// TranSend 응답 에러발생이 지속될 경우 ThreadTerm을 조정하기 위함 + /// iErrorCount 가 5 이상이면 Thread Term을 1분으로 조정하며, 다시 0으로 돌아가면 1초로 조정 + /// + private int iErrorCount = 0; + + private int iOldErrorCount = 0; + + /// + /// 기동하면서 읽어 온 통신서버 IP + /// + private string sCommSvrIp = string.Empty; + + /// + /// MSSQL DB 관련 객체 + /// + private static SqlDB sqlDb = null; + + ///// + ///// 고속도로 휴게소 POS 매출DATA 전송 URL + ///// + //private string sExTranUrl = string.Empty; + + ///// + ///// 고속도로 휴게소 POS 정산DATA 전송 URL + ///// + //private string sExCalcUrl = string.Empty; + + #endregion + + #region 생성자 + public NetworkTranSend() + { + m_cPosStatus = (PosStatus)StateObject.POS; + CommHeadLen = ItemColumn.LenMessage(Column.COMM_HEADER.LEN); + + //#20180322 휴게소pos매출연동 end,phj + CommHeadLen = ItemColumn.LenMessage(Column.COMM_HEADER.LEN); + //m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON); + + //#20180322 휴게소pos매출연동 start,phj + m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON); + //#20180322 휴게소pos매출연동 end,phj + } + #endregion + + #region TranSend Thread Start/Stop + /// + /// Server Send Thread Start + /// + public void StartTranSend() + { + this.sCommSvrIp = m_cPosStatus.Base.CommSvrIp; + + sqlDb = new SqlDB(m_cPosStatus.Base.LocalDbSource, m_cPosStatus.Base.LocalDbCatalog, m_cPosStatus.Base.LocalDbUserID, m_cPosStatus.Base.LocalDbPassword); + + //SetExUrl(); + + // 한국공항공사 매출 I/F 프로그램 실행 + //if (m_cPosStatus.Mst.ETC_IF_DIV == ItemConst.TranInterfaceOutside.IF_KOR_02) + //{ + // int iRet = MKACCLTOpen(); + // if(iRet == 0) + // { + // UserLog.WriteLogFile(UserCom.LOG_ERROR, + // UserCom.WARNING_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 (함수명)) + // "* 공항공사 MKACCLT.dll [ MKACCLT.dll Open Call. ]"); + // } + //} + + m_tSVRSend = new Thread(new ThreadStart(ThreadSVRSendRun)); + m_TranSVRSendRunning = true; + m_tSVRSend.Start(); + } + + /// + /// NetworkTranSend Thread Stop시 처리 + /// + public void StopTranSend() + { + try + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "NetworkTranSend Service Stop!!!"); + // 통신서버 Send Terminated (SC Send 종료) + m_TranSVRSendRunning = false; + + int count = 0; + while (count < 10) + { + if (m_tSVRSend != null && m_tSVRSend.IsAlive) m_TranSVRSendRunning = false; + else break; + + count++; + Thread.Sleep(300); + } + + if (count >= 10) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 NetworkTranSend Service Stop!!!"); + m_tSVRSend.Abort(); + } + + // DB Close + sqlDb.DBClose(); + + // 한국공항공사 매출 I/F 프로그램 종료 + //if (m_cPosStatus.Mst.ETC_IF_DIV == ItemConst.TranInterfaceOutside.IF_KOR_02) + //{ + // int iRet = MKACCLTClose(); + // if (iRet == 0) + // { + // UserLog.WriteLogFile(UserCom.LOG_ERROR, + // UserCom.WARNING_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 (함수명)) + // "* 공항공사 MKACCLT.dll [ MKACCLT.dll Close Call. ]"); + // } + //} + } + 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); + if (m_tSVRSend != null && m_tSVRSend.IsAlive) + m_tSVRSend.Abort(); + } + } + #endregion + + //#region 초기화 + //private void SetExUrl() + //{ + // try + // { + // CmMessage PosConfig = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosConfig); + + // sExTranUrl = PosConfig.GetMessage("SERVER").GetMessageValue("ExTranUrl"); + // sExCalcUrl = PosConfig.GetMessage("SERVER").GetMessageValue("ExCalcUrl"); + + // //if (string.IsNullOrWhiteSpace(sExTranUrl)) sExTranUrl = @"http://skhiway.com/SvrApp/SL000.java"; + // //if (string.IsNullOrWhiteSpace(sExCalcUrl)) sExCalcUrl = @"http://skhiway.com/SvrApp/PS000.java"; + // } + // 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); + // } + //} + //#endregion + + #region TranSend Main + /// + /// Server Send Run + /// + private void ThreadSVRSendRun() + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "ThreadSVRSendRun Run!!"); + + while(m_TranSVRSendRunning) + { + try + { + // 전송 데이터 건수 초기화 + iSendDataCnt = 0; + + #region 01 - 선불 또는 후불메인 일 경우에만 전송 + if (m_cPosStatus.Base.PosType == PosConst.POS_TYPE.PRE_PAYMENT || + (m_cPosStatus.Base.PosType == PosConst.POS_TYPE.DEFERRED_PAYMENT && m_cPosStatus.Base.PosCommunicationType == PosConst.MAIN_POS_DIV.MAIN_POS)) + { + // 1 - TranLog Send (TranLog 전송) + this.TranLogSendProcess(); + // 2 - Journal Send (Journal 전송) + this.JournalSendProcess(); + // 3 - ApprovalLog Send (승인로그 전송) + this.ApprovalLogSendProcess(); + // 4 - ETC TRAN Send (ETC TRAN 전송) + this.ETCTranLogSendProcess(); + // 5 - ETC Journal Send (ETC Journal 전송) + this.ETCJournalSendProcess(); + // 6 - Cashier Test Log Send (계산원 시험Log 전송) + this.CashierTestLogSendProcess(); + // 외부업체 I/F 의 경우 실 OPEN 전 까지 주석 처리 함(20170213) + // 고속도로 휴게소 입점 POS + //if(m_cPosStatus.Base.ExPos == "1") + if (m_cPosStatus.Mst.ETC_IF_DIV == ItemConst.TranInterfaceOutside.IF_KOR_01) + { + // 7 - 도로공사(고속도로 휴게소 입점POS) 매출 I/F XML 파일 생성 + this.MakeTranToExProcess(); + + // 8 - 도로공사(고속도로 휴게소 입점POS) 매출 전송 + //this.TranSendToExProcess(); + } + + //#20180322 휴게소pos매출연동 start,phj + else if (m_cPosStatus.Mst.ETC_IF_DIV == ItemConst.TranInterfaceOutside.IF_KOR_03) + { + // 17 - 휴게소pos매출연동 I/F JSON 파일 생성 + this.MakeTranToRestArea(); + } + //#20180322 휴게소pos매출연동 end,phj + + //else if (m_cPosStatus.Mst.ETC_IF_DIV == ItemConst.TranInterfaceOutside.IF_KOR_02) + //// 한국공항공사 관리 공항 입점 POS + //{ + // // 9 - 한국공항공사 매출 전송 + // this.TranSendToKacProcess(); + //} + // 11. 점포점검 내역 전송 + this.StoreCheckSendProcess(); + + // 12. 일일점검 내역 전송 + this.StoreEquipCheckSendProcess(); + + // 13. Scale Log Send (Scale Log 전송) + this.ScaleLogSendProcess(); + + // 14. 보류 로그 이력 (ETC_HOLD_LOG 전송) + this.HoldLogSendProcess(); + + //#해피앱 추후적립 start, sskim + // 15. 해피앱 추후적립 내역 전송(TR_HPAPP_AFTER_SAVE 전송) + this.HpAppAfterSaveSendProcess(); + //#해피앱 추후적립 end, sskim + + //#20171120 유통기한 바코드 인식률 start, phj + // 16. 유통기한 바코드 인식률 전송 (TR_BAR_SUCESS_RATE 전송) + this.BarcodeSucessRateSendProcess(); + //#20171120 유통기한 바코드 인식률 end, phj + + //#15945 해피오더 자동주문 상세기능 start + // 해피오더 자동주문 로그 전송(HPO_AUTOORDER_LOG) + this.HappyOrderAutoOrderLogSendProcess(); + //#15945 해피오더 자동주문 상세기능 end + + } + #endregion + + #region 02 - 상시 전송 + // 10. 긴급메세지 전송 + this.EmgNoteSendProcess(); + #endregion + + // 기본 : 100ms, 에러 5건 이상 : 5000ms, 에러 10회 이상 발생 시 : 60000ms, 데이터 없을 때 : 5000ms + if(iErrorCount >= 10) + { + iErrorCount = 10; + m_ThreadSleepTerm = 60000; + } + else if (iErrorCount == 5 || iSendDataCnt == 0) + { + m_ThreadSleepTerm = 5000; + } + else if(iErrorCount == 0) + { + m_ThreadSleepTerm = 100; + } + + // Error Count 감소로 전환 시 기본 ThreadTerm으로 설정 + if(iOldErrorCount > iErrorCount) + { + iErrorCount = 0; + m_ThreadSleepTerm = 100; + } + + iOldErrorCount = iErrorCount; + + int nNowSleepTerm = 0; + while (nNowSleepTerm < m_ThreadSleepTerm) + { + if (m_TranSVRSendRunning == false) break; + Thread.Sleep(100); + nNowSleepTerm += 100; + } + } + 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 (함수명)) + "ThreadSVRSendRun Exception : " + ex.Message); + break; + } + } + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "ThreadSVRSendRun Exit!!"); + } + #endregion + + #region TRAN / 승인로그 / JOURNAL / ETC TRAN / ETC JOURNAL 전송 모듈 + private string MakeCommHeader(int nMsgLen, string sMsgType, string sEncType, string sCmpCd, string sBrandCd, string sStorCd, string sSaleDt, string sPosNo, string sTradeNo, string sSysYmd, string sSysHms) + { + try + { + 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] = sCmpCd; + aCommHead[Column.COMM_HEADER.SEQ.BrandCd] = sBrandCd; + aCommHead[Column.COMM_HEADER.SEQ.StoreCd] = sStorCd; + aCommHead[Column.COMM_HEADER.SEQ.PosNo] = sPosNo; + aCommHead[Column.COMM_HEADER.SEQ.TradeNo] = sTradeNo; + aCommHead[Column.COMM_HEADER.SEQ.TranYmd] = sSaleDt; + aCommHead[Column.COMM_HEADER.SEQ.SysYmd] = sSysYmd; + aCommHead[Column.COMM_HEADER.SEQ.SysHms] = sSysHms; + aCommHead[Column.COMM_HEADER.SEQ.EncType] = sEncType; + 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, // Project Name (프로젝트명) + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)) + ex.Message); + } + + return ""; + } + + private string SendProcess(string sSvrIp, int iPort, int iTimeout, string[] aKey, string sMsgType, Hashtable htSendData) + { + string sRet = UserCom.RST_ERR; + + try + { + // JSON 객체로 변환 + string sJsonSendData = JsonConvert.SerializeObject(htSendData); + + string sJsonRecvData = string.Empty; + + string sCmpCd = aKey[0]; + string sBrandCd = aKey[1]; + string sStorCd = aKey[2]; + string sSaleDt = aKey[3]; + string sPosNo = aKey[4]; + string sTradeNo = aKey[5]; + string sSysYmd = DateTime.Now.ToString("yyyyMMdd"); + string sSysHms = DateTime.Now.ToString("HHmmss"); + + if(sPosNo.Length < 2) + { + sPosNo = sPosNo.PadLeft(2, ' '); + } + + // 암호화 데이터로 변환 + string sEncryptedSendData = UserLog.UserAES.DynamicKeyEncrypt(sPosNo, sSysYmd + sSysHms, sJsonSendData); + // JSON string 길이를 구하기 위해 byte 변환 + Byte[] arTempData = Encoding.UTF8.GetBytes(sEncryptedSendData); + + string sCommHeader = this.MakeCommHeader(arTempData.Length, sMsgType, PosConst.ENCRYPT_MODE.ENC_ON, sCmpCd, sBrandCd, sStorCd, sSaleDt, sPosNo, sTradeNo, sSysYmd, sSysHms); + + //UserLog.WriteLogFile(UserCom.LOG_SOCK, + // UserCom.INFO_LEVEL, + // System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + // System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) + // System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)), + // CmUtil.RPadH("[SEND" + ":" + sSvrIp + ":" + iPort, 27) + "] " + sCommHeader + sJsonSendData); + + int iRet = DataSendReceive(sSvrIp, iPort, iTimeout, sCommHeader + sEncryptedSendData); + + if (iRet == UserCom.OK) + { + // 성공 시 Thread Term 조정 위한 Error 발생 카운트 감소. 0 이상일 경우만 감소. + if (iErrorCount > 0) + iErrorCount -= 1; + + sRet = UserCom.RST_OK; + } + else + { + // 실패 시 Thread Term 조정 위해 Error 발생 카운트 증가 + iErrorCount += 1; + + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "Failed sending Tran/Log. [MsgType:" + sMsgType + + "][CmpCd:" + sCmpCd + "][BrandCd:" + sBrandCd + + "][StoreCd:" + sStorCd + "][SaleDt:" + sSaleDt + + "][Pos:" + sPosNo + "][TradeNo:" + sTradeNo + "]"); + } + } + 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; + } + + private int DataSendReceive(string sIP, int iPort, int iTimeout, string sSendData) + { + int iRet = UserCom.NG; + try + { + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeout; + + iRet = SendReceiveData(sSendData); + } + 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 iRet; + } + + private int SendReceiveData(string sSendData) + { + int iRet = UserCom.NG; + int nRecvLen = 0; + string sRecvData = string.Empty; + + try + { + m_sendSocket = new TcpSocket(m_ServerIp, m_ServerPort); + + // Data Send & Receive + nRecvLen = m_sendSocket.SendReceiveData(sSendData, ref sRecvData, m_ServerTimeout); + + //UserLog.WriteLogFile(UserCom.LOG_SOCK, + // UserCom.INFO_LEVEL, + // System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + // System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) + // System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)), + // CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sRecvData); + + if (sRecvData.Length == TcpSocket.COMM_HEAD_LEN) + { + if (sRecvData.Substring(56, 3).Equals("000")) + { + iRet = UserCom.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 (함수명)) + "NetworkTranSend Error : Exception !!! " + ex.Message); + } + return iRet; + } + #endregion + + #region 점포점검 저장 데이터 전송 + #region POS IRT 전문 송/수신 + public string ExecutePosIrt(string sMsgType, string sSvrIP, int nSvrPort, int nTimeout, Hashtable htSendData, ref Hashtable htRecvData, bool bVisibleMode) + { + string sRet = UserCom.RST_ERR; + Hashtable m_htRecvData = null; // 통신 수신 데이터 (JSON) + + try + { + string sCommHead = ItemColumn.MakeCommHeader(0, sMsgType); // 통신해더 생성 + + if (bVisibleMode == false) + { + // 팝업 화면 미표시 + m_bIRTComplete = true; + m_htRecvData = null; + + Thread thrSecondDisp = new Thread(() => sRet = OnNetworkIRT(sSvrIP, nSvrPort, nTimeout, sCommHead, htSendData)); + thrSecondDisp.Start(); + + while (m_bIRTComplete == true) + { + Thread.Sleep(100); + } + htRecvData = m_htRecvData; + } + } + catch (Exception ex) + { + WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); + } + return sRet; + } + #endregion + + #region POS IRT 전문 송수신 - 화면 미표시용 + private string OnNetworkIRT(string sServerIp, int nServerPort, int nTimeOut, string sCommHead, Hashtable htSendData) + { + string sRet = UserCom.RST_ERR; + + int nRecvRet = -1; + try + { + m_bIRTComplete = true; + + //if (m_cNetService == null) m_cNetJSONService = (INetworkJSON)sManager.InitServiceInstance(ServiceLists.AGENT_NETWORK.DLL, ServiceLists.AGENT_NETWORK.NETWORK_IRT); + nRecvRet = IRTSendReceive(sServerIp, nServerPort, nTimeOut, sCommHead, htSendData, ref m_htRecvData); + + if (nRecvRet == BaseCom.OK) sRet = UserCom.RST_OK; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "Process Exception !!! " + ex.Message); + } + finally + { + m_bIRTComplete = false; + } + return sRet; + } + #endregion + + #region IRT Byte로의 Send/Recv (공통헤더의 전문길이 0으로 세팅해서 송신. 자동 계산) + public int IRTSendReceive(string sIP, int iPort, int iTimeOut, string sCommData, Hashtable htData, ref Hashtable htRecvData) + { + int nStat = 9; + string sReturn = string.Empty; + string sRecvCommHeader = string.Empty; + string sRecvData = string.Empty; + + m_ServerIp = sIP; + m_ServerPort = iPort; + m_ServerTimeout = iTimeOut; + + string sJsonSendData = ""; + string sJsonReceiveData = ""; + + try + { + if (m_ServerIp != "" && m_ServerPort != 0) + { + if (htData != null) + { + sJsonSendData = JsonConvert.SerializeObject(htData); + + //sJsonSendData 암호화 처리 ... + + Byte[] sBytTempBuff = Encoding.UTF8.GetBytes(sJsonSendData); + string sDataLen = string.Format("{0:000000}", sBytTempBuff.Length); + + sCommData = sDataLen + sCommData.Substring(TcpSocket.COMM_MSGLEN); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkJSON.IRTSendReceive()", CmUtil.RPadH("[SEND" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sCommData + sJsonSendData); + } + + //Send Receive + nStat = SendReceiveData(sCommData + sJsonSendData, ref sJsonReceiveData); + + if (sJsonReceiveData != null && sJsonReceiveData != "") + { + sRecvCommHeader = sJsonReceiveData.Substring(0, TcpSocket.COMM_HEAD_LEN); + sRecvData = sJsonReceiveData.Substring(TcpSocket.COMM_HEAD_LEN); + //sJsonReceiveData 복호화 처리 ... + + htRecvData = JsonConvert.DeserializeObject(sRecvData); + + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (Project Name (프로젝트명)) + "NetworkJSON.IRTSendReceive()", CmUtil.RPadH("[RECV" + ":" + m_ServerIp + ":" + m_ServerPort, 27) + "] " + sRecvCommHeader + sRecvData); + } + } + } + catch (Exception e) + { + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.IRTSendReceive()", e.ToString()); + } + + return nStat; + } + #endregion + + #region IRT전문의 Send/Receive + private int SendReceiveData(string pSendData, ref string pRecvData, bool bIsDmbIf = false) + { + int nRecvLen = 0; + int nStat = BaseCom.NG; + string rRecvData = ""; + + try + { + m_IrtSocket = new TcpSocket(m_ServerIp, m_ServerPort, m_ServerTimeout); + + // Data Send & Receive + System.Diagnostics.Debug.Print("요청:" + pSendData); + nRecvLen = m_IrtSocket.SendReceiveData(pSendData, ref rRecvData, m_ServerTimeout, bIsDmbIf); + System.Diagnostics.Debug.Print("응답:" + rRecvData); + + if (nRecvLen > 0) + { + pRecvData = rRecvData; + nStat = BaseCom.OK; + } + else + { + pRecvData = ""; + nStat = nRecvLen; + } + m_IrtSocket.Close(); + } + catch (Exception e) + { + if (m_IrtSocket != null) m_IrtSocket.Close(); + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + "NetworkJSON.SendReceiveData()", "NetworkIrt Error : ThreadNetworkIrt Exception !!! " + e.ToString()); + } + finally + { + } + + System.Threading.Thread.Sleep(100); + return nStat; + } + #endregion + #endregion + + //*----------------------------------------------------------------------------------------------------------*/ + // TranLog / Journal / ApprovalLog / ETC Tran / ETC Journal 데이터 생성 + //*----------------------------------------------------------------------------------------------------------*/ + + #region 01 - TranLog 전송 + /// + /// TranLog Sending Execution (TranLog 전송 실행) + /// + public void TranLogSendProcess() + { + string sendFlag = string.Empty; + string sCMP_CD = string.Empty; + string sSTOR_CD = string.Empty; + string sSALE_DT = string.Empty; + string sPOS_NO = string.Empty; + string sTRADE_NO = string.Empty; + + string sREG_NO = string.Empty; + string sTRADE_DIV = string.Empty; + string sTRAIN_MODE_YN = string.Empty; + string sTRADE_KINDPER = string.Empty; + string sSYS_DT = string.Empty; + string sPAY_TIME = string.Empty; + string sORG_SALE_DT = string.Empty; + string sORG_POS_NO = string.Empty; + string sORG_TRADE_NO = string.Empty; + string sQTY = string.Empty; + string sTOTSALE_AMT = string.Empty; + string sTOTDC_AMT = string.Empty; + string sNET_SALE_AMT = string.Empty; + DataTable dtReturn = null; + try + { + // 전송할 TR 데이터 생성 + string sTranLog = GetTranLog(ref dtReturn); + + if(sTranLog == "" || dtReturn.Rows.Count == 0) + { + return; + } + else + { + iSendDataCnt += 1; + } + + sendFlag = "0"; // 0:미전송, 1:전송, 9:에러 + + DataRow dr = dtReturn.Rows[0]; + sCMP_CD = CmUtil.GetDataRowStr(dr, "CMP_CD"); + sSTOR_CD = CmUtil.GetDataRowStr(dr, "STOR_CD"); + sSALE_DT = CmUtil.GetDataRowStr(dr, "SALE_DT"); + sPOS_NO = CmUtil.GetDataRowStr(dr, "POS_NO"); + sTRADE_NO = CmUtil.GetDataRowStr(dr, "TRADE_NO"); + + sREG_NO = CmUtil.GetDataRowStr(dr, "REG_NO"); + sTRADE_DIV = CmUtil.GetDataRowStr(dr, "TRADE_DIV"); + sTRAIN_MODE_YN = CmUtil.GetDataRowStr(dr, "TRAIN_MODE_YN"); + sTRADE_KINDPER = CmUtil.GetDataRowStr(dr, "TRADE_KINDPER"); + sSYS_DT = CmUtil.GetDataRowStr(dr, "SYS_DT"); + sPAY_TIME = CmUtil.GetDataRowStr(dr, "PAY_TIME"); + sORG_SALE_DT = CmUtil.GetDataRowStr(dr, "ORG_BILLDT"); + sORG_POS_NO = CmUtil.GetDataRowStr(dr, "ORG_BILL_POSNO"); + sORG_TRADE_NO = CmUtil.GetDataRowStr(dr, "ORG_BILL_NO"); + sQTY = CmUtil.GetDataRowStr(dr, "QTY"); + sTOTSALE_AMT = CmUtil.GetDataRowStr(dr, "TOTSALE_AMT"); + sTOTDC_AMT = CmUtil.GetDataRowStr(dr, "TOTDC_AMT"); + sNET_SALE_AMT = CmUtil.GetDataRowStr(dr, "NET_SALE_AMT"); + + string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.TranPort), + 10000, + new string[] { sCMP_CD, m_cPosStatus.Base.BrandCd, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO }, + ItemConst.COMM_MSG_TYPE.TRAN, + MakeTranLogJsonData(dr, sTranLog)); + + if(sReturn == UserCom.RST_OK) + { + sendFlag = "1"; // 정상 전송 + + // 전송 건수 증가 + if( sSTOR_CD == m_cPosStatus.Base.StoreNo && sSALE_DT == m_cPosStatus.Base.SaleDate) + { + m_cPosStatus.Sale.TranSndCount++; + } + m_cPosStatus.Sale.OnLineStatus = "1"; + } + else + { + sendFlag = "9"; // 에러 + m_cPosStatus.Sale.OnLineStatus = "0"; + } + } + 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); + sendFlag = "9"; + } + finally + { + // Flag Update + TranLogFlgUpdate(sCMP_CD, sSTOR_CD, sPOS_NO, sSALE_DT, sTRADE_NO, sendFlag); + } + } + + private Hashtable MakeTranLogJsonData(DataRow drData, string sTranLog) + { + Hashtable htData = new Hashtable(); + + try + { + // 01 - 회사코드 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.CmpCd, CmUtil.GetDataRowStr(drData, "CMP_CD")); + // 02 - 판매일자 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.SaleDt, CmUtil.GetDataRowStr(drData, "SALE_DT")); + // 03 - 점포코드 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.StorCd, CmUtil.GetDataRowStr(drData, "STOR_CD")); + // 04 - 포스번호 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.PosNo, CmUtil.GetDataRowStr(drData, "POS_NO")); + // 05 - 거래번호 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.TradeNo, CmUtil.GetDataRowStr(drData, "TRADE_NO")); + // 06 - 등록번호 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.RegNo, CmUtil.GetDataRowStr(drData, "REG_NO")); + // 07 - 거래구분 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.TradeDiv, CmUtil.GetDataRowStr(drData, "TRADE_DIV")); + // 08 - 연습모드 여부 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.TrainModeYn, CmUtil.GetDataRowStr(drData, "TRAIN_MODE_YN")); + // 09 - 거래종별 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.TradeKindper, CmUtil.GetDataRowStr(drData, "TRADE_KINDPER")); + // 10 - 시스템 일시 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.SysDt, CmUtil.GetDataRowStr(drData, "SYS_DT")); + // 11 - 결제 시간 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.PayTime, CmUtil.GetDataRowStr(drData, "PAY_TIME")); + // 12 - 원거래판매 일자 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.OrgSaleDt, CmUtil.GetDataRowStr(drData, "ORG_BILLDT")); + // 13 - 원거래포스번호 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.OrgPosNo, CmUtil.GetDataRowStr(drData, "ORG_BILL_POSNO")); + // 14 - 원거래 거래번호 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.OrgTradeNo, CmUtil.GetDataRowStr(drData, "ORG_BILL_NO")); + // 15 - 수량 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.Qty, CmUtil.GetDataRowStr(drData, "QTY")); + // 16 - 총매출금액 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.TotSaleAmt, CmUtil.GetDataRowStr(drData, "TOTSALE_AMT")); + // 17 - 총할인금액 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.TotDcAmt, CmUtil.GetDataRowStr(drData, "TOTDC_AMT")); + // 18 - 순매출금액 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.NetSaleAmt, CmUtil.GetDataRowStr(drData, "NET_SALE_AMT")); + // 19 - 거래데이터 + htData.Add(Column.IQ_TRAN_LOG_REQ.DATA.DealData, sTranLog); + } + 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 (함수명)) + "ThreadSVRSendRun Exception : " + ex.Message); + } + + return htData; + } + + /// + /// 정상으로 송신한 경우 Flg추가용 쿼리 + /// + /// + /// + /// + /// + /// + /// + /// + public int TranLogFlgUpdate(string pCompanyCd, string pStoreNo, string pPosNo, string pSaleDate, string pTradeNo, string pSendFlag) + { + int iRet = UserCom.NG; + string sQuery = ""; + + try + { + if (pCompanyCd.Trim() == "") return iRet; + if (pSaleDate.Trim() == "") return iRet; + if (pStoreNo.Trim() == "") return iRet; + if (pPosNo.Trim() == "") return iRet; + if (pTradeNo.Trim() == "") return iRet; + + sQuery = "UPDATE POSLOG..TR_SALE_HEADER "; + sQuery += " SET SEND_YN = '" + pSendFlag + "' "; + sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + sQuery += " WHERE CMP_CD = '" + pCompanyCd + "' "; + sQuery += " AND STOR_CD = '" + pStoreNo + "' "; + sQuery += " AND SALE_DT = '" + pSaleDate + "' "; + sQuery += " AND POS_NO = '" + pPosNo + "' "; + sQuery += " AND TRADE_NO = '" + pTradeNo + "' "; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); + } + 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 iRet; + } + + /// + /// TranLog 조회 + /// + /// 0:미전송, 1:전송, 9:에러 + /// + public string GetTranLog(ref DataTable dtReturn) + { + string sQuery = ""; + string sCMP_CD = ""; + string sSTOR_CD = ""; + string sSALE_DT = ""; + string sPOS_NO = ""; + string sTRADE_NO = ""; + + string sTranData = ""; + DataTable dtTempReturn = null; + + try + { + sQuery = " SELECT TOP 1 "; + sQuery += " CMP_CD, SALE_DT, STOR_CD, POS_NO, TRADE_NO "; + sQuery += " , '' AS REG_NO, TRADE_DIV, TRAIN_MODE_YN, TRADE_KINDPER, SYS_DT "; + sQuery += " , PAY_TIME, ORG_BILLDT, ORG_BILL_POSNO, ORG_BILL_NO, QTY "; + sQuery += " , TOTSALE_AMT, TOTDC_AMT, NET_SALE_AMT "; + sQuery += " FROM POSLOG..TR_SALE_HEADER "; + sQuery += " WHERE SEND_YN <> '1' "; + //#20180131 인천공항 통합POS 사용유무가 사용이면 SEND_YN을 A로 설정 start + //grayber@20180228 [BRKR] 인천공항 SEND_YN 매출전송유무 'A' 제거 start + if (m_cPosStatus.Mst.CorpDiv.Equals(ItemConst.CORP_DIV.BR) != true) + sQuery += " AND SEND_YN <> 'A' "; + //grayber@20180228 [BRKR] 인천공항 SEND_YN 매출전송유무 'A' 제거 end + //#20180131 인천공항 통합POS 사용유무가 사용이면 SEND_YN을 A로 설정 end + sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sQuery += " ORDER BY SEND_YN, SALE_DT, TRADE_NO "; + + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn.Rows.Count == 1) + { + DataRow drTempReturn = dtTempReturn.Rows[0]; + + sCMP_CD = drTempReturn["CMP_CD"].ToString(); + sSTOR_CD = drTempReturn["STOR_CD"].ToString(); + sSALE_DT = drTempReturn["SALE_DT"].ToString(); + sPOS_NO = drTempReturn["POS_NO"].ToString(); + sTRADE_NO = drTempReturn["TRADE_NO"].ToString(); + + sTranData = GetTranHeader(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) + + GetTranDetail(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) + + GetTranPay(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) + //+ GetTranDC(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) + + GetTranCpiRslt(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) + + GetTranEtc(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) + //+ GetTranDpst(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) + + GetTranAdmt(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) + + GetTranGuestCnt(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO) + + GetTranReservInfo(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO); + } + } + + dtReturn = dtTempReturn; + } + catch (Exception ex) + { + sTranData = ""; + 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 sTranData; + } + + private string GetTranHeader(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '" + ItemConst.IRT_TRAN_TYPE.TranHeader + "' + '|' + '000000' + '|' + '0' + '|' + ISNULL(TRADE_DIV, '') + '|' + ISNULL(TRAIN_MODE_YN, '') + '|' + ISNULL(TRADE_KINDPER, '') + '|' + ISNULL(SYS_DT, '') + '|' + ISNULL(ORD_TIME, '') + '|' + "; + sQuery += " ISNULL(PAY_TIME, '') + '|' + ISNULL(PIC_NO, '') + '|' + ISNULL(ORD_PIC_NO, '') + '|' + ISNULL(STOR_OWN_PART_TIME_DIV, '') + '|' + ISNULL(ORG_BILL_POSNO, '') + '|' + "; + sQuery += " ISNULL(ORG_BILLDT, '') + '|' + ISNULL(ORG_BILL_NO, '') + '|' + ISNULL(RTN_RSN_CD, '') + '|' + ISNULL(RTN_RSN_MEMO, '') + '|' + ISNULL(NONSALES_RSN_CD, '') + '|' + "; + sQuery += " ISNULL(RESERV_NO, '') + '|' + ISNULL(RESERV_DT, '') + '|' + ISNULL(CUST_NO, '') + '|' + ISNULL(ORD_DIV, '') + '|' + ISNULL(FLOOR_CD, '') + '|' + "; + sQuery += " ISNULL(TBL_NO, '') + '|' + ISNULL(GUESTFLOOR, '') + '|' + ISNULL(FRGNR_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(CUSTCNT, 0)) + '|' + ISNULL(PAY_GNDR_DIV, '') + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(PAY_AGE, 0)) + '|' + CONVERT(VARCHAR, ISNULL(MAN_CMPNPSN_CNT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(WOMAN_CMPNPSN_CNT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(TOTSALE_AMT, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(TOTDC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(NET_SALE_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ITEM_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPI_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(COOP_CARD_DC_AMT, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(POINT_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPN_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(EMP_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SET_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ETC_AMT, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(EXCEP_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(TOT_VAT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_VAT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ETC_VAT, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(AF_ACCUM_POINT_AMT, 0)) + '|' + ISNULL(AF_ACCUM_POINT_INFO, '') + '|' + ISNULL(PPCARD_CUSTNM, '') + '|' + ISNULL(AMT_DUTCHPAY_YN, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_CNT, 0)) + '|'+ ISNULL(ORDER_NO, '') + '|' + "; + + + //#20170828 해피포인트 적립 제외 버튼 추가 phj, start + //기존 + //sQuery += " ISNULL(SLACK_FIELD, '') + '|' + ISNULL(MID_CLOSE_SEQ, '') + '|' + ISNULL(PPCARD_CUSTID, '') + '|' + ISNULL(PACK_TRADE_DIV, '') + '|' + ISNULL(VIP_TY, '') "; + //변경 + sQuery += " ISNULL(SLACK_FIELD, '') + '|' + ISNULL(MID_CLOSE_SEQ, '') + '|' + ISNULL(PPCARD_CUSTID, '') + '|' + ISNULL(PACK_TRADE_DIV, '') + '|' + ISNULL(VIP_TY, '') + '|' + ISNULL(HP_EXCLUDE_YN, '0')"; + //#20170828 해피포인트 적립 제외 버튼 추가 phj, end + + sQuery += " AS TR_HEADER "; + sQuery += " FROM POSLOG..TR_SALE_HEADER "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND SALE_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + sQuery += " AND POS_NO = '{3}' "; + sQuery += " AND TRADE_NO = '{4}' "; + + sSQL = string.Format(sQuery + , sCMP_CD + , sSALE_DT + , sSTOR_CD + , sPOS_NO + , sTRADE_NO); + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + + private string GetTranDetail(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranDetail + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(ORD_TIME, '') + '|' + ISNULL(FLOOR_CD, '') + '|' + ISNULL(TBL_NO, '') + '|' + "; + sQuery += " ISNULL(SUB_SHOP_CD, '') + '|' + ISNULL(ITEM_PLU_CD, '') + '|' + ISNULL(ITEM_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(SALE_QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SALE_PRC, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(SALE_AMT, 0)) + '|' + ISNULL(FLAVOUR_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(FLAVOUR_WEIGHT, 0)) + '|' + ISNULL(ITEM_INPUT_DIV, '') + '|' + ISNULL(ITEM_BAR_CD, '') + '|' + "; + sQuery += " ISNULL(TAKE_IN_OUT_DIV, '') + '|' + ISNULL(ITEM_TAX_DIV, '') + '|' + ISNULL(TAX_AMT_INCLUDE_YN, '') + '|' + ISNULL(TAXRATE_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(APPLY_TAX_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_VAT, 0)) + '|' + "; + sQuery += " ISNULL(SVC_TAXREATE_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(BILL_AMT, 0)) + '|' + ISNULL(NONSALES_RSN_CD, '') + '|' + ISNULL(DC_DIV, '') + '|' + ISNULL(DC_TYPE, '') + '|' + CONVERT(VARCHAR, ISNULL(DC_RATE, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ITEM_DC_AMT, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(SUM_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPI_DC_QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPI_DC_AMT, 0)) + '|' + ISNULL(COOP_CARD_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(COOP_CARD_DC_AMT, 0)) + '|' + ISNULL(POINT_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(POINT_DC_AMT, 0)) + '|' + "; + sQuery += " ISNULL(CPN_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(CPN_DC_AMT, 0)) + '|' + ISNULL(EMP_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(EMP_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SET_DC_AMT, 0)) + '|' + ISNULL(ETC_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(ETC_DC_AMT, 0)) + '|' + "; + sQuery += " ISNULL(EXCEP_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(EXCEP_DC_AMT, 0)) + '|' + ISNULL(PACK_DIV, '') + '|' + ISNULL(SET_MENU_CD, '') + '|' + ISNULL(SUBPRC_MENU_KEY_DIV, '') + '|' + "; + //#20180903 해피오더 매출 생성 시 tr_sale_detail에 구분자 추가 start + //기존 + //sQuery += " ISNULL(CPI_PRESENT_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(SALE_GIFT_NO, '') + '|' + ISNULL(CPN_NO, '') + '|' + ISNULL(SLACK_FIELD, '') + '|' + ISNULL(DISPO_ITEM_DIV, '') + '|' + ISNULL(CANCEL_DIV, '0') + '|' + ISNULL(NOTAX_DIV, '') AS TR_DETAIL"; + //변경 + sQuery += " ISNULL(CPI_PRESENT_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(SALE_GIFT_NO, '') + '|' + ISNULL(CPN_NO, '') + '|' + ISNULL(SLACK_FIELD, '') + '|' + ISNULL(DISPO_ITEM_DIV, '') + '|' + ISNULL(CANCEL_DIV, '0') + '|' + ISNULL(NOTAX_DIV, '') + '|' + ISNULL(HPO_REG_YN, '') AS TR_DETAIL"; + //#20180903 해피오더 매출 생성 시 tr_sale_detail에 구분자 추가 end + + sQuery += " FROM POSLOG..TR_SALE_DETAIL "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND SALE_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + sQuery += " AND POS_NO = '{3}' "; + sQuery += " AND TRADE_NO = '{4}' "; + + sSQL = string.Format(sQuery + , sCMP_CD + , sSALE_DT + , sSTOR_CD + , sPOS_NO + , sTRADE_NO); + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + + private string GetTranPay(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranPay + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(PAY_WAY_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(PAY_AMT, 0)) + '|' + ISNULL(PAY_DTL_CD_01, '') + '|' + ISNULL(PAY_DTL_CD_02, '') + '|' + "; + sQuery += " ISNULL(PAY_DTL_CD_03, '') + '|' + ISNULL(PAY_DTL_CD_04, '') + '|' + ISNULL(PAY_DTL_CD_05, '') + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_02, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(QTY_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_05, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_02, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(AMT_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_05, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_06, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_07, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(AMT_ENTRY_08, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_09, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_10, 0)) + '|' + ISNULL(OCCUR_ENTRY_01, '') + '|' + ISNULL(OCCUR_ENTRY_02, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_03, '') + '|' + ISNULL(OCCUR_ENTRY_04, '') + '|' + ISNULL(OCCUR_ENTRY_05, '') + '|' + ISNULL(OCCUR_ENTRY_06, '') + '|' + ISNULL(OCCUR_ENTRY_07, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_08, '') + '|' + ISNULL(OCCUR_ENTRY_09, '') + '|' + ISNULL(OCCUR_ENTRY_10, '') + '|' + ISNULL(OCCUR_ENTRY_11, '') + '|' + ISNULL(OCCUR_ENTRY_12, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_13, '') + '|' + ISNULL(OCCUR_ENTRY_14, '') + '|' + ISNULL(OCCUR_ENTRY_15, '') + '|' + ISNULL(OCCUR_ENTRY_16, '') + '|' + ISNULL(OCCUR_ENTRY_17, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_18, '') + '|' + ISNULL(OCCUR_ENTRY_19, '') + '|' + ISNULL(OCCUR_ENTRY_20, '') + '|' + ISNULL(OCCUR_ENTRY_21, '') + '|' + ISNULL(OCCUR_ENTRY_22, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_23, '') + '|' + ISNULL(OCCUR_ENTRY_24, '') + '|' + ISNULL(OCCUR_ENTRY_25, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(CANCEL_DIV, '') AS TR_PAY"; + sQuery += " FROM POSLOG..TR_SALE_PAY "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND SALE_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + sQuery += " AND POS_NO = '{3}' "; + sQuery += " AND TRADE_NO = '{4}' "; + + sSQL = string.Format(sQuery + , sCMP_CD + , sSALE_DT + , sSTOR_CD + , sPOS_NO + , sTRADE_NO); + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + + //private string GetTranDC(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) + //{ + // StringBuilder sbTranData = new StringBuilder(); + // string sQuery = ""; + // string sSQL = ""; + // DataTable dtTempReturn = null; + + // try + // { + // sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranDC + "' + '|' + DC_WAY_CD + '|' + CONVERT(VARCHAR, DC_AMT) + '|' + DC_DTL_CD_01 + '|' + DC_DTL_CD_02 + '|' + "; + // sQuery += " DC_DTL_CD_03 + '|' + DC_DTL_CD_04 + '|' + DC_DTL_CD_05 + '|' + CONVERT(VARCHAR, QTY_ENTRY_01) + '|' + CONVERT(VARCHAR, QTY_ENTRY_02) + '|' + "; + // sQuery += " CONVERT(VARCHAR, QTY_ENTRY_03) + '|' + CONVERT(VARCHAR, QTY_ENTRY_04) + '|' + CONVERT(VARCHAR, QTY_ENTRY_05) + '|' + CONVERT(VARCHAR, AMT_ENTRY_01) + '|' + CONVERT(VARCHAR, AMT_ENTRY_02) + '|' + "; + // sQuery += " CONVERT(VARCHAR, AMT_ENTRY_03) + '|' + CONVERT(VARCHAR, AMT_ENTRY_04) + '|' + CONVERT(VARCHAR, AMT_ENTRY_05) + '|' + CONVERT(VARCHAR, AMT_ENTRY_06) + '|' + CONVERT(VARCHAR, AMT_ENTRY_07) + '|' + "; + // sQuery += " CONVERT(VARCHAR, AMT_ENTRY_08) + '|' + CONVERT(VARCHAR, AMT_ENTRY_09) + '|' + CONVERT(VARCHAR, AMT_ENTRY_10) + '|' + OCCUR_ENTRY_01 + '|' + OCCUR_ENTRY_02 + '|' + "; + // sQuery += " OCCUR_ENTRY_03 + '|' + OCCUR_ENTRY_04 + '|' + OCCUR_ENTRY_05 + '|' + OCCUR_ENTRY_06 + '|' + OCCUR_ENTRY_07 + '|' + "; + // sQuery += " OCCUR_ENTRY_08 + '|' + OCCUR_ENTRY_09 + '|' + OCCUR_ENTRY_10 + '|' + OCCUR_ENTRY_11 + '|' + OCCUR_ENTRY_12 + '|' + "; + // sQuery += " OCCUR_ENTRY_13 + '|' + OCCUR_ENTRY_14 + '|' + OCCUR_ENTRY_15 + '|' + OCCUR_ENTRY_16 + '|' + OCCUR_ENTRY_17 + '|' + "; + // sQuery += " OCCUR_ENTRY_18 + '|' + OCCUR_ENTRY_19 + '|' + OCCUR_ENTRY_20 + '|' + OCCUR_ENTRY_21 + '|' + OCCUR_ENTRY_22 + '|' + "; + // sQuery += " OCCUR_ENTRY_23 + '|' + OCCUR_ENTRY_24 + '|' + OCCUR_ENTRY_25 + '|' + CONVERT(VARCHAR, BILLSPR_NO) + '|' + CANCEL_DIV AS TR_DC"; + // sQuery += " FROM POSLOG..TR_SALE_DC "; + // sQuery += " WHERE CMP_CD = '{0}' "; + // sQuery += " AND STOR_CD = '{1}' "; + // sQuery += " AND SALE_DT = '{2}' "; + // sQuery += " AND POS_NO = '{3}' "; + // sQuery += " AND TRADE_NO = '{4}' "; + + // sSQL = string.Format(sQuery + // , sCMP_CD + // , sSTOR_CD + // , sSALE_DT + // , sPOS_NO + // , sTRADE_NO); + + // if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + // { + // if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + // { + // foreach (DataRow dr in dtTempReturn.Rows) + // { + // sbTranData.Append(dr[0].ToString()); + // } + // } + // } + // } + // 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 sbTranData.ToString(); + //} + + private string GetTranCpiRslt(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranCpiRslt + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(CPI_TYPE, '') + '|' + CONVERT(VARCHAR, ISNULL(NMTAX_SEQ, 0)) + '|' + ISNULL(CPI_CD, '') + '|' + ISNULL(SUB_SHOP_CD, '') + '|' + "; + sQuery += " ISNULL(ITEM_PLU_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(DC_QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(DC_SUM_AMT, 0)) + '|' + ISNULL(CPI_DIV, '') + '|' + "; + sQuery += " ISNULL(PAYMNT_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(ACCUM_POINT, 0)) + '|' + ISNULL(LTTR_NMPLAT_NO, '') + '|' + ISNULL(CPI_CUST_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + "; + sQuery += " ISNULL(SLACK_FIELD, '') + '|' + ISNULL(CANCEL_DIV, '') AS TR_CPI_RSLT "; + sQuery += " FROM POSLOG..TR_SALE_CPI_RSLT "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND SALE_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + sQuery += " AND POS_NO = '{3}' "; + sQuery += " AND TRADE_NO = '{4}' "; + + sSQL = string.Format(sQuery + , sCMP_CD + , sSALE_DT + , sSTOR_CD + , sPOS_NO + , sTRADE_NO); + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + + private string GetTranEtc(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranEtc + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(ETC_WAY_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(ETC_AMT, 0)) + '|' + "; + sQuery += " ISNULL(ETC_DTL_CD_01, '') + '|' + ISNULL(ETC_DTL_CD_02, '') + '|' + ISNULL(ETC_DTL_CD_03, '') + '|' + ISNULL(ETC_DTL_CD_04, '') + '|' + ISNULL(ETC_DTL_CD_05, '') + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(QTY_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_02, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_05, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(AMT_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_02, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_05, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(AMT_ENTRY_06, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_07, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_08, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_09, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_10, 0)) + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_01, '') + '|' + ISNULL(OCCUR_ENTRY_02, '') + '|' + ISNULL(OCCUR_ENTRY_03, '') + '|' + ISNULL(OCCUR_ENTRY_04, '') + '|' + ISNULL(OCCUR_ENTRY_05, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_06, '') + '|' + ISNULL(OCCUR_ENTRY_07, '') + '|' + ISNULL(OCCUR_ENTRY_08, '') + '|' + ISNULL(OCCUR_ENTRY_09, '') + '|' + ISNULL(OCCUR_ENTRY_10, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_11, '') + '|' + ISNULL(OCCUR_ENTRY_12, '') + '|' + ISNULL(OCCUR_ENTRY_13, '') + '|' + ISNULL(OCCUR_ENTRY_14, '') + '|' + ISNULL(OCCUR_ENTRY_15, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_16, '') + '|' + ISNULL(OCCUR_ENTRY_17, '') + '|' + ISNULL(OCCUR_ENTRY_18, '') + '|' + ISNULL(OCCUR_ENTRY_19, '') + '|' + ISNULL(OCCUR_ENTRY_20, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_21, '') + '|' + ISNULL(OCCUR_ENTRY_22, '') + '|' + ISNULL(OCCUR_ENTRY_23, '') + '|' + ISNULL(OCCUR_ENTRY_24, '') + '|' + ISNULL(OCCUR_ENTRY_25, '') + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(CANCEL_DIV, '') AS TR_ETC"; + sQuery += " FROM POSLOG..TR_SALE_ETC "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND SALE_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + sQuery += " AND POS_NO = '{3}' "; + sQuery += " AND TRADE_NO = '{4}' "; + + sSQL = string.Format(sQuery + , sCMP_CD + , sSALE_DT + , sSTOR_CD + , sPOS_NO + , sTRADE_NO); + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + + //private string GetTranDpst(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) + //{ + // StringBuilder sbTranData = new StringBuilder(); + // string sQuery = ""; + // string sSQL = ""; + // DataTable dtTempReturn = null; + + // try + // { + // sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranDpst + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(DPST_WTHDR_TYPE, '') + '|' + ISNULL(DPST_WTHDR_CD, '') + '|' + ISNULL(DPST_WTHDR_ACC_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(DPST_WTHDR_QTY, 0)) + '|' + "; + // sQuery += " CONVERT(VARCHAR, ISNULL(DPST_WTHDR_AMT, 0)) + '|' + ISNULL(DPST_WTHDR_NM, '') + '|' + ISNULL(CUST_NO, '') + '|' + ISNULL(STOR_PAY_TYPE, '') + '|' + ISNULL(ETC_REASON, '') + '|' + ISNULL(SLACK_FIELD_01, '') + '|' + ISNULL(SLACK_FIELD_02, '') + '|' + ISNULL(SLACK_FIELD_03, '') + '|' + "; + // sQuery += " ISNULL(SLACK_FIELD_04, '') + '|' + SLACK_FIELD_05 AS TR_DPST "; + // sQuery += " FROM POSLOG..TR_SALE_DPST_WTHDR "; + // sQuery += " WHERE CMP_CD = '{0}' "; + // sQuery += " AND SALE_DT = '{1}' "; + // sQuery += " AND STOR_CD = '{2}' "; + // sQuery += " AND POS_NO = '{3}' "; + // sQuery += " AND TRADE_NO = '{4}' "; + + // sSQL = string.Format(sQuery + // , sCMP_CD + // , sSALE_DT + // , sSTOR_CD + // , sPOS_NO + // , sTRADE_NO); + + // if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + // { + // if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + // { + // foreach (DataRow dr in dtTempReturn.Rows) + // { + // sbTranData.Append(dr[0].ToString()); + // } + // } + // } + // } + // 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 sbTranData.ToString(); + //} + + private string GetTranAdmt(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranAdmt + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(ADMT_TYPE, '') + '|' + ISNULL(ADMT_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT, 0)) + '|' + "; + sQuery += " ISNULL(SLACK_FIELD_01, '') + '|' + ISNULL(SLACK_FIELD_02, '') + '|' + ISNULL(SLACK_FIELD_03, '') + '|' + ISNULL(SLACK_FIELD_04, '') + '|' + "; + sQuery += " ISNULL(SLACK_FIELD_05, '') AS TR_ADMT "; + sQuery += " FROM POSLOG..TR_SALE_ADMT "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND SALE_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + sQuery += " AND POS_NO = '{3}' "; + sQuery += " AND TRADE_NO = '{4}' "; + + sSQL = string.Format(sQuery + , sCMP_CD + , sSALE_DT + , sSTOR_CD + , sPOS_NO + , sTRADE_NO); + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + + private string GetTranGuestCnt(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranGuestCnt + "' + '|' + '000000' + '|' + '0' + '|' + CONVERT(VARCHAR, ISNULL(MALE_10L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(MALE_20L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(MALE_30L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(MALE_40L, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(MALE_50L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(FMALE_10L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(FMALE_20L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(FMALE_30L, 0)) + '|' + CONVERT(VARCHAR, ISNULL(FMALE_40L, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(FMALE_50L, 0)) AS TR_GUESTCNT "; + sQuery += " FROM POSLOG..TR_SALE_GUESTCNT "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND SALE_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + sQuery += " AND POS_NO = '{3}' "; + sQuery += " AND TRADE_NO = '{4}' "; + + sSQL = string.Format(sQuery + , sCMP_CD + , sSALE_DT + , sSTOR_CD + , sPOS_NO + , sTRADE_NO); + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + + private string GetTranReservInfo(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sTRADE_NO) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranReservInfo + "' + '|' + '000000' + '|' + '0' + '|' + ISNULL(RESERV_NO, 0) + '|' +ISNULL(RESERV_REG_DT, 0) + '|' + ISNULL(RESERV_REG_TM, 0) + '|' + ISNULL(ONOFF_DIV, 0) + '|' + "; + sQuery += " ISNULL(CUSTNM, 0) + '|' + ISNULL(CUST_PHN_NO, 0) + '|' + ISNULL(RESERV_DT, 0) + '|' + ISNULL(RESERV_TM, 0) + '|' + ISNULL(RESERV_MEMO, 0) AS TR_RESERVINFO "; + sQuery += " FROM POSLOG..TR_RESERV_INFO "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND SALE_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + sQuery += " AND POS_NO = '{3}' "; + sQuery += " AND TRADE_NO = '{4}' "; + + sSQL = string.Format(sQuery + , sCMP_CD + , sSALE_DT + , sSTOR_CD + , sPOS_NO + , sTRADE_NO); + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + #endregion + + #region 02 - Journal 전송 + /// + /// Journal Sending Execution (Journal 전송 실행) + /// + public void JournalSendProcess() + { + DataTable dtReturn = null; + Hashtable htData = null; + string sSendFlag = string.Empty; + string sCmpCd = string.Empty; + string sStorCd = string.Empty; + string sSaleDt = string.Empty; + string sPosNo = string.Empty; + string sTradeNo = string.Empty; + try + { + // 전송할 Journal 데이터 생성 + htData = GetJournalData(ref dtReturn); + + if(dtReturn == null || dtReturn.Rows.Count == 0) + { + return; + } + else + { + iSendDataCnt += 1; + } + + sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); + sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); + sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); + sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); + sTradeNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "TRADE_NO"); + + string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.JrnlPort), + Convert.ToInt32(m_cPosStatus.Base.JrnlTimeout), + new string[] { sCmpCd, m_cPosStatus.Base.BrandCd, sStorCd, sSaleDt, sPosNo, sTradeNo }, + ItemConst.COMM_MSG_TYPE.JOURNAL, + htData); + + if (sReturn == UserCom.RST_OK) + { + sSendFlag = "1"; // 정상 전송 + + // 전송 건수 증가 + if (sStorCd == m_cPosStatus.Base.StoreNo && sSaleDt == m_cPosStatus.Base.SaleDate) + { + m_cPosStatus.Sale.JourSndCount++; + } + m_cPosStatus.Sale.OnLineStatus = "1"; + } + else + { + sSendFlag = "9"; // 에러 + m_cPosStatus.Sale.OnLineStatus = "0"; + } + } + 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); + sSendFlag = "9"; + } + finally + { + // Flag Update + JournalFlgUpdate(sCmpCd, sStorCd, sPosNo, sSaleDt, sTradeNo, sSendFlag); + } + } + + private int JournalFlgUpdate(string sCmpCd, string sStorCd, string sPosNo, string sSaleDt, string sTradeNo, string sSendFlag) + { + int iRet = UserCom.NG; + string sQuery = string.Empty; + try + { + if (sCmpCd.Trim() == "") return iRet; + if (sStorCd.Trim() == "") return iRet; + if (sPosNo.Trim() == "") return iRet; + if (sSaleDt.Trim() == "") return iRet; + if (sTradeNo.Trim() == "") return iRet; + + sQuery += " UPDATE POSLOG..TR_SALE_JOURNAL "; + sQuery += " SET SEND_YN = '" + sSendFlag + "' "; + sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; + sQuery += " AND SALE_DT = '" + sSaleDt + "' "; + sQuery += " AND STOR_CD = '" + sStorCd + "' "; + sQuery += " AND POS_NO = '" + sPosNo + "' "; + sQuery += " AND TRADE_NO = '" + sTradeNo + "' "; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); + } + 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 iRet; + } + + public Hashtable GetJournalData(ref DataTable dtReturn) + { + Hashtable htReturn = null; + string sQuery = string.Empty; + + string sCmpCd = string.Empty; + string sSaleDt = string.Empty; + string sStorCd = string.Empty; + string sPosNo = string.Empty; + string sTradeNo = string.Empty; + + DataTable dtTempReturn = null; + try + { + sQuery += " SELECT TOP 1 "; + sQuery += " CMP_CD, SALE_DT, STOR_CD, POS_NO, TRADE_NO "; + sQuery += " , '' AS REG_NO, TRADE_DIV, TRAIN_MODE_YN, TRADE_KINDPER, SYS_DT "; + sQuery += " , SYS_TIME, PIC_NO, BILL_AMT, JOURNAL_DATA "; + //grayber@20180212 해피포인트 전자영수증 I/F 개선 #13924 start + sQuery += " , HPC_SAVE_APPR_DT, HPC_SAVE_APPR_NO, HPC_USE_APPR_DT, HPC_USE_APPR_NO "; + //grayber@20180212 해피포인트 전자영수증 I/F 개선 #13924 end + sQuery += " FROM POSLOG..TR_SALE_JOURNAL "; + sQuery += " WHERE SEND_YN <> '1' "; + //#20180131 인천공항 통합POS 사용유무가 사용이면 SEND_YN을 A로 설정 start + //grayber@20180228 [BRKR] 인천공항 SEND_YN 매출전송유무 'A' 제거 start + if(m_cPosStatus.Mst.CorpDiv.Equals(ItemConst.CORP_DIV.BR) != true) + sQuery += " AND SEND_YN <> 'A' "; + //grayber@20180228 [BRKR] 인천공항 SEND_YN 매출전송유무 'A' 제거 end + //#20180131 인천공항 통합POS 사용유무가 사용이면 SEND_YN을 A로 설정 end + sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sQuery += " ORDER BY SEND_YN, SALE_DT, TRADE_NO "; + + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if(dtTempReturn.Rows.Count == 1) + { + DataRow drTempReturn = dtTempReturn.Rows[0]; + + htReturn = MakeJournalJsonData(drTempReturn); + } + } + + dtReturn = dtTempReturn; + } + 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 htReturn; + } + + private Hashtable MakeJournalJsonData(DataRow drData) + { + Hashtable htData = new Hashtable(); + + try + { + // 01 - 회사코드 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.CmpCd, CmUtil.GetDataRowStr(drData, "CMP_CD")); + // 02 - 점포코드 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.StorCd, CmUtil.GetDataRowStr(drData, "STOR_CD")); + // 03 - 판매일자 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.SaleDt, CmUtil.GetDataRowStr(drData, "SALE_DT")); + // 04 - 포스번호 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.PosNo, CmUtil.GetDataRowStr(drData, "POS_NO")); + // 05 - 거래번호 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.TradeNo, CmUtil.GetDataRowStr(drData, "TRADE_NO")); + // 06 - 등록번호 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.RegNo, CmUtil.GetDataRowStr(drData, "REG_NO")); + // 07 - 거래구분 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.TradeDiv, CmUtil.GetDataRowStr(drData, "TRADE_DIV")); + // 08 - 연습모드 여부 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.TrainModeYn, CmUtil.GetDataRowStr(drData, "TRAIN_MODE_YN")); + // 09 - 거래종별 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.TradeKindper, CmUtil.GetDataRowStr(drData, "TRADE_KINDPER")); + // 10 - 시스템일자 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.SysDt, CmUtil.GetDataRowStr(drData, "SYS_DT")); + // 11 - 시스템시간 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.SysTime, CmUtil.GetDataRowStr(drData, "SYS_TIME")); + // 12 - 담당자번호 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.PicNo, CmUtil.GetDataRowStr(drData, "PIC_NO")); + // 13 - 영수금액 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.BillAmt, CmUtil.GetDataRowStr(drData, "BILL_AMT")); + // 14 - 저널데이터 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.JournalData, CmUtil.GetDataRowStr(drData, "JOURNAL_DATA")); + + //grayber@20180212 해피포인트 전자영수증 I/F 개선 #13924 start + // 15 - 해피포인트 적립 승인일자 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.HpcSaveApprDt, CmUtil.GetDataRowStr(drData, "HPC_SAVE_APPR_DT")); + // 16 - 해피포인트 적립 승인번호 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.HpcSaveApprNo, CmUtil.GetDataRowStr(drData, "HPC_SAVE_APPR_NO")); + // 17 - 해피포인트 사용 승인일자 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.HpcUseApprDt, CmUtil.GetDataRowStr(drData, "HPC_USE_APPR_DT")); + // 18 - 해피포인트 사용 승인번호 + htData.Add(Column.IQ_JOURNAL_REQ.DATA.HpcUseApprNo, CmUtil.GetDataRowStr(drData, "HPC_USE_APPR_NO")); + //grayber@20180212 해피포인트 전자영수증 I/F 개선 #13924 end + + } + 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 htData; + } + #endregion + + #region 03 - ApprovalLog 전송 + public void ApprovalLogSendProcess() + { + DataTable dtReturn = null; + Hashtable htData = null; + string sSendFlag = string.Empty; + string sCmpCd = string.Empty; + string sStorCd = string.Empty; + string sSaleDt = string.Empty; + string sPosNo = string.Empty; + string sTradeNo = string.Empty; + string sSeq = string.Empty; + try + { + // 전송할 승인로그 데이터 생성 + htData = GetApprovalLog(ref dtReturn); + + if (dtReturn == null || dtReturn.Rows.Count == 0) + { + return; + } + else + { + iSendDataCnt += 1; + } + + sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); + sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); + sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); + sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); + sTradeNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "TRADE_NO"); + sSeq = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SEQ"); + + string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.JrnlPort), + Convert.ToInt32(m_cPosStatus.Base.JrnlTimeout), + new string[] { sCmpCd, m_cPosStatus.Base.BrandCd, sStorCd, sSaleDt, sPosNo, sTradeNo }, + ItemConst.COMM_MSG_TYPE.APPRLOG, + htData); + + if (sReturn == UserCom.RST_OK) + { + sSendFlag = "1"; // 정상 전송 + m_cPosStatus.Sale.OnLineStatus = "1"; + } + else + { + sSendFlag = "9"; // 에러 + m_cPosStatus.Sale.OnLineStatus = "0"; + } + } + 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); + sSendFlag = "9"; + } + finally + { + // Flag Update + ApprovalLogFlgUpdate(sCmpCd, sStorCd, sPosNo, sSaleDt, sTradeNo, sSeq, sSendFlag); + } + } + + private int ApprovalLogFlgUpdate(string sCmpCd, string sStorCd, string sPosNo, string sSaleDt, string sTradeNo, string sSeq, string sSendFlag) + { + int iRet = UserCom.NG; + string sQuery = string.Empty; + try + { + if (sCmpCd.Trim() == "") return iRet; + if (sSaleDt.Trim() == "") return iRet; + if (sStorCd.Trim() == "") return iRet; + if (sPosNo.Trim() == "") return iRet; + if (sTradeNo.Trim() == "") return iRet; + if (sSeq.Trim() == "") return iRet; + + sQuery += " UPDATE POSLOG..TR_SALE_APPR_LOG "; + sQuery += " SET SEND_YN = '" + sSendFlag + "' "; + sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; + sQuery += " AND SALE_DT = '" + sSaleDt + "' "; + sQuery += " AND STOR_CD = '" + sStorCd + "' "; + sQuery += " AND POS_NO = '" + sPosNo + "' "; + sQuery += " AND TRADE_NO = '" + sTradeNo + "' "; + sQuery += " AND SEQ = '" + sSeq + "' "; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); + } + 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 iRet; + } + + public Hashtable GetApprovalLog(ref DataTable dtReturn) + { + Hashtable htReturn = null; + string sQuery = string.Empty; + + DataTable dtTempReturn = null; + try + { + sQuery += " SELECT TOP 1 "; + sQuery += " CMP_CD, STOR_CD, SALE_DT, POS_NO, TRADE_NO, SEQ, TRADE_DIV "; + sQuery += " , PAY_WAY_CD, PAY_DTL_CD, INQ_TYPE, TRAN_TYPE, CARD_NO, RES_CD, RES_MSG, PAY_AMT "; + sQuery += " , APPR_NO, APPR_DT, APPR_TIME, APPR_LOG, SEND_YN, REG_DATE, REG_ID, UPD_DATE "; + sQuery += " , ISNULL(AMT_ENTRY_01, 0) AMT_ENTRY_01 "; + sQuery += " , ISNULL(AMT_ENTRY_02, 0) AMT_ENTRY_02 "; + sQuery += " , ISNULL(AMT_ENTRY_03, 0) AMT_ENTRY_03 "; + sQuery += " , ISNULL(AMT_ENTRY_04, 0) AMT_ENTRY_04 "; + sQuery += " , ISNULL(AMT_ENTRY_05, 0) AMT_ENTRY_05 "; + + sQuery += " , ISNULL(AMT_ENTRY_06, 0) AMT_ENTRY_06 "; + sQuery += " , ISNULL(AMT_ENTRY_07, 0) AMT_ENTRY_07 "; + sQuery += " , ISNULL(AMT_ENTRY_08, 0) AMT_ENTRY_08 "; + sQuery += " , ISNULL(AMT_ENTRY_09, 0) AMT_ENTRY_09 "; + + sQuery += " , ISNULL(OCCUR_ENTRY_01, '') OCCUR_ENTRY_01 "; + sQuery += " , ISNULL(OCCUR_ENTRY_02, '') OCCUR_ENTRY_02 "; + sQuery += " , ISNULL(OCCUR_ENTRY_03, '') OCCUR_ENTRY_03 "; + sQuery += " , ISNULL(OCCUR_ENTRY_04, '') OCCUR_ENTRY_04 "; + sQuery += " , ISNULL(OCCUR_ENTRY_05, '') OCCUR_ENTRY_05 "; + sQuery += " , ISNULL(OCCUR_ENTRY_06, '') OCCUR_ENTRY_06 "; + sQuery += " , ISNULL(OCCUR_ENTRY_07, '') OCCUR_ENTRY_07 "; + sQuery += " , ISNULL(OCCUR_ENTRY_08, '') OCCUR_ENTRY_08 "; + sQuery += " , ISNULL(OCCUR_ENTRY_09, '') OCCUR_ENTRY_09 "; + + sQuery += " , ISNULL(USE_YN, '1') USE_YN "; + + sQuery += " FROM POSLOG..TR_SALE_APPR_LOG "; + sQuery += " WHERE SEND_YN <> '1' "; + sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sQuery += " ORDER BY SEND_YN, SALE_DT, TRADE_NO, SEQ "; + + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn.Rows.Count == 1) + { + DataRow drTempReturn = dtTempReturn.Rows[0]; + + htReturn = MakeApprovalLogJsonData(drTempReturn); + } + } + + dtReturn = dtTempReturn; + } + 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 htReturn; + } + + private Hashtable MakeApprovalLogJsonData(DataRow drData) + { + Hashtable htData = new Hashtable(); + + try + { + // 01 - 회사코드 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.CmpCd, CmUtil.GetDataRowStr(drData, "CMP_CD")); + // 02 - 점포코드 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.StorCd, CmUtil.GetDataRowStr(drData, "STOR_CD")); + // 03 - 판매일자 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.SaleDt, CmUtil.GetDataRowStr(drData, "SALE_DT")); + // 04 - 포스번호 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.PosNo, CmUtil.GetDataRowStr(drData, "POS_NO")); + // 05 - 거래번호 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.TradeNo, CmUtil.GetDataRowStr(drData, "TRADE_NO")); + // 06 - 순번 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.Seq, CmUtil.GetDataRowStr(drData, "SEQ")); + // 07 - 판매구분 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.TradeDiv, CmUtil.GetDataRowStr(drData, "TRADE_DIV")); + // 08 - 결제 구분 코드 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.PayWayCd, CmUtil.GetDataRowStr(drData, "PAY_WAY_CD")); + // 09 - 결제 상세 코드 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.PayDtlCd, CmUtil.GetDataRowStr(drData, "PAY_DTL_CD")); + // 10 - 승인구분 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.InqType, CmUtil.GetDataRowStr(drData, "INQ_TYPE")); + // 11 - 요청구분 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.TranType, CmUtil.GetDataRowStr(drData, "TRAN_TYPE")); + // 12 - 카드번호 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.CardNo, CmUtil.GetDataRowStr(drData, "CARD_NO")); + // 13 - 응답상태값 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.ResCd, CmUtil.GetDataRowStr(drData, "RES_CD")); + // 14 - 응답 메시지 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.ResMsg, CmUtil.GetDataRowStr(drData, "RES_MSG")); + // 15 - 결제금액 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.PayAmt, CmUtil.GetDataRowStr(drData, "PAY_AMT")); + // 16 - 승인번호 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.ApprNo, CmUtil.GetDataRowStr(drData, "APPR_NO")); + // 17 - 승인일자 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.ApprDt, CmUtil.GetDataRowStr(drData, "APPR_DT")); + // 18 - 승인시간 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.ApprTime, CmUtil.GetDataRowStr(drData, "APPR_TIME")); + // 19 - 입력데이터 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.ApprLog, CmUtil.GetDataRowStr(drData, "APPR_LOG")); + // 20 - 등록자ID + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.RegId, CmUtil.GetDataRowStr(drData, "REG_ID")); + // 21 - 금액1 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_01, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_01")); + // 22 - 금액2 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_02, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_02")); + // 23 - 금액3 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_03, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_03")); + // 24 - 금액4 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_04, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_04")); + // 25 - 금액5 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_05, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_05")); + + // 26 - 금액6 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_06, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_06")); + // 27 - 금액7 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_07, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_07")); + // 28 - 금액8 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_08, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_08")); + // 29 - 금액9 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.AMT_ENTRY_09, CmUtil.GetDataRowStr(drData, "AMT_ENTRY_09")); + + // 30 - 입력값1 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_01, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_01")); + // 31 - 입력값2 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_02, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_02")); + // 32 - 입력값3 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_03, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_03")); + // 33 - 입력값4 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_04, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_04")); + // 34 - 입력값5 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_05, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_05")); + // 35 - 입력값6 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_06, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_06")); + // 36 - 입력값7 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_07, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_07")); + // 37 - 입력값8 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_08, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_08")); + // 38 - 입력값9 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.OCCUR_ENTRY_09, CmUtil.GetDataRowStr(drData, "OCCUR_ENTRY_09")); + + // 39 - 사용여부 + htData.Add(Column.IQ_APPROVAL_LOG_REQ.DATA.USE_YN, CmUtil.GetDataRowStr(drData, "USE_YN")); + } + 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 htData; + } + #endregion + + #region 04 - ETC TRAN 전송 + public void ETCTranLogSendProcess() + { + string sendFlag = string.Empty; + string sCMP_CD = string.Empty; + string sSTOR_CD = string.Empty; + string sSALE_DT = string.Empty; + string sPOS_NO = string.Empty; + string sTRADE_NO = string.Empty; + + string sREG_NO = string.Empty; + string sTRADE_DIV = string.Empty; + string sTRAIN_MODE_YN = string.Empty; + string sTRADE_KINDPER = string.Empty; + string sSYS_DT = string.Empty; + string sORG_SALE_DT = string.Empty; + string sORG_POS_NO = string.Empty; + string sORG_TRADE_NO = string.Empty; + string sQTY = string.Empty; + string sTOTSALE_AMT = string.Empty; + string sTOTDC_AMT = string.Empty; + string sNET_SALE_AMT = string.Empty; + DataTable dtReturn = null; + try + { + // 전송할 ETC TRAN 데이터 생성 + string sEtcTranLog = GetEtcTranLog(ref dtReturn); + + if (sEtcTranLog == "" || dtReturn.Rows.Count == 0) + { + return; + } + else + { + iSendDataCnt += 1; + } + + sendFlag = "0"; // 0:미전송, 1:전송, 9:에러 + + DataRow dr = dtReturn.Rows[0]; + sCMP_CD = CmUtil.GetDataRowStr(dr, "CMP_CD"); + sSTOR_CD = CmUtil.GetDataRowStr(dr, "STOR_CD"); + sSALE_DT = CmUtil.GetDataRowStr(dr, "SALE_DT"); + sPOS_NO = CmUtil.GetDataRowStr(dr, "POS_NO"); + sREG_NO = CmUtil.GetDataRowStr(dr, "REG_NO"); + + sTRADE_NO = CmUtil.GetDataRowStr(dr, "TRADE_NO"); + sTRADE_DIV = CmUtil.GetDataRowStr(dr, "TRADE_DIV"); + sTRAIN_MODE_YN = CmUtil.GetDataRowStr(dr, "TRAIN_MODE_YN"); + sTRADE_KINDPER = CmUtil.GetDataRowStr(dr, "TRADE_KINDPER"); + sSYS_DT = CmUtil.GetDataRowStr(dr, "SYS_DT"); + sORG_SALE_DT = CmUtil.GetDataRowStr(dr, "ORG_BILLDT"); + sORG_POS_NO = CmUtil.GetDataRowStr(dr, "ORG_BILL_POSNO"); + sORG_TRADE_NO = CmUtil.GetDataRowStr(dr, "ORG_BILL_NO"); + sQTY = CmUtil.GetDataRowStr(dr, "QTY"); + sTOTSALE_AMT = CmUtil.GetDataRowStr(dr, "TOTSALE_AMT"); + sTOTDC_AMT = CmUtil.GetDataRowStr(dr, "TOTDC_AMT"); + sNET_SALE_AMT = CmUtil.GetDataRowStr(dr, "NET_SALE_AMT"); + + string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.EtcTranPort), + 8000, + new string[] { sCMP_CD, m_cPosStatus.Base.BrandCd, sSTOR_CD, sSALE_DT, sPOS_NO, sTRADE_NO }, + ItemConst.COMM_MSG_TYPE.ETCTRAN, + MakeTranLogJsonData(dr, sEtcTranLog)); + + if (sReturn == UserCom.RST_OK) + { + sendFlag = "1"; // 정상 전송 + + m_cPosStatus.Sale.OnLineStatus = "1"; + } + else + { + sendFlag = "9"; // 에러 + m_cPosStatus.Sale.OnLineStatus = "0"; + } + } + 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); + sendFlag = "9"; + } + finally + { + // Flag Update + ETCTranLogFlgUpdate(sCMP_CD, sSTOR_CD, sPOS_NO, sSALE_DT, sREG_NO, sendFlag); + } + } + + /// + /// 정상으로 송신한 경우 Flg추가용 쿼리 + /// + /// + /// + /// + /// + /// + /// + /// + public int ETCTranLogFlgUpdate(string pCompanyCd, string pStoreNo, string pPosNo, string pSaleDate, string pRegNo, string pSendFlag) + { + int iRet = UserCom.NG; ; + string sQuery = ""; + + try + { + if (pCompanyCd.Trim() == "") return iRet; + if (pStoreNo.Trim() == "") return iRet; + if (pPosNo.Trim() == "") return iRet; + if (pSaleDate.Trim() == "") return iRet; + if (pRegNo.Trim() == "") return iRet; + + sQuery = "UPDATE POSLOG..ETC_SALE_HEADER "; + sQuery += " SET SEND_YN = '" + pSendFlag + "' "; + sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + sQuery += " WHERE CMP_CD = '" + pCompanyCd + "' "; + sQuery += " AND SALE_DT = '" + pSaleDate + "' "; + sQuery += " AND STOR_CD = '" + pStoreNo + "' "; + sQuery += " AND POS_NO = '" + pPosNo + "' "; + sQuery += " AND REG_NO = '" + pRegNo + "' "; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); + } + 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 iRet; + } + + /// + /// ETC TranLog 조회 + /// + /// 0:미전송, 1:전송, 9:에러 + /// + public string GetEtcTranLog(ref DataTable dtReturn) + { + string sQuery = ""; + string sCMP_CD = ""; + string sSTOR_CD = ""; + string sSALE_DT = ""; + string sPOS_NO = ""; + string sREG_NO = ""; + string sTRADE_NO = ""; + + string sTranData = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT TOP 1 "; + sQuery += " CMP_CD, SALE_DT, STOR_CD, POS_NO, REG_NO "; + sQuery += " , TRADE_NO, TRADE_DIV, TRAIN_MODE_YN, TRADE_KINDPER, SYS_DT "; + sQuery += " , ORG_BILLDT, ORG_BILL_POSNO, ORG_BILL_NO, QTY, TOTSALE_AMT "; + sQuery += " , TOTDC_AMT, NET_SALE_AMT "; + sQuery += " FROM POSLOG..ETC_SALE_HEADER "; + sQuery += " WHERE SEND_YN <> '1' "; + sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sQuery += " ORDER BY SEND_YN, SALE_DT, REG_NO "; + + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn.Rows.Count == 1) + { + DataRow drTempReturn = dtTempReturn.Rows[0]; + + sCMP_CD = drTempReturn["CMP_CD"].ToString(); + sSTOR_CD = drTempReturn["STOR_CD"].ToString(); + sSALE_DT = drTempReturn["SALE_DT"].ToString(); + sPOS_NO = drTempReturn["POS_NO"].ToString(); + sREG_NO = drTempReturn["REG_NO"].ToString(); + sTRADE_NO = drTempReturn["TRADE_NO"].ToString(); + + sTranData = GetEtcTranHeader(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sREG_NO) + + GetEtcTranDetail(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sREG_NO) + + GetEtcTranPay(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sREG_NO) + + GetEtcTranEtc(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sREG_NO) + + GetEtcTranDpst(sCMP_CD, sSTOR_CD, sSALE_DT, sPOS_NO, sREG_NO); + } + } + + dtReturn = dtTempReturn; + } + catch (Exception ex) + { + sTranData = ""; + 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 sTranData; + } + + private string GetEtcTranHeader(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sREG_NO) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '" + ItemConst.IRT_TRAN_TYPE.EtcTranHeader + "' + '|' + '000000' + '|' + '0' + '|' + ISNULL(TRADE_DIV, '') + '|' + ISNULL(TRAIN_MODE_YN, '') + '|' + ISNULL(TRADE_KINDPER, '') + '|' + ISNULL(SYS_DT, '') + '|' + ISNULL(ORD_TIME, '') + '|' + "; + sQuery += " ISNULL(PAY_TIME, '') + '|' + ISNULL(PIC_NO, '') + '|' + ISNULL(ORD_PIC_NO, '') + '|' + ISNULL(STOR_OWN_PART_TIME_DIV, '') + '|' + ISNULL(ORG_BILL_POSNO, '') + '|' + "; + sQuery += " ISNULL(ORG_BILLDT, '') + '|' + ISNULL(ORG_BILL_NO, '') + '|' + ISNULL(RTN_RSN_CD, '') + '|' + ISNULL(RTN_RSN_MEMO, '') + '|' + ISNULL(NONSALES_RSN_CD, '') + '|' + "; + sQuery += " ISNULL(RESERV_NO, '') + '|' + ISNULL(RESERV_DT, '') + '|' + ISNULL(CUST_NO, '') + '|' + ISNULL(ORD_DIV, '') + '|' + ISNULL(FLOOR_CD, '') + '|' + "; + sQuery += " ISNULL(TBL_NO, '') + '|' + ISNULL(GUESTFLOOR, '') + '|' + ISNULL(FRGNR_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(CUSTCNT, 0)) + '|' + ISNULL(PAY_GNDR_DIV, '') + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(PAY_AGE, 0)) + '|' + CONVERT(VARCHAR, ISNULL(MAN_CMPNPSN_CNT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(WOMAN_CMPNPSN_CNT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(TOTSALE_AMT, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(TOTDC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(NET_SALE_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ITEM_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPI_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(COOP_CARD_DC_AMT, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(POINT_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPN_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(EMP_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SET_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ETC_AMT, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(EXCEP_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(TOT_VAT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_VAT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ETC_VAT, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(AF_ACCUM_POINT_AMT, 0)) + '|' + ISNULL(AF_ACCUM_POINT_INFO, '') + '|' + ISNULL(PPCARD_CUSTNM, '') + '|' + ISNULL(AMT_DUTCHPAY_YN, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_CNT, 0)) + '|'+ ISNULL(ORDER_NO, '') + '|' + "; + + //#20170828 해피포인트 적립 제외 버튼 추가 phj, start + //기존 + //sQuery += " ISNULL(SLACK_FIELD, '') + '|' + ISNULL(MID_CLOSE_SEQ, '') + '|' + ISNULL(PPCARD_CUSTID, '') + '|' + ISNULL(PACK_TRADE_DIV, '') + '|' + ISNULL(VIP_TY, '') "; + //변경 + sQuery += " ISNULL(SLACK_FIELD, '') + '|' + ISNULL(MID_CLOSE_SEQ, '') + '|' + ISNULL(PPCARD_CUSTID, '') + '|' + ISNULL(PACK_TRADE_DIV, '') + '|' + ISNULL(VIP_TY, '') + '|' + ISNULL(HP_EXCLUDE_YN, '0')"; + //#20170828 해피포인트 적립 제외 버튼 추가 phj, end + + sQuery += " AS ETC_TR_HEADER "; + sQuery += " FROM POSLOG..ETC_SALE_HEADER "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND SALE_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + sQuery += " AND POS_NO = '{3}' "; + sQuery += " AND REG_NO = '{4}' "; + + sSQL = string.Format(sQuery + , sCMP_CD + , sSALE_DT + , sSTOR_CD + , sPOS_NO + , sREG_NO); + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + + private string GetEtcTranDetail(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sREG_NO) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.EtcTranDetail + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(ORD_TIME, '') + '|' + ISNULL(FLOOR_CD, '') + '|' + ISNULL(TBL_NO, '') + '|' + "; + sQuery += " ISNULL(SUB_SHOP_CD, '') + '|' + ISNULL(ITEM_PLU_CD, '') + '|' + ISNULL(ITEM_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(SALE_QTY, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SALE_PRC, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(SALE_AMT, 0)) + '|' + ISNULL(FLAVOUR_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(FLAVOUR_WEIGHT, 0)) + '|' + ISNULL(ITEM_INPUT_DIV, '') + '|' + ISNULL(ITEM_BAR_CD, '') + '|' + "; + sQuery += " ISNULL(TAKE_IN_OUT_DIV, '') + '|' + ISNULL(ITEM_TAX_DIV, '') + '|' + ISNULL(TAX_AMT_INCLUDE_YN, '') + '|' + ISNULL(TAXRATE_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(APPLY_TAX_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SVC_FEE_VAT, 0)) + '|' + "; + sQuery += " ISNULL(SVC_TAXREATE_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(BILL_AMT, 0)) + '|' + ISNULL(NONSALES_RSN_CD, '') + '|' + ISNULL(DC_DIV, '') + '|' + ISNULL(DC_TYPE, '') + '|' + CONVERT(VARCHAR, ISNULL(DC_RATE, 0)) + '|' + CONVERT(VARCHAR, ISNULL(ITEM_DC_AMT, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(SUM_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPI_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(CPI_DC_AMT, 0)) + '|' + ISNULL(COOP_CARD_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(COOP_CARD_DC_AMT, 0)) + '|' + ISNULL(POINT_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(POINT_DC_AMT, 0)) + '|' + "; + sQuery += " ISNULL(CPN_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(CPN_DC_AMT, 0)) + '|' + ISNULL(EMP_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(EMP_DC_AMT, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SET_DC_AMT, 0)) + '|' + ISNULL(ETC_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(ETC_DC_AMT, 0)) + '|' + ISNULL(EXCEP_DC_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(EXCEP_DC_AMT, 0)) + '|' + ISNULL(PACK_DIV, '') + '|' + "; + sQuery += " ISNULL(SET_MENU_CD, '') + '|' + ISNULL(SUBPRC_MENU_KEY_DIV, '') + '|' + ISNULL(CPI_PRESENT_DIV, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(SALE_GIFT_NO, '') + '|' + ISNULL(CPN_NO, '') + '|' + ISNULL(SLACK_FIELD, '') + '|' + ISNULL(DISPO_ITEM_DIV, '') + '|' + ISNULL(CANCEL_DIV, '') + '|' + ISNULL(NOTAX_DIV, '0') AS ETC_TR_DETAIL"; + sQuery += " FROM POSLOG..ETC_SALE_DETAIL "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND SALE_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + sQuery += " AND POS_NO = '{3}' "; + sQuery += " AND REG_NO = '{4}' "; + + sSQL = string.Format(sQuery + , sCMP_CD + , sSALE_DT + , sSTOR_CD + , sPOS_NO + , sREG_NO); + + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + + private string GetEtcTranPay(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sREG_NO) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.EtcTranPay + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(PAY_WAY_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(PAY_AMT, 0)) + '|' + ISNULL(PAY_DTL_CD_01, '') + '|' + ISNULL(PAY_DTL_CD_02, '') + '|' + "; + sQuery += " ISNULL(PAY_DTL_CD_03, '') + '|' + ISNULL(PAY_DTL_CD_04, '') + '|' + ISNULL(PAY_DTL_CD_05, '') + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_02, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(QTY_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_05, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_02, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(AMT_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_05, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_06, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_07, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(AMT_ENTRY_08, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_09, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_10, 0)) + '|' + ISNULL(OCCUR_ENTRY_01, '') + '|' + ISNULL(OCCUR_ENTRY_02, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_03, '') + '|' + ISNULL(OCCUR_ENTRY_04, '') + '|' + ISNULL(OCCUR_ENTRY_05, '') + '|' + ISNULL(OCCUR_ENTRY_06, '') + '|' + ISNULL(OCCUR_ENTRY_07, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_08, '') + '|' + ISNULL(OCCUR_ENTRY_09, '') + '|' + ISNULL(OCCUR_ENTRY_10, '') + '|' + ISNULL(OCCUR_ENTRY_11, '') + '|' + ISNULL(OCCUR_ENTRY_12, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_13, '') + '|' + ISNULL(OCCUR_ENTRY_14, '') + '|' + ISNULL(OCCUR_ENTRY_15, '') + '|' + ISNULL(OCCUR_ENTRY_16, '') + '|' + ISNULL(OCCUR_ENTRY_17, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_18, '') + '|' + ISNULL(OCCUR_ENTRY_19, '') + '|' + ISNULL(OCCUR_ENTRY_20, '') + '|' + ISNULL(OCCUR_ENTRY_21, '') + '|' + ISNULL(OCCUR_ENTRY_22, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_23, '') + '|' + ISNULL(OCCUR_ENTRY_24, '') + '|' + ISNULL(OCCUR_ENTRY_25, '') + '|' + CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(CANCEL_DIV, '') AS ETC_TR_PAY"; + sQuery += " FROM POSLOG..ETC_SALE_PAY "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND SALE_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + sQuery += " AND POS_NO = '{3}' "; + sQuery += " AND REG_NO = '{4}' "; + + sSQL = string.Format(sQuery + , sCMP_CD + , sSALE_DT + , sSTOR_CD + , sPOS_NO + , sREG_NO); + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + + private string GetEtcTranEtc(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sREG_NO) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.EtcTranEtc + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(ETC_WAY_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(ETC_AMT, 0)) + '|' + "; + sQuery += " ISNULL(ETC_DTL_CD_01, '') + '|' + ISNULL(ETC_DTL_CD_02, '') + '|' + ISNULL(ETC_DTL_CD_03, '') + '|' + ISNULL(ETC_DTL_CD_04, '') + '|' + ISNULL(ETC_DTL_CD_05, '') + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(QTY_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_02, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(QTY_ENTRY_05, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(AMT_ENTRY_01, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_02, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_03, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_04, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_05, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(AMT_ENTRY_06, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_07, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_08, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_09, 0)) + '|' + CONVERT(VARCHAR, ISNULL(AMT_ENTRY_10, 0)) + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_01, '') + '|' + ISNULL(OCCUR_ENTRY_02, '') + '|' + ISNULL(OCCUR_ENTRY_03, '') + '|' + ISNULL(OCCUR_ENTRY_04, '') + '|' + ISNULL(OCCUR_ENTRY_05, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_06, '') + '|' + ISNULL(OCCUR_ENTRY_07, '') + '|' + ISNULL(OCCUR_ENTRY_08, '') + '|' + ISNULL(OCCUR_ENTRY_09, '') + '|' + ISNULL(OCCUR_ENTRY_10, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_11, '') + '|' + ISNULL(OCCUR_ENTRY_12, '') + '|' + ISNULL(OCCUR_ENTRY_13, '') + '|' + ISNULL(OCCUR_ENTRY_14, '') + '|' + ISNULL(OCCUR_ENTRY_15, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_16, '') + '|' + ISNULL(OCCUR_ENTRY_17, '') + '|' + ISNULL(OCCUR_ENTRY_18, '') + '|' + ISNULL(OCCUR_ENTRY_19, '') + '|' + ISNULL(OCCUR_ENTRY_20, '') + '|' + "; + sQuery += " ISNULL(OCCUR_ENTRY_21, '') + '|' + ISNULL(OCCUR_ENTRY_22, '') + '|' + ISNULL(OCCUR_ENTRY_23, '') + '|' + ISNULL(OCCUR_ENTRY_24, '') + '|' + ISNULL(OCCUR_ENTRY_25, '') + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(BILLSPR_NO, 0)) + '|' + ISNULL(CANCEL_DIV, '') AS ETC_TR_ETC"; + sQuery += " FROM POSLOG..ETC_SALE_ETC "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND SALE_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + sQuery += " AND POS_NO = '{3}' "; + sQuery += " AND REG_NO = '{4}' "; + + sSQL = string.Format(sQuery + , sCMP_CD + , sSALE_DT + , sSTOR_CD + , sPOS_NO + , sREG_NO); + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + + private string GetEtcTranDpst(string sCMP_CD, string sSTOR_CD, string sSALE_DT, string sPOS_NO, string sREG_NO) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.EtcTranDpst + "' + '|' + '000000' + '|' + CONVERT(VARCHAR, ISNULL(SEQ, 0)) + '|' + ISNULL(DPST_WTHDR_TYPE, '') + '|' + ISNULL(DPST_WTHDR_ACC_CD, '') + '|' + ISNULL(DPST_WTHDR_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(DPST_WTHDR_QTY, 0)) + '|' + "; + sQuery += " CONVERT(VARCHAR, ISNULL(DPST_WTHDR_AMT, 0)) + '|' + ISNULL(DPST_WTHDR_NM, '') + '|' + ISNULL(CUST_NO, '') + '|' + ISNULL(STOR_PAY_TYPE, '') + '|' + ISNULL(ETC_REASON, '') + '|' + ISNULL(SLACK_FIELD_01, '') + '|' + ISNULL(SLACK_FIELD_02, '') + '|' + ISNULL(SLACK_FIELD_03, '') + '|' + "; + sQuery += " ISNULL(SLACK_FIELD_04, '') + '|' + ISNULL(SLACK_FIELD_05, '') AS TR_DPST "; + sQuery += " FROM POSLOG..ETC_SALE_DPST_WTHDR "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND SALE_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + sQuery += " AND POS_NO = '{3}' "; + sQuery += " AND REG_NO = '{4}' "; + + sSQL = string.Format( sQuery + , sCMP_CD + , sSALE_DT + , sSTOR_CD + , sPOS_NO + , sREG_NO); + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + #endregion + + #region 05 - ETC Journal 전송 + public void ETCJournalSendProcess() + { + DataTable dtReturn = null; + Hashtable htData = null; + string sSendFlag = string.Empty; + string sCmpCd = string.Empty; + string sStorCd = string.Empty; + string sSaleDt = string.Empty; + string sPosNo = string.Empty; + string sRegNo = string.Empty; + string sTradeNo = string.Empty; + try + { + // 전송할 Journal 데이터 생성 + htData = GetEtcJournalData(ref dtReturn); + + if (dtReturn == null || dtReturn.Rows.Count == 0) + { + return; + } + else + { + iSendDataCnt += 1; + } + + sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); + sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); + sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); + sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); + sRegNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "REG_NO"); + sTradeNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "TRADE_NO"); + + string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.JrnlPort), + Convert.ToInt32(m_cPosStatus.Base.JrnlTimeout), + new string[] { sCmpCd, m_cPosStatus.Base.BrandCd, sStorCd, sSaleDt, sPosNo, sTradeNo }, + ItemConst.COMM_MSG_TYPE.ETCJNRL, + htData); + + if (sReturn == UserCom.RST_OK) + { + sSendFlag = "1"; // 정상 전송 + m_cPosStatus.Sale.OnLineStatus = "1"; + } + else + { + sSendFlag = "9"; // 에러 + m_cPosStatus.Sale.OnLineStatus = "0"; + } + } + 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); + sSendFlag = "9"; + } + finally + { + // Flag Update + EtcJournalFlgUpdate(sCmpCd, sStorCd, sPosNo, sSaleDt, sRegNo, sSendFlag); + } + } + + private int EtcJournalFlgUpdate(string sCmpCd, string sStorCd, string sPosNo, string sSaleDt, string sRegNo, string sSendFlag) + { + int iRet = UserCom.NG; + string sQuery = string.Empty; + try + { + if (sCmpCd.Trim() == "") return iRet; + if (sStorCd.Trim() == "") return iRet; + if (sPosNo.Trim() == "") return iRet; + if (sSaleDt.Trim() == "") return iRet; + if (sRegNo.Trim() == "") return iRet; + + sQuery += " UPDATE POSLOG..ETC_SALE_JOURNAL "; + sQuery += " SET SEND_YN = '" + sSendFlag + "' "; + sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; + sQuery += " AND SALE_DT = '" + sSaleDt + "' "; + sQuery += " AND STOR_CD = '" + sStorCd + "' "; + sQuery += " AND POS_NO = '" + sPosNo + "' "; + sQuery += " AND REG_NO = '" + sRegNo + "' "; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); + } + 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 iRet; + } + + public Hashtable GetEtcJournalData(ref DataTable dtReturn) + { + Hashtable htReturn = null; + string sQuery = string.Empty; + + string sCmpCd = string.Empty; + string sSaleDt = string.Empty; + string sStorCd = string.Empty; + string sPosNo = string.Empty; + string sRegNo = string.Empty; + string sTradeNo = string.Empty; + + DataTable dtTempReturn = null; + try + { + sQuery += " SELECT TOP 1 "; + sQuery += " CMP_CD, SALE_DT, STOR_CD, POS_NO, REG_NO "; + sQuery += " , TRADE_NO, TRADE_DIV, TRAIN_MODE_YN, TRADE_KINDPER, SYS_DT "; + sQuery += " , SYS_TIME, PIC_NO, BILL_AMT, JOURNAL_DATA "; + sQuery += " FROM POSLOG..ETC_SALE_JOURNAL "; + sQuery += " WHERE SEND_YN <> '1' "; + sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sQuery += " ORDER BY SEND_YN, SALE_DT, REG_NO "; + + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn.Rows.Count == 1) + { + DataRow drTempReturn = dtTempReturn.Rows[0]; + + htReturn = MakeJournalJsonData(drTempReturn); + } + } + + dtReturn = dtTempReturn; + } + 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 htReturn; + } + #endregion + + #region 06 - Cashier Test Log 전송 + public void CashierTestLogSendProcess() + { + DataTable dtReturn = null; + Hashtable htData = null; + string sSendFlag = string.Empty; + string sCmpCd = string.Empty; + string sStorCd = string.Empty; + string sSaleDt = string.Empty; + string sPosNo = string.Empty; + string sSeq = string.Empty; + try + { + // 전송할 승인로그 데이터 생성 + htData = GetCashierTestLog(ref dtReturn); + + if (dtReturn == null || dtReturn.Rows.Count == 0) + { + return; + } + else + { + iSendDataCnt += 1; + } + + sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); + sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); + sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); + sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); + sSeq = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SEQ_NO"); + + string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.JrnlPort), + Convert.ToInt32(m_cPosStatus.Base.JrnlTimeout), + new string[] { sCmpCd, m_cPosStatus.Base.BrandCd, sStorCd, sSaleDt, sPosNo, "00000" }, + ItemConst.COMM_MSG_TYPE.TESTLOG, + htData); + + if (sReturn == UserCom.RST_OK) + { + sSendFlag = "1"; // 정상 전송 + m_cPosStatus.Sale.OnLineStatus = "1"; + } + else + { + sSendFlag = "9"; // 에러 + m_cPosStatus.Sale.OnLineStatus = "0"; + } + } + 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); + sSendFlag = "9"; + } + finally + { + // Flag Update + CashierTestLogFlgUpdate(sCmpCd, sStorCd, sPosNo, sSaleDt, sSeq, sSendFlag); + } + } + + private int CashierTestLogFlgUpdate(string sCmpCd, string sStorCd, string sPosNo, string sSaleDt, string sSeq, string sSendFlag) + { + int iRet = UserCom.NG; + string sQuery = string.Empty; + try + { + if (sCmpCd.Trim() == "") return iRet; + if (sSaleDt.Trim() == "") return iRet; + if (sStorCd.Trim() == "") return iRet; + if (sPosNo.Trim() == "") return iRet; + if (sSeq.Trim() == "") return iRet; + + sQuery = " UPDATE POSLOG..TR_CASHIER_TEST "; + sQuery += " SET SEND_YN = '" + sSendFlag + "' "; + sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; + sQuery += " AND SALE_DT = '" + sSaleDt + "' "; + sQuery += " AND STOR_CD = '" + sStorCd + "' "; + sQuery += " AND POS_NO = '" + sPosNo + "' "; + sQuery += " AND SEQ_NO = '" + sSeq + "' "; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); + } + 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 iRet; + } + + public Hashtable GetCashierTestLog(ref DataTable dtReturn) + { + Hashtable htReturn = null; + string sQuery = string.Empty; + + DataTable dtTempReturn = null; + try + { + sQuery = " SELECT TOP 1 "; + sQuery += " CMP_CD, SALE_DT, STOR_CD, POS_NO, SEQ_NO, TEST_KIND, TEST_DATE "; + sQuery += " , CASHIER_NO, TEST_ENTRY_ID, PASS_CNT, TEST_CNT, TEST_PASS_YN "; + sQuery += " , SEND_YN, REG_DATE, UPD_DATE "; + sQuery += " FROM POSLOG..TR_CASHIER_TEST "; + sQuery += " WHERE SEND_YN <> '1' "; + sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sQuery += " ORDER BY SEND_YN, SALE_DT, SEQ_NO "; + + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn.Rows.Count == 1) + { + DataRow drTempReturn = dtTempReturn.Rows[0]; + + htReturn = MakeCashierTestLogJsonData(drTempReturn); + } + } + + dtReturn = dtTempReturn; + } + 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 htReturn; + } + + private Hashtable MakeCashierTestLogJsonData(DataRow drData) + { + Hashtable htData = new Hashtable(); + + try + { + // 01 - 회사코드 + htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.CmpCd, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.CmpCd)); + // 02 - 판매 일자 + htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.SaleDt, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.SaleDt)); + // 03 - 점포 코드 + htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.StorCd, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.StorCd)); + // 04 - 포스 번호 + htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.PosNo, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.PosNo)); + // 05 - 순번 + htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.SeqNo, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.SeqNo)); + // 06 - 시험 종류 + htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestKind, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestKind)); + // 07 - 시험 일시 + htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestDate, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestDate)); + // 08 - 계산원 번호 + htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.CashierNo, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.CashierNo)); + // 09 - 시험항목 ID + htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestEntryId, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestEntryId)); + // 10 - 정답 항목 수 + htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.PassCnt, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.PassCnt)); + // 11 - 시험 항목 수 + htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestCnt, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestCnt)); + // 12 - 시험 합격 여부 + htData.Add(Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestPassYn, CmUtil.GetDataRowStr(drData, Column.IQ_CASHIER_TEST_LOG_REQ.DATA.TestPassYn)); + } + 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 htData; + } + #endregion + + #region 07 - 도로공사(고속도로 휴게소 입점 POS) 매출 I/F XML파일 생성 + public void MakeTranToExProcess() + { + string sendFlag = string.Empty; + string sCmpCd = string.Empty; + string sSaleDt = string.Empty; + string sStorCd = string.Empty; + string sPosNo = string.Empty; + string sTradeNo = string.Empty; + + DataTable dtReturn = null; + try + { + // 전송할 데이터 조회 + GetTranInfo(ref dtReturn); + + if(dtReturn == null || dtReturn.Rows.Count == 0) + { + return; + } + else + { + iSendDataCnt += 1; + } + + sendFlag = "0"; // 0:미전송, 1:전송, 8:파일생성, 9:에러 + + DataRow dr = dtReturn.Rows[0]; + sCmpCd = CmUtil.GetDataRowStr(dr, "CMP_CD"); + sSaleDt = CmUtil.GetDataRowStr(dr, "SALE_DT"); + sStorCd = CmUtil.GetDataRowStr(dr, "STOR_CD"); + sPosNo = CmUtil.GetDataRowStr(dr, "POS_NO"); + sTradeNo = CmUtil.GetDataRowStr(dr, "TRADE_NO"); + + DataTable dtTRHeader = GetTranHeaderForEx(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + DataTable dtTRDetail = GetTranDetailForEx(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + DataTable dtTRCashData = GetTranCashDataForEx(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + DataTable dtTRCardData = GetTranCardDataForEx(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + + XmlDocument doc = new XmlDocument(); + XmlDeclaration docClaration = doc.CreateXmlDeclaration("1.0", null, null); + XmlElement root = doc.DocumentElement; + doc.InsertBefore(docClaration, root); + + + XmlElement erestNode = doc.CreateElement("EREST"); + doc.AppendChild(erestNode); + + MakeXmlHeader(ref doc, ref erestNode, dtTRHeader); + MakeXmlDetail(ref doc, ref erestNode, dtTRDetail); + MakeXmlCashData(ref doc, ref erestNode, dtTRCashData); + MakeXmlCardData(ref doc, ref erestNode, dtTRCardData); + + // 매출 TRAN XML 파일 생성 + string sFileNm = "H1" + "_" + sCmpCd + "_" + sStorCd + "_" + sPosNo + "_" + sSaleDt + "_" + sTradeNo + ".xml"; + doc.Save(BaseCom.NxDataPath + "SEND\\EX\\" + sFileNm); + + sendFlag = "8"; + } + 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 (함수명)) + "도로공사 매출XML 파일 생성 에러-" + sSaleDt + "/" + sStorCd + "/" + sPosNo + "/" + sTradeNo + ":" + ex.Message); + sendFlag = "9"; + } + finally + { + // Flag Update + OutsideTranSendFlgUpdate(sCmpCd, sStorCd, sPosNo, sSaleDt, sTradeNo, sendFlag); + } + } + + private int OutsideTranSendFlgUpdate(string pCompanyCd, string pStoreNo, string pPosNo, string pSaleDate, string pTradeNo, string pSendFlag) + { + int iRet = UserCom.NG; + string sQuery = ""; + + try + { + if (pCompanyCd.Trim() == "") return iRet; + if (pSaleDate.Trim() == "") return iRet; + if (pStoreNo.Trim() == "") return iRet; + if (pPosNo.Trim() == "") return iRet; + if (pTradeNo.Trim() == "" || pTradeNo.Trim() == "99999") return iRet; + + sQuery = "UPDATE POSLOG..TR_SALE_HEADER "; + sQuery += " SET OUT_SEND_YN = '" + pSendFlag + "' "; + sQuery += " WHERE CMP_CD = '" + pCompanyCd + "' "; + sQuery += " AND STOR_CD = '" + pStoreNo + "' "; + sQuery += " AND SALE_DT = '" + pSaleDate + "' "; + sQuery += " AND POS_NO = '" + pPosNo + "' "; + sQuery += " AND TRADE_NO = '" + pTradeNo + "' "; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); + } + 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 iRet; + } + + private void GetTranInfo(ref DataTable dtReturn) + { + string sQuery = string.Empty; + DataTable dtTempReturn = null; + + try + { + sQuery = " SELECT TOP 1 \n" + + " CMP_CD, SALE_DT, STOR_CD, POS_NO, TRADE_NO \n" + + " FROM POSLOG..TR_SALE_HEADER \n" + + " WHERE TRADE_KINDPER = '00' \n" + + " AND OUT_SEND_YN = '0' \n" + + " AND TRAIN_MODE_YN = '0' \n" + + " AND TRADE_KINDPER = '00' \n" + + " ORDER BY SALE_DT, TRADE_NO, OUT_SEND_YN \n"; + + sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn); + + dtReturn = dtTempReturn; + } + 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); + } + } + + private void MakeXmlHeader(ref XmlDocument doc, ref XmlElement upperNode, DataTable dtData) + { + try + { + DataRow dr = dtData.Rows[0]; + //----------------------------------------------------------------------------------------- + // TXJM-FD + //----------------------------------------------------------------------------------------- + XmlElement TXJMNode = doc.CreateElement("TXJM-FD"); + + TXJMNode.SetAttribute("SRID", "SL010"); // 1.전문ID (5) + TXJMNode.SetAttribute("RETCD", "0000"); // 2.전문적합성체크 (4) + TXJMNode.SetAttribute("TRHDR_CNT", "1"); // 3.헤더Count (2) + TXJMNode.SetAttribute("TRDTL_CNT", CmUtil.GetDataRowStr(dr, "TRDTL_CNT")); // 4.디테일Count (2) + TXJMNode.SetAttribute("TRCSH_CNT", CmUtil.GetDataRowStr(dr, "TRCSH_CNT")); // 5.현금Count (2) + TXJMNode.SetAttribute("TRCRD_CNT", CmUtil.GetDataRowStr(dr, "TRCRD_CNT")); // 6.카드Count (2) + TXJMNode.SetAttribute("TRCST_CNT", "0"); + TXJMNode.SetAttribute("TRFOD_CNT", "0"); + TXJMNode.SetAttribute("TRGFT_CNT", "0"); + TXJMNode.SetAttribute("TRJCD_CNT", "0"); + TXJMNode.SetAttribute("TRWES_CNT", "0"); + TXJMNode.SetAttribute("TRPSQ_CNT", "0"); + TXJMNode.SetAttribute("TRCSA_CNT", "0"); + TXJMNode.SetAttribute("TRGFA_CNT", "0"); + TXJMNode.SetAttribute("TRFOA_CNT", "0"); + TXJMNode.SetAttribute("TRRFC_CNT", "0"); + TXJMNode.SetAttribute("RUN_MODE", "T"); // T-테스트, R-정상 + + upperNode.AppendChild(TXJMNode); + + //----------------------------------------------------------------------------------------- + // TRHDR + //----------------------------------------------------------------------------------------- + XmlElement TRHDRNode = doc.CreateElement("TRHDR"); + + //TRHDRNode.SetAttribute("SHOP_CD", m_cPosStatus.Base.ExStoreCd); // 7.매장코드 (9) + //TRHDRNode.SetAttribute("SHOP_CD", m_cPosStatus.Base.OutSDVendConNo); // 7.매장코드 (9) + TRHDRNode.SetAttribute("SHOP_CD", m_cPosStatus.Mst.JOIN_STOR_CD); // 7.매장코드 (9) + TRHDRNode.SetAttribute("SALE_DATE", m_cPosStatus.Base.SaleDate); // 8.영업일자 (8) + TRHDRNode.SetAttribute("POS_NO", m_cPosStatus.Base.PosNo); // 9.포스번호 (2) + TRHDRNode.SetAttribute("BILL_NO", m_cPosStatus.Base.TradeNo.Substring(1, 4)); // 10.영수번호 (4) + TRHDRNode.SetAttribute("REGI_SEQ", "01"); // 11.정산차수 (2) + TRHDRNode.SetAttribute("SALE_YN", CmUtil.GetDataRowStr(dr, "SALE_YN")); // 12.판매여부 (1) + TRHDRNode.SetAttribute("TOT_SALE_AMT", CmUtil.GetDataRowStr(dr, "DCM_SALE_AMT")); // 13.총매출액 (12) AS-IS 에서 TOT_SALE_AMT 가 아닌 DCM_SALE_AMT 로 값을 채움 + TRHDRNode.SetAttribute("TOT_DC_AMT", CmUtil.GetDataRowStr(dr, "TOT_DC_AMT")); // 14.총할인액 (12) + TRHDRNode.SetAttribute("SVC_TIP_AMT", CmUtil.GetDataRowStr(dr, "SVC_TIP_AMT")); // 15.봉사료 (12) + TRHDRNode.SetAttribute("TOT_ETC_AMT", CmUtil.GetDataRowStr(dr, "TOT_ETC_AMT")); // 16.기타에누리액 (12) + TRHDRNode.SetAttribute("DCM_SALE_AMT", CmUtil.GetDataRowStr(dr, "DCM_SALE_AMT")); // 17.실매출액 (12) + TRHDRNode.SetAttribute("VAT_SALE_AMT", CmUtil.GetDataRowStr(dr, "VAT_SALE_AMT")); // 18.과세매출액 (12) + TRHDRNode.SetAttribute("VAT_AMT", CmUtil.GetDataRowStr(dr, "VAT_AMT")); // 19.부가세 (12) + TRHDRNode.SetAttribute("NO_VAT_SALE_AMT", CmUtil.GetDataRowStr(dr, "NO_VAT_SALE_AMT")); // 20.면세매출액 (12) + TRHDRNode.SetAttribute("NO_TAX_SALE_AMT", CmUtil.GetDataRowStr(dr, "NO_TAX_SALE_AMT")); // 21.순매출액 (12) + TRHDRNode.SetAttribute("EXP_PAY_AMT", CmUtil.GetDataRowStr(dr, "EXP_PAY_AMT")); // 22.받을금액 (12) + TRHDRNode.SetAttribute("GST_PAY_AMT", CmUtil.GetDataRowStr(dr, "GST_PAY_AMT")); // 23.받은금액 (12) + TRHDRNode.SetAttribute("RET_PAY_AMT", CmUtil.GetDataRowStr(dr, "RET_PAY_AMT")); // 24.거스름돈 (12) + TRHDRNode.SetAttribute("CASH_AMT", CmUtil.GetDataRowStr(dr, "CASH_AMT")); // 25.결제액-현금 (12) + TRHDRNode.SetAttribute("CRD_CARD_AMT", CmUtil.GetDataRowStr(dr, "CRD_CARD_AMT")); // 26.결제액-신용카드 (12) + TRHDRNode.SetAttribute("WES_AMT", "0"); // 27.결제액-외상 (12) + TRHDRNode.SetAttribute("TK_GFT_AMT", "0"); // 28.결제액-상품권 (12) + TRHDRNode.SetAttribute("TK_FOD_AMT", "0"); // 29.결제액-식권 (12) + TRHDRNode.SetAttribute("CST_POINT_AMT", "0"); // 30.결제액-회원포인트 (12) + TRHDRNode.SetAttribute("JCD_CARD_AMT", "0"); // 31.결제액-제휴카드(사용) (12) + TRHDRNode.SetAttribute("DC_GEN_AMT", CmUtil.GetDataRowStr(dr, "TOT_DC_AMT")); // 32.할인액-일반 (12) + TRHDRNode.SetAttribute("DC_SVC_AMT", "0"); // 33.할인액-서비스 (12) + TRHDRNode.SetAttribute("DC_PCD_AMT", "0"); // 34.할인액-제휴카드 (12) + TRHDRNode.SetAttribute("DC_CPN_AMT", "0"); // 35.할인액-쿠폰 (12) + TRHDRNode.SetAttribute("DC_CST_AMT", "0"); // 36.할인액-회원 (12) + TRHDRNode.SetAttribute("DC_TFD_AMT", "0"); // 37.할인액-식권 (12) + TRHDRNode.SetAttribute("DC_PRM_AMT", "0"); // 38.할인액-프로모션 (12) + TRHDRNode.SetAttribute("DC_CRD_AMT", "0"); // 39.할인액-신용카드현장할인 (12) + TRHDRNode.SetAttribute("DC_PACK_AMT", "0"); // 40.할인액-포장할인 (12) + TRHDRNode.SetAttribute("REPAY_CASH_AMT", CmUtil.GetDataRowStr(dr, "REPAY_CASH_AMT")); + TRHDRNode.SetAttribute("REPAY_TK_GFT_AMT", "0"); + TRHDRNode.SetAttribute("CASH_BILL_AMT", CmUtil.GetDataRowStr(dr, "CASH_BILL_AMT")); + TRHDRNode.SetAttribute("DLV_ORDER_FG", "0"); + TRHDRNode.SetAttribute("FD_TBL_CD", "000"); + TRHDRNode.SetAttribute("FD_GST_CNT_T", "1"); + TRHDRNode.SetAttribute("FD_GST_CNT_1", "1"); + TRHDRNode.SetAttribute("FD_GST_CNT_2", "0"); + TRHDRNode.SetAttribute("FD_GST_CNT_3", "0"); + TRHDRNode.SetAttribute("FD_GST_CNT_4", "0"); + TRHDRNode.SetAttribute("ORG_BILL_NO", CmUtil.GetDataRowStr(dr, "SALE_YN") == "N" ? m_cPosStatus.Base.StoreNo + CmUtil.GetDataRowStr(dr, "ORG_BILL_NO") : ""); + TRHDRNode.SetAttribute("ORDER_NO", m_cPosStatus.Base.TradeNo.Substring(1, 4)); + TRHDRNode.SetAttribute("INS_DT", CmUtil.GetDataRowStr(dr, "INS_DT")); + TRHDRNode.SetAttribute("EMP_NO", "0000"); + TRHDRNode.SetAttribute("PAY_OUT_DT", CmUtil.GetDataRowStr(dr, "PAY_OUT_DT")); + TRHDRNode.SetAttribute("CST_NM", ""); + TRHDRNode.SetAttribute("DLV_EMP_NO", ""); + TRHDRNode.SetAttribute("DLV_START_DT", ""); + TRHDRNode.SetAttribute("DLV_PAYIN_EMP_NO", ""); + TRHDRNode.SetAttribute("DLV_PAYIN_DT", ""); + TRHDRNode.SetAttribute("NEW_DLV_ADDR_YN", "N"); + TRHDRNode.SetAttribute("DLV_ADDR", ""); + TRHDRNode.SetAttribute("DLV_ADDR_DTL", ""); + TRHDRNode.SetAttribute("NEW_DLV_TEL_NO_YN", "N"); + TRHDRNode.SetAttribute("DLV_TEL_NO", ""); + TRHDRNode.SetAttribute("DLV_CL_CD", ""); + TRHDRNode.SetAttribute("DLV_CM_CD", ""); + TRHDRNode.SetAttribute("TRAVEL_CD", ""); + TRHDRNode.SetAttribute("RSV_NO", ""); + TRHDRNode.SetAttribute("PRE_PAY_CASH", "0"); + TRHDRNode.SetAttribute("PRE_PAY_CARD", "0"); + TRHDRNode.SetAttribute("RSV_USER_NM", ""); + TRHDRNode.SetAttribute("RSV_USER_TEL_NO", ""); + TRHDRNode.SetAttribute("PREPAY_AMT", "0"); + TRHDRNode.SetAttribute("COM_AMT", "0"); + + upperNode.AppendChild(TRHDRNode); + } + 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); + } + } + + private XmlDocument MakeXmlDetail(ref XmlDocument doc, ref XmlElement upperNode, DataTable dtData) + { + try + { + //----------------------------------------------------------------------------------------- + // TRDTL + //----------------------------------------------------------------------------------------- + XmlElement TRDTLNode = doc.CreateElement("TRDTL"); + upperNode.AppendChild(TRDTLNode); + + if (dtData == null) return doc; + + for(int nLoop = 0;nLoop < dtData.Rows.Count;nLoop++) + { + DataRow dr = dtData.Rows[nLoop]; + XmlElement DATADtlNode = doc.CreateElement("DATA-DTL"); + + DATADtlNode.SetAttribute("DTL_NO", string.Format("{0:0000}", nLoop + 1)); // 76.디테일번호 (4) + DATADtlNode.SetAttribute("REGI_SEQ", "01"); // 77.정산차수 (2) + DATADtlNode.SetAttribute("SALE_YN", CmUtil.GetDataRowStr(dr, "SALE_YN")); // 78.판매여부 (1) + DATADtlNode.SetAttribute("PROD_CD", CmUtil.GetDataRowStr(dr, "PROD_CD")); // 79.상품코드 (20) + DATADtlNode.SetAttribute("PROD_TYPE_FG", CmUtil.GetDataRowStr(dr, "PROD_TYPE_FG")); // 80.상품유형구분 (1) + //DATADtlNode.SetAttribute("CORNER_CD", m_cPosStatus.Base.ExCornerCd); // 81.코너코드 (4) + //DATADtlNode.SetAttribute("CORNER_CD", m_cPosStatus.Base.OutSDVendCrnrCd); // 81.코너코드 (4) + DATADtlNode.SetAttribute("CORNER_CD", m_cPosStatus.Mst.JOIN_BRAND_CD); // 81.코너코드 (4) + + DATADtlNode.SetAttribute("CHG_BILL_NO", ""); // 82.교환권번호(외식-푸드코드) (4) + DATADtlNode.SetAttribute("TAX_YN", CmUtil.GetDataRowStr(dr, "TAX_YN")); // 83.과세여부 (1) + DATADtlNode.SetAttribute("DLV_PACK_FG", CmUtil.GetDataRowStr(dr, "DLV_PACK_FG")); // 84.배달포장구분 (1) + DATADtlNode.SetAttribute("ORG_SALE_MG_CD", "0000"); // 85.원천판매마진코드 (4) + DATADtlNode.SetAttribute("ORG_SALE_UPRC", "0"); // 86.원천판매단가 (12) + DATADtlNode.SetAttribute("NORMAL_UPRC", CmUtil.GetDataRowStr(dr, "NORMAL_UPRC")); // 87.정상판매단가 (12) + DATADtlNode.SetAttribute("SALE_MG_CD", "0000"); // 88.판매마진코드 (4) + DATADtlNode.SetAttribute("SALE_QTY", CmUtil.GetDataRowStr(dr, "SALE_QTY")); // 89.판매수량 (9) + DATADtlNode.SetAttribute("SALE_UPRC", CmUtil.GetDataRowStr(dr, "SALE_UPRC")); // 90.판매단가 (12) + DATADtlNode.SetAttribute("SALE_AMT", CmUtil.GetDataRowStr(dr, "SALE_AMT")); // 91.매출액 (12) + DATADtlNode.SetAttribute("DC_AMT", CmUtil.GetDataRowStr(dr, "DC_AMT")); // 92.할인액 (12) + DATADtlNode.SetAttribute("ETC_AMT", CmUtil.GetDataRowStr(dr, "ETC_AMT")); // 93.기타에누리액(식권짜투리/에누리-끝전) (12) + DATADtlNode.SetAttribute("SVC_TIP_AMT", CmUtil.GetDataRowStr(dr, "SVC_TIP_AMT")); // 94.봉사료 (12) + DATADtlNode.SetAttribute("DCM_SALE_AMT", CmUtil.GetDataRowStr(dr, "DCM_SALE_AMT")); // 95.실매출액 (12) + DATADtlNode.SetAttribute("VAT_AMT", CmUtil.GetDataRowStr(dr, "VAT_AMT")); // 96.부가세 (12) + DATADtlNode.SetAttribute("SVC_CD", ""); // 97.서비스코드 (1) + DATADtlNode.SetAttribute("TK_CPN_CD", ""); // 98.쿠폰코드 (3) + DATADtlNode.SetAttribute("DC_AMT_GEN", CmUtil.GetDataRowStr(dr, "DC_AMT")); // 99.할인액-일반 (12) + DATADtlNode.SetAttribute("DC_AMT_SVC", "0"); // 100.할인액-서비스 (12) + DATADtlNode.SetAttribute("DC_AMT_JCD", "0"); // 101.할인액-제휴카드 (12) + DATADtlNode.SetAttribute("DC_AMT_CPN", "0"); // 102.할인액-쿠폰 (12) + DATADtlNode.SetAttribute("DC_AMT_CST", "0"); // 103.할인액-회원 (12) + DATADtlNode.SetAttribute("DC_AMT_FOD", "0"); // 104.할인액-식권 (12) + DATADtlNode.SetAttribute("DC_AMT_PRM", "0"); // 105.할인액-프로모션 (12) + DATADtlNode.SetAttribute("DC_AMT_CRD", "0"); // 106.할인액-신용카드-현장할인 (12) + DATADtlNode.SetAttribute("DC_AMT_PACK", "0"); // 107.할인액-포장 (12) + DATADtlNode.SetAttribute("CST_SALE_POINT", "0"); // 108.회원-매출포인트 (8) + DATADtlNode.SetAttribute("CST_USE_POINT", "0"); // 109.회원-사용포인트 (8) + DATADtlNode.SetAttribute("PRM_PROC_YN", "N"); // 110.프로모션-적용여부 (1) + DATADtlNode.SetAttribute("PRM_CD", ""); // 111.프로모션-코드 (4) + DATADtlNode.SetAttribute("PRM_SEQ", ""); // 112.프로모션-차수 (2) + DATADtlNode.SetAttribute("SDA_CD", ""); // 113.외식-사이드-속성코드 (10) + DATADtlNode.SetAttribute("SDS_ORG_DTL_NO", ""); // 114.외식-사이드-선택메뉴-원천DTLNO(재설정필요) (4) + DATADtlNode.SetAttribute("INS_DT", CmUtil.GetDataRowStr(dr, "INS_DT")); // 115.POS등록일시 (14) + DATADtlNode.SetAttribute("EMP_NO", "0000"); // 116.판매원코드 (4) + DATADtlNode.SetAttribute("PREPAY_AMT", "0"); // 117.선수입금액 (12) + DATADtlNode.SetAttribute("COM_AMT", "0"); // 118.이익금액 (12) + + TRDTLNode.AppendChild(DATADtlNode); + } + } + 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 doc; + } + + private XmlDocument MakeXmlCashData(ref XmlDocument doc, ref XmlElement upperNode, DataTable dtData) + { + try + { + //----------------------------------------------------------------------------------------- + // TRCSH + //----------------------------------------------------------------------------------------- + XmlElement TRCSHNode = doc.CreateElement("TRCSH"); + upperNode.AppendChild(TRCSHNode); + + if (dtData == null) return doc; + + // VAN사 터미널ID 취득 + string sTermNo = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.CREDITCARD_ITEM, ItemConst.TR_ITEM_ID.CREDITCARD.CREDIT_CARD, PosMst.MST_VAN.DATA.APPR_ID); + + for (int nLoop = 0; nLoop < dtData.Rows.Count; nLoop++) + { + DataRow dr = dtData.Rows[nLoop]; + XmlElement DATANode = doc.CreateElement("DATA-CSH"); + + DATANode.SetAttribute("LINE_NO", string.Format("{0:0000}", nLoop + 1)); // 119.라인번호 (4) + DATANode.SetAttribute("SEQ_NO", "01"); + DATANode.SetAttribute("REGI_SEQ", "01"); + DATANode.SetAttribute("SALE_YN", CmUtil.GetDataRowStr(dr, "SALE_YN")); // 판매여부 (1) + DATANode.SetAttribute("VAN_CD", "02"); // VAN사코드 (2) + //DATANode.SetAttribute("CORNER_CD", m_cPosStatus.Base.ExCornerCd); // 코너코드 (4) + //DATANode.SetAttribute("CORNER_CD", m_cPosStatus.Base.OutSDVendCrnrCd); // 코너코드 (4) + DATANode.SetAttribute("CORNER_CD", m_cPosStatus.Mst.JOIN_BRAND_CD); // 코너코드 (4) + + DATANode.SetAttribute("CASH_AMT", CmUtil.GetDataRowStr(dr, "APPR_AMT")); + DATANode.SetAttribute("APPR_AMT", CmUtil.GetDataRowStr(dr, "APPR_AMT")); // 승인금액 (12) + DATANode.SetAttribute("SVC_TIP_AMT", CmUtil.GetDataRowStr(dr, "SVC_TIP_AMT")); // 봉사료 (12) + DATANode.SetAttribute("VAT_AMT", CmUtil.GetDataRowStr(dr, "VAT_AMT")); // 부가세 (12) + DATANode.SetAttribute("APPR_PROC_FG", CmUtil.GetDataRowStr(dr, "APPR_PROC_FG"));// 승인처리구분 (1) + DATANode.SetAttribute("APPR_IDT_TYPE", CmUtil.GetDataRowStr(dr, "APPR_IDT_TYPE")); // 승인거래자유형 (1) + DATANode.SetAttribute("APPR_IDT_FG", CmUtil.GetDataRowStr(dr, "APPR_IDT_FG")); // 승인인식구분 (1) + DATANode.SetAttribute("CARD_IN_FG", CmUtil.GetDataRowStr(dr, "CARD_IN_FG")); // 카드입력구분 (1) + DATANode.SetAttribute("APPR_IDT_NO", CmUtil.GetDataRowStr(dr, "APPR_IDT_NO")); // 승인인식번호 (20) + DATANode.SetAttribute("APPR_DATE", CmUtil.GetDataRowStr(dr, "APPR_DATE")); // 승인일자 (8) + DATANode.SetAttribute("APPR_TIME", CmUtil.GetDataRowStr(dr, "APPR_TIME")); // 승인시각 (6) + DATANode.SetAttribute("APPR_NO", CmUtil.GetDataRowStr(dr, "APPR_NO")); // 승인번호 (16) + DATANode.SetAttribute("APPR_MSG", ""); // 승인응답메시지 (200) + DATANode.SetAttribute("VAN_TERM_NO", sTermNo); // VAN사터미널번호 (15) + DATANode.SetAttribute("VAN_SLIP_NO", ""); // VAN사전표번호 (12) + DATANode.SetAttribute("ORG_APPR_DATE", ""); // 원거래승인일자 (8) + DATANode.SetAttribute("ORG_APPR_NO", ""); // 원거래승인번호 (16) + DATANode.SetAttribute("APPR_LOG_NO", ""); // 승인로그번호 (5) + DATANode.SetAttribute("INS_DT", CmUtil.GetDataRowStr(dr, "INS_DT")); // 등록일시 (14) + DATANode.SetAttribute("EMP_NO", "0000"); // 판매원코드 (4) + DATANode.SetAttribute("EX_CD", "0"); // 통화코드 (2) + DATANode.SetAttribute("EX_KRW", "0"); // 환율 (12) + DATANode.SetAttribute("EX_EXP_AMT", "0"); // 통화-받을금액 (12) + DATANode.SetAttribute("EX_IN_AMT", "0"); // 통화-지불액 (12) + DATANode.SetAttribute("EX_RET_AMT", "0"); // 통화-거스름 (12) + DATANode.SetAttribute("KR_RET_AMT", "0"); // 원화-거스름 (12) + DATANode.SetAttribute("EX_PAY_AMT", "0"); // 통화-결제액(통화지불액-통화거스름) (12) + DATANode.SetAttribute("KR_PAY_AMT", "0"); // 원화-결제액(통화결제액*환율) (12) + DATANode.SetAttribute("KR_ETC_AMT", "0"); // 원화-에누리액(원화결제액-현금결제액-원화거스름) (12) + DATANode.SetAttribute("PRE_PAY_FG", "0"); + + TRCSHNode.AppendChild(DATANode); + } + } + 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 doc; + } + + private XmlDocument MakeXmlCardData(ref XmlDocument doc, ref XmlElement upperNode, DataTable dtData) + { + try + { + //----------------------------------------------------------------------------------------- + // TRCRD + //----------------------------------------------------------------------------------------- + XmlElement TRCRDNode = doc.CreateElement("TRCRD"); + upperNode.AppendChild(TRCRDNode); + + if (dtData == null) return doc; + + for (int nLoop = 0; nLoop < dtData.Rows.Count; nLoop++) + { + DataRow dr = dtData.Rows[nLoop]; + XmlElement DATANode = doc.CreateElement("DATA-CRD"); + + DATANode.SetAttribute("LINE_NO", string.Format("{0:0000}", nLoop + 1)); // 라인번호 (4) + DATANode.SetAttribute("SEQ_NO", CmUtil.GetDataRowStr(dr, "SEQ_NO")); // 일련번호 (2) + DATANode.SetAttribute("REGI_SEQ", "01"); // 정산차수 (2) + DATANode.SetAttribute("SALE_YN", CmUtil.GetDataRowStr(dr, "SALE_YN")); // 매출구분 (1) + DATANode.SetAttribute("VAN_CD", CmUtil.GetDataRowStr(dr, "VAN_CD")); // VAN사코드 (2) + //DATANode.SetAttribute("CORNER_CD", m_cPosStatus.Base.ExCornerCd); // 코너코드 (4) + //DATANode.SetAttribute("CORNER_CD", m_cPosStatus.Base.OutSDVendCrnrCd); // 코너코드 (4) + DATANode.SetAttribute("CORNER_CD", m_cPosStatus.Mst.JOIN_BRAND_CD); // 코너코드 (4) + + DATANode.SetAttribute("APPR_PROC_FG", CmUtil.GetDataRowStr(dr, "APPR_PROC_FG"));// 승인구분 (1) + DATANode.SetAttribute("CRD_CARD_NO", CmUtil.GetDataRowStr(dr, "CRD_CARD_NO")); // 카드번호 (20) + DATANode.SetAttribute("APPR_REQ_AMT", CmUtil.GetDataRowStr(dr, "APPR_REQ_AMT"));// 승인요청금액 (12) + DATANode.SetAttribute("SVC_TIP_AMT", CmUtil.GetDataRowStr(dr, "SVC_TIP_AMT")); // 봉사료 (12) + DATANode.SetAttribute("VAT_AMT", CmUtil.GetDataRowStr(dr, "VAT_AMT")); // 부가세 (12) + DATANode.SetAttribute("INST_MM_FG", CmUtil.GetDataRowStr(dr, "INST_MM_FG")); // 할부개월구분 (1) + DATANode.SetAttribute("INST_MM_CNT", CmUtil.GetDataRowStr(dr, "INST_MM_CNT")); // 할부개월수 (2) + DATANode.SetAttribute("VALID_TERM", "000000"); // 유효기간 (6) + DATANode.SetAttribute("SIGN_PAD_YN", CmUtil.GetDataRowStr(dr, "SIGN_PAD_YN")); // 사인패드사용여부 (1) + DATANode.SetAttribute("CARD_IN_FG", CmUtil.GetDataRowStr(dr, "CARD_IN_FG")); // 카드입력구분 (1) + DATANode.SetAttribute("APPR_DATE", CmUtil.GetDataRowStr(dr, "APPR_DATE")); // 승인일자 (8) + DATANode.SetAttribute("APPR_TIME", CmUtil.GetDataRowStr(dr, "APPR_TIME")); // 승인시간 (6) + DATANode.SetAttribute("APPR_NO", CmUtil.GetDataRowStr(dr, "APPR_NO")); // 승인번호 (16) + DATANode.SetAttribute("CRDCP_CD", ""); // 카드사코드 (3) + DATANode.SetAttribute("ISS_CRDCP_CD", ""); // 카드발급사코드 (4) + DATANode.SetAttribute("ISS_CRDCP_NM", ""); // 카드발급사명 (40) + DATANode.SetAttribute("PUR_CRDCP_CD", CmUtil.GetDataRowStr(dr, "PUR_CRDCP_CD"));// 카드매입사코드 (4) + DATANode.SetAttribute("PUR_CRDCP_NM", CmUtil.GetDataRowStr(dr, "PUR_CRDCP_NM").Trim());// 카드매입사명 (40) + DATANode.SetAttribute("APPR_AMT", CmUtil.GetDataRowStr(dr, "APPR_AMT")); // 승인금액(실제승인액) + DATANode.SetAttribute("APPR_DC_AMT", "0"); // 승인현장할인액 (12) + DATANode.SetAttribute("APPR_MSG", ""); // 승인응답메시지 (200) + DATANode.SetAttribute("VAN_TERM_NO", ""); // VAN사터미널번호 (15) + DATANode.SetAttribute("VAN_SLIP_NO", ""); // VAN사전표번호 (12) + DATANode.SetAttribute("CRDCP_TERM_NO", CmUtil.GetDataRowStr(dr, "CRDCP_TERM_NO").Trim()); // 카드사계약번호 (15) + DATANode.SetAttribute("ORG_APPR_DATE", ""); // 원거래승인일자 (8) + DATANode.SetAttribute("ORG_APPR_NO", ""); // 원거래승인번호 (16) + DATANode.SetAttribute("APPR_LOG_NO", ""); // 승인로그번호 (5) + DATANode.SetAttribute("INS_DT", CmUtil.GetDataRowStr(dr, "INS_DT")); // 등록일시 (14) + DATANode.SetAttribute("EMP_NO", "0000"); // 판매원번호 (4) + DATANode.SetAttribute("PRE_PAY_FG", "0"); // 선수금구분자 (1) + + TRCRDNode.AppendChild(DATANode); + } + } + 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 doc; + } + + private DataTable GetTranHeaderForEx(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo) + { + string sQuery = string.Empty; + string sSelQuery = string.Empty; + StringBuilder sb = new StringBuilder(); + + DataTable dtReturn = null; + try + { + sSelQuery = "SELECT CASE WHEN A.TRADE_DIV = '0' \n" + + " THEN 'Y' \n" + + " ELSE 'N' \n" + + " END AS SALE_YN \n" + + " , ISNULL(A.TOTSALE_AMT, 0) AS TOT_SALE_AMT \n" + + " , ISNULL(A.TOTDC_AMT, 0) AS TOT_DC_AMT \n" + + " , ISNULL(A.SVC_FEE_AMT, 0) AS SVC_TIP_AMT \n" + + " , 0 AS TOT_ETC_AMT \n" + + " , ISNULL(A.NET_SALE_AMT, 0) AS DCM_SALE_AMT \n" + + " , ISNULL(A.TOT_VAT, 0) AS VAT_AMT \n" + + " , ISNULL(A.NET_SALE_AMT, 0) - ISNULL(A.TOT_VAT, 0) AS NO_TAX_SALE_AMT \n" + + " , ISNULL(A.NET_SALE_AMT, 0) AS EXP_PAY_AMT \n" + + " , A.SALE_DT + A.PAY_TIME AS INS_DT \n" + + " , A.SALE_DT + A.PAY_TIME AS PAY_OUT_DT \n" + + " , A.ORG_BILLDT + A.POS_NO + SUBSTRING(A.ORG_BILL_NO, 2, 4) AS ORG_BILL_NO \n" + + " , C.TRDTL_CNT AS TRDTL_CNT \n" + + " , D.TRCSH_CNT AS TRCSH_CNT \n" + + " , B.TRCRD_CNT AS TRCRD_CNT \n" + + " , C.VAT_SALE_AMT AS VAT_SALE_AMT \n" + + " , C.NO_VAT_SALE_AMT AS NO_VAT_SALE_AMT \n" + + " , B.GST_PAY_AMT AS GST_PAY_AMT \n" + + " , B.RET_PAY_AMT AS RET_PAY_AMT \n" + + " , B.CASH_AMT AS CASH_AMT \n" + + " , B.CRD_CARD_AMT AS CRD_CARD_AMT \n" + + " , B.REPAY_CASH_AMT AS REPAY_CASH_AMT \n" + + " , D.CASH_BILL_AMT AS CASH_BILL_AMT \n" + + " FROM POSLOG..TR_SALE_HEADER A \n" + + " , ( \n" + + " SELECT SUM(CASE WHEN TSP.PAY_WAY_CD <> '02' \n" + + " THEN ISNULL(TSP.AMT_ENTRY_01, 0) - ISNULL(TSP.AMT_ENTRY_02, 0) \n" + + " ELSE 0 \n" + + " END) AS CASH_AMT \n" + + " , SUM(CASE WHEN TSP.PAY_WAY_CD = '02' \n" + + " THEN 1 \n" + + " ELSE 0 \n" + + " END) AS TRCRD_CNT \n" + + " , SUM(CASE WHEN TSP.PAY_WAY_CD = '02' \n" + + " THEN ISNULL(TSP.AMT_ENTRY_01, 0) \n" + + " ELSE 0 \n" + + " END) AS CRD_CARD_AMT \n" + + " , SUM(ISNULL(TSP.PAY_AMT, 0)) AS GST_PAY_AMT \n" + + " , SUM(ISNULL(TSP.AMT_ENTRY_02, 0)) AS RET_PAY_AMT \n" + + " , 0 AS REPAY_CASH_AMT \n" + + " FROM POSLOG..TR_SALE_HEADER TSH \n" + + " LEFT JOIN POSLOG..TR_SALE_PAY TSP \n" + + " ON TSH.CMP_CD = TSP.CMP_CD \n" + + " AND TSH.SALE_DT = TSP.SALE_DT \n" + + " AND TSH.STOR_CD = TSP.STOR_CD \n" + + " AND TSH.POS_NO = TSP.POS_NO \n" + + " AND TSH.TRADE_NO = TSP.TRADE_NO \n" + + " AND TSP.PAY_DTL_CD_05 = '1' \n" + + " AND TSP.CANCEL_DIV = '0' \n" + + " WHERE TSH.CMP_CD = '{0}' \n" + + " AND TSH.SALE_DT = '{1}' \n" + + " AND TSH.STOR_CD = '{2}' \n" + + " AND TSH.POS_NO = '{3}' \n" + + " AND TSH.TRADE_NO = '{4}' \n" + + " AND TSH.TRAIN_MODE_YN = '0' \n" + + " AND TSH.TRADE_KINDPER = '00' \n" + + " ) B \n" + + " , ( \n" + + " SELECT SUM(CASE WHEN ISNULL(TSD.SALE_AMT, 0) = 0 \n" + + " THEN 0 \n" + + " ELSE 1 \n" + + " END) AS TRDTL_CNT \n" + + " , SUM(CASE WHEN ISNULL(TSD.APPLY_TAX_AMT, 0) = 0 \n" + + " THEN 0 \n" + + " ELSE ISNULL(TSD.BILL_AMT, 0) - ISNULL(TSD.APPLY_TAX_AMT, 0) \n" + + " END) AS VAT_SALE_AMT \n" + + " , SUM(CASE WHEN ISNULL(TSD.APPLY_TAX_AMT, 0) = 0 \n" + + " THEN ISNULL(TSD.SALE_AMT, 0) \n" + + " ELSE 0 \n" + + " END) AS NO_VAT_SALE_AMT \n" + + " FROM POSLOG..TR_SALE_HEADER TSH \n" + + " LEFT JOIN POSLOG..TR_SALE_DETAIL TSD \n" + + " ON TSH.CMP_CD = TSD.CMP_CD \n" + + " AND TSH.SALE_DT = TSD.SALE_DT \n" + + " AND TSH.STOR_CD = TSD.STOR_CD \n" + + " AND TSH.POS_NO = TSD.POS_NO \n" + + " AND TSH.TRADE_NO = TSD.TRADE_NO \n" + + " AND TSD.CANCEL_DIV = '0' \n" + + " WHERE TSH.CMP_CD = '{0}' \n" + + " AND TSH.SALE_DT = '{1}' \n" + + " AND TSH.STOR_CD = '{2}' \n" + + " AND TSH.POS_NO = '{3}' \n" + + " AND TSH.TRADE_NO = '{4}' \n" + + " AND TSH.TRAIN_MODE_YN = '0' \n" + + " AND TSH.TRADE_KINDPER = '00' \n" + + " ) C \n" + + " , ( \n" + + " SELECT SUM(CASE WHEN TSE.ETC_WAY_CD = '00' \n" + + " THEN 1 \n" + + " ELSE 0 \n" + + " END) AS TRCSH_CNT \n" + + " , ISNULL(SUM(TSE.ETC_AMT), 0) AS CASH_BILL_AMT \n" + + " FROM POSLOG..TR_SALE_HEADER TSH \n" + + " LEFT JOIN POSLOG..TR_SALE_ETC TSE \n" + + " ON TSH.CMP_CD = TSE.CMP_CD \n" + + " AND TSH.SALE_DT = TSE.SALE_DT \n" + + " AND TSH.STOR_CD = TSE.STOR_CD \n" + + " AND TSH.POS_NO = TSE.POS_NO \n" + + " AND TSH.TRADE_NO = TSE.TRADE_NO \n" + + " AND TSE.ETC_WAY_CD = '00' \n" + + " WHERE TSH.CMP_CD = '{0}' \n" + + " AND TSH.SALE_DT = '{1}' \n" + + " AND TSH.STOR_CD = '{2}' \n" + + " AND TSH.POS_NO = '{3}' \n" + + " AND TSH.TRADE_NO = '{4}' \n" + + " AND TSH.TRAIN_MODE_YN = '0' \n" + + " AND TSH.TRADE_KINDPER = '00' \n" + + " ) D \n" + + " WHERE A.CMP_CD = '{0}' \n" + + " AND A.SALE_DT = '{1}' \n" + + " AND A.STOR_CD = '{2}' \n" + + " AND A.POS_NO = '{3}' \n" + + " AND A.TRADE_NO = '{4}' \n" + + " AND A.TRAIN_MODE_YN = '0' \n" + + " AND A.TRADE_KINDPER = '00' \n"; + + sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + + sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); + } + 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 dtReturn; + } + + private DataTable GetTranDetailForEx(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo) + { + string sQuery = string.Empty; + string sSelQuery = string.Empty; + StringBuilder sb = new StringBuilder(); + + DataTable dtReturn = null; + try + { + sSelQuery = "SELECT A.SEQ \n" + + " , CASE WHEN B.TRADE_DIV = '0' \n" + + " THEN 'Y' \n" + + " ELSE 'N' \n" + + " END AS SALE_YN \n" + + " , C.ENTR_CMP_ITEM_CD AS PROD_CD \n" + + " , CASE WHEN A.ITEM_DIV = '0' \n" + + " THEN '0' \n" + + " ELSE '1' \n" + + " END AS PROD_TYPE_FG \n" + + " , CASE WHEN A.ITEM_TAX_DIV = '0' OR A.NOTAX_DIV = '1' \n" + + " THEN 'N' \n" + + " ELSE 'Y' \n" + + " END AS TAX_YN \n" + + " , CASE WHEN A.TAKE_IN_OUT_DIV = '0' \n" + + " THEN '0' \n" + + " ELSE '2' \n" + + " END AS DLV_PACK_FG \n" + + " , CASE WHEN A.SALE_AMT = A.BILL_AMT \n" + + " THEN A.SALE_PRC \n" + + " ELSE A.BILL_AMT / A.SALE_QTY \n" + + " END AS NORMAL_UPRC \n" + + " , ISNULL(A.SALE_QTY, 0) AS SALE_QTY \n" + + " , CASE WHEN A.SALE_AMT = A.BILL_AMT \n" + + " THEN A.SALE_PRC \n" + + " ELSE A.BILL_AMT / A.SALE_QTY \n" + + " END AS SALE_UPRC \n" + + " , ISNULL(A.BILL_AMT, 0) AS SALE_AMT \n" + + " , ISNULL(A.ITEM_DC_AMT, 0) + ISNULL(A.SUM_DC_AMT, 0) + \n" + + " ISNULL(A.CPI_DC_AMT, 0) + ISNULL(A.COOP_CARD_DC_AMT, 0) + \n" + + " ISNULL(A.POINT_DC_AMT, 0) + ISNULL(A.CPN_DC_AMT, 0) + \n" + + " ISNULL(A.EMP_DC_AMT, 0) + ISNULL(A.SET_DC_AMT, 0) + \n" + + " ISNULL(A.ETC_DC_AMT, 0) + ISNULL(A.EXCEP_DC_AMT, 0) AS DC_AMT \n" + + " , 0 AS ETC_AMT \n" + + " , 0 AS SVC_TIP_AMT \n" + + " , ISNULL(A.BILL_AMT, 0) AS DCM_SALE_AMT \n" + + " , ISNULL(A.APPLY_TAX_AMT, 0) AS VAT_AMT \n" + + " , B.SALE_DT + B.PAY_TIME AS INS_DT \n" + + " FROM POSLOG..TR_SALE_DETAIL A \n" + + " , POSLOG..TR_SALE_HEADER B \n" + + " , POSMST..MST_OUT_SD_VEND_ITEM C \n" + + " WHERE A.CMP_CD = '{0}' \n" + + " AND A.SALE_DT = '{1}' \n" + + " AND A.STOR_CD = '{2}' \n" + + " AND A.POS_NO = '{3}' \n" + + " AND A.TRADE_NO = '{4}' \n" + + " AND A.CMP_CD = B.CMP_CD \n" + + " AND A.SALE_DT = B.SALE_DT \n" + + " AND A.STOR_CD = B.STOR_CD \n" + + " AND A.POS_NO = B.POS_NO \n" + + " AND A.TRADE_NO = B.TRADE_NO \n" + + " AND A.CMP_CD = C.CMP_CD \n" + + " AND A.ITEM_PLU_CD = C.ITEM_CD \n" + + " AND B.TRAIN_MODE_YN = '0' \n" + + " AND B.TRADE_KINDPER = '00' \n" + + " AND A.CANCEL_DIV = '0' \n" + + " AND C.USE_YN = '1' \n" + + " ORDER BY A.SEQ \n"; + + sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + + sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); + } + 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 dtReturn; + } + + private DataTable GetTranCashDataForEx(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo) + { + string sQuery = string.Empty; + string sSelQuery = string.Empty; + StringBuilder sb = new StringBuilder(); + + DataTable dtReturn = null; + try + { + sSelQuery = "SELECT CASE WHEN B.TRADE_DIV = '0' \n" + + " THEN 'Y' \n" + + " ELSE 'N' \n" + + " END AS SALE_YN \n" + + " , ISNULL(A.ETC_AMT, 0) AS APPR_AMT \n" + + " , 0 AS SVC_TIP_AMT \n" + + " , ISNULL(A.AMT_ENTRY_03, 0) AS VAT_AMT \n" + + " , CASE WHEN A.OCCUR_ENTRY_09 = '0' \n" + + " THEN '1' \n" + + " ELSE '2' \n" + + " END AS APPR_PROC_FG \n" + + " , CASE WHEN A.OCCUR_ENTRY_08 = '0' \n" + + " THEN '1' \n" + + " ELSE '2' \n" + + " END AS APPR_IDT_TYPE \n" + + " , CASE WHEN SUBSTRING(A.OCCUR_ENTRY_01, 1, 2) = '01' \n" + + " THEN '2' \n" + + " ELSE '3' \n" + + " END AS APPR_IDT_FG \n" + + " , 'K' AS CARD_IN_FG \n" + + " , A.OCCUR_ENTRY_01 AS APPR_IDT_NO \n" + + " , A.OCCUR_ENTRY_03 AS APPR_DATE \n" + + " , A.OCCUR_ENTRY_04 AS APPR_TIME \n" + + " , A.OCCUR_ENTRY_02 AS APPR_NO \n" + + " , A.OCCUR_ENTRY_03 + A.OCCUR_ENTRY_04 AS INS_DT \n" + + " FROM POSLOG..TR_SALE_ETC A \n" + + " , POSLOG..TR_SALE_HEADER B \n" + + " WHERE A.CMP_CD = '{0}' \n" + + " AND A.SALE_DT = '{1}' \n" + + " AND A.STOR_CD = '{2}' \n" + + " AND A.POS_NO = '{3}' \n" + + " AND A.TRADE_NO = '{4}' \n" + + " AND A.ETC_WAY_CD = '80' \n" + + " AND A.ETC_DTL_CD_01 = '00' \n" + + " AND A.CMP_CD = B.CMP_CD \n" + + " AND A.STOR_CD = B.STOR_CD \n" + + " AND A.POS_NO = B.POS_NO \n" + + " AND A.TRADE_NO = B.TRADE_NO \n" + + " AND B.TRAIN_MODE_YN = '0' \n" + + " AND B.TRADE_KINDPER = '00' \n"; + + sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + + sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); + } + 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 dtReturn; + } + + private DataTable GetTranCardDataForEx(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo) + { + string sQuery = string.Empty; + string sSelQuery = string.Empty; + StringBuilder sb = new StringBuilder(); + + DataTable dtReturn = null; + try + { + sSelQuery = "SELECT '01' AS SEQ_NO \n" + + " , '02' AS VAN_CD \n" + + " , CASE WHEN B.TRADE_DIV = '0' \n" + + " THEN 'Y' \n" + + " ELSE 'N' \n" + + " END AS SALE_YN \n" + + " , CASE WHEN A.OCCUR_ENTRY_08 = '0' \n" + + " THEN '1' \n" + + " ELSE '2' \n" + + " END AS APPR_PROC_FG \n" + + " , A.OCCUR_ENTRY_01 AS CRD_CARD_NO \n" + + " , ISNULL(A.PAY_AMT, 0) AS APPR_REQ_AMT \n" + + " , 0 AS SVC_TIP_AMT \n" + + " , ISNULL(A.PAY_AMT, 0) - ROUND(A.PAY_AMT / 1.1, 0) AS VAT_AMT \n" + + " , CASE WHEN A.OCCUR_ENTRY_14 = '00' \n" + + " THEN '0' \n" + + " ELSE '1' \n" + + " END AS INST_MM_FG \n" + + " , A.OCCUR_ENTRY_14 AS INST_MM_CNT \n" + + " , CASE WHEN A.OCCUR_ENTRY_17 = '0' \n" + + " THEN 'N' \n" + + " ELSE 'Y' \n" + + " END AS SIGN_PAD_YN \n" + + " , CASE WHEN A.OCCUR_ENTRY_05 = 'K' \n" + + " THEN 'K' \n" + + " ELSE 'S' \n" + + " END AS CARD_IN_FG \n" + + " , A.OCCUR_ENTRY_03 AS APPR_DATE \n" + + " , A.OCCUR_ENTRY_04 AS APPR_TIME \n" + + " , A.OCCUR_ENTRY_02 AS APPR_NO \n" + + " , A.OCCUR_ENTRY_11 AS PUR_CRDCP_CD \n" + + " , A.OCCUR_ENTRY_12 AS PUR_CRDCP_NM \n" + + " , ISNULL(A.PAY_AMT, 0) AS APPR_AMT \n" + + " , A.OCCUR_ENTRY_18 AS CRDCP_TERM_NO \n" + + " , A.OCCUR_ENTRY_03 + A.OCCUR_ENTRY_04 AS INS_DT \n" + + " FROM POSLOG..TR_SALE_PAY A \n" + + " , POSLOG..TR_SALE_HEADER B \n" + + " WHERE A.CMP_CD = '{0}' \n" + + " AND A.SALE_DT = '{1}' \n" + + " AND A.STOR_CD = '{2}' \n" + + " AND A.POS_NO = '{3}' \n" + + " AND A.TRADE_NO = '{4}' \n" + + " AND A.PAY_WAY_CD = '02' \n" + + " AND A.PAY_DTL_CD_05 = '1' \n" + + " AND A.CANCEL_DIV = '0' \n" + + " AND A.CMP_CD = B.CMP_CD \n" + + " AND A.SALE_DT = B.SALE_DT \n" + + " AND A.STOR_CD = B.STOR_CD \n" + + " AND A.POS_NO = B.POS_NO \n" + + " AND A.TRADE_NO = B.TRADE_NO \n" + + " AND B.TRAIN_MODE_YN = '0' \n" + + " AND B.TRADE_KINDPER = '00' \n"; + + sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + + sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); + } + 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 dtReturn; + } + + #endregion 07 - 도로공사(고속도로 휴게소 입점 POS) 매출 I/F XML파일 생성 + + #region 08 - 도로공사(고속도로 휴게소 입점 POS) 매출 전송 + public void TranSendToExProcess() + { + string sCmpCd = ""; + string sStoreNo = ""; + string sPosNo = ""; + string sSaleDate = ""; + string sTradeNo = ""; + string sendFlag = "8"; + + try + { + DirectoryInfo di = new DirectoryInfo(BaseCom.NxDataPath + "SEND\\EX\\"); + FileInfo[] xmlFiles = di.GetFiles("*.xml"); + + if(xmlFiles.Length < 1) + { + return; + } + else + { + iSendDataCnt += 1; + } + + for(int nLoop = 0;nLoop < xmlFiles.Length;nLoop++) + { + // 도로공사 매출전송 파일은 한번에 5개씩만 보낸다. + if(nLoop >= 5) + { + break; + } + FileInfo fi = xmlFiles[nLoop]; + + string[] sFile = fi.Name.Split(new char[] {'.'}, StringSplitOptions.RemoveEmptyEntries); + string sFileFullName = fi.FullName; + string[] sFileName = sFile[0].Split(new char[] { '_' }, StringSplitOptions.RemoveEmptyEntries); + string sFileExtension = sFile[1]; + + string sFileType = sFileName[0].Trim(); + sCmpCd = sFileName[1].Trim(); + sStoreNo = sFileName[2].Trim(); + sPosNo = sFileName[3].Trim(); + sSaleDate = sFileName[4].Trim(); + sTradeNo = sFileName[5].Trim(); + + string sUrl = string.Empty; + + if(sFileType == "H1") + { + //sUrl = sExTranUrl; + sUrl = m_cPosStatus.Mst.ETC_IF_URL1; + } + else + { + //sUrl = sExCalcUrl; + sUrl = m_cPosStatus.Mst.ETC_IF_URL2; + } + + XmlDocument doc = new XmlDocument(); + doc.Load(sFileFullName); + + string recvData = string.Empty; + if(Http_SendReceive(sUrl, doc, ref recvData) == BaseCom.OK) + { + if(recvData.IndexOf("RETCD=") > 0) + { + string sRetCd = recvData.Substring(recvData.IndexOf("RETCD=") + 6, 4); + + if(sRetCd == "0000") + { + if (iErrorCount > 0) + iErrorCount -= 1; + sendFlag = "1"; + fi.Delete(); + System.Threading.Thread.Sleep(50); + } + else + { + iErrorCount += 1; + sendFlag = "9"; + } + } + } + else + { + iErrorCount += 1; + sendFlag = "9"; + } + } + } + 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); + sendFlag = "9"; + } + finally + { + // Flag Update + OutsideTranSendFlgUpdate(sCmpCd, sStoreNo, sPosNo, sSaleDate, sTradeNo, sendFlag); + } + } + + private int Http_SendReceive(string sUrl, XmlDocument xmlDoc, ref string recvData) + { + int iRet = BaseCom.NG; + try + { + HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sUrl); + + req.Method = "POST"; + req.ContentType = "text/xml"; + req.Timeout = 30 * 1000; + + // create our stream to send + Stream webDataStream = req.GetRequestStream(); + xmlDoc.Save(webDataStream); + webDataStream.Close(); + + // get the response from out stream + WebResponse resp = req.GetResponse(); + webDataStream = resp.GetResponseStream(); + + // convert the result into a string + StreamReader respStreamReader = new StreamReader(webDataStream); + string respFromServer = respStreamReader.ReadToEnd(); + + recvData = respFromServer; + + respStreamReader.Close(); + + iRet = BaseCom.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 iRet; + } + #endregion 08 - 도로공사(고속도로 휴게소 입점 POS) 매출 전송 + + #region 09 - 한국공항공사 매출 I/F + //public void TranSendToKacProcess() + //{ + // string sCmpCd = string.Empty; + // string sSaleDt = string.Empty; + // string sStorCd = string.Empty; + // string sPosNo = string.Empty; + // string sTradeNo = string.Empty; + // string sendFlag = "0"; + + // DataTable dtReturn = null; + + // try + // { + // // 전송할 데이터 조회 + // GetTranInfo(ref dtReturn); + + // if(dtReturn == null || dtReturn.Rows.Count == 0) + // { + // return; + // } + // else + // { + // iSendDataCnt += 1; + // } + + // sendFlag = "0"; // 0:미전송, 1:전송, 9:에러 + + // DataRow dr = dtReturn.Rows[0]; + // sCmpCd = CmUtil.GetDataRowStr(dr, "CMP_CD"); + // sSaleDt = CmUtil.GetDataRowStr(dr, "SALE_DT"); + // sStorCd = CmUtil.GetDataRowStr(dr, "STOR_CD"); + // sPosNo = CmUtil.GetDataRowStr(dr, "POS_NO"); + // sTradeNo = CmUtil.GetDataRowStr(dr, "TRADE_NO"); + + // Column.KACReceiptHeader header = new Column.KACReceiptHeader(); + // ArrayList alKACItems = new ArrayList(); + + // // 전송할 매출 데이터 생성 + // MakeTranToKacProcess(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo, ref header, ref alKACItems); + + // string sReturn = SaveDataToDb("HEAD", sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo, header, alKACItems, null); + + // if(sReturn == UserCom.RST_OK) + // { + // sendFlag = "1"; + // } + // else + // { + // sendFlag = "9"; + // } + // } + // 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); + // sendFlag = "9"; + // } + // finally + // { + // // Flag Update + // OutsideTranSendFlgUpdate(sCmpCd, sStorCd, sPosNo, sSaleDt, sTradeNo, sendFlag); + // } + //} + ///// + ///// 매출저장 + ///// + ///// + ///// + ///// + ///// + ///// + ///// + ///// + ///// + ///// + //public string SaveDataToDb(string sSendType, string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo, Column.KACReceiptHeader cHeader, ArrayList alItems, Column.KACCalcData cCalcData) + //{ + // string sReturn = UserCom.RST_ERR; + + // int iItemCount = 0; + // StringBuilder sbTranHeader = new StringBuilder(""); + // StringBuilder sbTranItem = new StringBuilder(""); + // try + // { + // //string sDbConNo = string.Format("{0, -10}", m_cPosStatus.Base.KacConNo); + // //string sDbConNo = string.Format("{0, -10}", m_cPosStatus.Base.OutSDVendConNo); + // string sDbConNo = string.Format("{0, -10}", m_cPosStatus.Mst.JOIN_STOR_CD); + // string sDbStorCd = string.Format("{0, -10}", sStorCd); + // string sDbPosNo = string.Format("{0, -10}", sPosNo); + // string sDbTradeNo = string.Format("{0, -30}", sTradeNo); + + + // if (sSendType == "HEAD") + // { + // sbTranHeader.Append(cHeader.CON_NO); // 계약번호(ERP상의 계약번호) + // sbTranHeader.Append(cHeader.SALE_DT); // 영업일자 + // sbTranHeader.Append(cHeader.STORE_CD); // 점번호 + // sbTranHeader.Append(cHeader.POS_NO); // POS번호 + // sbTranHeader.Append(cHeader.RECEIPT_SEQ); // 순차적으로 증가되는 값 + // sbTranHeader.Append(cHeader.RECEIPT_NO); // 영수증번호 + // sbTranHeader.Append(cHeader.ITEM_QTY); // 아이템 건수 + // sbTranHeader.Append(cHeader.SALE_TM); // 매출시간 + // sbTranHeader.Append(cHeader.CANCEL_YN); // 영수증 취소 여부(0:정상, 1:취소) + // sbTranHeader.Append(cHeader.TOT_AMT); // 총매출금액 + // sbTranHeader.Append(cHeader.SALE_AMT); // 매가금액(공급가액) + // sbTranHeader.Append(cHeader.TAX_AMT); // 부가세금액 + // sbTranHeader.Append(cHeader.CASH_AMT); // 현금금액 + // sbTranHeader.Append(cHeader.CARD_AMT); // 카드금액 + // sbTranHeader.Append(cHeader.ETC_AMT); // 기타금액 + // sbTranHeader.Append(cHeader.CASH_YN); // 복합결제유문 발행 여부(복합결제 : 0, 현금결제만 : 1) + // sbTranHeader.Append(cHeader.CASH_RECEIPT_YN); // 현금영수증 발행 여부(발행 : 0, 미발행 : 1) + // sbTranHeader.Append(cHeader.BUY_NM); // 구매자명 + // sbTranHeader.Append(cHeader.BUY_COUN_CD); // 구매자국가코드 + // sbTranHeader.Append(cHeader.BUY_SEX_CD); // 구매자성별 + // sbTranHeader.Append(cHeader.BUY_BIRTHDAY); // 구매자생년월일 + // sbTranHeader.Append(cHeader.BUY_AGE); // 구매자나이 + // sbTranHeader.Append(cHeader.AIR_NO); // 항공기정보 + // sbTranHeader.Append(cHeader.CREATE_DT); // 영수증생성일자 + + // foreach (Column.KACReceiptItem item in alItems) + // { + // sbTranItem.Append(item.CON_NO); + // sbTranItem.Append(item.SALE_DT); + // sbTranItem.Append(item.STORE_CD); + // sbTranItem.Append(item.POS_NO); + // sbTranItem.Append(item.RECEIPT_NO); + // sbTranItem.Append(item.PROC_SEQ); + // sbTranItem.Append(item.PROD_CD); + // sbTranItem.Append(item.PROD_NM); + // sbTranItem.Append(item.QTY); + // sbTranItem.Append(item.UNIT_PRICE); + // sbTranItem.Append(item.AMT); + // sbTranItem.Append(item.CREATE_DT); + + // iItemCount++; + // } + // } + // else + // { + // sbTranHeader.Append(cCalcData.CON_NO); // 계약번호 + // sbTranHeader.Append(cCalcData.SALE_DT); // 영업일자 + // sbTranHeader.Append(cCalcData.STORE_CD); // 점번호 + // sbTranHeader.Append(cCalcData.POS_NO); // POS번호 + // sbTranHeader.Append(cCalcData.RECEIPT_SEQ); // 순차적으로 증가되는 값 + // sbTranHeader.Append(cCalcData.RECEIPT_NO); // 영수증번호 + // sbTranHeader.Append(cCalcData.SALE_TM); // 매출일시 + // sbTranHeader.Append(cCalcData.RECEIPT_QTY); // 매출건수 + // sbTranHeader.Append(cCalcData.TOTAL_AMT); // 총매출금액 + // sbTranHeader.Append(cCalcData.SALE_AMT); // 총공급가액 + // sbTranHeader.Append(cCalcData.TAX_AMT); // 총부가세금액 + // sbTranHeader.Append(cCalcData.CASH_AMT); // 총현금금액 + // sbTranHeader.Append(cCalcData.CARD_AMT); // 총카드금액 + // sbTranHeader.Append(cCalcData.ETC_AMT); // 총기타금액 + // sbTranHeader.Append(cCalcData.CREATE_DT); // 생성일자 + + // iItemCount = int.Parse(cCalcData.RECEIPT_QTY.Trim()); // 아이템건수(마감은 총매출건수) + // } + + // try + // { + // int iRet = ReceiptDB(sSendType, sDbConNo, sSaleDt, sDbStorCd, sDbPosNo, sDbTradeNo, sbTranHeader.ToString(), iItemCount, sbTranItem.ToString()); + // if(iRet == 0) + // { + // sReturn = UserCom.RST_OK; + // } + // } + // catch(Exception ex){} + // } + // 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 sReturn; + //} + + //private void MakeTranToKacProcess(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo, ref Column.KACReceiptHeader header, ref ArrayList alKACItems) + //{ + // try + // { + // DataTable dtHeader = GetTranHeaderForKac(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + // DataTable dtDetail = GetTranDetailForKac(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + // DataTable dtCash = GetTranCashForKac(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + + // double dBillAmt = 0; // 영수금액 + // double dNetAmt = 0; // 순매출액(부가세제외) + // double dVatAmt = 0; // 부가세 + // int iTotalItem = 0; // 아이템 개수 + // int iSaleQty = 0; // 아이템 수량 합계 + // double dSaleUprc = 0; // 아이템 단가 합계 + // double dSaleAmt = 0; // 아이템 영수금액 합계 + + // string sSysDate = CmUtil.GetDataRowStr(dtHeader.Rows[0], "SYS_DT"); + // string sSaleTm = CmUtil.GetDataRowStr(dtHeader.Rows[0], "PAY_TIME"); + + // int iSign = CmUtil.GetDataRowStr(dtHeader.Rows[0], "TRADE_DIV") == "0" ? 1 : -1; + // for (int nLoop = 0; nLoop < dtHeader.Rows.Count; nLoop++) + // { + // // 아이템은 최대 30개 까지만 전송 + // if (nLoop > 29) break; + // DataRow drData = dtHeader.Rows[nLoop]; + + // ////////////////////////////////////////////////////////////// + // // 영수증 정보 item(매출정보) // + // ////////////////////////////////////////////////////////////// + // dBillAmt = iSign * CmUtil.GetDataRowDouble(drData, "BILL_AMT"); + // dNetAmt = iSign * CmUtil.GetDataRowDouble(drData, "NET_TOT_AMT"); + // dVatAmt = iSign * CmUtil.GetDataRowDouble(drData, "TAX_AMT"); + + // Column.KACReceiptItem item = new Column.KACReceiptItem(); + + // //item.CON_NO = m_cPosStatus.Base.KacConNo; + // //item.CON_NO = m_cPosStatus.Base.OutSDVendConNo; + // item.CON_NO = m_cPosStatus.Mst.JOIN_STOR_CD; + // item.SALE_DT = sSaleDt; + // item.STORE_CD = sStorCd; + // item.POS_NO = sPosNo; + // item.RECEIPT_NO = sTradeNo; + // item.PROC_SEQ = CmUtil.GetDataRowStr(drData, "SEQ"); + // string sItemCd = CmUtil.GetDataRowStr(drData, "ITEM_PLU_CD"); + // item.PROD_CD = sItemCd; + // item.PROD_NM = CmUtil.GetDataRowStr(SeletItemMstToItemCode(sItemCd).Rows[0], PosMst.MST_ITEM.DATA.SHTCUT_ITEMNM); + // item.QTY = CmUtil.GetDataRowStr(drData, "SALE_QTY"); + // item.UNIT_PRICE = CmUtil.GetDataRowStr(drData, "SALE_PRC"); + // item.AMT = dBillAmt.ToString(); + // item.CREATE_DT = sSysDate; + + // // ArrayList에 영수증아이템 정보 추가 + // alKACItems.Add(item); + + // iSaleQty = iSaleQty + CmUtil.GetDataRowInt(drData, "SALE_QTY"); + // dSaleUprc = dSaleUprc + CmUtil.GetDataRowDouble(drData, "SALE_PRC"); + // dSaleAmt = dSaleAmt + dBillAmt; + + // iTotalItem++; + // } + + // ////////////////////////////////////////////////////////////// + // // 영수증 정보 item(매출정보) - TOTAL AMOUNT // + // ////////////////////////////////////////////////////////////// + // DataRow drDetail = dtDetail.Rows[0]; + // double dTotAmt = iSign * CmUtil.GetDataRowDouble(drDetail, "TOTAL_AMT"); + // double dCashAmt = iSign * CmUtil.GetDataRowDouble(drDetail, "CASH_AMT"); + // double dCardAmt = iSign * CmUtil.GetDataRowDouble(drDetail, "CARD_AMT"); + // double dEtcAmt = iSign * CmUtil.GetDataRowDouble(drDetail, "ETC_AMT"); + // string sCashYn = CmUtil.GetDataRowStr(drDetail, "CASH_YN"); + + // ////////////////////////////////////////////////////////////// + // // 영수증 정보 item(매출정보) - 현금영수증 발행 FLAG // + // ////////////////////////////////////////////////////////////// + // DataRow drCash = dtCash.Rows[0]; + // string sCashReceiptYn = CmUtil.GetDataRowStr(drCash, "CASH_RECEIPT_YN"); + + // ////////////////////////////////////////////////////////////// + // // 영수증 정보 header(매출정보) // + // ////////////////////////////////////////////////////////////// + // header.TRAN_TYPE = "TRAN"; + // //header.CON_NO = m_cPosStatus.Base.KacConNo; + // //header.CON_NO = m_cPosStatus.Base.OutSDVendConNo; + // header.CON_NO = m_cPosStatus.Mst.JOIN_STOR_CD; + // header.SALE_DT = sSaleDt; + // header.STORE_CD = sStorCd; + // header.POS_NO = sPosNo; + // header.RECEIPT_SEQ = sTradeNo; + // header.RECEIPT_NO = sTradeNo; + // header.ITEM_QTY = iTotalItem.ToString(); + // header.SALE_TM = sSaleTm; + // header.CANCEL_YN = CmUtil.GetDataRowStr(dtHeader.Rows[0], "TRADE_DIV"); + // header.TOT_AMT = dTotAmt.ToString(); + // header.SALE_AMT = dNetAmt.ToString(); + // header.TAX_AMT = dVatAmt.ToString(); + // header.CASH_AMT = dCashAmt.ToString(); + // header.CARD_AMT = dCardAmt.ToString(); + // header.ETC_AMT = dEtcAmt.ToString(); + // header.CASH_YN = sCashYn; + // header.CASH_RECEIPT_YN = sCashReceiptYn; + // header.BUY_NM = ""; + // header.BUY_COUN_CD = ""; + // header.BUY_SEX_CD = "9"; + // header.BUY_BIRTHDAY = ""; + // header.BUY_AGE = ""; + // header.AIR_NO = ""; + // header.CREATE_DT = sSysDate; + // } + // 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); + // } + //} + + //private DataTable GetTranHeaderForKac(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo) + //{ + // string sQuery = string.Empty; + // StringBuilder sb = new StringBuilder(); + + // DataTable dtReturn = null; + // try + // { + // sb.Append("SELECT TSH.SYS_DT AS SYS_DT "); + // sb.Append(" , TSH.PAY_TIME AS PAY_TIME "); + // sb.Append(" , TSH.TRADE_NO AS TRADE_NO "); + // sb.Append(" , TSH.TRADE_DIV AS TRADE_DIV "); + // sb.Append(" , TSH.ORG_BILL_NO AS VOID_NO "); + // sb.Append(" , TSD.* "); + // sb.Append(" , ISNULL(TSH.NET_SALE_AMT, 0) - ISNULL(TSH.TOT_VAT, 0) AS NET_TOT_AMT "); + // sb.Append(" , ISNULL(TSH.TOT_VAT, 0) AS TAX_AMT "); + // sb.Append(" FROM POSLOG..TR_SALE_HEADER TSH "); + // sb.Append(" , POSLOG..TR_SALE_DETAIL TSD "); + // sb.Append(" WHERE TSH.CMP_CD = '{0}' "); + // sb.Append(" AND TSH.SALE_DT = '{1}' "); + // sb.Append(" AND TSH.STOR_CD = '{2}' "); + // sb.Append(" AND TSH.POS_NO = '{3}' "); + // sb.Append(" AND TSH.TRADE_NO = '{4}' "); + // sb.Append(" AND TSH.CMP_CD = TSD.CMP_CD "); + // sb.Append(" AND TSH.SALE_DT = TSD.SALE_DT "); + // sb.Append(" AND TSH.STOR_CD = TSD.STOR_CD "); + // sb.Append(" AND TSH.POS_NO = TSD.POS_NO "); + // sb.Append(" AND TSH.TRADE_NO = TSD.TRADE_NO "); + + // sQuery = string.Format(sb.ToString(), sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + + // sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); + // } + // 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 dtReturn; + //} + + //private DataTable GetTranDetailForKac(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo) + //{ + // string sQuery = string.Empty; + // StringBuilder sb = new StringBuilder(); + + // DataTable dtReturn = null; + // try + // { + // sb.Append("SELECT (ISNULL(A.CASH_AMT, 0) + ISNULL(B.CARD_AMT, 0) + ISNULL(C.ETC_AMT, 0)) AS TOTAL_AMT "); + // sb.Append(" , ISNULL(A.CASH_AMT, 0) AS CASH_AMT "); + // sb.Append(" , ISNULL(B.CARD_AMT, 0) AS CARD_AMT "); + // sb.Append(" , ISNULL(C.ETC_AMT, 0) AS ETC_AMT "); + // sb.Append(" , CASE WHEN ((A.CASH_AMT <> 0) AND (B.CARD_AMT = 0) AND (C.ETC_AMT = 0)) "); + // sb.Append(" THEN '1' "); + // sb.Append(" ELSE '0' "); + // sb.Append(" END AS CASH_YN "); + // sb.Append(" FROM ( "); + // sb.Append(" SELECT SUM(ISNULL(PAY_AMT, 0)) AS CASH_AMT "); + // sb.Append(" FROM POSLOG..TR_SALE_PAY "); + // sb.Append(" WHERE CMP_CD = '{0}' "); + // sb.Append(" AND SALE_DT = '{1}' "); + // sb.Append(" AND STOR_CD = '{2}' "); + // sb.Append(" AND POS_NO = '{3}' "); + // sb.Append(" AND TRADE_NO = '{4}' "); + // sb.Append(" AND PAY_WAY_CD = '" + ItemConst.TR_ITEM_ID.CASH_ITEM + "' "); + // sb.Append(" ) A "); + // sb.Append(" , ( "); + // sb.Append(" SELECT SUM(ISNULL(PAY_AMT, 0)) AS CARD_AMT "); + // sb.Append(" FROM POSLOG..TR_SALE_PAY "); + // sb.Append(" WHERE CMP_CD = '{0}' "); + // sb.Append(" AND SALE_DT = '{1}' "); + // sb.Append(" AND STOR_CD = '{2}' "); + // sb.Append(" AND POS_NO = '{3}' "); + // sb.Append(" AND TRADE_NO = '{4}' "); + // sb.Append(" AND PAY_WAY_CD = '" + ItemConst.TR_ITEM_ID.CREDITCARD_ITEM + "' "); + // sb.Append(" ) B "); + // sb.Append(" , ( "); + // sb.Append(" SELECT SUM(ISNULL(PAY_AMT, 0)) AS ETC_AMT "); + // sb.Append(" FROM POSLOG..TR_SALE_PAY "); + // sb.Append(" WHERE CMP_CD = '{0}' "); + // sb.Append(" AND SALE_DT = '{1}' "); + // sb.Append(" AND STOR_CD = '{2}' "); + // sb.Append(" AND POS_NO = '{3}' "); + // sb.Append(" AND TRADE_NO = '{4}' "); + // sb.Append(" AND PAY_WAY_CD <> '" + ItemConst.TR_ITEM_ID.CASH_ITEM + "' "); + // sb.Append(" AND PAY_WAY_CD <> '" + ItemConst.TR_ITEM_ID.CREDITCARD_ITEM + "' "); + // sb.Append(" ) C "); + + // sQuery = string.Format(sb.ToString(), sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + + // sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); + // } + // 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 dtReturn; + //} + + //private DataTable GetTranCashForKac(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo) + //{ + // string sQuery = string.Empty; + // StringBuilder sb = new StringBuilder(); + + // DataTable dtReturn = null; + // try + // { + // sb.Append("SELECT TSH.TRADE_NO AS BILL_NO "); + // sb.Append(" , TSH.ORG_BILL_NO AS VOID_NO "); + // sb.Append(" , TSH.TRADE_DIV AS SALEH_DIV "); + // sb.Append(" , CASE WHEN (ISNULL(TSE.OCCUR_ENTRY_02, 0) = 0) "); + // sb.Append(" THEN '0' "); + // sb.Append(" ELSE '1' "); + // sb.Append(" END AS CASH_RECEIPT_YN "); + // sb.Append(" FROM POSLOG..TR_SALE_HEADER TSH "); + // sb.Append(" LEFT JOIN POSLOG..TR_SALE_ETC TSE "); + // sb.Append(" ON TSH.CMP_CD = TSE.CMP_CD "); + // sb.Append(" AND TSH.SALE_DT = TSE.SALE_DT "); + // sb.Append(" AND TSH.STOR_CD = TSE.STOR_CD "); + // sb.Append(" AND TSH.POS_NO = TSE.POS_NO "); + // sb.Append(" AND TSH.TRADE_NO = TSE.TRADE_NO "); + // sb.Append(" AND TSE.ETC_WAY_CD = '" + ItemConst.TR_ITEM_ID.ETC_INFO.CASHBILL + "' "); + // sb.Append(" WHERE TSH.CMP_CD = '{0}' "); + // sb.Append(" AND TSH.SALE_DT = '{1}' "); + // sb.Append(" AND TSH.STOR_CD = '{2}' "); + // sb.Append(" AND TSH.POS_NO = '{3}' "); + // sb.Append(" AND TSH.TRADE_NO = '{4}' "); + + // sQuery = string.Format(sb.ToString(), sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + + // sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); + // } + // 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 dtReturn; + //} + ///// + ///// 상품마스터 조회 + ///// + ///// + ///// + //private DataTable SeletItemMstToItemCode(string sItemCode) + //{ + // string sQuery = ""; + + // DataTable dtReturn = null; + + // try + // { + // // 상품코드로 상품 마스터 조회 + // sQuery += " SELECT * FROM POSMST..MST_ITEM "; + // sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'"; + // sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'"; + // sQuery += " AND SUB_STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'"; + // sQuery += " AND ITEM_CD = '" + sItemCode + "'"; + // sQuery += " AND USE_YN = '" + PosConst.MST_USE_YN.YES + "'"; + + // sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); + // } + // 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 dtReturn; + //} + #endregion 09 - 한국공항공사 매출 I/F + + #region 10 - 긴급 메세지 읽음 전송(MST_EMG_NOTE) + /// + /// 긴급메세지 전송 메인 + /// + public void EmgNoteSendProcess() + { + DataTable dtReturn = null; + Hashtable htData = null; + string sSendFlag = string.Empty; + string sMsgCode = string.Empty; + string sStartDT = string.Empty; + string sMsgDiv = string.Empty; + try + { + // 전송할 Journal 데이터 생성 + htData = GetEmgNoteData(ref dtReturn); + + if (dtReturn == null || dtReturn.Rows.Count == 0) + { + return; + } + else + { + iSendDataCnt += 1; + } + + sStartDT = CmUtil.GetDataRowStr(dtReturn.Rows[0], Column.IQ_EMG_NOTE_SEND.DATA.START_DT); + sMsgCode = CmUtil.GetDataRowStr(dtReturn.Rows[0], Column.IQ_EMG_NOTE_SEND.DATA.MSG_CODE); + sMsgDiv = CmUtil.GetDataRowStr(dtReturn.Rows[0], Column.IQ_EMG_NOTE_SEND.DATA.MSG_DIV); + + string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.JrnlPort), + Convert.ToInt32(m_cPosStatus.Base.JrnlTimeout), + new string[] { m_cPosStatus.Base.CmpCd, m_cPosStatus.Base.BrandCd, m_cPosStatus.Base.StoreNo, m_cPosStatus.Base.SaleDate, m_cPosStatus.Base.PosNo, m_cPosStatus.Base.TradeNo }, + ItemConst.COMM_MSG_TYPE.EMG_NOTE_SEND, + htData); + + if (sReturn == UserCom.RST_OK) + { + sSendFlag = "1"; // 정상 전송 + m_cPosStatus.Sale.OnLineStatus = "1"; + } + else + { + sSendFlag = "9"; // 에러 + m_cPosStatus.Sale.OnLineStatus = "0"; + } + } + 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); + sSendFlag = "9"; + } + finally + { + // Flag Update + EmgNoteFlgUpdate(sStartDT, sMsgCode, sMsgDiv, sSendFlag); + } + } + + /// + /// 전송 완료 업데이트 + /// + /// + /// + /// + /// + private int EmgNoteFlgUpdate(string sStartDT, string sMsgCode, string sMsgDiv, string sSendFlag) + { + int iRet = UserCom.NG; + string sQuery = string.Empty; + try + { + if (sStartDT.Trim() == "" || sMsgCode.Trim() == "" || sMsgDiv.Trim() == "") return iRet; + + sQuery += " UPDATE POSMST..MST_EMG_NOTE "; + sQuery += " SET SEND_YN = '" + sSendFlag + "' "; + + //성공한것만 업데이트 시간 변경! + if (sSendFlag == "1") + sQuery += " , UPD_DT = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + + sQuery += " WHERE 1 = 1 "; + sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'"; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'"; + sQuery += " AND START_DT = '" + sStartDT + "'"; + sQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "'"; + sQuery += " AND MSG_CODE = '" + sMsgCode + "' "; + sQuery += " AND MSG_DIV = '" + sMsgDiv + "' "; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); + } + 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 iRet; + } + /// + /// 긴급메세지 전송 조회 + /// + /// + /// + public Hashtable GetEmgNoteData(ref DataTable dtReturn) + { + Hashtable htReturn = null; + string sQuery = string.Empty; + + DataTable dtTempReturn = null; + try + { + sQuery += " SELECT TOP 1 "; + sQuery += " CMP_CD, STOR_CD, POS_NO, MSG_CODE, MSG_DIV, START_DT, UPD_DT, READ_YN "; + sQuery += " FROM POSMST..MST_EMG_NOTE "; + sQuery += " WHERE 1 = 1 "; + sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'"; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'"; + sQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "'"; + sQuery += " AND START_DT BETWEEN CONVERT(VARCHAR,GETDATE()-7,112) AND CONVERT(VARCHAR,GETDATE(),112) "; //-7일 전부터 + sQuery += " AND SEND_YN IN ('0','9') "; + sQuery += " ORDER BY READ_YN, UPD_DT "; + + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn.Rows.Count == 1) + { + DataRow drTempReturn = dtTempReturn.Rows[0]; + + htReturn = MakeEmgNoteJsonData(drTempReturn); + } + } + + dtReturn = dtTempReturn; + } + 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 htReturn; + } + /// + /// 긴급메세지 전송 헤시테이블 담기 + /// + /// + /// + private Hashtable MakeEmgNoteJsonData(DataRow drData) + { + Hashtable htData = new Hashtable(); + + try + { + // 01 - 회사코드 + htData.Add(Column.IQ_EMG_NOTE_SEND.DATA.CMP_CD, CmUtil.GetDataRowStr(drData, Column.IQ_EMG_NOTE_SEND.DATA.CMP_CD)); //"CMP_CD")); + // 02 - 점포코드 + htData.Add(Column.IQ_EMG_NOTE_SEND.DATA.STOR_CD, CmUtil.GetDataRowStr(drData, Column.IQ_EMG_NOTE_SEND.DATA.STOR_CD)); //"STOR_CD")); + // 03 - 포스번호 + htData.Add(Column.IQ_EMG_NOTE_SEND.DATA.POS_NO, CmUtil.GetDataRowStr(drData, Column.IQ_EMG_NOTE_SEND.DATA.POS_NO)); //"POS_NO")); + // 04 - 메세지코드 + htData.Add(Column.IQ_EMG_NOTE_SEND.DATA.MSG_CODE, CmUtil.GetDataRowStr(drData, Column.IQ_EMG_NOTE_SEND.DATA.MSG_CODE)); //"MSG_CODE")); + // 05 - 메시지 구분별 유형 + htData.Add(Column.IQ_EMG_NOTE_SEND.DATA.MSG_DIV, CmUtil.GetDataRowStr(drData, Column.IQ_EMG_NOTE_SEND.DATA.MSG_DIV)); // "MSG_DIV")); + // 06 - 시작 시간 + htData.Add(Column.IQ_EMG_NOTE_SEND.DATA.START_DT, CmUtil.GetDataRowStr(drData, Column.IQ_EMG_NOTE_SEND.DATA.START_DT)); + // 07 - 업데이트 시간 + htData.Add(Column.IQ_EMG_NOTE_SEND.DATA.UPD_DT, CmUtil.GetDataRowStr(drData, Column.IQ_EMG_NOTE_SEND.DATA.UPD_DT)); // "UPD_DT")); + // 08 - 읽음 시간 - 2017-01-24 추가 + htData.Add(Column.IQ_EMG_NOTE_SEND.DATA.READ_YN, CmUtil.GetDataRowStr(drData, Column.IQ_EMG_NOTE_SEND.DATA.READ_YN)); // "READ_YN")); + + } + 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 htData; + } + + #endregion + + #region 11 - 점포점검 내역 전송 (ITR 전송) + public void StoreCheckSendProcess() + { + DataTable dtReturn = null; + + string sSendFlag = ""; + string sCmpCd = ""; + string sStorCd = ""; + string sSaleDt = ""; + string sInspctEntryGrpCd = ""; + + Hashtable htSendData = new Hashtable(); + Hashtable htRecvData = new Hashtable(); + + try + { + // 전송할 점포점검 데이터 생성 + string sStoreCheckLog = GetStoreCheckLog(ref dtReturn); + + if (dtReturn == null || dtReturn.Rows.Count == 0) + { + return; + } + else + { + iSendDataCnt += 1; + } + + DataRow dr = dtReturn.Rows[0]; + sCmpCd = CmUtil.GetDataRowStr(dr, Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.CMP_CD); + sStorCd = CmUtil.GetDataRowStr(dr, Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.STOR_CD); + sSaleDt = CmUtil.GetDataRowStr(dr, Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.START_DT); + sInspctEntryGrpCd = CmUtil.GetDataRowStr(dr, Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.INSPCT_ENTRY_GRP_CD); + + htSendData = MakeStoreCheckLogJsonData(dr, sStoreCheckLog); + + string sReturn = ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.PayInqPort, 10000, htSendData, ref htRecvData, false); + if (sReturn == UserCom.RST_OK) + { + sSendFlag = "1"; // 정상 전송 + m_cPosStatus.Sale.OnLineStatus = "1"; + } + else + { + sSendFlag = "9"; // 에러 + m_cPosStatus.Sale.OnLineStatus = "0"; + } + } + 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); + sSendFlag = "9"; + } + finally + { + // Flag Update + StoreCheckFlgUpdate(sCmpCd, sStorCd, sSaleDt, sInspctEntryGrpCd, sSendFlag); + } + } + + private Hashtable MakeStoreCheckLogJsonData(DataRow drData, string sStoreCheckLog) + { + Hashtable htData = new Hashtable(); + + try + { + // 01 - INQ 종별 + htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.INQ_TYPE, ItemConst.IRT_INQ_TYPE.STORE_CHECK_SAVE); + // 02 - 점포 코드 + htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.STOR_CD, CmUtil.GetDataRowStr(drData, Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.STOR_CD)); + // 03 - 요청구분 + htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.INQ_DIV, "1"); + // 04 - 점포점검 데이터 + htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.SAVE_DATA, sStoreCheckLog); + // 05 - 응답 코드 + htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.RES_CD, ""); + } + 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 htData; + } + + private int StoreCheckFlgUpdate(string sCmpCd, string sStorCd, string sSaleDt, string sInspctEntryGrpCd, string sSendFlag) + { + int iRet = UserCom.NG; + string sQuery = ""; + try + { + if (sCmpCd.Trim() == "") return iRet; + if (sSaleDt.Trim() == "") return iRet; + if (sStorCd.Trim() == "") return iRet; + + sQuery = " UPDATE POSLOG..ETC_STOR_INSPCT_ANSWR_STOR "; + sQuery += " SET SEND_YN = '" + sSendFlag + "' "; + sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; + sQuery += " AND START_DT = '" + sSaleDt + "' "; + sQuery += " AND STOR_CD = '" + sStorCd + "' "; + sQuery += " AND INSPCT_ENTRY_GRP_CD = '" + sInspctEntryGrpCd + "' "; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); + } + 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 iRet; + } + + public string GetStoreCheckLog(ref DataTable dtReturn) + { + string sQuery = ""; + string sCMP_CD = ""; + string sSTOR_CD = ""; + string sSTART_DT = ""; + string sINSPCT_ENTRY_GRP_CD = ""; + + string sStoreCheckData = ""; + + DataTable dtTempReturn = null; + try + { + sQuery = " SELECT TOP 1 "; + sQuery += " CMP_CD, INSPCT_ENTRY_GRP_CD, STOR_CD, START_DT "; + sQuery += " FROM POSLOG..ETC_STOR_INSPCT_ANSWR_STOR "; + sQuery += " WHERE SEND_YN <> '1' "; + sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sQuery += " ORDER BY SEND_YN, START_DT "; + + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn.Rows.Count == 1) + { + DataRow drTempReturn = dtTempReturn.Rows[0]; + + sCMP_CD = drTempReturn[Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.CMP_CD].ToString(); + sSTOR_CD = drTempReturn[Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.STOR_CD].ToString(); + sSTART_DT = drTempReturn[Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.START_DT].ToString(); + sINSPCT_ENTRY_GRP_CD = drTempReturn[Column.ETC_STOR_INSPCT_ANSWR_STOR.NAME.INSPCT_ENTRY_GRP_CD].ToString(); + + + sStoreCheckData = GetStoreCheckHeader(sCMP_CD, sSTOR_CD, sSTART_DT, sINSPCT_ENTRY_GRP_CD) + + GetStoreCheckDetail(sCMP_CD, sSTOR_CD, sSTART_DT, sINSPCT_ENTRY_GRP_CD); + } + } + + dtReturn = dtTempReturn; + } + 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 sStoreCheckData; + } + + private string GetStoreCheckHeader(string sCMP_CD, string sSTOR_CD, string sSTART_DT, string sINSPCT_ENTRY_GRP_CD) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '" + ItemConst.IRT_TRAN_TYPE.TranHeader + "' + '|' + ISNULL(CMP_CD, '') + '|' + ISNULL(INSPCT_ENTRY_GRP_CD, '') + '|' + ISNULL(STOR_CD, '') + '|' + ISNULL(START_DT, '') + '|' + ISNULL(ANSWR_YN, '') + '|' + "; + sQuery += " ISNULL(ETC_CTNTS_1, '') + '|' + ISNULL(ETC_CTNTS_2, '') + '|' + ISNULL(ETC_CTNTS_3, '') + '|' + ISNULL(REG_USER_ID, '') + '|' + ISNULL(REG_DATE, '') + '|' + "; + sQuery += " ISNULL(UPD_USER_ID, '') + '|' + ISNULL(UPD_DATE, '') AS STORE_CHECK_HEADER "; + sQuery += " FROM POSLOG..ETC_STOR_INSPCT_ANSWR_STOR "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND START_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + sQuery += " AND INSPCT_ENTRY_GRP_CD = '{3}' "; + + sSQL = string.Format(sQuery + , sCMP_CD + , sSTART_DT + , sSTOR_CD + , sINSPCT_ENTRY_GRP_CD); + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + + private string GetStoreCheckDetail(string sCMP_CD, string sSTOR_CD, string sSTART_DT, string sINSPCT_ENTRY_GRP_CD) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranDetail + "' + '|' + ISNULL(CMP_CD, '') + '|' + ISNULL(BRAND_CD, '') + '|' + ISNULL(INSPCT_ENTRY_GRP_CD, '') + '|' + ISNULL(STOR_CD, '') + '|' + ISNULL(START_DT, '') + '|' + "; + sQuery += " ISNULL(INSPCT_ENTRY_L_CLSS_CD, '') + '|' + CONVERT(VARCHAR, ISNULL(INSPCT_ENTRY, 0)) + '|' + ISNULL(SEL_ENTRY_1_YN, '') + '|' + ISNULL(SEL_ENTRY_2_YN, '') + '|' + ISNULL(SEL_ENTRY_3_YN, '') + '|' + ISNULL(SEL_ENTRY_4_YN, '') + '|' + ISNULL(SEL_ENTRY_5_YN, '') + '|' +"; + sQuery += " CONVERT(VARCHAR, ISNULL(SCORE_1, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SCORE_2, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SCORE_3, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SCORE_4, 0)) + '|' + CONVERT(VARCHAR, ISNULL(SCORE_5, 0)) + '|' + "; + sQuery += " ISNULL(SEL_ENTRY_1_CTNTS, '') + '|' + ISNULL(SEL_ENTRY_2_CTNTS, '') + '|' + ISNULL(SEL_ENTRY_3_CTNTS, '') + '|' + ISNULL(SEL_ENTRY_4_CTNTS, '') + '|' + ISNULL(SEL_ENTRY_5_CTNTS, 0) + '|' + "; + sQuery += " ISNULL(NOTE, '') + '|' + ISNULL(REG_USER_ID, 0) + '|' + ISNULL(REG_DATE, '') + '|' + ISNULL(UPD_USER_ID, '') + '|' + ISNULL(UPD_DATE, '') AS STORE_CHECK_DETAIL "; + sQuery += " FROM POSLOG..ETC_STOR_INSPCT_ANSWR "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND START_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + sQuery += " AND INSPCT_ENTRY_GRP_CD = '{3}' "; + + sSQL = string.Format(sQuery + , sCMP_CD + , sSTART_DT + , sSTOR_CD + , sINSPCT_ENTRY_GRP_CD); + + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + + #endregion + + #region 12 - 점포장비점검 내역 전송 (ITR 전송) + public void StoreEquipCheckSendProcess() + { + DataTable dtReturn = null; + + string sSendFlag = ""; + string sCmpCd = ""; + string sStorCd = ""; + string sSaleDt = ""; + + Hashtable htSendData = new Hashtable(); + Hashtable htRecvData = new Hashtable(); + + try + { + // 전송할 점포점검 데이터 생성 + string sStoreCheckLog = GetStoreEquipCheckLog(ref dtReturn); + + if (dtReturn == null || dtReturn.Rows.Count == 0) + { + return; + } + else + { + iSendDataCnt += 1; + } + + DataRow dr = dtReturn.Rows[0]; + sCmpCd = CmUtil.GetDataRowStr(dr, Column.ETC_STOR_EQU_CHECK_LIST.NAME.CMP_CD); + sStorCd = CmUtil.GetDataRowStr(dr, Column.ETC_STOR_EQU_CHECK_LIST.NAME.STOR_CD); + sSaleDt = CmUtil.GetDataRowStr(dr, Column.ETC_STOR_EQU_CHECK_LIST.NAME.SALE_DT); + + htSendData = MakeStoreEquipCheckLogJsonData(dr, sStoreCheckLog); + + string sReturn = ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.PayInqPort, 10000, htSendData, ref htRecvData, false); + if (sReturn == UserCom.RST_OK) + { + sSendFlag = "1"; // 정상 전송 + m_cPosStatus.Sale.OnLineStatus = "1"; + } + else + { + sSendFlag = "9"; // 에러 + m_cPosStatus.Sale.OnLineStatus = "0"; + } + } + 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); + sSendFlag = "9"; + } + finally + { + // Flag Update + StoreEquipCheckFlgUpdate(sCmpCd, sStorCd, sSaleDt, sSendFlag); + } + } + + private Hashtable MakeStoreEquipCheckLogJsonData(DataRow drData, string sStoreCheckLog) + { + Hashtable htData = new Hashtable(); + + try + { + // 01 - INQ 종별 + htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.INQ_TYPE, ItemConst.IRT_INQ_TYPE.STR_EQUIP_CHECK_SAVE); + // 02 - 점포 코드 + htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.STOR_CD, CmUtil.GetDataRowStr(drData, Column.ETC_STOR_EQU_CHECK_LIST.NAME.STOR_CD)); + // 03 - 요청구분 + htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.INQ_DIV, "1"); + // 04 - 점포점검 데이터 + htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.SAVE_DATA, sStoreCheckLog); + // 05 - 응답 코드 + htData.Add(Column.IQ_STOR_CHECK_LIST_INQ.DATA.RES_CD, ""); + } + 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 htData; + } + + private int StoreEquipCheckFlgUpdate(string sCmpCd, string sStorCd, string sSaleDt, string sSendFlag) + { + int iRet = UserCom.NG; + string sQuery = ""; + try + { + if (sCmpCd.Trim() == "") return iRet; + if (sSaleDt.Trim() == "") return iRet; + if (sStorCd.Trim() == "") return iRet; + + sQuery = " UPDATE POSLOG..ETC_STOR_EQU_CHECK_LIST "; + sQuery += " SET SEND_YN = '" + sSendFlag + "' "; + sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; + sQuery += " AND SALE_DT = '" + sSaleDt + "' "; + sQuery += " AND STOR_CD = '" + sStorCd + "' "; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); + } + 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 iRet; + } + + public string GetStoreEquipCheckLog(ref DataTable dtReturn) + { + string sQuery = ""; + string sCMP_CD = ""; + string sSTOR_CD = ""; + string sSTART_DT = ""; + + string sStoreCheckData = ""; + + DataTable dtTempReturn = null; + try + { + sQuery = " SELECT TOP 1 "; + sQuery += " CMP_CD, STOR_CD, SALE_DT "; + sQuery += " FROM POSLOG..ETC_STOR_EQU_CHECK_LIST "; + sQuery += " WHERE SEND_YN <> '1' "; + sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sQuery += " ORDER BY SEND_YN, SALE_DT "; + + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn.Rows.Count == 1) + { + DataRow drTempReturn = dtTempReturn.Rows[0]; + + sCMP_CD = drTempReturn[Column.ETC_STOR_EQU_CHECK_LIST.NAME.CMP_CD].ToString(); + sSTOR_CD = drTempReturn[Column.ETC_STOR_EQU_CHECK_LIST.NAME.STOR_CD].ToString(); + sSTART_DT = drTempReturn[Column.ETC_STOR_EQU_CHECK_LIST.NAME.SALE_DT].ToString(); + + sStoreCheckData = GetStoreEquipCheckHeader(sCMP_CD, sSTOR_CD, sSTART_DT) + + GetStoreEquipCheckDetail(sCMP_CD, sSTOR_CD, sSTART_DT); + } + } + + dtReturn = dtTempReturn; + } + 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 sStoreCheckData; + } + + private string GetStoreEquipCheckHeader(string sCMP_CD, string sSTOR_CD, string sSALE_DT) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '" + ItemConst.IRT_TRAN_TYPE.TranHeader + "' + '|' + ISNULL(CMP_CD, '') + '|' + ISNULL(STOR_CD, '') + '|' + ISNULL(SALE_DT, '') + '|' + ISNULL(CHECK_STATE, '') + '|' + "; + sQuery += " ISNULL(REG_USER_ID, '') + '|' + ISNULL(REG_DATE, '') + '|' + ISNULL(UPD_USER_ID, '') + '|' + ISNULL(UPD_DATE, '') AS STORE_EQUIP_CHECK_HEADER "; + sQuery += " FROM POSLOG..ETC_STOR_EQU_CHECK_LIST "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND SALE_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + + sSQL = string.Format(sQuery + , sCMP_CD + , sSALE_DT + , sSTOR_CD); + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + + private string GetStoreEquipCheckDetail(string sCMP_CD, string sSTOR_CD, string sSALE_DT) + { + StringBuilder sbTranData = new StringBuilder(); + string sQuery = ""; + string sSQL = ""; + DataTable dtTempReturn = null; + + try + { + sQuery += " SELECT '#~' + '" + ItemConst.IRT_TRAN_TYPE.TranDetail + "' + '|' + ISNULL(CMP_CD, '') + '|' + ISNULL(STOR_CD, '') + '|' + ISNULL(SALE_DT, '') + '|' + "; + sQuery += " ISNULL(CHECK_DIV_CD, '') + '|' + ISNULL(CHECK_EQU_CD, '') + '|' + ISNULL(CHECK_RESULT, '') + '|' + ISNULL(AS_RESULT, '') + '|' + ISNULL(STOR_RESULT, '') + '|' + "; + sQuery += " ISNULL(REG_USER_ID, 0) + '|' + ISNULL(REG_DATE, '') + '|' + ISNULL(UPD_USER_ID, '') + '|' + ISNULL(UPD_DATE, '') AS STORE_EQUIP_CHECK_DETAIL "; + sQuery += " FROM POSLOG..ETC_STOR_EQU_CHECK_DETAIL "; + sQuery += " WHERE CMP_CD = '{0}' "; + sQuery += " AND SALE_DT = '{1}' "; + sQuery += " AND STOR_CD = '{2}' "; + + sSQL = string.Format(sQuery + , sCMP_CD + , sSALE_DT + , sSTOR_CD); + + + if (sqlDb.DBDataTableSelect(sSQL, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn != null && dtTempReturn.Rows.Count > 0) + { + foreach (DataRow dr in dtTempReturn.Rows) + { + sbTranData.Append(dr[0].ToString()); + } + } + } + } + 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 sbTranData.ToString(); + } + + #endregion + + #region 13 - SCALE Log 전송 + public void ScaleLogSendProcess() + { + DataTable dtReturn = null; + Hashtable htData = null; + string sSendFlag = string.Empty; + string sCmpCd = string.Empty; + string sBrandCd = string.Empty; + string sStorCd = string.Empty; + string sSaleDt = string.Empty; + string sPosNo = string.Empty; + string sScaleDt = string.Empty; + string sScaleTm = string.Empty; + + try + { + // 전송할 Scale Log 데이터 생성 + htData = GetScaleLogData(ref dtReturn); + + if(dtReturn == null || dtReturn.Rows.Count == 0) + { + return; + } + else + { + iSendDataCnt += 1; + } + + sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); + sBrandCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "BRAND_CD"); + sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); + sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); + sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); + sScaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SCALE_DT"); + sScaleTm = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SCALE_TM"); + + string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.ScaleLogPort), + 5000, + new string[] { sCmpCd, sBrandCd, sStorCd, sSaleDt, sPosNo, "" }, + ItemConst.COMM_MSG_TYPE.SCALE_LOG, + htData); + + if(sReturn == UserCom.RST_OK) + { + sSendFlag = "1"; // 정상 전송 + + m_cPosStatus.Sale.OnLineStatus = "1"; + } + else + { + sSendFlag = "9"; // 에러 + + m_cPosStatus.Sale.OnLineStatus = "0"; + } + } + 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); + sSendFlag = "9"; + } + finally + { + // Flag Update + ScaleLogFlgUpdate(sCmpCd, sBrandCd, sSaleDt, sStorCd, sPosNo, sScaleDt, sScaleTm, sSendFlag); + } + } + + public Hashtable GetScaleLogData(ref DataTable dtReturn) + { + Hashtable htReturn = null; + string sQuery = string.Empty; + + DataTable dtTempReturn = null; + try + { + sQuery += "SELECT TOP 1 "; + sQuery += " CMP_CD, BRAND_CD, SALE_DT, STOR_CD, POS_NO "; + sQuery += " , SCALE_DT, SCALE_TM, WEIGHT, ITEM_NM, NORMAL_YN "; + sQuery += " FROM POSLOG..ETC_SCALE_LOG "; + sQuery += " WHERE SEND_YN <> '1' "; + sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sQuery += " ORDER BY SEND_YN, SALE_DT "; + + if(sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if(dtTempReturn.Rows.Count == 1) + { + DataRow drTempReturn = dtTempReturn.Rows[0]; + + htReturn = MakeScaleLogJsonData(drTempReturn); + } + } + + dtReturn = dtTempReturn; + } + 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 htReturn; + } + + private Hashtable MakeScaleLogJsonData(DataRow drData) + { + Hashtable htData = new Hashtable(); + + try + { + // 01 - 회사코드 + htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.CmpCd, CmUtil.GetDataRowStr(drData, "CMP_CD")); + // 02 - 점포코드 + htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.StorCd, CmUtil.GetDataRowStr(drData, "STOR_CD")); + // 03 - 판매일자 + htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.SaleDt, CmUtil.GetDataRowStr(drData, "SALE_DT")); + // 04 - 포스번호 + htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.PosNo, CmUtil.GetDataRowStr(drData, "POS_NO")); + // 05 - 측정일자 + htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.ScaleDt, CmUtil.GetDataRowStr(drData, "SCALE_DT")); + // 06 - 측정시간 + htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.ScaleTm, CmUtil.GetDataRowStr(drData, "SCALE_TM")); + // 07 - 중량 + htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.Weight, CmUtil.GetDataRowStr(drData, "WEIGHT")); + // 08 - 상품명 + htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.ItemNm, CmUtil.GetDataRowStr(drData, "ITEM_NM")); + // 09 - 정상/미달 구분 + htData.Add(Column.IQ_SCALE_LOG_REQ.DATA.NormalYn, CmUtil.GetDataRowStr(drData, "NORMAL_YN")); + } + 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 htData; + } + + private int ScaleLogFlgUpdate(string sCmpCd, string sBrandCd, string sSaleDt, string sStorCd, string sPosNo, string sScaleDt, string sScaleTm, string sSendFlag) + { + int iRet = UserCom.NG; + string sQuery = string.Empty; + try + { + if (sCmpCd.Trim() == "") return iRet; + if (sBrandCd.Trim() == "") return iRet; + if (sSaleDt.Trim() == "") return iRet; + if (sStorCd.Trim() == "") return iRet; + if (sPosNo.Trim() == "") return iRet; + if (sScaleDt.Trim() == "") return iRet; + if (sScaleTm.Trim() == "") return iRet; + + sQuery += "UPDATE POSLOG..ETC_SCALE_LOG "; + sQuery += " SET SEND_YN = '" + sSendFlag + "' "; + sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; + sQuery += " AND BRAND_CD = '" + sBrandCd + "' "; + sQuery += " AND SALE_DT = '" + sSaleDt + "' "; + sQuery += " AND STOR_CD = '" + sStorCd + "' "; + sQuery += " AND POS_NO = '" + sPosNo + "' "; + sQuery += " AND SCALE_DT = '" + sScaleDt + "' "; + sQuery += " AND SCALE_TM = '" + sScaleTm + "' "; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); + } + 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 iRet; + } + #endregion 13 - SCALE Log 전송 + + #region 14 - 보류 로그 전송 + /// + /// 보류로그 전송 메인 + /// + public void HoldLogSendProcess() + { + DataTable dtReturn = null; + Hashtable htData = null; + string sSendFlag = string.Empty; + string sCmpCd = string.Empty; + string sBrandCd = string.Empty; + string sStorCd = string.Empty; + string sSaleDt = string.Empty; + string sPosNo = string.Empty; + string sRegNo = string.Empty; + string sSeq = string.Empty; + + + try + { + // 전송할 Scale Log 데이터 생성 + htData = GetHoldLogData(ref dtReturn); + + if (dtReturn == null || dtReturn.Rows.Count == 0) + { + return; + } + else + { + iSendDataCnt += 1; + } + + sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); + sBrandCd = m_cPosStatus.Base.BrandCd; + sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); + sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); + sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); + sRegNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "REG_NO"); + sSeq = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SEQ"); + + string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.ScaleLogPort), + 5000, + new string[] { sCmpCd, sBrandCd, sStorCd, sSaleDt, sPosNo, "" }, + ItemConst.COMM_MSG_TYPE.HOLD_LOG, + htData); + + if (sReturn == UserCom.RST_OK) + { + sSendFlag = "1"; // 정상 전송 + + m_cPosStatus.Sale.OnLineStatus = "1"; + } + else + { + sSendFlag = "9"; // 에러 + + m_cPosStatus.Sale.OnLineStatus = "0"; + } + } + 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); + sSendFlag = "9"; + } + finally + { + // Flag Update + HoldLogFlgUpdate(sCmpCd, sSaleDt, sStorCd, sPosNo, sRegNo, sSeq, sSendFlag); + } + } + + /// + /// 데이터 조회 + /// + /// + /// + public Hashtable GetHoldLogData(ref DataTable dtReturn) + { + Hashtable htReturn = null; + string sQuery = string.Empty; + + DataTable dtTempReturn = null; + try + { + ///////////////////////////////////////////////////////////////// + /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! + ///////////////////////////////////////////////////////////////// + + sQuery += "SELECT TOP 1 "; + sQuery += " CMP_CD, SALE_DT, STOR_CD, POS_NO, REG_NO, SEQ, HOLD_STAT, SYS_DT, SYS_TM, REG_SEQ "; + sQuery += " ,ORG_REG_SEQ, PIC_NO, ITEM_QTY, SALE_AMT, AMT_FILLER_01, AMT_FILLER_02, STR_FILLER_01, STR_FILLER_02 "; + sQuery += " FROM POSLOG.dbo.ETC_HOLD_HISTORY "; + sQuery += " WHERE SEND_YN <> '1' "; + sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sQuery += " ORDER BY SEND_YN ASC "; + + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn.Rows.Count == 1) + { + DataRow drTempReturn = dtTempReturn.Rows[0]; + + htReturn = MakeHoldLogJsonData(drTempReturn); + } + } + + dtReturn = dtTempReturn; + } + 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 htReturn; + } + + /// + /// 전문 생성 + /// + /// + /// + private Hashtable MakeHoldLogJsonData(DataRow drData) + { + Hashtable htData = new Hashtable(); + + try + { + ///////////////////////////////////////////////////////////////// + /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! + ///////////////////////////////////////////////////////////////// + + // 전문 생성 + for (int iRow = 0; iRow < drData.Table.Columns.Count; iRow++) + { + htData.Add(drData.Table.Columns[iRow].ColumnName, drData[iRow].ToString()); + } + + } + 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 htData; + } + + /// + /// 디비 업데이트 + /// + /// + /// + /// + /// + /// + /// + /// + private int HoldLogFlgUpdate(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sRegNo, string sSeq, string sSendFlag) + { + int iRet = UserCom.NG; + string sQuery = string.Empty; + try + { + if (sCmpCd.Trim() == "" || sSaleDt.Trim() == "" || sStorCd.Trim() == "" || sPosNo.Trim() == "" || sRegNo.Trim() == "" || sSeq.Trim() == "") return iRet; + + sQuery += "UPDATE POSLOG.dbo.ETC_HOLD_HISTORY "; + sQuery += " SET SEND_YN = '" + sSendFlag + "' "; + sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; + sQuery += " AND SALE_DT = '" + sSaleDt + "' "; + sQuery += " AND STOR_CD = '" + sStorCd + "' "; + sQuery += " AND POS_NO = '" + sPosNo + "' "; + sQuery += " AND REG_NO = '" + sRegNo + "' "; + sQuery += " AND SEQ = '" + sSeq + "' "; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); + } + 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 iRet; + } + #endregion 14 - 보류 로그 전송 + + #region 15 - 해피앱 추후적립 내역 전송(TR_HPAPP_AFTER_SAVE 전송) + //#해피앱 추후적립 start, sskim + /// + /// 보류로그 전송 메인 + /// + public void HpAppAfterSaveSendProcess() + { + DataTable dtReturn = null; + Hashtable htData = null; + string sSendFlag = string.Empty; + string sCmpCd = string.Empty; + string sBrandCd = string.Empty; + string sStorCd = string.Empty; + string sSaleDt = string.Empty; + string sPosNo = string.Empty; + string sTradeNo = string.Empty; + + + try + { + // 전송할 TR_HpAppAfterSave 데이터 생성 + htData = GetHpAppAfterSaveData(ref dtReturn); + + if (dtReturn == null || dtReturn.Rows.Count == 0) + { + return; + } + else + { + iSendDataCnt += 1; + } + + sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); + sBrandCd = m_cPosStatus.Base.BrandCd; + sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); + sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); + sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); + sTradeNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "TRADE_NO"); + + string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.JrnlPort), + 5000, + new string[] { sCmpCd, sBrandCd, sStorCd, sSaleDt, sPosNo, sTradeNo }, + ItemConst.COMM_MSG_TYPE.HPAPP_AFTER_SAVE, + htData); + + if (sReturn == UserCom.RST_OK) + { + sSendFlag = "1"; // 정상 전송 + + m_cPosStatus.Sale.OnLineStatus = "1"; + } + else + { + sSendFlag = "9"; // 에러 + + m_cPosStatus.Sale.OnLineStatus = "0"; + } + } + 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); + sSendFlag = "9"; + } + finally + { + // Flag Update + HpAppAfterSaveUpdate(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo, sSendFlag); + } + } + + /// + /// 데이터 조회 + /// + /// + /// + public Hashtable GetHpAppAfterSaveData(ref DataTable dtReturn) + { + Hashtable htReturn = null; + string sQuery = string.Empty; + + DataTable dtTempReturn = null; + try + { + ///////////////////////////////////////////////////////////////// + /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! + ///////////////////////////////////////////////////////////////// + + sQuery += "SELECT TOP 1 "; + sQuery += " CMP_CD, SALE_DT, STOR_CD, POS_NO, TRADE_NO "; + sQuery += " ,BILL_BAR_CD, TMNLNO, TOT_TRADE_AMT, ACCUM_TRGT_AMT, APPR_WAY_CD "; + sQuery += " ,APPR_CARD_NO, ADD_ACCUM_YN, ADD_ACCUM_CD, ADD_ACCUM_HQ_ALLOT_AMT, ADD_ACCUM_STOR_ALLOT_AMT "; + sQuery += " ,SAVE_STATUS "; + sQuery += " FROM POSLOG.dbo.TR_HPAPP_AFTER_SAVE "; + sQuery += " WHERE SEND_YN <> '1' "; + sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sQuery += " ORDER BY SEND_YN ASC "; + + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn.Rows.Count == 1) + { + DataRow drTempReturn = dtTempReturn.Rows[0]; + + htReturn = MakeHpAppAfterSaveJsonData(drTempReturn); + } + } + + dtReturn = dtTempReturn; + } + 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 htReturn; + } + + /// + /// 전문 생성 + /// + /// + /// + private Hashtable MakeHpAppAfterSaveJsonData(DataRow drData) + { + Hashtable htData = new Hashtable(); + + try + { + ///////////////////////////////////////////////////////////////// + /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! + ///////////////////////////////////////////////////////////////// + + // 전문 생성 + for (int iRow = 0; iRow < drData.Table.Columns.Count; iRow++) + { + htData.Add(drData.Table.Columns[iRow].ColumnName, drData[iRow].ToString()); + } + + } + 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 htData; + } + + /// + /// 디비 업데이트 + /// + /// + /// + /// + /// + /// + /// + private int HpAppAfterSaveUpdate(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo, string sSendFlag) + { + int iRet = UserCom.NG; + string sQuery = string.Empty; + try + { + if (sCmpCd.Trim() == "" || sSaleDt.Trim() == "" || sStorCd.Trim() == "" || sPosNo.Trim() == "" || sTradeNo.Trim() == "") return iRet; + + sQuery += "UPDATE POSLOG.dbo.TR_HPAPP_AFTER_SAVE "; + sQuery += " SET SEND_YN = '" + sSendFlag + "' "; + sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; + sQuery += " AND SALE_DT = '" + sSaleDt + "' "; + sQuery += " AND STOR_CD = '" + sStorCd + "' "; + sQuery += " AND POS_NO = '" + sPosNo + "' "; + sQuery += " AND TRADE_NO = '" + sTradeNo + "' "; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); + } + 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 iRet; + } + + //#해피앱 추후적립 end, sskim + #endregion 15 - 해피앱 추후적립 내역 전송(TR_HPAPP_AFTER_SAVE 전송) + + //#20171120 유통기한 바코드 인식률 start, phj + #region 16 - 유통기한 바코드 인식률 (TR_BAR_SUCESS_RATE 전송) + + public void BarcodeSucessRateSendProcess() + { + DataTable dtReturn = null; + Hashtable htData = null; + + string sSendFlag = string.Empty; + string sCmpCd = string.Empty; + string sBrandCd = string.Empty; + string sStorCd = string.Empty; + string sSaleDt = string.Empty; + string sPosNo = string.Empty; + string sTradeNo = string.Empty; + string sSeq = string.Empty; + + try + { + // 전송할 TR_BAR_SUCESS_RATE 데이터 생성 + htData = GetBarcodeSucessRateData(ref dtReturn); + + if (dtReturn == null || dtReturn.Rows.Count == 0) + { + return; + } + else + { + iSendDataCnt += 1; + } + + sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); + sBrandCd = m_cPosStatus.Base.BrandCd; + sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); + sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); + sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); + sTradeNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "REG_NO"); + sSeq = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SEQ"); + + + string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.JrnlPort), + 5000, + new string[] { sCmpCd, sBrandCd, sStorCd, sSaleDt, sPosNo, sTradeNo }, + ItemConst.COMM_MSG_TYPE.BAR_SUCESS_RATE, + htData); + + if (sReturn == UserCom.RST_OK) + { + sSendFlag = "1"; // 정상 전송 + + m_cPosStatus.Sale.OnLineStatus = "1"; + } + else + { + sSendFlag = "9"; // 에러 + + m_cPosStatus.Sale.OnLineStatus = "0"; + } + } + 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); + sSendFlag = "9"; + } + finally + { + // Flag Update + BarcodeSucessRateUpdate(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo, sSendFlag, sSeq); + } + } + + /// + /// 데이터 조회 + /// + /// + /// + public Hashtable GetBarcodeSucessRateData(ref DataTable dtReturn) + { + Hashtable htReturn = null; + string sQuery = string.Empty; + + DataTable dtTempReturn = null; + try + { + ///////////////////////////////////////////////////////////////// + /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! + ///////////////////////////////////////////////////////////////// + + sQuery += "SELECT TOP 1 "; + sQuery += " CMP_CD,SALE_DT,STOR_CD,POS_NO,REG_NO,SEQ,BAR_CD,SUCESS_YN,SEND_YN,UPD_DATE,REG_DATE "; + sQuery += " FROM POSLOG.dbo.TR_BAR_SUCESS_RATE "; + sQuery += " WHERE SEND_YN <> '1' "; + sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "' "; + sQuery += " ORDER BY SEND_YN ASC "; + + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn.Rows.Count == 1) + { + DataRow drTempReturn = dtTempReturn.Rows[0]; + + htReturn = MakeBarcodeSucessRateJsonData(drTempReturn); + } + } + + dtReturn = dtTempReturn; + } + 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 htReturn; + } + + /// + /// 전문 생성 + /// + /// + /// + private Hashtable MakeBarcodeSucessRateJsonData(DataRow drData) + { + Hashtable htData = new Hashtable(); + + try + { + ///////////////////////////////////////////////////////////////// + /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! + ///////////////////////////////////////////////////////////////// + + // 전문 생성 + for (int iRow = 0; iRow < drData.Table.Columns.Count; iRow++) + { + htData.Add(drData.Table.Columns[iRow].ColumnName, drData[iRow].ToString()); + } + + } + 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 htData; + } + + /// + /// 디비 업데이트 + /// + /// + /// + /// + /// + /// + /// + private int BarcodeSucessRateUpdate(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo, string sSendFlag, string sSeq) + { + int iRet = UserCom.NG; + string sQuery = string.Empty; + try + { + if (sCmpCd.Trim() == "" || sSaleDt.Trim() == "" || sStorCd.Trim() == "" || sPosNo.Trim() == "" || sTradeNo.Trim() == "") return iRet; + + sQuery += "UPDATE POSLOG.dbo.TR_BAR_SUCESS_RATE "; + sQuery += " SET SEND_YN = '" + sSendFlag + "' "; + sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; + sQuery += " AND SALE_DT = '" + sSaleDt + "' "; + sQuery += " AND STOR_CD = '" + sStorCd + "' "; + sQuery += " AND POS_NO = '" + sPosNo + "' "; + sQuery += " AND REG_NO = '" + sTradeNo + "' "; + sQuery += " AND SEQ = '" + sSeq + "' "; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); + } + 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 iRet; + } + + #endregion 16 - 유통기한 바코드 인식률 + //#20171120 유통기한 바코드 인식률 end, phj + + + //#20180322 휴게소pos매출연동 start,phj + #region 17 - 휴게소pos매출연동 대상거래 조회 + private void GetRestAreaTranInfo(ref DataTable dtReturn) + { + string sQuery = string.Empty; + DataTable dtTempReturn = null; + + try + { + sQuery = " SELECT TOP 1 \n" + + + //20180404 도로공사 재전송 기능을 제외한 기본 스레드 동작에서는 영업일자 기준으로 동작하지 않도록 수정 start, phj + //기본 + //+ " CMP_CD, SALE_DT, STOR_CD, POS_NO, TRADE_NO \n" + //변경 + + " CMP_CD, SALE_DT, STOR_CD, POS_NO, TRADE_NO, OUT_SEND_YN \n" + //20180404 도로공사 재전송 기능을 제외한 기본 스레드 동작에서는 영업일자 기준으로 동작하지 않도록 수정 end, phj + + + " FROM POSLOG..TR_SALE_HEADER \n" + + " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' \n" + + " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' \n" + + " AND TRADE_KINDPER IN ('00','20','21','42') \n" + + " AND OUT_SEND_YN <> '8' \n" + + " AND TRAIN_MODE_YN = '0' \n" + + " ORDER BY SALE_DT desc, TRADE_NO desc, OUT_SEND_YN \n"; + + sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn); + + dtReturn = dtTempReturn; + } + 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); + } + } + #endregion 17 - 휴게소pos매출연동 + //#20180322 휴게소pos매출연동 end,phj + + //#20180322 휴게소pos매출연동 start,phj + #region 17 - 휴게소pos매출연동 + public void MakeTranToRestArea() + { + bool bRet = false; + string sendFlag = string.Empty; + // 빌정보 + string sCmpCd = string.Empty; + string sSaleDt = string.Empty; + string sStorCd = string.Empty; + string sPosNo = string.Empty; + string sTradeNo = string.Empty; + + //20180404 도로공사 재전송 기능을 제외한 기본 스레드 동작에서는 영업일자 기준으로 동작하지 않도록 수정 start, phj + string sOutSendYN = string.Empty; + //20180404 도로공사 재전송 기능을 제외한 기본 스레드 동작에서는 영업일자 기준으로 동작하지 않도록 수정 end, phj + + // 텍스트 파일 생성 + string sFilename = string.Empty; + string sFileFullname = string.Empty; + string sPath = string.Empty; + // JSON 생성 + string sJsonData = string.Empty; + + DataTable dtReturn = null; + try + { + // 전송할 데이터 조회 + GetRestAreaTranInfo(ref dtReturn); + + if (dtReturn == null || dtReturn.Rows.Count == 0) + { + return; + } + else + { + iSendDataCnt += 1; + } + + // 0:미전송, 8:파일생성, 9:에러 + sendFlag = "0"; + + DataRow dr = dtReturn.Rows[0]; + + sCmpCd = CmUtil.GetDataRowStr(dr, "CMP_CD"); + sSaleDt = CmUtil.GetDataRowStr(dr, "SALE_DT"); + sStorCd = CmUtil.GetDataRowStr(dr, "STOR_CD"); + sPosNo = CmUtil.GetDataRowStr(dr, "POS_NO"); + sTradeNo = CmUtil.GetDataRowStr(dr, "TRADE_NO"); + + + //20180404 도로공사 재전송 기능을 제외한 기본 스레드 동작에서는 영업일자 기준으로 동작하지 않도록 수정 start, phj + sOutSendYN = CmUtil.GetDataRowStr(dr, "OUT_SEND_YN"); + + + if ((CmUtil.LongParse(sSaleDt) < CmUtil.LongParse(m_cPosStatus.Base.SaleDate)) && sOutSendYN != "R") + { + //20180403 영업일자보다 크거나 같거나 스레드 동작하도록 추가수정 + return; + } + //20180404 도로공사 재전송 기능을 제외한 기본 스레드 동작에서는 영업일자 기준으로 동작하지 않도록 수정 end, phj + + + Hashtable htData = null; + htData = new Hashtable(); + htData.Clear(); + bRet = MakeTrSendData(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo, ref htData); + + if (bRet == false) + { + sendFlag = "9"; + return; + } + else + { + // JSON 생성 + m_cDataCommon.HashToJsonString(htData, ref sJsonData); + + //S+영업일자(YYMMDD)+운영업체코드(3자리)+휴게소코드(7자리)+포스그룹코드(2자리)+POS번호(4자리)+영수증번호(8자리).dat + sFilename = string.Format("{0}{1}{2}{3}{4}{5}{6}.dat" + , ItemConst.ROAD_SAVE_TYPE.SALE + , sSaleDt.Substring(2, 6).Trim() //영업일자(YYMMDD) + , m_cPosStatus.RestAreaPos.RestAreaPosGroupCd.PadLeft(3, '0').Trim() //운영업체코드(3자리) + , m_cPosStatus.RestAreaPos.RestAreaPosCd.PadLeft(7, '0').Trim() //휴게소코드(7자리) + , m_cPosStatus.RestAreaPos.RestAreaPosPosGroupCd.PadLeft(2, '0').Trim() //포스그룹코드(2자리) + , m_cPosStatus.RestAreaPos.RestAreaPosPosNo.PadLeft(4, '0').Trim() //POS번호(4자리) + , sTradeNo.PadLeft(8, '0')); //영수증번호(8자리) + + + //#20180410 휴게소매출 경로 없을 경우 자동생성 안함 start,phj + if (m_cPosStatus.RestAreaPos.RestAreaPosDir == "") + { + m_cPosStatus.RestAreaPos.RestAreaPosDir = @"C:\eRest_SPC\Sals\"; + } + //#20180410 휴게소매출 경로 없을 경우 자동생성 안함 end,phj + + sPath = m_cPosStatus.RestAreaPos.RestAreaPosDir; + sFileFullname = sPath + sFilename; + + //if (m_cDataCommon.SaveRoadJson(ItemConst.ROAD_SAVE_TYPE.SALE, dFilename, sJsonData).Equals(UserCom.RST_OK)) + if (CmUtil.WriteTextFile(sFileFullname, sJsonData) == true) + { + //CmUtil.FileCopy(sFilename, dFilename, false); + sendFlag = "8"; + } + else + { + sendFlag = "9"; + + 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 (함수명)) + "도로공사 Hi-쉼마루 파일 생성 오류 -> " + sFileFullname); + } + } + } + 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 (함수명)) + "도로공사 Hi-쉼마루 파일 생성 오류 -> " + sFileFullname + " : " + ex.Message); + sendFlag = "9"; + } + finally + { + // Flag Update + OutsideTranSendFlgUpdate(sCmpCd, sStorCd, sPosNo, sSaleDt, sTradeNo, sendFlag); + } + } + #endregion 17 - 휴게소pos매출연동 + //#20180322 휴게소pos매출연동 end,phj + + //#20180322 휴게소pos매출연동 start,phj + #region 17 - 휴게소 포스에 보낼 데이터 조립 + private bool MakeTrSendData(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo, ref Hashtable htSendData) + { + bool bRet = false; + + Hashtable htData = null; + htData = new Hashtable(); + htData.Clear(); + + try + { + Hashtable ht_Header = null; + ht_Header = new Hashtable(); + ht_Header.Clear(); + bRet = MakeSaleHDData(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo, ref ht_Header); + if (bRet == false) + { + return bRet; + } + + + ArrayList Al_Detail = null; + Al_Detail = new ArrayList(); + Al_Detail.Clear(); + bRet = MakeSaleDTData(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo, ref Al_Detail); + if (bRet == false) + { + return bRet; + } + + ArrayList Al_Paylist = null; + Al_Paylist = new ArrayList(); + Al_Paylist.Clear(); + bRet = MakePaymentData(sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo, ref Al_Paylist); + if (bRet == false) + { + return bRet; + } + + // JSON 생성 + if (ht_Header.Count > 0) htData.Add(Column.RESTAREA_SALE_HD.ITEM, ht_Header); + if (Al_Detail.Count > 0) htData.Add(Column.RESTAREA_SALE_DT.ITEM, Al_Detail); + if (Al_Paylist.Count > 0) htData.Add(Column.RESTAREA_SALE_SP.ITEM, Al_Paylist); + + htSendData = htData; + + bRet = true; + } + 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 (함수명)) + "도로공사 Hi-쉼마루 SEND DATA -> " + ex.Message); + + } + + //return htData; + return bRet; + } + #endregion 17 - 휴게소 포스에 보낼 데이터 조립 + //#20180322 휴게소pos매출연동 end,phj + + //#20180322 휴게소pos매출연동 start,phj + #region 결제조회 + private bool MakePaymentData(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo, ref ArrayList AlSaleSPData) + { + bool bRet = false; + string sQuery = string.Empty; + string sSelQuery = string.Empty; + + DataTable dtReturn = new DataTable(); + StringBuilder sb = new StringBuilder(); + + Column.RESTAREA_SALE_SP.RESTAREA_PAY_CASH.DATA Pay_Cash = null; + Column.RESTAREA_SALE_SP.RESTAREA_PAY_CARD.DATA Pay_Card = null; + + Pay_Cash = new Column.RESTAREA_SALE_SP.RESTAREA_PAY_CASH.DATA(); + Pay_Card = new Column.RESTAREA_SALE_SP.RESTAREA_PAY_CARD.DATA(); + + ArrayList al_Payment = null; + al_Payment = new ArrayList(); + al_Payment.Clear(); + + try + { + #region 카드결제조회 + + sQuery = ""; + sSelQuery = ""; + + + //PCKR 02 00 신용카드 + //PCKR 04 02 삼성포인트사용 + //PCKR 04 06 신한포인트사용 + //PCKR 04 07 현대M포인트사용 + //PCKR 07 00 알리페이 + //PCKR 07 01 WechatPay + //PCKR 07 02 스마일페이 + //PCKR 07 03 T-PAY + //PCKR 09 00 T-MONEY + //PCKR 09 01 캐시비 + //PCKR 10 02 해피기프트카드 (신) + + sSelQuery = "SELECT '01' AS SLIP_FG \n" + + " ,ROUND ( CONVERT(VARCHAR, ISNULL(A.PAY_AMT, 0)) ,0) AS APPR_AMT \n" + + " ,A.OCCUR_ENTRY_11 AS PURCHASE_CD \n" + + " ,A.OCCUR_ENTRY_12 AS PURCHASE_CO_NM \n" + + " ,A.OCCUR_ENTRY_02 AS APPR_NO \n" + + " ,'20' + A.OCCUR_ENTRY_03 AS APPR_DAY \n" + + " ,A.OCCUR_ENTRY_04 + '00' AS APPR_TIME \n" + + " ,'0' AS CARD_GB \n" + + //#20180406 도로공사 수정 start + //DDC_GB : 구분되는 값 없을경우 0으로 전송 + //기존 + //" ,'1' AS DDC_GB \n" + + //변경 + " ,'0' AS DDC_GB \n" + + //#20180406 도로공사 수정 end + " ,'' AS STD_CARD_CORD_CD \n" + + " ,'32' AS VAN_CD \n" + + " ,SUBSTRING(A.OCCUR_ENTRY_01,1,6) AS CARD_NO \n" + + " FROM POSLOG..TR_SALE_PAY A \n" + + " , POSLOG..TR_SALE_HEADER B \n" + + " WHERE A.CMP_CD = '{0}' \n" + + " AND A.SALE_DT = '{1}' \n" + + " AND A.STOR_CD = '{2}' \n" + + " AND A.POS_NO = '{3}' \n" + + " AND A.TRADE_NO = '{4}' \n" + + + //2018-04-03 카드기준 추가 + //기존 + //" AND A.PAY_WAY_CD = '02' \n" + + //변경 + " AND A.PAY_WAY_CD + A.PAY_DTL_CD_01 IN ('0200','0402','0406','0407','0700','0701','0702','0703','0900','0901','1002') \n" + + + " AND A.PAY_DTL_CD_05 = '1' \n" + + " AND A.CANCEL_DIV = '0' \n" + + " AND A.CMP_CD = B.CMP_CD \n" + + " AND A.SALE_DT = B.SALE_DT \n" + + " AND A.STOR_CD = B.STOR_CD \n" + + " AND A.POS_NO = B.POS_NO \n" + + " AND A.TRADE_NO = B.TRADE_NO \n" + + " AND B.TRAIN_MODE_YN = '0' \n" + + " AND B.TRADE_KINDPER IN ('00','20','21','42') \n"; + + dtReturn = null; + sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); + + if (dtReturn != null && dtReturn.Rows.Count != 0) + { + foreach (DataRow dr in dtReturn.Rows) + { + Hashtable ht_PAY_CARD = new Hashtable(); + + ht_PAY_CARD.Add(Pay_Card.SLIP_FG, CmUtil.GetDataRowStr(dr, "SLIP_FG")); + ht_PAY_CARD.Add(Pay_Card.APPR_AMT, CmUtil.GetDataRowStr(dr, "APPR_AMT")); + ht_PAY_CARD.Add(Pay_Card.PURCHASE_CD, CmUtil.GetDataRowStr(dr, "PURCHASE_CD")); + ht_PAY_CARD.Add(Pay_Card.PURCHASE_CO_NM, CmUtil.GetDataRowStr(dr, "PURCHASE_CO_NM")); + ht_PAY_CARD.Add(Pay_Card.APPR_NO, CmUtil.GetDataRowStr(dr, "APPR_NO")); + ht_PAY_CARD.Add(Pay_Card.APPR_DAY, CmUtil.GetDataRowStr(dr, "APPR_DAY")); + ht_PAY_CARD.Add(Pay_Card.APPR_TIME, CmUtil.GetDataRowStr(dr, "APPR_TIME")); + ht_PAY_CARD.Add(Pay_Card.CARD_GB, CmUtil.GetDataRowStr(dr, "CARD_GB")); + ht_PAY_CARD.Add(Pay_Card.DDC_GB, CmUtil.GetDataRowStr(dr, "DDC_GB")); + ht_PAY_CARD.Add(Pay_Card.STD_CARD_CORD_CD, CmUtil.GetDataRowStr(dr, "STD_CARD_CORD_CD")); + ht_PAY_CARD.Add(Pay_Card.VAN_CD, CmUtil.GetDataRowStr(dr, "VAN_CD")); + + al_Payment.Add(ht_PAY_CARD); + ht_PAY_CARD = null; + } + } + + #endregion 카드결제조회 + + + #region 현금승인결제조회 + + //카드 제외한 나머지 결제 금액 - 현금 승인 금액 뺀 거 + sQuery = ""; + sSelQuery = ""; + sSelQuery = " SELECT A.* , ROUND (ISNULL(A.APPR_AMT, 0) - ISNULL(A.ETC_AMT, 0),0) AS RESULT_AMT \n " + + " FROM \n " + + " ( \n " + + //2018-04-03 카드기준 추가 + //기존 + //" SELECT ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 <> '0200' THEN \n " + + //" ISNULL(TSP.AMT_ENTRY_01, 0) - ISNULL(TSP.AMT_ENTRY_02, 0) \n " + + //" ELSE 0 END),0) AS APPR_AMT ,\n " + + + //변경 + " SELECT ROUND (ISNULL(TSP.AMT_ENTRY_01, 0) - ISNULL(TSP.AMT_ENTRY_02, 0) ,0) AS APPR_AMT,\n " + + + " '02' AS SLIP_FG,\n " + + " '00' AS PROC_TYPE,\n " + + " '' AS APPR_NO,\n " + + " '' AS APPR_DAY,\n " + + " '' AS APPR_TYPE,\n " + + " '32' AS VAN_CD, \n" + + " ( SELECT ROUND (CONVERT(VARCHAR, ISNULL(TSE.ETC_AMT, 0)) ,0) AS APPR_AMT \n " + + " FROM POSLOG..TR_SALE_ETC TSE \n " + + " WHERE TSE.CMP_CD = '{0}' \n " + + " AND TSE.SALE_DT = '{1}' \n " + + " AND TSE.STOR_CD = '{2}' \n " + + " AND TSE.POS_NO = '{3}' \n " + + " AND TSE.TRADE_NO = '{4}' \n " + + " AND TSE.ETC_WAY_CD = '80' \n " + + " AND TSE.ETC_DTL_CD_01 = '00' \n " + + " AND TSE.CANCEL_DIV = '0') AS ETC_AMT \n " + + " FROM POSLOG..TR_SALE_HEADER TSH LEFT JOIN POSLOG..TR_SALE_PAY TSP \n " + + " ON TSH.CMP_CD = TSP.CMP_CD \n " + + " AND TSH.SALE_DT = TSP.SALE_DT \n " + + " AND TSH.STOR_CD = TSP.STOR_CD \n " + + " AND TSH.POS_NO = TSP.POS_NO \n " + + " AND TSH.TRADE_NO = TSP.TRADE_NO \n " + + + //2018-04-03 카드기준 추가 + //추가 + " AND TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 NOT IN ('0200','0402','0406','0407','0700','0701','0702','0703','0900','0901','1002') \n" + + + + + " AND TSP.PAY_DTL_CD_05 = '1' \n " + + " AND TSP.CANCEL_DIV = '0' \n " + + " WHERE TSH.CMP_CD = '{0}' \n " + + " AND TSH.SALE_DT = '{1}' \n " + + " AND TSH.STOR_CD = '{2}' \n " + + " AND TSH.POS_NO = '{3}' \n " + + " AND TSH.TRADE_NO = '{4}' \n " + + " AND TSH.TRAIN_MODE_YN = '0' \n " + + " AND TSH.TRADE_KINDPER IN ('00','20','21','42') \n " + + " ) A \n " ; + + dtReturn = null; + sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); + + if (dtReturn != null && dtReturn.Rows.Count != 0) + { + DataRow dr = dtReturn.Rows[0]; + // 결제 금액 전체를 현금영수증 승인했을 때는 생성하지 않도록 한다. + if (CmUtil.GetDataRowStr(dr, "RESULT_AMT") != "0") + { + Hashtable ht_PAY_CASH = new Hashtable(); + ht_PAY_CASH.Add(Pay_Cash.SLIP_FG, CmUtil.GetDataRowStr(dr, "SLIP_FG")); + ht_PAY_CASH.Add(Pay_Cash.PROC_TYPE, CmUtil.GetDataRowStr(dr, "PROC_TYPE")); + // 전체결제 금액 - 카드결제금액 - 현금영수증 승인금액 + ht_PAY_CASH.Add(Pay_Cash.APPR_AMT, CmUtil.GetDataRowStr(dr, "RESULT_AMT")); + ht_PAY_CASH.Add(Pay_Cash.APPR_NO, CmUtil.GetDataRowStr(dr, "APPR_NO")); + ht_PAY_CASH.Add(Pay_Cash.APPR_DAY, CmUtil.GetDataRowStr(dr, "APPR_DAY")); + ht_PAY_CASH.Add(Pay_Cash.APPR_TIME, CmUtil.GetDataRowStr(dr, "APPR_TIME")); + ht_PAY_CASH.Add(Pay_Cash.VAN_CD, CmUtil.GetDataRowStr(dr, "VAN_CD")); + al_Payment.Add(ht_PAY_CASH); + ht_PAY_CASH = null; + } + } + + + + sQuery = ""; + sSelQuery = ""; + sSelQuery = "SELECT '02' AS SLIP_FG \n " + + " , '00' AS PROC_TYPE \n " + + " , ROUND ( CONVERT(VARCHAR, ISNULL(A.ETC_AMT, 0)) ,0) AS APPR_AMT \n " + + " , A.OCCUR_ENTRY_02 AS APPR_NO \n " + + " , '20' + A.OCCUR_ENTRY_03 AS APPR_DAY \n " + + " , A.OCCUR_ENTRY_04 + '00' AS APPR_TIME \n " + + " , '32' AS VAN_CD \n " + + " , (CASE WHEN A.OCCUR_ENTRY_10 = '1' THEN '0' \n " + + " ELSE CASE WHEN A.OCCUR_ENTRY_11 = '0' THEN '1' \n " + + " ELSE '2' END \n " + + " END) AS APPR_TYPE \n " + + " FROM POSLOG..TR_SALE_ETC A \n " + + " , POSLOG..TR_SALE_HEADER B \n " + + " WHERE A.CMP_CD = '{0}' \n " + + " AND A.SALE_DT = '{1}' \n " + + " AND A.STOR_CD = '{2}' \n " + + " AND A.POS_NO = '{3}' \n " + + " AND A.TRADE_NO = '{4}' \n " + + " AND A.ETC_WAY_CD = '80' \n " + + " AND A.ETC_DTL_CD_01 = '00' \n " + + " AND A.CMP_CD = B.CMP_CD \n " + + " AND A.STOR_CD = B.STOR_CD \n " + + " AND A.SALE_DT = B.SALE_DT \n " + + " AND A.POS_NO = B.POS_NO \n " + + " AND A.TRADE_NO = B.TRADE_NO \n " + + " AND B.TRAIN_MODE_YN = '0' \n " + + " AND B.TRADE_KINDPER IN ('00','20','21','42') \n "; + + dtReturn = null; + sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); + + if (dtReturn != null && dtReturn.Rows.Count != 0) + { + //foreach (DataRow dr in dtReturn.Rows) + //{ + + DataRow dr = dtReturn.Rows[0]; + + Hashtable ht_PAY_CASH = new Hashtable(); + ht_PAY_CASH.Add(Pay_Cash.SLIP_FG, CmUtil.GetDataRowStr(dr, "SLIP_FG")); + //"00" : 현금, "01" : 상품권, "02" : 모바일쿠폰, "03" : 나이스선불카드, "04" : 마이탐 선불카드 + ht_PAY_CASH.Add(Pay_Cash.PROC_TYPE, CmUtil.GetDataRowStr(dr, "PROC_TYPE")); + ht_PAY_CASH.Add(Pay_Cash.APPR_AMT, CmUtil.GetDataRowStr(dr, "APPR_AMT")); + ht_PAY_CASH.Add(Pay_Cash.APPR_NO, CmUtil.GetDataRowStr(dr, "APPR_NO")); + ht_PAY_CASH.Add(Pay_Cash.APPR_DAY, CmUtil.GetDataRowStr(dr, "APPR_DAY")); + ht_PAY_CASH.Add(Pay_Cash.APPR_TIME, CmUtil.GetDataRowStr(dr, "APPR_TIME")); + ht_PAY_CASH.Add(Pay_Cash.VAN_CD, CmUtil.GetDataRowStr(dr, "VAN_CD")); + al_Payment.Add(ht_PAY_CASH); + ht_PAY_CASH = null; + //} + } + #endregion 현금승인결제조회 + + AlSaleSPData = al_Payment; + + bRet = true; + + } + 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 (함수명)) + "도로공사 Hi-쉼마루 SaleSP -> " + sQuery + " : " + ex.Message); + + bRet = false; + } + + return bRet; + } + #endregion + //#20180322 휴게소pos매출연동 end,phj + + //#20180322 휴게소pos매출연동 start,phj + #region 상세조회 + private bool MakeSaleDTData(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo, ref ArrayList AlSaleDTData) + { + bool bRet = false; + string sQuery = string.Empty; + string sSelQuery = string.Empty; + + DataTable dtReturn = new DataTable(); + StringBuilder sb = new StringBuilder(); + + Column.RESTAREA_SALE_DT.DATA RESTAREA_SALE_DT = null; + RESTAREA_SALE_DT = new Column.RESTAREA_SALE_DT.DATA(); + + ArrayList al_SaleDT = null; + al_SaleDT = new ArrayList(); + al_SaleDT.Clear(); + + try + { + #region SALE_DT + + sQuery = ""; + sSelQuery = ""; + //#20180406 도로공사 수정 start + //LINE_NO : 1자리일 경우 앞에 0채워서 2자리로 생성 + //기존 + //sSelQuery = "SELECT CONVERT(VARCHAR, A.SEQ) AS LINE_NO \n " + //변경 + sSelQuery = "SELECT REPLICATE('0', 2 - LEN(CONVERT(VARCHAR, A.SEQ))) + CONVERT(VARCHAR, A.SEQ) AS LINE_NO \n " + + //#20180406 도로공사 수정 end + //" , A.STOR_CD AS SHOP_CD \n " + + " ,'" + m_cPosStatus.RestAreaPos.RestAreaPosCd.PadLeft(7, '0').Trim() + "' AS SHOP_CD \n " + + //" , CONVERT(VARCHAR, A.SEQ) AS PROD_SEQ \n " + + " , A.ITEM_PLU_CD AS PROD_SEQ \n " + + " , '' AS SOURCE_CD \n " + + " , CONVERT(VARCHAR, ISNULL(A.SALE_QTY, 0)) AS PAN_QTY \n " + + " , ROUND (CONVERT(VARCHAR, ISNULL(A.SALE_AMT, 0)) ,0) AS TOT_PAN_AMT \n " + + " , '00' AS NOZZLE_NO \n " + + " , CONVERT(VARCHAR, ISNULL(A.SALE_PRC, 0)) AS PAN_COST \n " + + " , '0' AS FEE_COST \n " + + " , '0' AS OIL_PROC_GB \n " + + " , ROUND ('0' ,0) AS PRE_PAY_AMT \n " + + " , ROUND ('0' ,0) AS FEE_AMT \n " + + " , ROUND ('0' ,0) AS SC_AMT \n " + + " , ROUND (CONVERT(VARCHAR, A.BILL_AMT) ,0) AS REAL_PAN_AMT \n " + + " , ROUND (CONVERT(VARCHAR, A.APPLY_TAX_AMT) ,0) AS VAT_AMT \n " + + " , ROUND (CONVERT(VARCHAR, ISNULL(A.BILL_AMT, 0) - ISNULL(A.APPLY_TAX_AMT, 0)) ,0) AS NET_PAN_AMT \n " + + " , '0' AS NOZZLE_END_DTIME \n " + + " , '0' AS DUTY_PAN_GB \n " + + " , ROUND (CONVERT(VARCHAR, ISNULL(A.ITEM_DC_AMT, 0) + ISNULL(A.SUM_DC_AMT, 0) + \n " + + " ISNULL(A.CPI_DC_AMT, 0) + ISNULL(A.COOP_CARD_DC_AMT, 0) + \n " + + " ISNULL(A.POINT_DC_AMT, 0) + ISNULL(A.CPN_DC_AMT, 0) + \n " + + " ISNULL(A.EMP_DC_AMT, 0) + ISNULL(A.SET_DC_AMT, 0) + \n " + + " ISNULL(A.ETC_DC_AMT, 0) + ISNULL(A.EXCEP_DC_AMT, 0)) ,0) AS DC_AMT \n " + + //" , ROUND ('0' ,0) AS NORM_DC_AMT \n " + + " , ROUND (CONVERT(VARCHAR, ISNULL(A.ITEM_DC_AMT, 0) + ISNULL(A.SUM_DC_AMT, 0) + \n " + + " ISNULL(A.CPI_DC_AMT, 0) + ISNULL(A.COOP_CARD_DC_AMT, 0) + \n " + + " ISNULL(A.POINT_DC_AMT, 0) + ISNULL(A.CPN_DC_AMT, 0) + \n " + + " ISNULL(A.EMP_DC_AMT, 0) + ISNULL(A.SET_DC_AMT, 0) + \n " + + " ISNULL(A.ETC_DC_AMT, 0) + ISNULL(A.EXCEP_DC_AMT, 0)) ,0) AS NORM_DC_AMT \n " + + " , ROUND ('0' ,0) AS BONUS_DC_AMT \n " + + " , ROUND ('0' ,0) AS RAND_BONUS_DC_AMT \n " + + " FROM POSLOG..TR_SALE_DETAIL A \n " + + " , POSLOG..TR_SALE_HEADER B \n " + + " WHERE A.CMP_CD = '{0}' \n " + + " AND A.SALE_DT = '{1}' \n " + + " AND A.STOR_CD = '{2}' \n " + + " AND A.POS_NO = '{3}' \n " + + " AND A.TRADE_NO = '{4}' \n " + + " AND A.CMP_CD = B.CMP_CD \n " + + " AND A.SALE_DT = B.SALE_DT \n " + + " AND A.STOR_CD = B.STOR_CD \n " + + " AND A.POS_NO = B.POS_NO \n " + + " AND A.TRADE_NO = B.TRADE_NO \n " + + " AND B.TRAIN_MODE_YN = '0' \n " + + " AND B.TRADE_KINDPER IN ('00','20','21','42') \n " + + " AND A.CANCEL_DIV = '0' \n " + + // 판매단가가 0원이 아닌 것만 보냄. + " AND A.SALE_PRC > 0 \n" + + " ORDER BY A.SEQ \n "; + + dtReturn = null; + sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); + + if (dtReturn != null && dtReturn.Rows.Count != 0) + { + foreach (DataRow dr in dtReturn.Rows) + { + Hashtable tr_SaleDT = new Hashtable(); + + tr_SaleDT.Add(RESTAREA_SALE_DT.LINE_NO, CmUtil.GetDataRowStr(dr, "LINE_NO")); + tr_SaleDT.Add(RESTAREA_SALE_DT.SHOP_CD, CmUtil.GetDataRowStr(dr, "SHOP_CD")); + tr_SaleDT.Add(RESTAREA_SALE_DT.PROD_SEQ, CmUtil.GetDataRowStr(dr, "PROD_SEQ")); + tr_SaleDT.Add(RESTAREA_SALE_DT.SOURCE_CD, CmUtil.GetDataRowStr(dr, "SOURCE_CD")); //cPluItem.ITEM_PLU_CD + tr_SaleDT.Add(RESTAREA_SALE_DT.PAN_QTY, CmUtil.GetDataRowStr(dr, "PAN_QTY")); + tr_SaleDT.Add(RESTAREA_SALE_DT.TOT_PAN_AMT, CmUtil.GetDataRowStr(dr, "TOT_PAN_AMT")); + tr_SaleDT.Add(RESTAREA_SALE_DT.NOZZLE_NO, CmUtil.GetDataRowStr(dr, "NOZZLE_NO")); + tr_SaleDT.Add(RESTAREA_SALE_DT.PAN_COST, CmUtil.GetDataRowStr(dr, "PAN_COST")); + tr_SaleDT.Add(RESTAREA_SALE_DT.FEE_COST, CmUtil.GetDataRowStr(dr, "FEE_COST")); + tr_SaleDT.Add(RESTAREA_SALE_DT.OIL_PROC_GB, CmUtil.GetDataRowStr(dr, "OIL_PROC_GB")); + tr_SaleDT.Add(RESTAREA_SALE_DT.PRE_PAY_AMT, CmUtil.GetDataRowStr(dr, "PRE_PAY_AMT")); + tr_SaleDT.Add(RESTAREA_SALE_DT.FEE_AMT, CmUtil.GetDataRowStr(dr, "FEE_AMT")); + tr_SaleDT.Add(RESTAREA_SALE_DT.SC_AMT, CmUtil.GetDataRowStr(dr, "SC_AMT")); + tr_SaleDT.Add(RESTAREA_SALE_DT.REAL_PAN_AMT, CmUtil.GetDataRowStr(dr, "REAL_PAN_AMT")); + tr_SaleDT.Add(RESTAREA_SALE_DT.VAT_AMT, CmUtil.GetDataRowStr(dr, "VAT_AMT")); + tr_SaleDT.Add(RESTAREA_SALE_DT.NET_PAN_AMT, CmUtil.GetDataRowStr(dr, "NET_PAN_AMT")); + tr_SaleDT.Add(RESTAREA_SALE_DT.NOZZLE_END_DTIME, CmUtil.GetDataRowStr(dr, "NOZZLE_END_DTIME")); + tr_SaleDT.Add(RESTAREA_SALE_DT.DUTY_PAN_GB, CmUtil.GetDataRowStr(dr, "DUTY_PAN_GB")); + tr_SaleDT.Add(RESTAREA_SALE_DT.DC_AMT, CmUtil.GetDataRowStr(dr, "DC_AMT")); + tr_SaleDT.Add(RESTAREA_SALE_DT.NORM_DC_AMT, CmUtil.GetDataRowStr(dr, "NORM_DC_AMT")); + tr_SaleDT.Add(RESTAREA_SALE_DT.BONUS_DC_AMT, CmUtil.GetDataRowStr(dr, "BONUS_DC_AMT")); + + //RAND_BONUS_DC_AMT String 14 Y 1 임의등록 보너스카드 DC 금액(미사용) + tr_SaleDT.Add(RESTAREA_SALE_DT.RAND_BONUS_DC_AMT, CmUtil.GetDataRowStr(dr, "RAND_BONUS_DC_AMT")); + + al_SaleDT.Add(tr_SaleDT); + tr_SaleDT = null; + } + } + + #endregion SALE_DT + + AlSaleDTData = al_SaleDT; + + bRet = true; + + } + 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 (함수명)) + "도로공사 Hi-쉼마루 SaleDT -> " + sQuery + " : " + ex.Message); + + bRet = false; + } + + return bRet; + } + #endregion + //#20180322 휴게소pos매출연동 end,phj + + //#20180322 휴게소pos매출연동 start,phj + #region 헤더조회 + private bool MakeSaleHDData(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sTradeNo, ref Hashtable htSaleHDData) + { + bool bRet = false; + string sQuery = string.Empty; + string sSelQuery = string.Empty; + + DataTable dtReturn = new DataTable(); + StringBuilder sb = new StringBuilder(); + + Column.RESTAREA_SALE_HD.DATA RESTAREA_SALE_HD = null; + RESTAREA_SALE_HD = new Column.RESTAREA_SALE_HD.DATA(); + + + Hashtable ht_SaleHD = null; + ht_SaleHD = new Hashtable(); + ht_SaleHD.Clear(); + + try + { + #region SALE_HD + + sQuery = ""; + sSelQuery = ""; + sSelQuery = "SELECT A.SALE_DT AS SALE_DAY \n " + + //#20180406 도로공사 수정 start + //BILL_NO : 앞에 0 채워서 8자리로 생성 + //기존 + //" , A.TRADE_NO AS BILL_NO \n " + + //변경 + " , REPLICATE('0', 8 - LEN(A.TRADE_NO)) + A.TRADE_NO AS BILL_NO \n " + + //#20180406 도로공사 수정 end + " , A.TRADE_DIV AS SALE_GB \n " + + " , A.SYS_DT + A.PAY_TIME AS SYS_DTIME \n " + + " , CONVERT(VARCHAR, C.TRDTL_CNT) AS DETAIL_CNT \n " + + //#20180403 도로공사 현금전표 분기에 따른 총전표건수 계산식 변경 start + //기존 + //" , CONVERT(VARCHAR, (CASE WHEN ISNULL(B.CASH_AMT,0) > 0 THEN 1 ELSE 0 END) + B.TRCRD_CNT) AS SLIP_CNT \n " + + //변경 + // 1. 현금처리 금액이 있는지 체크 + // 2. 현금처리 금액 - 현금 영수증 금액 빼서 0보다 크면 현금전표 2건 생성되고 아니면 1건 생성 + // 3. 현금처리 금액이 없으면 현금전표 0건 생성 + " , CONVERT(VARCHAR, (CASE WHEN ISNULL(B.CASH_AMT,0) = 0 THEN 0 \n " + + " ELSE ( CASE WHEN D.TRCSH_CNT = '1' THEN (CASE WHEN ISNULL(B.CASH_AMT,0) - ISNULL(D.CASH_BILL_AMT,0) > 0 THEN 2 ELSE 1 END) \n " + + " ELSE '1' \n " + + " END) \n " + + " END) + B.TRCRD_CNT) AS SLIP_CNT \n " + + //#20180403 도로공사 현금전표 분기에 따른 총전표건수 계산식 변경 end + " , ROUND (CONVERT(VARCHAR, ISNULL(A.TOTSALE_AMT, 0)),0) AS TOT_PAN_AMT \n " + + " , ROUND (CONVERT(VARCHAR, B.CASH_AMT),0) AS CASH_AMT \n " + + " , ROUND (CONVERT(VARCHAR, B.CRD_CARD_AMT),0) AS CARD_AMT \n " + + " , ROUND ('0',0) AS GIFT_AMT \n " + + " , ROUND ('0',0) AS SC_AMT \n " + + " , ROUND ('0',0) AS PRE_PAY_AMT \n " + + " , ROUND ('0',0) AS FEE_PROFIT_AMT \n " + + " , ROUND (CONVERT(VARCHAR, ISNULL(A.NET_SALE_AMT, 0)),0) AS REAL_PAN_AMT \n " + + " , ROUND (CONVERT(VARCHAR, ISNULL(A.TOT_VAT, 0)), 0) AS VAT_AMT \n " + + " , ROUND (CONVERT(VARCHAR, ISNULL(A.NET_SALE_AMT, 0) - ISNULL(A.TOT_VAT, 0)),0) AS NET_PAN_AMT \n " + + " , ROUND (CONVERT(VARCHAR, D.TRCSH_CNT),0) AS CASH_BILL_GB \n " + + " , CASE WHEN TRADE_DIV = '1' THEN \n " + + //#20180406 도로공사 수정 start + //ORB_BILL_NO : 년도 YYYY형식으로 수정, 빌번호 8자리 + //기존 + //" (SUBSTRING(A.ORG_BILLDT,3,6) + \n " + + //변경 + " (A.ORG_BILLDT + \n " + + //#20180406 도로공사 수정 end + //" '000' + \n " + + " '" + m_cPosStatus.RestAreaPos.RestAreaPosGroupCd.PadLeft(3, '0').Trim() + "' + \n " + + //" SUBSTRING(A.STOR_CD, 2, 6) + \n " + 기존6자리에서 7자리로 늘임 + //" SUBSTRING(A.STOR_CD, 1, 7) + \n " + + " '" + m_cPosStatus.RestAreaPos.RestAreaPosCd.PadLeft(7, '0').Trim() + "' + \n " + + //" '00' + \n " + + " '" + m_cPosStatus.RestAreaPos.RestAreaPosPosGroupCd.PadLeft(2, '0').Trim() + "' + \n " + + //" REPLICATE('0', 4 - LEN(A.ORG_BILL_POSNO)) + A.ORG_BILL_POSNO + \n " + + " REPLICATE('0', 4 - LEN('" + m_cPosStatus.RestAreaPos.RestAreaPosPosNo.PadLeft(4, '0').Trim() + "')) + '" + m_cPosStatus.RestAreaPos.RestAreaPosPosNo.PadLeft(4, '0').Trim() + "' + \n " + + " REPLICATE('0', 8 - LEN(A.ORG_BILL_NO)) + A.ORG_BILL_NO) \n " + + " ELSE '' END AS ORG_BILL_NO \n " + + " , '' AS EMP_ID \n " + + " , '' AS OIL_PROC_CB \n " + + " , ROUND ('0',0) AS BONUS_USE_AMT \n " + + " , ROUND (CONVERT(VARCHAR, A.TOTDC_AMT),0) AS DC_AMT \n " + + //" , ROUND ('0',0) AS NORM_DC_AMT \n " + + " , ROUND (CONVERT(VARCHAR, A.TOTDC_AMT),0) AS NORM_DC_AMT \n " + + " , ROUND ('0',0) AS BONUS_DC_AMT \n " + + " , ROUND ('0',0) AS RAND_BONUS_DC_AMT \n " + + " FROM POSLOG..TR_SALE_HEADER A \n " + + " , ( \n " + + + + //2018-04-03 카드기준 추가 + //기존 + //" SELECT ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 <> '0200' \n " + + //" THEN ISNULL(TSP.AMT_ENTRY_01, 0) - ISNULL(TSP.AMT_ENTRY_02, 0) \n " + + //" ELSE 0 \n " + + //" END),0) AS CASH_AMT \n " + + //" , ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 = '0200' \n " + + //" THEN 1 \n " + + //" ELSE 0 \n " + + //" END),0) AS TRCRD_CNT \n " + + //" , ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 = '0200' \n " + + //" THEN ISNULL(TSP.AMT_ENTRY_01, 0) \n " + + //" ELSE 0 \n " + + //" END),0) AS CRD_CARD_AMT \n " + + //변경 + " SELECT ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 NOT IN ('0200','0402','0406','0407','0700','0701','0702','0703','0900','0901','1002') \n " + + " THEN ISNULL(TSP.AMT_ENTRY_01, 0) - ISNULL(TSP.AMT_ENTRY_02, 0) \n " + + " ELSE 0 \n " + + " END),0) AS CASH_AMT \n " + + + + + //2018-04-03 카드기준 추가 + //기존 + //" , ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 = '0200' \n " + + //" THEN 1 \n " + + //" ELSE 0 \n " + + //" END),0) AS TRCRD_CNT \n " + + //변경 + " , ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 IN ('0200','0402','0406','0407','0700','0701','0702','0703','0900','0901','1002') \n " + + " THEN 1 \n " + + " ELSE 0 \n " + + " END),0) AS TRCRD_CNT \n " + + + //2018-04-03 카드기준 추가 + //기존 + //" , ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 = '0200' \n " + + //" THEN ISNULL(TSP.AMT_ENTRY_01, 0) \n " + + //" ELSE 0 \n " + + //" END),0) AS CRD_CARD_AMT \n " + + //변경 + " , ROUND (SUM(CASE WHEN TSP.PAY_WAY_CD + TSP.PAY_DTL_CD_01 IN ('0200','0402','0406','0407','0700','0701','0702','0703','0900','0901','1002') \n " + + " THEN ISNULL(TSP.AMT_ENTRY_01, 0) \n " + + " ELSE 0 \n " + + " END),0) AS CRD_CARD_AMT \n " + + + + " , ROUND (SUM(ISNULL(TSP.PAY_AMT, 0)),0) AS GST_PAY_AMT \n " + + " , ROUND (SUM(ISNULL(TSP.AMT_ENTRY_02, 0)),0) AS RET_PAY_AMT \n " + + " , ROUND (0,0) AS REPAY_CASH_AMT \n " + + " FROM POSLOG..TR_SALE_HEADER TSH \n " + + " LEFT JOIN POSLOG..TR_SALE_PAY TSP \n " + + " ON TSH.CMP_CD = TSP.CMP_CD \n " + + " AND TSH.SALE_DT = TSP.SALE_DT \n " + + " AND TSH.STOR_CD = TSP.STOR_CD \n " + + " AND TSH.POS_NO = TSP.POS_NO \n " + + " AND TSH.TRADE_NO = TSP.TRADE_NO \n " + + " AND TSP.PAY_DTL_CD_05 = '1' \n " + + " AND TSP.CANCEL_DIV = '0' \n " + + " WHERE TSH.CMP_CD = '{0}' \n " + + " AND TSH.SALE_DT = '{1}' \n " + + " AND TSH.STOR_CD = '{2}' \n " + + " AND TSH.POS_NO = '{3}' \n " + + " AND TSH.TRADE_NO = '{4}' \n " + + " AND TSH.TRAIN_MODE_YN = '0' \n " + + " AND TSH.TRADE_KINDPER IN ('00','20','21','42') \n " + + " ) B \n " + + " , ( \n " + + " SELECT SUM(CASE WHEN ISNULL(TSD.SALE_AMT, 0) = 0 \n " + + " THEN 0 \n " + + " ELSE 1 \n " + + " END) AS TRDTL_CNT \n " + + " , ROUND (SUM(CASE WHEN ISNULL(TSD.APPLY_TAX_AMT, 0) = 0 \n " + + " THEN 0 \n " + + " ELSE ISNULL(TSD.BILL_AMT, 0) - ISNULL(TSD.APPLY_TAX_AMT, 0) \n " + + " END),0) AS VAT_SALE_AMT \n " + + " , ROUND (SUM(CASE WHEN ISNULL(TSD.APPLY_TAX_AMT, 0) = 0 \n " + + " THEN ISNULL(TSD.SALE_AMT, 0) \n " + + " ELSE 0 \n " + + " END),0) AS NO_VAT_SALE_AMT \n " + + " FROM POSLOG..TR_SALE_HEADER TSH \n " + + " LEFT JOIN POSLOG..TR_SALE_DETAIL TSD \n " + + " ON TSH.CMP_CD = TSD.CMP_CD \n " + + " AND TSH.SALE_DT = TSD.SALE_DT \n " + + " AND TSH.STOR_CD = TSD.STOR_CD \n " + + " AND TSH.POS_NO = TSD.POS_NO \n " + + " AND TSH.TRADE_NO = TSD.TRADE_NO \n " + + " AND TSD.CANCEL_DIV = '0' \n " + + " WHERE TSH.CMP_CD = '{0}' \n " + + " AND TSH.SALE_DT = '{1}' \n " + + " AND TSH.STOR_CD = '{2}' \n " + + " AND TSH.POS_NO = '{3}' \n " + + " AND TSH.TRADE_NO = '{4}' \n " + + " AND TSH.TRAIN_MODE_YN = '0' \n " + + " AND TSH.TRADE_KINDPER IN ('00','20','21','42') \n " + + " ) C \n " + + " , ( \n " + + " SELECT SUM(CASE WHEN TSE.ETC_DTL_CD_01 = '00' \n " + + " THEN 1 \n " + + " ELSE 0 \n " + + " END) AS TRCSH_CNT \n " + + " , ISNULL(SUM(TSE.ETC_AMT), 0) AS CASH_BILL_AMT \n " + + " FROM POSLOG..TR_SALE_HEADER TSH \n " + + " LEFT JOIN POSLOG..TR_SALE_ETC TSE \n " + + " ON TSH.CMP_CD = TSE.CMP_CD \n " + + " AND TSH.SALE_DT = TSE.SALE_DT \n " + + " AND TSH.STOR_CD = TSE.STOR_CD \n " + + " AND TSH.POS_NO = TSE.POS_NO \n " + + " AND TSH.TRADE_NO = TSE.TRADE_NO \n " + + " AND TSE.ETC_WAY_CD = '80' \n " + + " WHERE TSH.CMP_CD = '{0}' \n " + + " AND TSH.SALE_DT = '{1}' \n " + + " AND TSH.STOR_CD = '{2}' \n " + + " AND TSH.POS_NO = '{3}' \n " + + " AND TSH.TRADE_NO = '{4}' \n " + + " AND TSH.TRAIN_MODE_YN = '0' \n " + + " AND TSH.TRADE_KINDPER IN ('00','20','21','42') \n " + + " ) D \n " + + " WHERE A.CMP_CD = '{0}' \n " + + " AND A.SALE_DT = '{1}' \n " + + " AND A.STOR_CD = '{2}' \n " + + " AND A.POS_NO = '{3}' \n " + + " AND A.TRADE_NO = '{4}' \n " + + " AND A.TRAIN_MODE_YN = '0' \n " + + " AND A.TRADE_KINDPER IN ('00','20','21','42') \n "; + + dtReturn = null; + sQuery = string.Format(sSelQuery, sCmpCd, sSaleDt, sStorCd, sPosNo, sTradeNo); + sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtReturn); + + if (dtReturn != null && dtReturn.Rows.Count != 0) + { + DataRow dr = dtReturn.Rows[0]; + + ht_SaleHD.Add(RESTAREA_SALE_HD.SALE_DAY, CmUtil.GetDataRowStr(dr, "SALE_DAY")); + ht_SaleHD.Add(RESTAREA_SALE_HD.BILL_NO, CmUtil.GetDataRowStr(dr, "BILL_NO")); + ht_SaleHD.Add(RESTAREA_SALE_HD.SALE_GB, CmUtil.GetDataRowStr(dr, "SALE_GB")); + ht_SaleHD.Add(RESTAREA_SALE_HD.SYS_DTIME, CmUtil.GetDataRowStr(dr, "SYS_DTIME")); + ht_SaleHD.Add(RESTAREA_SALE_HD.DETAIL_CNT, CmUtil.GetDataRowStr(dr, "DETAIL_CNT")); + ht_SaleHD.Add(RESTAREA_SALE_HD.SLIP_CNT, CmUtil.GetDataRowStr(dr, "SLIP_CNT")); + ht_SaleHD.Add(RESTAREA_SALE_HD.TOT_PAN_AMT, CmUtil.GetDataRowStr(dr, "TOT_PAN_AMT")); + ht_SaleHD.Add(RESTAREA_SALE_HD.CASH_AMT, CmUtil.GetDataRowStr(dr, "CASH_AMT")); + ht_SaleHD.Add(RESTAREA_SALE_HD.CARD_AMT, CmUtil.GetDataRowStr(dr, "CARD_AMT")); + ht_SaleHD.Add(RESTAREA_SALE_HD.GIFT_AMT, CmUtil.GetDataRowStr(dr, "GIFT_AMT")); + ht_SaleHD.Add(RESTAREA_SALE_HD.SC_AMT, CmUtil.GetDataRowStr(dr, "SC_AMT")); + ht_SaleHD.Add(RESTAREA_SALE_HD.PRE_PAY_AMT, CmUtil.GetDataRowStr(dr, "PRE_PAY_AMT")); + ht_SaleHD.Add(RESTAREA_SALE_HD.FEE_PROFIT_AMT, CmUtil.GetDataRowStr(dr, "FEE_PROFIT_AMT")); + ht_SaleHD.Add(RESTAREA_SALE_HD.REAL_PAN_AMT, CmUtil.GetDataRowStr(dr, "REAL_PAN_AMT")); + ht_SaleHD.Add(RESTAREA_SALE_HD.VAT_AMT, CmUtil.GetDataRowStr(dr, "VAT_AMT")); + ht_SaleHD.Add(RESTAREA_SALE_HD.NET_PAN_AMT, CmUtil.GetDataRowStr(dr, "NET_PAN_AMT")); + ht_SaleHD.Add(RESTAREA_SALE_HD.CASH_BILL_GB, CmUtil.GetDataRowStr(dr, "CASH_BILL_GB")); + ht_SaleHD.Add(RESTAREA_SALE_HD.ORG_BILL_NO, CmUtil.GetDataRowStr(dr, "ORG_BILL_NO")); + ht_SaleHD.Add(RESTAREA_SALE_HD.EMP_ID, CmUtil.GetDataRowStr(dr, "EMP_ID")); + ht_SaleHD.Add(RESTAREA_SALE_HD.OIL_PROC_CB, CmUtil.GetDataRowStr(dr, "OIL_PROC_CB")); + ht_SaleHD.Add(RESTAREA_SALE_HD.BONUS_USE_AMT, CmUtil.GetDataRowStr(dr, "BONUS_USE_AMT")); + ht_SaleHD.Add(RESTAREA_SALE_HD.DC_AMT, CmUtil.GetDataRowStr(dr, "DC_AMT")); + ht_SaleHD.Add(RESTAREA_SALE_HD.NORM_DC_AMT, CmUtil.GetDataRowStr(dr, "NORM_DC_AMT")); + ht_SaleHD.Add(RESTAREA_SALE_HD.BONUS_DC_AMT, CmUtil.GetDataRowStr(dr, "BONUS_DC_AMT")); + ht_SaleHD.Add(RESTAREA_SALE_HD.RAND_BONUS_DC_AMT, CmUtil.GetDataRowStr(dr, "RAND_BONUS_DC_AMT")); + } + + #endregion SALE_HD + + htSaleHDData = ht_SaleHD; + + bRet = true; + } + 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 (함수명)) + "도로공사 Hi-쉼마루 SaleHD -> " + sQuery + " : " + ex.Message); + + bRet = false; + } + + return bRet; + } + #endregion + //#20180322 휴게소pos매출연동 end,phj + + //#15945 해피오더 자동주문 상세기능 start + //해피오더 자동주문 로그 전송(HPO_AUTOORDER_LOG) + public void HappyOrderAutoOrderLogSendProcess() + { + DataTable dtReturn = null; + Hashtable htData = null; + + string sSendFlag = string.Empty; + string sCmpCd = string.Empty; + string sBrandCd = string.Empty; + string sStorCd = string.Empty; + string sSaleDt = string.Empty; + string sPosNo = string.Empty; + string sStatus = string.Empty; + string sOrderNo = string.Empty; + string sOrderType = string.Empty; + + try + { + // 전송할 HPO_AUTOORDER_LOG 데이터 생성 + htData = GetHappyOrderAutoOrderLogData(ref dtReturn); + + + if (dtReturn == null || dtReturn.Rows.Count == 0) + { + return; + } + else + { + iSendDataCnt += 1; + } + + sCmpCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "CMP_CD"); + sBrandCd = m_cPosStatus.Base.BrandCd; + sSaleDt = CmUtil.GetDataRowStr(dtReturn.Rows[0], "SALE_DT"); + sStorCd = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STOR_CD"); + sPosNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "POS_NO"); + sOrderType = CmUtil.GetDataRowStr(dtReturn.Rows[0], "ORDER_TYPE"); + sOrderNo = CmUtil.GetDataRowStr(dtReturn.Rows[0], "ORDER_NO"); + sStatus = CmUtil.GetDataRowStr(dtReturn.Rows[0], "STATUS"); + + + + string sReturn = SendProcess(m_cPosStatus.Base.CommSvrIp, + Convert.ToInt32(m_cPosStatus.Base.JrnlPort), + 5000, + new string[] { sCmpCd, sBrandCd, sStorCd, sSaleDt, sPosNo, "" }, + ItemConst.COMM_MSG_TYPE.HPO_AUTOORDER_LOG, + htData); + + if (sReturn == UserCom.RST_OK) + { + sSendFlag = "1"; // 정상 전송 + + m_cPosStatus.Sale.OnLineStatus = "1"; + } + else + { + sSendFlag = "9"; // 에러 + + m_cPosStatus.Sale.OnLineStatus = "0"; + } + } + 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); + sSendFlag = "9"; + } + finally + { + // Flag Update + HappyOrderAutoOrderLogUpdate(sCmpCd, sSaleDt, sStorCd, sPosNo, sOrderNo, sStatus, sSendFlag); + } + } + + + /// + /// 데이터 조회 + /// + /// + /// + public Hashtable GetHappyOrderAutoOrderLogData(ref DataTable dtReturn) + { + Hashtable htReturn = null; + string sQuery = string.Empty; + + DataTable dtTempReturn = null; + try + { + ///////////////////////////////////////////////////////////////// + /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! + ///////////////////////////////////////////////////////////////// + + //00013523PCKR002 0000007 201808025400002201807301740181000{"ORDER_NO":"A100","STATUS":"5","PRE_STATUS":"4", "CLOUD_RES":"200", "GUBUN":"P", "CASHIER_ID":"0000007123", "REG_DATE":"201808031159"} + sQuery += "SELECT TOP 1 "; + sQuery += " CMP_CD,SALE_DT,STOR_CD,POS_NO,ORDER_NO,PRE_STATUS,STATUS,ORDER_TYPE,CLOUD_RES,GUBUN,CASHIER_ID,REG_DATE "; + sQuery += " FROM POSLOG.dbo.TR_AUTOMATICSHIPMENT_LOG "; + sQuery += " WHERE SEND_YN <> '1' "; + sQuery += " AND CMP_CD = '" + m_cPosStatus.Base.CmpCd + "' "; + sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "' "; + sQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "' "; + sQuery += " ORDER BY SEND_YN ASC "; + + if (sqlDb.DBDataTableSelect(sQuery, CommandType.Text, (SqlParameter[])null, out dtTempReturn) == UserCom.OK) + { + if (dtTempReturn.Rows.Count == 1) + { + DataRow drTempReturn = dtTempReturn.Rows[0]; + + htReturn = MakeHappyOrderAutoOrderLogJsonData(drTempReturn); + } + } + + dtReturn = dtTempReturn; + } + 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 htReturn; + } + + /// + /// 전문 생성 + /// + /// + /// + private Hashtable MakeHappyOrderAutoOrderLogJsonData(DataRow drData) + { + Hashtable htData = new Hashtable(); + + try + { + ///////////////////////////////////////////////////////////////// + /// 중요! 테이블 컬럼명 갯수와 명칭은 동일 해야함! + ///////////////////////////////////////////////////////////////// + + // 전문 생성 + for (int iRow = 0; iRow < drData.Table.Columns.Count; iRow++) + { + if (drData.Table.Columns[iRow].ColumnName == "CMP_CD" || + drData.Table.Columns[iRow].ColumnName == "SALE_DT" || + drData.Table.Columns[iRow].ColumnName == "STOR_CD" || + drData.Table.Columns[iRow].ColumnName == "POS_NO" || + drData.Table.Columns[iRow].ColumnName == "ORDER_TYPE") continue; + + htData.Add(drData.Table.Columns[iRow].ColumnName, drData[iRow].ToString()); + } + + } + 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 htData; + } + + /// + /// 디비 업데이트 + /// + /// + /// + /// + /// + /// + /// + private int HappyOrderAutoOrderLogUpdate(string sCmpCd, string sSaleDt, string sStorCd, string sPosNo, string sOrderNo, string sStatus, string sSendFlag) + { + int iRet = UserCom.NG; + string sQuery = string.Empty; + try + { + if (sCmpCd.Trim() == "" || sSaleDt.Trim() == "" || sStorCd.Trim() == "" || sPosNo.Trim() == "" || sOrderNo.Trim() == "" || sStatus.Trim() == "") return iRet; + + sQuery += "UPDATE POSLOG.dbo.TR_AUTOMATICSHIPMENT_LOG "; + sQuery += " SET SEND_YN = '" + sSendFlag + "' "; + sQuery += " , UPD_DATE = '" + DateTime.Now.ToString("yyyyMMddHHmmss") + "' "; + sQuery += " WHERE CMP_CD = '" + sCmpCd + "' "; + sQuery += " AND SALE_DT = '" + sSaleDt + "' "; + sQuery += " AND STOR_CD = '" + sStorCd + "' "; + sQuery += " AND POS_NO = '" + sPosNo + "' "; + sQuery += " AND ORDER_NO = '" + sOrderNo + "' "; + sQuery += " AND STATUS = '" + sStatus + "' "; + + iRet = sqlDb.DBExecuteNonQuery(sQuery, CommandType.Text, (SqlParameter[])null); + } + 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 iRet; + } + + //#15945 해피오더 자동주문 상세기능 end + } +} diff --git a/Agent/NetworkTranSend/NetworkTranSend.csproj b/Agent/NetworkTranSend/NetworkTranSend.csproj new file mode 100644 index 0000000..7b56ff3 --- /dev/null +++ b/Agent/NetworkTranSend/NetworkTranSend.csproj @@ -0,0 +1,88 @@ + + + + + Debug + AnyCPU + {B709B5A7-A4F0-4B18-8E07-1EA3541DDB01} + Library + Properties + Cosmos.Network + Agent.NetworkTranSend + v4.0 + 512 + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\BIN\Cosmos.BaseFrame.dll + + + ..\..\..\BIN\Cosmos.ServiceProvider.dll + + + ..\..\..\BIN\Cosmos.UserFrame.dll + + + False + ..\..\..\BIN\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + {670a81be-cee3-4c29-846d-a37652ca270d} + CommonManager + + + {a5b7accd-79eb-4261-bd36-01ab484ad8e3} + Common + + + + + copy .\IC\Agent.NetworkTranSend.dll .\Agent.NetworkTranSend.dll + + + copy .\Agent.NetworkTranSend.dll .\IC\Agent.NetworkTranSend.dll + + + \ No newline at end of file diff --git a/Agent/NetworkTranSend/Properties/AssemblyInfo.cs b/Agent/NetworkTranSend/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..ed652f1 --- /dev/null +++ b/Agent/NetworkTranSend/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("NetworkTranSend")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("NetworkTranSend")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("2786bf88-f09e-4e7c-9875-0653209757e1")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Agent/OLEDevice/Activator.cs b/Agent/OLEDevice/Activator.cs new file mode 100644 index 0000000..dded7db --- /dev/null +++ b/Agent/OLEDevice/Activator.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Generic; +using System.Text; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : OLEDevice 관련 클래스 Activator +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.Service +{ + /// + /// Load BaseFrame and save information (BaseFrame의 로드하고 정보를 보관한다) + /// + public class Activator : InitServiceAbstract + { + /// + /// Class별 객체를 리턴 + /// + /// + /// + public override object InitServiceInstance(string sClassNm) + { + //UserLog.WriteLogFile(UserCom.LOG_DEBUG, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + // "Activator.InitServiceInstance()", "Message : " + sClassNm + " Registration Starting !!!"); + + object retObj = null; + + switch (sClassNm) + { + case ServiceLists.AGENT_OLEDEVICE.DEVICE_MSR: + { + Cosmos.OLEDevice.DeviceMsr agentClass = new Cosmos.OLEDevice.DeviceMsr(); + retObj = agentClass; + break; + } + case ServiceLists.AGENT_OLEDEVICE.DEVICE_POSPRINTER: + { + Cosmos.OLEDevice.DevicePosPrinter agentClass = new Cosmos.OLEDevice.DevicePosPrinter(); + retObj = agentClass; + break; + } + case ServiceLists.AGENT_OLEDEVICE.DEVICE_SCANNER: + { + Cosmos.OLEDevice.DeviceScanner agentclass = new Cosmos.OLEDevice.DeviceScanner(); + retObj = agentclass; + break; + } + case ServiceLists.AGENT_OLEDEVICE.DEVICE_CASHDRAWER: + { + Cosmos.OLEDevice.DeviceCashdrawer agentClass = new Cosmos.OLEDevice.DeviceCashdrawer(); + + retObj = agentClass; + break; + } + case ServiceLists.AGENT_OLEDEVICE.DEVICE_CATTERMINAL: + { + Cosmos.OLEDevice.DeviceCatTerminal agentClass = new Cosmos.OLEDevice.DeviceCatTerminal(); + + retObj = agentClass; + break; + } + case ServiceLists.AGENT_OLEDEVICE.DEVICE_ICREADER: + { + Cosmos.OLEDevice.DeviceICReader agentClass = new Cosmos.OLEDevice.DeviceICReader(); + + retObj = agentClass; + break; + } + case ServiceLists.AGENT_OLEDEVICE.DEVICE_SIGNPAD: + { + Cosmos.OLEDevice.DeviceSignPad agentClass = new Cosmos.OLEDevice.DeviceSignPad(); + + retObj = agentClass; + break; + } + case ServiceLists.AGENT_OLEDEVICE.DEVICE_SCALE: + { + Cosmos.OLEDevice.DeviceScale agentClass = new Cosmos.OLEDevice.DeviceScale(); + + retObj = agentClass; + break; + } + case ServiceLists.AGENT_OLEDEVICE.DEVICE_LABELPRINTER: + { + Cosmos.OLEDevice.DeviceLabelPrinter agentClass = new Cosmos.OLEDevice.DeviceLabelPrinter(); + + retObj = agentClass; + break; + } + case ServiceLists.AGENT_OLEDEVICE.DEVICE_OURHOME: + { + Cosmos.OLEDevice.DeviceOurHome agentClass = new Cosmos.OLEDevice.DeviceOurHome(); + + retObj = agentClass; + break; + } + case ServiceLists.AGENT_OLEDEVICE.DEVICE_TPAYGLE: + { + Cosmos.OLEDevice.DeviceTPaygle agentClass = new Cosmos.OLEDevice.DeviceTPaygle(); + + retObj = agentClass; + break; + } + case ServiceLists.AGENT_OLEDEVICE.OCB_DIRECT: + { + Cosmos.OLEDevice.OCBDirect agentClass = new Cosmos.OLEDevice.OCBDirect(); + + retObj = agentClass; + break; + } + } + + return retObj; + } + } +} diff --git a/Agent/OLEDevice/DeviceCashdrawer.cs b/Agent/OLEDevice/DeviceCashdrawer.cs new file mode 100644 index 0000000..3611e1d --- /dev/null +++ b/Agent/OLEDevice/DeviceCashdrawer.cs @@ -0,0 +1,552 @@ +using System; +using System.Threading; +using System.Runtime.InteropServices; +using System.IO.Ports; + +using Cosmos.UserFrame; +using Cosmos.Common; +using Cosmos.ServiceProvider; + +using Microsoft.PointOfService; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : CahsDrawer 제어 +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.OLEDevice +{ + /// + /// CASHDRAWER 제어 CLASS + /// + public class DeviceCashdrawer : ICashdrawerUs + { + #region VctDraw2kSs.dll 제어 함수 + [DllImport("VctDraw2kSs.dll", EntryPoint = "OpenDrawPort")] + public static extern int OpenDrawPortFor9700(); + + [DllImport("VctDraw2kSs.dll", EntryPoint = "CloseDrawPort")] + public static extern int CloseDrawPortFor9700(); + + [DllImport("VctDraw2kSs.dll", EntryPoint = "OpenDraw")] + public static extern void OpenDrawFor9700(); + #endregion + + #region TgDrawA.dll 제어 함수 + [DllImport("TgDrawA.dll", EntryPoint = "OpenDrawPort")] + public static extern int OpenDrawPortForTg(); + + [DllImport("TgDrawA.dll", EntryPoint = "CloseDrawPort")] + public static extern int CloseDrawPortForTg(); + + [DllImport("TgDrawA.dll", EntryPoint = "OpenDraw")] + public static extern void OpenDrawForTg(); + #endregion + /// + /// StateServer Object (StateServer 객체) + /// + public StateServer StateObject = (StateServer)StateServer.GetInstance(); + /// + /// Device 상태 정보 객체 + /// + public DeviceStatus devStatus = new DeviceStatus(); + /// + /// POS 기본 정보 + /// + public PosStatus m_cPosStatus = null; + /// + /// Pos for .Net CashDrawer 객체 + /// + private CashDrawer cashdrawer = null; + /// + /// Pos for .Net의 Device 정보를 가져오기 위한 객체 + /// + private PosExplorer posExplorer = null; + /// + /// RS232통신을 위한 시리얼포트 객체 + /// + private SerialPort m_serialPort = null; + + private IPosPrinterUs objPosPrinter = null; + /// + /// + /// g + private int m_sUpdateStatus = 0; + + /// + /// 0:OPOS, 1:RS232(프린터에 연결), 2:IBM본체에 연결하는 돈통 + /// DRAWER_TYPE 참고 + /// + private int drawerType = 0; + + #region 초기화 + /// + /// 생성자 + /// + public DeviceCashdrawer() + { + try + { + try + { + posExplorer = new PosExplorer(); + } + catch (Exception ex) { } + devStatus = (DeviceStatus)StateObject.DEVICE; + m_cPosStatus = (PosStatus)StateObject.POS; + objPosPrinter = (IPosPrinterUs)(new SManager()).InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_POSPRINTER); + DeviceStatusInit(); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + } + + /// + /// 초기화 + /// + private void DeviceStatusInit() + { + devStatus.Cashdrawer.Status = ""; + devStatus.Cashdrawer.DeviceName = ""; + devStatus.Cashdrawer.Open = false; + } + #endregion + + #region 디바이스 OPEN/CLOSE 처리 + /// + /// 디바이스 Open시 처리함수 + /// + /// 장비종류(ex- "Msr","PosPrinter","Scanner"...) + /// 레지스트리 항목(ex- "DefaultMsr","DefaultPosPrinter","DefaultScanner"...) + /// + public bool OpenDevice(string sDeviceType, string sLogicalName) + { + bool bRet = false; + + try + { + if(devStatus.Cashdrawer.UseYn == false) + { + return false; + } + + if(m_cPosStatus.Base.OlePosCashDrawerType == PosConst.POS_DEVICE_LIST.CASHDRAWER._1_PRINTER) + { + if(devStatus.Printer.UseYn == false) + { + return false; + } + devStatus.Cashdrawer.Open = true; + devStatus.Cashdrawer.Status = "SUCCESS"; + } + else if(m_cPosStatus.Base.OlePosCashDrawerType == PosConst.POS_DEVICE_LIST.CASHDRAWER._2_OPOS_IBM) + { + OpenDeviceByOPOS(sDeviceType, sLogicalName); + } + else if(m_cPosStatus.Base.OlePosCashDrawerType == PosConst.POS_DEVICE_LIST.CASHDRAWER._3_DLL_TPS8700) + { + OpenDrawForTg(); + bRet = true; + } + else if(m_cPosStatus.Base.OlePosCashDrawerType == PosConst.POS_DEVICE_LIST.CASHDRAWER._4_DLL_VPS9700) + { + OpenDrawFor9700(); + bRet = true; + } + else if (m_cPosStatus.Base.OlePosCashDrawerType == PosConst.POS_DEVICE_LIST.CASHDRAWER._5_IBM_MAIN) + { + OpenDeviceByRS232(m_cPosStatus.Base.OlePosCashDrawerSerialPortNumber, m_cPosStatus.Base.OlePosCashDrawerBaudRate); + } + + bRet = true; + } + catch (Exception ex) + { + devStatus.Cashdrawer.Open = false; + devStatus.Cashdrawer.Status = "CashDrawer Device Open Exception"; + + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + devStatus.Cashdrawer.Status + "/" + ex.Message); + return bRet; + } + return bRet; + } + + public bool OpenDeviceByOPOS(string sDeviceType, string sLogicalName) + { + bool bRet = false; + + try + { + DeviceInfo devInfo = null; + + if (sDeviceType == DeviceType.CashDrawer && sLogicalName == PosConst.OPOS_LDN.CASHDRAWER) + { + devInfo = posExplorer.GetDevice(DeviceType.CashDrawer, PosConst.OPOS_LDN.CASHDRAWER); + } + else + { + devStatus.Cashdrawer.Open = false; + devStatus.Cashdrawer.Status = "DEVICE INFO ERROR"; + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceCashdrawer.OpenDeviceByOPOS()", devStatus.Printer.Status); + return bRet; + } + + if(devInfo == null) + { + devStatus.Cashdrawer.Open = false; + devStatus.Cashdrawer.Status = "DEVICE INFO ERROR"; + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceCashdrawer.OpenDeviceByOPOS()", devStatus.Printer.Status); + return bRet; + } + + cashdrawer = (CashDrawer)posExplorer.CreateInstance(devInfo); + + if(cashdrawer != null) + { + cashdrawer.StatusUpdateEvent += new StatusUpdateEventHandler(CashDrawer_StatusUpdateEventDataEvent); + + try + { + cashdrawer.Open(); + } + catch(Exception ex) + { + devStatus.Cashdrawer.Status = "OPEN FAIL"; + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceCashdrawer.OpenDeviceByOPOS()", devStatus.Printer.Status); + return bRet; + } + + try + { + cashdrawer.Claim(1000); + } + catch(Exception ex) + { + devStatus.Cashdrawer.Status = "CLAIM FAIL"; + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceCashdrawer.OpenDeviceByOPOS()", devStatus.Printer.Status); + return bRet; + } + + try + { + cashdrawer.DeviceEnabled = true; + } + catch(Exception ex) + { + devStatus.Cashdrawer.Status = "DEVICE ENABLED FAIL"; + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceCashdrawer.OpenDeviceByOPOS()", devStatus.Printer.Status); + return bRet; + } + + devStatus.Cashdrawer.DeviceName = devInfo.ServiceObjectName; + devStatus.Cashdrawer.Open = true; + devStatus.Cashdrawer.Status = "Success"; + bRet = true; + } + } + catch (Exception ex) + { + devStatus.Cashdrawer.Open = false; + devStatus.Cashdrawer.Status = "CashDrawer Device Open Exception"; + + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + devStatus.Cashdrawer.Status + "/" + ex.Message); + } + + return bRet; + } + + public bool OpenDeviceByRS232(string sSerialPort, long lBaudrate) + { + bool bRet = false; + + try + { + if(m_serialPort != null) + { + m_serialPort.Close(); + System.Threading.Thread.Sleep(50); + m_serialPort = null; + } + + if(m_serialPort == null) + { + m_serialPort = new SerialPort(); + if(m_serialPort == null) + { + devStatus.Cashdrawer.Open = false; + devStatus.Cashdrawer.Status = "SERIAL PORT ERROR"; + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.Cashdrawer.Status); + return bRet; + } + + m_serialPort.NewLine = "\r\n"; + m_serialPort.Encoding = System.Text.Encoding.GetEncoding("ks_c_5601-1987"); + + m_serialPort.WriteBufferSize = 1024 * 3; + m_serialPort.PortName = sSerialPort; + m_serialPort.BaudRate = (int)lBaudrate; + m_serialPort.DataBits = 8; + m_serialPort.StopBits = StopBits.One; + m_serialPort.Parity = Parity.None; + + m_serialPort.Open(); + if(m_serialPort.IsOpen == false) + { + devStatus.Cashdrawer.Open = false; + devStatus.Cashdrawer.Status = "SERIAL PORT OPEN ERROR"; + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.Cashdrawer.Status); + return bRet; + } + + devStatus.Cashdrawer.Open = true; + devStatus.Cashdrawer.Status = "SUCCESS"; + bRet = true; + } + } + catch (Exception ex) + { + devStatus.Cashdrawer.Open = false; + devStatus.Cashdrawer.Status = "CashDrawer Device Open Exception"; + + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRet; + } + + /// + /// 디바이스 Close시 처리함수 + /// + /// + public bool CloseDevice() + { + bool bRet = false; + + try + { + if(m_cPosStatus.Base.OlePosCashDrawerType == PosConst.POS_DEVICE_LIST.CASHDRAWER._2_OPOS_IBM) + { + if (cashdrawer == null) + return bRet; + + cashdrawer.DeviceEnabled = false; + cashdrawer.Release(); + cashdrawer.Close(); + cashdrawer = null; + } + else if(m_cPosStatus.Base.OlePosCashDrawerType == PosConst.POS_DEVICE_LIST.CASHDRAWER._3_DLL_TPS8700) + { + CloseDrawPortForTg(); + } + else if(m_cPosStatus.Base.OlePosCashDrawerType == PosConst.POS_DEVICE_LIST.CASHDRAWER._4_DLL_VPS9700) + { + CloseDrawPortFor9700(); + } + else if(m_cPosStatus.Base.OlePosCashDrawerType == PosConst.POS_DEVICE_LIST.CASHDRAWER._5_IBM_MAIN) + { + if(m_serialPort == null) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceCashdrawer.CloseDevice()", "m_serialPort == null"); + return bRet; + } + + m_serialPort.Close(); + m_serialPort = null; + } + bRet = true; + + devStatus.Cashdrawer.Status = "CLOSE"; + devStatus.Cashdrawer.Open = false; + } + catch (Exception ex) + { + devStatus.Cashdrawer.Status = "CLOSE EXCEPTION"; + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + devStatus.Cashdrawer.Status + "/" + ex.Message); + } + + return bRet; + } + #endregion + + #region POS for .NET 이벤트 처리 + /// + /// Cashdrawer 상태 변경에 따른 이벤트 처리 + /// + /// + /// + private void CashDrawer_StatusUpdateEventDataEvent(object sender, StatusUpdateEventArgs e) + { + try + { + m_sUpdateStatus = e.Status; + + switch (m_sUpdateStatus) + { + case CashDrawer.StatusOpen: + devStatus.Cashdrawer.Status = "DRAWER OPENED"; + break; + case CashDrawer.StatusClosed: + devStatus.Cashdrawer.Status = "DRAWER CLOSED"; + break; + } + + if (PosOLEDevice.m_delegateOlePos != null) + PosOLEDevice.m_delegateOlePos(PosConst.OPOS_DEVICE.CASHDRAWER, devStatus.Cashdrawer.Status, string.Empty, string.Empty); + } + catch (Exception ex) + { + devStatus.Cashdrawer.Status = "STATUS UPDATE EVENT ERROR"; + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + devStatus.Cashdrawer.Status + "-" + ex.Message); + } + } + #endregion + + #region 돈통 개방 처리 + /// + /// 돈통 개방 + /// + public void OpenCashDrawer() + { + bool bRet = false; + + try + { + if (devStatus.Cashdrawer.Open == false) + { + OpenDevice(DeviceType.CashDrawer, PosConst.OPOS_LDN.CASHDRAWER); + } + + if (devStatus.Cashdrawer.Open == true) + { + if (m_cPosStatus.Base.OlePosCashDrawerType == PosConst.POS_DEVICE_LIST.CASHDRAWER._1_PRINTER) + { + objPosPrinter.OpenCashDrawer(); + bRet = true; + } + else if (m_cPosStatus.Base.OlePosCashDrawerType == PosConst.POS_DEVICE_LIST.CASHDRAWER._2_OPOS_IBM) + { + cashdrawer.OpenDrawer(); + bRet = true; + } + else if (m_cPosStatus.Base.OlePosCashDrawerType == PosConst.POS_DEVICE_LIST.CASHDRAWER._3_DLL_TPS8700) + { + OpenDrawForTg(); + bRet = true; + } + else if (m_cPosStatus.Base.OlePosCashDrawerType == PosConst.POS_DEVICE_LIST.CASHDRAWER._4_DLL_VPS9700) + { + OpenDrawFor9700(); + bRet = true; + } + else if (m_cPosStatus.Base.OlePosCashDrawerType == PosConst.POS_DEVICE_LIST.CASHDRAWER._5_IBM_MAIN) + { + TransmitCommand(PosConst.ESCP_COMMAND.CASHDRAWER_OPEN_IBMHOST, true); + bRet = true; + } + else + { + devStatus.Cashdrawer.Status = "DRAWER TYPE ERROR"; + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.Cashdrawer.Status); + } + devStatus.Cashdrawer.Status = "DRAWER OPEN"; + } + } + catch (Exception ex) + { + devStatus.Cashdrawer.Status = "DRAWER OPEN ERROR"; + + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + devStatus.Cashdrawer.Status + "/" + ex.Message); + } + + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Open Drawer=" + (bRet ? "SUCCESS" : "FAIL")); + } + #endregion + + #region SerialPort 전송 + private void TransmitCommand(byte[] aCmd, bool bSleepOn = true) + { + if (m_serialPort.IsOpen == true) + { + int iOffset = 0; + //int iReadBuf = 2048; + int iReadBuf = m_serialPort.WriteBufferSize; + + while (true) + { + if (iOffset >= aCmd.Length) + { + break; + } + if (iReadBuf + iOffset > aCmd.Length) + { + iReadBuf = aCmd.Length - iOffset; + } + m_serialPort.Write(aCmd, iOffset, iReadBuf); + + iOffset += iReadBuf; + System.Threading.Thread.Sleep(10); + } + //m_serialPort.Write(Encoding.Default.GetString(aCmd, 0, aCmd.Length)); + + if (bSleepOn == true) System.Threading.Thread.Sleep(30); + } + } + #endregion + } +} diff --git a/Agent/OLEDevice/DeviceCatTerminal.cs b/Agent/OLEDevice/DeviceCatTerminal.cs new file mode 100644 index 0000000..f560567 --- /dev/null +++ b/Agent/OLEDevice/DeviceCatTerminal.cs @@ -0,0 +1,335 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Cosmos.UserFrame; +using Cosmos.Common; +using System.Runtime.InteropServices; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : CAT 단말기 제어 +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.OLEDevice +{ + /// + /// CAT 단말기 제어 CLASS + /// + public class DeviceCatTerminal : ICatTerminalUs + { + + /// + /// 단말기와 승인/취소 통신을 처리하는 함수 + /// + /// + /// + /// + /// + /// + [DllImport("SPCNSecuCAT.dll")] + public static extern int SPCNSecuCAT_Payment(int comport, int baud, byte[] input_msg, byte[] output_msg); + + /// + /// 단말기에 저장된 미전송 내역을 받아오는 함수 + /// + /// + /// + /// + /// + [DllImport("SPCNSecuCAT.dll")] + public static extern int SPCNSecuCAT_GetRemain(int comport, int baud, byte[] output_msg); + + /// + /// 중국 - 샨더 단말기와 승인/취소 통신을 처리하는 함수 + /// + /// + /// + /// + [DllImport("LibSand.dll")] + public static extern void card_trans(int comport, byte[] input_msg, byte[] output_msg); + + /// + /// 중국 - 은련 단말기와 승인/취소 통신을 처리하는 함수 + /// + /// + /// + /// + [DllImport("posinf.dll")] + public static extern int bankall(byte[] request, byte[] response); + + /// + /// StateServer Object (StateServer 객체) + /// + public StateServer StateObject = (StateServer)StateServer.GetInstance(); + /// + /// Device 상태 정보 객체 + /// + public DeviceStatus m_cdevStatus = null; + + /// + /// Pos 상태 정보 객체 + /// + public PosStatus m_cPosStatus = null; + + /// + /// 생성자 + /// + public DeviceCatTerminal() + { + try + { + m_cPosStatus = (PosStatus)StateObject.POS; + m_cdevStatus = (DeviceStatus)StateObject.DEVICE; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + } + + + #region 연결확인 + /// + /// 연결확인(가동시 체크) + /// + public bool SPCNSecuCatStatus() + { + bool bRet = false; + string sSendData = string.Empty; + string sRecvData = string.Empty; + + try + { + if (m_cPosStatus.Base.OlePosCATModel == PosConst.CAT_MODEL_DIV._KOR_SPCN) + { + sSendData = CmUtil.RPadH("Z0A0 000000000000000000000000000", 360); + if (SPCNSecuCatApprove(sSendData, ref sRecvData) > 0) + bRet = true; + } + else if (m_cPosStatus.Base.OlePosCATModel == PosConst.CAT_MODEL_DIV._CHN_SAND || m_cPosStatus.Base.OlePosCATModel == PosConst.CAT_MODEL_DIV._CHN_UNION) + { + // 중국산은 상태 체크 없어 패스 + //if (SPCNSecuCatApprove(sSendData, ref sRecvData) >= 0) + bRet = true; + } + + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRet; + } + #endregion + + + #region 연결 상태 확인 및 CAT 단말기 정보 확인 + /// + /// 연결 상태 및 CAT 단말기 정보 확인 + /// + public int SPCNSecuCatInfo(string sSendData, ref string sRecvData) + { + int nReturn = -99; + + try + { + nReturn = SPCNSecuCatApprove(sSendData, ref sRecvData); + + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 nReturn; + } + #endregion + + #region 승인/취소 요청 + /// + /// 승인/취소 요청 + /// + /// + /// + /// + public int SPCNSecuCatApprove(string sSendData, ref string sRecvData) + { + int nReturn = -99; + + try + { + + byte[] bytInputMsg = null; + byte[] bytOutput = new byte[4096]; + + sRecvData = string.Empty; + Array.Clear(bytOutput, 0, bytOutput.Length); + + bytInputMsg = Encoding.Default.GetBytes(sSendData); + + switch (m_cPosStatus.Base.OlePosCATModel) + { + case PosConst.CAT_MODEL_DIV._KOR_SPCN: + { + nReturn = SPCNSecuCAT_Payment(CmUtil.IntParse(m_cPosStatus.Base.OlePosCATSerialPortNumber.Replace("COM", "")), (int)m_cPosStatus.Base.OlePosCATSerialBaudRate, bytInputMsg, bytOutput); // 승인조회 + + if (nReturn < 0) //승인실퍠 + { + //실패경우 + sRecvData = ErrCodeToMsg(nReturn); + } + else + { + sRecvData = ByteToString(bytOutput); + } + break; + } + case PosConst.CAT_MODEL_DIV._CHN_SAND: + { + // 중국 샨더 단말기 + card_trans(CmUtil.IntParse(m_cPosStatus.Base.OlePosCATSerialPortNumber.Replace("COM", "")), bytInputMsg, bytOutput); // 승인조회 + + sRecvData = ByteToString(bytOutput); + + if (sRecvData.Length > 0) nReturn = 0; + break; + } + case PosConst.CAT_MODEL_DIV._CHN_UNION: + { + // 중국 은련 단말기 + bankall(bytInputMsg, bytOutput); // 승인조회 + + sRecvData = ByteToString(bytOutput); + + if (sRecvData.Length > 0) nReturn = 0; + break; + } + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 nReturn; + } + #endregion + + + #region 승인/취소 요청 + /// + /// 단말기에 저장된 미전송 내역을 받아오는 함수 + /// + /// + /// + public int SPCNSecuCatRemain(ref string sRecvData) + { + int nReturn = -99; + + try + { + byte[] bytOutput = new byte[4096]; + + sRecvData = string.Empty; + Array.Clear(bytOutput, 0, bytOutput.Length); + + nReturn = SPCNSecuCAT_GetRemain(CmUtil.IntParse(m_cPosStatus.Base.OlePosCATSerialPortNumber.Replace("COM", "")), (int)m_cPosStatus.Base.OlePosCATSerialBaudRate, bytOutput); + + if (nReturn < 0) //승인실퍠 + { + //실패경우 + sRecvData = ErrCodeToMsg(nReturn); + } + else + { + sRecvData = ByteToString(bytOutput); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 nReturn; + } + #endregion + + /// + /// Byte배열을 string으로 변환 (Byte배열의 null(0x00)값 제거) + /// + /// + /// + private string ByteToString(byte[] data) + { + int inx = Array.FindIndex(data, 0, (x) => x == 0x0); + if (inx >= 0) + { + return Encoding.Default.GetString(data, 0, inx); + } + else + { + return Encoding.Default.GetString(data); + } + } + + /// + /// 응답코드 + /// + /// + /// + private string ErrCodeToMsg(int nErrCode) + { + string sMsg = string.Empty; + + try + { + switch (nErrCode) + { + case -101: sMsg = "시리얼포트번호오류"; break; + case -102: sMsg = "통신속도오류"; break; + case -103: sMsg = "전문길이오류"; break; + case -210: sMsg = "할부개월오류"; break; + case -211: sMsg = "금액봉사료세금오류"; break; + case -212: sMsg = "원거래일자오류"; break; + case -213: sMsg = "포인트거래구분오류"; break; + case -301: sMsg = "거래중카드제거"; break; + case -302: sMsg = "단말기 사용자 강제종료"; break; + case -303: sMsg = "기타단말기오류"; break; + case -304: sMsg = "카드삽입되어있음"; break; + case -305: sMsg = "사용자강제취소"; break; + case -401: sMsg = "시리얼포트오픈오류"; break; + case -402: sMsg = "시리얼쓰기오류"; break; + case -403: sMsg = "시리얼읽기오류"; break; + case -404: sMsg = "시리얼닫기오류"; break; + case -405: sMsg = "시리얼타임아웃"; break; + case -411: sMsg = "미전송내역없음"; break; + default: sMsg = "정의되어 있지 않은 메세지" + "[" + nErrCode + "]"; break; + } + } + catch { } + return sMsg; + } + + } +} diff --git a/Agent/OLEDevice/DeviceICReader.cs b/Agent/OLEDevice/DeviceICReader.cs new file mode 100644 index 0000000..e8804cb --- /dev/null +++ b/Agent/OLEDevice/DeviceICReader.cs @@ -0,0 +1,2757 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Runtime.InteropServices; + +using Cosmos.Common; +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.CommonManager; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : IC 리더기 제어 +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.OLEDevice +{ + /// + /// IC 리더기 제어 CLASS + /// + public class DeviceICReader : IICReaderUs + { + #region SpcnPos.DLL 을 이용한 IC리더기 제어 함수 + + + /// + /// 배출 요청 함수 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnIcReaderCardExhaust(int tranType, int mediaType, byte[] maintainType, byte[] backFeeding, byte[] etcData, byte[] output_msg); + + + + /// + /// 승인 요청 함수 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnIcPos(byte[] input_msg, int input_msg_len, byte[] signData, byte[] icData, byte[] oilData, byte[] authInfo, byte[] output_msg); + + /// + /// 망취소 요청 함수 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnReversal(byte[] req_msg, byte[] res_msg, byte[] authInfo, byte[] output_msg); + + /// + /// [IC리더기] 초기화 요청 함수 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnIcReaderInit(); + + /// + /// [IC리더기] 시간설정 요청 함수 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnIcReaderSetTime(); + + // 환경설정 정보 가져오기 + [DllImport("SpcnPos.dll")] + public static extern int SpcnGetFlag(byte[] appName, byte[] keyName, byte[] output, int outputMaxLen); + + // 환경설정 정보 설정하기 + [DllImport("SpcnPos.dll")] + public static extern int SpcnSetFlag(byte[] appName, byte[] keyName, byte[] value); + + /// + /// [IC리더기] 상호인증 요청 함수 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnIcReaderKeyDownload(byte[] inTrmlId, byte[] inAuthInfo); + + /// + /// [IC리더기] 무결성검사 요청 함수 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnIcReaderIntegrity(byte[] outResTime); + + /// + /// [IC리더기] 상태확인 요청 함수 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnIcReaderStatus(byte[] outHwStatus, byte[] outIntegrityStatus, byte[] outCardInStatus, byte[] outReaderName, byte[] outReaderVersion, byte[] outModuleId); + + /// + /// [IC리더기] 카드 정보 요청 함수 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnIcReaderCardInfo(int tranType, byte[] trmlId, int amount, byte[] output_msg); + + /// + /// [IC리더기] 발급사 인증 요청 함수 + /// IcChipData는 ARC / (FS) / Additional Response Data / (FS) / Issuer Authentication Data / (FS) / Issuer Script 형태를 맞춰야 함 + /// 승인응답일 경우에는 정상적으로 데이터가 넘어오나 승인취소일 경우에는 ARC만 들어오므로 FS갯수만 맞추면 됨. + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnIcReaderCardIssuer(byte[] inIcChipData, byte[] output_msg); + + /// + /// [IC리더기] 카드번호 암호화 요청 함수 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnIcReaderCardEncrypt(byte[] inCardNum, byte[] output_msg); + + // (RF) RF카드 정보 조회 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfPrepaidCardInfo(byte[] output_msg); + + /// + /// (RF) 후불 결제 거래 카드 정보 요청 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfCreditCardInfo(byte[] terminalNo, byte[] samType, byte[] amount, byte[] msg1, byte[] msg2, byte[] msg3, byte[] output_msg); + + // (RF) [미보안] 후불 결제 거래 카드 정보 요청 + [DllImport("SpcnPosEx.dll")] + public static extern int SpcnRfCreditCardInfoEx(byte[] terminalNo, byte[] samType, byte[] amount, byte[] msg1, byte[] msg2, byte[] msg3, byte[] output_msg); + + //20171013 dkshin 해피기프트(신) IC/RF 충전 및 승인 + /// + /// (RF) 해피기프트카드(코나머니) 정보 읽기 조회 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfEtcCardInfo(byte[] terminalNo, byte[] samType, byte[] amount, byte[] msg1, byte[] msg2, byte[] msg3, byte[] output_msg); + + /// + /// RF 초기화 요청 함수 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfReaderInit(); + + /// + /// RF 시간 설정 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfReaderSetTime(); + + // RF 상호인증 요청 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfReaderKeyDownload(byte[] inTrmlId, byte[] inAuthInfo); + + // RF 무결성 요청 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfReaderIntegrity(byte[] outResTime); + + // RF 상태확인 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfReaderStatus(byte[] outHwStatus, byte[] outIntegrityStatus, byte[] outCardInStatus, byte[] outReaderName, byte[] outReaderVersion, byte[] outModuleId); + + // RF 사원카드 정보 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfEmployeeCardInfo(byte[] output); + + /// + /// IC 리더 콜백 호출 요청 + /// + /// + [DllImport("SpcnPos.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void SpcnRegIcCallback(IntPtr callback); + /// + /// IC 리더 콜백 호출 해지 + /// + [DllImport("SpcnPos.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern void SpcnUnRegIcCallback(); + /// + /// IC 리더 설정 + /// + /// + /// + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnIcReaderSettingDevice(byte[] type, byte[] value); + /// + /// MSR 신용카드 요청 - 미인증 POS 사용 + /// + /// + /// + /// + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnPos(byte[] input_msg, int input_msg_len, byte[] output_msg); + + /// + /// + /// + /// + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnStopProcess(int type); + + /// + /// IC 리더기 펌웨어 업데이트 + /// + /// + /// + /// + /// + /// + [DllImport("DeFWDownloadDll.dll")] + public static extern int DE_DownloadFW(int checkfwtout, int downfwtout, int nPort, byte[] DCheck); + /// + /// IC 리더기 펌웨어 이전 버전 업데이트 + /// + /// + /// + /// + /// + [DllImport("DeFWDownloadDll.dll")] + public static extern int DE_BacktoFW(int checkfwtout, int downfwtout, int nPort); + + //#20171016 IC리더기 펌웨어 업데이트 Start, srlee + /// + /// IC 리더기 펌웨어 업데이트_NEW + /// + /// + /// + /// + /// + /// + [DllImport("VANDeDownloadDll.dll")] + public static extern int DE_FWDOWN(int nPort, int nBaud, byte[] cPW, byte[] filepath); + /// + /// IC 리더기 펌웨어 다운로드 상태 확인하는 callback 함수 등록 + /// + /// + /// + [DllImport("VANDeDownloadDll.dll")] + public static extern void DE_CallBackFunReg(IntPtr callback); + //#20171016 IC리더기 펌웨어 업데이트 End, srlee + #endregion + + /// + /// 등록제 정보 + /// (0~15 : IC리더기 정보, 16~31 : POS S/W명 과 Version) + /// + private StringBuilder m_sAuthInfo_IC = new StringBuilder(); + public StringBuilder AuthInfo_IC { get { return m_sAuthInfo_IC; } } + + /// + /// 등록제 정보 + /// (0~15 : RF리더기 정보, 16~31 : POS S/W명 과 Version) + /// + private StringBuilder m_sAuthInfo_RF = new StringBuilder(); + public StringBuilder AuthInfo_RF { get { return m_sAuthInfo_RF; } } + + /// + /// StateServer Object (StateServer 객체) + /// + public StateServer StateObject = (StateServer)StateServer.GetInstance(); + /// + /// Device 상태 정보 객체 + /// + public DeviceStatus m_cDevStatus = null; + + /// + /// Pos 상태 정보 객체 + /// + public PosStatus m_cPosStatus = null; + + // VAN IP, PORT Update 체크 여부 + private static bool m_bUpdateIni = false; + + /// + /// IC리더 콜백 처리 여부 + /// + private bool m_bIcReaderCallBack = false; + + //#20171024 START, PHJ + + private string m_sPAY_WAY_CD; + /// + /// 결제수단코드 + /// + public string PAY_WAY_CD { set { this.m_sPAY_WAY_CD = value; } } + + private string m_sPAY_DTL_CD; + /// + /// 결제수단상세코드 + /// + public string PAY_DTL_CD { set { this.m_sPAY_DTL_CD = value; } } + + //#20171024 END, PHJ + + /// + /// 생성자 + /// + public DeviceICReader() + { + try + { + m_cPosStatus = (PosStatus)StateObject.POS; + m_cDevStatus = (DeviceStatus)StateObject.DEVICE; + + //InitializeDevice(); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + } + + /// + /// IC리더기 초기화 작업 + /// + public void InitializeDevice() + { + //UpdateIniConfig(m_cDevStatus.ICReader.VanIP, m_cDevStatus.ICReader.VanPort); + UpdateIniConfig(); + + if (m_cDevStatus.ICReader.UseYn == true) + { + SetAuthInfoString(PosConst.POS_CARD_READER_DEVICE_TYPE.IC_READER); + } + + + } + /// + /// SpcnPos.dll 이 사용하는 SpcnPosCfg.ini 파일 update + /// + private void UpdateIniConfig() + { + StringBuilder sbGetText = new StringBuilder(); + CmMessage m_PosDevice = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + "PosDevice.INI"); + string sPortNumber = string.Empty; + long lBaudrate = 0; + bool bRtn = false; + try + { + sPortNumber = CmUtil.StringNullEmpty(GetConfigInfo(m_PosDevice, "ICREADER", "SerialPortNumber")); + lBaudrate = CmUtil.LongParse(CmUtil.StringNullEmpty(GetConfigInfo(m_PosDevice, "ICREADER", "SerialBaudRate"))); + + if (sPortNumber.Length < 3 || lBaudrate <= 0) + { + new Exception("PosDevice.INI IC리더기 설정 오류"); + return; + } + + sbGetText.Clear(); + WinAPI.GetPrivateProfileString(PosConst.POS_ICREADER_CONFIG.APPNAME, + PosConst.POS_ICREADER_CONFIG.KEY_READER_PORT, + string.Empty, + sbGetText, + 64, + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + + if (sbGetText.ToString() != sPortNumber.Substring(3, sPortNumber.Length - 3))//Yoo modify 20160613 + { + bRtn = WinAPI.WritePrivateProfileString(PosConst.POS_ICREADER_CONFIG.APPNAME, + PosConst.POS_ICREADER_CONFIG.KEY_READER_PORT, + sPortNumber.Substring(3, sPortNumber.Length - 3), + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig);//Yoo modify 20160613 + if (bRtn == false) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + PosConst.INI_FILE_NAME.ICReaderConfig + "/" + PosConst.POS_ICREADER_CONFIG.KEY_READER_PORT + " 쓰기 실패"); + } + } + + sbGetText.Clear(); + WinAPI.GetPrivateProfileString(PosConst.POS_ICREADER_CONFIG.APPNAME, + PosConst.POS_ICREADER_CONFIG.KEY_READER_BAUDRATE, + string.Empty, + sbGetText, + 64, + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + if (sbGetText.ToString() != Convert.ToString(lBaudrate)) + { + bRtn = WinAPI.WritePrivateProfileString(PosConst.POS_ICREADER_CONFIG.APPNAME, + PosConst.POS_ICREADER_CONFIG.KEY_READER_BAUDRATE, + Convert.ToString(lBaudrate), + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + if (bRtn == false) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + PosConst.INI_FILE_NAME.ICReaderConfig + "/" + PosConst.POS_ICREADER_CONFIG.KEY_READER_BAUDRATE + " 쓰기 실패"); + } + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 UpdateIniConfig(string sSvrIP, string sPort) + { + StringBuilder sbGetText = new StringBuilder(); + CmMessage m_PosDevice = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + "PosDevice.INI"); + bool bRtn1 = false; + bool bRtn2 = false; + try + { + // IP, PORT 설정 (SPCN) + if (sSvrIP.Trim() != "" && sPort.Trim() != "") + { + bRtn1 = WinAPI.WritePrivateProfileString(PosConst.POS_ICREADER_CONFIG.APPNAME, "SPCN_IP", + sSvrIP.Trim(), + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + if (bRtn1 == false) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + PosConst.INI_FILE_NAME.ICReaderConfig + "/" + sSvrIP + " SPCN_IP 쓰기 실패"); + } + + bRtn2 = WinAPI.WritePrivateProfileString(PosConst.POS_ICREADER_CONFIG.APPNAME, "SPCN_PORT", + sPort.Trim(), + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + if (bRtn2 == false) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + PosConst.INI_FILE_NAME.ICReaderConfig + "/" + sPort + " SPCN_PORT 쓰기 실패"); + } + + if (bRtn1 == true && bRtn2 == true) + { + // VAN IP, PORT Update flag 설정 + m_bUpdateIni = true; + } + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + } + + /// + /// 설정 파일 읽기 + /// + /// + /// + /// + /// + private string GetConfigInfo(CmMessage cCfgInfo, string sGroup, string sValueName) + { + return GetConfigInfo(cCfgInfo, sGroup, sValueName, ""); + } + private string GetConfigInfo(CmMessage cCfgInfo, string sGroup, string sValueName, string sDefault) + { + try + { + string sValue = cCfgInfo.GetMessage(sGroup).GetMessageValue(sValueName); + if (sValue == null) + return sDefault; + else + return sValue; + } + catch { } + + return sDefault; + } + + /// + /// Byte배열을 string으로 변환 (Byte배열의 null(0x00)값 제거) + /// + /// + /// + private string ByteToString(byte[] data) + { + int inx = Array.FindIndex(data, 0, (x) => x == 0x0); + if (inx >= 0) + { + return Encoding.Default.GetString(data, 0, inx); + } + else + { + return Encoding.Default.GetString(data); + } + } + + /// + /// Byte배열을 string으로 변환 (Byte배열의 null(0x00)값 제거) - 카드번호 전용 + /// + /// + /// + /// + private void ByteToString(byte[] data, ref string sData) + { + int inx = Array.FindIndex(data, 0, (x) => x == 0x0); + if (inx >= 0) + { + sData = Encoding.Default.GetString(data, 0, inx); + } + else + { + sData = Encoding.Default.GetString(data); + } + + + } + + /// + /// 등록제 정보 설정 + /// + /// + /// + public StringBuilder SetAuthInfoString(string sDeviceType) + { + string[] arICReaderStatus = null; + string sPosSwInfo = string.Empty; + try + { + if (m_bUpdateIni == false) + { + UpdateIniConfig(m_cDevStatus.ICReader.VanIP, m_cDevStatus.ICReader.VanPort); + } + + arICReaderStatus = GetStatus_ICReader(sDeviceType); + + sPosSwInfo = m_cPosStatus.Base.Auth_POS_SW_Ver; //PosConst.IC_AUTH_POS_SW_INFO; + sPosSwInfo = sPosSwInfo.PadLeft(16, '#'); + + if (sDeviceType == PosConst.POS_CARD_READER_DEVICE_TYPE.SAIGNPAD) + { + // RF리더기 + m_sAuthInfo_RF = new StringBuilder(); + + // 무결성 실패시 리턴 + if (arICReaderStatus[1] != "0") return m_sAuthInfo_RF; + + m_sAuthInfo_RF.Clear(); + m_sAuthInfo_RF.Append(arICReaderStatus[3].PadLeft(12, '#')); + m_sAuthInfo_RF.Append(arICReaderStatus[4]); + m_sAuthInfo_RF.Append(sPosSwInfo); + } + else + { + // IC리더기 + m_sAuthInfo_IC = new StringBuilder(); + + // 무결성 실패시 리턴 + if (arICReaderStatus[1] != "0") return m_sAuthInfo_IC; + + m_sAuthInfo_IC.Clear(); + m_sAuthInfo_IC.Append(arICReaderStatus[3].PadLeft(12, '#')); + m_sAuthInfo_IC.Append(arICReaderStatus[4]); + m_sAuthInfo_IC.Append(sPosSwInfo); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + if (sDeviceType == PosConst.POS_CARD_READER_DEVICE_TYPE.SAIGNPAD) + return m_sAuthInfo_RF; + else + return m_sAuthInfo_IC; + } + + #region SpcnPos.DLL 모듈 호출 함수 + /// + /// [IC리더기] 상태확인 요청 + /// + /// + /// + public string[] GetStatus_ICReader(string sDeviceType) + { + int iRet = 0; + string[] arReturn = null; + byte[] outHwStatus = new byte[2049]; + byte[] outIntegrityStatus = new byte[2049]; + byte[] outCardInStatus = new byte[2049]; + byte[] outReaderName = new byte[2049]; + byte[] outReaderVersion = new byte[2049]; + byte[] outModuleId = new byte[2049]; + + try + { + if (m_bUpdateIni == false) + { + UpdateIniConfig(m_cDevStatus.ICReader.VanIP, m_cDevStatus.ICReader.VanPort); + } + + Array.Clear(outHwStatus, 0x0, outHwStatus.Length); + Array.Clear(outIntegrityStatus, 0x0, outIntegrityStatus.Length); + Array.Clear(outCardInStatus, 0x0, outCardInStatus.Length); + Array.Clear(outReaderName, 0x0, outReaderName.Length); + Array.Clear(outReaderVersion, 0x0, outReaderVersion.Length); + Array.Clear(outModuleId, 0x0, outModuleId.Length); + + if (sDeviceType == PosConst.POS_CARD_READER_DEVICE_TYPE.SAIGNPAD) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "SpcnRfReaderStatus.Start."); + + if (m_cDevStatus.SignPad.UseYn == false) return arReturn; + + iRet = SpcnRfReaderStatus(outHwStatus, outIntegrityStatus, outCardInStatus, outReaderName, outReaderVersion, outModuleId); + } + else + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "SpcnIcReaderStatus.Start."); + + if (m_cDevStatus.ICReader.UseYn == false) return arReturn; + + iRet = SpcnIcReaderStatus(outHwStatus, outIntegrityStatus, outCardInStatus, outReaderName, outReaderVersion, outModuleId); + } + + if (iRet > 0) + { + arReturn = new string[] { ByteToString(outHwStatus) + , ByteToString(outIntegrityStatus) + , ByteToString(outCardInStatus) + , ByteToString(outReaderName) + , ByteToString(outReaderVersion) + , ByteToString(outModuleId)}; + + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Success. "); + } + else + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Error. " + iRet); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception. " + ex.Message); + } + + return arReturn; + } + + /// + /// 카드번호 암호화 + /// + //#20170913 현금영수증, 포인트카드 마스킹 미적용 start + //기존 + //public string GetEncryptedCardNo(string sPlainCardNo) + //변경 + public string GetEncryptedCardNo(string sPlainCardNo, string sEncGB = "1") + //#20170913 현금영수증, 포인트카드 마스킹 미적용 end + { + int iRtn = -1; + string sRtn = string.Empty; + byte[] outEncryptedCardNo; + try + { + outEncryptedCardNo = new byte[2049]; + Array.Clear(outEncryptedCardNo, 0x0, outEncryptedCardNo.Length); + +#if !DEVICE_MSR_VER + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.ICReader.UseYn == false) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0389); + return sRtn; + } + if (m_cDevStatus.ICReader.Integrity_IC_Status != true) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0386); + return sRtn; + } + + //#20171024 START, PHJ + + if ( + (m_sPAY_WAY_CD == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM) && + (m_sPAY_DTL_CD == ItemConst.TR_ITEM_ID.ETC_INFO.CASHBILL) && + (sPlainCardNo.Length >= 16) && + (sPlainCardNo.StartsWith(PosConst.HP_CARD_PRIFIX))) + { + sPlainCardNo = CmUtil.MidH(sPlainCardNo, 0, 16); + + //#20171024 START, PHJ - 20171027 + m_sPAY_WAY_CD = ""; + m_sPAY_DTL_CD = ""; + //#20171024 END, PHJ - 20171027 + } + + //#20171024 END, PHJ + + iRtn = SpcnIcReaderCardEncrypt(Encoding.Default.GetBytes(sPlainCardNo), outEncryptedCardNo); + if (iRtn == -161 || iRtn == -162) + { + SpcnStopProcess(0); // 이전 진행중인 처리가 있다면 중지 후 암호화 처리(2017.06.01) + iRtn = SpcnIcReaderCardEncrypt(Encoding.Default.GetBytes(sPlainCardNo), outEncryptedCardNo); + } + if (iRtn <= 0) return sRtn; + + sRtn = ByteToString(outEncryptedCardNo); + + //#20171123 서명패드로 입력받는 경우 마스킹 미처리 start + + if (sEncGB == "0") + { + sRtn = CmUtil.MidH(sRtn, 0, 514) + sPlainCardNo; + } + + //#20171123 서명패드로 입력받는 경우 마스킹 미처리 end + +#else + if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + { + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.ICReader.UseYn == false) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0389); + return sRtn; + } + if (m_cDevStatus.ICReader.Integrity_IC_Status != true) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0386); + return sRtn; + } + + //#20171024 START, PHJ + + if ( + (m_sPAY_WAY_CD == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM) && + (m_sPAY_DTL_CD == ItemConst.TR_ITEM_ID.ETC_INFO.CASHBILL) && + (sPlainCardNo.Length >= 16) && + (sPlainCardNo.StartsWith(PosConst.HP_CARD_PRIFIX))) + { + sPlainCardNo = CmUtil.MidH(sPlainCardNo, 0, 16); + + //#20171024 START, PHJ - 20171027 + m_sPAY_WAY_CD = ""; + m_sPAY_DTL_CD = ""; + //#20171024 END, PHJ - 20171027 + } + + //#20171024 END, PHJ + + iRtn = SpcnIcReaderCardEncrypt(Encoding.Default.GetBytes(sPlainCardNo), outEncryptedCardNo); + if (iRtn == -161 || iRtn == -162) + { + SpcnStopProcess(0); // 이전 진행중인 처리가 있다면 중지 시킨다. + iRtn = SpcnIcReaderCardEncrypt(Encoding.Default.GetBytes(sPlainCardNo), outEncryptedCardNo); + } + if (iRtn <= 0) return sRtn; + + sRtn = ByteToString(outEncryptedCardNo); + } + else + { + // MSR + string sInputType = ""; + + //#20171024 START, PHJ + //기존 + //sPlainCardNo = MSR_CardNoCheck(sPlainCardNo, "", ref sInputType); + + //변경 + sPlainCardNo = MSR_CardNoCheck(sPlainCardNo, "", ref sInputType, m_sPAY_WAY_CD, m_sPAY_DTL_CD); + //#20171024 END, PHJ + + //#20170913 현금영수증, 포인트카드 마스킹 미적용 start + //기존 + //sRtn = "00" + CmUtil.MidH(sPlainCardNo, 0, 512) + CmUtil.MidH(sPlainCardNo, 0, 6) + "********"; + //변경 + + if (sEncGB == "0") + { + sRtn = "00" + CmUtil.MidH(sPlainCardNo, 0, 512) + sPlainCardNo; + } + else + { + sRtn = "00" + CmUtil.MidH(sPlainCardNo, 0, 512) + CmUtil.MidH(sPlainCardNo, 0, 6) + "********"; + } + + //#20170913 현금영수증, 포인트카드 마스킹 미적용 end + } +#endif + } + catch (Exception ex) + { + sRtn = sPlainCardNo; + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 sRtn; + } + + + /// + /// [IC리더기] 배출 요청 + /// + public bool Exhaust_ICCard() + { + int iRtn = 0; + bool bRtn = false; + + byte[] maintainType = Encoding.Default.GetBytes("2"); + byte[] backFeeding = Encoding.Default.GetBytes("00"); + byte[] etcData = Encoding.Default.GetBytes(""); + byte[] output_msg = Encoding.Default.GetBytes(""); + + iRtn = SpcnIcReaderCardExhaust(3, 0, maintainType, backFeeding, etcData, output_msg); + if (iRtn > 0) + { + bRtn = true; + } + return bRtn; + } + + + /// + /// [IC리더기] 초기화 요청 + /// + public bool Init_ICReader(string sDeviceType) + { + int iRtn = 0; + bool bRtn = false; + + try + { + if (sDeviceType == PosConst.POS_CARD_READER_DEVICE_TYPE.SAIGNPAD) + { + // 서명패드 초기화 + iRtn = SpcnRfReaderInit(); + } + else + { + if (m_bUpdateIni == false) + { + UpdateIniConfig(m_cDevStatus.ICReader.VanIP, m_cDevStatus.ICReader.VanPort); + } + + // IC 리더기 초기화 + iRtn = SpcnIcReaderInit(); + } + if (iRtn > 0) + { + bRtn = true; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + /// + /// [IC리더기] 시간설정 요청 + /// + public bool SetTime_ICReader(string sDeviceType) + { + int iRtn = 0; + bool bRtn = false; + + try + { + if (sDeviceType == PosConst.POS_CARD_READER_DEVICE_TYPE.SAIGNPAD) + { + if (m_cDevStatus.SignPad.UseYn != true) return bRtn; + + // 서명패드 시간설정 요청 + iRtn = SpcnRfReaderSetTime(); + } + else + { + if (m_cDevStatus.ICReader.UseYn == false) return bRtn; + + // IC 리더기 시간설정 요청 + iRtn = SpcnIcReaderSetTime(); + } + if (iRtn > 0) + { + bRtn = true; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + /// + /// [IC리더기] 상호인증 요청 + /// + /// + /// + /// + public string KeyDownload_ICReader(string sDeviceType, string sTerminerID) + { + int iRtn = 0; + string sRet = UserCom.RST_ERR; + + try + { + // 서명패드 무결성 검사시 + if (sDeviceType == PosConst.POS_CARD_READER_DEVICE_TYPE.SAIGNPAD) + { + if (m_cDevStatus.SignPad.UseYn == false) return sRet; + + // 상태 확인 + SetAuthInfoString(sDeviceType); + + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "SpcnRfReaderKeyDownload.Start. " + AuthInfo_RF.ToString()); + // 상호인증 + iRtn = SpcnRfReaderKeyDownload(Encoding.Default.GetBytes(sTerminerID), Encoding.Default.GetBytes(AuthInfo_RF.ToString())); + } + else + { + if (m_cDevStatus.ICReader.UseYn == false) return sRet; + + if (m_bUpdateIni == false) + { + UpdateIniConfig(m_cDevStatus.ICReader.VanIP, m_cDevStatus.ICReader.VanPort); + } + + // 상태 확인 + SetAuthInfoString(sDeviceType); + + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "SpcnIcReaderKeyDownload.Start. " + AuthInfo_IC.ToString()); + + // 상호인증 + iRtn = SpcnIcReaderKeyDownload(Encoding.Default.GetBytes(sTerminerID), Encoding.Default.GetBytes(AuthInfo_IC.ToString())); + } + + if (iRtn > 0) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Success. "); + sRet = UserCom.RST_OK; + } + else + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Error. " + iRtn); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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; + } + + /// + /// [IC리더기] 무결성검사 요청 + /// + /// 장비구분:IC/ SignPad + /// 응답 결과 시간 + /// true:정상처리, false:에러 + public string IntegrityCheck_ICReader(string sDeviceType, ref string sRsltTime) + { + int iRtn = 0; + string sRet = UserCom.RST_ERR; + byte[] outResTime = new byte[2049]; + + // 무결성 검사 상태값 설정 + DeviceStatus m_cDevStatus = (DeviceStatus)StateObject.DEVICE; + + try + { + sRsltTime = string.Empty; + Array.Clear(outResTime, 0x0, outResTime.Length); + + // 상태 확인 + SetAuthInfoString(sDeviceType); + + // 시간설정 + SetTime_ICReader(sDeviceType); + + // 서명패드 무결성 검사시 + if (sDeviceType == PosConst.POS_CARD_READER_DEVICE_TYPE.SAIGNPAD) + { + if (m_cDevStatus.SignPad.UseYn == false) return sRet; + + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "SpcnRfReaderIntegrity.Start. "); + // 무결성 검사 + iRtn = SpcnRfReaderIntegrity(outResTime); + } + else + { + if (m_cDevStatus.ICReader.UseYn == false) return sRet; + + if (m_bUpdateIni == false) + { + UpdateIniConfig(m_cDevStatus.ICReader.VanIP, m_cDevStatus.ICReader.VanPort); + } + + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "SpcnIcReaderIntegrity.Start. "); + // 무결성 검사 + iRtn = SpcnIcReaderIntegrity(outResTime); + } + + if (iRtn > 0) + { + sRsltTime = ByteToString(outResTime); + sRet = UserCom.RST_OK; + + if (sDeviceType == PosConst.POS_CARD_READER_DEVICE_TYPE.IC_READER) m_cDevStatus.ICReader.Integrity_IC_Status = true; + else if (sDeviceType == PosConst.POS_CARD_READER_DEVICE_TYPE.SAIGNPAD) m_cDevStatus.ICReader.Integrity_SignPad_Status = true; + + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Success. "); + } + else + { + sRsltTime = string.Empty; + + // 무결성 실패시 인증번호 삭제 + if (sDeviceType == PosConst.POS_CARD_READER_DEVICE_TYPE.IC_READER) + { + m_sAuthInfo_IC.Clear(); + m_cDevStatus.ICReader.Integrity_IC_Status = false; + } + else if (sDeviceType == PosConst.POS_CARD_READER_DEVICE_TYPE.SAIGNPAD) + { + m_sAuthInfo_RF.Clear(); + m_cDevStatus.ICReader.Integrity_SignPad_Status = false; + } + + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Error. " + iRtn); + } + } + catch (Exception ex) + { + sRsltTime = string.Empty; + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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; + } + + /// + /// [IC리더기] 카드 정보 요청 + /// + public bool GetCardInfo_ICReader(int iTranType, int iAmount, ref string sRsltMsg) + { + return GetCardInfo_ICReader(iTranType, iAmount, ref sRsltMsg, false); + } + public bool GetCardInfo_ICReader(int iTranType, int iAmount, ref string sRsltMsg, bool bMask) + { + int iRtn = 0; + bool bRtn = false; + byte[] outMsg = new byte[4096]; + + try + { +#if !DEVICE_MSR_VER + sRsltMsg = string.Empty; + Array.Clear(outMsg, 0x0, outMsg.Length); + + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.ICReader.UseYn == false) + { + //Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0389); + return bRtn; + } + else if (m_cDevStatus.ICReader.Integrity_IC_Status != true) + { + //Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0386); + return bRtn; + } + + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "SpcnIcReaderCardInfo.Start. "); + + iRtn = SpcnIcReaderCardInfo(iTranType, Encoding.Default.GetBytes(m_cPosStatus.Base.OlePosICReaderSerialNumber), iAmount, outMsg); + if (iRtn > 0) + { + //카드번호 뒷 4자리 *로 치환 - 여전법대응! (마스킹 필요한 카드 필요시 사용) + if (outMsg.Length > 1046 && bMask == false) + { + for (int iRow = 1042; iRow < 1046; iRow++) + { + if (outMsg[iRow] != ((byte)0x20)) //스페이스 아니면! + { + outMsg[iRow] = (byte)0x2A; //*로 치환 + } + } + } + + ByteToString(outMsg, ref sRsltMsg); + bRtn = true; + + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Success. "); + } + else + { + //Block된 카드인경우 에러 메세지! + //if (iRtn == -144) + // WinManager.ErrorMessage(ErrCodeToMsg(iRtn)); + + if (iRtn != -118) + { + string sErrMsg = ErrCodeToMsg(iRtn); + //Cosmos.CommonManager.WinManager.ErrorMessage(sErrMsg); + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + iRtn + "=" + sErrMsg); + } + else + { + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + iRtn); + } + sRsltMsg = string.Empty; + } +#else + if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + { + sRsltMsg = string.Empty; + Array.Clear(outMsg, 0x0, outMsg.Length); + + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.ICReader.UseYn == false) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0389); + return bRtn; + } + else if (m_cDevStatus.ICReader.Integrity_IC_Status != true) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0386); + return bRtn; + } + + iRtn = SpcnIcReaderCardInfo(iTranType, Encoding.Default.GetBytes(m_cPosStatus.Base.OlePosICReaderSerialNumber), iAmount, outMsg); + if (iRtn > 0) + { + //카드번호 뒷 4자리 *로 치환 - 여전법대응! (마스킹 필요한 카드 필요시 사용) + if (outMsg.Length > 1046 && bMask == false) + { + for (int iRow = 1042; iRow < 1046; iRow++) + { + if (outMsg[iRow] != ((byte)0x20)) //스페이스 아니면! + { + outMsg[iRow] = (byte)0x2A; //*로 치환 + } + } + } + + ByteToString(outMsg, ref sRsltMsg); + bRtn = true; + } + else + { + //Block된 카드인경우 에러 메세지! + //if (iRtn == -144) + // WinManager.ErrorMessage(ErrCodeToMsg(iRtn)); + + if (iRtn != -118) + { + string sErrMsg = ErrCodeToMsg(iRtn); + Cosmos.CommonManager.WinManager.ErrorMessage(sErrMsg); + + UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + iRtn + "=" + sErrMsg); + } + sRsltMsg = string.Empty; + } + } +#endif + } + catch (Exception ex) + { + sRsltMsg = string.Empty; + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + /// + /// [IC리더기] 발급사 인증 요청 + /// + public bool CardIssuer_ICReader(string sIcChipData, ref string sRsltMsg) + { + int iRtn = 0; + bool bRtn = false; + byte[] outMsg = new byte[2049]; + + try + { + sRsltMsg = string.Empty; + Array.Clear(outMsg, 0x0, outMsg.Length); + + iRtn = SpcnIcReaderCardIssuer(Encoding.Default.GetBytes(sIcChipData), outMsg); + + if (iRtn > 0) + { + sRsltMsg = ByteToString(outMsg); + + if (CmUtil.MidH(sRsltMsg, 0, 2) == "00") + { + bRtn = true; + } + else + { + bRtn = false; + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Error - IssuerRecvValue : " + sRsltMsg); + } + + } + else + { + sRsltMsg = string.Empty; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + /// + /// 승인 요청 + /// + public int SpcnCommPos(string sInputMsg, string sSignData, string sIcData, string sOilData, string m_sAuthInfo, ref string sRecvData) + { + int nReturn = -99; + + try + { + byte[] bytInputMsg = null; + byte[] bytSignData = null; + byte[] bytIcData = null; + byte[] bytOilData = null; + byte[] bytAuthInfo = null; + + byte[] bytOutput = new byte[4096]; + + sRecvData = string.Empty; + Array.Clear(bytOutput, 0, bytOutput.Length); + + //// 무결성 실패후 진행시 오류 메시지 표시 + //if (m_cDevStatus.ICReader.Integrity_IC_Status != true && m_cPosStatus.Base.OlePosICReaderUseFlag == "1") + //{ + // Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0386); + // return nReturn; + //} + + bytInputMsg = Encoding.Default.GetBytes(sInputMsg); + bytSignData = Encoding.Default.GetBytes(sSignData); + bytIcData = Encoding.Default.GetBytes(sIcData); + + //#20180827 유가보조/면세유 미사용 start + //기존 + bytOilData = Encoding.Default.GetBytes(sOilData); + //변경 + /* + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "[sOilData:" + sOilData); + + sOilData = ""; + bytOilData = Encoding.Default.GetBytes(sOilData); + */ + //#20180827 유가보조/면세유 미사용 end + + if (m_sAuthInfo == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF) + { + bytAuthInfo = Encoding.Default.GetBytes(AuthInfo_RF.ToString()); + } + else + { + bytAuthInfo = Encoding.Default.GetBytes(AuthInfo_IC.ToString()); + } + +#if !DEVICE_MSR_VER + nReturn = SpcnIcPos(bytInputMsg, sInputMsg.Length, bytSignData, bytIcData, bytOilData, bytAuthInfo, bytOutput); // IC 승인조회 +#else + if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + { + nReturn = SpcnIcPos(bytInputMsg, sInputMsg.Length, bytSignData, bytIcData, bytOilData, bytAuthInfo, bytOutput); // IC 승인조회 + } + else + { + //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start + // 기존 + //nReturn = SpcnPos(bytInputMsg, sInputMsg.Length, bytOutput); // MSR 승인조회 + + if ((sIcData != "" || sIcData != null) && m_sAuthInfo == PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF) // 해피기프트(신) MS에서 RF 승인 시 + nReturn = SpcnIcPos(bytInputMsg, sInputMsg.Length, bytSignData, bytIcData, bytOilData, bytAuthInfo, bytOutput); // IC 승인조회 + else + nReturn = SpcnPos(bytInputMsg, sInputMsg.Length, bytOutput); // MSR 승인조회 + //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End + } +#endif + if (nReturn < 0) //승인실퍠 + { + // 실패경우 + sRecvData = ErrCodeToMsg(nReturn); + } + else + { + sRecvData = ByteToString(bytOutput); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 nReturn; + } + /// + /// 망취소 요청 + /// + /// 직전 승인 요청전문 + /// 직전 승인 응답전문 + /// 응답전문 + /// + public int SpcnCommPosForNetCancel(string sReqMsg, string sResMsg, ref string sRecvData) + { + int nReturn = -99; + + try + { + byte[] bytReqMsg = Encoding.Default.GetBytes(sReqMsg); + byte[] bytResMsg = Encoding.Default.GetBytes(sResMsg); + byte[] bytOutput = new byte[2049]; + + sRecvData = string.Empty; + Array.Clear(bytOutput, 0, bytOutput.Length); + +#if !DEVICE_MSR_VER + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.ICReader.UseYn == false) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0389); + return nReturn; + } + if (m_cDevStatus.ICReader.Integrity_IC_Status != true) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0386); + return nReturn; + } + + nReturn = SpcnReversal(bytReqMsg, bytResMsg, Encoding.Default.GetBytes(AuthInfo_IC.ToString()), bytOutput); +#else + if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + { + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.ICReader.UseYn == false) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0389); + return nReturn; + } + if (m_cDevStatus.ICReader.Integrity_IC_Status != true) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0386); + return nReturn; + } + + nReturn = SpcnReversal(bytReqMsg, bytResMsg, Encoding.Default.GetBytes(AuthInfo_IC.ToString()), bytOutput); + } + else + { + // MSR 망취소 함수 확인 필요 + //nReturn = SpcnReversal(bytReqMsg, bytResMsg, Encoding.Default.GetBytes(AuthInfo_IC.ToString()), bytOutput); + } +#endif + + if (nReturn < 0) //승인실퍠 + { + //실패경우 + sRecvData = ErrCodeToMsg(nReturn); + } + else + { + sRecvData = ByteToString(bytOutput); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 nReturn; + } + + /// + /// RF 카드 정보 요청 + /// + /// + /// + /// + /// + /// + /// + /// + public bool GetRfCreditCardInfo(string sSamType, string sAmount, string sMsg1, string sMsg2, string sMsg3, ref string sRsltMsg) + { + int iRtn = 0; + bool bRtn = false; + byte[] outMsg = new byte[2049]; + + try + { + sRsltMsg = string.Empty; + Array.Clear(outMsg, 0x0, outMsg.Length); + + DeviceStatus m_cDevStatus = (DeviceStatus)StateObject.DEVICE; + if (m_cDevStatus.SignPad.UseYn != true) + { + sRsltMsg = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0390); + return false; + } + +#if !DEVICE_MSR_VER + if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + { + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true) + { + //#20171208, RF버튼 선택 시에만 서명패드 무결성 체크하도록 수정 Start + //sRsltMsg = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0387); + sRsltMsg = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0385); + //#20171208, RF버튼 선택 시에만 서명패드 무결성 체크하도록 수정 End + return false; + } + } + + // 터미널 ID가져오기 + string sTerminalNo = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.CREDITCARD_ITEM, ItemConst.TR_ITEM_ID.CREDITCARD.CREDIT_CARD, PosMst.MST_VAN.DATA.APPR_ID); + + byte[] bytTerminalNo = Encoding.Default.GetBytes(sTerminalNo); + byte[] bytSamType = Encoding.Default.GetBytes(sSamType); + byte[] bytAmount = Encoding.Default.GetBytes(sAmount); + byte[] bytsMsg1 = Encoding.Default.GetBytes(sMsg1); + byte[] bytsMsg2 = Encoding.Default.GetBytes(sMsg2); + byte[] bytsMsg3 = Encoding.Default.GetBytes(sMsg3); + + iRtn = SpcnRfCreditCardInfo(bytTerminalNo, bytSamType, bytAmount, bytsMsg1, bytsMsg2, bytsMsg3, outMsg); + if (iRtn <= 0) + { + if (iRtn != -84) + { + string sErrMsg = ErrCodeToMsg(iRtn); + Cosmos.CommonManager.WinManager.ErrorMessage(sErrMsg); + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + iRtn + "=" + sErrMsg); + } + return false; + } + + //카드번호 뒷 4자리 *로 치환 - 여전법대응! + if (outMsg.Length > 526) + { + for (int iRow = 526; iRow < 530; iRow++) + { + if (outMsg[iRow] != ((byte)0x20)) //스페이스 아니면! + { + outMsg[iRow] = (byte)0x2A; //*로 치환 + } + } + } + + ByteToString(outMsg, ref sRsltMsg); + bRtn = true; +#else + if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + { + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true) + { + sRsltMsg = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0387); + return false; + } + + } + // 터미널 ID가져오기 + string sTerminalNo = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.CREDITCARD_ITEM, ItemConst.TR_ITEM_ID.CREDITCARD.CREDIT_CARD, PosMst.MST_VAN.DATA.APPR_ID); + + byte[] bytTerminalNo = Encoding.Default.GetBytes(sTerminalNo); + byte[] bytSamType = Encoding.Default.GetBytes(sSamType); + byte[] bytAmount = Encoding.Default.GetBytes(sAmount); + byte[] bytsMsg1 = Encoding.Default.GetBytes(sMsg1); + byte[] bytsMsg2 = Encoding.Default.GetBytes(sMsg2); + byte[] bytsMsg3 = Encoding.Default.GetBytes(sMsg3); + + if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + iRtn = SpcnRfCreditCardInfo(bytTerminalNo, bytSamType, bytAmount, bytsMsg1, bytsMsg2, bytsMsg3, outMsg); + else + iRtn = SpcnRfCreditCardInfoEx(bytTerminalNo, bytSamType, bytAmount, bytsMsg1, bytsMsg2, bytsMsg3, outMsg); + if (iRtn <= 0) + { + if (iRtn != -84) + { + string sErrMsg = ErrCodeToMsg(iRtn); + Cosmos.CommonManager.WinManager.ErrorMessage(sErrMsg); + + UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + iRtn + "=" + sErrMsg); + } + return false; + } + + string sTempData = ByteToString(outMsg); + + //미인증 데이터 인증 데이터 포멧으로 변환 + //카드구분(1)+카드방식(1)+신용Track데이터(40)+포인트Track데이터(42)+IC Chip 데이터(512) + //카드구분(1)+카드방식(1)+카드정보(512)+마스킹카드번호(40)+서비스코드(5)+포인트카드정보(512)+포인트마스킹(40)+포인트서비스코드(5)+IC CHIP(512)+삼성페이 서비스(40) + + sRsltMsg = CmUtil.LeftH(CmUtil.MidH(sTempData, 0, 42), 514); + sRsltMsg += CmUtil.LeftH(CmUtil.MidH(sTempData, 2, 6) + (CmUtil.MidH(sTempData, 8, 10).Replace("=", "").Trim().Length == 9 ? "*********" : "**********"), 40); + sRsltMsg += CmUtil.LeftH(CmUtil.MidH(sTempData, 34, 5), 5); + sRsltMsg += CmUtil.LeftH("", 557); + sRsltMsg += CmUtil.LeftH(CmUtil.MidH(sTempData, 84, 512), 512); + sRsltMsg += CmUtil.LeftH(CmUtil.MidH(sTempData, 42, 40), 40); + + + ////카드번호 뒷 4자리 *로 치환 - 여전법대응! + //if (outMsg.Length > 526) + //{ + // for (int iRow = 526; iRow < 530; iRow++) + // { + // if (outMsg[iRow] != ((byte)0x20)) //스페이스 아니면! + // { + // outMsg[iRow] = (byte)0x2A; //*로 치환 + // } + // } + + // if (m_cDevStatus.ICReader.UseYn != true) // 여전법 인증여부(0:MSR, 1:IC) + // { + // for (int iRow = 0; iRow < 16; iRow++) + // { + // if (iRow >= 0 && iRow < 6) + // outMsg[514 + iRow] = outMsg[2 + iRow]; // 카드 bin + // else if (iRow >= 6 && iRow < 16) + // outMsg[514 + iRow] = (byte)0x2A; // 7~16 *로 변환 + // } + + // for (int iRow = 34; iRow < 40; iRow++) + // { + // outMsg[555 + (iRow-35)] = outMsg[iRow]; // 서비스 코드 + // } + + // } + //} + + //ByteToString(outMsg, ref sRsltMsg); + bRtn = true; +#endif + } + catch (Exception ex) + { + sRsltMsg = string.Empty; + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + //20171013 dkshin 해피기프트(신) IC/RF 충전 및 승인 + /// + /// RF 코나머니카드 정보 요청 + /// + /// + /// + /// + /// + /// + /// + /// + public bool GetRfEtcCardInfo(string sSamType, string sAmount, string sMsg1, string sMsg2, string sMsg3, ref string sRsltMsg) + { + int iRtn = 0; + bool bRtn = false; + byte[] outMsg = new byte[2049]; + + try + { + sRsltMsg = string.Empty; + Array.Clear(outMsg, 0x0, outMsg.Length); + + DeviceStatus m_cDevStatus = (DeviceStatus)StateObject.DEVICE; + if (m_cDevStatus.SignPad.UseYn != true) + { + sRsltMsg = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0390); + return false; + } + +#if !DEVICE_MSR_VER + if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + { + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true) + { + //#20171208, RF버튼 선택 시에만 서명패드 무결성 체크하도록 수정 Start + //sRsltMsg = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0387); + sRsltMsg = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0385); + //#20171208, RF버튼 선택 시에만 서명패드 무결성 체크하도록 수정 End + return false; + } + } + + // 터미널 ID가져오기 + string sTerminalNo = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.CREDITCARD_ITEM, ItemConst.TR_ITEM_ID.CREDITCARD.CREDIT_CARD, PosMst.MST_VAN.DATA.APPR_ID); + + byte[] bytTerminalNo = Encoding.Default.GetBytes(sTerminalNo); + byte[] bytSamType = Encoding.Default.GetBytes(sSamType); + byte[] bytAmount = Encoding.Default.GetBytes(sAmount); + byte[] bytsMsg1 = Encoding.Default.GetBytes(sMsg1); + byte[] bytsMsg2 = Encoding.Default.GetBytes(sMsg2); + byte[] bytsMsg3 = Encoding.Default.GetBytes(sMsg3); + + iRtn = SpcnRfEtcCardInfo(bytTerminalNo, bytSamType, bytAmount, bytsMsg1, bytsMsg2, bytsMsg3, outMsg); + if (iRtn <= 0) + { + if (iRtn != -84) + { + string sErrMsg = ErrCodeToMsg(iRtn); + Cosmos.CommonManager.WinManager.ErrorMessage(sErrMsg); + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + iRtn + "=" + sErrMsg); + } + return false; + } + + //카드번호 뒷 4자리 *로 치환 - 여전법대응! + if (outMsg.Length > 526) + { + for (int iRow = 526; iRow < 530; iRow++) + { + if (outMsg[iRow] != ((byte)0x20)) //스페이스 아니면! + { + outMsg[iRow] = (byte)0x2A; //*로 치환 + } + } + } + + ByteToString(outMsg, ref sRsltMsg); + bRtn = true; +#else + if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + { + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true) + { + sRsltMsg = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0387); + return false; + } + + } + // 터미널 ID가져오기 + string sTerminalNo = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.CREDITCARD_ITEM, ItemConst.TR_ITEM_ID.CREDITCARD.CREDIT_CARD, PosMst.MST_VAN.DATA.APPR_ID); + + byte[] bytTerminalNo = Encoding.Default.GetBytes(sTerminalNo); + byte[] bytSamType = Encoding.Default.GetBytes(sSamType); + byte[] bytAmount = Encoding.Default.GetBytes(sAmount); + byte[] bytsMsg1 = Encoding.Default.GetBytes(sMsg1); + byte[] bytsMsg2 = Encoding.Default.GetBytes(sMsg2); + byte[] bytsMsg3 = Encoding.Default.GetBytes(sMsg3); + + //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start + //if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + // iRtn = SpcnRfCreditCardInfo(bytTerminalNo, bytSamType, bytAmount, bytsMsg1, bytsMsg2, bytsMsg3, outMsg); + //else + // iRtn = SpcnRfCreditCardInfoEx(bytTerminalNo, bytSamType, bytAmount, bytsMsg1, bytsMsg2, bytsMsg3, outMsg); + + iRtn = SpcnRfEtcCardInfo(bytTerminalNo, bytSamType, bytAmount, bytsMsg1, bytsMsg2, bytsMsg3, outMsg); + //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End + + if (iRtn <= 0) + { + if (iRtn != -84) + { + string sErrMsg = ErrCodeToMsg(iRtn); + Cosmos.CommonManager.WinManager.ErrorMessage(sErrMsg); + + UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + iRtn + "=" + sErrMsg); + } + return false; + } + + //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 Start + // 기존 + //string sTempData = ByteToString(outMsg); + + //미인증 데이터 인증 데이터 포멧으로 변환 + //카드구분(1)+카드방식(1)+신용Track데이터(40)+포인트Track데이터(42)+IC Chip 데이터(512) + //카드구분(1)+카드방식(1)+카드정보(512)+마스킹카드번호(40)+서비스코드(5)+포인트카드정보(512)+포인트마스킹(40)+포인트서비스코드(5)+IC CHIP(512)+삼성페이 서비스(40) + + //sRsltMsg = CmUtil.LeftH(CmUtil.MidH(sTempData, 0, 42), 514); + //sRsltMsg += CmUtil.LeftH(CmUtil.MidH(sTempData, 2, 6) + (CmUtil.MidH(sTempData, 8, 10).Replace("=", "").Trim().Length == 9 ? "*********" : "**********"), 40); + //sRsltMsg += CmUtil.LeftH(CmUtil.MidH(sTempData, 34, 5), 5); + //sRsltMsg += CmUtil.LeftH("", 557); + //sRsltMsg += CmUtil.LeftH(CmUtil.MidH(sTempData, 84, 512), 512); + //sRsltMsg += CmUtil.LeftH(CmUtil.MidH(sTempData, 42, 40), 40); + + // 변경 + if (outMsg.Length > 526) + { + for (int iRow = 526; iRow < 530; iRow++) + { + if (outMsg[iRow] != ((byte)0x20)) //스페이스 아니면! + { + outMsg[iRow] = (byte)0x2A; //*로 치환 + } + } + } + + ByteToString(outMsg, ref sRsltMsg); + //#20171129, 해피기프트(신) MS매장 RF카드 IC승인되도록 수정 End + bRtn = true; +#endif + } + catch (Exception ex) + { + sRsltMsg = string.Empty; + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + /// + /// SPC 사원 카드 정보 읽기 + /// + /// + /// + public bool GetSpcEmpCardInfo(ref string sRsltMsg) + { + int iRtn = 0; + bool bRtn = false; + byte[] outMsg = new byte[2049]; + + try + { + sRsltMsg = string.Empty; + Array.Clear(outMsg, 0x0, outMsg.Length); + + DeviceStatus m_cDevStatus = (DeviceStatus)StateObject.DEVICE; + if (m_cDevStatus.SignPad.UseYn != true) + { + sRsltMsg = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0390); + return false; + } + +//#if !DEVICE_MSR_VER +// // 무결성 실패후 진행시 오류 메시지 표시 +// if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true) +// { +// sRsltMsg = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0387); +// return false; +// } +//#else +// if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) +// { +// // 무결성 실패후 진행시 오류 메시지 표시 +// if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true) +// { +// sRsltMsg = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0387); +// return false; +// } +// } +//#endif + iRtn = SpcnRfEmployeeCardInfo(outMsg); + if (iRtn > 0) + { + ByteToString(outMsg, ref sRsltMsg); + bRtn = true; + } + else + { + if (iRtn != -84) + { + string sErrMsg = ErrCodeToMsg(iRtn); + Cosmos.CommonManager.WinManager.ErrorMessage(sErrMsg); + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + iRtn + "=" + sErrMsg); + } + sRsltMsg = string.Empty; + } + } + catch (Exception ex) + { + sRsltMsg = string.Empty; + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + /// + /// 선불카드 조회 + /// + /// + public bool RfPrepaidCardInfo(ref string sRsltMsg) + { + int iRtn = 0; + bool bRtn = false; + byte[] outMsg = new byte[2049]; + + try + { + sRsltMsg = string.Empty; + Array.Clear(outMsg, 0x0, outMsg.Length); + + DeviceStatus m_cDevStatus = (DeviceStatus)StateObject.DEVICE; + if (m_cDevStatus.SignPad.UseYn != true) + { + sRsltMsg = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0390); + return false; + } +//#if !DEVICE_MSR_VER +// // 무결성 실패후 진행시 오류 메시지 표시 +// if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true) +// { +// sRsltMsg = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0387); +// return false; +// } +//#else +// if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) +// { +// // 무결성 실패후 진행시 오류 메시지 표시 +// if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true) +// { +// sRsltMsg = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0387); +// return false; +// } +// } +//#endif + iRtn = SpcnRfPrepaidCardInfo(outMsg); + if (iRtn > 0) + { + ByteToString(outMsg, ref sRsltMsg); + bRtn = true; + } + else + { + if (iRtn != -84) + { + string sErrMsg = ErrCodeToMsg(iRtn); + Cosmos.CommonManager.WinManager.ErrorMessage(sErrMsg); + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + iRtn + "=" + sErrMsg); + } + return false; + } + } + catch (Exception ex) + { + sRsltMsg = string.Empty; + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + /// + /// IC 콜백 요청 + /// + /// + /// + public bool RegIcCallback(PosOLEDevice.DelegateIcReader delegateReader) + { + try + { + // return true; // 콜백 제거(2017.05.15) +#if !DEVICE_MSR_VER + if (m_cDevStatus.ICReader.UseYn == false) return false; + if (m_cDevStatus.ICReader.Integrity_IC_Status != true && m_cDevStatus.ICReader.UseYn == true) return false; + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "SpcnRegIcCallback.Start"); + + GCHandle gch = GCHandle.Alloc(delegateReader); + IntPtr intptr_delegate = Marshal.GetFunctionPointerForDelegate(delegateReader); + SpcnStopProcess(0); + SpcnRegIcCallback(intptr_delegate); + gch.Free(); + + m_bIcReaderCallBack = true; + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "SpcnRegIcCallback.Success"); +#else + if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + { + if (m_cDevStatus.ICReader.UseYn == false) return false; + if (m_cDevStatus.ICReader.Integrity_IC_Status != true && m_cDevStatus.ICReader.UseYn == true) return false; + + GCHandle gch = GCHandle.Alloc(delegateReader); + IntPtr intptr_delegate = Marshal.GetFunctionPointerForDelegate(delegateReader); + SpcnRegIcCallback(intptr_delegate); + gch.Free(); + + m_bIcReaderCallBack = true; + } +#endif + return true; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 false; + } + + /// + /// IC 콜백 해지 + /// + /// + public bool UnRegIcCallback() + { + try + { + // return true; // 콜백 제거(2017.05.15) +#if !DEVICE_MSR_VER + if (m_cDevStatus.ICReader.UseYn == false) return false; + if (m_bIcReaderCallBack == false) return false; + //if (m_cDevStatus.ICReader.Integrity_IC_Status != true && m_cDevStatus.ICReader.UseYn == true) return false; + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "SpcnUnRegIcCallback.Start"); + + SpcnUnRegIcCallback(); + + m_bIcReaderCallBack = false; + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "SpcnUnRegIcCallback.Success"); +#else + if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + { + if (m_cDevStatus.ICReader.UseYn == false) return false; + if (m_cDevStatus.ICReader.Integrity_IC_Status != true && m_cDevStatus.ICReader.UseYn == true) return false; + + SpcnUnRegIcCallback(); + + m_bIcReaderCallBack = false; + } +#endif + return true; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 false; + } + + + /// + /// IC 콜백 설정 + /// + /// + public bool IcReaderSettingDevice(bool bEnable) + { + try + { + // return true; // 콜백 제거(2017.05.15) +#if !DEVICE_MSR_VER + if (m_cDevStatus.ICReader.UseYn == false) return false; + if (m_cDevStatus.ICReader.Integrity_IC_Status != true && m_cDevStatus.ICReader.UseYn == true) return false; + + StringBuilder a = new StringBuilder(); + StringBuilder b = new StringBuilder(); + byte[] by_a = new byte[3]; + byte[] by_b = new byte[3]; + int rc = 0; + + if (bEnable == true) + { + a.Append("U1"); + b.Append("1"); + } + else + { + a.Append("U1"); + b.Append("0"); + } + + by_a = System.Text.Encoding.UTF8.GetBytes(a.ToString()); + by_b = System.Text.Encoding.UTF8.GetBytes(b.ToString()); + + rc = SpcnIcReaderSettingDevice(by_a, by_b); +#else + if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + { + if (m_cDevStatus.ICReader.UseYn == false) return false; + if (m_cDevStatus.ICReader.Integrity_IC_Status != true && m_cDevStatus.ICReader.UseYn == true) return false; + + StringBuilder a = new StringBuilder(); + StringBuilder b = new StringBuilder(); + byte[] by_a = new byte[3]; + byte[] by_b = new byte[3]; + int rc = 0; + + if (bEnable == true) + { + a.Append("U1"); + b.Append("1"); + } + else + { + a.Append("U1"); + b.Append("0"); + } + + by_a = System.Text.Encoding.UTF8.GetBytes(a.ToString()); + by_b = System.Text.Encoding.UTF8.GetBytes(b.ToString()); + + rc = SpcnIcReaderSettingDevice(by_a, by_b); + } +#endif + return true; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 false; + } + + /// + /// 문자열을 바이트열로 변환 + /// + /// + /// + private byte[] GetByteArrayFromString(string src) + { + return System.Text.Encoding.Default.GetBytes(src); + } + + /// + /// 응답코드 + /// + /// + /// + private string ErrCodeToMsg(int nErrCode) + { + string sMsg = string.Empty; + + try + { + switch (nErrCode) + { + case -3: sMsg = "암호화오류(전문생성오류)"; break; + case -4: sMsg = "암호화오류(전문생성오류)"; break; + case -5: sMsg = "암호화오류 (전문오류)"; break; + case -6: sMsg = "암호화오류 (전문오류)"; break; + case -7: sMsg = "암호화오류 (키생성)"; break; + case -8: sMsg = "암호화오류 (키생성)"; break; + case -9: sMsg = "암호화오류 (키생성)"; break; + case -10: sMsg = "요청 IP 오류"; break; + case -11: sMsg = "암호화 구분 2 붙인 전문 오류"; break; + case -12: sMsg = "전자서명 전문일 경우 전문길이 필드 없는 오류"; break; + case -13: sMsg = "전자서명 전문일 경우 전문길이 필드 없는 오류"; break; + case -14: sMsg = "전문 전체길이 체크 오류"; break; + case -15: sMsg = "파라미터 오류 (접속 IP 오류)"; break; + case -16: sMsg = "파라미터 오류 (요청전문 오류)"; break; + case -17: sMsg = "전자서명 암호화 오류"; break; + case -18: sMsg = "개시거래 요망"; break; + case -20: sMsg = "SOCKET CONNECT 오류"; break; + case -21: sMsg = "SOCKET SELECT 오류"; break; + case -22: sMsg = "SOCKET RECV SELECT 오류"; break; + case -23: sMsg = "SOCKET RECV SELECT 오류"; break; + case -24: sMsg = "SOCKET RECV 오류"; break; + case -25: sMsg = "SOCKET RECV 오류"; break; + case -26: sMsg = "SOCKET SEND 오류"; break; + case -30: sMsg = "전문오류 (전자서명 필요없는 거래)"; break; + case -31: sMsg = "전문오류 (전자서명 데이터 구조 오류)"; break; + case -32: sMsg = "전문오류 (CR 없음)"; break; + case -33: sMsg = "전문오류 (ETX 없음)"; break; + case -34: sMsg = "전문오류(FS2 없음)"; break; + case -35: sMsg = "전자서명오류 (암호화 오류)"; break; + case -36: sMsg = "전자서명 길이 오류 (모바일)"; break; + case -37: sMsg = "IC데이터 오류 (FS오류)"; break; + case -38: sMsg = "IC데이터 오류(IC데이터/등록정보 오류)"; break; + case -40: sMsg = "EOT 미수신 (수신X)"; break; + case -41: sMsg = "EOT 미수신 (수신오류)"; break; + case -42: sMsg = "SOCKET 초기화 오류"; break; + case -43: sMsg = "SOCKET CONNECT 오류"; break; + case -44: sMsg = "SOCKET SEND 오류 (암호화)"; break; + case -45: sMsg = "SOCKET SEND 오류 (전문)"; break; + case -46: sMsg = "SOCKET RECV 오류 (헤더)"; break; + case -47: sMsg = "SOCKET RECV 오류 (전문)"; break; + case -48: sMsg = "SOCKET RECV 오류 (암호화)"; break; + case -49: sMsg = "SOCKET RECV 오류 (CHECK)"; break; + case -50: sMsg = "SOCKET SEND 오류 (ACK)"; break; + case -60: sMsg = "(모바일)SOCKET 생성 오류"; break; + case -61: sMsg = "(모바일)SOCKET CONNECT 오류"; break; + case -62: sMsg = "(모바일)SOCKET SELECT 오류"; break; + case -63: sMsg = "(모바일)SOCKET 옵션 설정 오류"; break; + case -64: sMsg = "(모바일)SOCKET 옵션 설정 오류"; break; + case -65: sMsg = "(모바일)SOCKET 오류"; break; + case -66: sMsg = "(모바일)SOCKET RECV 오류"; break; + case -67: sMsg = "(모바일)SOCKET RECV SELECT 오류"; break; + case -68: sMsg = "(모바일)SOCKET RECV SELECT 오류"; break; + case -69: sMsg = "(모바일)SOCKET SEND 오류"; break; + case -70: sMsg = "(모바일)SOCKET SEND SELECT 오류"; break; + case -79: sMsg = "시리얼 클래스 생성 오류"; break; + case -80: sMsg = "INI 파일 오류 (TYPE 구분 설정요망)"; break; + case -81: sMsg = "싸인패드 포트 오류"; break; + case -82: sMsg = "싸인패드 포트 오류"; break; + case -83: sMsg = "싸인패드 통신 오류"; break; + case -84: sMsg = "싸인패드 사용자 취소"; break; + case -85: sMsg = "싸인패드 타임아웃 오류"; break; + case -86: sMsg = "싸인패드 오픈 오류"; break; + case -87: sMsg = "싸인패드 초기화 오류"; break; + case -88: sMsg = "싸인패드 요청 오류"; break; + case -89: sMsg = "싸인패드 통신 오류"; break; + case -90: sMsg = "요청전문오류 (헤더 메시지 길이 오류)"; break; + case -91: sMsg = "요청전문오류 (거래구분 코드 오류)"; break; + case -92: sMsg = "미지원 전문"; break; + case -93: sMsg = "요청전문 필수 항목 누락"; break; + case -94: sMsg = "버퍼 초과"; break; + case -95: sMsg = "핀블럭 길이 오류"; break; + case -96: sMsg = "(전자서명생성) 이미지 파일 미존재"; break; + case -97: sMsg = "(전자서명생성) 이미지 파일 읽기 오류"; break; + case -98: sMsg = "(전자서명생성) 이미지 파일 크기 오류"; break; + case -99: sMsg = "(전자서명생성) 이미지 파일 데이터 오류"; break; + case -101: sMsg = "IC리더기 포트 설정 오류"; break; + case -102: sMsg = "IC리더기 오픈 오류"; break; + case -103: sMsg = "IC리더기 시리얼 생성 오류"; break; + case -104: sMsg = "IC리더기 파라미터 오류"; break; + case -105: sMsg = "IC리더기 쓰기 오류"; break; + case -106: sMsg = "보안표준키 다운로드 항목 오류(K2)"; break; + case -107: sMsg = "보안표준키 다운로드 승인 거절(K2)"; break; + case -108: sMsg = "보안표준키 다운로드 항목 오류(K4)"; break; + case -109: sMsg = "보안표준키 다운로드 승인 거절(K4)"; break; + case -110: sMsg = "IC리더기 응답 오류(Class 생성 오류)"; break; + case -111: sMsg = "IC리더기 응답 오류(길이 정보 수신 오류)"; break; + case -112: sMsg = "IC리더기 응답 오류(STX 오류)"; break; + case -113: sMsg = "IC리더기 응답 오류(수신 오류)"; break; + case -114: sMsg = "IC리더기 응답전문 오류(STX 오류)"; break; + case -115: sMsg = "IC리더기 응답전문 오류(ETX 오류)"; break; + case -116: sMsg = "IC리더기 응답전문 오류(LRC 오류)"; break; + case -117: sMsg = "IC리더기 초기화 오류"; break; + case -118: sMsg = "IC리더기 사용자 취소"; break; + case -119: sMsg = "IC리더기 타임아웃 오류"; break; + case -120: sMsg = "IC리더기 통신 오류"; break; + case -121: sMsg = "카드발급사 인증요청 IC CHIP DATA 오류"; break; + case -122: sMsg = "카드발급사 인증요청 데이터 오류"; break; + case -123: sMsg = "카드발급사 등록제 정보 데이터 오류"; break; + case -124: sMsg = "카드발급사 응답전문 데이터 오류"; break; + case -125: sMsg = "카드발급사 전문 구분 데이터 오류"; break; + case -126: sMsg = "카드발급사 전문버젼 데이터 오류"; break; + case -127: sMsg = "카드발급사 응답전문 미승인 오류"; break; + case -128: sMsg = "카드발급사 응답전문 GS 데이터 오류"; break; + case -129: sMsg = "카드발급사 인증 거절 (망취소 거절) - POS 망취소 요망"; break; + case -130: sMsg = "카드발급사 인증 거절 (망취소 완료)"; break; + case -131: sMsg = "망취소 실패(GS 없음) - POS에서 망취소 요망"; break; + case -132: sMsg = "망취소 실패(서버 거절) - POS에서 망취소 요망"; break; + case -133: sMsg = "망취소 실패(통신오류) - POS에서 망취소 요망"; break; + case -134: sMsg = "망취소 대상 아님"; break; + case -140: sMsg = "IC리더기 카드 읽기 오류 (거래매체 유형 미지정 오류)"; break; + case -141: sMsg = "IC리더기 카드 읽기 오류 (거래매체 유형 예외 오류)"; break; + case -142: sMsg = "IC리더기 카드 읽기 오류 (IC거래 구분 오류)"; break; + case -143: sMsg = "IC리더기 거래중 카드 제거 오류"; break; + case -144: sMsg = "IC리더기 거래가 거절된 카드 오류"; break; + case -145: sMsg = "IC리더기 기타 오류"; break; + case -146: sMsg = "IC리더기 거래 요청 전 카드 삽입 오류"; break; + case -147: sMsg = "IC리더기 상호인증 미완료 후 거래 시도 오류"; break; + case -148: sMsg = "IC리더기 무결성 미성공 후 거래 시도 오류"; break; + case -149: sMsg = "IC리더기 에러 코드 발생 오류"; break; + case -150: sMsg = "IC리더기 Fallback 진행 오류"; break; + case -151: sMsg = "IC리더기 거래 중 오류 (비정상 응답)"; break; + case -161: sMsg = "IC 거래 진행 중"; break; + case -162: sMsg = "SIGNPAD 거래 진행 중"; break; + case -2243: sMsg = "여러장의 카드가 입력됨"; break; + case -2150: sMsg = "지원 불가 카드입니다."; break; + default: sMsg = "정의되어 있지 않은 메세지" + "[" + nErrCode + "]"; break; + } + + //sMsg = string.Format("ErrCd:{0} Desc:{1}", nErrCode, sMsg); + } + catch { } + return sMsg; + } + #endregion + + #region 카드번호 첫자리와 끝자리 체크하여 문자인 경우 스페이스로 치환 + /// + /// 카드번호 첫자리와 끝자리 체크하여 문자인 경우 스페이스로 치환 + /// + /// + /// + + //#20171024 START, PHJ + //기존 + //private string MSR_CardNoCheck(string sCardNo, string sValidDate, ref string sInputType) + + //변경 + private string MSR_CardNoCheck(string sCardNo, string sValidDate, ref string sInputType, string sPayWayCd = "", string sPayDtlCd = "") + //#20171024 END, PHJ + + { + string sRet = ""; + string sFirst = CmUtil.MidH(sCardNo, 0, 1); + string sLast = CmUtil.MidH(sCardNo, CmUtil.LenH(sCardNo.Trim()) - 1, 1); + + try + { + if (sFirst.Contains("^") == true) + return ""; + else if (sFirst.Contains("%") == true) + return ""; + + sCardNo = sCardNo.Trim(); + + if (sFirst.Contains(m_cDevStatus.Msr.STX) == true && m_cDevStatus.Msr.STX.Trim() != "") + { + // 첫자리가 ;, ? 경우 치환 + sCardNo = CmUtil.MidH(sCardNo, 1, CmUtil.LenH(sCardNo.Trim())); + } + else if (CmUtil.IsNumber(sFirst) != true) + { + // 첫자리가 숫자가 아닌 경우 치환 + sCardNo = CmUtil.MidH(sCardNo, 1, CmUtil.LenH(sCardNo.Trim())); + } + + if (sLast.Contains(m_cDevStatus.Msr.ETX) == true && m_cDevStatus.Msr.ETX.Trim() != "") + { + // 끝자리가 ? 경우 치환 + sCardNo = CmUtil.MidH(sCardNo, 0, CmUtil.LenH(sCardNo.Trim()) - 1); + } + + if (sCardNo.IndexOf("=") > 0) + { + if (sCardNo.Trim().Length >= 37) + sCardNo = CmUtil.MidH(sCardNo, 0, 37); + + sInputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP; + } + else if (sValidDate != null && sValidDate.Trim() != "") + { + sCardNo = sCardNo + "=" + sValidDate; + sInputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN; + } + else + { + //#20171024 START, PHJ + //기존 + //sInputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN; + + //변경 + if ( + (m_sPAY_WAY_CD == ItemConst.TR_ITEM_ID.ETC_INFO_ITEM) && + (m_sPAY_DTL_CD == ItemConst.TR_ITEM_ID.ETC_INFO.CASHBILL) && + (sCardNo.Length >= 16) && + (sCardNo.StartsWith(PosConst.HP_CARD_PRIFIX))) + { + sInputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP; + sCardNo = CmUtil.MidH(sCardNo, 0, 16); + + m_sPAY_WAY_CD = ""; + m_sPAY_DTL_CD = ""; + } + else + { + sInputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN; + } + //#20171024 END, PHJ + } + + sRet = sCardNo; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 IC리더기 펌웨어 업데이트 요청 + /// + /// IC리더기 펌웨어 업데이트 요청 + /// + /// + /// + /// + /// + /// + /// + public bool SetDE_DownloadFW(int checkfwtout, int downfwtout, int nPort, byte[] DllCheck, ref string sMsg) + { + int iRtn = 0; + bool bRtn = false; + + try + { + if (m_cDevStatus.ICReader.UseYn == false) return true; + + // IC리더기 펌웨어 업데이트 요청 + iRtn = DE_DownloadFW(checkfwtout, downfwtout, nPort, DllCheck); + + // 응답값 + sMsg = GetReturn_DE_DownloadFW(iRtn); + + // 업데이트 성공 또는 업데이트 필요없으면 정상 리턴 + if (iRtn == 1000 || iRtn == 1001) bRtn = true; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 + "\n" + sMsg ); + } + + return bRtn; + } + + //#20171016 IC리더기 펌웨어 업데이트 Start, srlee + /// + /// IC 리더기 펌웨어 업데이트_NEW + /// + /// + /// + /// + /// + /// + public int SetDE_FWDOWN(int nPort, int nBaud, byte[] filepath, IntPtr callBackFunc) + { + int iRtn = -99; + byte[] cPW = Encoding.UTF8.GetBytes("FC28CCCE3C301E274E135435C54A46CC"); + + try + { + DE_CallBackFunReg(callBackFunc); + + // IC리더기 펌웨어 업데이트 요청 + iRtn = DE_FWDOWN(nPort, nBaud, cPW, filepath); + + if (iRtn != 0) // 0:정상 + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ICREADER FW ERROR => CODE : " + iRtn); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 iRtn; + } + //#20171016 IC리더기 펌웨어 업데이트 End, srlee + #endregion + + #region IC리더기 펌웨어 업데이트 상태 응답값 + /// + /// IC리더기 펌웨어 업데이트 상태 응답값 + /// + /// + /// + private string GetReturn_DE_DownloadFW(int ret) + { + string sMsg = ""; + try + { + switch (ret) + { + case 1000: + sMsg = "성공하였습니다."; + break; + case 1001: + sMsg = "업데이트가 필요없습니다."; + break; + case 1002: + sMsg = "업데이트가 필요합니다."; + break; + case 1003: + sMsg = "다운로드 체크 프로그램에서 응답을 못받았습니다."; + break; + case 1005: + sMsg = "다운로드 체크 프로그램에서 응답 받는 환경 생성 실패하였습니다."; + break; + case 1006: + sMsg = "업데이트 프로그램이 실행 안되어있습니다."; + break; + case 1: + sMsg = "서버에 연결하지 않고 펌웨어 업데이트를 시도하였습니다."; + break; + case 2: + sMsg = "다운로드할 단말기를 못찾았습니다."; + break; + case 3: + sMsg = "FTP 연결에 실패하였습니다."; + break; + case 4: + sMsg = "리더기 정보 및 서버 체크 중입니다."; + break; + case 5: + sMsg = "업데이트 정보 파일 가져오기를 실패하였습니다."; + break; + case 6: + sMsg = "업데이트 할 펌웨어 파일이 없습니다."; + break; + case 7: + sMsg = "업데이트 할 펌웨어 파일 가져오기에 실패하였습니다."; + break; + case 8: + sMsg = "펌웨어 인증에 실패하였습니다.(1)"; + break; + case 9: + sMsg = "펌웨어 인증에 실패하였습니다.(2)"; + break; + case 10: + sMsg = "펌웨어 인증에 실패하였습니다.(3)"; + break; + case 11: + sMsg = "펌웨어 파일의 버전 조회에 실패하였습니다."; + break; + case 12: + sMsg = "BIOS 인증에 실패하였습니다."; + break; + case 13: + sMsg = "펌웨어 파일 읽기에 실패하였습니다."; + break; + case 14: + sMsg = "펌웨어 파일 다운로드 도중에 실패하였습니다."; + break; + case 15: + sMsg = "펌웨어 파일 다운로드 완료 후 실패하였습니다."; + break; + case 16: + sMsg = "펌웨어 파일 다운로드 완료 후 펌웨어 확인에 실패하였습니다."; + break; + case 17: + sMsg = "단말기 포트 연결에 실패하였습니다."; + break; + case 18: + sMsg = "펌웨어 파일 다운로드 중입니다."; + break; + case 19: + sMsg = "잘못된 펌웨어 버전 정보입니다."; + break; + case 20: + sMsg = "서버에서 다운로드 받은 버전과 다운로드 완료한 펌웨어 파일의 버전 정보가 일치하지 않습니다."; + break; + case 21: + sMsg = "서버 확인 로그 파일 저장에 실패하였습니다."; + break; + case 22: + sMsg = "서버 확인 로그 파일 저장에 실패하였습니다."; + break; + case 23: + sMsg = "서버 확인 로그 파일 저장에 실패하였습니다.(년도 폴더 생성 실패)"; + break; + case 24: + sMsg = "서버 확인 로그 파일 저장에 실패하였습니다.(월 폴더 생성 실패)"; + break; + case 25: + sMsg = "다운로드 받은 펌웨어 파일의 버전 확인에 실패하였습니다."; + break; + case 26: + sMsg = "다운로드 도중 타임아웃 실패하였습니다."; + break; + case 27: + sMsg = "이전 버전의 파일이 없습니다."; + break; + case 28: + sMsg = "이전버전 파일 다운로드 도중 실패하였습니다."; + break; + case 29: + sMsg = "펌웨어와 호환되지않는 DLL입니다."; + break; + case 1008: + sMsg = "파일을 실행할 수 없습니다. 관리자에게 문의하십시오."; + break; + case 30: + sMsg = "DualPayUpdater를 실행할 수 없습니다."; + break; + case 31: + sMsg = "이전 버전의 펌웨어 파일이 존재하지 않습니다."; + break; + case 32: + sMsg = "다운받은 펌웨어 파일이 존재하지 않습니다."; + break; + case 33: + sMsg = "이전 버전의 펌웨어 파일의 버전 확인을 실패하였습니다."; + break; + case 1007: + sMsg = "업데이트할 FW 파일이 없습니다."; + break; + case 1009: + sMsg = "이전 버전의 펌웨어 파일이 존재합니다."; + break; + case 34: + sMsg = "업데이트를 하지 않았습니다."; + break; + default: + sMsg = "에러가 발생하였습니다."; + break; + } + } + catch (Exception) + { + + throw; + } + return sMsg; + } + #endregion + + + [DllImport("SpcnPos.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int SpcnIcReaderCardInfo_RegCallback(int tranType, byte[] trmlId, int amount, int timeout_sec, IntPtr callback); + + [DllImport("SpcnPos.dll", CallingConvention = CallingConvention.Cdecl)] + public static extern int SpcnIcReaderCardInfo_UnRegCallback(); + + /// + /// IC 콜백 요청(CARD INFO) + /// + /// + /// + /// + /// + public bool RegIcCallbackCardInfo(string sTmrId, int nCardAmt, PosOLEDevice.CallbackIc delegateIcReader) + { + try + { + if (m_cDevStatus.ICReader.UseYn == false) return false; + if (m_cDevStatus.ICReader.Integrity_IC_Status != true && m_cDevStatus.ICReader.UseYn == true) return false; + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "SpcnIcReaderCardInfo_RegCallback.Start"); + int rc = 0; + GCHandle gch = GCHandle.Alloc(delegateIcReader); + + + + + IntPtr intptr_delegate = Marshal.GetFunctionPointerForDelegate(delegateIcReader); + rc = SpcnIcReaderCardInfo_RegCallback(0, GetByteArrayFromString(sTmrId), nCardAmt, 60, intptr_delegate); + gch.Free(); + + m_bIcReaderCallBack = true; + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "SpcnIcReaderCardInfo_RegCallback.Success"); + + return true; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 false; + } + + /// + /// IC 콜백 해지(CARD INFO) + /// + /// + public bool UnRegIcCallbackCardInfo() + { + try + { + + if (m_cDevStatus.ICReader.UseYn == false) return false; + if (m_bIcReaderCallBack == false) return false; + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "SpcnIcReaderCardInfo_UnRegCallback.Start"); + + int rc = SpcnIcReaderCardInfo_UnRegCallback(); + + m_bIcReaderCallBack = false; + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "SpcnIcReaderCardInfo_UnRegCallback.Success " + rc); + + return true; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 false; + } + } +} diff --git a/Agent/OLEDevice/DeviceLabelPrinter.cs b/Agent/OLEDevice/DeviceLabelPrinter.cs new file mode 100644 index 0000000..e82cde5 --- /dev/null +++ b/Agent/OLEDevice/DeviceLabelPrinter.cs @@ -0,0 +1,582 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel; +using System.IO; +using System.IO.Ports; + +using Cosmos.UserFrame; +using Cosmos.Common; +using Cosmos.CommonManager; + +namespace Cosmos.OLEDevice +{ + public class DeviceLabelPrinter : ILabelPrinterUs + { + /// + /// StateServer Object (StateServer 객체) + /// + public StateServer StateObject = (StateServer)StateServer.GetInstance(); + /// + /// Device 상태 정보 객체 + /// + public DeviceStatus devStatus = null; + + /// + /// Pos 상태 정보 객체 + /// + public PosStatus m_cPosStatus = null; + + /// + /// RS232통신을 위한 시리얼포트 객체 + /// + private SerialPort m_serialPort = null; + + private BackgroundWorker bw = null; + + public DeviceLabelPrinter() + { + try + { + m_cPosStatus = (PosStatus)StateObject.POS; + devStatus = (DeviceStatus)StateObject.DEVICE; + bw = new BackgroundWorker(); + + DeviceInit(); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + } + + private void DeviceInit() + { + devStatus.LabelPrinter.Data = string.Empty; + } + + #region OPEN/CLOSE 처리 함수 + /// + /// 디바이스 OPEN시 처리 함수 + /// + /// + public bool OpenDevice(string sSerialPort, long lBaudrate) + { + bool bRet = false; + try + { + if (m_serialPort != null) + { + //grayber@20180308 라벨프린터 처리, 시리얼 포트 버퍼 초기화 start (주석처리) + //m_serialPort.DiscardInBuffer(); + //m_serialPort.DiscardOutBuffer(); + //grayber@20180308 라벨프린터 처리, 시리얼 포트 버퍼 초기화 end + + m_serialPort.Close(); + System.Threading.Thread.Sleep(50); + m_serialPort = null; + } + + if (m_serialPort == null) + { + m_serialPort = new SerialPort(); + //m_serialPort = new SerialPort(sSerialPort, (int)lBaudrate, Parity.None, 8, StopBits.One); + if (m_serialPort == null) + { + devStatus.LabelPrinter.Open = false; + devStatus.LabelPrinter.Status = "SERIAL PORT ERROR"; + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.LabelPrinter.Status); + return bRet; + } + + m_serialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived); + m_serialPort.PinChanged += new SerialPinChangedEventHandler(serialPort_PinChanged); + m_serialPort.ErrorReceived += new SerialErrorReceivedEventHandler(serialPort_ErrorReceived); + + m_serialPort.NewLine = "\r\n"; + m_serialPort.Encoding = System.Text.Encoding.GetEncoding("ks_c_5601-1987"); + + m_serialPort.WriteBufferSize = 1024 * 1024; + m_serialPort.PortName = sSerialPort; + m_serialPort.BaudRate = (int)lBaudrate; + m_serialPort.DataBits = 8; + m_serialPort.StopBits = StopBits.One; + m_serialPort.Parity = Parity.None; + m_serialPort.Handshake = Handshake.None; + m_serialPort.ReadTimeout = 500; + m_serialPort.WriteTimeout = 2000; + + m_serialPort.Open(); + if (m_serialPort.IsOpen == false) + { + devStatus.LabelPrinter.Open = false; + devStatus.LabelPrinter.Status = "SERIAL PORT OPEN ERROR"; + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.LabelPrinter.Status); + return bRet; + } + + devStatus.LabelPrinter.Open = true; + devStatus.LabelPrinter.Status = "SUCCESS"; + + bw.DoWork += OlePosHandler; + bRet = true; + } + else + { + devStatus.LabelPrinter.Open = false; + devStatus.LabelPrinter.Status = "SERIAL PORT ERROR"; + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.LabelPrinter.Status); + return bRet; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRet; + } + /// + /// 디바이스 CLOSE시 처리 함수 + /// + /// + public bool CloseDevice() + { + bool bRet = false; + try + { + if (m_serialPort == null) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Close fail(m_serialPort == null)"); + return bRet; + } + + //grayber@20180308 라벨프린터 처리, 시리얼 포트 버퍼 초기화 start + m_serialPort.DiscardInBuffer(); + m_serialPort.DiscardOutBuffer(); + //grayber@20180308 라벨프린터 처리, 시리얼 포트 버퍼 초기화 end + + m_serialPort.Close(); + bRet = true; + m_serialPort = null; + devStatus.LabelPrinter.Status = "CLOSE"; + devStatus.LabelPrinter.Open = false; + bw.DoWork -= OlePosHandler; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRet; + } + #endregion + + #region 이벤트 처리 + private void OlePosHandler(object sender, DoWorkEventArgs e) + { + try + { + if (PosOLEDevice.m_delegateOlePos != null) + PosOLEDevice.m_delegateOlePos(PosConst.OPOS_DEVICE.LABELPRINTER, devStatus.Scale.Data, string.Empty, string.Empty); + else + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "이벤트 전송 대상 없음"); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + } + + private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) + { + SerialPort serialPort = (SerialPort)sender; + byte[] bytRecvBuf = new byte[serialPort.BytesToRead]; + + try + { + if (!bw.IsBusy) + { + serialPort.Read(bytRecvBuf, 0, bytRecvBuf.Length); + + bw.RunWorkerAsync(); + } + else + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + "이벤트 처리 전 이벤트 발생 불가"); + } + } + catch (Exception ex) + { + + } + } + + private void serialPort_PinChanged(object sender, SerialPinChangedEventArgs e) + { + throw new NotImplementedException(); + } + + private void serialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e) + { + throw new NotImplementedException(); + } + #endregion + + #region 명령어 처리 함수 + /// + /// 일반 제품정보 라벨 프린터 출력 함수 + /// + /// 제품명(한글) ex)"파인트" + /// 제품명(영문) ex)"Pint" + /// 중량 ex)"340g" + /// 점포명 ex)"양재사옥점" + public void PrintProductWeightInfo(string sProductNm_Ko, string sProductNm_En, string sWeight, string sStoreNm) + { + string[] sCommands = null; + try + { + if (m_cPosStatus.Base.OlePosLabelPrinterModel == PosConst.POS_DEVICE_LIST.LABEL_PRINTER.OLD_TYPE) + { + sCommands = new string[] { "CLL\r\n" // 메모리 클리어 + , "NEW\r\n" // 새로운 명령어 시작 + , "CLIP ON\r\n" + , "NASC 949\r\n" // intermec 한글폰트 설정 + + , "FONT \"HYGothic-Medium\",12\r\n" + , "PRPOS 0,150\r\n" + //grayber@20180308 시리얼 포트 버퍼 초기화 start + //, "PRTXT \"" + sProductNm_Ko + " : " + sWeight + "\"\r\n" + , "PRTXT \"" + sProductNm_Ko + " : " + string.Format( "{0:#,###}",CmUtil.IntParse(sWeight)) + "\"\r\n" + //grayber@20180308 시리얼 포트 버퍼 초기화 end + , "FONT \"HYGothic-Medium\",9\r\n" + , "PRPOS 0,110\r\n" + , "PRTXT \"" + System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "\"\r\n" + + , "PRPOS 0,70\r\n" + //grayber@20180308 시리얼 포트 버퍼 초기화 start + //, "PRTXT \"" + sStoreNm + "\"\r\n" + , "PRTXT \"" + sStoreNm +" 점" + "\"\r\n" + //grayber@20180308 라벨프린터 처리, 시리얼 포트 버퍼 초기화 end + , "PF\r\n" }; + } + else if(m_cPosStatus.Base.OlePosLabelPrinterModel == PosConst.POS_DEVICE_LIST.LABEL_PRINTER.NEW_TYPE) + { + sCommands = new string[] { "SETUP \"MEDIA,MEDIA SIZE,LENGTH,1200\"\r\n" // 용지출력범위 조정 + , "CLL\r\n" // 메모리 클리어 + , "NEW\r\n" // 새로운 명령어 시작 + , "CLIP ON\r\n" + , "NASC 949\r\n" // intermec 한글폰트 설정 + + , "FONT \"HYGothic-Medium\",9\r\n" + , "PRPOS 110,290\r\n" + //grayber@20180308 라벨프린터 처리, 시리얼 포트 버퍼 초기화 start + //, "PRTXT \"" + sStoreNm + "\"\r\n" + , "PRTXT \"" + sStoreNm + " 점" + "\"\r\n" + //grayber@20180308 라벨프린터 처리, 시리얼 포트 버퍼 초기화 end + + , "FONT \"HYGothic-Medium\",5\r\n" + , "PRPOS 110,270\r\n" + , "PRTXT \"" + System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "\"\r\n" + + , "FONT \"HYGothic-Medium\",7\r\n" + , "PRPOS 70,50\r\n" + , "PRTXT \"" + sProductNm_En + "\"\r\n" + + , "FONT \"HYGothic-Medium\",9\r\n" + , "PRPOS 70,20\r\n" + , "PRTXT \"" + sProductNm_Ko + "\"\r\n" + + , "FONT \"HYGothic-Medium\",14\r\n" + , "PRPOS 170,20\r\n" + //grayber@20180308 라벨프린터 처리, 시리얼 포트 버퍼 초기화 start + //, "PRTXT \"" + sWeight + "\"\r\n" + , "PRTXT \"" + string.Format( "{0:#,###}",CmUtil.IntParse(sWeight)) + "\"\r\n" + //grayber@20180308 라벨프린터 처리, 시리얼 포트 버퍼 초기화 end + , "PF\r\n" }; + } + else + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + "Check label printer model configuration."); + return; + } + + if(sCommands != null) + WriteCommand(sCommands); + } + catch(Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + } + + /// + /// 02O(해피오더) 제품정보 라벨 프린터 출력 함수 + /// + /// 제품명 ex)"패밀리" + /// 주문번호 ex)"123456" + /// 중량 ex)"990g" + /// ex) "플레이버1/플레이버2/플레이버3" + /// ex) "플레이버4/플레이버5/플레이버6" + /// 점포명 ex)"양재사옥" + /// 주문시간 ex)"2016-06-23 14:00:00" + /// 포장시간 ex)"2016-06-23 14:20:00" + public void PrintO2OProductInfo(string sProductNm, string sOrderNo, string sWeight, string sContent_1, string sContent_2, string sStoreNm, string sOrderYmdhms, string sPackingYmdhms) + { + string[] sCommands = null; + try + { + if (m_cPosStatus.Base.OlePosLabelPrinterModel == PosConst.POS_DEVICE_LIST.LABEL_PRINTER.OLD_TYPE) + { + sCommands = new string[] { "CLL\r\n" + , "NEW\r\n" + , "CLIP ON\r\n" + , "FONT \"HYGothic-Medium\",12\r\n" + , "NASC 949\r\n" + + , "PRPOS 0,190\r\n" + //grayber@20180308 라벨프린터 처리, 시리얼 포트 버퍼 초기화 start + //, "PRTXT \"" + sProductNm + " / " + sWeight + " (" + sOrderNo + ")\"\r\n" + , "PRTXT \"" + sProductNm + " / " + string.Format( "{0:#,###}", CmUtil.IntParse( sWeight)) + " (" + sOrderNo + ")\"\r\n" + //grayber@20180308 라벨프린터 처리, 시리얼 포트 버퍼 초기화 end + , "FONT \"HYGothic-Medium\",9\r\n" + + , "PRPOS 0,150\r\n" + , "PRTXT \"" + sContent_1 + "\"\r\n" + + , "PRPOS 0,110\r\n" + , "PRTXT \"" + sContent_2 + "\"\r\n" + + , "PRPOS 0,50\r\n" + , "PRTXT \"주문 " + sOrderYmdhms + "\"\r\n" + + , "PRPOS 0,10\r\n" + , "PRTXT \"포장 " + sPackingYmdhms + "\"\r\n" + , "PF\r\n" }; + } + else if (m_cPosStatus.Base.OlePosLabelPrinterModel == PosConst.POS_DEVICE_LIST.LABEL_PRINTER.NEW_TYPE) + { + sCommands = new string[] { "SETUP \"MEDIA,MEDIA SIZE,Length,1200\"\r\n" // 라벨프린터 용지범위 수정 + , "CLL\r\n" // 메모리 클리어 + , "NEW\r\n" // 새로운 명령어 시작 + , "CLIP ON\r\n" + , "NASC 949\r\n" // intermec 한글폰트 설정 + + , "FONT \"HYGothic-Medium\",9\r\n" + , "PRPOS 110,290\r\n" + //grayber@20180308 라벨프린터 처리, 시리얼 포트 버퍼 초기화 start + //, "PRTXT \"" + sStoreNm + "\"\r\n" + , "PRTXT \"" + sStoreNm + " 점" + "\"\r\n" + //grayber@20180308 라벨프린터 처리, 시리얼 포트 버퍼 초기화 end + + , "FONT \"HYGothic-Medium\",5\r\n" + , "PRPOS 90,270\r\n" + , "PRTXT \"주문 " + sOrderYmdhms + "\"\r\n" + + , "PRPOS 90,250\r\n" + , "PRTXT \"포장 " + sPackingYmdhms + "\"\r\n" + + , "FONT \"HYGothic-Medium\",9\r\n" + , "PRPOS 60,200\r\n" + , "PRTXT \"" + sProductNm + "(" + sOrderNo + ")" + "\"\r\n" + + , "FONT \"HYGothic-Medium\",8\r\n" + , "PRPOS 60,170\r\n" + , "PRTXT \"" + sContent_1 + "\"\r\n" + + , "PRPOS 60,150\r\n" + , "PRTXT \"" + sContent_2 + "\"\r\n" + + , "FONT \"HYGothic-Medium\",14\r\n" + , "PRPOS 200,20\r\n" + //grayber@20180308 라벨프린터 처리, 시리얼 포트 버퍼 초기화 start + //, "PRTXT \"" + sWeight + "\"\r\n" + , "PRTXT \"" + string.Format("{0:#,###}", CmUtil.IntParse(sWeight)) + "\"\r\n" + //grayber@20180308 라벨프린터 처리, 시리얼 포트 버퍼 초기화 end + , "PF\r\n" }; + } + else + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + "Check label printer model configuration."); + return; + } + + if (sCommands != null) + WriteCommand(sCommands); + } + catch(Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + } + + /// + /// 바코드 출력 라벨 프린터 출력 함수 + /// + /// 제품명(한글) ex)"파인트" + /// 바코드 ex)"zxcgfdsgfhgsf" + /// 점포명 ex)"양재사옥점" + public void PrintProductBarCodeInfo(string sProductNm_Ko, string sBarcode_Data, string sStoreNm) + { + string[] sCommands = null; + try + { + if (m_cPosStatus.Base.OlePosLabelPrinterModel == PosConst.POS_DEVICE_LIST.LABEL_PRINTER.OLD_TYPE) + { + sCommands = new string[] { "CLL\r\n" // 메모리 클리어 + , "NEW\r\n" // 새로운 명령어 시작 + , "CLIP ON\r\n" + , "BF ON\r\n" + , "PP 100,90\r\n" + , "BM 1\r\n" + , "BT \"CODE128\r\n" + , "BF \"Swiss 721 BT\",7\r\n" + , "PB \"" + sBarcode_Data + "\"\r\n" + , "FONT \"HYGothic-Medium\",10\r\n" + , "NASC 949\r\n" + , "PP 20,40\r\n" + , "PT \"" + sProductNm_Ko + "\"\r\n" + , "PF\r\n" }; + } + else if (m_cPosStatus.Base.OlePosLabelPrinterModel == PosConst.POS_DEVICE_LIST.LABEL_PRINTER.NEW_TYPE) + { + sCommands = new string[] { "SETUP \"MEDIA,MEDIA SIZE,LENGTH,1200\"\r\n" // 용지출력범위 조정 + , "CLL\r\n" // 메모리 클리어 + , "NEW\r\n" // 새로운 명령어 시작 + , "BF ON\r\n" + , "PP 90,150\r\n" + , "BH 50\r\n" + , "BM 1\r\n" + , "BT \"CODE128\r\n" + , "BF \"Swiss 721 BT\",7\r\n" + , "PB \"" + sBarcode_Data + "\"\r\n" + , "NASC 949\r\n" + , "FONT \"HYGothic-Medium\",9\r\n" + , "PP 130,290\r\n" + , "PT \"" + sStoreNm + "\" 점\r\n" + , "FONT \"HYGothic-Medium\",5\r\n" + , "PP 130,270\r\n" + , "PT \"시간" + System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss") + "\"\r\n" + , "FONT \"HYGothic-Medium\",9\r\n" + , "PP 90,20\r\n" + , "PT \"" + sProductNm_Ko + "\"\r\n" + , "PF\r\n" }; + } + else + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + "Check label printer model configuration."); + return; + } + + if (sCommands != null) + WriteCommand(sCommands); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + } + + /// + /// Write commands to port. + /// + /// + private void WriteCommand(string[] sCommands) + { + try + { + if(devStatus.LabelPrinter.Open) + { + foreach(string cmd in sCommands) + { + m_serialPort.Write(cmd); + } + } + } + catch(Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 + } +} diff --git a/Agent/OLEDevice/DeviceLineDisplay.cs b/Agent/OLEDevice/DeviceLineDisplay.cs new file mode 100644 index 0000000..52811ee --- /dev/null +++ b/Agent/OLEDevice/DeviceLineDisplay.cs @@ -0,0 +1,308 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO.Ports; +using System.ComponentModel; +using System.Runtime.InteropServices; + +using Cosmos.Common; +using Cosmos.UserFrame; + +namespace Cosmos.OLEDevice +{ + /// + /// Line Display 제어 CLASS + /// + public class DeviceLineDisplay : ILineDisplayUs + { + #region VctCdpStdJo.dll 제어 함수 + [DllImport("VctCdpStdJo.dll")] + public static extern int CdpOpen(); + + [DllImport("VctCdpStdJo.dll")] + public static extern int CdpWrite(string sMsg, int iAmt); + + [DllImport("VctCdtpStdJo.dll")] + public static extern int CdpClose(); + #endregion + #region 클래스 변수 선언 + /// + /// StateServer Object (StateServer 객체) + /// + public StateServer StateObject = (StateServer)StateServer.GetInstance(); + + public PosStatus m_cPosStatus = new PosStatus(); + /// + /// Device 상태 정보 객체 + /// + public DeviceStatus devStatus = new DeviceStatus(); + + /// + /// RS232통신을 위한 시리얼포트 객체 + /// + private SerialPort m_serialPort = null; + + //private BackgroundWorker bw = null; + #endregion 클래스 변수 선언 + + #region 생성자 / 초기화 + public DeviceLineDisplay() + { + try + { + m_cPosStatus = (PosStatus)StateObject.POS; + devStatus = (DeviceStatus)StateObject.DEVICE; + + DeviceStatusInit(); + //bw = new BackgroundWorker(); + } + catch(Exception ex) + { + + } + } + + private void DeviceStatusInit() + { + devStatus.LineDisplay.Open = false; + devStatus.LineDisplay.Status = string.Empty; + } + #endregion 생성자 / 초기화 + + #region OPEN / CLOSE 처리 + public bool OpenDevice(string sSerialPort, long lBaudrate) + { + bool bRet = false; + try + { + if (m_serialPort != null) + { + m_serialPort.Close(); + System.Threading.Thread.Sleep(50); + m_serialPort = null; + } + + if (m_serialPort == null) + { + m_serialPort = new SerialPort(); + if (m_serialPort == null) + { + devStatus.Scale.Open = false; + devStatus.Scale.Status = "SERIAL PORT ERROR"; + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + devStatus.Scale.Status); + return bRet; + } + + m_serialPort.NewLine = "\r\n"; + m_serialPort.Encoding = System.Text.Encoding.GetEncoding("ks_c_5601-1987"); + + m_serialPort.WriteBufferSize = 1024 * 1024; + m_serialPort.PortName = sSerialPort; + m_serialPort.BaudRate = (int)lBaudrate; + m_serialPort.ReadTimeout = 500; + m_serialPort.WriteTimeout = 2000; + + if(m_cPosStatus.Base.OleCdpModel == PosConst.POS_DEVICE_LIST.CDP._0_TOSHIBA) + { + m_serialPort.Parity = Parity.Odd; + m_serialPort.DataBits = 8; + m_serialPort.StopBits = StopBits.One; + m_serialPort.Handshake = Handshake.RequestToSend; + m_serialPort.RtsEnable = true; + m_serialPort.DtrEnable = true; + } + else + { + m_serialPort.Parity = Parity.None; + m_serialPort.DataBits = 8; + m_serialPort.StopBits = StopBits.One; + m_serialPort.Handshake = Handshake.None; + m_serialPort.RtsEnable = false; + m_serialPort.DtrEnable = false; + } + + m_serialPort.Open(); + if (m_serialPort.IsOpen == false) + { + devStatus.LineDisplay.Open = false; + devStatus.LineDisplay.Status = "SERIAL PORT OPEN ERROR"; + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.Scale.Status); + return bRet; + } + + devStatus.LineDisplay.Open = true; + devStatus.LineDisplay.Status = "SUCCESS"; + + bRet = true; + } + else + { + devStatus.LineDisplay.Open = false; + devStatus.LineDisplay.Status = "SERIAL PORT ERROR"; + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.Scale.Status); + return bRet; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRet; + } + + + public bool CloseDevice() + { + bool bRet = false; + + try + { + if (m_serialPort == null) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Close fail(m_serialPort == null)"); + return bRet; + } + + m_serialPort.Close(); + bRet = true; + m_serialPort = null; + devStatus.LineDisplay.Status = "CLOSE"; + devStatus.LineDisplay.Open = false; + } + catch (Exception ex) + { + devStatus.LineDisplay.Status = "CLOSE EXCEPTION"; + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRet; + } + #endregion OPEN / CLOSE 처리 + + #region LineDisplay 제어 + public bool DisplayText(int iAmt, string sMsg) + { + bool bRet = false; + + try + { + DisplayClear(); + + if (m_cPosStatus.Base.OleCdpModel == PosConst.POS_DEVICE_LIST.CDP._0_TOSHIBA) + { + TransmitCommand(PosConst.CDP_COMMAND.LINE_START_1); + TransmitCommand(Convert.ToString(iAmt)); + TransmitCommand(PosConst.CDP_COMMAND.LINE_START_2); + TransmitCommand(sMsg); + } + else if (m_cPosStatus.Base.OleCdpModel == PosConst.POS_DEVICE_LIST.CDP._1_XN) + { + TransmitCommand(string.Format("{0, -20}", Convert.ToString(iAmt))); + TransmitCommand(string.Format("{0, -20}", sMsg)); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRet; + } + + public bool DisplayClear() + { + bool bRet = false; + + try + { + if(m_cPosStatus.Base.OleCdpModel == PosConst.POS_DEVICE_LIST.CDP._0_TOSHIBA) + { + TransmitCommand(PosConst.CDP_COMMAND.LINE_CLEAR); + } + else if(m_cPosStatus.Base.OleCdpModel == PosConst.POS_DEVICE_LIST.CDP._1_XN) + { + TransmitCommand(PosConst.CDP_COMMAND.LINE_CLEAR_XN); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRet; + } + #endregion + + private void TransmitCommand(byte[] aCmd, bool bSleepOn = true) + { + if (m_serialPort.IsOpen == true) + { + int iOffset = 0; + //int iReadBuf = 2048; + int iReadBuf = m_serialPort.WriteBufferSize; + + while (true) + { + if (iOffset >= aCmd.Length) + { + break; + } + if (iReadBuf + iOffset > aCmd.Length) + { + iReadBuf = aCmd.Length - iOffset; + } + m_serialPort.Write(aCmd, iOffset, iReadBuf); + + iOffset += iReadBuf; + System.Threading.Thread.Sleep(10); + } + //m_serialPort.Write(Encoding.Default.GetString(aCmd, 0, aCmd.Length)); + + if (bSleepOn == true) System.Threading.Thread.Sleep(30); + } + } + + private void TransmitCommand(string sMsg, bool bSleepOn = true) + { + if(m_serialPort.IsOpen == true) + { + m_serialPort.WriteLine(sMsg); + + if (bSleepOn == true) System.Threading.Thread.Sleep(30); + } + } + } +} diff --git a/Agent/OLEDevice/DeviceMsr.cs b/Agent/OLEDevice/DeviceMsr.cs new file mode 100644 index 0000000..14a38c8 --- /dev/null +++ b/Agent/OLEDevice/DeviceMsr.cs @@ -0,0 +1,184 @@ +using System; +using System.Text; +using System.Threading; + +using Cosmos.UserFrame; +using Cosmos.Common; + +//using Microsoft.PointOfService; +using System.ComponentModel; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : Msr 제어 +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.OLEDevice +{ + /// + /// Msr 제어 CLASS + /// + public class DeviceMsr : IMsrUs + { + /// + /// StateServer Object (StateServer 객체) + /// + public StateServer StateObject = (StateServer)StateServer.GetInstance(); + /// + /// Device 상태 정보 객체 + /// + public DeviceStatus devStatus = new DeviceStatus(); + ///// + ///// Pos for .Net Msr 객체 + ///// + //private Msr msr = null; + ///// + ///// Pos for .Net의 Device 정보를 가져오기 위한 객체 + ///// + //private PosExplorer posExplorer = null; + + + private string m_sTrackData1 = string.Empty; + private string m_sTrackData2 = string.Empty; + private string m_sTrackData3 = string.Empty; + + /// + /// 이벤트 비동기 발생을 위한 대리자 + /// + private BackgroundWorker bw = null; + + private int m_nErrorCount = 0; + + /// + /// 생성자 + /// + public DeviceMsr() + { + try + { + //posExplorer = new PosExplorer(); + devStatus = (DeviceStatus)StateObject.DEVICE; + DeviceStatusInit(); + bw = new BackgroundWorker(); + + m_nErrorCount = 0; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.DeviceMsr()", ex.Message); + } + } + + /// + /// 장비의 Event 발생 Enable 상태 설정 + /// True:사용가능, False:사용불가능 + /// + public bool DeviceEnabled + { + get + { + return false; + } + set + { + try + { + bool bRet = SetDeviceEnabled(value); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceMsr.DeviceEnabled()", ex.Message); + } + } + } + + /// + /// 장비의 Event 발생 Enable 상태 설정 + /// True:사용가능, False:사용불가능 + /// + private bool SetDeviceEnabled(bool bEnable) + { + bool bRet = false; + + try + { + + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceMsr.SetDeviceEnabled()", ex.Message); + devStatus.Msr.Status = "DEVICE ENABLED FAIL"; + } + return bRet; + } + + /// + /// 디바이스 Open시 처리함수 + /// + /// 장비종류(ex- "Msr","PosPrinter","Scanner"...) + /// 레지스트리 항목(ex- "DefaultMsr","DefaultPosPrinter","DefaultScanner"...) + /// + public bool OpenDevice(string sDeviceType, string sLogicalName) + { + bool bRet = false; + + try + { + + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceMsr.OpenDevice()", ex.Message); + devStatus.Msr.Open = false; + devStatus.Msr.Status = "DEVICE OPEN EXCEPTION"; + return bRet; + } + + return bRet; + } + + + + + /// + /// Msr StateServer 정보 초기화 + /// + private void DeviceStatusInit() + { + devStatus.Msr.Track1Data = ""; + devStatus.Msr.Track2Data = ""; + devStatus.Msr.Track3Data = ""; + devStatus.Msr.DeviceName = ""; + devStatus.Msr.Status = ""; + devStatus.Msr.Open = false; + } + + /// + /// 디바이스 Close시 처리함수 + /// + /// + public bool CloseDevice() + { + bool bRet = false; + + try + { + + + devStatus.Msr.Status = "CLOSE"; + devStatus.Msr.Open = false; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceMsr.CloseDevice()", ex.Message); + devStatus.Msr.Status = "CLOSE EXCEPTION"; + } + return bRet; + } + } +} diff --git a/Agent/OLEDevice/DeviceOurHome.cs b/Agent/OLEDevice/DeviceOurHome.cs new file mode 100644 index 0000000..fecf110 --- /dev/null +++ b/Agent/OLEDevice/DeviceOurHome.cs @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +using Cosmos.Common; +using Cosmos.UserFrame; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : 아워홈 +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.OLEDevice +{ + public class DeviceOurHome : IOurHome + { + #region 변수 선언 + /// + /// StateServer Object (StateServer 객체) + /// + public StateServer StateObject = (StateServer)StateServer.GetInstance(); + + /// + /// 아워홈 OCX form 객체 + /// + frmDeviceOurHome frmOurHome = null; + #endregion + + #region 생성자 + /// + /// 생성자 + /// + public DeviceOurHome() + { + try + { + frmOurHome = new frmDeviceOurHome(); + } + catch(Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 고객정보 조회 + /// + /// 고객정보 조회 + /// + /// + /// + /// + /// + public string Rf_EmpInfo(string sStoreCD, string sRFNo, string sRFType) + { + string sResult = "9^Not Connect DataBase!!!"; + try + { + sResult = frmOurHome.Rf_EmpInfo(sStoreCD, sRFNo, sRFType); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 sResult; + } + #endregion + + #region 결제 + /// + /// 결제 + /// + /// + /// + /// + /// + public string Rf_TransData(string sStoreCD, string sTranData, string sRfType) + { + string sResult = "9^Not Connect DataBase!!!"; + try + { + sResult = frmOurHome.Rf_TransData(sStoreCD, sTranData, sRfType); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 sResult; + } + #endregion + } +} diff --git a/Agent/OLEDevice/DevicePosPrinter.cs b/Agent/OLEDevice/DevicePosPrinter.cs new file mode 100644 index 0000000..c08d349 --- /dev/null +++ b/Agent/OLEDevice/DevicePosPrinter.cs @@ -0,0 +1,5701 @@ +//#20180329 프린터 간헐적 미출력 증상 수정 start +//로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP +#define PRT_ERROR //적용시 주석 해제 +//출력 할때 마다 open, close 하는 부분 한번만 하도록 수정 +//#define PRT_OPENCLOSE //적용시 주석 해제 +//전체 버퍼 한번에 출력 하도록 수정 +//#define PRT_ALLWRITE //적용시 주석 해제 +//프린터 ErrorReceived +//#define PRT_RECVERR //적용시 주석 해제 +//Printer Thread Event Wait +//#define PRT_WAITEVENT //적용시 주석 해제 +//#20180329 프린터 간헐적 미출력 증상 수정 end + +//20180611 프린터 미출력 개선 02Printer.exe start +//O2Printer.exe 통해 프린터 출력 +#define PRT_O2PRINTER // 적용시 주석 해제 +//20180611 프린터 미출력 개선 02Printer.exe end + +using System; +using System.IO; +using System.IO.Ports; +using System.ComponentModel; + +using Cosmos.UserFrame; +using Cosmos.BaseFrame; +using Cosmos.Common; +using Cosmos.CommonManager; + +using Microsoft.PointOfService; +using System.Drawing; +using System.Text; +using System.Collections; +using System.Runtime.InteropServices; +using System.Threading; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : PosPrinter 제어 +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.OLEDevice +{ + + /// + /// PosPrinter 제어 CLASS + /// + public class DevicePosPrinter : IPosPrinterUs + { + + public enum Printer_Interface + { + _USB_ = 0, + _COM_, + }; + + /// + /// + /// + public enum Barcode_Type + { + _UPC_A_, + _UPC_E_, + _JAN13_EAN13_, + _JAN8_EAN8_, + _CODE39_, + _ITF25_, + _CODABAR_, + _CODE93_, //1~255byte + _CODE128_ //2~255byte + }; + /// + /// + /// + public enum AlignmentR { _Align_left_, _Center_, _Align_right } + + /// + /// 영수증 프린터 오픈 함수 + /// + [DllImport("REXOD_SDK.dll")] + public static extern bool REXOD_Setup_Printer(Printer_Interface nType, int dirverNum, int nbps); + + /// + /// 영수증 프린터 초기화 함수 + /// + [DllImport("REXOD_SDK.dll")] + public static extern int REXOD_Printer_DeInit(); + + /// + /// 영수증 프린터 출력 함수 + /// + [DllImport("REXOD_SDK.dll")] + public static extern int REXOD_Print_CharW([MarshalAs(UnmanagedType.LPWStr)] string printData); + + /// + /// 영수증 프린터 enum 함수 + /// + [DllImport("REXOD_SDK.dll")] + public static extern int REXOD_Enum_Printer(Printer_Interface nType, int[] list); + + /// + /// 영수증 프린터 용지 자르기 함수 + /// + [DllImport("REXOD_SDK.dll")] + public static extern int REXOD_Part_Cut(); + + /// + /// 영수증 프린터 용지 자르기(전체) 함수 + /// + [DllImport("REXOD_SDK.dll")] + public static extern int REXOD_Full_Cut(); + + /// + /// 영수증 프린터 마지막 라인 추가 함수 + /// + [DllImport("REXOD_SDK.dll")] + public static extern int REXOD_Enter_With_nLine(int lineCount); + + /// + /// 영수증 프린터 라인 볼드 처리 함수 + /// + [DllImport("REXOD_SDK.dll")] + public static extern int REXOD_Bold_Word(bool bold); + + + /// + /// 영수증 프린터 라인 오른쪽으로 이동 함수 + /// + [DllImport("REXOD_SDK.dll")] + public static extern bool REXOD_Set_This_Line_Start_Position(int leftMargin); + + + /// + /// 영수증 프린터 바코드 높이 조절 함수 + /// + [DllImport("REXOD_SDK.dll")] + public static extern bool REXOD_Set_Barcode_Height(byte height); + + /// + /// 영수증 프린터 바코드 출력 함수 + /// + [DllImport("REXOD_SDK.dll")] + public static extern bool REXOD_Print_Barcode(Barcode_Type BarcodeType, byte[] pDate, int DateNum); + + /// + /// 영수증 프린터 바코드 출력 함수 + /// + [DllImport("REXOD_SDK.dll")] + public static extern bool REXOD_Select_Barcode_Alignment(AlignmentR newAlignment); + + /// + /// + /// + /// + /// + [DllImport("REXOD_SDK.dll")] + public static extern bool REXOD_Select_Alignment(AlignmentR newAlignment); + + /// + /// 영수증 프린터 이미지 출력 함수 + /// + /// + /// + [DllImport("REXOD_SDK.dll")] + //public static extern bool REXOD_Print_Bitmap(IntPtr bitmapImage); + public static extern bool REXOD_Print_Bitmap(IntPtr bitmapImage); + + + /// + /// 영수증 프린터 폰트 2배 + /// + /// + /// + [DllImport("REXOD_SDK.dll")] + public static extern bool REXOD_Double_Height(bool state); + + /// + /// 영수증 프린터 폰트 2배 + /// + /// + /// + [DllImport("REXOD_SDK.dll")] + public static extern bool REXOD_Double_Width(bool state); + + + private enum BarcodeType { CODE93, CODE128 }; + private enum Alignment { CENTER, LEFT, RIGHT }; + private enum HRIPosition { NO_PRINT, ABOVE, BELOW, ABOVE_BELOW }; + /// + /// StateServer Object (StateServer 객체) + /// + public StateServer StateObject = (StateServer)StateServer.GetInstance(); + /// + /// Device 상태 정보 객체 + /// + public DeviceStatus devStatus = null; + public PosStatus m_cPosStatus = null; + + /// + /// Posfor.Net PosPrinter 객체 + /// + private PosPrinter posprinter = null; + /// + /// Pos for .Net의 Device 정보를 가져오기 위한 객체 + /// + private PosExplorer posExplorer = null; + + /// + /// StatusUpdateEvent의 Status 정보 저장 + /// + private int m_sUpdateStatus = 0; + ///// + ///// Bitmap 상단 Logo 설정 성공 여부 플래그 + ///// true:SetBitmap성공, false:SetBitmap실패 + ///// + //private bool SetTopLogo = false; + ///// + ///// Bitmap 하단 Logo 설정 성공 여부 플래그 + ///// true:SetBitmap성공, false:SetBitmap실패 + ///// + //private bool SetBottomLogo = false; + ///// + ///// ErrorEvent의 Error응답 정보 저장 + ///// + //private ErrorResponse m_sErrorResponse; + + /// + /// RS232통신을 위한 시리얼포트 객체 + /// + private SerialPort m_serialPort = null; + + private BackgroundWorker bw = null; + + // Printer Status/Error 응답 이벤트 + + private string DELIMETER = "^:|"; + + private bool m_bFreeEvents; + public bool FreeEvents + { + get { return m_bFreeEvents; } + set { m_bFreeEvents = value; } + } + + /// + /// Printer Daemon 작동 여부 + /// + private bool m_PrinterDaemonRunning = true; + /// + /// Printer Daemon Thread + /// + private Thread m_tPrtDaemon = null; + /// + /// Thread Waiting Time(스레드 대기시간) + /// + private int m_ThreadSleepTerm = 1000; + + private static ArrayList m_PrtBuffer; + + private const string CMD_OPEN_CASHDRAWER = "_OPEN_A_CASHDRAWER_"; + + //20180611 프린터 미출력 개선 02Printer.exe start + //변경 + #if(PRT_O2PRINTER) + int lRecvLen = 20; + byte[] bytRecvBuff = new byte[1024]; + int lTimeout = 1000; + private TcpSocket m_cPrtSocket = null; + #endif + + //20180611 프린터 미출력 개선 02Printer.exe end + + #if(PRT_WAITEVENT) + private AutoResetEvent m_AutoResetEvent = null; + #endif + + /// + /// 생성자 + /// + public DevicePosPrinter() + { + try + { + try + { + + #if(PRT_WAITEVENT) + // TEST::Printer Thread Event Wait + m_AutoResetEvent = new AutoResetEvent(false); + #endif + + posExplorer = new PosExplorer(); + } + catch (Exception ex) { } + devStatus = (DeviceStatus)StateObject.DEVICE; + m_cPosStatus = (PosStatus)StateObject.POS; + DeviceStatusInit(); + bw = new BackgroundWorker(); + } + catch(Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + + /// + /// Printer StateServer 정보 초기화 + /// + private void DeviceStatusInit() + { + devStatus.Printer.TopLogoFileName = ""; + devStatus.Printer.BottomLogoFileName = ""; + devStatus.Printer.DeviceName = ""; + devStatus.Printer.Status = ""; + devStatus.Printer.ErrorStatus = ""; + devStatus.Printer.Open = false; + } + + #region PrinterDaemon Start/Stop + /// + /// Printer Daemon Start + /// + public void StartPrinterDaemon() + { + try + { + m_PrtBuffer = new ArrayList(); + + m_tPrtDaemon = new Thread(new ThreadStart(ThreadPrtDaemonRun)); + m_PrinterDaemonRunning = true; + m_tPrtDaemon.Start(); + } + catch(Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + + /// + /// Printer Daemon Stop + /// + public void StopPrinterDaemon() + { + try + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "Printer Daemon Stop!!!"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Printer Daemon Stop!!!"); + #else + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "Printer Daemon Stop!!!"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + // 통신서버 Send Terminated (SC Send 종료) + m_PrinterDaemonRunning = false; + + #if(PRT_WAITEVENT) + m_AutoResetEvent.Set(); + #endif + + int count = 0; + //while (count < 10) + while (count < 5) + { + if (m_tPrtDaemon != null && m_tPrtDaemon.IsAlive) m_PrinterDaemonRunning = false; + else break; + + count++; + Thread.Sleep(300); + } + + if (count >= 10) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 Printer Daemon Stop!!!"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 Printer Daemon Stop!!!"); + #else + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 Printer Daemon Stop!!!"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + m_tPrtDaemon.Abort(); + } + } + catch (Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + #endregion PrinterThread Start/Stop + + #region Printer Buffer 관련 + /// + /// Printer Buffer 초기화 + /// + public void PrinterBufferClear() + { + try + { + m_PrtBuffer.Clear(); + } + catch (Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception :"+ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception :"+ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + + public ArrayList GetPrinterBuffer() + { + return m_PrtBuffer; + } + + public void AddToPrinterBuffer(byte[] arData) + { + try + { + m_PrtBuffer.Add(arData); + + #if(PRT_WAITEVENT) + m_AutoResetEvent.Set(); + #endif + } + catch (Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception :"+ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception :"+ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + } + } + #endregion + + #region Printer Daemon Main + /// + /// Printer Daemon Run + /// + private void ThreadPrtDaemonRun() + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //출력 할때 마다 open, close 하는 부분 한번만 하도록 수정 + #if(PRT_OPENCLOSE) //프린터 포트 동작 변경시 + bool bClsRet = false; + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + bool bRet = false; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "Printer Daemon Run!!"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Printer Daemon Run!!"); + #else + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "Printer Daemon Run!!"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + while(m_PrinterDaemonRunning) + { + try + { + #if(PRT_WAITEVENT) + UserLog.WriteLogFile(UserCom.LOG_OP, 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 (함수명)) + "▶▶▶ Printer Device Thread Event WaitOne "); + m_AutoResetEvent.WaitOne(); + m_AutoResetEvent.Reset(); + UserLog.WriteLogFile(UserCom.LOG_OP, 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 (함수명)) + "▶▶▶ Printer Device Thread Event Run "); + #endif + + ArrayList alBuffer = GetPrinterBuffer(); + + if(alBuffer.Count > 0) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Prineter Buffer Count : " + alBuffer.Count); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Prineter Buffer Count : " + alBuffer.Count); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Prineter Buffer Count : " + alBuffer.Count); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + bRet = OpenDevice(PosConst.OPOS_DEVICE.POSPRINTER, PosConst.OPOS_LDN.POSPRINTER); + if( bRet == false) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Failed to open printer device ..."); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Failed to open printer device ..."); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Failed to open printer device ..."); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + } + System.Threading.Thread.Sleep(100); + + if (devStatus.Printer.Open == true) + { + //MemoryStream stream = new MemoryStream(); + //BinaryWriter bw = new BinaryWriter(stream); + + bool bCheckPrinter = true; + + //#20171212 프린터 상태 체크 여부 추가 start + //0: 체크, 1: 체크안함 + //기존 + /* + if (m_cPosStatus.Base.OlePosPrinterModel == PosConst.POS_DEVICE_LIST.POS_PRINTER._1_EPSON) + { + bCheckPrinter = CheckPrinter(); + } + */ + //변경 + if (m_cPosStatus.Base.OlePosPrinterModel == PosConst.POS_DEVICE_LIST.POS_PRINTER._1_EPSON && + m_cPosStatus.Base.OlePosPrinterCheckYn == "0") + { + bCheckPrinter = CheckPrinter(); + } + //#20171212 프린터 상태 체크 여부 추가 end + + //if (CheckPrinter() == true) + if(bCheckPrinter == false) + { + //프린터 상태 체크 실패 시에도 Port Close(20170508-조충연K) + WinManager.ConfirmMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0691)); + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "CheckPrinter() Failed..."); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "CheckPrinter() Failed..."); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "CheckPrinter() Failed..."); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + } + //else + //{ + //헬스체크 후 응답값과 상관없이 프린트 출력업무 수행. + for (int nBufCnt = 0; nBufCnt < alBuffer.Count; nBufCnt++) + { + if (devStatus.Printer.Open == false) break; + byte[] arPrtData = (byte[])alBuffer[nBufCnt]; + + //#20180123 프린터 다운 현상 관련 로그 추가 start + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Prineter nBufCnt : " + nBufCnt); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Prineter nBufCnt : " + nBufCnt); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Prineter nBufCnt : " + nBufCnt); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + //#20180123 프린터 다운 현상 관련 로그 추가 end + + if (Encoding.UTF8.GetString(arPrtData).Equals(CMD_OPEN_CASHDRAWER) == true) + { + switch (m_cPosStatus.Base.OlePosPrinterModel) + { + case PosConst.POS_DEVICE_LIST.POS_PRINTER._1_EPSON: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._6_P2C: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._7_1NR://2018.01.22;"7:4610_1NR" 모델 추가, 처리는 _1_EPSON 과 동일;girak.kim + default: + //bw.Write(PosConst.ESCP_COMMAND.OPEN_CASHDRAWER); + TransmitCommand(PosConst.ESCP_COMMAND.OPEN_CASHDRAWER); + break; + case PosConst.POS_DEVICE_LIST.POS_PRINTER._2_TOSHIBA: + //bw.Write(PosConst.ESCP_COMMAND.OPEN_CASHDRAWER_FOR_TOSHIBA); + TransmitCommand(PosConst.ESCP_COMMAND.OPEN_CASHDRAWER_FOR_TOSHIBA); + break; + } + } + else + { + //bw.Write(arPrtData); + //bw.Write(string.Format("{0}{1}", (char)13, (char)10)); + TransmitCommand(arPrtData); + } + } + //} + + + //bw.Flush(); + //TransmitCommand(stream.ToArray()); + + PrinterBufferClear(); + } + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //출력 할때 마다 open, close 하는 부분 한번만 하도록 수정 + //기존 + /* + bRet = CloseDevice(); + if(bRet == false) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Failed to close printer device ..."); + } + */ + //변경 + #if(PRT_OPENCLOSE) //프린터 포트 동작 변경시 + #else + bRet = CloseDevice(); + if(bRet == false) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Failed to close printer device ..."); + } + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + + #if(PRT_WAITEVENT) + #else + int nNowSleepTerm = 0; + while (nNowSleepTerm < m_ThreadSleepTerm) + { + if (m_PrinterDaemonRunning == false) break; + Thread.Sleep(100); + nNowSleepTerm += 100; + } + #endif + } + catch(Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + 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 (함수명)) + "Printer Daemon Exception : " + ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Printer Daemon Exception : " + ex.Message); + #else + 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 (함수명)) + "Printer Daemon Exception : " + ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "Printer Daemon Exit!!"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Printer Daemon Exit!!"); + #else + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "Printer Daemon Exit!!"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //출력 할때 마다 open, close 하는 부분 한번만 하도록 수정 + #if(PRT_OPENCLOSE) //프린터 포트 동작 변경시 + bClsRet = CloseDevice(); + if (bClsRet == false) + { + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Failed to close printer device ..."); + } + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + } + #endregion + + #region Convert Graysacle Image + [DllImport("gdi32.dll")] + public static extern bool DeleteObject(IntPtr hObject); + + [DllImport("user32.dll")] + public static extern IntPtr GetDC(IntPtr hwnd); + + [DllImport("gdi32.dll")] + public static extern IntPtr CreateCompatibleDC(IntPtr hdc); + + [DllImport("user32.dll")] + public static extern int ReleaseDC(IntPtr hwnd, IntPtr hdc); + + [DllImport("gdi32.dll")] + public static extern int DeleteDC(IntPtr hdc); + + [DllImport("gdi32.dll")] + public static extern IntPtr SelectObject(IntPtr hdc, IntPtr hgdiobj); + + [DllImport("gdi32.dll")] + public static extern int BitBlt(IntPtr hdcDst, int xDst, int yDst, int w, int h, IntPtr hdcSrc, int xSrc, int ySrc, int rop); + static int SRCCOPY = 0x00CC0020; + + [DllImport("gdi32.dll")] + static extern IntPtr CreateDIBSection(IntPtr hdc, ref BITMAPINFO bmi, uint Usage, out IntPtr bits, IntPtr hSection, uint dwOffset); + + static uint BI_RGB = 0; + static uint DIB_RGB_COLORS = 0; + [StructLayout(LayoutKind.Sequential)] + private struct BITMAPINFO + { + public uint biSize; + public int biWidth, biHeight; + public short biPlanes, biBitCount; + public uint biCompression, biSizeImage; + public int biXPelsPerMeter, biYPelsPerMeter; + public uint biClrUsed, biClrImportant; + [MarshalAs(UnmanagedType.ByValArray, SizeConst = 256)] + public uint[] cols; + } + #endregion + + #region OPEN/RESET/CLOSE + /// + /// 디바이스 Open시 처리함수 + /// + /// 장비종류(ex- "Msr","PosPrinter","Scanner"...) + /// 레지스트리 항목(ex- "DefaultMsr","DefaultPosPrinter","DefaultScanner"...) + /// + public bool OpenDevice(string sDeviceType, string sLogicalName) + { + bool bRet = false; + + try + { + if (devStatus.Printer.UseYn == false) + { + return bRet; + } + + switch(m_cPosStatus.Base.OlePosPrinterController) + { + case PosConst.POS_DEVICE_CONTROLLER.OPOS: + bRet = OpenDeviceByOPOS(sDeviceType, sLogicalName); + break; + case PosConst.POS_DEVICE_CONTROLLER.RS232: + bRet = OpenDeviceByRS232(m_cPosStatus.Base.OlePosPrinterSerialPortNumber, m_cPosStatus.Base.OlePosPrinterSerialBaudRate); + break; + } + } + catch(Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + + return bRet; + } + /// + /// OPOS사용 디바이스 Open시 처리함수 + /// + /// 장비종류(ex- "Msr","PosPrinter","Scanner"...) + /// 레지스트리 항목(ex- "DefaultMsr","DefaultPosPrinter","DefaultScanner"...) + /// + public bool OpenDeviceByOPOS(string sDeviceType, string sLogicalName) + { + bool bRet = false; + //SetTopLogo = false; + //SetBottomLogo = false; + try + { + if(devStatus.Printer.Open == true) + { + return true; + } + + DeviceInfo devinfo = null; + + if (sDeviceType == DeviceType.PosPrinter && sLogicalName == PosConst.OPOS_LDN.POSPRINTER) + devinfo = posExplorer.GetDevice(DeviceType.PosPrinter, PosConst.OPOS_LDN.POSPRINTER); + else + { + devStatus.Printer.Open = false; + devStatus.Printer.Status = "DEVICE INFO ERROR"; + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + return bRet; + } + + if (devinfo == null) + { + devStatus.Printer.Open = false; + devStatus.Printer.Status = "DEVICE INFO ERROR"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + return bRet; + } + + posprinter = (PosPrinter)posExplorer.CreateInstance(devinfo); + + if (posprinter != null) + { + posprinter.StatusUpdateEvent += new StatusUpdateEventHandler(Printer_StatusUpdateEvent); + posprinter.ErrorEvent += new DeviceErrorEventHandler(Printer_ErrorEvent); + + try + { + posprinter.Open(); + } + catch (Exception ex) + { + devStatus.Printer.Status = "OPEN FAIL"; + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "Exception :" + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + return bRet; + } + + try + { + posprinter.Claim(1000); + } + catch (Exception ex) + { + devStatus.Printer.Status = "CLAIM FAIL"; + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "Exception :" + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + return bRet; + } + + try + { + posprinter.DeviceEnabled = true; + } + catch (Exception ex) + { + devStatus.Printer.Status = "DEVICE ENABLED FAIL"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "Exception :" + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + return bRet; + } + + try + { + posprinter.AsyncMode = true; + posprinter.RecLineChars = 42; + posprinter.RecLetterQuality = true; + posprinter.RecLineSpacing = 20; + } + catch (Exception ex) + { + devStatus.Printer.Status = "RecLetterQuality 설정 Fail"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "Exception :" + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.OpenDeviceByOPOS()", devStatus.Printer.Status); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + return bRet; + } + + devStatus.Printer.DeviceName = devinfo.ServiceObjectName; + devStatus.Printer.Open = true; + devStatus.Printer.Status = "SUCCESS"; + devStatus.Printer.ErrorStatus = "OK"; + + bw.DoWork += OlePosHandler; + bRet = true; + } + } + catch (Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.OpenDeviceByOPOS()", ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "Exception :" + "DevicePosPrinter.OpenDeviceByOPOS()", ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.ERROR_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.OpenDeviceByOPOS()", ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + devStatus.Printer.Open = false; + devStatus.Printer.Status = "DEVICE OPEN EXCEPTION"; + bRet = false; + } + return bRet; + } + /// + /// RS232사용 디바이스 Open시 처리함수 + /// + /// SerialPort 번호 + /// Baudrate + /// + public bool OpenDeviceByRS232(string sSerialPort, long lBaudrate) + { + bool bRet = false; + + try + { + //20180611 프린터 미출력 개선 02Printer.exe start + //변경 + #if(PRT_O2PRINTER) + int iRet = OpenPrtTcpDevice("127.0.0.1", 9110); + if (iRet == UserCom.OK) + { + devStatus.Printer.Open = true; + devStatus.Printer.Status = "SUCCESS"; + devStatus.Printer.ErrorStatus = "OK"; + + ResetDevice(); + + bRet = true; + } + else + { + devStatus.Printer.Open = false; + devStatus.Printer.Status = "TCP CONNECT ERROR"; + bRet = false; + } + + return bRet; + #endif + //20180611 프린터 미출력 개선 02Printer.exe end + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //출력 할때 마다 open, close 하는 부분 한번만 하도록 수정 + //기존 + /* + if (m_serialPort != null) + { + // add by wani(20170914) - Serial Port Close 보완(Buffer 초기화 추가) + m_serialPort.DiscardInBuffer(); + m_serialPort.DiscardOutBuffer(); + m_serialPort.Close(); + m_serialPort.Dispose(); + System.Threading.Thread.Sleep(50); + m_serialPort = null; + } + */ + //변경 + #if(PRT_OPENCLOSE) //프린터 포트 동작 변경시 + if (m_serialPort != null) + { + if (m_serialPort.IsOpen == false) + { + // add by wani(20170914) - Serial Port Close 보완(Buffer 초기화 추가) + m_serialPort.DiscardInBuffer(); + m_serialPort.DiscardOutBuffer(); + m_serialPort.Close(); + m_serialPort.Dispose(); + System.Threading.Thread.Sleep(50); + m_serialPort = null; + } + else + { + bRet = true; + return bRet; + } + } + #else + if (m_serialPort != null) + { + // add by wani(20170914) - Serial Port Close 보완(Buffer 초기화 추가) + m_serialPort.DiscardInBuffer(); + m_serialPort.DiscardOutBuffer(); + m_serialPort.Close(); + m_serialPort.Dispose(); + System.Threading.Thread.Sleep(50); + m_serialPort = null; + } + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + if( m_serialPort == null ) + { + //m_serialPort = new SerialPort(m_cPosStatus.Base.OlePosPrinterSerialPortNumber, (int)m_cPosStatus.Base.OlePosPrinterSerialBaudRate); + m_serialPort = new SerialPort(); + if (m_serialPort == null) + { + devStatus.Printer.Open = false; + devStatus.Printer.Status = "SERIAL PORT ERROR"; + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.Printer.Status); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + UserCom.WARNING_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 (함수명)) + devStatus.Printer.Status); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.Printer.Status); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + return bRet; + } + + //m_serialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived); + //m_serialPort.PinChanged += new SerialPinChangedEventHandler(serialPort_PinChanged); + //m_serialPort.ErrorReceived += new SerialErrorReceivedEventHandler(serialPort_ErrorReceived); + + m_serialPort.NewLine = "\r\n"; + m_serialPort.Encoding = System.Text.Encoding.GetEncoding("ks_c_5601-1987"); + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //전체 버퍼 한번에 출력 하도록 수정 + #if(PRT_ALLWRITE) //프린터 포트 동작 변경시 + m_serialPort.WriteBufferSize = 1024 * 10; + #else + m_serialPort.WriteBufferSize = 1024 * 3; + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + m_serialPort.PortName = sSerialPort; + m_serialPort.BaudRate = (int)lBaudrate; + m_serialPort.DataBits = 8; + m_serialPort.StopBits = StopBits.One; + m_serialPort.Parity = Parity.None; + + //#20170808 프린터 출력 안되는 현상 수정 start + //특정 케이블에 따라 출력이 안되는 현상이 있음 전부 Handshake.none로 처리 + //적용시 변경 소스로 적용 + //기존 + /* + if (m_cPosStatus.Base.OlePosPrinterModel == PosConst.POS_DEVICE_LIST.POS_PRINTER._6_P2C) + { + m_serialPort.Handshake = Handshake.None; + } + else + { + m_serialPort.Handshake = Handshake.RequestToSend; + } + */ + //변경 + m_serialPort.Handshake = Handshake.None; + //#20170808 프린터 출력 안되는 현상 수정 end + + // 프린터 NV메모리에 upload 하기 위해 WriteTimeout 값이 10초 이상 되어야 함 + m_serialPort.ReadTimeout = 10000; + m_serialPort.WriteTimeout = 10000; + + m_serialPort.RtsEnable = true; + m_serialPort.DtrEnable = true; + FreeEvents = false; + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "[1] Before opening port"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "[1] Before opening port"); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "[1] Before opening port"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + //#20180329 프린터 간헐적 미출력 증상 수정 start + #if(PRT_ERROR) //프린터 포트 동작 변경시 + m_serialPort.Close(); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + m_serialPort.Open(); + + //#20180316 프린터 출력 안되는 증상 - 포트 오픈, 리셋 후 sleep 추가 start + //#20180402 프린터 출력 안되는 점포 증가로 해당 sleep 소스 주석 start + //System.Threading.Thread.Sleep(100); + //#20180402 프린터 출력 안되는 점포 증가로 해당 sleep 소스 주석 end + //#20180316 프린터 출력 안되는 증상 - 포트 오픈, 리셋 후 sleep 추가 end + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "[2] After opening port"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "[2] After opening port"); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "[2] After opening port"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + + if (m_serialPort.IsOpen == false) + { + devStatus.Printer.Open = false; + devStatus.Printer.Status = "SERIAL PORT OPEN ERROR"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.Printer.Status); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + UserCom.WARNING_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 (함수명)) + devStatus.Printer.Status); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.Printer.Status); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + return bRet; + } + ResetDevice(); + + devStatus.Printer.Open = true; + devStatus.Printer.Status = "SUCCESS"; + devStatus.Printer.ErrorStatus = "OK"; + + bw.DoWork += OlePosHandler; + + bRet = true; + } + else + { + devStatus.Printer.Open = false; + devStatus.Printer.Status = "SERIAL PORT ERROR"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.Printer.Status); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + UserCom.WARNING_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 (함수명)) + devStatus.Printer.Status); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.Printer.Status); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + return bRet; + } + } + catch(Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception : "+ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception : " + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception : "+ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + + return bRet; + } + /// + /// 디바이스 Rest시 처리함수 + /// + public void ResetDevice() + { + try + { + switch (m_cPosStatus.Base.OlePosPrinterModel) + { + case PosConst.POS_DEVICE_LIST.POS_PRINTER._1_EPSON: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._2_TOSHIBA: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._7_1NR://2018.01.22;"7:4610_1NR" 모델 추가, 처리는 _1_EPSON 과 동일;girak.kim + TransmitCommand(PosConst.ESCP_COMMAND.INITIALIZE_PRINTER); + break; + case PosConst.POS_DEVICE_LIST.POS_PRINTER._3_IBM: + + //20180611 프린터 미출력 개선 02Printer.exe start + //변경 + #if(PRT_O2PRINTER) + TransmitCommand(new byte[] { (byte)0x1B, (byte)0x31, + (byte)0x1B, (byte)0x20, (byte)0x03, + (byte)0x1B, (byte)0x33, (byte)10, // 라인간격 + (byte)0x1B, (byte)0x25, (byte)0x00, // Double Byte Mode + (byte)0x1B, (byte)0x20, (byte)3, // 글자간 간격 + (byte)0x1B, (byte)0x54, (byte)6 }); + //기존 + #else + TransmitCommand(new byte[] { (byte)0x1B, (byte)0x31 }); + TransmitCommand(new byte[] { (byte)0x1B, (byte)0x20, (byte)0x03 }); // 글자간 간격 + TransmitCommand(new byte[] { (byte)0x1B, (byte)0x33, (byte)10 }); // 라인간격 + TransmitCommand(new byte[] { (byte)0x1B, (byte)0x25, (byte)0x00 }); // Double Byte Mode + TransmitCommand(new byte[] { (byte)0x1B, (byte)0x20, (byte)3 }); // + TransmitCommand(new byte[] { (byte)0x1B, (byte)0x54, (byte)6 }); + #endif + //20180611 프린터 미출력 개선 02Printer.exe end + + break; + default: + break; + } + } + catch(Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception :" + ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception :" + ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + /// A + /// 디바이스 Close시 처리함수 + /// + /// + public bool CloseDevice() + { + bool bRet = false; + + try + { + switch(m_cPosStatus.Base.OlePosPrinterController) + { + case PosConst.POS_DEVICE_CONTROLLER.OPOS: + bRet = CloseDeviceByOPOS(); + bRet = true; + break; + case PosConst.POS_DEVICE_CONTROLLER.RS232: + bRet = CloseDeviceByRS232(); + break; + } + } + catch (Exception ex) + { + devStatus.Printer.Status = "CLOSE EXCEPTION"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception :" + ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception :" + ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + return bRet; + } + /// + /// OPOS사용 디바이스 Close시 처리함수 + /// + public bool CloseDeviceByOPOS() + { + bool bRet = false; + + try + { + if (posprinter == null) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.CloseDeviceByOPOS()", "posprinter == null"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.CloseDeviceByOPOS()", "posprinter == null"); + #else + UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.CloseDeviceByOPOS()", "posprinter == null"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + return bRet; + } + posprinter.DeviceEnabled = false; + posprinter.Release(); + posprinter.Close(); + bRet = true; + posprinter = null; + devStatus.Printer.Status = "CLOSE"; + devStatus.Printer.Open = false; + //SetTopLogo = false; + //SetBottomLogo = false; + bw.DoWork -= OlePosHandler; + } + catch (Exception ex) + { + devStatus.Printer.Status = "CLOSE EXCEPTION"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception :" + ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception :" + ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + + return bRet; + } + /// + /// RS232사용 디바이스 Close시 처리함수 + /// + public bool CloseDeviceByRS232() + { + bool bRet = false; + bool PortOpenResult = false; + + try + { + //20180611 프린터 미출력 개선 02Printer.exe start + //변경 + #if(PRT_O2PRINTER) + devStatus.Printer.Status = "CLOSE"; + devStatus.Printer.Open = false; + return true; + #endif + //20180611 프린터 미출력 개선 02Printer.exe end + + if (m_serialPort == null) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.CloseDeviceByRS232()", "m_serialPort == null"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.CloseDeviceByRS232()", "m_serialPort == null"); + #else + UserLog.WriteLogFile(UserCom.LOG_ERROR, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.CloseDeviceByRS232()", "m_serialPort == null"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + return bRet; + } + + // add by wani(20170914) - Serial Port Close 보완(Buffer 초기화 추가) + m_serialPort.DiscardInBuffer(); + m_serialPort.DiscardOutBuffer(); + m_serialPort.Close(); + System.Threading.Thread.Sleep(100); + PortOpenResult = m_serialPort.IsOpen; + if (PortOpenResult.Equals(true)) + { + m_serialPort.Close(); + System.Threading.Thread.Sleep(100); + } + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "SerialPort.IsOpen => " + PortOpenResult.ToString()); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "SerialPort.IsOpen => " + PortOpenResult.ToString()); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "SerialPort.IsOpen => " + PortOpenResult.ToString()); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + m_serialPort.Dispose(); + bRet = true; + m_serialPort = null; + + devStatus.Printer.Status = "CLOSE"; + devStatus.Printer.Open = false; + //SetTopLogo = false; + //SetBottomLogo = false; + bw.DoWork -= OlePosHandler; + } + catch(Exception ex) + { + devStatus.Printer.Status = "CLOSE EXCEPTION"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception :" + ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception :" + ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + + return bRet; + } + #endregion + + #region Printer check + /// + /// Enable transmission of automatic status. + /// + /// + public bool CheckPrinter() + { + bool bRet = false; + string sTemp = ""; + int nLen = 0; + string sResp = ""; + byte[] bytReadData; + + try + { + if (m_cPosStatus.Base.OlePosPrinterModel == PosConst.POS_DEVICE_CONTROLLER.RS232) + { + switch (m_cPosStatus.Base.OlePosPrinterModel) + { + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._1_TM_T88II: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._2_TM_T88III: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._3_TM_T88IV: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._4_TM_T88V: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._8_SRP_352PLUSIII: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._1_EPSON: + if (devStatus.Printer.Open == false) + { + if (OpenDevice(PosConst.OPOS_DEVICE.POSPRINTER, PosConst.OPOS_LDN.POSPRINTER) == false) return bRet; + } + + bytReadData = new byte[1]; + + //20180611 프린터 미출력 개선 02Printer.exe start + //기존 + #if(PRT_O2PRINTER) + #else + if (m_serialPort != null && m_serialPort.IsOpen == true) + { + #endif + //20180611 프린터 미출력 개선 02Printer.exe end + + // 프린터 초기화 + TransmitCommand(PosConst.ESCP_COMMAND.INITIALIZE_PRINTER, false); + System.Threading.Thread.Sleep(10); + + // Cover Check + + //20180611 프린터 미출력 개선 02Printer.exe start + //기존 + #if(PRT_O2PRINTER) + #else + TransmitCommand(PosConst.ESCP_COMMAND.TRANSMIT_OFFLINE_STATUS, false); + #endif + //변경 + #if(PRT_O2PRINTER) + TransmitCommand(PosConst.ESCP_COMMAND.TRANSMIT_OFFLINE_STATUS, false, true); + #endif + //20180611 프린터 미출력 개선 02Printer.exe end + + System.Threading.Thread.Sleep(70); + + #region + //sResp = m_serialPort.ReadExisting(); + //if (sResp.Length > 0) + //{ + // byte[] respByte = Encoding.Default.GetBytes(sResp); + // if (respByte[0] == PosConst.ESCP_COMMAND.STATUS_OK[0]) + // { + // bRet = true; + // } + // else + // { + // return bRet; + // } + //} + //else + //{ + // return bRet; + //} + #endregion + + //20180611 프린터 미출력 개선 02Printer.exe start + //기존 + #if(PRT_O2PRINTER) + #else + m_serialPort.Read(bytReadData, 0, 1); + if (bytReadData.Length > 0) + { + if (bytReadData[0] == PosConst.ESCP_COMMAND.STATUS_OK[0]) + { + bRet = true; + } + else + { + return bRet; + } + } + else + { + return bRet; + } + #endif + //변경 + #if(PRT_O2PRINTER) + if (bytRecvBuff.Length > 0) + { + if (bytRecvBuff[12] == PosConst.ESCP_COMMAND.STATUS_OK[0]) + { + bRet = true; + } + else + { + return bRet; + } + } + else + { + return bRet; + } + #endif + //20180611 프린터 미출력 개선 02Printer.exe end + + // Paper Check + + //20180611 프린터 미출력 개선 02Printer.exe start + //기존 + #if(PRT_O2PRINTER) + #else + TransmitCommand(PosConst.ESCP_COMMAND.TRANSMIT_CONTINUOUS_PAPER_DETECTOR_STATUS, false); + #endif + //변경 + #if(PRT_O2PRINTER) + TransmitCommand(PosConst.ESCP_COMMAND.TRANSMIT_CONTINUOUS_PAPER_DETECTOR_STATUS, false, true); + #endif + //20180611 프린터 미출력 개선 02Printer.exe end + + System.Threading.Thread.Sleep(70); + + #region + //sResp = m_serialPort.ReadExisting(); + + //if (sResp.Length > 0) + //{ + // byte[] respByte = Encoding.Default.GetBytes(sResp); + // if (respByte[0] == PosConst.ESCP_COMMAND.STATUS_OK[0]) + // { + // bRet = true; + // } + // else + // { + // //bRet = false; + // string NEAR_END = Encoding.Default.GetString(new byte[] { 0x1E }); + // string NOT_PRESENT = Encoding.Default.GetString(new byte[] { 0x72 }); + + // string sErrMsg = string.Empty; + // if (sResp == NEAR_END) + // { + // bRet = true; + // sErrMsg = "Local Printer : RECEIPT_PAPER_NEAR_END"; + // } + // else if (sResp == NOT_PRESENT) sErrMsg = "Local Printer : RECEIPT_PAPER_NOT_PRESENT"; + // else sErrMsg = "Local Printer : ETC_ERROR"; + + // UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + // System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + // System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + // sErrMsg); + // } + //} + //else + //{ + // return bRet; + //} + #endregion + + //20180611 프린터 미출력 개선 02Printer.exe start + //기존 + #if(PRT_O2PRINTER) + #else + m_serialPort.Read(bytReadData, 0, 1); + if (bytReadData.Length > 0) + { + if (bytReadData[0] == PosConst.ESCP_COMMAND.STATUS_OK[0]) + { + bRet = true; + } + else + { + string NEAR_END = Encoding.Default.GetString(new byte[] { 0x1E }); + string NOT_PRESENT = Encoding.Default.GetString(new byte[] { 0x72 }); + string sReadData = Encoding.Default.GetString(bytReadData); + + string sErrMsg = string.Empty; + if (sReadData == NEAR_END) + { + bRet = true; + sErrMsg = "Local Printer : RECEIPT_PAPER_NEAR_END"; + } + else if (sReadData == NOT_PRESENT) sErrMsg = "Local Printer : RECEIPT_PAPER_NOT_PRESENT"; + else sErrMsg = "Local Printer : ETC_ERROR"; + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + sErrMsg); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + sErrMsg); + #else + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + sErrMsg); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + else + { + return bRet; + } + #endif + //변경 + #if(PRT_O2PRINTER) + if (bytRecvBuff.Length > 0) + { + if (bytRecvBuff[12] == PosConst.ESCP_COMMAND.STATUS_OK[0]) + { + bRet = true; + } + else + { + string NEAR_END = Encoding.Default.GetString(new byte[] { 0x1E }); + string NOT_PRESENT = Encoding.Default.GetString(new byte[] { 0x72 }); + string sReadData = Encoding.Default.GetString(bytRecvBuff); + + string sErrMsg = string.Empty; + if (sReadData == NEAR_END) + { + bRet = true; + sErrMsg = "Local Printer : RECEIPT_PAPER_NEAR_END"; + } + else if (sReadData == NOT_PRESENT) sErrMsg = "Local Printer : RECEIPT_PAPER_NOT_PRESENT"; + else sErrMsg = "Local Printer : ETC_ERROR"; + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + sErrMsg); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + sErrMsg); + #else + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + sErrMsg); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + else + { + return bRet; + } + #endif + //20180611 프린터 미출력 개선 02Printer.exe end + + #region + //if (sResp.Length > 0) + //{ + // byte[] respByte = Encoding.Default.GetBytes(sResp); + // if (respByte[0] == PosConst.ESCP_COMMAND.STATUS_OK[1]) + // { + // bRet = true; + // } + // else + // { + // return bRet; + // } + //} + //else + //{ + // return bRet; + //} + #endregion + + //20180611 프린터 미출력 개선 02Printer.exe start + //기존 + #if(PRT_O2PRINTER) + #else + } + #endif + //20180611 프린터 미출력 개선 02Printer.exe end + + break; + #region + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._2_TOSHIBA: + // // Cover Check + // TransmitCommand(PosConst.ESCP_COMMAND.TRANSMIT_OFFLINE_STATUS, false); + // System.Threading.Thread.Sleep(100); + // sResp = m_serialPort.ReadExisting(); + // if (sResp.Length > 0) + // { + // byte[] respByte = Encoding.Default.GetBytes(sResp); + // if (respByte[0] == PosConst.ESCP_COMMAND.STATUS_OK[0]) + // { + // bRet = true; + // } + // else + // { + // return bRet; + // } + // } + // else + // { + // return bRet; + // } + // break; + #endregion + default: + bRet = true; + break; + } + } + } + catch(Exception ex) + { + devStatus.Printer.Status = "Status Check Error"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception :" + ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception :" + ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + + return bRet; + } + + //private int IsPrinterStatusOK() + //{ + // int iReturn = UserCom.NG; + // byte[] bytReadData; + // string sReadData; + // BitArray arBit = null; + // try + // { + // switch(m_cPosStatus.Base.OlePosPrinterModel) + // { + // case PosConst.POS_DEVICE_LIST.POS_PRINTER._7_TRST_A00: + // if (m_serialPort != null && m_serialPort.IsOpen == true) + // { + // FreeEvents = true; + + // bytReadData = new byte[1]; + + // // 프린터 초기화 + // TransmitCommand(PosConst.ESCP_COMMAND.INITIALIZE_PRINTER, false); + // System.Threading.Thread.Sleep(10); + + // // To check whether ONLINE or OFFLINE + // //TransmitCommand(PosConst.ESCP_COMMAND.TRANSMIT_PRINTER_STATUS); + // //sReadData = m_serialPort.ReadExisting(); + // ////m_serialPort.Read(bytReadData, 0, 1); + // ////arBit = new BitArray(bytReadData); + // //arBit = new BitArray(Encoding.Default.GetBytes(sReadData)); + // //// ONLINE/ONFFLINE Status(ONLINE : 0, OFFLINE : 1) + // //if(arBit[3] == true) + // //{ + // // return UserCom.NG1; + // //} + + // // To check cover status + // TransmitCommand(PosConst.ESCP_COMMAND.TRANSMIT_OFFLINE_STATUS); + // m_serialPort.Read(bytReadData, 0, 1); + // arBit = new BitArray(bytReadData); + // // Cover Status(Closed : 0, Open : 1) + // if(arBit[2] == true) + // { + // return UserCom.NG2; + // } + + // // To check paper out status + // TransmitCommand(PosConst.ESCP_COMMAND.TRANSMIT_CONTINUOUS_PAPER_DETECTOR_STATUS); + // m_serialPort.Read(bytReadData, 0, 1); + // // Paper out sensor(Has paper : 0, Paper Out : 1) + // if(arBit[5] == true) + // { + // return UserCom.NG3; + // } + + // iReturn = UserCom.OK; + + // FreeEvents = false; + // } + // break; + // default: + // iReturn = UserCom.OK; + // break; + // } + // } + // catch (Exception ex) + // { + // FreeEvents = false; + // 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 UserCom.NG; + // } + + // return iReturn; + //} + #endregion + + #region 시리얼 이벤트 + private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //프린터 ErrorReceived + /* + SerialData err = e.EventType; + string strErr = ""; + + switch (err) + { + case SerialData.Chars: + strErr = "문자를 받아서 입력 버퍼에 배치했습니다."; + break; + case SerialData.Eof: + strErr = "파일 끝 문자를 받아서 입력 버퍼에 배치했습니다."; + break; + default: + break; + } + + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + strErr); + */ + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + + private void serialPort_PinChanged(object sender, SerialPinChangedEventArgs e) + { + + } + + private void serialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //프린터 ErrorReceived + #if(PRT_RECVERR) + + SerialError err = e.EventType; + string strErr = ""; + + switch (err) + { + case SerialError.Frame: + strErr = "HardWare Framing Error"; + break; + case SerialError.Overrun: + strErr = "Charaters Buffer Over Run"; + break; + case SerialError.RXOver: + strErr = "Input Buffer OverFlow"; + break; + case SerialError.RXParity: + strErr = "Founded Parity Error"; + break; + case SerialError.TXFull: + strErr = "Write Buffer was Fulled"; + break; + default: + break; + } + + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + strErr); + + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + + private void POSPrinter_StatusUpdateEvent(string sData) + { + + } + + /// + /// + /// + /// + /// + private void OlePosHandler(object sender, DoWorkEventArgs e) + { + try + { + if (PosOLEDevice.m_delegateOlePos != null) + PosOLEDevice.m_delegateOlePos(PosConst.OPOS_DEVICE.POSPRINTER, devStatus.Printer.Status, devStatus.Printer.ErrorStatus, string.Empty); + else + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "이벤트 전송 대상 없음"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "이벤트 전송 대상 없음"); + #else + UserLog.WriteLogFile(UserCom.LOG_ERROR, + 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 (함수명)) + "이벤트 전송 대상 없음"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + catch (Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + 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); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + 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); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + /// + /// Printer 상태 변경에 따른 이벤트 처리 + /// + /// + /// + private void Printer_StatusUpdateEvent(object sender, StatusUpdateEventArgs e) + { + try + { + if (!bw.IsBusy) + { + m_sUpdateStatus = e.Status; + + switch (m_sUpdateStatus) + { + case PosPrinter.StatusCoverOK: + devStatus.Printer.ErrorStatus = "OK"; + devStatus.Printer.Status = "COVER OK"; + break; + case PosPrinter.StatusReceiptEmpty: + devStatus.Printer.ErrorStatus = "NO PAPER"; + devStatus.Printer.Status = "RECEIPT EMPTY"; + break; + case PosPrinter.StatusCoverOpen: + devStatus.Printer.ErrorStatus = "COVER OPEN"; + devStatus.Printer.Status = "COVER OPEN"; + break; + case PosPrinter.StatusReceiptNearEmpty: + devStatus.Printer.ErrorStatus = "OK"; + devStatus.Printer.Status = "REC_NEAREMPTY"; + break; + case PosPrinter.StatusReceiptPaperOK: + devStatus.Printer.ErrorStatus = "OK"; + devStatus.Printer.Status = "REC PAPEROK"; + break; + default: + devStatus.Printer.ErrorStatus = "OK"; + devStatus.Printer.Status = "OK"; + break; + } + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.Printer_StatusUpdateEvent()", "POS Printer Status=[" + devStatus.Printer.Status + "], ErrStatus=[" + devStatus.Printer.ErrorStatus + "]"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.Printer_StatusUpdateEvent()", "POS Printer Status=[" + devStatus.Printer.Status + "], ErrStatus=[" + devStatus.Printer.ErrorStatus + "]"); + #else + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.Printer_StatusUpdateEvent()", "POS Printer Status=[" + devStatus.Printer.Status + "], ErrStatus=[" + devStatus.Printer.ErrorStatus + "]"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + bw.RunWorkerAsync(); + if (PosOLEDevice.m_delegateOlePos != null) + PosOLEDevice.m_delegateOlePos(PosConst.OPOS_DEVICE.POSPRINTER, devStatus.Printer.Status, devStatus.Printer.ErrorStatus, string.Empty); + } + else + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + "프린터 이벤트 처리 전 이벤트 발생 불가"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + UserCom.WARNING_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 (함수명)) + "프린터 이벤트 처리 전 이벤트 발생 불가"); + #else + UserLog.WriteLogFile(UserCom.LOG_ERROR, + UserCom.WARNING_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 (함수명)) + "프린터 이벤트 처리 전 이벤트 발생 불가"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + catch (Exception ex) + { + devStatus.Printer.Status = "STATUS UPDATE EVENT ERROR"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + 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); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + 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); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + finally + { + //posprinter.ClearOutput(); + } + } + + /// + /// Printer 에러이벤트 처리 + /// + /// + /// + private void Printer_ErrorEvent(object sender, DeviceErrorEventArgs e) + { + try + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.Printer_ErrorEvent()", "ErrorEvent 발생, ErrorCode=[" + e.ErrorCode.ToString() + "], ErrorResponse=[" + e.ErrorResponse.ToString() + "]"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.Printer_ErrorEvent()", "ErrorEvent 발생, ErrorCode=[" + e.ErrorCode.ToString() + "], ErrorResponse=[" + e.ErrorResponse.ToString() + "]"); + #else + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.Printer_ErrorEvent()", "ErrorEvent 발생, ErrorCode=[" + e.ErrorCode.ToString() + "], ErrorResponse=[" + e.ErrorResponse.ToString() + "]"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + if (e.ErrorResponse == ErrorResponse.Clear) + { + if (devStatus.Printer.ErrorStatus != "ER_CLEAR") + { + //devStatus.Printer.ErrorStatus = "ER_CLEAR"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.Printer_ErrorEvent()", + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.Printer_ErrorEvent()", + #else + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.Printer_ErrorEvent()", + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + e.ErrorCode + " " + devStatus.Printer.ErrorStatus + " " + posprinter.ErrorString); + //UserLog.WriteAMSLog("DEV", "ERR", "0302", "Printer " + e.ErrorCode.ToString() + " " + posprinter.ErrorString); + } + } + + if (e.ErrorCode == ErrorCode.Failure) + { + if (devStatus.Printer.ErrorStatus != "E_FAILURE") + { + devStatus.Printer.ErrorStatus = "E_FAILURE"; + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.Printer_ErrorEvent()", + e.ErrorCode + " " + devStatus.Printer.ErrorStatus + " " + posprinter.ErrorString); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.Printer_ErrorEvent()", + e.ErrorCode + " " + devStatus.Printer.ErrorStatus + " " + posprinter.ErrorString); + #else + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.Printer_ErrorEvent()", + e.ErrorCode + " " + devStatus.Printer.ErrorStatus + " " + posprinter.ErrorString); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + //UserLog.WriteAMSLog("DEV", "ERR", "0402", "Printer " + e.ErrorCode.ToString() + " " + posprinter.ErrorString); + } + } + + posprinter.ClearOutput(); + } + catch (Exception ex) + { + devStatus.Printer.Status = "ERROREVENT ERROR"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + #endregion + + #region 출력 + /// + /// 바코드 아래 출력할 문구의 가운데 정렬후 리턴 + /// + /// + /// + private string TextAlignCenter(string sData) + { + string sPrtData = string.Empty; + + if (m_cPosStatus.Base.OptBillPrintSize == "0") //0:42bytes + { + if (CmUtil.LenH(sData) < 42) sPrtData = CmUtil.LPadH("", 21 - (CmUtil.LenH(sData) / 2)) + sData; + } + + return sPrtData; + } + + /// + /// 출력할 데이터를 Line group 단위로 받아 처리 + /// + /// + private void PrintLineDataGroup(string pLineDataGroup) + { + StringBuilder sbPrintData = new StringBuilder(); + string sHeader = string.Empty; + string sData = string.Empty; + //20170913 IBM 프린터 행간 축소 start + //기존 + //string CrLf = string.Format("{0}{1}", (char)13, (char)10); + //변경 + byte[] CrLf; + //20170913 IBM 프린터 행간 축소 end + string[] aLineDataGroup; + byte[] bytTemp = null; + + try + { + MemoryStream stream = new MemoryStream(); + BinaryWriter bw = new BinaryWriter(stream); + + //20170913 IBM 프린터 행간 축소 start + CrLf = new byte[5]; + Array.Clear(CrLf, 0, CrLf.Length); + + if (m_cPosStatus.Base.OlePosPrinterModel == PosConst.POS_DEVICE_LIST.POS_PRINTER._3_IBM) + { + // LF + WIDTH_X2_OFF + CrLf[0] = 10; + CrLf[1] = 27; + CrLf[2] = 33; + CrLf[3] = 0; + } + else + { + // CRLF + CrLf[0] = 13; + CrLf[1] = 10; + } + //20170913 IBM 프린터 행간 축소 end + + aLineDataGroup = pLineDataGroup.Split(new string[] { DELIMETER }, StringSplitOptions.None); + int nLoop = 0; + foreach (string sLineData in aLineDataGroup) + { + if (sLineData.Length < 5) continue; + + sHeader = sLineData.Substring(0, 5); + sData = sLineData.Substring(5); + + switch(sHeader) + { + case PosConst.PRT_HDR.PRT_BMP: //[BMP] + bytTemp = PrintBMP(sData); + if (bytTemp != null) + { + bw.Write(bytTemp); + } + break; + case PosConst.PRT_HDR.PRT_SGN: + bytTemp = PrintBMP(BaseCom.NxDataPath + "SIGN\\" + sData); + if (bytTemp != null) + { + bw.Write(bytTemp); + } + break; + case PosConst.PRT_HDR.PRT_TBM: //[TBM] + //if (File.Exists(BaseCom.NxImgPath + m_cPosStatus.Base.BrandDiv + "_TOP.bmp") == true) + //{ + // bw.Write(PosConst.ESCP_COMMAND.CENTER_ALIGN); + // bw.Write(PrintTopLogo()); + // bw.Write(PosConst.ESCP_COMMAND.LEFT_ALIGN); + //} + + //2018.01.22; 1NR 모델은 상단부터 출력;girak.kim;Start + if (m_cPosStatus.Base.OlePosPrinterModel == PosConst.POS_DEVICE_LIST.POS_PRINTER._7_1NR) + { + if (m_cPosStatus.Base.TextLogoMsgUseYn == "0" && File.Exists(BaseCom.NxImgPath + m_cPosStatus.Base.BrandDiv + "_TOP.bmp") == true) + { + bw.Write(PosConst.ESCP_COMMAND.CENTER_ALIGN); + bw.Write(PrintTopLogo()); + bw.Write(PosConst.ESCP_COMMAND.LEFT_ALIGN); + } + } + //2018.01.22; 1NR 모델은 상단부터 출력;girak.kim;End + + break; + case PosConst.PRT_HDR.PRT_BBM: //[BBM] + if (m_cPosStatus.Base.TextLogoMsgUseYn == "0" && + File.Exists(BaseCom.NxImgPath + m_cPosStatus.Base.BrandDiv + "_BOT.bmp") == true) + { + bw.Write(PosConst.ESCP_COMMAND.CENTER_ALIGN); + bw.Write(PrintBottomLogo()); + bw.Write(PosConst.ESCP_COMMAND.LEFT_ALIGN); + } + break; + case PosConst.PRT_HDR.PRT_BAR: //[BAR] + bw.Write(Encoding.Default.GetBytes(PrintBarcodeData(BarcodeType.CODE128, Alignment.CENTER, HRIPosition.BELOW, sData))); + break; + case PosConst.PRT_HDR.PRT_BA1: //[BA1] + case PosConst.PRT_HDR.PRT_SIS: + bw.Write(Encoding.Default.GetBytes(PrintBarcodeData(BarcodeType.CODE128, Alignment.CENTER, HRIPosition.NO_PRINT, sData))); + break; + case PosConst.PRT_HDR.PRT_CUT: //[CUT] + int iMaxCnt = 0; + switch(m_cPosStatus.Base.OlePosPrinterModel) + { + case PosConst.POS_DEVICE_LIST.POS_PRINTER._1_EPSON: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._2_TOSHIBA: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._7_1NR://2018.01.22; 1NR 모델 추가 ;girak.kim + default: + iMaxCnt = 4; + break; + case PosConst.POS_DEVICE_LIST.POS_PRINTER._6_P2C: + iMaxCnt = 2; + break; + } + if (m_cPosStatus.Base.OlePosPrinterModel != PosConst.POS_DEVICE_LIST.POS_PRINTER._7_1NR)//2018.01.22; 1NR 모델은 상단에 출력하므로 조건문 추가, 그 외는 기존 처리;girak.kim; + { + //원래 소스 부분 + // 영수증 상단 로고를 컷팅 바로 직전에 출력하는 것으로 변경함(20170623) + //for (int i = 0; i < iMaxCnt; i++) + //{ + // bw.Write(CrLf); + //} + + if (m_cPosStatus.Base.TextLogoMsgUseYn == "0" && File.Exists(BaseCom.NxImgPath + m_cPosStatus.Base.BrandDiv + "_TOP.bmp") == true) + { + bw.Write(PosConst.ESCP_COMMAND.CENTER_ALIGN); + bw.Write(PrintTopLogo()); + bw.Write(PosConst.ESCP_COMMAND.LEFT_ALIGN); + } + else + { + for (int i = 0; i < iMaxCnt; i++) + { + bw.Write(CrLf); + } + } + //원래 소스 부분 끝 + } + + + switch (m_cPosStatus.Base.OlePosPrinterModel) + { + case PosConst.POS_DEVICE_LIST.POS_PRINTER._3_IBM: + bw.Write(PosConst.ESCP_COMMAND.PAPER_CUT_1NR); + break; + default: + bw.Write(PosConst.ESCP_COMMAND.PAPER_CUT); + break; + } + break; + case PosConst.PRT_HDR.PRT_NOR: //[NOR] + bw.Write(Encoding.Default.GetBytes(sData)); + bw.Write(CrLf); + break; + case PosConst.PRT_HDR.PRT_BLD: //[BLD] + bw.Write(PosConst.ESCP_COMMAND.BOLD_ON); + bw.Write(Encoding.Default.GetBytes(sData)); + bw.Write(PosConst.ESCP_COMMAND.BOLD_OFF); + bw.Write(CrLf); + break; + case PosConst.PRT_HDR.PRT_LIN: + bw.Write(PosConst.ESCP_COMMAND.UNDERLINE_ON); + bw.Write(Encoding.Default.GetBytes(sData)); + bw.Write(PosConst.ESCP_COMMAND.UNDERLINE_OFF); + bw.Write(CrLf); + break; + case PosConst.PRT_HDR.PRT_HOR: + bw.Write(PosConst.ESCP_COMMAND.WIDTH_X2_ON); + bw.Write(Encoding.Default.GetBytes(sData)); + bw.Write(PosConst.ESCP_COMMAND.WIDTH_X2_OFF); + bw.Write(CrLf); + break; + case PosConst.PRT_HDR.PRT_VER: + bw.Write(PosConst.ESCP_COMMAND.HEIGHT_X2_ON); + bw.Write(Encoding.Default.GetBytes(sData)); + bw.Write(PosConst.ESCP_COMMAND.HEIGHT_X2_OFF); + bw.Write(CrLf); + break; + case PosConst.PRT_HDR.PRT_BIG: + bw.Write(PosConst.ESCP_COMMAND.ZOOM_ON); + bw.Write(Encoding.Default.GetBytes(sData)); + bw.Write(PosConst.ESCP_COMMAND.ZOOM_OFF); + bw.Write(CrLf); + break; + case PosConst.PRT_HDR.PRT_VRB: + bw.Write(PosConst.ESCP_COMMAND.HEIGHT_X2_ON); + bw.Write(PosConst.ESCP_COMMAND.BOLD_ON); + bw.Write(Encoding.Default.GetBytes(sData)); + bw.Write(PosConst.ESCP_COMMAND.BOLD_OFF); + bw.Write(PosConst.ESCP_COMMAND.HEIGHT_X2_OFF); + bw.Write(CrLf); + break; + case PosConst.PRT_HDR.PRT_HRB: + bw.Write(PosConst.ESCP_COMMAND.WIDTH_X2_ON); + bw.Write(PosConst.ESCP_COMMAND.BOLD_ON); + bw.Write(Encoding.Default.GetBytes(sData)); + bw.Write(PosConst.ESCP_COMMAND.BOLD_OFF); + bw.Write(PosConst.ESCP_COMMAND.WIDTH_X2_OFF); + bw.Write(CrLf); + break; + case PosConst.PRT_HDR.PRT_BGB: + bw.Write(PosConst.ESCP_COMMAND.ZOOM_ON); + bw.Write(PosConst.ESCP_COMMAND.BOLD_ON); + bw.Write(Encoding.Default.GetBytes(sData)); + bw.Write(PosConst.ESCP_COMMAND.BOLD_OFF); + bw.Write(PosConst.ESCP_COMMAND.ZOOM_OFF); + bw.Write(CrLf); + break; + + case PosConst.PRT_HDR.PRT_VRE : + //bw.Write(PosConst.ESCP_COMMAND.HEIGHT_X2_ON); + //bw.Write(PosConst.ESCP_COMMAND.REVERSE_MODE_ON); + //bw.Write(Encoding.Default.GetBytes(sData)); + //bw.Write(PosConst.ESCP_COMMAND.REVERSE_MODE_OFF); + //bw.Write(PosConst.ESCP_COMMAND.HEIGHT_X2_OFF); + + bw.Write(PosConst.ESCP_COMMAND.CENTER_ALIGN); + bw.Write(PosConst.ESCP_COMMAND.HEIGHT_X2_ON); + bw.Write(PosConst.ESCP_COMMAND.REVERSE_MODE_ON); + bw.Write(Encoding.Default.GetBytes(sData.Trim())); + bw.Write(PosConst.ESCP_COMMAND.REVERSE_MODE_OFF); + bw.Write(PosConst.ESCP_COMMAND.HEIGHT_X2_OFF); + + bw.Write(CrLf); + bw.Write(PosConst.ESCP_COMMAND.LEFT_ALIGN); + break; + } + + nLoop++; + } + + bw.Flush(); + //TransmitCommand(stream.ToArray()); + AddToPrinterBuffer(stream.ToArray()); + } + catch(Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + + /// + /// 출력할 데이터를 1 Line 단위로 받아 처리 + /// + /// + private void PrintLineData(string pLineData) + { + string sType = ""; + + string sLineData = ""; + + string CrLf = string.Format("{0}{1}", (char)13, (char)10); + + string sTxtData = ""; + + if (pLineData.Length < 5) return; + + sType = pLineData.Substring(0, 5); + sLineData = pLineData.Substring(5); + + string sPosMode = string.Empty; + + switch (sType) + { + case PosConst.PRT_HDR.PRT_BMP: //[BMP] + try + { + posprinter.PrintBitmap(PrinterStation.Receipt, sLineData, PosPrinter.PrinterBitmapAsIs, PosPrinter.PrinterBitmapCenter); + } + catch (Exception ex) + { + devStatus.Printer.Status = "BITMAP PRT FAIL"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + 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 (함수명)) + "Print BMP Exception : "+devStatus.Printer.Status + "/" + ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Print BMP Exception : " + devStatus.Printer.Status + "/" + ex.Message); + #else + 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 (함수명)) + "Print BMP Exception : "+devStatus.Printer.Status + "/" + ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + break; + case PosConst.PRT_HDR.PRT_TBM: //[TBM] + try + { + posprinter.PrintNormal(PrinterStation.Receipt, (char)27 + "|1B"); //'Bitmap Image Print ('비트맵 이미지 출력) + } + catch (Exception ex) + { + devStatus.Printer.Status = "TOP BMP PRT FAIL"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + 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 (함수명)) + "Print BMP Exception : "+devStatus.Printer.Status + "/" + ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Print BMP Exception : " + devStatus.Printer.Status + "/" + ex.Message); + #else + 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 (함수명)) + "Print BMP Exception : "+devStatus.Printer.Status + "/" + ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + break; + case PosConst.PRT_HDR.PRT_BBM: //[BBM] + try + { + posprinter.PrintNormal(PrinterStation.Receipt, (char)27 + "|2B"); //'Bitmap Image Print ('비트맵 이미지 출력) + } + catch(Exception ex) + { + devStatus.Printer.Status = "BOTTOM BMP PRT FAIL"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + 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 (함수명)) + "Print BBM Exception : " + devStatus.Printer.Status + "/" + ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Print BBM Exception : " + devStatus.Printer.Status + "/" + ex.Message); + #else + 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 (함수명)) + "Print BBM Exception : " + devStatus.Printer.Status + "/" + ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + break; + case PosConst.PRT_HDR.PRT_BAR: //[BAR] + try + { + posprinter.PrintBarCode(PrinterStation.Receipt, sLineData, BarCodeSymbology.Code128, 50, 368, PosPrinter.PrinterBarCodeCenter, BarCodeTextPosition.Below); + } + catch (Exception ex) + { + devStatus.Printer.Status = "BAR PRT FAIL"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + 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 (함수명)) + "Print BAR Exception : " + devStatus.Printer.Status + "/" + ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Print BAR Exception : " + devStatus.Printer.Status + "/" + ex.Message); + #else + 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 (함수명)) + "Print BAR Exception : " + devStatus.Printer.Status + "/" + ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + break; + case PosConst.PRT_HDR.PRT_BA1: //[BA1] + case PosConst.PRT_HDR.PRT_SIS: + try + { + posprinter.PrintBarCode(PrinterStation.Receipt, sLineData, BarCodeSymbology.Code128, 50, 368, PosPrinter.PrinterBarCodeCenter, BarCodeTextPosition.None); + } + catch (Exception ex) + { + devStatus.Printer.Status = "BAREx PRT FAIL"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + 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 (함수명)) + "Print BA1 Exception : " + devStatus.Printer.Status + "/" + ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Print BA1 Exception : " + devStatus.Printer.Status + "/" + ex.Message); + #else + 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 (함수명)) + "Print BA1 Exception : " + devStatus.Printer.Status + "/" + ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + break; + case PosConst.PRT_HDR.PRT_CUT: //[CUT] + try + { + for(int nLoop = 0;nLoop < 5;nLoop++) + { + posprinter.PrintNormal(PrinterStation.Receipt, (char)27 + "|N" + " " + CrLf); + } + posprinter.CutPaper(100); + } + catch (Exception ex) + { + devStatus.Printer.Status = "CUT PAPER FAIL"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + 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 (함수명)) + "Print 1 Exception : " + devStatus.Printer.Status + "/" + ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Print 1 Exception : " + devStatus.Printer.Status + "/" + ex.Message); + #else + 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 (함수명)) + "Print 1 Exception : " + devStatus.Printer.Status + "/" + ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + break; + default: // Text Print (텍스트 출력) + sTxtData = ""; + switch (sType) + { + case PosConst.PRT_HDR.PRT_NOR: + sTxtData = sTxtData + (char)27 + "|N" + sLineData + CrLf; + posprinter.PrintNormal(PrinterStation.Receipt, sTxtData); + break; //'Normal (보통문자) + case PosConst.PRT_HDR.PRT_BLD: + sTxtData = sTxtData + (char)27 + "|bC" + sLineData + CrLf; + posprinter.PrintNormal(PrinterStation.Receipt, sTxtData); + break; //'Bold (진하게) + case PosConst.PRT_HDR.PRT_LIN: + sTxtData = sTxtData + (char)27 + "|uC" + sLineData + CrLf; + posprinter.PrintNormal(PrinterStation.Receipt, sTxtData); + break; //'Under Line (Under Line 출력) + case PosConst.PRT_HDR.PRT_HOR: + sTxtData = sTxtData + (char)27 + "|2C" + sLineData + CrLf; + posprinter.PrintNormal(PrinterStation.Receipt, sTxtData); + break; //'2 times horizontal expansion (가로 2배 확대) + case PosConst.PRT_HDR.PRT_VER: + sTxtData = sTxtData + (char)27 + "|3C" + sLineData + CrLf; + posprinter.PrintNormal(PrinterStation.Receipt, sTxtData); + break; //'2 times vertical expansion (세로 2배 확대) + case PosConst.PRT_HDR.PRT_BIG: + sTxtData = sTxtData + (char)27 + "|4C" + sLineData + CrLf; + posprinter.PrintNormal(PrinterStation.Receipt, sTxtData); + break; //'2 times horizontal and vertical expansion (가로세로 2배 확대) + case PosConst.PRT_HDR.PRT_VRB: + sTxtData = sTxtData + (char)27 + "|bC" + (char)27 + "|3C" + sLineData + CrLf; + break; //'2 times vertical expansion and bold(진하게 세로 2배 확대) + case PosConst.PRT_HDR.PRT_HRB: + sTxtData = sTxtData + (char)27 + "|bC" + (char)27 + "|2C" + sLineData + CrLf; + break; //'2 times horizontal expansion and bold(진하게 가로 2배 확대) + case PosConst.PRT_HDR.PRT_BGB: + sTxtData = sTxtData + (char)27 + "|bC" + (char)27 + "|4C" + sLineData + CrLf; + break; //'2 times horizontal and vertical expansion, bold(진하게 가로세로 2배 확대) + } + break; + } + } + + private byte[] PrintBMP(string sFilePath) + { + byte[] arRet = null; + try + { + arRet = GetSelectBitImageByte(sFilePath, 0, false); + + } + catch (Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception : "+ ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception : " + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception : "+ ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + + return arRet; + } + + + + /// + /// 상단 로고 출력 + /// + private byte[] PrintTopLogo() + { + byte[] arRet = null; + try + { + switch (m_cPosStatus.Base.OlePosPrinterModel) + { + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._1_TM_T88II: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._2_TM_T88III: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._3_TM_T88IV: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._4_TM_T88V: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._6_4610_1NR: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._7_TRST_A00: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._9_TP_600: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._10_GIANT_100S: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._11_P2C_All_In_One: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._1_EPSON: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._6_P2C: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._7_1NR://2018.01.22;"7:4610_1NR" 모델 추가, 이미지 처리는 _1_EPSON 과 동일;girak.kim + default: + + arRet = PosConst.ESCP_COMMAND.PRINT_NV_BIT_IMAGE_1; + break; + case PosConst.POS_DEVICE_LIST.POS_PRINTER._2_TOSHIBA: + arRet = PosConst.ESCP_COMMAND.PRINT_NV_BIT_IMAGE_3; + break; + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._5_4610_TF7: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._3_IBM: + arRet = PosConst.ESCP_COMMAND.PRINT_NV_BIT_IMAGE_1_1NR; + //arRet = PosConst.ESCP_COMMAND.PRINT_NV_BIT_IMAGE_1; + break; + } + } + catch (Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "PrintTopLogo Exception : " + ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + "PrintTopLogo : " + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "PrintTopLogo Exception : " + ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + + return arRet; + } + /// + /// 하단 로고 출력 + /// + private byte[] PrintBottomLogo() + { + byte[] arRet = null; + try + { + switch (m_cPosStatus.Base.OlePosPrinterModel) + { + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._1_TM_T88II: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._2_TM_T88III: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._3_TM_T88IV: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._4_TM_T88V: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._6_4610_1NR: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._7_TRST_A00: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._9_TP_600: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._10_GIANT_100S: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._11_P2C_All_In_One: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._1_EPSON: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._6_P2C: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._7_1NR://2018.01.22;"7:4610_1NR" 모델 추가, 이미지 처리는 _1_EPSON 과 동일;girak.kim + default: + + arRet = PosConst.ESCP_COMMAND.PRINT_NV_BIT_IMAGE_2; + break; + case PosConst.POS_DEVICE_LIST.POS_PRINTER._2_TOSHIBA: + arRet = PosConst.ESCP_COMMAND.PRINT_NV_BIT_IMAGE_4; + + break; + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._5_4610_TF7: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._3_IBM: + arRet = PosConst.ESCP_COMMAND.PRINT_NV_BIT_IMAGE_2_1NR; + //arRet = PosConst.ESCP_COMMAND.PRINT_NV_BIT_IMAGE_2; + break; + } + + } + catch (Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "PrintBottomLogo Exception:" + ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + "PrintBottomLogo :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "PrintBottomLogo Exception:" + ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + + return arRet; + } + + /// + /// 바코드 출력 함수 + /// + /// 바코드형태 + /// 정렬위치 + /// HRI Character position + /// 바코드데이터 + private string PrintBarcodeData(BarcodeType btBarcodeType, Alignment aAlignment, HRIPosition hpHriPosition, string sLineData) + { + try + { + string sBarcodeData = string.Empty; + + switch(m_cPosStatus.Base.OlePosPrinterModel) + { + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._1_TM_T88II: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._2_TM_T88III: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._3_TM_T88IV: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._4_TM_T88V: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._6_4610_1NR: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._7_TRST_A00: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._9_TP_600: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._10_GIANT_100S: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._11_P2C_All_In_One: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._1_EPSON: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._2_TOSHIBA: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._6_P2C: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._7_1NR://2018.01.22;"7:4610_1NR" 모델 추가, 처리는 _1_EPSON 과 동일;girak.kim + default: + // 바코드 출력 위치 정렬 + sBarcodeData += GetAlignCommandToString(aAlignment); + // Set HRI chracter print position + sBarcodeData += GetHRIPositionCommandToString(hpHriPosition); + // Set Barcode horizontal size. + sBarcodeData += String.Format("{0}{1}{2}", + Convert.ToChar(0x1D), Convert.ToChar(0x77), Convert.ToChar(0x02)); + // Set Barcode height + sBarcodeData += String.Format("{0}{1}{2}", + Convert.ToChar(0x1D), Convert.ToChar(0x68), Convert.ToChar(0x32)); + // Print Barcode + sBarcodeData += String.Format("{0}{1}", + Convert.ToChar(0x1D), Convert.ToChar(0x6B)); + + switch (btBarcodeType) + { + case BarcodeType.CODE93: + sBarcodeData += String.Format("{0}", Convert.ToChar(0x48)); + sBarcodeData += Convert.ToChar(sLineData.Length); + sBarcodeData += sLineData; + break; + case BarcodeType.CODE128: + sBarcodeData += String.Format("{0}", Convert.ToChar(0x49)); + int nDataLen = sLineData.Length + 2; + sBarcodeData += String.Format("{0}", Convert.ToChar(nDataLen)); + sBarcodeData += String.Format("{0}", Convert.ToChar(0x7B)); // "{" + sBarcodeData += String.Format("{0}", Convert.ToChar(0x42)); // "B" + sBarcodeData += sLineData; + break; + } + break; + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._5_4610_TF7: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._3_IBM: + // 바코드 출력 위치 정렬 + sBarcodeData += GetAlignCommandToString(aAlignment); + // Set HRI chracter print position + sBarcodeData += GetHRIPositionCommandToString(hpHriPosition); + // Set Barcode horizontal size. + sBarcodeData += String.Format("{0}{1}{2}", + Convert.ToChar(0x1D), Convert.ToChar(0x77), Convert.ToChar(0x02)); + // Set Barcode height + sBarcodeData += String.Format("{0}{1}{2}", + Convert.ToChar(0x1D), Convert.ToChar(0x68), Convert.ToChar(50)); + // Print Barcode + sBarcodeData += String.Format("{0}{1}", + Convert.ToChar(0x1D), Convert.ToChar(0x6B)); + + switch (btBarcodeType) + { + case BarcodeType.CODE93: + sBarcodeData += String.Format("{0}", Convert.ToChar(0x48)); + sBarcodeData += Convert.ToChar(sLineData.Length); + sBarcodeData += sLineData; + break; + case BarcodeType.CODE128: + sBarcodeData += String.Format("{0}", Convert.ToChar(0x08)); + sBarcodeData += sLineData; + break; + } + break; + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._4_IBM_1NR: + // // 바코드 출력 위치 정렬 + // sBarcodeData += GetAlignCommandToString(aAlignment); + // // Set HRI chracter print position + // sBarcodeData += GetHRIPositionCommandToString(hpHriPosition); + // // Set Barcode horizontal size. + // sBarcodeData += String.Format("{0}{1}{2}", + // Convert.ToChar(0x1D), Convert.ToChar(0x77), Convert.ToChar(0x02)); + // // Set Barcode height + // sBarcodeData += String.Format("{0}{1}{2}", + // Convert.ToChar(0x1D), Convert.ToChar(0x68), Convert.ToChar(0x50)); + // // Print Barcode + // sBarcodeData += String.Format("{0}{1}", + // Convert.ToChar(0x1D), Convert.ToChar(0x6B)); + + // switch (btBarcodeType) + // { + // case BarcodeType.CODE93: + // sBarcodeData += String.Format("{0}", Convert.ToChar(0x48)); + // sBarcodeData += Convert.ToChar(sLineData.Length); + // sBarcodeData += sLineData; + // break; + // case BarcodeType.CODE128: + // sBarcodeData += String.Format("{0}", Convert.ToChar(0x07)); + // //sBarcodeData += String.Format("{0}", Convert.ToChar(0x07)); + // sBarcodeData += sLineData; + // break; + // } + // break; + } + // 출력 정렬 위치 원복 + sBarcodeData += GetAlignCommandToString(Alignment.LEFT); + + //m_serialPort.Write(sBarcodeData); + return sBarcodeData; + } + catch(Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + return ""; + } + } + /// + /// Byte 배열의 HRI print position Command 를 string으로 변환 + /// + /// + /// + private string GetHRIPositionCommandToString(HRIPosition hpHriPosition) + { + string sCommand = string.Empty; + try + { + switch(hpHriPosition) + { + case HRIPosition.NO_PRINT: + sCommand = System.Text.Encoding.Default.GetString(buildESCPCommand(PosConst.ESCP_COMMAND.HRI_PRINT_POSITION, (byte)0)); + break; + case HRIPosition.ABOVE: + sCommand = System.Text.Encoding.Default.GetString(buildESCPCommand(PosConst.ESCP_COMMAND.HRI_PRINT_POSITION, (byte)1)); + break; + case HRIPosition.BELOW: + sCommand = System.Text.Encoding.Default.GetString(buildESCPCommand(PosConst.ESCP_COMMAND.HRI_PRINT_POSITION, (byte)2)); + break; + case HRIPosition.ABOVE_BELOW: + sCommand = System.Text.Encoding.Default.GetString(buildESCPCommand(PosConst.ESCP_COMMAND.HRI_PRINT_POSITION, (byte)3)); + break; + } + } + catch(Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + return sCommand; + } + /// + /// Byte 배열의 Align Command 를 string으로 변환 + /// + /// 정렬위치 + /// + private string GetAlignCommandToString(Alignment aAlignment) + { + string sCommand = string.Empty; + try + { + switch(aAlignment) + { + case Alignment.CENTER: + sCommand = System.Text.Encoding.Default.GetString(PosConst.ESCP_COMMAND.CENTER_ALIGN); + break; + case Alignment.LEFT: + sCommand = System.Text.Encoding.Default.GetString(PosConst.ESCP_COMMAND.LEFT_ALIGN); + break; + case Alignment.RIGHT: + sCommand = System.Text.Encoding.Default.GetString(PosConst.ESCP_COMMAND.RIGHT_ALIGN); + break; + } + } + catch(Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + + return sCommand; + } + + /// + /// 프린터 출력 + /// + /// 출력할 데이터 Line 단위 배열 + /// 해피스테이션만 사용할꺼임 2019.03.27 + /// + public bool ReceiptPrinter(string[] pPrintData, bool kiosk) + { + bool bRet = false; + + int[] List = new int[32]; + int ListNum = 0; + bool Interface_opend = true; + + + if (m_cPosStatus.Base.OlePosPrinterController == PosConst.POS_DEVICE_CONTROLLER.RS232) //해피스테이션 rs232 사용 + { + string sPrtPort = CmUtil.MidH(m_cPosStatus.Base.OlePosPrinterSerialPortNumber, 3, m_cPosStatus.Base.OlePosPrinterSerialPortNumber.Length - 3); + long baudRate = m_cPosStatus.Base.OlePosPrinterSerialBaudRate; + Interface_opend = REXOD_Setup_Printer(Printer_Interface._COM_, int.Parse(sPrtPort), (int)baudRate); + + } + else if (m_cPosStatus.Base.OlePosPrinterController == PosConst.POS_DEVICE_CONTROLLER.OPOS) //해피스테이션 usb 사용 + { + ListNum = REXOD_Enum_Printer(Printer_Interface._USB_, List); + + if (ListNum >= 1) + { + Interface_opend = REXOD_Setup_Printer(Printer_Interface._USB_, List[0], 0); + } + } + + + + + Bitmap bitmapImage; + int iRet = 0; + string sFileName = string.Empty; + string lastPrintData = ""; + string printDataGbn = ""; + byte[] strBarcode = null; + for (int i = 0; i < pPrintData.Length; i++) + { + + if (pPrintData[i].Length >= 5) + printDataGbn = pPrintData[i].Substring(0, 5); + if (pPrintData[i].Length >= 5) + lastPrintData = pPrintData[i].Substring(5) + "\r\n"; + else + lastPrintData = "" + "\r\n"; + + + + + if (printDataGbn.Equals("[BLD]")) REXOD_Bold_Word(true); + + + if (printDataGbn.Equals("[BAR]")) + { + strBarcode = Encoding.UTF8.GetBytes(PrintBarcodeData(BarcodeType.CODE128, Alignment.CENTER, HRIPosition.NO_PRINT, lastPrintData.Replace("\r\n", ""))); + + REXOD_Select_Barcode_Alignment(AlignmentR._Center_); + REXOD_Print_Barcode(Barcode_Type._CODE128_, strBarcode, strBarcode.Length); + } + else if (printDataGbn.Equals("[SGN]")) + { + sFileName = BaseCom.NxDataPath + "SIGN\\" + lastPrintData.Replace("\r\n", ""); + if (File.Exists(sFileName)) + { + bitmapImage = new Bitmap(sFileName); + if (bitmapImage != null) + { + // var rectangle = new System.Drawing.Rectangle(0, 0, 496, 100); + // var lastImg = bitmapImage.Clone(rectangle, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); + + // ImageConverter converter = new ImageConverter(); + // GCHandle pinnedArray = GCHandle.Alloc((byte[])converter.ConvertTo(bitmapImage, typeof(byte[])), GCHandleType.Pinned); + // IntPtr pointer = pinnedArray.AddrOfPinnedObject(); + + REXOD_Select_Alignment(AlignmentR._Center_); + IntPtr hbit = bitmapImage.GetHbitmap(); + REXOD_Print_Bitmap(hbit); + //REXOD_Print_Bitmap(pointer); + //pinnedArray.Free(); + DeleteObject(hbit); + REXOD_Select_Alignment(AlignmentR._Align_left_); + } + } + } + else if (printDataGbn.Equals("[TBM]")) + { + sFileName = BaseCom.NxCDPPath + PosConst.MST_IMG_PATH.RLOGO + @"PB_TOP.bmp"; + if (File.Exists(sFileName)) + { + bitmapImage = new Bitmap(sFileName); + if (bitmapImage != null) + { + + // var rectangle = new System.Drawing.Rectangle(0, 0, 496, 100); + // var lastImg = bitmapImage.Clone(rectangle, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); + + // ImageConverter converter = new ImageConverter(); + // GCHandle pinnedArray = GCHandle.Alloc((byte[])converter.ConvertTo(bitmapImage, typeof(byte[])), GCHandleType.Pinned); + // IntPtr pointer = pinnedArray.AddrOfPinnedObject(); + + REXOD_Select_Alignment(AlignmentR._Center_); + IntPtr hbit = bitmapImage.GetHbitmap(); + REXOD_Print_Bitmap(hbit); + //REXOD_Print_Bitmap(pointer); + //pinnedArray.Free(); + DeleteObject(hbit); + REXOD_Select_Alignment(AlignmentR._Align_left_); + } + } + } + else if (printDataGbn.Equals("[BBM]")) + { + sFileName = BaseCom.NxCDPPath + PosConst.MST_IMG_PATH.RLOGO + @"PB_BOT.bmp"; + if (File.Exists(sFileName)) + { + bitmapImage = new Bitmap(sFileName); + if (bitmapImage != null) + { + // var rectangle = new System.Drawing.Rectangle(0, 0, 496, 100); + // var lastImg = bitmapImage.Clone(rectangle, System.Drawing.Imaging.PixelFormat.Format8bppIndexed); + + // ImageConverter converter = new ImageConverter(); + // GCHandle pinnedArray = GCHandle.Alloc((byte[])converter.ConvertTo(bitmapImage, typeof(byte[])), GCHandleType.Pinned); + // IntPtr pointer = pinnedArray.AddrOfPinnedObject(); + + REXOD_Select_Alignment(AlignmentR._Center_); + IntPtr hbit = bitmapImage.GetHbitmap(); + REXOD_Print_Bitmap(hbit); + //REXOD_Print_Bitmap(pointer); + //pinnedArray.Free(); + DeleteObject(hbit); + REXOD_Select_Alignment(AlignmentR._Align_left_); + + } + } + } + else if (printDataGbn.Equals("[BIG]")) + { + //RE + REXOD_Double_Height(true); + REXOD_Double_Width(true); + REXOD_Bold_Word(true); + + REXOD_Set_This_Line_Start_Position(40); + iRet = REXOD_Print_CharW(lastPrintData); + + REXOD_Double_Height(false); + REXOD_Double_Width(false); + REXOD_Bold_Word(false); + iRet = REXOD_Print_CharW(" " + "\r\n"); + }else if (printDataGbn.Equals("[HOR]")) + { + REXOD_Double_Width(true); + + REXOD_Set_This_Line_Start_Position(40); + iRet = REXOD_Print_CharW(lastPrintData); + + REXOD_Double_Width(false); + } + else if (printDataGbn.Equals("[VER]")) + { + + iRet = REXOD_Print_CharW(" " + "\r\n"); + REXOD_Set_This_Line_Start_Position(40); + iRet = REXOD_Print_CharW(lastPrintData); + iRet = REXOD_Print_CharW(" " + "\r\n"); + + } + else + { + REXOD_Set_This_Line_Start_Position(40); + iRet = REXOD_Print_CharW(lastPrintData); + + } + + + if (printDataGbn.Equals("[BLD]")) REXOD_Bold_Word(false); + } + + REXOD_Enter_With_nLine(6); + + REXOD_Full_Cut(); + + return bRet; + } + + /// + /// 프린터 출력 + /// + /// 출력할 데이터 Line 단위 배열 + /// + public bool ReceiptPrinter(string[] pPrintData) + { + bool bRet = false; + + try + { + if (devStatus.Printer.ErrorStatus == "E_FAILURE") devStatus.Printer.ErrorStatus = "OK"; + + if(devStatus.Printer.UseYn == false) + { + return bRet; + } + + //if (devStatus.Printer.Open == false) + //{ + // if (OpenDevice(PosConst.OPOS_DEVICE.POSPRINTER, PosConst.OPOS_LDN.POSPRINTER) == false) return bRet; + //} + + if (m_cPosStatus.Base.OlePosPrinterController == PosConst.POS_DEVICE_CONTROLLER.OPOS) + { + if (devStatus.Printer.Open == false) + { + if (OpenDevice(PosConst.OPOS_DEVICE.POSPRINTER, PosConst.OPOS_LDN.POSPRINTER) == false) return bRet; + } + + // (OPOS) Begin a transaction. + posprinter.TransactionPrint(PrinterStation.Receipt, PrinterTransactionControl.Transaction); + + foreach (string sLineData in pPrintData) + { + this.PrintLineData(sLineData); + } + + // (OPOS) End a transaction by printing the buffered data. + posprinter.TransactionPrint(PrinterStation.Receipt, PrinterTransactionControl.Normal); + + if (devStatus.Printer.ErrorStatus != "OK") + { + //프린터 상태 체크 실패 시에도 Port Close(20170508-조충연K) + CloseDevice(); + + devStatus.Printer.Status = "Receipt Print Fail"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "ReceiptPrinter Fail " + devStatus.Printer.ErrorStatus); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "ReceiptPrinter Fail " + devStatus.Printer.ErrorStatus); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "ReceiptPrinter Fail " + devStatus.Printer.ErrorStatus); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + return bRet; + } + else + { + devStatus.Printer.Status = "Receipt Print Success"; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "ReceiptPrinter SUCCESS"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "ReceiptPrinter SUCCESS"); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "ReceiptPrinter SUCCESS"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + + CloseDevice(); + } + else if(m_cPosStatus.Base.OlePosPrinterController == PosConst.POS_DEVICE_CONTROLLER.RS232) + { + //if (m_serialPort == null || m_serialPort.IsOpen == false) + //{ + // return false; + //} + + //if (CheckPrinter() == false) + //{ + // //프린터 상태 체크 실패 시에도 Port Close(20170508-조충연K) + // CloseDevice(); + // WinManager.ConfirmMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0691)); + // return false; + //} + + + // PAGE MODE 에서 Print NV bit image 명령어(FS p)를 사용할 수 없으므로 + // Serial I/F 사용 시에는 PAGE MODE 사용 안 함 (2016/06/16-CYCHO) + // (RS232) Begin a transaction. + //TransmitCommand(PosConst.ESCP_COMMAND.SET_PAGE_MODE); + + StringBuilder sbBuffer = new StringBuilder(); + + int nCnt = 0; + int nEndIdx; + for (int i = 0; i < (nEndIdx = pPrintData.Length); i++) + { + sbBuffer.Append(pPrintData[i]); + sbBuffer.Append(DELIMETER); + nCnt++; + //20180611 프린터 미출력 개선 02Printer.exe start, 20180719 + #if(PRT_O2PRINTER) + if(nCnt >= 1000 || i + 1 == nEndIdx) + #else + if(nCnt >= 100 || i + 1 == nEndIdx) + #endif + //20180611 프린터 미출력 개선 02Printer.exe end, 20180719 + { + nCnt = 0; + this.PrintLineDataGroup(sbBuffer.ToString()); + sbBuffer.Clear(); + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + pPrintData.Length.ToString() + "," + i.ToString()); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + pPrintData.Length.ToString() + "," + i.ToString()); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + pPrintData.Length.ToString() + "," + i.ToString()); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "ReceiptPrinter SUCCESS"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "ReceiptPrinter SUCCESS"); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "ReceiptPrinter SUCCESS"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + + //// 빚은몰 웹페이지에서 출력 기능이 존재하여 계속 물고 있을 수 없다.(안호성C - 2017.04.28) + //CloseDevice(); + bRet = true; + } + catch (Exception ex) + { + devStatus.Printer.Status = "Receipt Print Fail"; + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + 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); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + 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); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + return bRet; + } + + return bRet; + } + #endregion + + #region Print Bitmap image + /// + /// BMP 이미지를 byte로 반환 + /// + /// + private byte[] GetSelectBitImageByte(string sFilePath, double nImgWidth, bool bImgScale) + { + byte[] bytes = new byte[0]; + try + { + // BMP파일 경로가 없거나 경로에 파일이 없으면 return + if (sFilePath == "" || File.Exists(sFilePath) == false) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "BMP File not Exists : " + sFilePath); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "BMP File not Exists : " + sFilePath); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "BMP File not Exists : " + sFilePath); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + return null; + } + + ConvertBitmapData data = GetBitmapData(sFilePath, nImgWidth, bImgScale); + + BitArray dots = data.Dots; + byte[] width = BitConverter.GetBytes(data.Width); + + int offset = 0; + MemoryStream stream = new MemoryStream(); + BinaryWriter bw = new BinaryWriter(stream); + + // 초기화 + bw.Write((char)0x1B); + bw.Write('@'); + + bw.Write((char)0x1B); + bw.Write('3'); + bw.Write((byte)24); + + bw.Write((char)0x1B); + bw.Write((char)0x61); + bw.Write((char)0x31); + + while (offset < data.Height) + { + /* Select bit image mode + * [Format] ASCII ESC ✻ m nL nH d1 ... dk + * Hex 1B 2A m nL nH d1 ... dk + * Decimal 27 42 m nL nH d1 ... dk + *------------------------------------------------- + * m Mode Number of bits for Dot density Amount of data (k) + * vertical data in horizontal + * 0 8-dot single-density 8 Single-density nL + nH × 256 + * 1 8-dot double-density 8 Double-density nL + nH × 256 + * 32 24-dot single-density 24 Single-density (nL +nH × 256) × 3 + * 33 24-dot double-density 24 Double-density (nL + nH × 256) × 3 + */ + bw.Write((char)0x1B); + bw.Write('*'); // bit-image mode(0x2A) + bw.Write((byte)33); // 24-dot double-density + bw.Write(width[0]); // width low byte + bw.Write(width[1]); // width high byte + + for (int x = 0; x < data.Width; ++x) + { + for (int k = 0; k < 3; ++k) + { + byte slice = 0; + for (int b = 0; b < 8; ++b) + { + int y = (((offset / 8) + k) * 8) + b; + // Calculate the location of the pixel we want in the bit array. + // It'll be at (y * width) + x. + int i = (y * data.Width) + x; + + // If the image is shorter than 24 dots, pad with zero. + bool v = false; + if (i < dots.Length) + { + v = dots[i]; + } + slice |= (byte)((v ? 1 : 0) << (7 - b)); + } + + bw.Write(slice); + } + } + offset += 24; // 24-dot double-density + bw.Write((char)0x0A); + } + // Restore the line spacing to the default of 30 dots. + bw.Write((char)0x1B); + bw.Write('3'); + bw.Write((byte)30); + + bw.Flush(); + bytes = stream.ToArray(); + } + catch (Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception : "+ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception : " + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception : "+ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + + return bytes; + } + + internal class ConvertBitmapData + { + public BitArray Dots { get; set; } + + public int Height { get; set; } + + public int Width { get; set; } + } + + private ConvertBitmapData GetBitmapData(string sFilePath, double nImgWidth, bool bImgScale) + { + try + { + using(var bitmaptmp = (Bitmap)Bitmap.FromFile(sFilePath)) + { + Bitmap bitmap = bitmaptmp; + + var threshold = 127; + var index = 0; + + if(nImgWidth <= 0) + { + nImgWidth = (double)bitmap.Width; + } + double multiplier = nImgWidth; + + double scale = (double)(multiplier / (double)bitmap.Width); + if (!bImgScale) + scale = 1; + + int xheight = (int)(bitmap.Height * scale); + int xwidth = (int)(bitmap.Width * scale); + var dimensions = xwidth * xheight; + var dots = new BitArray(dimensions); + + for(var y = 0;y < xheight;y++) + { + for(var x = 0;x < xwidth;x++) + { + var _x = (int)(x / scale); + var _y = (int)(y / scale); + var color = bitmap.GetPixel(_x, _y); + var luminance = (int)(color.R * 0.3 + color.G * 0.59 + color.B * 0.11); + dots[index] = (luminance < threshold); + index++; + } + } + + return new ConvertBitmapData() { Dots = dots, Height = (int)(bitmap.Height * scale), Width = (int)(bitmap.Width * scale) }; + } + } + catch (Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception :" +ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception :" +ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + return null; + } + + #endregion + + #region Upload image to NV memory region + /// + /// Logo BMP 파일을 프린터 메모리에 Upload + /// + /// + public bool SetLogoBmp() + { + string sTopLogoTargetFile = string.Empty; + string sBotLogoTargetFile = string.Empty; + string sTopLogoFile = string.Empty; + string sBotLogoFile = string.Empty; + string[] sLogoFiles = null; + + //if (SetTopLogo && SetBottomLogo) return true; + + try + { + + sTopLogoFile = BaseFrame.BaseCom.NxImgPath + m_cPosStatus.Base.BrandDiv + "_TOP.bmp"; + sBotLogoFile = BaseFrame.BaseCom.NxImgPath + m_cPosStatus.Base.BrandDiv + "_BOT.bmp"; + + if(File.Exists(sTopLogoFile)) + { + if(File.Exists(sBotLogoFile)) + { + sLogoFiles = new string[] { sTopLogoFile, sBotLogoFile }; + } + else + { + sLogoFiles = new string[] { sTopLogoFile }; + } + } + else + { + //SetTopLogo = false; + //SetBottomLogo = false; + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, " Logo file Not Exists ", sTopLogoFile + "," + sBotLogoFile); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, " Logo file Not Exists ", sTopLogoFile + "," + sBotLogoFile); + #else + UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, " Logo file Not Exists ", sTopLogoFile + "," + sBotLogoFile); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + return true; + } + + foreach(String img in sLogoFiles) + { + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Logo file : "+img); + } + + if (devStatus.Printer.Open == false) return false; + + if (m_cPosStatus.Base.OlePosPrinterController == PosConst.POS_DEVICE_CONTROLLER.OPOS) + { + for (int i = 0; i < sLogoFiles.Length; i++) + { + posprinter.SetBitmap(i + 1, PrinterStation.Receipt, sLogoFiles[i], 496, PosPrinter.PrinterBitmapCenter); + System.Threading.Thread.Sleep(1000); + } + } + else if (m_cPosStatus.Base.OlePosPrinterController == PosConst.POS_DEVICE_CONTROLLER.RS232) + { + switch (m_cPosStatus.Base.OlePosPrinterModel) + { + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._1_TM_T88II: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._2_TM_T88III: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._3_TM_T88IV: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._4_TM_T88V: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._7_TRST_A00: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._9_TP_600: + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._10_GIANT_100S: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._1_EPSON: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._7_1NR://2018.01.22;"7:4610_1NR" 모델 추가, 이미지 처리는 _1_EPSON 과 동일;girak.kim + default: + SetBitmap_EPSON(sLogoFiles); + break; + case PosConst.POS_DEVICE_LIST.POS_PRINTER._2_TOSHIBA: + SetBitmap_TOSHIBA(sLogoFiles); + break; + //case PosConst.POS_DEVICE_LIST.POS_PRINTER._11_P2C_All_In_One: + case PosConst.POS_DEVICE_LIST.POS_PRINTER._6_P2C: + break; + } + // 이미지 upload 후 sleep 필수 + System.Threading.Thread.Sleep(8000); + } + devStatus.Printer.Status = "LOGO BMP DOWN SUCCESS"; + //SetTopLogo = true; + //SetBottomLogo = true; + + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "devStatus.Printer.Status:"+devStatus.Printer.Status); + + + return true; + } + catch(Exception ex) + { + devStatus.Printer.Status = "LOGO BMP DOWN FAIL"; + //SetBottomLogo = false; + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + 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 (함수명)) + "SetLogoBmp Exception, devStatus.Printer.Status : " + devStatus.Printer.Status); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "SetLogoBmp Exception, devStatus.Printer.Status : " + devStatus.Printer.Status); + #else + 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 (함수명)) + "SetLogoBmp Exception, devStatus.Printer.Status : " + devStatus.Printer.Status); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + return false; + } + } + + private void SetBitmap_TOSHIBA(string[] sFileName) + { + byte[] bytes; + try + { + int nBitmapCnt = sFileName.Length; + + MemoryStream stream = new MemoryStream(); + BinaryWriter bw = new BinaryWriter(stream); + + for(int nRow = 0;nRow < nBitmapCnt;nRow++) + { + bw.Write((char)0x1F); + bw.Write((char)0x30); + + bw.Write((byte)(3 + nRow)); + + byte[] raw = File.ReadAllBytes(sFileName[nRow]); + + bw.Write((char)0x1F); + for(int i = 0;i < raw.Length;i++) + { + bw.Write(raw[i]); + } + } + bw.Flush(); + bytes = stream.ToArray(); + + if (bytes != null && bytes.Length > 0) + { + TransmitCommand(bytes, false); + } + } + catch (Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + 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 (함수명)) + "SetBitmap_TOSHIBA() Exception : " + ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "SetBitmap_TOSHIBA() Exception : " + ex.Message); + #else + 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 (함수명)) + "SetBitmap_TOSHIBA() Exception : " + ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + + /// + /// 명판 출력할 로고 이미지 Set + /// + /// 명판 출력 파일명 + /// + private void SetBitmap_EPSON(string[] sFileName) + { + byte[] bytes; + try + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "SetBitmap_EPSON Start"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "SetBitmap_EPSON Start"); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "SetBitmap_EPSON Start"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + /* ────────────────────────────────────────────────────── + * [Name] Define NV bit image + * [Format] ASCII FS q n [xL xH yL yH d1...dk]1...[xL xH yL yH d1...dk]n + * Hex 1C 71 n [xL xH yL yH d1...dk]1...[xL xH yL yH d1...dk]n + * Decimal 28 113 n [xL xH yL yH d1...dk]1...[xL xH yL yH d1...dk]n + * [Description] Defines the NV bit image in the NV graphics area. + * • n specifies the number of defined NV bit images. + * • xL, xH specifies (xL + xH × 256) bytes in the horizontal direction for the NV bit image you defined. + * • yL, yH specifies (yL + yH × 256) bytes in the vertical direction for the NV bit image you defined. + * • d specifies the definition data for the NV bit image (column format). + * • k indicates the number of the definition data. k is an explanation parameter; therefore it does not need to be transmitted. + * Defined Region 1 ≤ n ≤ 255 + * 0 ≤ xL ≤ 255 + * 0 ≤ xH ≤ 3 However, 1 ≤ (xL+xH×256) ≤ 1023 + * 0 ≤ yL ≤ 255 + * 0 ≤ yH ≤ 1 However, 1 ≤ (yL+yH×256) ≤ 288 + * 0 ≤ d ≤ 255 + * k = (xL+xH×256) × (yL+yH×256) ×8 + * Total defined data area = 2 M bytes (256 K bytes) + * ────────────────────────────────────────────────────── + */ + int nBitmapCnt = sFileName.Length; + + MemoryStream stream = new MemoryStream(); + BinaryWriter bw = new BinaryWriter(stream); + + // 초기화 + bw.Write((char)0x1B); + bw.Write((char)0x40); + + //// Select pripheral device + //bw.Write((char)0x1B); + //bw.Write((char)0x3D); + //bw.Write((char)0x01); + + // Define NV bit image + bw.Write((char)0x1C); // FS + bw.Write((char)0x71); // q + bw.Write((byte)nBitmapCnt); + + + for (int nRow = 0; nRow < nBitmapCnt; nRow++) + { + // 원본 이미지 Load + Bitmap image = new Bitmap(sFileName[nRow]); + // 1Bit Graysacle로 Convert + Bitmap bmptmp = ConvertGrayscale1or8Bit(image, 1); + byte[] raw = ConvertNVBitmap(bmptmp, true); + //byte[] raw = ConvertNVBitmap(image, true); + bw.Write(raw); + image.Dispose(); + bmptmp.Dispose(); + } + bw.Flush(); + bytes = stream.ToArray(); + + if (bytes != null && bytes.Length > 0) + { + TransmitCommand(bytes, false); + } + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "SetBitmap_EPSON End"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "SetBitmap_EPSON End"); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "SetBitmap_EPSON End"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + catch(Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + 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 (함수명)) + "SetBitmap_EPSON Exception : " + ex.Message); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "SetBitmap_EPSON Exception : " + ex.Message); + #else + 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 (함수명)) + "SetBitmap_EPSON Exception : " + ex.Message); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + + private byte[] ConvertNVBitmap(Bitmap bitmap, bool bIncludeSize) + { + int baseIndex = ((bIncludeSize) ? 4 : 0); + int xSize = (bitmap.Width / 8); + if (xSize * 8 != bitmap.Width) + { + xSize++; + } + int ySize = (bitmap.Height / 8); + if (ySize * 8 != bitmap.Height) + { + ySize++; + } + + byte[] raw = new byte[xSize * ySize * 8 + ((bIncludeSize) ? 4 : 0)]; + + try + { + for (int i = 0; i < raw.Length; raw[i++] = 0) ; + + if (bIncludeSize) + { + raw[0] = (byte)(xSize & 0x00FF); + raw[1] = (byte)(xSize & 0xFF00); + raw[2] = (byte)(ySize & 0x00FF); + raw[3] = (byte)(ySize & 0xFF00); + } + + int k = (raw[0] + raw[1] * 256) * (raw[2] + raw[3] * 256) * 8; + if (k > 2000000) + { + throw new Exception("Incorrect size"); + } + if (raw[0] < 0 || raw[0] > 255 || raw[1] < 0 || raw[1] > 3 || (raw[0] + raw[1] * 255) < 1 || (raw[0] + raw[1] * 255) > 1023 || + raw[2] < 0 || raw[2] > 255 || raw[3] < 0 || raw[3] > 1 || (raw[2] + raw[3] * 255) < 1 || (raw[2] + raw[3] * 255) > 288) + { + throw new Exception("Incorrect size"); + } + + for (int x = 0; x < bitmap.Width; x++) + { + for (int y = 0; y < bitmap.Height; y++) + { + Color color = bitmap.GetPixel(x, y); + if (RGBGreatEqual(color, 255, 255, 128)) + { + continue; + } + int idx = (ySize * x) + y / 8; + byte mask = (byte)(0x80 >> (y % 8)); + raw[idx + baseIndex] |= mask; + } + } + } + catch(Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + ex.Message); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + return raw; + } + + private static bool RGBGreatEqual(Color c1, int R, int G, int B) + { + return (c1.R >= R && c1.G >= G && c1.B >= B); + } + + private Bitmap ConvertGrayscale1or8Bit(System.Drawing.Bitmap b, int bitpixel) + { + if (bitpixel != 1 && bitpixel != 8) throw new System.ArgumentException("1 or 8", "bit"); + + int w = b.Width, h = b.Height; + IntPtr hbm = b.GetHbitmap(); + + BITMAPINFO bmi = new BITMAPINFO(); + bmi.biSize = 40; + bmi.biWidth = w; + bmi.biHeight = h; + bmi.biPlanes = 1; + bmi.biBitCount = (short)bitpixel; + bmi.biCompression = BI_RGB; + bmi.biSizeImage = (uint)(((w + 7) & 0xFFFFFFF8) * h / 8); + bmi.biXPelsPerMeter = 1000000; + bmi.biYPelsPerMeter = 1000000; + + uint ncols = (uint)1 << bitpixel; + bmi.biClrUsed = ncols; + bmi.biClrImportant = ncols; + bmi.cols = new uint[256]; + if (bitpixel == 1) { bmi.cols[0] = MAKERGB(0, 0, 0); bmi.cols[1] = MAKERGB(255, 255, 255); } + else { for (int i = 0; i < ncols; i++) bmi.cols[i] = MAKERGB(i, i, i); } + + IntPtr bits0; + IntPtr hbm0 = CreateDIBSection(IntPtr.Zero, ref bmi, DIB_RGB_COLORS, out bits0, IntPtr.Zero, 0); + IntPtr sdc = GetDC(IntPtr.Zero); + IntPtr hdc = CreateCompatibleDC(sdc); SelectObject(hdc, hbm); + IntPtr hdc0 = CreateCompatibleDC(sdc); SelectObject(hdc0, hbm0); + + BitBlt(hdc0, 0, 0, w, h, hdc, 0, 0, SRCCOPY); + + System.Drawing.Bitmap b0 = System.Drawing.Bitmap.FromHbitmap(hbm0); + + DeleteDC(hdc); + DeleteDC(hdc0); + ReleaseDC(IntPtr.Zero, sdc); + DeleteObject(hbm); + DeleteObject(hbm0); + + return b0; + } + private static uint MAKERGB(int r, int g, int b) + { + return ((uint)(b & 255)) | ((uint)((r & 255) << 8)) | ((uint)((g & 255) << 16)); + } + #endregion + + #region (RS232통신) 텍스트 출력 함수 + + private void WriteData(string sText) + { + byte[] outputBytes = System.Text.Encoding.Default.GetBytes(sText); + + TransmitCommand(outputBytes); + } + + /// + /// 텍스트 왼쪽 정렬로 출력 후 Line feed + /// + /// + /// + private void WriteLine(string sText, int nAlign = PosConst.PRINT_ALIGN.LEFT_ALIGN) + { + sText = sText.Trim('\n').Trim('\r'); + byte[] outputBytes = System.Text.Encoding.Default.GetBytes(sText); + + if (nAlign == PosConst.PRINT_ALIGN.LEFT_ALIGN) + { + TransmitCommand(PosConst.ESCP_COMMAND.LEFT_ALIGN, false); + } + else if (nAlign == PosConst.PRINT_ALIGN.CENTER_ALIGN) + { + TransmitCommand(PosConst.ESCP_COMMAND.CENTER_ALIGN, false); + } + else if (nAlign == PosConst.PRINT_ALIGN.RIGHT_ALIGN) + { + TransmitCommand(PosConst.ESCP_COMMAND.RIGHT_ALIGN, false); + } + + TransmitCommand(outputBytes); + + TransmitCommand(PosConst.ESCP_COMMAND.LEFT_ALIGN, false); + + TransmitCommand(PosConst.ESCP_COMMAND.LINE_FEED); + } + /// + /// BOLD 옵션으로 텍스트 출력 후 Line feed + /// + /// + /// + private void WriteLineBold(string sText, int nAlign = PosConst.PRINT_ALIGN.LEFT_ALIGN) + { + TransmitCommand(PosConst.ESCP_COMMAND.BOLD_ON); + WriteLine(sText, nAlign); + TransmitCommand(PosConst.ESCP_COMMAND.BOLD_OFF); + } + /// + /// 텍스트를 가로, 세로 2배 확대로 출력 후 Line feed + /// + /// + /// + private void WriteLineZoom(string sText, int nAlign = PosConst.PRINT_ALIGN.LEFT_ALIGN) + { + TransmitCommand(PosConst.ESCP_COMMAND.ZOOM_ON); + WriteLine(sText, nAlign); + TransmitCommand(PosConst.ESCP_COMMAND.ZOOM_OFF); + } + /// + /// 텍스트를 가로 2배 확대로 출력 후 Line feed + /// + /// + /// + private void WriteLineWidthX2(string sText, int nAlign = PosConst.PRINT_ALIGN.LEFT_ALIGN) + { + TransmitCommand(PosConst.ESCP_COMMAND.WIDTH_X2_ON); + WriteLine(sText, nAlign); + TransmitCommand(PosConst.ESCP_COMMAND.WIDTH_X2_OFF); + } + /// + /// 텍스트를 세로 2배 확대로 출력 후 Line feed + /// + /// + /// + private void WriteLineHeightX2(string sText, int nAlign = PosConst.PRINT_ALIGN.LEFT_ALIGN) + { + TransmitCommand(PosConst.ESCP_COMMAND.HEIGHT_X2_ON); + WriteLine(sText, nAlign); + TransmitCommand(PosConst.ESCP_COMMAND.HEIGHT_X2_OFF); + } + /// + /// Set line spacing + /// + /// nLines < 0 일 경우, Set default line spacing + /// + private void SetLineSpace(int nLines) + { + if (nLines >= 0) + { + TransmitCommand(buildESCPCommand(PosConst.ESCP_COMMAND.SET_LINE_SPACING, (byte)nLines)); + } + else + { + TransmitCommand(PosConst.ESCP_COMMAND.SET_DEFAULT_LINE_SPACING); + } + } + /// + /// Underline 옵션으로 텍스트 출력 후 Line feed + /// + /// + /// + private void WriteLineUnderline(string sText, int nAlign = PosConst.PRINT_ALIGN.LEFT_ALIGN) + { + TransmitCommand(PosConst.ESCP_COMMAND.UNDERLINE_ON); + WriteLine(sText, nAlign); + TransmitCommand(PosConst.ESCP_COMMAND.UNDERLINE_OFF); + } + #endregion + + #region (RS232) 명령어 조합 및 전송 + private byte[] buildESCPCommand(byte[] command, byte[] args) + { + byte[] ESCPCommand = new byte[command.Length + args.Length]; + + Array.Copy(command, 0, ESCPCommand, 0, command.Length); + Array.Copy(args, 0, ESCPCommand, command.Length, args.Length); + + return ESCPCommand; + } + + private byte[] buildESCPCommand(byte[] command, byte arg) + { + byte[] ESCPCommand = new byte[command.Length + 1]; + + Array.Copy(command, 0, ESCPCommand, 0, command.Length); + ESCPCommand[command.Length] = arg; + + return ESCPCommand; + } + + //20180611 프린터 미출력 개선 02Printer.exe start + //기존 + #if(PRT_O2PRINTER) + #else + private void TransmitCommand(byte[] aCmd, bool bSleepOn = true) + #endif + //변경 + #if(PRT_O2PRINTER) + private void TransmitCommand(byte[] aCmd, bool bSleepOn = true, bool bHeathChk = false) + #endif + //20180611 프린터 미출력 개선 02Printer.exe end + { + try + { + //20180611 프린터 미출력 개선 02Printer.exe start + //기존 + #if(PRT_O2PRINTER) + #else + if (m_serialPort.IsOpen == true) + { + #endif + //20180611 프린터 미출력 개선 02Printer.exe end + + int iOffset = 0; + // Send 를 위한 buffer 크기를 1024 byte 로 고정(20170608) + int iReadBuf = 1024; + //int iReadBuf = m_serialPort.WriteBufferSize; + + while (true) + { + if (iOffset >= aCmd.Length) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "TransmitCommand Finish " + aCmd.Length.ToString() + "," + iOffset.ToString()); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "TransmitCommand Finish " + aCmd.Length.ToString() + "," + iOffset.ToString()); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "TransmitCommand Finish " + aCmd.Length.ToString() + "," + iOffset.ToString()); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + break; + } + if (iReadBuf + iOffset > aCmd.Length) + { + iReadBuf = aCmd.Length - iOffset; + } + + //#20180123 프린터 다운 현상 관련 로그 추가 start + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Prineter Write : TransmitCommand() Start"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Prineter Write : TransmitCommand() Start"); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Prineter Write : TransmitCommand() Start"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + //#20180123 프린터 다운 현상 관련 로그 추가 end + + + // grayber@20180124 프린터 출력관련 오류 수정 start - 프린터 배열 오프셋 설정 오류로 변수 변경 + //기존 + //m_serialPort.Write(aCmd, iOffset, aCmd.Length); + //수정 + //#20180329 프린터 간헐적 미출력 증상 수정 start + //전체 버퍼 한번에 출력 하도록 수정 + #if(PRT_ALLWRITE) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Prineter Write data: " + Encoding.Default.GetString(aCmd)); + + m_serialPort.Write(Encoding.Default.GetString(aCmd)); + //m_serialPort.Write(aCmd, iOffset, aCmd.Length); + #else + + //20180611 프린터 미출력 개선 02Printer.exe start + //기존 + #if(PRT_O2PRINTER) + #else + m_serialPort.Write(aCmd, iOffset, iReadBuf); + #endif + //변경 + #if(PRT_O2PRINTER) + // TCP 접속 정보 + string sPrtTcpIp = "127.0.0.1"; + string sPrtTcpPort = "9110"; + + // 프린터 PORT 번호 + string sPrtPort = CmUtil.MidH(m_cPosStatus.Base.OlePosPrinterSerialPortNumber, 3, m_cPosStatus.Base.OlePosPrinterSerialPortNumber.Length - 3); + + //Connect + int iRet = OpenPrtTcpDevice(sPrtTcpIp, int.Parse(sPrtTcpPort)); + + //#20181114 영수증 프린터 base63로 전송 start + //기존 + #region 기존 + + //출력 + // 0001: 출력, 0002: 헬스체크 + string sPrtGb = "0001"; + string sTimeOut = "00000"; + + if (bHeathChk == true) + { + sPrtGb = "0002"; + sTimeOut = "00500"; + } + else if (bHeathChk == false) + { + sPrtGb = "0001"; + sTimeOut = "00000"; + } + + // tcp 헤더 + string sCommHeader = sPrtGb + // 0001: 출력, 0002: 헬스체크 + string.Format("{0:D2}", Convert.ToInt32(sPrtPort)) + // 01,02,03 포트번호 + string.Format("{0:D6}", (int)m_cPosStatus.Base.OlePosPrinterSerialBaudRate) + // 프린터 속도 + sTimeOut + // 타임아웃 + string.Format("{0:D6}", (int)aCmd.Length); // 출력 데이터 길이 + + // tcp 종료구분자 + string sETX = string.Format("{0}", (char)0x03) + + string.Format("{0}", (char)0x03) + + string.Format("{0}", (char)0x03); + + // tcp 헤더 byte로 변환 + byte[] sSendbt = null; + sSendbt = Encoding.Default.GetBytes(sCommHeader); + + // tcp 종료구분자 byte로 변환 + byte[] byEtx = null; + byEtx = Encoding.Default.GetBytes(sETX); + + // 전체 tcp 전송 데이터 byte 배열 생성 + byte[] sSendData = new byte[sSendbt.Length + aCmd.Length + byEtx.Length]; + + // sSendData 배열에 tcp 헤더 데이터 복사 + Array.Copy(sSendbt, 0, sSendData, 0, sSendbt.Length); + // sSendData 배열에 영수증 출력 데이터 복사 + Array.Copy(aCmd, 0, sSendData, sSendbt.Length, aCmd.Length); + // sSendData 배열에 tcp 종료구분자 복사 + Array.Copy(byEtx, 0, sSendData, sSendbt.Length + aCmd.Length, byEtx.Length); + + // 응답 배열 초기화 + bytRecvBuff = null; + + // 전체 한번에 전송하기 위에 전송 길이 재설정 + iOffset += aCmd.Length; + + // byte[], int, ref byte[], int + int iPrtSendSocket = m_cPrtSocket.Prt_ByPassSendReceiveData(sSendData, lRecvLen, ref bytRecvBuff, lTimeout); + + //string sTemp0 = Encoding.Default.GetString(aCmd); + + #endregion 기존 + //변경 + #region 변경 + /* + //출력 + // 0101: 출력, 0102: 헬스체크 + string sPrtGb = "0101"; + string sTimeOut = "00000"; + + if (bHeathChk == true) + { + sPrtGb = "0102"; + sTimeOut = "00500"; + } + else if (bHeathChk == false) + { + sPrtGb = "0101"; + sTimeOut = "00000"; + } + + string sSendDataBase64 = Convert.ToBase64String(aCmd); + byte[] btSendDataBase64 = Encoding.Default.GetBytes(sSendDataBase64); + + + // tcp 헤더 + string sCommHeader = sPrtGb + // 0001: 출력, 0002: 헬스체크 + string.Format("{0:D2}", Convert.ToInt32(sPrtPort)) + // 01,02,03 포트번호 + string.Format("{0:D6}", (int)m_cPosStatus.Base.OlePosPrinterSerialBaudRate) + // 프린터 속도 + sTimeOut + // 타임아웃 + string.Format("{0:D6}", (int)btSendDataBase64.Length); // 출력 데이터 길이 + + // tcp 종료구분자 + string sETX = string.Format("{0}", (char)0x03) + + string.Format("{0}", (char)0x03) + + string.Format("{0}", (char)0x03); + + // tcp 헤더 byte로 변환 + byte[] sSendbt = null; + sSendbt = Encoding.Default.GetBytes(sCommHeader); + + // tcp 종료구분자 byte로 변환 + byte[] byEtx = null; + byEtx = Encoding.Default.GetBytes(sETX); + + // 전체 tcp 전송 데이터 byte 배열 생성 + byte[] sSendData = new byte[sSendbt.Length + btSendDataBase64.Length + byEtx.Length]; + + // sSendData 배열에 tcp 헤더 데이터 복사 + Array.Copy(sSendbt, 0, sSendData, 0, sSendbt.Length); + // sSendData 배열에 영수증 출력 데이터 복사 + Array.Copy(btSendDataBase64, 0, sSendData, sSendbt.Length, btSendDataBase64.Length); + // sSendData 배열에 tcp 종료구분자 복사 + Array.Copy(byEtx, 0, sSendData, sSendbt.Length + btSendDataBase64.Length, byEtx.Length); + + // 응답 배열 초기화 + bytRecvBuff = null; + + // 전체 한번에 전송하기 위에 전송 길이 재설정 + iOffset += aCmd.Length; + + // byte[], int, ref byte[], int + int iPrtSendSocket = m_cPrtSocket.Prt_ByPassSendReceiveData(sSendData, lRecvLen, ref bytRecvBuff, lTimeout); + + //string sTemp0 = Encoding.Default.GetString(aCmd); + //string sTemp1 = Encoding.Default.GetString(btSendDataBase64); + //byte[] sBtTemp1 = Convert.FromBase64String(sTemp1); + //string sTemp2 = Encoding.Default.GetString(sBtTemp1); + */ + #endregion 변경 + //#20181114 영수증 프린터 base63로 전송 end + + //System.Threading.Thread.Sleep(2000); + #endif + //20180611 프린터 미출력 개선 02Printer.exe end + + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + // grayber@20180124 프린터 출력관련 오류 수정 end + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //프린터 ErrorReceived + #if(PRT_RECVERR) //프린터 포트 동작 변경시 + //m_serialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived); + m_serialPort.ErrorReceived += new SerialErrorReceivedEventHandler(serialPort_ErrorReceived); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + + //#20180123 프린터 다운 현상 관련 로그 추가 start + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Prineter Write : TransmitCommand() End"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Prineter Write : TransmitCommand() End"); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Prineter Write : TransmitCommand() End"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + //#20180123 프린터 다운 현상 관련 로그 추가 end + + //#20180329 프린터 간헐적 미출력 증상 수정 start + + //20180611 프린터 미출력 개선 02Printer.exe start + //기존 + #if(PRT_O2PRINTER) + #else + //전체 버퍼 한번에 출력 하도록 수정 + #if(PRT_ALLWRITE) //프린터 포트 동작 변경시 + iOffset += aCmd.Length; + #else + iOffset += iReadBuf; + #endif + #endif + //20180611 프린터 미출력 개선 02Printer.exe end + + //#20180329 프린터 간헐적 미출력 증상 수정 end + + System.Threading.Thread.Sleep(10); + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, aCmd.Length.ToString() + "," + iOffset.ToString()); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, aCmd.Length.ToString() + "," + iOffset.ToString()); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, aCmd.Length.ToString() + "," + iOffset.ToString()); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + //m_serialPort.Write(Encoding.Default.GetString(aCmd, 0, aCmd.Length)); + + if (bSleepOn == true) System.Threading.Thread.Sleep(30); + + //20180611 프린터 미출력 개선 02Printer.exe start + //기존 + #if(PRT_O2PRINTER) + #else + } + else + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Serial Port Is Not Opened"); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Serial Port Is Not Opened"); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.WARNING_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name, "Serial Port Is Not Opened"); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + #endif + //20180611 프린터 미출력 개선 02Printer.exe end + } + catch(Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + devStatus.Printer.Status); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + devStatus.Printer.Status); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + devStatus.Printer.Status); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + + this.CloseDevice(); + } + + //#20180329 프린터 간헐적 미출력 증상 수정 start + //출력 할때 마다 open, close 하는 부분 한번만 하도록 수정 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + finally + { + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Prineter Write : TransmitCommand() finally"); + } + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + #endregion + + #region 돈통 Open함수 + /// + /// 돈통 Open 함수 + /// + public void OpenCashDrawer() + { + try + { + if (m_cPosStatus.Base.OlePosCashDrawerType == PosConst.POS_DEVICE_LIST.CASHDRAWER._1_PRINTER) + { + this.AddToPrinterBuffer(Encoding.UTF8.GetBytes(CMD_OPEN_CASHDRAWER)); + //if (devStatus.Printer.Open == false) + //{ + // this.OpenDevice(PosConst.OPOS_DEVICE.POSPRINTER, PosConst.OPOS_LDN.POSPRINTER); + //} + //switch (m_cPosStatus.Base.OlePosPrinterModel) + //{ + // case PosConst.POS_DEVICE_LIST.POS_PRINTER._1_EPSON: + // case PosConst.POS_DEVICE_LIST.POS_PRINTER._6_P2C: + // default: + // TransmitCommand(PosConst.ESCP_COMMAND.OPEN_CASHDRAWER); + // break; + // case PosConst.POS_DEVICE_LIST.POS_PRINTER._2_TOSHIBA: + // TransmitCommand(PosConst.ESCP_COMMAND.OPEN_CASHDRAWER_FOR_TOSHIBA); + // break; + //} + //if(devStatus.Printer.Open == true) + //{ + // this.CloseDevice(); + //} + } + } + catch(Exception ex) + { + //#20180329 프린터 간헐적 미출력 증상 수정 start + //로그 생성 위치 변경 UserCom.LOG_IOS, LOG_ERROR -> UserCom.LOG_OP + //기존 + /* + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + devStatus.Printer.Status); + */ + //변경 + #if(PRT_ERROR) //프린터 포트 동작 변경시 + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 (함수명)) + "Exception :" + devStatus.Printer.Status); + #else + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + devStatus.Printer.Status); + #endif + //#20180329 프린터 간헐적 미출력 증상 수정 end + } + } + + //20180611 프린터 미출력 개선 02Printer.exe start + //변경 + #if(PRT_O2PRINTER) + #region Printer OPEN / CLOSE + public int OpenPrtTcpDevice(string sIp, int iPort) + { + int iRet = UserCom.NG; + try + { + // PING 테스트로 프린터 가능여부 확인(2017.05.30) + if (CmUtil.PingTest(sIp) == false) + { + if (CmUtil.PingTest(sIp) == false) + { + UserLog.WriteLogFile(UserCom.LOG_OP, 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 (함수명)) + "PrtTcp PingTest Fail"); + return iRet; + } + + } + + m_cPrtSocket = new TcpSocket(sIp, iPort, lTimeout); + + if (m_cPrtSocket == null) + { + UserLog.WriteLogFile(UserCom.LOG_OP, 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 (함수명)) + "TcpSocket null"); + return -9; + } + + // 접속 3회 시도 + for (int nLoop = 0; nLoop < 1; nLoop++) + { + try + { + iRet = m_cPrtSocket.Connect(-1); + } + catch (Exception ex) + { + iRet = UserCom.NG; + UserLog.WriteLogFile(UserCom.LOG_OP, 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 (함수명)) + "PrtTcp Exception Error=" + ex.Message); + m_cPrtSocket.Close(); + continue; + } + // 접속 실패 + if (iRet != UserCom.OK) + { + iRet = UserCom.NG; + UserLog.WriteLogFile(UserCom.LOG_OP, 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 (함수명)) + "PrtTcp(Ethernet) Connect Error"); + m_cPrtSocket.Close(); + continue; + } + + break; + } + + return iRet; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_OP, + System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + // Class Name (Class Name (클래스명)) + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", // Function Name (Function Name (함수명)) + ex.Message); + return -99; + } + } + + public void ClosePrtTcpDevice() + { + try + { + if (m_cPrtSocket != null) + { + m_cPrtSocket.Close(); + m_cPrtSocket = null; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_OP, + 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 + #endif + //20180611 프린터 미출력 개선 02Printer.exe end + #endregion + } +} \ No newline at end of file diff --git a/Agent/OLEDevice/DeviceScale.cs b/Agent/OLEDevice/DeviceScale.cs new file mode 100644 index 0000000..d6a0c60 --- /dev/null +++ b/Agent/OLEDevice/DeviceScale.cs @@ -0,0 +1,324 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using System.IO.Ports; +using System.ComponentModel; + +using Cosmos.UserFrame; +using Cosmos.Common; + +namespace Cosmos.OLEDevice +{ + public class DeviceScale : IScaleUs + { + /// + /// StateServer Object (StateServer 객체) + /// + public StateServer StateObject = (StateServer)StateServer.GetInstance(); + + /// + /// Device 상태 정보 객체 + /// + public DeviceStatus devStatus = null; + + /// + /// Pos 상태 정보 객체 + /// + public PosStatus m_cPosStatus = null; + + /// + /// RS232통신을 위한 시리얼포트 객체 + /// + private SerialPort m_serialPort = null; + + private BackgroundWorker bw = null; + + private string m_sReceivedData = string.Empty; + + #region 초기화 + /// + /// 생성자 + /// + public DeviceScale() + { + try + { + m_cPosStatus = (PosStatus)StateObject.POS; + devStatus = (DeviceStatus)StateObject.DEVICE; + + DeviceStatusInit(); + bw = new BackgroundWorker(); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + } + + private void DeviceStatusInit() + { + devStatus.Scale.Open = false; + devStatus.Scale.Data = string.Empty; + devStatus.Scale.Status = string.Empty; + } + #endregion + + #region OPEN/CLOSE 처리 함수 + /// + /// 디바이스 OPEN시 처리 함수 + /// + /// + public bool OpenDevice(string sSerialPort, long lBaudrate) + { + bool bRet = false; + try + { + if (m_serialPort != null) + { + m_serialPort.Close(); + System.Threading.Thread.Sleep(50); + m_serialPort = null; + } + + if (m_serialPort == null) + { + m_serialPort = new SerialPort(); + if( m_serialPort == null) + { + devStatus.Scale.Open = false; + devStatus.Scale.Status = "SERIAL PORT ERROR"; + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.Scale.Status); + return bRet; + } + + m_serialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived); + //m_serialPort.PinChanged += new SerialPinChangedEventHandler(serialPort_PinChanged); + //m_serialPort.ErrorReceived += new SerialErrorReceivedEventHandler(serialPort_ErrorReceived); + + m_serialPort.NewLine = "\r\n"; + m_serialPort.Encoding = Encoding.ASCII; + + m_serialPort.WriteBufferSize = 512; + m_serialPort.PortName = sSerialPort; + m_serialPort.BaudRate = (int)lBaudrate; + m_serialPort.DataBits = 7; + m_serialPort.StopBits = StopBits.One; + m_serialPort.Parity = Parity.Even; + m_serialPort.Handshake = Handshake.None; + m_serialPort.ReadTimeout = 500; + m_serialPort.WriteTimeout = 2000; + + m_serialPort.Open(); + if (m_serialPort.IsOpen == false) + { + devStatus.Scale.Open = false; + devStatus.Scale.Status = "SERIAL PORT OPEN ERROR"; + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.Scale.Status); + return bRet; + } + + devStatus.Scale.Open = true; + devStatus.Scale.Status = "SUCCESS"; + + bw.DoWork += OlePosHandler; + bRet = true; + } + else + { + devStatus.Scale.Open = false; + devStatus.Scale.Status = "SERIAL PORT ERROR"; + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + devStatus.Scale.Status); + return bRet; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRet; + } + /// + /// 디바이스 Close시 처리 함수 + /// + /// + public bool CloseDevice() + { + bool bRet = false; + + try + { + if (m_serialPort == null) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Close fail(m_serialPort == null)"); + return bRet; + } + + m_serialPort.Close(); + bRet = true; + m_serialPort = null; + devStatus.Scale.Status = "CLOSE"; + devStatus.Scale.Open = false; + bw.DoWork -= OlePosHandler; + } + catch (Exception ex) + { + devStatus.Printer.Status = "CLOSE EXCEPTION"; + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRet; + } + #endregion + + #region 이벤트 처리 + private void OlePosHandler(object sender, DoWorkEventArgs e) + { + try + { + if (PosOLEDevice.m_delegateOlePos != null) + PosOLEDevice.m_delegateOlePos(PosConst.OPOS_DEVICE.SCALE, devStatus.Scale.Data, string.Empty, string.Empty); + else + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "이벤트 전송 대상 없음"); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + } + + private void serialPort_DataReceived(object sender, SerialDataReceivedEventArgs e) + { + SerialPort serialPort = (SerialPort)sender; + string sHeader = string.Empty; + string sWeight = string.Empty; + string sUnit = string.Empty; + + try + { + if(!bw.IsBusy) + { + // 데이터의 Terminator는 개행문자(\r\n) 이므로 개행문자 까지 값을 읽는 ReadLine으로 수신 + string sBuf = serialPort.ReadLine(); + sHeader = sBuf.Substring(0, 2); + + // 계량모드에서의 데이터만 처리. + // ST:계량모드, QT:계수모드, US:데이터가 안정되지 않다., OL:데이터가 오버되어 있다.(계량범위를 넘었다.) + if (sHeader.Equals("ST")) + { + sWeight = sBuf.Substring(3, 9); + sUnit = sBuf.Substring(12, 3).Trim(); + + //devStatus.Scale.Data = sWeight; + devStatus.Scale.Data = sBuf; + devStatus.Scale.Unit = sUnit; + } + + bw.RunWorkerAsync(); + } + else + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + "저울 이벤트 처리 전 이벤트 발생 불가"); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + } + + private void serialPort_PinChanged(object sender, SerialPinChangedEventArgs e) + { + + } + + private void serialPort_ErrorReceived(object sender, SerialErrorReceivedEventArgs e) + { + + } + #endregion + + #region 저울 0점 조정 + /// + /// 저울 0점 조정 + /// + public void ScaleCalibration() + { + byte[] bytCalibrationCmd = new byte[] { (byte)0x54, (byte)0x0A }; + + if(devStatus.Scale.Open == true) + { + m_serialPort.Write(bytCalibrationCmd, 0, bytCalibrationCmd.Length); + } + } + #endregion + + #region 무게 전송 요청 + /// + /// 무게 전송 요청 + /// + public void ScaleWeigh() + { + byte[] bytWeighCmd = new byte[] { (byte)0x53, (byte)0x0A }; + + if (devStatus.Scale.Open == true) + { + m_serialPort.Write(bytWeighCmd, 0, bytWeighCmd.Length); + } + } + #endregion + } +} diff --git a/Agent/OLEDevice/DeviceScanner.cs b/Agent/OLEDevice/DeviceScanner.cs new file mode 100644 index 0000000..19957de --- /dev/null +++ b/Agent/OLEDevice/DeviceScanner.cs @@ -0,0 +1,507 @@ +using System; +using System.Text; +using System.Threading; +using System.Runtime.InteropServices; +//using Microsoft.PointOfService; +using System.ComponentModel; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; +using Cosmos.CommonManager; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : Hand Scanner 제어 +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.OLEDevice +{ + public class DeviceScanner : IScannerUs + { + /// + /// StateServer Object (StateServer 객체) + /// + public StateServer StateObject = (StateServer)StateServer.GetInstance(); + /// + /// Device 상태 정보 객체 + /// + public DeviceStatus devStatus = new DeviceStatus(); + + ///// + ///// Pos for .Net Scanner 객체 + ///// + //private Scanner scanner = null; + ///// + ///// Pos for .Net의 Device 정보를 가져오기 위한 객체 + ///// + //private PosExplorer posExplorer = null; + + private string m_sScanData = string.Empty; + private string m_sScanDataLabel = string.Empty; + private string m_sScanDataType = string.Empty; + + private BackgroundWorker bw = null; + + private int m_nErrorCount = 0; + /// + /// 생성자 + /// + public DeviceScanner() + { + try + { + //posExplorer = new PosExplorer(); + devStatus = (DeviceStatus)StateObject.DEVICE; + DeviceStatusInit(); + bw = new BackgroundWorker(); + + m_nErrorCount = 0; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DevicePosPrinter.Devicescanner()", ex.Message); + } + } + + /// + /// 디바이스 Open시 처리함수 + /// + /// 장비종류(ex- "Msr","PosPrinter","Scanner"...) + /// 레지스트리 항목(ex- "DefaultMsr","DefaultPosPrinter","DefaultScanner"...) + /// + public bool OpenDevice(string sDeviceType, string sLogicalName) + { + bool bRet = false; + + try + { + //DeviceInfo devinfo = null; + + //if (sDeviceType == DeviceType.Scanner && sLogicalName == PosConst.OPOS_LDN.SCANNER) + // devinfo = posExplorer.GetDevice(DeviceType.Scanner, PosConst.OPOS_LDN.SCANNER); + //else + //{ + // devStatus.Scanner.Open = false; + // devStatus.Scanner.Status = "DEVICE INFO ERROR"; + // UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + // "DeviceScanner.OpenDevice()", devStatus.Scanner.Status); + // return bRet; + //} + + //if (devinfo == null) + //{ + // devStatus.Scanner.Open = false; + // devStatus.Scanner.Status = "DEVICE INFO ERROR"; + // UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + // "DeviceScanner.OpenDevice()", devStatus.Scanner.Status); + // return bRet; + //} + + //scanner = (Scanner)posExplorer.CreateInstance(devinfo); + + //if (scanner != null) + //{ + // scanner.DataEvent += new DataEventHandler(Scanner_DataEvent); + // scanner.ErrorEvent += new DeviceErrorEventHandler(Scanner_ErrorEvent); + + // try + // { + // scanner.Open(); + // } + // catch (Exception ex) + // { + // devStatus.Scanner.Status = "OPEN FAIL"; + // UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + // "DeviceScanner.OpenDevice()", devStatus.Scanner.Status + " " + ex.Message); + // //UserLog.WriteAMSLog("DEV", "ERR", "0103", "GunScanner " + devStatus.Scanner.Status); + + // return bRet; + // } + + + // try + // { + // scanner.Claim(1000); + // } + // catch (Exception ex) + // { + // devStatus.Scanner.Status = "CLAIM FAIL"; + // UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + // "Devicescanner.OpenDevice()", devStatus.Scanner.Status + " " + ex.Message); + // //UserLog.WriteAMSLog("DEV", "ERR", "0203", "GunScanner " + devStatus.Scanner.Status); + // //장비관련 AMS 로그 삭제 요청(2015.07.23) + + // return bRet; + // } + + // try + // { + // scanner.DeviceEnabled = true; + // } + // catch (Exception ex) + // { + // devStatus.Scanner.Status = "DEVICE ENABLED FAIL"; + // UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + // "DeviceScanner.OpenDevice()", devStatus.Scanner.Status + " " + ex.Message); + // return bRet; + // } + + // try + // { + // scanner.DataEventEnabled = true; + // } + // catch (Exception ex) + // { + // devStatus.Scanner.Status = "DATAEVENT ENABLED FAIL"; + // UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + // "DeviceScanner.OpenDevice()", devStatus.Scanner.Status + " " + ex.Message); + // return bRet; + // } + // scanner.DecodeData = true; + // devStatus.Scanner.Open = true; + // devStatus.Scanner.Status = "Success"; + + // bw.DoWork += OlePosHandler; + // bRet = true; + //} + //m_nErrorCount = 0; + } + catch (Exception ex) + { + devStatus.Scanner.Open = false; + devStatus.Scanner.Status = "DEVICE OPEN EXCEPTION"; + + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceScanner.OpenDevice()", devStatus.Scanner.Status + " " + ex.Message); + return bRet; + } + return bRet; + } + + ///// + ///// + ///// + ///// + ///// + //private void Scanner_DataEvent(object sender, DataEventArgs e) + //{ + // try + // { + // if(!bw.IsBusy) + // { + // ASCIIEncoding encoder = new ASCIIEncoding(); + + // m_sScanData = encoder.GetString(scanner.ScanData); + // m_sScanDataLabel = encoder.GetString(scanner.ScanDataLabel); + // m_sScanDataType = scanner.ScanDataType.ToString(); + + // devStatus.Scanner.Data = m_sScanData; + // devStatus.Scanner.DataLabel = ""; + // //for (int i = 0; i < m_sScanDataLabel.Length; i++) + // //{ + // // if (CmUtil.IsNumber(m_sScanDataLabel.Substring(i, 1)) == true) + // // devStatus.Scanner.DataLabel += m_sScanDataLabel.Substring(i, 1); + // //} + // string sChgDataLabel = ""; + // for (int i = 0; i < scanner.ScanDataLabel.Length; i++) + // { + // if (scanner.ScanDataLabel[i] == (byte)29) + // sChgDataLabel += "|"; + // else + // sChgDataLabel += Convert.ToChar(scanner.ScanDataLabel[i]).ToString(); + // } + // for (int i = 0; i < sChgDataLabel.Length; i++) + // { + // if (CmUtil.IsNumber(sChgDataLabel.Substring(i, 1)) == true) + // { + // devStatus.Scanner.DataLabel = sChgDataLabel.Substring(i, sChgDataLabel.Length - i); + // break; + // } + // //if (sChgDataLabel.Substring(i, 1) != string.Format("{0}", (char)10) && sChgDataLabel.Substring(i, 1) != string.Format("{0}", (char)13)) + // //{ + // // devStatus.Scanner.DataLabel = devStatus.Scanner.DataLabel + sChgDataLabel.Substring(i, 1); + // //} + // } + // devStatus.Scanner.DataType = m_sScanDataType; + + // UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + // "DeviceScanner.Scanner_DataEvent()", + // "Data=" + m_sScanData + ", DataLabel=" + m_sScanDataLabel + "=>" + devStatus.Scanner.DataLabel + ", DataType=" + m_sScanDataType); + // bw.RunWorkerAsync(); + // } + // else + // { + // UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + // "DeviceScanner.Scanner_DataEvent()", "스캐너 이벤트 처리 전 이벤트 발생 불가"); + // //Cosmos.CommonManager.WinManager.ErrorMessage("해당 화면에서 스캐너를 입력 할 수 없습니다.", "스캐너 입력 오류", true); + // //MessageStartTimer(100); + // } + + // //if (PosOLEDevice.m_delegateOlePos != null) + // // PosOLEDevice.m_delegateOlePos(PosConst.OPOS_DEVICE.SCANNER, m_sScanData, devStatus.Scanner.DataLabel, m_sScanDataType); + // //else + // //{ + // // UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + // // "DeviceScanner.Scanner_DataEvent()", "이벤트 전송 대상 없음."); + // // Cosmos.CommonManager.WinManager.ErrorMessage("해당 화면에서 스캐너를 입력 할 수 없습니다.", "스캐너 입력 오류", true); + // //} + + // } + // catch (Exception ex) + // { + // UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + // "DeviceScanner.Scanner_DataEvent()", ex.Message); + // devStatus.Scanner.Status = "DATAEVENT ERROR"; + // } + // finally + // { + // scanner.ClearInput(); + // scanner.DataEventEnabled = true; + // } + //} + + /// + /// + /// + /// + /// + private void OlePosHandler(object sender, DoWorkEventArgs e) + { + try + { + if (PosOLEDevice.m_delegateOlePos != null) + PosOLEDevice.m_delegateOlePos(PosConst.OPOS_DEVICE.SCANNER, string.Empty, devStatus.Scanner.DataLabel, string.Empty); + else + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceScanner.OlePosHandler()", "이벤트 전송 대상 없음."); + //Cosmos.CommonManager.WinManager.ErrorMessage("해당 화면에서 스캐너를 입력 할 수 없습니다.", "스캐너 입력 오류", true); + //MessageStartTimer(100); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceScanner.OlePosHandler()", ex.Message); + } + } + + //private void MessageStartTimer(int dueTime) + //{ + // try + // { + // Thread thrBeep = new Thread(new ThreadStart(OnBeepSound)); + // thrBeep.Start(); + // } + // catch (Exception ex) + // { + // UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + // "DeviceScanner.MessageStartTimer()", ex.Message); + // } + //} + + //private void OnBeepSound() + //{ + // try + // { + // CmMessage m_PosConfig = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + "PosConfig.INI"); + // string sPosUseType = m_PosConfig.GetMessage("olepos").GetMessageValue("PosUseType"); + // string sKeyboard = m_PosConfig.GetMessage("control").GetMessageValue("Keyboard"); + + // for (int i = 0; i < 5; i++) + // { + // WinManager.BuzzSoundOn(sPosUseType, sKeyboard); + // Thread.Sleep(200); + // } + + // //CmMessage m_PosConfig = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + "PosConfig.INI"); + + // //string sPosUseType = m_PosConfig.GetMessage("olepos").GetMessageValue("PosUseType"); + // //string sKeyboard = m_PosConfig.GetMessage("control").GetMessageValue("Keyboard"); + + // //for (int i = 0; i < 5; i++) + // //{ + // // if (sPosUseType == "2" || sPosUseType == "9" || sPosUseType == "4" || sKeyboard == "2") + // // // POS모델 ==> 2:7K, 9.B20(Toshiba) 4.3000XC(분스) + // // // POS키보드 ==> (0:104, 1:40, 2:32) + // // Console.Beep(); + // // else + // // BuzzOn(0, 0); + // // Thread.Sleep(200); + // //} + // } + // catch (Exception ex) + // { + // UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + // "DeviceScanner.OnBeepSound()", ex.Message); + // } + //} + + //private void MessageStartTimer(int dueTime) + //{ + // if (m_nErrorCount < 2) + // { + // Timer t = new Timer(new TimerCallback(MessageTimerProc)); + // t.Change(dueTime, 0); + // } + //} + + //private void MessageTimerProc(object state) + //{ + // m_nErrorCount++; + // // The state object is the Timer object. + // Timer t = (Timer)state; + // t.Dispose(); + + // Cosmos.CommonManager.WinManager.ErrorMessage("해당 화면에서 스캐너를 입력 할 수 없습니다.", "스캐너 입력 오류", true); + // m_nErrorCount--; + //} + + ///// + ///// + ///// + ///// + ///// + //private void Scanner_ErrorEvent(object sender, DeviceErrorEventArgs e) + //{ + // try + // { + // ASCIIEncoding encoder = new ASCIIEncoding(); + + // m_sScanData = encoder.GetString(scanner.ScanData); + // m_sScanDataLabel = encoder.GetString(scanner.ScanDataLabel); + // m_sScanDataType = scanner.ScanDataType.ToString(); + + // UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + // "DeviceScanner.Scanner_ErrorEvent()", + // "ErrorEvent 발생 ScanData=[" + m_sScanData + "] ScanDataLabel=[" + m_sScanDataLabel + "] ScanDataType=[" + m_sScanDataType + "]"); + + // devStatus.Scanner.Data = string.Empty; + // devStatus.Scanner.DataLabel = string.Empty; + + // scanner.ClearInput(); + // scanner.DataEventEnabled = true; + + // devStatus.Scanner.Status = "ERROR EVENT"; + // } + // catch (Exception ex) + // { + // UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + // "DeviceScanner.Scanner_ErrorEvent()", ex.Message); + + // devStatus.Scanner.Status = "ErrorEvent Error 발생"; + // } + //} + + /// + /// Scanner StateServer 정보 초기화 + /// + private void DeviceStatusInit() + { + devStatus.Scanner.Data = ""; + devStatus.Scanner.DataLabel = ""; + devStatus.Scanner.DataType = ""; + devStatus.Scanner.DeviceName = ""; + devStatus.Scanner.Status = ""; + devStatus.Scanner.Open = false; + } + + /// + /// 디바이스 Close시 처리함수 + /// + /// + public bool CloseDevice() + { + bool bRet = false; + + try + { + //if (scanner == null) + // return bRet; + + //scanner.DataEventEnabled = false; + //scanner.DeviceEnabled = false; + //scanner.Release(); + //scanner.Close(); + //scanner = null; + bRet = true; + devStatus.Scanner.Status = "CLOSE"; + devStatus.Scanner.Open = false; + bw.DoWork -= OlePosHandler; + } + catch (Exception ex) + { + bw.DoWork -= OlePosHandler; + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceScanner.CloseDevice()", ex.Message); + + devStatus.Scanner.Status = "CLOSE EXCEPTION"; + } + return bRet; + } + + /// + /// 장비의 Event 발생 Enable 상태 설정 + /// True:사용가능, False:사용불가능 + /// + public bool DeviceEnabled + { + get + { + try + { + //if (scanner.DeviceEnabled && scanner.DataEventEnabled) + // return true; + //else + return false; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceScanner.DeviceEnabled()", ex.Message); + return false; + } + } + set + { + try + { + bool bRet = SetDeviceEnabled(value); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceScanner.DeviceEnabled()", ex.Message); + } + } + } + + /// + /// 장비의 Event 발생 Enable 상태 설정 + /// True:사용가능, False:사용불가능 + /// + /// + /// + private bool SetDeviceEnabled(bool bEnable) + { + bool bRet = false; + + try + { + //scanner.DataEventEnabled = bEnable; + //scanner.DeviceEnabled = bEnable; + devStatus.Scanner.Status = "DEVICE ENABLED " + bEnable.ToString(); + bRet = true; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, // Project Name (프로젝트명) + "DeviceScanner.SetDeviceEnabled()", ex.Message); + devStatus.Scanner.Status = "DEVICE ENABLED FAIL"; + } + return bRet; + } + } +} diff --git a/Agent/OLEDevice/DeviceSignPad.cs b/Agent/OLEDevice/DeviceSignPad.cs new file mode 100644 index 0000000..95ce929 --- /dev/null +++ b/Agent/OLEDevice/DeviceSignPad.cs @@ -0,0 +1,1934 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.Common; +using Cosmos.CommonManager; +using System.Runtime.InteropServices; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : 사인패드 제어 +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.OLEDevice +{ + public class DeviceSignPad : ISignPadUs + { + #region SpcnPos.DLL 함수 + /// + /// [사인패드] 전자서명 요청 함수 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnGetSign(int input_amt, byte[] input_sign_path, byte[] input_sign_name, byte[] output_msg); + + /// + /// [사인패드] 전자서명 요청 함수 EX(메세지) + /// + /// + /// + /// + /// + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnGetSignEx(byte[] input_msg1, byte[] input_msg2, byte[] input_msg3, byte[] input_msg4, byte[] input_sign_path, byte[] input_sign_name, byte[] output_msg); + + /// + /// [사인패드] 비밀번호 요청 함수 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnGetPin(byte[] input_pin_block, byte[] output_msg); + + /// + /// [사인패드] 사용자정보 요청 함수 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnGetMsg(int maskingType, byte[] show_msg, byte[] output_msg); + + /// + /// [사인패드] 사용자정보 요청 함수(MAX 처리) + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnGetMsg2(int maskingType, int maxLen, byte[] show_msg, byte[] output_msg); + + // 환경설정 정보 가져오기 + [DllImport("SpcnPos.dll")] + public static extern int SpcnGetFlag(byte[] appName, byte[] keyName, byte[] output, int outputMaxLen); + + // 환경설정 정보 설정하기 + [DllImport("SpcnPos.dll")] + public static extern int SpcnSetFlag(byte[] appName, byte[] keyName, byte[] value); + + // 상호인증 요청 + [DllImport("SpcnPos.dll")] + public static extern int SpcnIcReaderKeyDownload(byte[] inTrmlId, byte[] inAuthInfo); + + // 무결성 요청 + [DllImport("SpcnPos.dll")] + public static extern int SpcnIcReaderIntegrity(byte[] outResTime); + + // 키오스크 전자서명 요청 + [DllImport("SpcnPos.dll")] + public static extern int SpcnGetKioskSign(byte[] input_sign_path, byte[] input_sign_name, byte[] output_msg); + + // 승인함수 + [DllImport("SpcnPos.dll")] + public static extern int SpcnIcPos(byte[] input_msg, int input_msg_len, byte[] signData, byte[] icData, byte[] oilData, byte[] authInfo, byte[] output_msg); + + // (RF) RF카드 정보 조회 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfPrepaidCardInfo(byte[] output_msg); + + // (RF) RF카드 잔액 조회 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfCommonCardInfo(byte[] samType, byte[] output_msg); + + // (RF) RF카드 잔액 조회 (비프 여부 - 화면표시 여부로 사용) + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfCommonCardInfoEx(byte[] samType, byte[] isBeep, byte[] output_msg); + + // (RF) SAM ID조회 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfGetSamId(byte[] samType, byte[] output_msg); + + // (RF) T머니/EB카드 개시거래 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfStart(byte[] terminalNo, byte[] bizName, byte[] docSeq, byte[] samType, byte[] output_msg); + + // (RF) T머니/EB카드 운영정보 다운로드 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfDownOperatingData(byte[] terminalNo, byte[] bizName, byte[] docSeq, byte[] samType, byte[] output_msg); + + // (RF) PAYON SAM 등록 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfPayonOpen(byte[] terminalNo, byte[] bizName, byte[] docSeq, byte[] cardType); + + /// + /// RF 시간 설정 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfReaderSetTime(); + + // (RF) 후불 결제 거래 카드 정보 요청 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfCreditCardInfo(byte[] terminalNo, byte[] samType, byte[] amount, byte[] msg1, byte[] msg2, byte[] msg3, byte[] output_msg); + + // (RF) 선불카드 지불 거래 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfPrepaidCardApprove(byte[] terminalNo, byte[] samType, byte[] amount, byte[] msg1, byte[] msg2, byte[] msg3, byte[] output_msg); + + // (RF) 선불카드 지불 재거래 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfPrepaidCardApproveRe(byte[] terminalNo, byte[] samType, byte[] amount, byte[] msg1, byte[] msg2, byte[] msg3, byte[] output_msg); + + // (RF) 선불카드 직전취소 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfPrepaidCardProcCancel(byte[] terminalNo, byte[] samType, byte[] msg1, byte[] msg2, byte[] msg3, byte[] org_money, byte[] org_dateTime, byte[] org_receiptNo, byte[] output_msg); + + // (RF) 선불카드 현금반품 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfPrepaidCardVoidCash(byte[] terminalNo, byte[] samType, byte[] msg1, byte[] msg2, byte[] msg3, byte[] org_money, byte[] org_dateTime, byte[] org_receiptNo, byte[] output_msg); + + // (RF) 선불카드 반품충전 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfPrepaidCardCancel(byte[] terminalNo, byte[] bizName, byte[] docSeq, byte[] samType, byte[] msg1, byte[] msg2, byte[] msg3, byte[] receiptNo, byte[] org_money, byte[] org_dateTime, byte[] org_receiptNo, byte[] output_msg); + + // (RF) 거래내역 개수 조회 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfGetTranCount(byte[] samType, byte[] output_msg); + + // (RF) 마지막 거래내역 조회 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfGetLastTran(byte[] samType, byte[] output_msg); + + // (RF) 거래내역 조회 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfGetTranIndex(byte[] samType, byte[] tranIndex, byte[] output_msg); + + // (RF) 거래내역 순차 조회 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfGetTranOrder(byte[] samType, byte[] tranIndex, byte[] output_msg); + + // (RF) 거래내역 삭제 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfDeleteTran(byte[] samType); + + // (RF) 거래내역 업로드 + [DllImport("SpcnPos.dll")] + public static extern int SpcnRfUploadTran(byte[] terminalNo, byte[] bizName, byte[] docSeq, byte[] receiptNo, byte[] org_money, byte[] org_dateTime, byte[] org_receiptNo, byte[] rfData, byte[] output_msg); + + // 싸인 BMP -> 데이터 변환 + [DllImport("SpcnPos.dll")] + public static extern int SpcnGetSignFromImage(byte[] filePath, byte[] output_msg); + + // 싸인패드 정보 확인((O) 응답메시지 (모델명(10) + 펌웨어버젼(20) + App버젼(30) + RF버젼(30) + 시리얼번호(30) + POS연동타입(1)) + [DllImport("SpcnPos.dll")] + public static extern int SpcnGetSignPadInfo(byte[] output_msg); + + /// + /// 키오스크 비밀번호 입력 POS사용자(은련카드용) + /// + /// 암호화에 사용될 핀블럭 + /// 암호화 되어진 비밀번호 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnGetKioskPin(byte[] input_pin_block, byte[] output); + + /// + /// 비밀번호 입력 POS사용자(해피포인트) + /// + /// 암호화 되어지지 않는 비밀번호 + /// + [DllImport("SpcnPos.dll")] + public static extern int SpcnGetKioskMsg(byte[] output); + + #endregion + + #region csp_download.DLL 함수 + /// + /// [사인패드] 업데이트 요청 함수(생성) + /// + [DllImport("csp_downloader.dll")] + public static extern int CSPDN_Create(); + + /// + /// [사인패드] 업데이트 요청 함수(초기화) + /// + [DllImport("csp_downloader.dll")] + public static extern int CSPDN_ClearFiles(int ret_code); + + /// + /// [사인패드] 업데이트 요청 함수(펌웨어) + /// + [DllImport("csp_downloader.dll")] + public static extern int CSPDN_SetFileSW(int ret_code, string updateData); + + /// + /// [사인패드] 업데이트 요청 함수(시작) + /// + [DllImport("csp_downloader.dll")] + public static extern int CSPDN_Start(int ret_code, string sign_port); + + /// + /// [사인패드] 업데이트 요청 함수(영상) + /// + [DllImport("csp_downloader.dll")] + public static extern int CSPDN_SetFileAVI(int ret_code, byte[] updateData); + + /// + /// [사인패드] 업데이트 요청 함수(이미지) + /// + [DllImport("csp_downloader.dll")] + public static extern int CSPDN_SetFileBMP(int ret_code, int index, byte[] updateData); + + /// + /// [사인패드] 업데이트 요청 함수(결과코드) + /// + [DllImport("csp_downloader.dll")] + public static extern int CSPDN_SetMessageResult(int ret_code, IntPtr hwnd, int nMessaage); + + /// + /// [사인패드] 업데이트 요청 함수(프로그래스바 결과값) + /// + [DllImport("csp_downloader.dll")] + public static extern int CSPDN_SetMessageProgress(int ret_code, IntPtr hwnd, int nMessaage); + + /// + /// [사인패드] 업데이트 자원해제 + /// + [DllImport("csp_downloader.dll")] + public static extern int CSPDN_Destroy(int ret_code); + + /// + /// [사인패드] 업데이트 종료(취소) + /// + [DllImport("csp_downloader.dll")] + public static extern int CSPDN_Stop(int ret_code); + + + //[DllImport("user32.dll", SetLastError = true)] + //private static extern int SendMessage(int hWnd, int wMsg, int wParam, int lParam); + + + #endregion + + #region 생성자 + /// + /// SPCN_Dongle.ocx 가 포함된 form 객체 + /// + //frmSignPad frmSignPad = null; + + /// + /// StateServer Object (StateServer 객체) + /// + public StateServer StateObject = (StateServer)StateServer.GetInstance(); + /// + /// Device 상태 정보 객체 + /// + public DeviceStatus m_cDevStatus = null; + + /// + /// Pos 상태 정보 객체 + /// + public PosStatus m_cPosStatus = null; + + /// + /// T-Money Host + /// + private static string m_sTMoneyHost = null; + public string TMoneyHost { get { return m_sTMoneyHost; } set { m_sTMoneyHost = value; } } + + /// + /// T-Money Port + /// + private static int m_iTMoneyPort = -1; + public int TMoneyPort { get { return m_iTMoneyPort; } set { m_iTMoneyPort = value; } } + + // 임시 pss + private int nRet_Code = 0; + + /// + /// 생성자 + /// + public DeviceSignPad() + { + try + { + //frmSignPad = new frmSignPad(); + m_cPosStatus = (PosStatus)StateObject.POS; + m_cDevStatus = (DeviceStatus)StateObject.DEVICE; + + //UpdateIniConfig(); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 Byte배열을 string으로 변환 (Byte배열의 null(0x00)값 제거) + /// + /// Byte배열을 string으로 변환 (Byte배열의 null(0x00)값 제거) + /// + /// + /// + private string ByteToString(byte[] data) + { + int inx = Array.FindIndex(data, 0, (x) => x == 0x0); + if (inx >= 0) + { + return Encoding.Default.GetString(data, 0, inx); + } + else + { + return Encoding.Default.GetString(data); + } + } + #endregion + + #region SpcnPos.dll 이 사용하는 SpcnPosCfg.ini 파일 update + /// + /// SpcnPos.dll 이 사용하는 SpcnPosCfg.ini 파일 update + /// + public void UpdateIniConfig() + { + StringBuilder sbGetText = new StringBuilder(); + CmMessage m_PosDevice = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + "PosDevice.INI"); + string sPortNumber = string.Empty; + string sAutoFlag = string.Empty; + string sMinCnt = string.Empty; + string sTimeOut = string.Empty; + long lBaudrate = 0; + bool bRtn = false; + try + { + sPortNumber = CmUtil.StringNullEmpty(GetConfigInfo(m_PosDevice, "SIGNPAD", "SerialPortNumber")); + lBaudrate = CmUtil.LongParse(CmUtil.StringNullEmpty(GetConfigInfo(m_PosDevice, "SIGNPAD", "SerialBaudRate"))); + sAutoFlag = CmUtil.StringNullEmpty(GetConfigInfo(m_PosDevice, "SIGNPAD", "AutoFlag")); + sMinCnt = CmUtil.StringNullEmpty(GetConfigInfo(m_PosDevice, "SIGNPAD", "MinCnt")); + sTimeOut = CmUtil.StringNullEmpty(GetConfigInfo(m_PosDevice, "SIGNPAD", "TimeOut")); + + if (sPortNumber.Length < 3 || lBaudrate <= 0) + { + new Exception("PosDevice.INI 사인패드 설정 오류"); + return; + } + + // SIGN_PORT 설정 + sbGetText.Clear(); + WinAPI.GetPrivateProfileString(PosConst.POS_SIGNPAD_CONFIG.APPNAME, + PosConst.POS_SIGNPAD_CONFIG.KEY_SIGN_PORT, + string.Empty, + sbGetText, + 64, + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + + + if (sbGetText.ToString() != sPortNumber.Substring(3, sPortNumber.Length - 3))//Yoo modify 20160613 + { + bRtn = WinAPI.WritePrivateProfileString(PosConst.POS_SIGNPAD_CONFIG.APPNAME, + PosConst.POS_SIGNPAD_CONFIG.KEY_SIGN_PORT, + sPortNumber.Substring(3, sPortNumber.Length - 3), + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig);//Yoo modify 20160613 + if (bRtn == false) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + PosConst.INI_FILE_NAME.ICReaderConfig + "/" + PosConst.POS_SIGNPAD_CONFIG.KEY_SIGN_PORT + " 쓰기 실패"); + } + } + // SIGN_BAUDRATE 설정 + sbGetText.Clear(); + WinAPI.GetPrivateProfileString(PosConst.POS_SIGNPAD_CONFIG.APPNAME, + PosConst.POS_SIGNPAD_CONFIG.KEY_SIGN_BAUDRATE, + string.Empty, + sbGetText, + 64, + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + if (sbGetText.ToString() != Convert.ToString(lBaudrate)) + { + bRtn = WinAPI.WritePrivateProfileString(PosConst.POS_SIGNPAD_CONFIG.APPNAME, + PosConst.POS_SIGNPAD_CONFIG.KEY_SIGN_BAUDRATE, + Convert.ToString(lBaudrate), + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + if (bRtn == false) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + PosConst.INI_FILE_NAME.ICReaderConfig + "/" + PosConst.POS_SIGNPAD_CONFIG.KEY_SIGN_BAUDRATE + " 쓰기 실패"); + } + } + // SIGN_AUTO_FLAG 설정 + sbGetText.Clear(); + WinAPI.GetPrivateProfileString(PosConst.POS_SIGNPAD_CONFIG.APPNAME, + PosConst.POS_SIGNPAD_CONFIG.KEY_SIGN_AUTOFLAG, + string.Empty, + sbGetText, + 64, + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + if (sbGetText.ToString() != sAutoFlag) + { + bRtn = WinAPI.WritePrivateProfileString(PosConst.POS_SIGNPAD_CONFIG.APPNAME, + PosConst.POS_SIGNPAD_CONFIG.KEY_SIGN_AUTOFLAG, + sAutoFlag, + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + if (bRtn == false) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + PosConst.INI_FILE_NAME.ICReaderConfig + "/" + PosConst.POS_SIGNPAD_CONFIG.KEY_SIGN_AUTOFLAG + " 쓰기 실패"); + } + } + // SIGN_MIN_CNT 설정 + sbGetText.Clear(); + WinAPI.GetPrivateProfileString(PosConst.POS_SIGNPAD_CONFIG.APPNAME, + PosConst.POS_SIGNPAD_CONFIG.KEY_SIGN_MIN_CNT, + string.Empty, + sbGetText, + 64, + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + if (sbGetText.ToString() != sMinCnt) + { + bRtn = WinAPI.WritePrivateProfileString(PosConst.POS_SIGNPAD_CONFIG.APPNAME, + PosConst.POS_SIGNPAD_CONFIG.KEY_SIGN_MIN_CNT, + sMinCnt, + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + if (bRtn == false) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + PosConst.INI_FILE_NAME.ICReaderConfig + "/" + PosConst.POS_SIGNPAD_CONFIG.KEY_SIGN_MIN_CNT + " 쓰기 실패"); + } + } + // SIGN_TIMEOUT 설정 + sbGetText.Clear(); + WinAPI.GetPrivateProfileString(PosConst.POS_SIGNPAD_CONFIG.APPNAME, + PosConst.POS_SIGNPAD_CONFIG.KEY_SIGN_TIMEOUT, + string.Empty, + sbGetText, + 64, + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + if (sbGetText.ToString() != sTimeOut) + { + bRtn = WinAPI.WritePrivateProfileString(PosConst.POS_SIGNPAD_CONFIG.APPNAME, + PosConst.POS_SIGNPAD_CONFIG.KEY_SIGN_TIMEOUT, + sTimeOut, + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + if (bRtn == false) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + PosConst.INI_FILE_NAME.ICReaderConfig + "/" + PosConst.POS_SIGNPAD_CONFIG.KEY_SIGN_TIMEOUT + " 쓰기 실패"); + } + } + + //#20170904 IC_MSG_CARD, RF_MSG_CARD 문구 추가 start + // IC_MSG_CARD 설정 + sbGetText.Clear(); + WinAPI.GetPrivateProfileString(PosConst.POS_SIGNPAD_CONFIG.APPNAME, + PosConst.POS_SIGNPAD_CONFIG.KEY_IC_MSG_CARD, + string.Empty, + sbGetText, + 64, + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + + if (sbGetText.ToString() != MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0726)) + { + bRtn = WinAPI.WritePrivateProfileString(PosConst.POS_SIGNPAD_CONFIG.APPNAME, + PosConst.POS_SIGNPAD_CONFIG.KEY_IC_MSG_CARD, + MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0726), + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + if (bRtn == false) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + PosConst.INI_FILE_NAME.ICReaderConfig + "/" + PosConst.POS_SIGNPAD_CONFIG.KEY_IC_MSG_CARD + " 쓰기 실패"); + } + } + + // RF_MSG_CARD 설정 + sbGetText.Clear(); + WinAPI.GetPrivateProfileString(PosConst.POS_SIGNPAD_CONFIG.APPNAME, + PosConst.POS_SIGNPAD_CONFIG.KEY_RF_MSG_CARD, + string.Empty, + sbGetText, + 64, + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + + if (sbGetText.ToString() != MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0727)) + { + bRtn = WinAPI.WritePrivateProfileString(PosConst.POS_SIGNPAD_CONFIG.APPNAME, + PosConst.POS_SIGNPAD_CONFIG.KEY_RF_MSG_CARD, + MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0727), + BaseCom.NxBinPath + PosConst.INI_FILE_NAME.ICReaderConfig); + if (bRtn == false) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + UserCom.WARNING_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 (함수명)) + PosConst.INI_FILE_NAME.ICReaderConfig + "/" + PosConst.POS_SIGNPAD_CONFIG.KEY_RF_MSG_CARD + " 쓰기 실패"); + } + } + //#20170904 IC_MSG_CARD, RF_MSG_CARD 문구 추가 end + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 GetConfigInfo(CmMessage cCfgInfo, string sGroup, string sValueName) + { + return GetConfigInfo(cCfgInfo, sGroup, sValueName, ""); + } + private string GetConfigInfo(CmMessage cCfgInfo, string sGroup, string sValueName, string sDefault) + { + try + { + string sValue = cCfgInfo.GetMessage(sGroup).GetMessageValue(sValueName); + if (sValue == null) + return sDefault; + else + return sValue; + } + catch { } + + return sDefault; + } + #endregion + + #region 사인패드 관련 함수 + /// + /// [사인패드] 전자서명 요청 + /// + /// 거래금액 + /// 전자서명 생성 디렉토리 + /// 전자서명 생성 파일명 + /// 전자서명 데이터 + /// + public bool GetSign_SignPad(int iAmount, string sSignDataPath, string sSignDataName, ref string sSignData) + { + int iRtn = 0; + bool bRtn = false; + byte[] arSignData = new byte[2048]; + + try + { + sSignData = string.Empty; + Array.Clear(arSignData, 0x0, arSignData.Length); + if (m_cDevStatus.SignPad.UseYn != true) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0390); + return bRtn; + } +#if !DEVICE_MSR_VER + //if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true) + //{ + // Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0387); + // return bRtn; + //} + + iRtn = SpcnGetSign(iAmount, Encoding.Default.GetBytes(sSignDataPath), Encoding.Default.GetBytes(sSignDataName), arSignData); +#else + if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + { + //if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true) + //{ + // Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0387); + // return bRtn; + //} + + iRtn = SpcnGetSign(iAmount, Encoding.Default.GetBytes(sSignDataPath), Encoding.Default.GetBytes(sSignDataName), arSignData); + } + else + { + iRtn = SpcnGetSign(iAmount, Encoding.Default.GetBytes(sSignDataPath), Encoding.Default.GetBytes(sSignDataName), arSignData); + } +#endif + if (iRtn > 0) + { + sSignData = ByteToString(arSignData); + bRtn = true; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + /// + /// [사인패드] 전자서명 요청EX + /// + /// 거래금액 + /// 전자서명 생성 디렉토리 + /// 전자서명 생성 파일명 + /// 전자서명 데이터 + /// + public bool GetSign_SignPadEx(string sMsg1, string sMsg2, string sMsg3, string sMsg4, string sSignDataPath, string sSignDataName, ref string sSignData) + { + int iRtn = 0; + bool bRtn = false; + byte[] arSignData = new byte[2048]; + + try + { + sSignData = string.Empty; + Array.Clear(arSignData, 0x0, arSignData.Length); + + if (m_cDevStatus.SignPad.UseYn != true) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0390); + return bRtn; + } + +#if !DEVICE_MSR_VER + //if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true && m_cDevStatus.SignPad.UseYn == true) + //{ + // Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0387); + // return bRtn; + //} + iRtn = SpcnGetSignEx(Encoding.Default.GetBytes(sMsg1), Encoding.Default.GetBytes(sMsg2), Encoding.Default.GetBytes(sMsg3), Encoding.Default.GetBytes(sMsg4), Encoding.Default.GetBytes(sSignDataPath), Encoding.Default.GetBytes(sSignDataName), arSignData); +#else + if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + { + //if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true && m_cDevStatus.SignPad.UseYn == true) + //{ + // Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0387); + // return bRtn; + //} + iRtn = SpcnGetSignEx(Encoding.Default.GetBytes(sMsg1), Encoding.Default.GetBytes(sMsg2), Encoding.Default.GetBytes(sMsg3), Encoding.Default.GetBytes(sMsg4), Encoding.Default.GetBytes(sSignDataPath), Encoding.Default.GetBytes(sSignDataName), arSignData); + } + else + { + iRtn = SpcnGetSignEx(Encoding.Default.GetBytes(sMsg1), Encoding.Default.GetBytes(sMsg2), Encoding.Default.GetBytes(sMsg3), Encoding.Default.GetBytes(sMsg4), Encoding.Default.GetBytes(sSignDataPath), Encoding.Default.GetBytes(sSignDataName), arSignData); + } +#endif + + if (iRtn > 0) + { + sSignData = ByteToString(arSignData); + bRtn = true; + } + else + { + Cosmos.CommonManager.WinManager.ErrorMessage( ErrCodeToMsg(iRtn)); + bRtn = false; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + /// + /// [사인패드] 전자서명 요청 터치패드(키오스크,테블릿용) + /// + /// + /// + /// + /// + public bool GetSign_SignPadForTouchpad(string sSignDataPath, string sSignDataName, ref string sSignData) + { + int iRtn = 0; + bool bRtn = false; + byte[] arSignData = new byte[2048]; + + try + { + + //이 함수 사용시 설정 추가 부분! + //============================================ + //SpcnPoscfg.ini 해당 항목 추가 + //============================================ + //KIOSK_CUSTOM_SET=Y + //[DESIGN] + //KIOSK_SIGN_DIALOG_POS=50,100,800,800 + //KIOSK_SIGN_BG_COLOR=0,0,0 + //KIOSK_SIGN_FONT_COLOR=150,100,100 + //KIOSK_SIGN_BTN_COLOR=40,40,40 + //KIOSK_SIGN_FONT=굴림,27 + //============================================ + //KIOSK_CUSTOM_SET : Y 고정 + //KIOSK_SIGN_DIALOG_POS : 위치 및 크기 + //KIOSK_SIGN_DIALOG_POS : 폼 배경색 + //KIOSK_SIGN_BG_COLOR : 싸인화면 배경색 + //KIOSK_SIGN_FONT_COLOR : 글자폰트 + //KIOSK_SIGN_BTN_COLOR : 버튼색상 + //KIOSK_SIGN_FONT : 폰트 및 사이즈 + + sSignData = string.Empty; + Array.Clear(arSignData, 0x0, arSignData.Length); + //if (m_cPosStatus.Base.OlePosSignPadUseFlag != "1") + //{ + // Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0390); + // return bRtn; + //} + //else if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true && m_cPosStatus.Base.OlePosSignPadUseFlag == "1") + //{ + // Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0387); + // return bRtn; + //} + + iRtn = SpcnGetKioskSign(Encoding.Default.GetBytes(sSignDataPath), Encoding.Default.GetBytes(sSignDataName), arSignData); + + if (iRtn > 0) + { + sSignData = ByteToString(arSignData); + bRtn = true; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + /// + /// BitMap -> SignData 변환 + /// + /// + /// + /// + public bool GetSign_BmpToData(string sSignDataPath, ref string sSignData) + { + int iRtn = 0; + bool bRtn = false; + byte[] arSignData = new byte[2048]; + + try + { + sSignData = string.Empty; + Array.Clear(arSignData, 0x0, arSignData.Length); + + iRtn = SpcnGetSignFromImage(Encoding.Default.GetBytes(sSignDataPath), arSignData); + + if (iRtn > 0) + { + sSignData = ByteToString(arSignData); + bRtn = true; + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + /// + /// 싸인패드 정보 확인[(O) 응답메시지 (모델명(10) + 펌웨어버젼(20) + App버젼(30) + RF버젼(30) + 시리얼번호(30) + POS연동타입(1)] + /// + /// + /// + public bool GetSignPadInfo(ref string sRsltMsg) + { + int iRtn = 0; + bool bRtn = false; + byte[] outMsg = new byte[2049]; + + try + { + sRsltMsg = string.Empty; + Array.Clear(outMsg, 0x0, outMsg.Length); + + iRtn = SpcnGetSignPadInfo(outMsg); + + if (iRtn > 0) + { + sRsltMsg = ByteToString(outMsg); + bRtn = true; + } + else + { + sRsltMsg = string.Empty; + } + } + catch (Exception ex) + { + sRsltMsg = string.Empty; + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + + /// + /// [사인패드] 비밀번호 요청 + /// + /// 마스킹 처리된 카드번호 + /// 암호화 되어진 비밀번호 + /// + public bool GetPin_SignPad(string sMaskedCardNo, ref string sEncryptedPwd) + { + int iRtn = 0; + bool bRtn = false; + byte[] arCardNo = null; + byte[] arPwd = new byte[2048]; + + try + { + sEncryptedPwd = string.Empty; + arCardNo = Encoding.Default.GetBytes(sMaskedCardNo); + Array.Clear(arPwd, 0x0, arPwd.Length); + + for (int i = 0; i < arCardNo.Length; i++) + { + if (arCardNo[i] == '*') + { + arCardNo[i] = (byte)'0'; + } + } + + if (m_cDevStatus.SignPad.UseYn != true) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0390); + return bRtn; + } +#if !DEVICE_MSR_VER + //if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true && m_cDevStatus.SignPad.UseYn == true) + //{ + // Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0387); + // return bRtn; + //} + iRtn = SpcnGetPin(arCardNo, arPwd); +#else + if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + { + //if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true && m_cDevStatus.SignPad.UseYn == true) + //{ + // Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0387); + // return bRtn; + //} + iRtn = SpcnGetPin(arCardNo, arPwd); + } + else + { + iRtn = SpcnGetPin(arCardNo, arPwd); + } +#endif + if (iRtn <= 0) + { + if (iRtn != -84) + { + string sErrMsg = ErrCodeToMsg(iRtn); + Cosmos.CommonManager.WinManager.ErrorMessage(sErrMsg); + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + iRtn + "=" + sErrMsg); + } + return false; + } + + sEncryptedPwd = ByteToString(arPwd); + bRtn = true; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + + /// + /// 은련카드 비밀번호 사용자 입력 처리 + /// + /// + /// + /// + public bool GetKioskPin(string sMaskedCardNo, ref string sEncryptedPwd) + { + int iRtn = 0; + bool bRtn = false; + byte[] arCardNo = null; + byte[] arPwd = new byte[2048]; + + try + { + sEncryptedPwd = string.Empty; + arCardNo = Encoding.Default.GetBytes(sMaskedCardNo.Replace("*", "0")); // 카드번호 마스킹 '*' => '0' 으로 치환! + Array.Clear(arPwd, 0x0, arPwd.Length); + + iRtn = SpcnGetKioskPin(arCardNo, arPwd); + if (iRtn <= 0) + { + if (iRtn != -84) + { + string sErrMsg = ErrCodeToMsg(iRtn); + Cosmos.CommonManager.WinManager.ErrorMessage(sErrMsg); + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + iRtn + "=" + sErrMsg); + } + return false; + } + + sEncryptedPwd = ByteToString(arPwd); + bRtn = true; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + /// + /// 비밀번호 입력 처리(해피포인트) + /// + /// + /// + public bool GetKioskMsg(ref string sEncryptedPwd) + { + int iRtn = 0; + bool bRtn = false; + byte[] arPwd = new byte[2048]; + + try + { + sEncryptedPwd = string.Empty; + + Array.Clear(arPwd, 0x0, arPwd.Length); + + iRtn = SpcnGetKioskMsg(arPwd); + if (iRtn <= 0) + { + if (iRtn != -84) + { + string sErrMsg = ErrCodeToMsg(iRtn); + Cosmos.CommonManager.WinManager.ErrorMessage(sErrMsg); + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + iRtn + "=" + sErrMsg); + } + return false; + } + + sEncryptedPwd = ByteToString(arPwd); + bRtn = true; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + + /// + /// 사용자정보 요청 함수 + /// + /// + /// + /// + /// + public bool GetMsg_SignPad(bool bMaskingEnable, string sDisplayMsg, ref string sReceivedData) + { + return GetMsg_SignPad(bMaskingEnable, sDisplayMsg, ref sReceivedData, 0); + } + + /// + /// 사용자정보 요청 함수 + /// + /// + /// + /// + /// + public bool GetMsg_SignPad(bool bMaskingEnable, string sDisplayMsg, ref string sReceivedData, int iMaxLengh) + { + int iRtn = 0; + bool bRtn = false; + byte[] arReceivedData = new byte[2048]; + + try + { + sReceivedData = string.Empty; + Array.Clear(arReceivedData, 0x0, arReceivedData.Length); + + if (m_cDevStatus.SignPad.UseYn != true) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0390); + return bRtn; + } +#if !DEVICE_MSR_VER + //if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true && m_cDevStatus.SignPad.UseYn) + //{ + // Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0387); + // return bRtn; + //} + + if (iMaxLengh > 0 ) + { + iRtn = SpcnGetMsg2(bMaskingEnable ? 0 : 1, iMaxLengh, Encoding.Default.GetBytes(sDisplayMsg), arReceivedData); + } + else + { + iRtn = SpcnGetMsg(bMaskingEnable ? 0 : 1, Encoding.Default.GetBytes(sDisplayMsg), arReceivedData); + } +#else + if (m_cDevStatus.ICReader.UseYn == true) // 여전법 인증여부(0:MSR, 1:IC) + { + //if (m_cDevStatus.ICReader.Integrity_SignPad_Status != true && m_cDevStatus.SignPad.UseYn) + //{ + // Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0387); + // return bRtn; + //} + + if (iMaxLengh > 0) + { + iRtn = SpcnGetMsg2(bMaskingEnable ? 0 : 1, iMaxLengh, Encoding.Default.GetBytes(sDisplayMsg), arReceivedData); + } + else + { + iRtn = SpcnGetMsg(bMaskingEnable ? 0 : 1, Encoding.Default.GetBytes(sDisplayMsg), arReceivedData); + } + } + else + { + if (iMaxLengh > 0) + { + iRtn = SpcnGetMsg2(bMaskingEnable ? 0 : 1, iMaxLengh, Encoding.Default.GetBytes(sDisplayMsg), arReceivedData); + } + else + { + iRtn = SpcnGetMsg(bMaskingEnable ? 0 : 1, Encoding.Default.GetBytes(sDisplayMsg), arReceivedData); + } + } +#endif + if (iRtn <= 0) + { + if (iRtn != -84) + { + string sErrMsg = ErrCodeToMsg(iRtn); + Cosmos.CommonManager.WinManager.ErrorMessage(sErrMsg); + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + iRtn + "=" + sErrMsg); + } + return false; + } + + sReceivedData = ByteToString(arReceivedData); + bRtn = true; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 bRtn; + } + + /// + /// 서명패드 업데이트(펌웨어) + /// + /// + public bool SetFirmware_SignPad_Update(int nCreateCode, string sDatePath) + { + bool bRtn = true; + + int nRet = -1; + + nRet = CSPDN_ClearFiles(nCreateCode); + if (nRet < 0) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + nRet); + bRtn = false; + } + + nRet = -1; + + nRet = CSPDN_SetFileSW(nCreateCode, sDatePath); + if (nRet < 0) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + nRet); + bRtn = false; + } + + return bRtn; + } + + /// + /// 서명패드 업데이트(동영상) + /// + /// + public bool SetAvi_SignPad_Update(int nCreateCode, string sDatePath) + { + bool bRtn = true; + + int nRet = -1; + + nRet = CSPDN_ClearFiles(nCreateCode); + if (nRet < 0) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + nRet); + return false; + } + + nRet = -1; + nRet = CSPDN_SetFileAVI(nCreateCode, Encoding.Default.GetBytes(sDatePath)); + if (nRet < 0) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + nRet); + return false; + } + + return bRtn; + } + + /// + /// 서명패드 업데이트(이미지) + /// + /// + public bool SetImage_SignPad_Update(int nCreateCode, int nIndex, string sDatePath) + { + bool bRtn = true; + + int nRet = -1; + + // + //nRet = CSPDN_ClearFiles(nRet_Code); + //if (nRet <= 0) + //{ + // UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + // , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + // , "ERROR => CODE : " + nRet); + // return false; + //} + + //nRet = -1; + nRet = CSPDN_SetFileBMP(nCreateCode, nIndex, Encoding.Default.GetBytes(sDatePath)); + if (nRet < 0) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + nRet); + return false; + } + + return bRtn; + } + + /// + /// 서명패드 업데이트 완료 후 시작 + /// + /// + public bool SignPad_Start(int nCreateCode, string sSignPort) + { + bool bRtn = false; + + int nRet = -1; + + nRet = CSPDN_Start(nCreateCode, sSignPort); + if (nRet < 0) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + nRet); + return bRtn; + } + bRtn = true; + + return bRtn; + } + + /// + /// 서명패드 업데이트(결과메세지 리턴) + /// + /// + public bool SignPad_Update_Return(int nCreateCode, IntPtr nhwnd, int nMessage) + { + bool bRtn = false; + + int nRet = -1; + + nRet = CSPDN_SetMessageResult(nCreateCode, nhwnd, nMessage); + + return bRtn; + } + + /// + /// 서명패드 업데이트(결과메세지 리턴) + /// + /// + public bool SignPad_Update_Progress_Return(int nCreateCode, IntPtr nhwnd, int nMessage) + { + bool bRtn = false; + + int nRet = -1; + + nRet = CSPDN_SetMessageProgress(nCreateCode, nhwnd, nMessage); + + return bRtn; + } + + + /// + /// 서명패드 업데이트 파일 코드(각 함수에 다 넣어 줌) + /// + /// + public int SignPad_Create_UpdateCode() + { + int nRet_Code = -1; + + nRet_Code = CSPDN_Create(); + + return nRet_Code; + } + + /// + /// 서명패드 업데이트 자원해제 + /// + /// + public int SignPad_Update_Destroy(int nCreateCode) + { + int nRet = -1; + + CSPDN_Destroy(nCreateCode); + + return nRet; + } + + /// + /// 서명패드 업데이트 파일초기화 + /// + /// + public int SignPad_Update_FileClear(int nCreateCode) + { + int nRet = -1; + + CSPDN_ClearFiles(nCreateCode); + + return nRet; + } + + + /// + /// 서명패드 업데이트 취소 + /// + /// + public int SignPad_Update_Stop(int nCreateCode) + { + int nRet = -1; + + nRet = CSPDN_Stop(nCreateCode); + + return nRet; + } + + #endregion + + #region T-Money 기능 + /// + /// 운영정보 다운로드 + /// + /// + /// + /// + /// + /// + /// + public string TMoneyDownload(string sTerminalNo, string sBizNm, string sSeqNo, string sCardType, string sDownType, ref byte[] rep_array) + { + //byte[] rep_array = new byte[2049]; + int iReturn = -1; + string sRet = UserCom.RST_ERR; + int iRtn = -1; + try + { + // 서명패드 시간설정 요청 + if (m_cDevStatus.ICReader.UseYn == true) + iRtn = SpcnRfReaderSetTime(); + + if (sCardType == "T") + { + //WinManager.ShowSearchMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0349)); + + iReturn = SpcnRfDownOperatingData(GetByteArrayFromString(sTerminalNo), GetByteArrayFromString(sBizNm), GetByteArrayFromString(sSeqNo), GetByteArrayFromString(sCardType), rep_array); + } + else if (sCardType == "E") + { + //WinManager.ShowSearchMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0360)); + + iReturn = SpcnRfDownOperatingData(GetByteArrayFromString(sTerminalNo), GetByteArrayFromString(sBizNm), GetByteArrayFromString(sSeqNo), GetByteArrayFromString(sCardType), rep_array); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + finally + { + if (iReturn > 0) sRet = UserCom.RST_OK; + //WinManager.HideSearchMessage(this); + } + return sRet; + } + /// + /// T-Money 개시 + /// + /// + /// + /// + /// + /// + public string TMoneyOpen(string sTerminalNo, string sBizNm, string sSeqNo, string sCardType) + { + int iReturn = -1; + byte[] rep_array = new byte[2049]; + string sRet = UserCom.RST_ERR; + int iRtn = -1; + + try + { + // 서명패드 시간설정 요청 + if (m_cDevStatus.ICReader.UseYn == true) + iRtn = SpcnRfReaderSetTime(); + + if (sCardType == "Y") + { + //WinManager.ShowSearchMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0350)); + iReturn = SpcnRfPayonOpen(GetByteArrayFromString(sTerminalNo), GetByteArrayFromString(sBizNm), GetByteArrayFromString(sSeqNo), GetByteArrayFromString(sCardType)); + } + else if (sCardType == "T") + { + //WinManager.ShowSearchMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0348)); + iReturn = SpcnRfStart(GetByteArrayFromString(sTerminalNo), GetByteArrayFromString(sBizNm), GetByteArrayFromString(sSeqNo), GetByteArrayFromString(sCardType), rep_array); + } + else if (sCardType == "E") + { + //WinManager.ShowSearchMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0359)); + iReturn = SpcnRfStart(GetByteArrayFromString(sTerminalNo), GetByteArrayFromString(sBizNm), GetByteArrayFromString(sSeqNo), GetByteArrayFromString(sCardType), rep_array); + } + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + } + finally + { + if (iReturn > 0) sRet = UserCom.RST_OK; + + //WinManager.HideSearchMessage(this); + } + return sRet; + } + + /// + /// T-Money 잔액조회 + /// + /// + /// + /// + /// + public int TMoneyInfo(string sCardType, ref string sRet) + { + return TMoneyInfo(sCardType, ref sRet, "N" ); + } + public int TMoneyInfo(string sCardType, ref string sRet, string sBeep = "N" ) + { + int nReturn = -1; + byte[] rep_array = new byte[2049]; + try + { + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.SignPad.UseYn != true) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0390); + return nReturn; + } + + //nReturn = SpcnRfCommonCardInfo(GetByteArrayFromString(sCardType), rep_array); + nReturn = SpcnRfCommonCardInfoEx(GetByteArrayFromString(sCardType), GetByteArrayFromString(sBeep), rep_array); + + if (nReturn <= 0) + { + if (nReturn != -84) + { + string sErrMsg = ErrCodeToMsg(nReturn); + Cosmos.CommonManager.WinManager.ErrorMessage(sErrMsg); + + UserLog.WriteLogFile(UserCom.LOG_IOS, UserCom.INFO_LEVEL, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name + , System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()" + , "ERROR => CODE : " + nReturn + "=" + sErrMsg); + } + return nReturn; + } + + sRet = System.Text.Encoding.Default.GetString(rep_array); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 nReturn; + } + + /// + /// T-Money 지불거래 + /// + /// + /// + /// + /// + /// + /// + /// + /// + public int TMoneyApprove(string sTID, string sCardType, string sAmount, string sMsg1, string sMsg2, string sMsg3, ref string sResultMsg) + { + int nReturn = -1; + byte[] rep_signpad_array = new byte[2049]; + + try + { + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.SignPad.UseYn != true) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0390); + return nReturn; + } + + nReturn = SpcnRfPrepaidCardApprove(GetByteArrayFromString(sTID), GetByteArrayFromString(sCardType), GetByteArrayFromString(sAmount), GetByteArrayFromString(sMsg1), GetByteArrayFromString(sMsg2), GetByteArrayFromString(sMsg3), rep_signpad_array); + + sResultMsg = System.Text.Encoding.Default.GetString(rep_signpad_array); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 nReturn; + } + + /// + /// T-Money 지불 재거래 + /// + /// + /// + /// + /// + /// + /// + /// + /// + public int TMoneyApproveRe(string sTID, string sCardType, string sAmount, string sMsg1, string sMsg2, string sMsg3, ref string sResultMsg) + { + int nReturn = -1; + byte[] rep_signpad_array = new byte[2049]; + + try + { + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.SignPad.UseYn != true) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0390); + return nReturn; + } + + nReturn = SpcnRfPrepaidCardApproveRe(GetByteArrayFromString(sTID), GetByteArrayFromString(sCardType), GetByteArrayFromString(sAmount), GetByteArrayFromString(sMsg1), GetByteArrayFromString(sMsg2), GetByteArrayFromString(sMsg3), rep_signpad_array); + + sResultMsg = System.Text.Encoding.Default.GetString(rep_signpad_array); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 nReturn; + } + + /// + /// T-Money 승인내역 Upload + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public int TMoneyUploadTran(string sTID, string sbizName, string sDocSeq, string sTradeNo, string sOrgAmount, string sOrgDateTime, string sOrgTradeNo, string sRfData, ref string sResultMsg) + { + int nReturn = -1; + byte[] rep_signpad_array = new byte[2049]; + byte[] rep_van_array = new byte[2049]; + + try + { + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.SignPad.UseYn != true) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0390); + return nReturn; + } + + rep_signpad_array = System.Text.Encoding.Default.GetBytes(sRfData); + nReturn = SpcnRfUploadTran(GetByteArrayFromString(sTID), GetByteArrayFromString(sbizName), GetByteArrayFromString(sDocSeq), GetByteArrayFromString(sTradeNo), GetByteArrayFromString(sOrgAmount), GetByteArrayFromString(sOrgDateTime), GetByteArrayFromString(sOrgTradeNo), rep_signpad_array, rep_van_array); + + sResultMsg = System.Text.Encoding.Default.GetString(rep_van_array); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 nReturn; + } + + /// + /// T-Money 직전취소 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public int TMoneyApproveCancel(string sTID, string sCardType, string sMsg1, string sMsg2, string sMsg3, string sOrgAmount, string sOrgDateTime, string sOrgTradeNo, ref string sResultMsg) + { + byte[] rep_signpad_array = new byte[2049]; + int nReturn = -1; + try + { + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.SignPad.UseYn != true) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0390); + return nReturn; + } + + nReturn = SpcnRfPrepaidCardProcCancel(GetByteArrayFromString(sTID), GetByteArrayFromString(sCardType), GetByteArrayFromString(sMsg1), GetByteArrayFromString(sMsg2), GetByteArrayFromString(sMsg3), GetByteArrayFromString(sOrgAmount), GetByteArrayFromString(sOrgDateTime), GetByteArrayFromString(sOrgTradeNo), rep_signpad_array); + + sResultMsg = System.Text.Encoding.Default.GetString(rep_signpad_array); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 nReturn; + } + + /// + /// T-Money 현금반품 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public int TMoneyCashVoid(string sTID, string sCardType, string sMsg1, string sMsg2, string sMsg3, string sTradeNo, string sOrgAmount, string sOrgDateTime, string sOrgTradeNo, ref string sResultMsg) + { + byte[] rep_signpad_array = new byte[2049]; + int nReturn = -1; + try + { + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.SignPad.UseYn != true) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0390); + return nReturn; + } + + Array.Clear(rep_signpad_array, 0, rep_signpad_array.Length); + nReturn = SpcnRfPrepaidCardVoidCash(GetByteArrayFromString(sTID), GetByteArrayFromString(sCardType), GetByteArrayFromString(sMsg1), GetByteArrayFromString(sMsg2), GetByteArrayFromString(sMsg3), GetByteArrayFromString(sOrgAmount), GetByteArrayFromString(sOrgDateTime), GetByteArrayFromString(sOrgTradeNo), rep_signpad_array); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 nReturn; + } + + /// + /// T-Money 반품충전 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public int TMoneyVoidCharge(string sTID, string sbizName, string sDocSeq, string sCardType, string sMsg1, string sMsg2, string sMsg3, string sTradeNo, string sOrgAmount, string sOrgDateTime, string sOrgTradeNo, ref string sResultMsg) + { + byte[] rep_signpad_array = new byte[2049]; + int nReturn = -1; + try + { + // 무결성 실패후 진행시 오류 메시지 표시 + if (m_cDevStatus.SignPad.UseYn != true) + { + Cosmos.CommonManager.WinManager.ErrorMessage(Cosmos.CommonManager.POS_MESSAGE.ERROR.MSG_0390); + return nReturn; + } + + Array.Clear(rep_signpad_array, 0, rep_signpad_array.Length); + nReturn = SpcnRfPrepaidCardCancel(GetByteArrayFromString(sTID), GetByteArrayFromString(sbizName), GetByteArrayFromString(sDocSeq), GetByteArrayFromString(sCardType), GetByteArrayFromString(sMsg1), GetByteArrayFromString(sMsg2), GetByteArrayFromString(sMsg3), GetByteArrayFromString(sTradeNo), GetByteArrayFromString(sOrgAmount), GetByteArrayFromString(sOrgDateTime), GetByteArrayFromString(sOrgTradeNo), rep_signpad_array); + + sResultMsg = System.Text.Encoding.Default.GetString(rep_signpad_array); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 nReturn; + } + + private byte[] GetByteArrayFromString(string src) + { + return System.Text.Encoding.Default.GetBytes(src); + } + + #endregion + + #region 응답코드 + /// + /// 응답코드 + /// + /// + /// + private string ErrCodeToMsg(int nErrCode) + { + string sMsg = string.Empty; + + try + { + switch (nErrCode) + { + case -3: sMsg = "암호화오류(전문생성오류)"; break; + case -4: sMsg = "암호화오류(전문생성오류)"; break; + case -5: sMsg = "암호화오류 (전문오류)"; break; + case -6: sMsg = "암호화오류 (전문오류)"; break; + case -7: sMsg = "암호화오류 (키생성)"; break; + case -8: sMsg = "암호화오류 (키생성)"; break; + case -9: sMsg = "암호화오류 (키생성)"; break; + case -10: sMsg = "요청 IP 오류"; break; + case -11: sMsg = "암호화 구분 2 붙인 전문 오류"; break; + case -12: sMsg = "전자서명 전문일 경우 전문길이 필드 없는 오류"; break; + case -13: sMsg = "전자서명 전문일 경우 전문길이 필드 없는 오류"; break; + case -14: sMsg = "전문 전체길이 체크 오류"; break; + case -15: sMsg = "파라미터 오류 (접속 IP 오류)"; break; + case -16: sMsg = "파라미터 오류 (요청전문 오류)"; break; + case -17: sMsg = "전자서명 암호화 오류"; break; + case -18: sMsg = "개시거래 요망"; break; + case -20: sMsg = "SOCKET CONNECT 오류"; break; + case -21: sMsg = "SOCKET SELECT 오류"; break; + case -22: sMsg = "SOCKET RECV SELECT 오류"; break; + case -23: sMsg = "SOCKET RECV SELECT 오류"; break; + case -24: sMsg = "SOCKET RECV 오류"; break; + case -25: sMsg = "SOCKET RECV 오류"; break; + case -26: sMsg = "SOCKET SEND 오류"; break; + case -30: sMsg = "전문오류 (전자서명 필요없는 거래)"; break; + case -31: sMsg = "전문오류 (전자서명 데이터 구조 오류)"; break; + case -32: sMsg = "전문오류 (CR 없음)"; break; + case -33: sMsg = "전문오류 (ETX 없음)"; break; + case -34: sMsg = "전문오류(FS2 없음)"; break; + case -35: sMsg = "전자서명오류 (암호화 오류)"; break; + case -36: sMsg = "전자서명 길이 오류 (모바일)"; break; + case -37: sMsg = "IC데이터 오류 (FS오류)"; break; + case -38: sMsg = "IC데이터 오류(IC데이터/등록정보 오류)"; break; + case -40: sMsg = "EOT 미수신 (수신X)"; break; + case -41: sMsg = "EOT 미수신 (수신오류)"; break; + case -42: sMsg = "SOCKET 초기화 오류"; break; + case -43: sMsg = "SOCKET CONNECT 오류"; break; + case -44: sMsg = "SOCKET SEND 오류 (암호화)"; break; + case -45: sMsg = "SOCKET SEND 오류 (전문)"; break; + case -46: sMsg = "SOCKET RECV 오류 (헤더)"; break; + case -47: sMsg = "SOCKET RECV 오류 (전문)"; break; + case -48: sMsg = "SOCKET RECV 오류 (암호화)"; break; + case -49: sMsg = "SOCKET RECV 오류 (CHECK)"; break; + case -50: sMsg = "SOCKET SEND 오류 (ACK)"; break; + case -60: sMsg = "(모바일)SOCKET 생성 오류"; break; + case -61: sMsg = "(모바일)SOCKET CONNECT 오류"; break; + case -62: sMsg = "(모바일)SOCKET SELECT 오류"; break; + case -63: sMsg = "(모바일)SOCKET 옵션 설정 오류"; break; + case -64: sMsg = "(모바일)SOCKET 옵션 설정 오류"; break; + case -65: sMsg = "(모바일)SOCKET 오류"; break; + case -66: sMsg = "(모바일)SOCKET RECV 오류"; break; + case -67: sMsg = "(모바일)SOCKET RECV SELECT 오류"; break; + case -68: sMsg = "(모바일)SOCKET RECV SELECT 오류"; break; + case -69: sMsg = "(모바일)SOCKET SEND 오류"; break; + case -70: sMsg = "(모바일)SOCKET SEND SELECT 오류"; break; + case -79: sMsg = "시리얼 클래스 생성 오류"; break; + case -80: sMsg = "INI 파일 오류 (TYPE 구분 설정요망)"; break; + case -81: sMsg = "싸인패드 포트 오류"; break; + case -82: sMsg = "싸인패드 포트 오류"; break; + case -83: sMsg = "싸인패드 통신 오류"; break; + case -84: sMsg = "싸인패드 사용자 취소"; break; + case -85: sMsg = "싸인패드 타임아웃 오류"; break; + case -86: sMsg = "싸인패드 오픈 오류"; break; + case -87: sMsg = "싸인패드 초기화 오류"; break; + case -88: sMsg = "싸인패드 요청 오류"; break; + case -89: sMsg = "싸인패드 통신 오류"; break; + case -90: sMsg = "요청전문오류 (헤더 메시지 길이 오류)"; break; + case -91: sMsg = "요청전문오류 (거래구분 코드 오류)"; break; + case -92: sMsg = "미지원 전문"; break; + case -93: sMsg = "요청전문 필수 항목 누락"; break; + case -94: sMsg = "버퍼 초과"; break; + case -95: sMsg = "핀블럭 길이 오류"; break; + case -96: sMsg = "(전자서명생성) 이미지 파일 미존재"; break; + case -97: sMsg = "(전자서명생성) 이미지 파일 읽기 오류"; break; + case -98: sMsg = "(전자서명생성) 이미지 파일 크기 오류"; break; + case -99: sMsg = "(전자서명생성) 이미지 파일 데이터 오류"; break; + case -101: sMsg = "IC리더기 포트 설정 오류"; break; + case -102: sMsg = "IC리더기 오픈 오류"; break; + case -103: sMsg = "IC리더기 시리얼 생성 오류"; break; + case -104: sMsg = "IC리더기 파라미터 오류"; break; + case -105: sMsg = "IC리더기 쓰기 오류"; break; + case -106: sMsg = "보안표준키 다운로드 항목 오류(K2)"; break; + case -107: sMsg = "보안표준키 다운로드 승인 거절(K2)"; break; + case -108: sMsg = "보안표준키 다운로드 항목 오류(K4)"; break; + case -109: sMsg = "보안표준키 다운로드 승인 거절(K4)"; break; + case -110: sMsg = "IC리더기 응답 오류(Class 생성 오류)"; break; + case -111: sMsg = "IC리더기 응답 오류(길이 정보 수신 오류)"; break; + case -112: sMsg = "IC리더기 응답 오류(STX 오류)"; break; + case -113: sMsg = "IC리더기 응답 오류(수신 오류)"; break; + case -114: sMsg = "IC리더기 응답전문 오류(STX 오류)"; break; + case -115: sMsg = "IC리더기 응답전문 오류(ETX 오류)"; break; + case -116: sMsg = "IC리더기 응답전문 오류(LRC 오류)"; break; + case -117: sMsg = "IC리더기 초기화 오류"; break; + case -118: sMsg = "IC리더기 사용자 취소"; break; + case -119: sMsg = "IC리더기 타임아웃 오류"; break; + case -120: sMsg = "IC리더기 통신 오류"; break; + case -121: sMsg = "카드발급사 인증요청 IC CHIP DATA 오류"; break; + case -122: sMsg = "카드발급사 인증요청 데이터 오류"; break; + case -123: sMsg = "카드발급사 등록제 정보 데이터 오류"; break; + case -124: sMsg = "카드발급사 응답전문 데이터 오류"; break; + case -125: sMsg = "카드발급사 전문 구분 데이터 오류"; break; + case -126: sMsg = "카드발급사 전문버젼 데이터 오류"; break; + case -127: sMsg = "카드발급사 응답전문 미승인 오류"; break; + case -128: sMsg = "카드발급사 응답전문 GS 데이터 오류"; break; + case -129: sMsg = "카드발급사 인증 거절 (망취소 거절) - POS 망취소 요망"; break; + case -130: sMsg = "카드발급사 인증 거절 (망취소 완료)"; break; + case -131: sMsg = "망취소 실패(GS 없음) - POS에서 망취소 요망"; break; + case -132: sMsg = "망취소 실패(서버 거절) - POS에서 망취소 요망"; break; + case -133: sMsg = "망취소 실패(통신오류) - POS에서 망취소 요망"; break; + case -134: sMsg = "망취소 대상 아님"; break; + case -140: sMsg = "IC리더기 카드 읽기 오류 (거래매체 유형 미지정 오류)"; break; + case -141: sMsg = "IC리더기 카드 읽기 오류 (거래매체 유형 예외 오류)"; break; + case -142: sMsg = "IC리더기 카드 읽기 오류 (IC거래 구분 오류)"; break; + case -143: sMsg = "IC리더기 거래중 카드 제거 오류"; break; + case -144: sMsg = "IC리더기 거래가 거절된 카드 오류"; break; + case -145: sMsg = "IC리더기 기타 오류"; break; + case -146: sMsg = "IC리더기 거래 요청 전 카드 삽입 오류"; break; + case -147: sMsg = "IC리더기 상호인증 미완료 후 거래 시도 오류"; break; + case -148: sMsg = "IC리더기 무결성 미성공 후 거래 시도 오류"; break; + case -149: sMsg = "IC리더기 에러 코드 발생 오류"; break; + case -150: sMsg = "IC리더기 Fallback 진행 오류"; break; + case -151: sMsg = "IC리더기 거래 중 오류 (비정상 응답)"; break; + case -161: sMsg = "IC 거래 진행 중"; break; + case -162: sMsg = "SIGNPAD 거래 진행 중"; break; + case -2150: sMsg = "지원 불가 카드입니다."; break; + default: sMsg = "알수없는 메세지"; break; + } + + //sMsg = string.Format("ErrCd:{0} Desc:{1}", nErrCode, sMsg); + } + catch { } + return sMsg; + } + #endregion + } +} diff --git a/Agent/OLEDevice/DeviceTPaygle.cs b/Agent/OLEDevice/DeviceTPaygle.cs new file mode 100644 index 0000000..d72545a --- /dev/null +++ b/Agent/OLEDevice/DeviceTPaygle.cs @@ -0,0 +1,455 @@ +using System; +using System.Collections.Generic; +using System.Collections; +using System.Linq; +using System.Text; +using System.Data; +using System.Runtime.InteropServices; + +using Newtonsoft.Json.Linq; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; +using Cosmos.CommonManager; + +namespace Cosmos.OLEDevice +{ + /// + /// T-PAY BLE Dongle (paygle) + /// + class DeviceTPaygle : ITPaygleUs + { + + #region ## XPayLib.dll Function + /// + /// 체크인 된 고객리스트를 수신 + /// + /// + /// + [DllImport("XPayLib.dll")] + private static extern int GetPOSConnectList(byte[] connectList); + + /// + /// 선택고객의 BLE OTB 발급요청(구버전 호환성문제로 유지) + /// + /// + /// + [DllImport("XPayLib.dll")] + private static extern int ReqPOSProvide(byte[] XPT); + + /// + /// 선택고객의 BLE OTB 발급요청/수신(폰의 OS별로 지원 가능) + /// + /// + /// + /// + [DllImport("XPayLib.dll")] + private static extern int ReqPOSProvide2(byte[] XPT, byte[] param); + + /// + /// BLE OTB 수신 + /// + /// + /// + [DllImport("XPayLib.dll")] + private static extern int GetOTB(byte[] KeyRlt); + + /// + /// 수신된 비밀번호를 40Byte 해시코드로 변환 + /// + /// HashString 반환버퍼 + /// 변환할 비밀번호 + [DllImport("XPayLib.dll")] + private static extern void PWHashing(byte[] Rlt, byte[] param); + + /// + /// Paygle상태를 체크하고 업데이트가 필요한 경우 업데이트 + /// + /// + [DllImport("PaygleCheck.dll")] + private static extern int PaygleCheckProc(); + + //#20170906 T페이 고도화 작업 phj, start + /// 수신된 OTB를 분류 검증 (결제방식, 사전인증 체크 기능) + /// 입력된 OTB의 유효성과, 선인증여부를 확인합니다. + /// + /// 카드번호 + [DllImport("XPayLib.dll")] + private static extern int ClassifyOTB(byte[] ClassifyOTB); + //#20170906 T페이 고도화 작업 phj, end + + #endregion + + + private StateServer StateObject = (StateServer)StateServer.GetInstance(); // StateObject : StateServer Object (객체) + private PosStatus posStatus = new PosStatus(); // 기본정보 참조 + private DeviceStatus devStatus = new DeviceStatus(); // 장치정보 참조 + + /// + /// 생성자 + /// + public DeviceTPaygle() + { + devStatus = (DeviceStatus)StateObject.DEVICE; + posStatus = (PosStatus)StateObject.POS; + } + + /// + /// 체크인 고객리스트 수신 + /// + /// 고객리스트(JSON) + /// 체크인된고객수 + /// + /// * Connect List (JSON Format) + /// 1 DATETIME YYYYMMDDHHMMSS 결과수신시간/처리시간 + /// 2 POSID string 요청POS 식별번호 + /// 3 LIST JSONList 체크인 고객리스트 + /// 3.1 XPT String 단말기 식별코드 (반복) + /// 3.2 NAME String 단말기 등록이름 (반복) + /// 3.3 NICKNAME String 단말기 등록 닉네임 (반복) + /// 3.4 MDN String 단말기 전화번호 (반복) + /// 3.5 DEVICE_TYPE String “001” : 안드로이드, “002” : 아이폰(iOS 적용 버전) + /// + /// * Sample + /// { + /// "DATETIME":"20160329144522", + /// "POSID":"WHONEED010", + /// "LIST":[ + /// {"XPT":"********lVGOW48naN0mRPg==", "NAME":"**호", "NICK_NAME":"별명", "MDN":"01089**23**","DEVICE_TYPE":"001"} + /// …(반복) + /// ] + /// } + /// + public int GetConnectList(out string phoneList) + { + phoneList = string.Empty; + try + { + byte[] buffer = new byte[1024 * 2]; + + int ret = GetPOSConnectList(buffer); + if (ret < 0) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "XPayLib.dll GetPOSConnectList Function Error (ErrorCode=" + ret.ToString() + ")"); + } + phoneList = Encoding.Default.GetString(buffer).Replace("\0", ""); + + return ret; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception." + ex.Message); + return -9; + } + } + + /// + /// + /// + /// + /// + public int GetConnectList(out Column.TPAY_CONNECT_INFO phoneList) + { + phoneList = null; + try + { + byte[] buffer = new byte[1024 * 2]; + + int ret = GetPOSConnectList(buffer); + string result = Encoding.Default.GetString(buffer).Replace("\0", ""); + if (ret < 0) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "XPayLib.dll GetPOSConnectList Function Error (ErrorCode=" + ret.ToString() + ")"); + return ret; + } + + phoneList = new Column.TPAY_CONNECT_INFO(); + + JObject json = JObject.Parse(result); + phoneList.DATATIME = json["DATETIME"].ToString(); + phoneList.POSID = json["POSID"].ToString(); + + JArray jArray = JArray.Parse(json["LIST"].ToString()); + for (var i = 0; i < ret; i++) + { + JObject js = JObject.Parse(jArray[i].ToString()); + + Column.TPAY_PHONE phone = new Column.TPAY_PHONE(); + phone.XPT = js["XPT"].ToString(); + phone.NAME = js["NAME"].ToString(); + phone.NICK_NAME = js["NICK_NAME"].ToString(); + phone.MDN = js["MDN"].ToString(); + phone.DEVICE_TYPE = js["DEVICE_TYPE"].ToString(); + + phoneList.LIST.Add(phone); + } + + return ret; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception." + ex.Message); + phoneList = null; + return -9; + } + } + + /// + /// 선택된 XPT 단말기(스마트폰)에 BLE BOT 발급 요청 + /// + /// 결제키 발급대상 단말기 식별코드 + /// 요청POS식별번호 + /// 장비구분(001:안드로이드, 002:iOS) + /// + public bool ReqPosProvide(string xpt, string posID, string deviceType, out string errMsg) + { + errMsg = string.Empty; + + try + { + //byte[] param1 = Encoding.Default.GetBytes(xpt); + //byte[] param2 = Encoding.Default.GetBytes(posID); + //int ret = ReqPOSProvide(param1); + + string temp = JObject.FromObject(new { XPT = xpt, DEVICE_TYPE = deviceType }).ToString(); + //string temp = "{" + string.Format("\"XPT\":\"{0}\",\"DEVICE_TYPE\":\"{1}\"", xpt, deviceType) + "}"; + byte[] param1 = Encoding.Default.GetBytes(xpt); + byte[] param2 = Encoding.Default.GetBytes(temp); + int ret = ReqPOSProvide2(param1, param2); + if (ret < 0) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "XPayLib.dll ReqPOSProvide2 Function Error (ErrorCode=" + ret.ToString() + ")"); + + } + + errMsg = ret == 0 ? string.Empty : "Error Code =" + ret.ToString(); + return ret == 0 ? true : false; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception." + ex.Message); + errMsg = ex.Message; + return false; + } + } + + /// + /// BLE OTB 수신 + /// + /// 성공:OTB, 실패:오류메시지 + /// + /// 0:성공, -10001:Timeout, -10002:DeviceError + public bool GetOTB(out string result) + { + result = string.Empty; + try + { + byte[] buffer = new byte[1024]; + int ret = GetOTB(buffer); + switch(ret) + { + case 0: + result = Encoding.Default.GetString(buffer).Replace("\0", "").Trim(); + break; + case -10001: + result = "Timeout"; + break; + case -10002: + result = "Device Error"; + break; + } + if (ret != 0) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "XPayLib.dll GetOTB Function Error (ErrorCode=" + ret.ToString() + ", " + result + ")"); + } + + return ret == 0 ? true : false; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception." + ex.Message); + result = ex.Message; + return false; + } + } + + /// + /// 수신된 비밀번호를 40Byte 해시코드로 변환 + /// + /// + /// + public string GetHashPassword(string password) + { + try + { + byte[] buffer = new byte[40]; + byte[] pws = new byte[4]; + pws = Encoding.Default.GetBytes(password); + + PWHashing(buffer, pws); + + return Encoding.Default.GetString(buffer).Replace("\0", ""); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception." + ex.Message); + return string.Empty; + } + } + + /// + /// + /// + /// + public bool CheckPaygle() + { + try + { + int ret = PaygleCheckProc(); + return ret == 0 ? true : false; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "Exception." + ex.Message); + return false; + } + } + + + //#20170906 T페이 고도화 작업 phj, start + #region ## ClassifyOTBCheck 입력된 OTB의 유효성과, 선인증여부를 확인 + public int ClassifyOTBCheck(string pOTB) + { + int ret = 0; + + try + { + byte[] GetOTB = Encoding.Default.GetBytes(pOTB); + + //입력된 OTB의 유효성과, 선인증여부를 확인 + //10 : 구버전의 OTB로 제약 없음 + //20 : 할인/결제 가능, 핀패드 입력 필요 + //21 : 할인/결제 가능, 핀패드 입력 불필요 + //30 : 결제만 가능, 핀패드 입력 필요 + //31 : 결제만 가능, 핀패드 입력 불필요 + + ret = ClassifyOTB(GetOTB); + + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "XPayLib.dll ClassifyOTB Function Result : " + ret.ToString() + ", (" + pOTB + ")"); + return ret; + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "XPayLib.dll ClassifyOTB Function Exception : " + ex.Message + ", Result : " + ret.ToString() + ", (" + pOTB + ")"); + return ret; + } + } + + #endregion + //#20170906 T페이 고도화 작업 phj, end + + //#20170906 T페이 고도화 작업 phj, start + #region ## ClassifyOTBCheckMsg 메세지 + public string ClassifyOTBCheckMsg(string pOTB) + { + string result = string.Empty; + try + { + switch (pOTB) + { + case "0": + result = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0729);//"유효하지 않은 OTB 입니다" + break; + case "10": + result = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0730);//"구버전의 OTB 입니다" + break; + case "20": + result = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0731);//"통합결제만 가능 합니다(결제비밀번호 필수)"; + break; + case "21": + result = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0732);//"통합결제만 가능 합니다(결제비밀번호 불필요)"; + break; + case "30": + result = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0733);//"일반결제만 가능 합니다(결제비밀번호 필수)"; + break; + case "31": + result = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0734);//"일반결제만 가능 합니다(결제비밀번호 불필요)"; + break; + + default: + result = MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0735);//"해당응답코드없음"; + break; + } + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "XPayLib.dll ClassifyOTB Function Msg : " + result + ", (" + pOTB + ")"); + + return result; + + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 (함수명)) + "XPayLib.dll ClassifyOTB Function Msg Exception : " + ex.Message + ", Result : " + result + ", (" + pOTB + ")"); + return result; + } + } + #endregion + //#20170906 T페이 고도화 작업 phj, end + } +} diff --git a/Agent/OLEDevice/OCBDirect.cs b/Agent/OLEDevice/OCBDirect.cs new file mode 100644 index 0000000..f9ef8e2 --- /dev/null +++ b/Agent/OLEDevice/OCBDirect.cs @@ -0,0 +1,623 @@ +using Cosmos.Common; +using Cosmos.CommonManager; +using Cosmos.ServiceProvider; +using Cosmos.UserFrame; +using System; +using System.Runtime.InteropServices; +using System.Text; + +/*-----------------------------------------------------------------------------------------------*/ +// 설 명 : OCB 직통신 +// 작 성 자 : +// 변경 이력 : +/*-----------------------------------------------------------------------------------------------*/ +namespace Cosmos.OLEDevice +{ + /// + /// OCB 직통신 + /// + public class OCBDirect : IOCBDirect + { + #region MPS.DLL 함수 + /// + /// 가맹점등록 + /// + [DllImport("MPS.dll")] + public static extern int RegisterMcht(string A, string B, string C, string D, string E, string F, string G, string H, string I, string J, byte[] K); + /// + /// 가맹점등록 + /// + [DllImport("MPS.dll")] + public static extern int AuthMcht(string A, string B, string C, string D, string E, string F, string G, string H, string I, string J, byte[] K); + + /// + /// 포인트조회 + /// + [DllImport("MPS.dll")] + public static extern int InquiryPoint(string A, string B, string C, string D, string E, string F, string G, string H, string I, string J, string K, string L, byte[] M); + /// + /// 포인트적립 + /// + [DllImport("MPS.dll")] + public static extern int SavePoint(string A, string B, string C, string D, string E, string F, string G, string H, + string I, string J, string K, string L, string M, string N, string O, string P, + string Q, string R, string S, string T, string U, string V, string W, string X, + string Y, int Z, byte[] AA, int BB, byte[] CC, byte[] DD); + /// + /// 포인트적립취소 + /// + [DllImport("MPS.dll")] + public static extern int CancelSavePoint(string A, string B, string C, string D, string E, string F, string G, string H, + string I, string J, string K, string L, string M, string N, string O, string P, + string Q, string R, string S, string T, string U, string V, byte[] W); + /// + /// 포인트사용 + /// + [DllImport("MPS.dll")] + public static extern int UsePoint ( string A, string B, string C, string D, string E, string F, string G, string H, + string I, string J, string K, string L, string M, string N, string O, string P, + string Q, string R, string S, string T, byte[] U ); + /// + /// 포인트사용취소 + /// + [DllImport("MPS.dll")] + public static extern int CancelUsePoint(string A, string B, string C, string D, string E, string F, string G, string H, + string I, string J, string K, string L, string M, string N, string O, string P, + string Q, string R, string S, byte[] T); + /// + /// 포인트할인 + /// + [DllImport("MPS.dll")] + public static extern int DiscountService(string A, string B, string C, string D, string E, string F, string G, string H, string I, + string J, string K, string L, string M, string N, string O, string P, string Q, string R, + string S, string T, byte[] U); + /// + /// 포인트할인취소 + /// + [DllImport("MPS.dll")] + public static extern int CancelDiscountService ( string A, string B, string C, string D, string E, string F, string G, string H, string I, + string J, string K, string L, string M, string N, string O, string P, string Q, string R, + string S, byte[] T ); + /// + /// 망취소 + /// + [DllImport("MPS.dll")] + public static extern int ForcedCancelUsePoint(string A, string B, string C, string D, string E, string F, string G, string H, + string I, string J, string K, string L, string M, string N, string O, string P, + string Q, string R, string S, byte[] T); + + private IDataCommonUs m_cDataCommon = null; + protected SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출 + + #endregion + + #region 생성자 + /// + /// StateServer Object (StateServer 객체) + /// + public StateServer StateObject = (StateServer)StateServer.GetInstance(); + /// + /// Pos 상태 정보 객체 + /// + public PosStatus m_cPosStatus = null; + /// + /// 생성자 + /// + public OCBDirect() + { + try + { + m_cPosStatus = (PosStatus)StateObject.POS; + m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 OCB 직통신 + /// + /// OCB 직통신 + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public string OCB_Direct_Point(string sTradeDiv, string sPayWayCD, string sPayWayDtlCD, string sTranType, string sCardNo, string sCardPwd, string sPayAmt, string sApprDt, string sApprNo, string sUniqueID, ref string sResMsg, ref string[] aIrtRspDTL) + { + int nRet = -1; + string sRet = UserCom.RST_ERR; + + byte[] bRecvData = new byte[4096]; + int nNowPos = 0; + + string sResCD = "0"; + string sApprTm = ""; + + try + { + #region 0.기초설정 + // 응답메시지 + sResMsg = ""; + + // VAN 정보 조회 + //string sCMPApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.OKCASHBACK_POINT, PosMst.MST_VAN.DATA.CMP_APPR_ID); + //string sApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.OKCASHBACK_POINT, PosMst.MST_VAN.DATA.APPR_ID); + //string sApprPWD = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.POINT_ITEM, ItemConst.TR_ITEM_ID.POINT_USE.OKCASHBACK_POINT, PosMst.MST_VAN.DATA.APPR_PWD); + string sCMPApprID = PosMstManager.GetMstVan(PosMstManager.GetPosOption(POS_OPTION.OPT326), PosMst.MST_VAN.DATA.CMP_APPR_ID); + string sApprID = PosMstManager.GetMstVan(PosMstManager.GetPosOption(POS_OPTION.OPT326), PosMst.MST_VAN.DATA.APPR_ID); + string sApprPWD = PosMstManager.GetMstVan(PosMstManager.GetPosOption(POS_OPTION.OPT326), PosMst.MST_VAN.DATA.APPR_PWD); + + // 입력구분 + string sInputType = "2"; + if (sCardNo.IndexOf("=") > 0) sInputType = "0"; + + // 추적번호 = POS번호(2) + 일자(DD) + 시간(SSFFF) + if (sTranType != PosConst.POS_OCB_DIRECT.NET_CAN_POINT) + sUniqueID = m_cPosStatus.Base.PosNo.PadLeft(2, '0') + DateTime.Now.ToString("dd") + string.Format("{0:00000}", DateTime.Now.ToString("ssfff")) + "0"; + #endregion + + // 요청 - 승인로그 저장 (판매구분, [0]결제수단, [1]결제상세코드, [2]전문구분, [3]요청구분, [4]카드번호, [5]결제금액, [6]승인번호, [7]승인일자, [8]승인시간, [9]응답상태값, [10]응답메시지, [11]전문) + string sSendData = sTranType + CmUtil.MidH(sCMPApprID, 0, 4) + DateTime.Now.ToString("yyyyMMdd") + DateTime.Now.ToString("HHmmss") + CmUtil.MidH(sUniqueID, 0, 10) + "A" + "A1" + CmUtil.MidH(sApprID, 0, 15) + CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10) + CmUtil.MidH(sApprPWD, 0, 16) + CmUtil.MidH(sCardNo, 0, 16) + CmUtil.MidH(sCardPwd, 0, 16) + CmUtil.MidH(sPayAmt, 0, 16) + CmUtil.MidH(sApprDt, 0, 8) + CmUtil.MidH(sApprNo, 0, 16) + CmUtil.MidH(sUniqueID, 0, 10); + + // 승인데이터 중 카드번호 마스킹 처리(2017.05.25) + string sWriteSendData = CmUtil.MakeLogDataToMask(false, sCardNo, sSendData); + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "[SEND:" + sWriteSendData); + m_cDataCommon.SetSaleApprLog(sTradeDiv, new string[] { sPayWayCD, sPayWayDtlCD, sTranType, "S", sCardNo, sPayAmt, "", "", "", "", "", sWriteSendData }); + + #region 1.요청전문 + // 1.요청전문 + switch (sTranType) + { + case PosConst.POS_OCB_DIRECT.STOR_REGISTER: + { + #region 가맹점 등록 + /* + A CHAR 4 전문번호 2A10 + B CHAR 4 기관코드 해당기관코드 + C CHAR 8 전송일자 예:20030924(YYYYMMDD) + D CHAR 6 전송시간 예:130201(HHMMSS) + E CHAR 10 추적번호 Sequence number(일별 Unique) + F CHAR 1 멤버쉽프로그램ID 'A' : OKCashbag + G CHAR 2 서비스구분 'A1' : OK캐쉬백서비스, 'A2' : T포인트서비스 , 'A3' : 로디아서비스 + H CHAR 15 가맹점번호 가맹점번호(8)+SPACE 7자리 입력 + I CHAR 10 가맹점사업자번호 예:1111111111 + J CHAR 16 가맹점 비밀번호 예:1111 + */ + nRet = RegisterMcht(sTranType, CmUtil.MidH(sCMPApprID, 0, 4), DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), CmUtil.MidH(sUniqueID, 0, 10), "A", "A1" + , CmUtil.MidH(sApprID, 0, 15), CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10), CmUtil.MidH(sApprPWD, 0, 16), bRecvData); + break; + #endregion + } + case PosConst.POS_OCB_DIRECT.STOR_AUTH: + { + #region 가맹점 인증 + /* + A CHAR 4 전문번호 2A20 + B CHAR 4 기관코드 해당기관코드 + C CHAR 8 전송일자 예:20030924(YYYYMMDD) + D CHAR 6 전송시간 예:130201(HHMMSS) + E CHAR 10 추적번호 Sequence number(일별 Unique) + F CHAR 1 멤버쉽프로그램ID 'A' : OKCashbag + G CHAR 2 서비스구분 'A1' : OK캐쉬백서비스, 'A2' : T포인트서비스 , 'A3' : 로디아서비스 + H CHAR 15 가맹점번호 가맹점번호(8)+SPACE 7자리 입력 + I CHAR 10 가맹점사업자번호 예:1111111111 + J CHAR 16 가맹점 비밀번호 예:1111 + */ + nRet = AuthMcht(sTranType, CmUtil.MidH(sCMPApprID, 0, 4), DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), CmUtil.MidH(sUniqueID, 0, 10), "A", "A1" + , CmUtil.MidH(sApprID, 0, 15), CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10), CmUtil.MidH(sApprPWD, 0, 16), bRecvData); + break; + #endregion + } + case PosConst.POS_OCB_DIRECT.INQ_POINT: + { + #region 포인트 조회 + /* + A CHAR 4 전문번호 2M30 + B CHAR 4 기관코드 해당기관코드 + C CHAR 8 전송일자 예:20030924(YYYYMMDD) + D CHAR 6 전송시간 예:130201(HHMMSS) + E CHAR 10 추적번호 Sequence number(일별 Unique) + F CHAR 1 멤버쉽프로그램ID 'A' : OKCashbag + G CHAR 2 서비스구분 'A1' : OK캐쉬백서비스, 'A2' : T포인트서비스 , 'A3' : 로디아서비스 + H CHAR 15 가맹점번호 가맹점번호(8)+SPACE 7자리 입력 + I CHAR 10 가맹점사업자번호 예:1111111111 + J CHAR 19 카드번호 예:1234123412341234 ('-'제외) + K CHAR 19 주민번호 예:1234123412341234 ('-'제외) + L CHAR 2 요청구분 카드번호 : 'R1' , 주민번호 :'R2' + */ + nRet = InquiryPoint(sTranType, CmUtil.MidH(sCMPApprID, 0, 4), DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), CmUtil.MidH(sUniqueID, 0, 10), "A", "A1" + , CmUtil.MidH(sApprID, 0, 15), CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10), CmUtil.MidH(sCardNo, 0, 19), CmUtil.MidH("", 0, 19), "R1", bRecvData); + break; + #endregion + } + case PosConst.POS_OCB_DIRECT.SAVE_POINT: + { + #region 포인트 적립 + /* + A CHAR 4 전문번호 2100 + B CHAR 4 기관코드 해당기관코드 + C CHAR 8 전송일자 예:20030924(YYYYMMDD) + D CHAR 6 전송시간 예:130201(HHMMSS) + E CHAR 10 추적번호 Sequence number(일별 Unique) + F CHAR 1 멤버쉽프로그램ID 'A' : OKCashbag + G CHAR 2 서비스구분 'A1' : OK캐쉬백서비스, 'A2' : T포인트서비스 , 'A3' : 로디아서비스 + H CHAR 15 가맹점번호 가맹점번호(8)+SPACE 7자리 입력 + I CHAR 10 가맹점사업자번호 예:1111111111 + J CHAR 8 거래일자 예:20030924(YYYYMMDD) + K CHAR 6 거래시간 예:130201(HHMMSS) + L CHAR 1 KEY-IN 여부 '0':Swapping, '2':Key-in, 'F': mart 수집상품 only + M CHAR 19 카드번호 예:1234123412341234 ('-'제외) + N CHAR 19 주민번호 예:1234123412341234 ('-'제외) + O CHAR 2 전표코드 '01' : 적립 + P CHAR 2 거래구분코드 '11' : 금액현재, '12' : 금액가용, '21' : 포인트현재, '22' : 포인트가용 + Q CHAR 2 계약구분코드 현금:01, 카드:02 + R CHAR 10 거래금액 예:10000 + S CHAR 9 현금거래금액 예:12000 (공급가액(T) + 부가가치세(U) + 봉사료(V)의 합계) + T CHAR 9 공급가액 예:10000(현금결제시 현금영수증발급을 위해 입력) + U CHAR 9 부가가치세 예:1000(현금결제시 현금영수증발급을 위해 입력) + V CHAR 9 봉사료 예:1000(현금결제시 현금영수증발급을 위해 입력) + W CHAR 1 거래자구분 소비자소득공제용(0:기본값), 사업자지출증빙용(1) + X CHAR 1 현금영수증처리구분 적립+현금(0), 적립Only(1) + Y CHAR 30 영수증번호 예:123456789(공백은 Space처리) + Z INT 4 쿠폰상품개수 예:2 (50개를 초과하지 않음) (상품 없을 경우 0(Zero)) + AA STRUCT 가변 상품바코드(18) 예:8823456789123 (적립코드)(상품 없을 경우 입력안함) + (모두 CHAR형) 상품수량(5) 예:2 (공백은 Space로처리)(상품 없을 경우 입력안함) + 적립용 상품 제휴사코드(6) 예:123456 (상품 없을 경우 입력안함) + 포인트구분(1) + BB INT 4 마트상품개수 예:2 (50개를 초과하지 않음) (상품 없을 경우 0(Zero)) + CC STRUCT 가변 상품바코드(18) 예:8823456789123 (적립코드)(상품 없을 경우 입력안함) + (모두 CHAR형) 상품수량(6) 예:2 (공백은 Space로처리) (상품 없을 경우 입력안함) + 수집용 상품 제휴사코드(6) 예:123456 (상품 없을 경우 입력안함) + 상품판매단가(9) 예:10000 (공백은 Space로처리)(상품 없을 경우 입력안함) + 상품분류코드(6) 예:F10000 (상품 없을 경우 입력안함) + 인자를 넘길때 (CHAR *)으로 Type Casting해서 넘긴다. + */ + nRet = SavePoint(sTranType, CmUtil.MidH(sCMPApprID, 0, 4), DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), CmUtil.MidH(sUniqueID, 0, 10), "A", "A1", CmUtil.MidH(sApprID, 0, 15), CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10) + , DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss") + , CmUtil.MidH(sInputType, 0, 1), CmUtil.MidH(sCardNo, 0, 19), CmUtil.MidH("", 0, 19), "01", "11", "01" + , CmUtil.MidH(sPayAmt, 0, 10), CmUtil.MidH("", 0, 9), CmUtil.MidH("", 0, 9), CmUtil.MidH("", 0, 9), CmUtil.MidH("", 0, 9) + , CmUtil.MidH("0", 0, 1), "1", CmUtil.MidH("", 0, 30), 0, null, 0, null, bRecvData); + + break; + #endregion + } + case PosConst.POS_OCB_DIRECT.SAVE_CAN_POINT: + { + #region 포인트 적립 취소 + /* + A CHAR 4 전문번호 2110 + B CHAR 4 기관코드 해당기관코드 + C CHAR 8 전송일자 예:20030924(YYYYMMDD) + D CHAR 6 전송시간 예:130201(HHMMSS) + E CHAR 10 추적번호 Sequence number(일별 Unique) + F CHAR 1 멤버쉽프로그램ID 'A' : OKCashbag + G CHAR 2 서비스구분 'A1' : OK캐쉬백서비스, 'A2' : T포인트서비스 , 'A3' : 로디아서비스 + H CHAR 15 가맹점번호 가맹점번호(8)+SPACE 7자리 입력 + I CHAR 10 가맹점사업자번호 예:1111111111 + J CHAR 8 거래일자 예:20030924(YYYYMMDD) + K CHAR 6 거래시간 예:130201(HHMMSS) + L CHAR 1 KEY-IN 여부 0':Swapping, '2':Key-in + M CHAR 19 카드번호 예:1234123412341234 ('-'제외) + N CHAR 19 주민번호 예:1234123412341234 ('-'제외) + O CHAR 8 원거래일자 예:20030924(YYYYMMDD) + P CHAR 9 원거래승인번호 예:123456789(공백은 Space로처리) + Q CHAR 2 전표코드 '21' : 적립취소 + R CHAR 2 거래구분코드 '41' : 적립취소 + S CHAR 10 원거래금액 예:10000(공백은 Space로처리) + T CHAR 1 취소요청구분 적립+현금(0), 적립Only(1) + U CHAR 30 원거래 영수증번호 예:123456789(공백은 Space처리) + V CHAR 1 현금영수증 취소사유 코드 '1' : 반품/거래취소, '2' : 거래오류로인한 취소, '3' : 기타(사유분류 불분명) + */ + nRet = CancelSavePoint(sTranType, CmUtil.MidH(sCMPApprID, 0, 4), DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), CmUtil.MidH(sUniqueID, 0, 10), "A", "A1", CmUtil.MidH(sApprID, 0, 15), CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10) + , DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss") + , CmUtil.MidH(sInputType, 0, 1), CmUtil.MidH(sCardNo, 0, 19), CmUtil.MidH("", 0, 19), CmUtil.MidH(sApprDt, 0, 8), CmUtil.MidH(sApprNo, 0, 9), "21", "41" + , CmUtil.MidH(sPayAmt, 0, 10), "1", CmUtil.MidH("", 0, 30), "1", bRecvData); + break; + #endregion + } + case PosConst.POS_OCB_DIRECT.USE_POINT: + { + #region 포인트 사용 + /* + A CHAR 4 전문번호 2400 + B CHAR 4 기관코드 해당기관코드 + C CHAR 8 전송일자 예:20030924(YYYYMMDD) + D CHAR 6 전송시간 예:130201(HHMMSS) + E CHAR 10 추적번호 Sequence number(일별 Unique) + F CHAR 1 멤버쉽프로그램ID 'A' : OKCashbag + G CHAR 2 서비스구분 'A1' : OK캐쉬백서비스, 'A2' : T포인트서비스 , 'A3' : 로디아서비스 + H CHAR 15 가맹점번호 가맹점번호(8)+SPACE 7자리 입력 + I CHAR 10 가맹점사업자번호 예:1111111111 + J CHAR 8 거래일자 예:20030924(YYYYMMDD) + K CHAR 6 거래시간 예:130201(HHMMSS) + L CHAR 1 KEY-IN 여부 0':Swapping, '2':Key-in + M CHAR 19 카드번호 예:1234123412341234 ('-'제외) + N CHAR 19 주민번호 예:1234123412341234 ('-'제외) + O CHAR 16 카드 비밀번호 예:1111 + P CHAR 2 전표코드 '11' : 사용 + Q CHAR 2 거래구분코드 '40' : 사용 + R CHAR 2 계약구분코드 '08' : 포인트 사용 + S CHAR 10 사용포인트 예:10000 + T CHAR 10 총거래금액 예:10000 + */ + nRet = UsePoint(sTranType, CmUtil.MidH(sCMPApprID, 0, 4), DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), CmUtil.MidH(sUniqueID, 0, 10), "A", "A1", CmUtil.MidH(sApprID, 0, 15), CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10) + , DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss") + , CmUtil.MidH(sInputType, 0, 1), CmUtil.MidH(sCardNo, 0, 19), CmUtil.MidH("", 0, 19), CmUtil.MidH(sCardPwd, 0, 16), "11", "40", "08" + , CmUtil.MidH(sPayAmt, 0, 10), CmUtil.MidH("", 0, 10), bRecvData); + break; + #endregion + } + case PosConst.POS_OCB_DIRECT.USE_CAN_POINT: + { + #region 포인트 사용 취소 + /* + A CHAR 4 전문번호 2410 + B CHAR 4 기관코드 해당기관코드 + C CHAR 8 전송일자 예:20030924(YYYYMMDD) + D CHAR 6 전송시간 예:130201(HHMMSS) + E CHAR 10 추적번호 Sequence number(일별 Unique) + F CHAR 1 멤버쉽프로그램ID 'A' : OKCashbag + G CHAR 2 서비스구분 'A1' : OK캐쉬백서비스, 'A2' : T포인트서비스 , 'A3' : 로디아서비스 + H CHAR 15 가맹점번호 가맹점번호(8)+SPACE 7자리 입력 + I CHAR 10 가맹점사업자번호 예:1111111111 + J CHAR 8 거래일자 예:20030924(YYYYMMDD) + K CHAR 6 거래시간 예:130201(HHMMSS) + L CHAR 1 KEY-IN 여부 0':Swapping, '2':Key-in + M CHAR 19 카드번호 예:1234123412341234 ('-'제외) + N CHAR 19 주민번호 예:1234123412341234 ('-'제외) + O CHAR 8 원거래일자 예:20030924(YYYYMMDD) + P CHAR 9 원거래승인번호 예:123456789(공백은 Space로처리) + Q CHAR 2 전표코드 '22' : 사용취소 + R CHAR 2 거래구분코드 '42' : 사용취소 + S CHAR 10 원거래금액 예:10000(공백은 Space로처리) + */ + nRet = CancelUsePoint(sTranType, CmUtil.MidH(sCMPApprID, 0, 4), DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), CmUtil.MidH(sUniqueID, 0, 10), "A", "A1", CmUtil.MidH(sApprID, 0, 15), CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10) + , DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss") + , CmUtil.MidH(sInputType, 0, 1), CmUtil.MidH(sCardNo, 0, 19), CmUtil.MidH("", 0, 19), CmUtil.MidH(sApprDt, 0, 8), CmUtil.MidH(sApprNo, 0, 9), "22", "42" + , CmUtil.MidH(sPayAmt, 0, 10), bRecvData); + break; + #endregion + } + case PosConst.POS_OCB_DIRECT.NET_CAN_POINT: + { + #region 망취소 + /* + A CHAR 4 전문번호 2410 + B CHAR 4 기관코드 해당기관코드 + C CHAR 8 전송일자 예:20030924(YYYYMMDD) + D CHAR 6 전송시간 예:130201(HHMMSS) + E CHAR 10 추적번호 포인트 사용 호출시 사용한 추적번호 + F CHAR 1 멤버쉽프로그램ID 'A' : OKCashbag + G CHAR 2 서비스구분 'A1' : OK캐쉬백서비스, 'A2' : T포인트서비스 , 'A3' : 로디아서비스 + H CHAR 15 가맹점번호 가맹점번호(8)+SPACE 7자리 입력 + I CHAR 10 가맹점사업자번호 예:1111111111 + J CHAR 8 거래일자 예:20030924(YYYYMMDD) + K CHAR 6 거래시간 예:130201(HHMMSS) + L CHAR 1 KEY-IN 여부 0':Swapping, '2':Key-in + M CHAR 19 카드번호 예:1234123412341234 ('-'제외) + N CHAR 19 주민번호 예:1234123412341234 ('-'제외) + O CHAR 8 원거래일자 예:20030924(YYYYMMDD) + P CHAR 9 원거래승인번호 예:123456789(공백은 Space로처리) + Q CHAR 2 전표코드 '21' : 적립취소 '22' : 사용취소 + R CHAR 2 거래구분코드 '41' : 적립취소 '42' : 사용취소 + S CHAR 10 원거래금액 예:10000(공백은 Space로처리) + */ + nRet = ForcedCancelUsePoint(PosConst.POS_OCB_DIRECT.NET_CAN_POINT, CmUtil.MidH(sCMPApprID, 0, 4), DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss"), CmUtil.MidH(sUniqueID, 0, 10), "A", "A1", CmUtil.MidH(sApprID, 0, 15), CmUtil.MidH(m_cPosStatus.Mst.StorBizPsnNo, 0, 10) + , DateTime.Now.ToString("yyyyMMdd"), DateTime.Now.ToString("HHmmss") + , CmUtil.MidH(sInputType, 0, 1), CmUtil.MidH(sCardNo, 0, 19), CmUtil.MidH("", 0, 19), CmUtil.MidH(sApprDt, 0, 8), CmUtil.MidH(sApprNo, 0, 9), (sTranType == PosConst.POS_OCB_DIRECT.SAVE_CAN_POINT ? "21" : "22"), (sTranType == PosConst.POS_OCB_DIRECT.SAVE_CAN_POINT ? "41" : "42") + , CmUtil.MidH(sPayAmt, 0, 10), bRecvData); + break; + #endregion + } + } + #endregion + + + + #region 2.처리결과 + // 2.처리결과 + if (nRet != 1) + { + sResMsg = ErrCodeToMsg(nRet); // 오류 + sResCD = "1"; + } + #endregion + + #region 3.응답전문(정상) + else + { + // 정상응답 + switch (sTranType) + { + case PosConst.POS_OCB_DIRECT.STOR_REGISTER: // 가맹점 등록 + case PosConst.POS_OCB_DIRECT.STOR_AUTH: // 가맹점 인증 + { + nNowPos = 0; + aIrtRspDTL = new string[Column.POS_REQ_OCB_AUTHMCHT.LEN.Length]; + ItemColumn.ParseMessage(Column.POS_REQ_OCB_AUTHMCHT.LEN, Column.POS_REQ_OCB_AUTHMCHT.TYPE, bRecvData, ref nNowPos, ref aIrtRspDTL); + if (aIrtRspDTL[Column.POS_REQ_OCB_AUTHMCHT.SEQ.RES_CD].Trim() != "1") + { + // 응답오류 + sResMsg = aIrtRspDTL[Column.POS_REQ_OCB_AUTHMCHT.SEQ.RES_MSG].Trim(); + sResCD = "1"; + } + else + { + // 정상 + sResMsg = "OK"; + sResCD = "0"; + sRet = UserCom.RST_OK; + } + break; + } + case PosConst.POS_OCB_DIRECT.INQ_POINT: // 포인트 조회 + { + nNowPos = 0; + aIrtRspDTL = new string[Column.POS_REQ_OCB_INQPOINT.LEN.Length]; + ItemColumn.ParseMessage(Column.POS_REQ_OCB_INQPOINT.LEN, Column.POS_REQ_OCB_INQPOINT.TYPE, bRecvData, ref nNowPos, ref aIrtRspDTL); + if (aIrtRspDTL[Column.POS_REQ_OCB_INQPOINT.SEQ.RES_CD].Trim() != "1") + { + // 응답오류 + sResMsg = aIrtRspDTL[Column.POS_REQ_OCB_INQPOINT.SEQ.RES_MSG1].Trim(); + sResCD = "1"; + } + else + { + // 정상 + sResMsg = "OK"; + sResCD = "0"; + sRet = UserCom.RST_OK; + } + break; + } + case PosConst.POS_OCB_DIRECT.SAVE_POINT: // 포인트 적립 + case PosConst.POS_OCB_DIRECT.USE_POINT: // 포인트 사용 + { + nNowPos = 0; + aIrtRspDTL = new string[Column.POS_REQ_OCB_POINT.LEN.Length]; + ItemColumn.ParseMessage(Column.POS_REQ_OCB_POINT.LEN, Column.POS_REQ_OCB_POINT.TYPE, bRecvData, ref nNowPos, ref aIrtRspDTL); + if (aIrtRspDTL[Column.POS_REQ_OCB_POINT.SEQ.RES_CD].Trim() != "1") + { + // 응답오류 + sResMsg = aIrtRspDTL[Column.POS_REQ_OCB_POINT.SEQ.RES_MSG1].Trim(); + sResCD = "1"; + } + else + { + // 정상 + sResMsg = "OK"; + sResCD = "0"; + sApprDt = aIrtRspDTL[Column.POS_REQ_OCB_POINT.SEQ.APPR_DATE].Trim(); + sApprTm = aIrtRspDTL[Column.POS_REQ_OCB_POINT.SEQ.APPR_TIME].Trim(); + sApprNo = aIrtRspDTL[Column.POS_REQ_OCB_POINT.SEQ.APPR_NO].Trim(); + + sRet = UserCom.RST_OK; + } + break; + } + case PosConst.POS_OCB_DIRECT.SAVE_CAN_POINT: // 포인트 적립 취소 + case PosConst.POS_OCB_DIRECT.USE_CAN_POINT: // 포인트 사용 취소 + case PosConst.POS_OCB_DIRECT.NET_CAN_POINT: // 포인트 망 취소 + { + nNowPos = 0; + aIrtRspDTL = new string[Column.POS_REQ_OCB_CANPOINT.LEN.Length]; + ItemColumn.ParseMessage(Column.POS_REQ_OCB_CANPOINT.LEN, Column.POS_REQ_OCB_CANPOINT.TYPE, bRecvData, ref nNowPos, ref aIrtRspDTL); + if (aIrtRspDTL[Column.POS_REQ_OCB_CANPOINT.SEQ.RES_CD].Trim() != "1") + { + // 응답오류 + sResMsg = aIrtRspDTL[Column.POS_REQ_OCB_CANPOINT.SEQ.RES_MSG1].Trim(); + sResCD = "1"; + } + else + { + // 정상 + sResMsg = "OK"; + sResCD = "0"; + sApprDt = aIrtRspDTL[Column.POS_REQ_OCB_CANPOINT.SEQ.APPR_DATE].Trim(); + sApprTm = aIrtRspDTL[Column.POS_REQ_OCB_CANPOINT.SEQ.APPR_TIME].Trim(); + sApprNo = aIrtRspDTL[Column.POS_REQ_OCB_CANPOINT.SEQ.APPR_NO].Trim(); + sRet = UserCom.RST_OK; + } + break; + } + } + } + + // 응답 - 승인로그 저장 (판매구분, [0]결제수단, [1]결제상세코드, [2]전문구분, [3]요청구분, [4]카드번호, [5]결제금액, [6]승인번호, [7]승인일자, [8]승인시간, [9]응답상태값, [10]응답메시지, [11]전문) + string sRecvData = ByteToString(bRecvData); + + // 승인데이터 중 카드번호 마스킹 처리(2017.05.25) + string sWriteRecvData = CmUtil.MakeLogDataToMask(false, sCardNo, sRecvData.Trim()); + UserLog.WriteLogFile(UserCom.LOG_SOCK, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", + "[RECV:" + sWriteRecvData); + m_cDataCommon.SetSaleApprLog(sTradeDiv, new string[] { sPayWayCD, sPayWayDtlCD, sTranType, "R" + , sCardNo, sPayAmt + , sApprNo, (sApprDt == "" ? DateTime.Now.ToString("yyyyMMdd") : sApprDt), (sApprTm == "" ? DateTime.Now.ToString("HHmmss") : sApprTm) + , sResCD + , sResMsg + , sWriteRecvData }); + + #endregion + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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); + sResMsg = ex.Message; + } + return sRet; + } + #endregion + + #region 응답코드 + /// + /// 응답코드 + /// + /// + /// + private string ErrCodeToMsg(int nErrCode) + { + string sMsg = string.Empty; + + try + { + switch (nErrCode) + { + case -1 : sMsg = "실패 - 함수Parameter값 이상"; break; + case 2 : sMsg = "암호화 실패 - 암호화, 복호화오류"; break; + case 3 : sMsg = "소켓 초기화 실패 - 네트워크 단절에 의한 소켓 초기화 실패"; break; + case 4 : sMsg = "소켓 Send 실패"; break; + case 5 : sMsg = "소켓 Receive 실패"; break; + case 6 : sMsg = "소켓 타임아웃"; break; + case 7 : sMsg = "인터넷 연결 실패"; break; + default: sMsg = "알 수 없는 에러"; break; + } + } + catch { } + return sMsg; + } + #endregion + + #region Byte 문자열 처리 + /// + /// Byte배열을 string으로 변환 (Byte배열의 null(0x00)값 제거) + /// + /// + /// + private string ByteToString(byte[] data) + { + int inx = Array.FindIndex(data, 0, (x) => x == 0x0); + if (inx >= 0) + { + return Encoding.Default.GetString(data, 0, inx); + } + else + { + return Encoding.Default.GetString(data); + } + } + #endregion + } +} diff --git a/Agent/OLEDevice/OLEDevice.csproj b/Agent/OLEDevice/OLEDevice.csproj new file mode 100644 index 0000000..bb0e611 --- /dev/null +++ b/Agent/OLEDevice/OLEDevice.csproj @@ -0,0 +1,139 @@ + + + + + Debug + AnyCPU + {404D077E-7CD4-49E6-8219-E79A28749DE0} + Library + Properties + Cosmos.OLEDevice + Agent.OLEDevice + v4.0 + 512 + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + ..\..\..\BIN\Agent.OLEDevice.XML + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\..\BIN\AxInterop.SPCNSECUCATLib.dll + + + False + ..\..\..\BIN\AxInterop.SPCNSECUMSRLib.dll + + + False + ..\..\..\BIN\Cosmos.BaseFrame.dll + + + False + ..\..\..\BIN\Cosmos.ServiceProvider.dll + + + False + ..\..\..\BIN\Cosmos.UserFrame.dll + + + False + ..\..\..\BIN\Microsoft.PointOfService.dll + + + False + ..\..\..\BIN\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + + + + + + + Form + + + frmDeviceOurHome.cs + + + + + + + + + + frmDeviceOurHome.cs + + + + + {0C240E1D-AB66-45B9-A7D5-A523F36009C2} + 2 + 0 + 0 + aximp + False + + + + + {670a81be-cee3-4c29-846d-a37652ca270d} + CommonManager + + + {a5b7accd-79eb-4261-bd36-01ab484ad8e3} + Common + + + + + copy .\IC\Agent.OLEDevice.dll .\Agent.OLEDevice.dll + + + copy .\Agent.OLEDevice.dll .\IC\Agent.OLEDevice.dll + + + \ No newline at end of file diff --git a/Agent/OLEDevice/Properties/AssemblyInfo.cs b/Agent/OLEDevice/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..1b1ae1d --- /dev/null +++ b/Agent/OLEDevice/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리의 일반 정보는 다음 특성 집합을 통해 제어됩니다. +// 어셈블리와 관련된 정보를 수정하려면 +// 이 특성 값을 변경하십시오. +[assembly: AssemblyTitle("OLEDevice")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OLEDevice")] +[assembly: AssemblyCopyright("Copyright © 2016")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하십시오. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("cec0ee82-9b18-4cf3-b591-21e8967580dc")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 버전이 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Agent/OLEDevice/frmDeviceOurHome.Designer.cs b/Agent/OLEDevice/frmDeviceOurHome.Designer.cs new file mode 100644 index 0000000..de5d452 --- /dev/null +++ b/Agent/OLEDevice/frmDeviceOurHome.Designer.cs @@ -0,0 +1,65 @@ +namespace Cosmos.OLEDevice +{ + partial class frmDeviceOurHome + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmDeviceOurHome)); + this.axOUT_STORE_RF1 = new AxOUT_STOR_RF.AxOUT_STORE_RF(); + ((System.ComponentModel.ISupportInitialize)(this.axOUT_STORE_RF1)).BeginInit(); + this.SuspendLayout(); + // + // axOUT_STORE_RF1 + // + this.axOUT_STORE_RF1.Enabled = true; + this.axOUT_STORE_RF1.Location = new System.Drawing.Point(95, 12); + this.axOUT_STORE_RF1.Name = "axOUT_STORE_RF1"; + this.axOUT_STORE_RF1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axOUT_STORE_RF1.OcxState"))); + this.axOUT_STORE_RF1.Size = new System.Drawing.Size(34, 36); + this.axOUT_STORE_RF1.TabIndex = 0; + // + // frmDeviceOurHome + // + this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(380, 325); + this.Controls.Add(this.axOUT_STORE_RF1); + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.Name = "frmDeviceOurHome"; + this.ShowInTaskbar = false; + this.Text = "frmOurHome"; + ((System.ComponentModel.ISupportInitialize)(this.axOUT_STORE_RF1)).EndInit(); + this.ResumeLayout(false); + + } + + #endregion + + private AxOUT_STOR_RF.AxOUT_STORE_RF axOUT_STORE_RF1; + + } +} \ No newline at end of file diff --git a/Agent/OLEDevice/frmDeviceOurHome.cs b/Agent/OLEDevice/frmDeviceOurHome.cs new file mode 100644 index 0000000..5a61316 --- /dev/null +++ b/Agent/OLEDevice/frmDeviceOurHome.cs @@ -0,0 +1,237 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +using Cosmos.Common; +using Cosmos.ServiceProvider; +using Cosmos.CommonManager; +using Cosmos.UserFrame; +using Cosmos.BaseFrame; + +namespace Cosmos.OLEDevice +{ + public partial class frmDeviceOurHome : Form + { + #region 변수 선언 + + protected SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출 + protected StateServer StateObject = (StateServer)StateServer.GetInstance(); // StateObject : StateServer Object (객체) + protected PosStatus m_cPosStatus = new PosStatus(); // 기본정보 참조 + + /// + /// 빌딩코드 + /// + ///private string m_sRegStorCode = ""; + /// + /// 서버 IP + /// + private string m_sServerIP = ""; + /// + /// DB 스키마 + /// + private string m_sDBChema = ""; + /// + /// ID + /// + private string m_sID = ""; + /// + /// Password + /// + private string m_sPassword = ""; + #endregion + + public frmDeviceOurHome() + { + InitializeComponent(); + + base.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint | ControlStyles.ResizeRedraw, true); + //this.UpdateStyles(); + + //m_sRegStorCode = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.EMP_PAY_ITEM, ItemConst.TR_ITEM_ID.EMP_PAY.OURHOME, PosMst.MST_VAN.DATA.CMP_APPR_ID); + m_sServerIP = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.EMP_PAY_ITEM, ItemConst.TR_ITEM_ID.EMP_PAY.OURHOME, PosMst.MST_VAN.DATA.IP); + + // 접속정보 + LoadPosConfig_OurHome(); + if (m_sDBChema == null || m_sDBChema.Trim() == "") SavePosConfig_OurHome(); + } + + #region 접속/해제 처리 함수 + /// + /// DB 접속 + /// + /// + /// + /// + /// + /// + /// + private string DBConnect(string sStorCode, string sServerIP, string sDBSchema, string sID, string sPassword) + { + string sResult = "9^Not Connect DataBase!!!"; + try + { + sResult = axOUT_STORE_RF1.DbConnect(sStorCode, sServerIP, sDBSchema, sID, sPassword); + } + catch(Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 sResult; + } + + /// + /// DB 접속 해제 + /// + /// + private void DBDisConnect() + { + try + { + axOUT_STORE_RF1.DbDisConnect(); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 고객정보 조회 + /// + /// 고객정보 조회 + /// + /// + /// + /// + /// + public string Rf_EmpInfo(string sStoreCD, string sRFNo, string sRFType) + { + string sResult = "9^Not Connect DataBase!!!"; + string[] aRecvData = null; + try + { + sResult = DBConnect(sStoreCD, m_sServerIP, m_sDBChema, m_sID, m_sPassword); + aRecvData = sResult.Split(new string[] { "^" }, StringSplitOptions.None); + if (aRecvData[0] != "1") return sResult; + + sResult = axOUT_STORE_RF1.Rf_EmpInfo(sStoreCD, sRFNo, sRFType); + DBDisConnect(); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 sResult; + } + #endregion + + #region 결제 + /// + /// 결제 + /// + /// + /// + /// + public string Rf_TransData(string sStoreCD, string sTranData, string sRfType) + { + string sResult = "9^Not Connect DataBase!!!"; + string[] aRecvData = null; + try + { + sResult = DBConnect(sStoreCD, m_sServerIP, m_sDBChema, m_sID, m_sPassword); + aRecvData = sResult.Split(new string[] { "^" }, StringSplitOptions.None); + if (aRecvData[0] != "1") return sResult; + + sResult = axOUT_STORE_RF1.Rf_TransData(sTranData, sRfType); + DBDisConnect(); + } + catch (Exception ex) + { + UserLog.WriteLogFile(UserCom.LOG_IOS, + 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 sResult; + } + #endregion + + #region SavePosConfig Pos 환경설정정보 저장 (PosConfig.INI) + /// + /// POS환경설정정보 파일저장 (PosConfig.INI) + /// + /// + public string SavePosConfig_OurHome() + { + string sRet = UserCom.RST_ERR; + try + { + CmMessage cmPosConfig = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosConfig); + + cmPosConfig.GetMessage("OURHOME".Trim()).MakeMessageOverWrite("DBChema".Trim(), "OURHOME"); + cmPosConfig.GetMessage("OURHOME".Trim()).MakeMessageOverWrite("ID".Trim(), "OUT_STORE"); + cmPosConfig.GetMessage("OURHOME".Trim()).MakeMessageOverWrite("Password".Trim(), "OUT_STORE"); + + // 파일저장 + cmPosConfig.MakeFileFromMessage(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosConfig); + + LoadPosConfig_OurHome(); + + sRet = UserCom.RST_OK; + } + catch (Exception ex) + { + WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); + } + return sRet; + } + #endregion + + #region LoadPosConfig Pos 환경설정정보 읽기(PosConfig.INI) + /// + /// POS환경설정정보 파일읽기 (PosConfig.INI) + /// + /// + public string LoadPosConfig_OurHome() + { + string sRet = UserCom.RST_ERR; + try + { + CmMessage cmPosConfig = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosConfig); + + m_sDBChema = cmPosConfig.GetMessage("OURHOME").GetMessageValue("DBChema"); + m_sID = cmPosConfig.GetMessage("OURHOME").GetMessageValue("ID"); + m_sPassword = cmPosConfig.GetMessage("OURHOME").GetMessageValue("Password"); + + sRet = UserCom.RST_OK; + } + catch (Exception ex) + { + WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); + } + return sRet; + } + #endregion + } +} diff --git a/Agent/OLEDevice/frmDeviceOurHome.resx b/Agent/OLEDevice/frmDeviceOurHome.resx new file mode 100644 index 0000000..e03c924 --- /dev/null +++ b/Agent/OLEDevice/frmDeviceOurHome.resx @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w + LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0 + ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAXQAAAAIB + AAAAAQAAAAAAAAAAAAAAAEgAAACTsgAASAAAAAMACAAL8ldHIAAAAF8AZQB4AHQAZQBuAHQAeACEAwAA + AwAIAAryV0fg////XwBlAHgAdABlAG4AdAB5ALkDAAAL + + + \ No newline at end of file diff --git a/Dropimage/Bl_bar.png b/Dropimage/Bl_bar.png new file mode 100644 index 0000000..f25032c Binary files /dev/null and b/Dropimage/Bl_bar.png differ diff --git a/Dropimage/Bl_discount.png b/Dropimage/Bl_discount.png new file mode 100644 index 0000000..7e6206d Binary files /dev/null and b/Dropimage/Bl_discount.png differ diff --git a/Dropimage/Bl_num1.png b/Dropimage/Bl_num1.png new file mode 100644 index 0000000..1470091 Binary files /dev/null and b/Dropimage/Bl_num1.png differ diff --git a/Dropimage/Bl_num2.png b/Dropimage/Bl_num2.png new file mode 100644 index 0000000..cd1c588 Binary files /dev/null and b/Dropimage/Bl_num2.png differ diff --git a/Dropimage/Bl_num3.png b/Dropimage/Bl_num3.png new file mode 100644 index 0000000..8b8320d Binary files /dev/null and b/Dropimage/Bl_num3.png differ diff --git a/Dropimage/Btn_coupondelete.png b/Dropimage/Btn_coupondelete.png new file mode 100644 index 0000000..aaf2d78 Binary files /dev/null and b/Dropimage/Btn_coupondelete.png differ diff --git a/Dropimage/Btn_toggle_off.png b/Dropimage/Btn_toggle_off.png new file mode 100644 index 0000000..cc3defd Binary files /dev/null and b/Dropimage/Btn_toggle_off.png differ diff --git a/Dropimage/Btn_toggle_on.png b/Dropimage/Btn_toggle_on.png new file mode 100644 index 0000000..dc2f935 Binary files /dev/null and b/Dropimage/Btn_toggle_on.png differ diff --git a/Dropimage/Ic_Basket.png b/Dropimage/Ic_Basket.png new file mode 100644 index 0000000..26a8d02 Binary files /dev/null and b/Dropimage/Ic_Basket.png differ diff --git a/Dropimage/Ic_ai_off.png b/Dropimage/Ic_ai_off.png new file mode 100644 index 0000000..170ce4a Binary files /dev/null and b/Dropimage/Ic_ai_off.png differ diff --git a/Dropimage/Ic_ai_on.png b/Dropimage/Ic_ai_on.png new file mode 100644 index 0000000..0792695 Binary files /dev/null and b/Dropimage/Ic_ai_on.png differ diff --git a/Dropimage/Ic_mylist_d.png b/Dropimage/Ic_mylist_d.png new file mode 100644 index 0000000..5738baa Binary files /dev/null and b/Dropimage/Ic_mylist_d.png differ diff --git a/Dropimage/Ic_mylist_n.png b/Dropimage/Ic_mylist_n.png new file mode 100644 index 0000000..7d835d9 Binary files /dev/null and b/Dropimage/Ic_mylist_n.png differ diff --git a/Dropimage/Ic_mylist_s.png b/Dropimage/Ic_mylist_s.png new file mode 100644 index 0000000..80571ab Binary files /dev/null and b/Dropimage/Ic_mylist_s.png differ diff --git a/Dropimage/Ic_mylist_x.png b/Dropimage/Ic_mylist_x.png new file mode 100644 index 0000000..7190e97 Binary files /dev/null and b/Dropimage/Ic_mylist_x.png differ diff --git a/Dropimage/Ic_order_off.png b/Dropimage/Ic_order_off.png new file mode 100644 index 0000000..17a49c8 Binary files /dev/null and b/Dropimage/Ic_order_off.png differ diff --git a/Dropimage/Ic_order_on.png b/Dropimage/Ic_order_on.png new file mode 100644 index 0000000..0f95b33 Binary files /dev/null and b/Dropimage/Ic_order_on.png differ diff --git a/Dropimage/Ic_totalcost.png b/Dropimage/Ic_totalcost.png new file mode 100644 index 0000000..ccd9d7c Binary files /dev/null and b/Dropimage/Ic_totalcost.png differ diff --git a/Dropimage/Img_bell.png b/Dropimage/Img_bell.png new file mode 100644 index 0000000..42b5479 Binary files /dev/null and b/Dropimage/Img_bell.png differ diff --git a/Dropimage/Img_best.png b/Dropimage/Img_best.png new file mode 100644 index 0000000..fb6167d Binary files /dev/null and b/Dropimage/Img_best.png differ diff --git a/Dropimage/Img_main_logo.png b/Dropimage/Img_main_logo.png new file mode 100644 index 0000000..6883621 Binary files /dev/null and b/Dropimage/Img_main_logo.png differ diff --git a/Dropimage/Img_new.png b/Dropimage/Img_new.png new file mode 100644 index 0000000..43784cf Binary files /dev/null and b/Dropimage/Img_new.png differ diff --git a/Dropimage/Img_page_dot_off.png b/Dropimage/Img_page_dot_off.png new file mode 100644 index 0000000..512df66 Binary files /dev/null and b/Dropimage/Img_page_dot_off.png differ diff --git a/Dropimage/Img_page_dot_on.png b/Dropimage/Img_page_dot_on.png new file mode 100644 index 0000000..1a03a34 Binary files /dev/null and b/Dropimage/Img_page_dot_on.png differ diff --git a/Dropimage/Img_qr.png b/Dropimage/Img_qr.png new file mode 100644 index 0000000..e1a35ad Binary files /dev/null and b/Dropimage/Img_qr.png differ diff --git a/Dropimage/Img_qr_Android.png b/Dropimage/Img_qr_Android.png new file mode 100644 index 0000000..c5892cf Binary files /dev/null and b/Dropimage/Img_qr_Android.png differ diff --git a/Dropimage/Img_qr_bg.png b/Dropimage/Img_qr_bg.png new file mode 100644 index 0000000..cab809d Binary files /dev/null and b/Dropimage/Img_qr_bg.png differ diff --git a/Dropimage/Img_qr_iOS.png b/Dropimage/Img_qr_iOS.png new file mode 100644 index 0000000..54f41a9 Binary files /dev/null and b/Dropimage/Img_qr_iOS.png differ diff --git a/Dropimage/basket_list_bg.png b/Dropimage/basket_list_bg.png new file mode 100644 index 0000000..b7eaea3 Binary files /dev/null and b/Dropimage/basket_list_bg.png differ diff --git a/Dropimage/basket_pop_bg.png b/Dropimage/basket_pop_bg.png new file mode 100644 index 0000000..632f57e Binary files /dev/null and b/Dropimage/basket_pop_bg.png differ diff --git a/Dropimage/basket_pop_bg2.png b/Dropimage/basket_pop_bg2.png new file mode 100644 index 0000000..7a1e735 Binary files /dev/null and b/Dropimage/basket_pop_bg2.png differ diff --git a/Dropimage/bg_basket_box.png b/Dropimage/bg_basket_box.png new file mode 100644 index 0000000..753f820 Binary files /dev/null and b/Dropimage/bg_basket_box.png differ diff --git a/Dropimage/bg_basket_none.png b/Dropimage/bg_basket_none.png new file mode 100644 index 0000000..369f7f4 Binary files /dev/null and b/Dropimage/bg_basket_none.png differ diff --git a/Dropimage/btn_addorder2_f.png b/Dropimage/btn_addorder2_f.png new file mode 100644 index 0000000..e4e7ad5 Binary files /dev/null and b/Dropimage/btn_addorder2_f.png differ diff --git a/Dropimage/btn_addorder2_n.png b/Dropimage/btn_addorder2_n.png new file mode 100644 index 0000000..c552358 Binary files /dev/null and b/Dropimage/btn_addorder2_n.png differ diff --git a/Dropimage/btn_addorder3_f.png b/Dropimage/btn_addorder3_f.png new file mode 100644 index 0000000..e14cc86 Binary files /dev/null and b/Dropimage/btn_addorder3_f.png differ diff --git a/Dropimage/btn_addorder3_n.png b/Dropimage/btn_addorder3_n.png new file mode 100644 index 0000000..1018159 Binary files /dev/null and b/Dropimage/btn_addorder3_n.png differ diff --git a/Dropimage/btn_addorder_b.png b/Dropimage/btn_addorder_b.png new file mode 100644 index 0000000..4cda439 Binary files /dev/null and b/Dropimage/btn_addorder_b.png differ diff --git a/Dropimage/btn_addorder_bb.png b/Dropimage/btn_addorder_bb.png new file mode 100644 index 0000000..2b6c333 Binary files /dev/null and b/Dropimage/btn_addorder_bb.png differ diff --git a/Dropimage/btn_addorder_camerascan_f.png b/Dropimage/btn_addorder_camerascan_f.png new file mode 100644 index 0000000..a22f49f Binary files /dev/null and b/Dropimage/btn_addorder_camerascan_f.png differ diff --git a/Dropimage/btn_addorder_camerascan_n.png b/Dropimage/btn_addorder_camerascan_n.png new file mode 100644 index 0000000..6f1bbdb Binary files /dev/null and b/Dropimage/btn_addorder_camerascan_n.png differ diff --git a/Dropimage/btn_addorder_f.png b/Dropimage/btn_addorder_f.png new file mode 100644 index 0000000..eebb67e Binary files /dev/null and b/Dropimage/btn_addorder_f.png differ diff --git a/Dropimage/btn_addorder_n.png b/Dropimage/btn_addorder_n.png new file mode 100644 index 0000000..793d180 Binary files /dev/null and b/Dropimage/btn_addorder_n.png differ diff --git a/Dropimage/btn_addorder_payment_f.png b/Dropimage/btn_addorder_payment_f.png new file mode 100644 index 0000000..cef8b38 Binary files /dev/null and b/Dropimage/btn_addorder_payment_f.png differ diff --git a/Dropimage/btn_addorder_payment_n.png b/Dropimage/btn_addorder_payment_n.png new file mode 100644 index 0000000..9a12df1 Binary files /dev/null and b/Dropimage/btn_addorder_payment_n.png differ diff --git a/Dropimage/btn_addorder_selforder_f.png b/Dropimage/btn_addorder_selforder_f.png new file mode 100644 index 0000000..b041da1 Binary files /dev/null and b/Dropimage/btn_addorder_selforder_f.png differ diff --git a/Dropimage/btn_addorder_selforder_n.png b/Dropimage/btn_addorder_selforder_n.png new file mode 100644 index 0000000..ecd3902 Binary files /dev/null and b/Dropimage/btn_addorder_selforder_n.png differ diff --git a/Dropimage/btn_basket_delete.png b/Dropimage/btn_basket_delete.png new file mode 100644 index 0000000..a5df863 Binary files /dev/null and b/Dropimage/btn_basket_delete.png differ diff --git a/Dropimage/btn_basket_plus.png b/Dropimage/btn_basket_plus.png new file mode 100644 index 0000000..2242735 Binary files /dev/null and b/Dropimage/btn_basket_plus.png differ diff --git a/Dropimage/btn_camerascan_start.png b/Dropimage/btn_camerascan_start.png new file mode 100644 index 0000000..f07b801 Binary files /dev/null and b/Dropimage/btn_camerascan_start.png differ diff --git a/Dropimage/btn_check_n.png b/Dropimage/btn_check_n.png new file mode 100644 index 0000000..759611b Binary files /dev/null and b/Dropimage/btn_check_n.png differ diff --git a/Dropimage/btn_check_s.png b/Dropimage/btn_check_s.png new file mode 100644 index 0000000..9fbc730 Binary files /dev/null and b/Dropimage/btn_check_s.png differ diff --git a/Dropimage/btn_count_minus_n.png b/Dropimage/btn_count_minus_n.png new file mode 100644 index 0000000..5769186 Binary files /dev/null and b/Dropimage/btn_count_minus_n.png differ diff --git a/Dropimage/btn_count_minus_p.png b/Dropimage/btn_count_minus_p.png new file mode 100644 index 0000000..725d00d Binary files /dev/null and b/Dropimage/btn_count_minus_p.png differ diff --git a/Dropimage/btn_count_plus_n.png b/Dropimage/btn_count_plus_n.png new file mode 100644 index 0000000..06e565a Binary files /dev/null and b/Dropimage/btn_count_plus_n.png differ diff --git a/Dropimage/btn_count_plus_p.png b/Dropimage/btn_count_plus_p.png new file mode 100644 index 0000000..9da8628 Binary files /dev/null and b/Dropimage/btn_count_plus_p.png differ diff --git a/Dropimage/btn_coupon_d.png b/Dropimage/btn_coupon_d.png new file mode 100644 index 0000000..be8e48c Binary files /dev/null and b/Dropimage/btn_coupon_d.png differ diff --git a/Dropimage/btn_coupon_n.png b/Dropimage/btn_coupon_n.png new file mode 100644 index 0000000..f555dd5 Binary files /dev/null and b/Dropimage/btn_coupon_n.png differ diff --git a/Dropimage/btn_coupon_p.png b/Dropimage/btn_coupon_p.png new file mode 100644 index 0000000..7b146db Binary files /dev/null and b/Dropimage/btn_coupon_p.png differ diff --git a/Dropimage/btn_coupon_s.png b/Dropimage/btn_coupon_s.png new file mode 100644 index 0000000..cdb404d Binary files /dev/null and b/Dropimage/btn_coupon_s.png differ diff --git a/Dropimage/btn_delete.png b/Dropimage/btn_delete.png new file mode 100644 index 0000000..913d99c Binary files /dev/null and b/Dropimage/btn_delete.png differ diff --git a/Dropimage/btn_delete_2.png b/Dropimage/btn_delete_2.png new file mode 100644 index 0000000..53a081b Binary files /dev/null and b/Dropimage/btn_delete_2.png differ diff --git a/Dropimage/btn_delete_2_p.png b/Dropimage/btn_delete_2_p.png new file mode 100644 index 0000000..d7cf654 Binary files /dev/null and b/Dropimage/btn_delete_2_p.png differ diff --git a/Dropimage/btn_gift_n.png b/Dropimage/btn_gift_n.png new file mode 100644 index 0000000..aed6d84 Binary files /dev/null and b/Dropimage/btn_gift_n.png differ diff --git a/Dropimage/btn_gift_s.png b/Dropimage/btn_gift_s.png new file mode 100644 index 0000000..202732c Binary files /dev/null and b/Dropimage/btn_gift_s.png differ diff --git a/Dropimage/btn_happypoint_d.png b/Dropimage/btn_happypoint_d.png new file mode 100644 index 0000000..cd5e906 Binary files /dev/null and b/Dropimage/btn_happypoint_d.png differ diff --git a/Dropimage/btn_happypoint_info.png b/Dropimage/btn_happypoint_info.png new file mode 100644 index 0000000..c5d3eea Binary files /dev/null and b/Dropimage/btn_happypoint_info.png differ diff --git a/Dropimage/btn_happypoint_n.png b/Dropimage/btn_happypoint_n.png new file mode 100644 index 0000000..1f0674e Binary files /dev/null and b/Dropimage/btn_happypoint_n.png differ diff --git a/Dropimage/btn_help.png b/Dropimage/btn_help.png new file mode 100644 index 0000000..ed36d15 Binary files /dev/null and b/Dropimage/btn_help.png differ diff --git a/Dropimage/btn_language_chi.png b/Dropimage/btn_language_chi.png new file mode 100644 index 0000000..eebdf90 Binary files /dev/null and b/Dropimage/btn_language_chi.png differ diff --git a/Dropimage/btn_language_eng.png b/Dropimage/btn_language_eng.png new file mode 100644 index 0000000..cb32111 Binary files /dev/null and b/Dropimage/btn_language_eng.png differ diff --git a/Dropimage/btn_language_jap.png b/Dropimage/btn_language_jap.png new file mode 100644 index 0000000..51cb3a4 Binary files /dev/null and b/Dropimage/btn_language_jap.png differ diff --git a/Dropimage/btn_language_kor.png b/Dropimage/btn_language_kor.png new file mode 100644 index 0000000..df8cc40 Binary files /dev/null and b/Dropimage/btn_language_kor.png differ diff --git a/Dropimage/btn_main_camerascan_f.png b/Dropimage/btn_main_camerascan_f.png new file mode 100644 index 0000000..53c4abc Binary files /dev/null and b/Dropimage/btn_main_camerascan_f.png differ diff --git a/Dropimage/btn_main_camerascan_n.png b/Dropimage/btn_main_camerascan_n.png new file mode 100644 index 0000000..e01e090 Binary files /dev/null and b/Dropimage/btn_main_camerascan_n.png differ diff --git a/Dropimage/btn_main_menu_n.png b/Dropimage/btn_main_menu_n.png new file mode 100644 index 0000000..46cf5f9 Binary files /dev/null and b/Dropimage/btn_main_menu_n.png differ diff --git a/Dropimage/btn_main_menu_p.png b/Dropimage/btn_main_menu_p.png new file mode 100644 index 0000000..abf7be0 Binary files /dev/null and b/Dropimage/btn_main_menu_p.png differ diff --git a/Dropimage/btn_main_selforder_f.png b/Dropimage/btn_main_selforder_f.png new file mode 100644 index 0000000..a8e4c02 Binary files /dev/null and b/Dropimage/btn_main_selforder_f.png differ diff --git a/Dropimage/btn_main_selforder_n.png b/Dropimage/btn_main_selforder_n.png new file mode 100644 index 0000000..6cf3616 Binary files /dev/null and b/Dropimage/btn_main_selforder_n.png differ diff --git a/Dropimage/btn_minus.png b/Dropimage/btn_minus.png new file mode 100644 index 0000000..7ae76b1 Binary files /dev/null and b/Dropimage/btn_minus.png differ diff --git a/Dropimage/btn_number.png b/Dropimage/btn_number.png new file mode 100644 index 0000000..42f8d09 Binary files /dev/null and b/Dropimage/btn_number.png differ diff --git a/Dropimage/btn_number2.png b/Dropimage/btn_number2.png new file mode 100644 index 0000000..8a35769 Binary files /dev/null and b/Dropimage/btn_number2.png differ diff --git a/Dropimage/btn_number_0.png b/Dropimage/btn_number_0.png new file mode 100644 index 0000000..0dd8d9d Binary files /dev/null and b/Dropimage/btn_number_0.png differ diff --git a/Dropimage/btn_number_1.png b/Dropimage/btn_number_1.png new file mode 100644 index 0000000..4f66743 Binary files /dev/null and b/Dropimage/btn_number_1.png differ diff --git a/Dropimage/btn_number_2.png b/Dropimage/btn_number_2.png new file mode 100644 index 0000000..373e952 Binary files /dev/null and b/Dropimage/btn_number_2.png differ diff --git a/Dropimage/btn_number_3.png b/Dropimage/btn_number_3.png new file mode 100644 index 0000000..475f8ad Binary files /dev/null and b/Dropimage/btn_number_3.png differ diff --git a/Dropimage/btn_number_4.png b/Dropimage/btn_number_4.png new file mode 100644 index 0000000..4bbeced Binary files /dev/null and b/Dropimage/btn_number_4.png differ diff --git a/Dropimage/btn_number_5.png b/Dropimage/btn_number_5.png new file mode 100644 index 0000000..724e393 Binary files /dev/null and b/Dropimage/btn_number_5.png differ diff --git a/Dropimage/btn_number_6.png b/Dropimage/btn_number_6.png new file mode 100644 index 0000000..e3bfe8f Binary files /dev/null and b/Dropimage/btn_number_6.png differ diff --git a/Dropimage/btn_number_7.png b/Dropimage/btn_number_7.png new file mode 100644 index 0000000..4e04ff5 Binary files /dev/null and b/Dropimage/btn_number_7.png differ diff --git a/Dropimage/btn_number_8.png b/Dropimage/btn_number_8.png new file mode 100644 index 0000000..94d5818 Binary files /dev/null and b/Dropimage/btn_number_8.png differ diff --git a/Dropimage/btn_number_9.png b/Dropimage/btn_number_9.png new file mode 100644 index 0000000..5089e79 Binary files /dev/null and b/Dropimage/btn_number_9.png differ diff --git a/Dropimage/btn_number_all_n.png b/Dropimage/btn_number_all_n.png new file mode 100644 index 0000000..45f4f07 Binary files /dev/null and b/Dropimage/btn_number_all_n.png differ diff --git a/Dropimage/btn_number_all_p.png b/Dropimage/btn_number_all_p.png new file mode 100644 index 0000000..c2c15cd Binary files /dev/null and b/Dropimage/btn_number_all_p.png differ diff --git a/Dropimage/btn_number_c.png b/Dropimage/btn_number_c.png new file mode 100644 index 0000000..914211a Binary files /dev/null and b/Dropimage/btn_number_c.png differ diff --git a/Dropimage/btn_number_d.png b/Dropimage/btn_number_d.png new file mode 100644 index 0000000..6a962dc Binary files /dev/null and b/Dropimage/btn_number_d.png differ diff --git a/Dropimage/btn_option.png b/Dropimage/btn_option.png new file mode 100644 index 0000000..4959e10 Binary files /dev/null and b/Dropimage/btn_option.png differ diff --git a/Dropimage/btn_option_n.png b/Dropimage/btn_option_n.png new file mode 100644 index 0000000..ad46686 Binary files /dev/null and b/Dropimage/btn_option_n.png differ diff --git a/Dropimage/btn_option_s.png b/Dropimage/btn_option_s.png new file mode 100644 index 0000000..7cac59f Binary files /dev/null and b/Dropimage/btn_option_s.png differ diff --git a/Dropimage/btn_page_after_n.png b/Dropimage/btn_page_after_n.png new file mode 100644 index 0000000..ce50533 Binary files /dev/null and b/Dropimage/btn_page_after_n.png differ diff --git a/Dropimage/btn_page_before_n.png b/Dropimage/btn_page_before_n.png new file mode 100644 index 0000000..1ea070d Binary files /dev/null and b/Dropimage/btn_page_before_n.png differ diff --git a/Dropimage/btn_pay_ali_n.png b/Dropimage/btn_pay_ali_n.png new file mode 100644 index 0000000..f878016 Binary files /dev/null and b/Dropimage/btn_pay_ali_n.png differ diff --git a/Dropimage/btn_pay_back_n.png b/Dropimage/btn_pay_back_n.png new file mode 100644 index 0000000..0ed0b11 Binary files /dev/null and b/Dropimage/btn_pay_back_n.png differ diff --git a/Dropimage/btn_pay_bluemembers_n.png b/Dropimage/btn_pay_bluemembers_n.png new file mode 100644 index 0000000..bf39893 Binary files /dev/null and b/Dropimage/btn_pay_bluemembers_n.png differ diff --git a/Dropimage/btn_pay_cashbee_n.png b/Dropimage/btn_pay_cashbee_n.png new file mode 100644 index 0000000..dcaa398 Binary files /dev/null and b/Dropimage/btn_pay_cashbee_n.png differ diff --git a/Dropimage/btn_pay_creditcard_n.png b/Dropimage/btn_pay_creditcard_n.png new file mode 100644 index 0000000..565afe4 Binary files /dev/null and b/Dropimage/btn_pay_creditcard_n.png differ diff --git a/Dropimage/btn_pay_happyapp_d.png b/Dropimage/btn_pay_happyapp_d.png new file mode 100644 index 0000000..2017dd1 Binary files /dev/null and b/Dropimage/btn_pay_happyapp_d.png differ diff --git a/Dropimage/btn_pay_happyapp_f.png b/Dropimage/btn_pay_happyapp_f.png new file mode 100644 index 0000000..87ec76c Binary files /dev/null and b/Dropimage/btn_pay_happyapp_f.png differ diff --git a/Dropimage/btn_pay_happyapp_n.png b/Dropimage/btn_pay_happyapp_n.png new file mode 100644 index 0000000..d9a6cce Binary files /dev/null and b/Dropimage/btn_pay_happyapp_n.png differ diff --git a/Dropimage/btn_pay_happygift_n.png b/Dropimage/btn_pay_happygift_n.png new file mode 100644 index 0000000..8f767aa Binary files /dev/null and b/Dropimage/btn_pay_happygift_n.png differ diff --git a/Dropimage/btn_pay_happypoint_d.png b/Dropimage/btn_pay_happypoint_d.png new file mode 100644 index 0000000..3929dce Binary files /dev/null and b/Dropimage/btn_pay_happypoint_d.png differ diff --git a/Dropimage/btn_pay_happypoint_f.png b/Dropimage/btn_pay_happypoint_f.png new file mode 100644 index 0000000..fc0505c Binary files /dev/null and b/Dropimage/btn_pay_happypoint_f.png differ diff --git a/Dropimage/btn_pay_happypoint_n.png b/Dropimage/btn_pay_happypoint_n.png new file mode 100644 index 0000000..15a6648 Binary files /dev/null and b/Dropimage/btn_pay_happypoint_n.png differ diff --git a/Dropimage/btn_pay_hyundai_n.png b/Dropimage/btn_pay_hyundai_n.png new file mode 100644 index 0000000..42502d7 Binary files /dev/null and b/Dropimage/btn_pay_hyundai_n.png differ diff --git a/Dropimage/btn_pay_hyundaioilbank_n.png b/Dropimage/btn_pay_hyundaioilbank_n.png new file mode 100644 index 0000000..bd66ead Binary files /dev/null and b/Dropimage/btn_pay_hyundaioilbank_n.png differ diff --git a/Dropimage/btn_pay_kakao_n.png b/Dropimage/btn_pay_kakao_n.png new file mode 100644 index 0000000..236b27d Binary files /dev/null and b/Dropimage/btn_pay_kakao_n.png differ diff --git a/Dropimage/btn_pay_kiaredmembers_n.png b/Dropimage/btn_pay_kiaredmembers_n.png new file mode 100644 index 0000000..2b279e0 Binary files /dev/null and b/Dropimage/btn_pay_kiaredmembers_n.png differ diff --git a/Dropimage/btn_pay_kt_d.png b/Dropimage/btn_pay_kt_d.png new file mode 100644 index 0000000..ba00cbb Binary files /dev/null and b/Dropimage/btn_pay_kt_d.png differ diff --git a/Dropimage/btn_pay_kt_f.png b/Dropimage/btn_pay_kt_f.png new file mode 100644 index 0000000..217ae73 Binary files /dev/null and b/Dropimage/btn_pay_kt_f.png differ diff --git a/Dropimage/btn_pay_kt_n.png b/Dropimage/btn_pay_kt_n.png new file mode 100644 index 0000000..4e49a31 Binary files /dev/null and b/Dropimage/btn_pay_kt_n.png differ diff --git a/Dropimage/btn_pay_lg_d.png b/Dropimage/btn_pay_lg_d.png new file mode 100644 index 0000000..15e3804 Binary files /dev/null and b/Dropimage/btn_pay_lg_d.png differ diff --git a/Dropimage/btn_pay_lg_f.png b/Dropimage/btn_pay_lg_f.png new file mode 100644 index 0000000..1c5e8f7 Binary files /dev/null and b/Dropimage/btn_pay_lg_f.png differ diff --git a/Dropimage/btn_pay_lg_n.png b/Dropimage/btn_pay_lg_n.png new file mode 100644 index 0000000..af7d074 Binary files /dev/null and b/Dropimage/btn_pay_lg_n.png differ diff --git a/Dropimage/btn_pay_mobilecoupon_d.png b/Dropimage/btn_pay_mobilecoupon_d.png new file mode 100644 index 0000000..763f1b8 Binary files /dev/null and b/Dropimage/btn_pay_mobilecoupon_d.png differ diff --git a/Dropimage/btn_pay_mobilecoupon_f.png b/Dropimage/btn_pay_mobilecoupon_f.png new file mode 100644 index 0000000..7cdd23c Binary files /dev/null and b/Dropimage/btn_pay_mobilecoupon_f.png differ diff --git a/Dropimage/btn_pay_mobilecoupon_n.png b/Dropimage/btn_pay_mobilecoupon_n.png new file mode 100644 index 0000000..72b7f7a Binary files /dev/null and b/Dropimage/btn_pay_mobilecoupon_n.png differ diff --git a/Dropimage/btn_pay_more_n.png b/Dropimage/btn_pay_more_n.png new file mode 100644 index 0000000..835c2ab Binary files /dev/null and b/Dropimage/btn_pay_more_n.png differ diff --git a/Dropimage/btn_pay_ocb_d.png b/Dropimage/btn_pay_ocb_d.png new file mode 100644 index 0000000..03e67ca Binary files /dev/null and b/Dropimage/btn_pay_ocb_d.png differ diff --git a/Dropimage/btn_pay_ocb_f.png b/Dropimage/btn_pay_ocb_f.png new file mode 100644 index 0000000..4133f3f Binary files /dev/null and b/Dropimage/btn_pay_ocb_f.png differ diff --git a/Dropimage/btn_pay_ocb_n.png b/Dropimage/btn_pay_ocb_n.png new file mode 100644 index 0000000..21a5a03 Binary files /dev/null and b/Dropimage/btn_pay_ocb_n.png differ diff --git a/Dropimage/btn_pay_samsung_n.png b/Dropimage/btn_pay_samsung_n.png new file mode 100644 index 0000000..ac9b195 Binary files /dev/null and b/Dropimage/btn_pay_samsung_n.png differ diff --git a/Dropimage/btn_pay_samsunglg_n.png b/Dropimage/btn_pay_samsunglg_n.png new file mode 100644 index 0000000..b4459cc Binary files /dev/null and b/Dropimage/btn_pay_samsunglg_n.png differ diff --git a/Dropimage/btn_pay_shinhan_n.png b/Dropimage/btn_pay_shinhan_n.png new file mode 100644 index 0000000..469aa91 Binary files /dev/null and b/Dropimage/btn_pay_shinhan_n.png differ diff --git a/Dropimage/btn_pay_sk_d.png b/Dropimage/btn_pay_sk_d.png new file mode 100644 index 0000000..e4b9a6f Binary files /dev/null and b/Dropimage/btn_pay_sk_d.png differ diff --git a/Dropimage/btn_pay_sk_f.png b/Dropimage/btn_pay_sk_f.png new file mode 100644 index 0000000..a2ae4fd Binary files /dev/null and b/Dropimage/btn_pay_sk_f.png differ diff --git a/Dropimage/btn_pay_sk_n.png b/Dropimage/btn_pay_sk_n.png new file mode 100644 index 0000000..d8eb5c4 Binary files /dev/null and b/Dropimage/btn_pay_sk_n.png differ diff --git a/Dropimage/btn_pay_smile_n.png b/Dropimage/btn_pay_smile_n.png new file mode 100644 index 0000000..3f4d014 Binary files /dev/null and b/Dropimage/btn_pay_smile_n.png differ diff --git a/Dropimage/btn_pay_spc2_d.png b/Dropimage/btn_pay_spc2_d.png new file mode 100644 index 0000000..7949f5c Binary files /dev/null and b/Dropimage/btn_pay_spc2_d.png differ diff --git a/Dropimage/btn_pay_spc2_f.png b/Dropimage/btn_pay_spc2_f.png new file mode 100644 index 0000000..fb54551 Binary files /dev/null and b/Dropimage/btn_pay_spc2_f.png differ diff --git a/Dropimage/btn_pay_spc2_n.png b/Dropimage/btn_pay_spc2_n.png new file mode 100644 index 0000000..092d786 Binary files /dev/null and b/Dropimage/btn_pay_spc2_n.png differ diff --git a/Dropimage/btn_pay_spc_n.png b/Dropimage/btn_pay_spc_n.png new file mode 100644 index 0000000..be7545d Binary files /dev/null and b/Dropimage/btn_pay_spc_n.png differ diff --git a/Dropimage/btn_pay_tmoney_n.png b/Dropimage/btn_pay_tmoney_n.png new file mode 100644 index 0000000..3a9d3fb Binary files /dev/null and b/Dropimage/btn_pay_tmoney_n.png differ diff --git a/Dropimage/btn_pay_zero_n.png b/Dropimage/btn_pay_zero_n.png new file mode 100644 index 0000000..4908796 Binary files /dev/null and b/Dropimage/btn_pay_zero_n.png differ diff --git a/Dropimage/btn_plus.png b/Dropimage/btn_plus.png new file mode 100644 index 0000000..10a4468 Binary files /dev/null and b/Dropimage/btn_plus.png differ diff --git a/Dropimage/btn_pop_chi_n.png b/Dropimage/btn_pop_chi_n.png new file mode 100644 index 0000000..f03ad07 Binary files /dev/null and b/Dropimage/btn_pop_chi_n.png differ diff --git a/Dropimage/btn_pop_chi_s.png b/Dropimage/btn_pop_chi_s.png new file mode 100644 index 0000000..6402925 Binary files /dev/null and b/Dropimage/btn_pop_chi_s.png differ diff --git a/Dropimage/btn_pop_eng_n.png b/Dropimage/btn_pop_eng_n.png new file mode 100644 index 0000000..15e6378 Binary files /dev/null and b/Dropimage/btn_pop_eng_n.png differ diff --git a/Dropimage/btn_pop_eng_s.png b/Dropimage/btn_pop_eng_s.png new file mode 100644 index 0000000..8a08744 Binary files /dev/null and b/Dropimage/btn_pop_eng_s.png differ diff --git a/Dropimage/btn_pop_jap_n.png b/Dropimage/btn_pop_jap_n.png new file mode 100644 index 0000000..cc310d0 Binary files /dev/null and b/Dropimage/btn_pop_jap_n.png differ diff --git a/Dropimage/btn_pop_jap_s.png b/Dropimage/btn_pop_jap_s.png new file mode 100644 index 0000000..940af4a Binary files /dev/null and b/Dropimage/btn_pop_jap_s.png differ diff --git a/Dropimage/btn_pop_kor_n.png b/Dropimage/btn_pop_kor_n.png new file mode 100644 index 0000000..c176465 Binary files /dev/null and b/Dropimage/btn_pop_kor_n.png differ diff --git a/Dropimage/btn_pop_kor_s.png b/Dropimage/btn_pop_kor_s.png new file mode 100644 index 0000000..6710790 Binary files /dev/null and b/Dropimage/btn_pop_kor_s.png differ diff --git a/Dropimage/btn_reset.png b/Dropimage/btn_reset.png new file mode 100644 index 0000000..aad0371 Binary files /dev/null and b/Dropimage/btn_reset.png differ diff --git a/Dropimage/btn_store.png b/Dropimage/btn_store.png new file mode 100644 index 0000000..c038050 Binary files /dev/null and b/Dropimage/btn_store.png differ diff --git a/Dropimage/btn_store_agree_n.png b/Dropimage/btn_store_agree_n.png new file mode 100644 index 0000000..1f8343d Binary files /dev/null and b/Dropimage/btn_store_agree_n.png differ diff --git a/Dropimage/btn_store_agree_n2.png b/Dropimage/btn_store_agree_n2.png new file mode 100644 index 0000000..47998e3 Binary files /dev/null and b/Dropimage/btn_store_agree_n2.png differ diff --git a/Dropimage/btn_store_agree_s.png b/Dropimage/btn_store_agree_s.png new file mode 100644 index 0000000..bf00dd5 Binary files /dev/null and b/Dropimage/btn_store_agree_s.png differ diff --git a/Dropimage/discount_bar.png b/Dropimage/discount_bar.png new file mode 100644 index 0000000..6a13107 Binary files /dev/null and b/Dropimage/discount_bar.png differ diff --git a/Dropimage/happy_member_gold.png b/Dropimage/happy_member_gold.png new file mode 100644 index 0000000..d665d89 Binary files /dev/null and b/Dropimage/happy_member_gold.png differ diff --git a/Dropimage/happy_member_pink.png b/Dropimage/happy_member_pink.png new file mode 100644 index 0000000..759162a Binary files /dev/null and b/Dropimage/happy_member_pink.png differ diff --git a/Dropimage/happy_member_platinum.png b/Dropimage/happy_member_platinum.png new file mode 100644 index 0000000..0c0ae16 Binary files /dev/null and b/Dropimage/happy_member_platinum.png differ diff --git a/Dropimage/ic_alert_cancel.png b/Dropimage/ic_alert_cancel.png new file mode 100644 index 0000000..bf1da04 Binary files /dev/null and b/Dropimage/ic_alert_cancel.png differ diff --git a/Dropimage/ic_alert_check.png b/Dropimage/ic_alert_check.png new file mode 100644 index 0000000..f49cdf1 Binary files /dev/null and b/Dropimage/ic_alert_check.png differ diff --git a/Dropimage/ic_alert_coupon.png b/Dropimage/ic_alert_coupon.png new file mode 100644 index 0000000..dc6a55b Binary files /dev/null and b/Dropimage/ic_alert_coupon.png differ diff --git a/Dropimage/ic_alert_delete.png b/Dropimage/ic_alert_delete.png new file mode 100644 index 0000000..7e480a0 Binary files /dev/null and b/Dropimage/ic_alert_delete.png differ diff --git a/Dropimage/ic_alert_discountcancel.png b/Dropimage/ic_alert_discountcancel.png new file mode 100644 index 0000000..95384c5 Binary files /dev/null and b/Dropimage/ic_alert_discountcancel.png differ diff --git a/Dropimage/ic_alert_error.png b/Dropimage/ic_alert_error.png new file mode 100644 index 0000000..13d983e Binary files /dev/null and b/Dropimage/ic_alert_error.png differ diff --git a/Dropimage/ic_alert_fail.png b/Dropimage/ic_alert_fail.png new file mode 100644 index 0000000..299e672 Binary files /dev/null and b/Dropimage/ic_alert_fail.png differ diff --git a/Dropimage/ic_alert_giftcancel.png b/Dropimage/ic_alert_giftcancel.png new file mode 100644 index 0000000..750e7c4 Binary files /dev/null and b/Dropimage/ic_alert_giftcancel.png differ diff --git a/Dropimage/ic_alert_help.png b/Dropimage/ic_alert_help.png new file mode 100644 index 0000000..d472d3d Binary files /dev/null and b/Dropimage/ic_alert_help.png differ diff --git a/Dropimage/ic_alert_ing.gif b/Dropimage/ic_alert_ing.gif new file mode 100644 index 0000000..9f14a6e Binary files /dev/null and b/Dropimage/ic_alert_ing.gif differ diff --git a/Dropimage/ic_alert_ing2.gif b/Dropimage/ic_alert_ing2.gif new file mode 100644 index 0000000..89a1cb2 Binary files /dev/null and b/Dropimage/ic_alert_ing2.gif differ diff --git a/Dropimage/ic_alert_listcancel.png b/Dropimage/ic_alert_listcancel.png new file mode 100644 index 0000000..d5d35c0 Binary files /dev/null and b/Dropimage/ic_alert_listcancel.png differ diff --git a/Dropimage/ic_alert_ordercancel.png b/Dropimage/ic_alert_ordercancel.png new file mode 100644 index 0000000..db7f825 Binary files /dev/null and b/Dropimage/ic_alert_ordercancel.png differ diff --git a/Dropimage/ic_alert_payment.png b/Dropimage/ic_alert_payment.png new file mode 100644 index 0000000..7d86ca4 Binary files /dev/null and b/Dropimage/ic_alert_payment.png differ diff --git a/Dropimage/ic_info.png b/Dropimage/ic_info.png new file mode 100644 index 0000000..1e42ec3 Binary files /dev/null and b/Dropimage/ic_info.png differ diff --git a/Dropimage/ic_info_x.png b/Dropimage/ic_info_x.png new file mode 100644 index 0000000..36338ae Binary files /dev/null and b/Dropimage/ic_info_x.png differ diff --git a/Dropimage/ic_option.png b/Dropimage/ic_option.png new file mode 100644 index 0000000..289b276 Binary files /dev/null and b/Dropimage/ic_option.png differ diff --git a/Dropimage/ic_option_candle.png b/Dropimage/ic_option_candle.png new file mode 100644 index 0000000..4f19ab7 Binary files /dev/null and b/Dropimage/ic_option_candle.png differ diff --git a/Dropimage/ic_option_flavor.png b/Dropimage/ic_option_flavor.png new file mode 100644 index 0000000..a534989 Binary files /dev/null and b/Dropimage/ic_option_flavor.png differ diff --git a/Dropimage/ic_option_shot.png b/Dropimage/ic_option_shot.png new file mode 100644 index 0000000..693cf37 Binary files /dev/null and b/Dropimage/ic_option_shot.png differ diff --git a/Dropimage/ic_option_takein.png b/Dropimage/ic_option_takein.png new file mode 100644 index 0000000..5d10cd9 Binary files /dev/null and b/Dropimage/ic_option_takein.png differ diff --git a/Dropimage/ic_point.png b/Dropimage/ic_point.png new file mode 100644 index 0000000..90c353d Binary files /dev/null and b/Dropimage/ic_point.png differ diff --git a/Dropimage/ic_store.png b/Dropimage/ic_store.png new file mode 100644 index 0000000..66e540d Binary files /dev/null and b/Dropimage/ic_store.png differ diff --git a/Dropimage/ic_talk.png b/Dropimage/ic_talk.png new file mode 100644 index 0000000..05fe0db Binary files /dev/null and b/Dropimage/ic_talk.png differ diff --git a/Dropimage/ic_won.png b/Dropimage/ic_won.png new file mode 100644 index 0000000..f2e7afb Binary files /dev/null and b/Dropimage/ic_won.png differ diff --git a/Dropimage/img_cashreceipt.png b/Dropimage/img_cashreceipt.png new file mode 100644 index 0000000..84283be Binary files /dev/null and b/Dropimage/img_cashreceipt.png differ diff --git a/Dropimage/img_check_bg.png b/Dropimage/img_check_bg.png new file mode 100644 index 0000000..d356f3d Binary files /dev/null and b/Dropimage/img_check_bg.png differ diff --git a/Dropimage/img_contents.png b/Dropimage/img_contents.png new file mode 100644 index 0000000..ce0f7dc Binary files /dev/null and b/Dropimage/img_contents.png differ diff --git a/Dropimage/img_contents_default.png b/Dropimage/img_contents_default.png new file mode 100644 index 0000000..81faaf4 Binary files /dev/null and b/Dropimage/img_contents_default.png differ diff --git a/Dropimage/img_contents_soldout.png b/Dropimage/img_contents_soldout.png new file mode 100644 index 0000000..f41bfb8 Binary files /dev/null and b/Dropimage/img_contents_soldout.png differ diff --git a/Dropimage/img_event.png b/Dropimage/img_event.png new file mode 100644 index 0000000..4d64ea9 Binary files /dev/null and b/Dropimage/img_event.png differ diff --git a/Dropimage/img_gif_1.png b/Dropimage/img_gif_1.png new file mode 100644 index 0000000..21dee0e Binary files /dev/null and b/Dropimage/img_gif_1.png differ diff --git a/Dropimage/img_gif_barcode.gif b/Dropimage/img_gif_barcode.gif new file mode 100644 index 0000000..70987e9 Binary files /dev/null and b/Dropimage/img_gif_barcode.gif differ diff --git a/Dropimage/img_gif_barcode.mp4 b/Dropimage/img_gif_barcode.mp4 new file mode 100644 index 0000000..a3faa7d Binary files /dev/null and b/Dropimage/img_gif_barcode.mp4 differ diff --git a/Dropimage/img_gif_barcode_happy.avi b/Dropimage/img_gif_barcode_happy.avi new file mode 100644 index 0000000..3656378 Binary files /dev/null and b/Dropimage/img_gif_barcode_happy.avi differ diff --git a/Dropimage/img_gif_barcode_happy.gif b/Dropimage/img_gif_barcode_happy.gif new file mode 100644 index 0000000..c7e7400 Binary files /dev/null and b/Dropimage/img_gif_barcode_happy.gif differ diff --git a/Dropimage/img_gif_barcodescan.gif b/Dropimage/img_gif_barcodescan.gif new file mode 100644 index 0000000..97b24fa Binary files /dev/null and b/Dropimage/img_gif_barcodescan.gif differ diff --git a/Dropimage/img_gif_barcodescan.mp4 b/Dropimage/img_gif_barcodescan.mp4 new file mode 100644 index 0000000..cafdf6a Binary files /dev/null and b/Dropimage/img_gif_barcodescan.mp4 differ diff --git a/Dropimage/img_gif_camerascan.gif b/Dropimage/img_gif_camerascan.gif new file mode 100644 index 0000000..98244fa Binary files /dev/null and b/Dropimage/img_gif_camerascan.gif differ diff --git a/Dropimage/img_gif_card.gif b/Dropimage/img_gif_card.gif new file mode 100644 index 0000000..f73793a Binary files /dev/null and b/Dropimage/img_gif_card.gif differ diff --git a/Dropimage/img_gif_nfc.gif b/Dropimage/img_gif_nfc.gif new file mode 100644 index 0000000..b4eea87 Binary files /dev/null and b/Dropimage/img_gif_nfc.gif differ diff --git a/Dropimage/img_gif_pay.gif b/Dropimage/img_gif_pay.gif new file mode 100644 index 0000000..950a9d8 Binary files /dev/null and b/Dropimage/img_gif_pay.gif differ diff --git a/Dropimage/img_like.png b/Dropimage/img_like.png new file mode 100644 index 0000000..2dab2a2 Binary files /dev/null and b/Dropimage/img_like.png differ diff --git a/Dropimage/img_point.png b/Dropimage/img_point.png new file mode 100644 index 0000000..22921d5 Binary files /dev/null and b/Dropimage/img_point.png differ diff --git a/Dropimage/img_receipt.png b/Dropimage/img_receipt.png new file mode 100644 index 0000000..d1dddbc Binary files /dev/null and b/Dropimage/img_receipt.png differ diff --git a/Dropimage/img_talk.png b/Dropimage/img_talk.png new file mode 100644 index 0000000..400506f Binary files /dev/null and b/Dropimage/img_talk.png differ diff --git a/Dropimage/nextstation_button.jpg b/Dropimage/nextstation_button.jpg new file mode 100644 index 0000000..417aa81 Binary files /dev/null and b/Dropimage/nextstation_button.jpg differ diff --git a/Dropimage/nextstation_img.jpg b/Dropimage/nextstation_img.jpg new file mode 100644 index 0000000..145b129 Binary files /dev/null and b/Dropimage/nextstation_img.jpg differ diff --git a/Dropimage/step01.png b/Dropimage/step01.png new file mode 100644 index 0000000..a1def57 Binary files /dev/null and b/Dropimage/step01.png differ diff --git a/Dropimage/step02.png b/Dropimage/step02.png new file mode 100644 index 0000000..7ea6dd4 Binary files /dev/null and b/Dropimage/step02.png differ diff --git a/Dropimage/step03.png b/Dropimage/step03.png new file mode 100644 index 0000000..733777e Binary files /dev/null and b/Dropimage/step03.png differ diff --git a/Dropimage/step_bg.png b/Dropimage/step_bg.png new file mode 100644 index 0000000..67f0706 Binary files /dev/null and b/Dropimage/step_bg.png differ diff --git a/Dropimage/store_bg.png b/Dropimage/store_bg.png new file mode 100644 index 0000000..0c428a4 Binary files /dev/null and b/Dropimage/store_bg.png differ diff --git a/ImageCopy.bat b/ImageCopy.bat new file mode 100644 index 0000000..8a1b420 --- /dev/null +++ b/ImageCopy.bat @@ -0,0 +1,2 @@ +@echo off +Xcopy Dropimage ..\Image\Kiosk\PB /Y /I diff --git a/Kiosk/Common/SPC.Kiosk.Base/Properties/AssemblyInfo.cs b/Kiosk/Common/SPC.Kiosk.Base/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..55cdf2a --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Base/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("SPC.Kiosk.Base")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("SPC.Kiosk.Base")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("bcc10fa2-c358-480c-8ff0-615750f3c306")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 +// 기본값으로 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Kiosk/Common/SPC.Kiosk.Base/RelayCommand.cs b/Kiosk/Common/SPC.Kiosk.Base/RelayCommand.cs new file mode 100644 index 0000000..82638bc --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Base/RelayCommand.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Input; + +namespace SPC.Kiosk.Base +{ + /// + /// Commad Interfase Implementation + /// + public class Command : ICommand + { + private readonly Action _handler; + private bool _isEnabled; + + /// + /// Set Commad Handler + /// + /// + public Command(Action handler) + { + _handler = handler; + IsEnabled = true; + } + /// + /// CanExecut Is Enabled + /// + public bool IsEnabled + { + get { return _isEnabled; } + set + { + if (value != _isEnabled) + { + _isEnabled = value; + CanExecuteChanged?.Invoke(this, EventArgs.Empty); + } + } + } + /// + /// CanExecute Status Return + /// + /// + /// + public bool CanExecute(object parameter) + { + return IsEnabled; + } + /// + /// CanExecuteChanged EventHandler + /// + public event EventHandler CanExecuteChanged; + /// + /// Execute with parameter + /// + /// + public void Execute(object parameter) + { + IsEnabled = false; + _handler(parameter); + IsEnabled = true; + } + /// + /// Execute with out parameter + /// + public void Execute() + { + IsEnabled = false; + _handler(null); + IsEnabled = true; + } + } +} diff --git a/Kiosk/Common/SPC.Kiosk.Base/SPC.Kiosk.Base.csproj b/Kiosk/Common/SPC.Kiosk.Base/SPC.Kiosk.Base.csproj new file mode 100644 index 0000000..9276a72 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Base/SPC.Kiosk.Base.csproj @@ -0,0 +1,53 @@ + + + + + Debug + AnyCPU + {BCC10FA2-C358-480C-8FF0-615750F3C306} + Library + Properties + SPC.Kiosk.Base + SPC.Kiosk.Base + v4.0 + 512 + true + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Kiosk/Common/SPC.Kiosk.Base/ViewModelBase.cs b/Kiosk/Common/SPC.Kiosk.Base/ViewModelBase.cs new file mode 100644 index 0000000..202080b --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Base/ViewModelBase.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; + +namespace SPC.Kiosk.Base +{ + /// + /// Basic View Model + /// + public abstract class ViewModelBase : INotifyPropertyChanged + { + /// + /// View Model a Member PropertyChanged EventHandler + /// + public event PropertyChangedEventHandler PropertyChanged; + + + protected virtual void PropertyChange(string propName) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName)); + } + + } +} diff --git a/Kiosk/Common/SPC.Kiosk.Common.Model/CommonModel.cs b/Kiosk/Common/SPC.Kiosk.Common.Model/CommonModel.cs new file mode 100644 index 0000000..f216ec9 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common.Model/CommonModel.cs @@ -0,0 +1,147 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Media; +using SPC.Kiosk.Base; + +namespace SPC.Kiosk.Common.Model +{ + public class M_PopupReturn + { + public bool OKAnswer { get; set; } + public bool TimeOut { get; set; } + public SupportLanguageType ReturnLanguage { get; set; } + public object PopupArgs { get; set; } + } + /// + /// Button Send Events Args + /// + public class ItemDropEventArgs + { + /// + /// Send Object + /// + public object SourceObject { get; set; } = null; + /// + /// Target Object + /// + public object TargetObject { get; set; } = null; + } + public class M_IntroItems + { + public int ItemsStack { get; set; } = 1; + public double StackWidth { get; set; } = double.NaN; + public List StackContents { get; set; } = null; + } + public class M_StackContents + { + public int ItemsIndex { get; set; } = 0; + public List MediaRollItems { get; set; } = null; + } + /// + /// Media Rolling Item Model + /// + public class M_MediaRollItem + { + /// + /// Media Type Image or VOD + /// + public MediaType Type { get; set; } = MediaType.None; + /// + /// Media File Path + /// + public string MediaPath { get; set; } = string.Empty; + /// + /// Media Show Running Time Seconds + /// + public double RunnigSeconds { get; set; } = 0; + public bool RepeatMedia { get; set; } + public TimeSpan StartTime { get; set; } = default(TimeSpan); + public TimeSpan EndTime { get; set; } = default(TimeSpan); + public IntroLinkType LinkType { get; set; } = IntroLinkType.None; + public string LinkParameter { get; set; } = string.Empty; + } + /// + /// Button List Item Collection + /// + public class M_ItemData + { + public int Index { get; set; } = -1; + public string ItemCode { get; set; } = string.Empty; + public string Category1 { get; set; } = string.Empty; + public string Category2 { get; set; } = string.Empty; + public M_AnimationButton DataParameter { get; set; } + public M_TextBlock BaseTextBlock { get; set; } + public M_TextBlock AdditionTextBlock { get; set; } + } + public class M_AnimationButton + { + public double Width { get; set; } = double.NaN; + public double Height { get; set; } = double.NaN; + public Thickness Margin { get; set; } + public string NormalBrush { get; set; } = string.Empty; + public string DownBrush { get; set; } = string.Empty; + public string DisableBrush { get; set; } = string.Empty; + public string SwitchOnBrush { get; set; } = string.Empty; + public string DragCursorImage { get; set; } = string.Empty; + public HotSpotType DragCursorHotSpot { get; set; } = HotSpotType.LeftTop; + public Stretch BrushStretch { get; set; } = Stretch.Fill; + public bool Enabled { get; set; } = true; + public bool Switch { get; set; } + public bool AutoToggle { get; set; } + public bool ClickSend { get; set; } + public string BaseGrid { get; set; } = string.Empty; + public string ReciveElement { get; set; } = string.Empty; + public ButtonAnimationType ClickAnimationType { get; set; } = ButtonAnimationType.None; + public ButtonAnimationType DropAnimationType { get; set; } = ButtonAnimationType.None; + public List LanguageText { get; set; } = null; + public string Text { get; set; } = string.Empty; + public Visibility TextVisible { get; set; } = Visibility.Collapsed; + public string TextForeground { get; set; } = string.Empty; + public string SwitchOnForeground { get; set; } = string.Empty; + public string DisableForeground { get; set; } = string.Empty; + public VerticalAlignment TextVerticalAlignment { get; set; } = VerticalAlignment.Center; + public HorizontalAlignment TextHorizontalAlignment { get; set; } = HorizontalAlignment.Center; + public string TextFontFamily { get; set; } = string.Empty; + public double TextFontSize { get; set; } = 12; + public FontWeight TextFontWeight { get; set; } = FontWeights.Normal; + public TextWrapping TextWrapping { get; set; } = TextWrapping.Wrap; + public TextAlignment TextAlignment { get; set; } = TextAlignment.Center; + public Thickness TextMargin { get; set; } + public bool DragEnable { get; set; } + public double CircleSize { get; set; } = 30d; + public string CircleBackBrush { get; set; } = string.Empty; + public string CircleTextBruch { get; set; } = string.Empty; + public string CircleText { get; set; } = string.Empty; + public bool CircleOuter { get; set; } + public SupportLanguageType DisplayLanguage { get; set; } + public List BadgeImages { get; set; } = null; + }; + /// + /// Button List Item Text Box Collection + /// + public class M_TextBlock + { + public List LanguageData { get; set; } = null; + + public double TextSize { get; set; } = 12; + + public string TextBrush { get; set; } = "Transparent"; + + public FontWeight TextWeight { get; set; } = FontWeights.Normal; + + } + public class M_MultiLanguage + { + public string MessageCode { get; set; } + public List MessageData {get; set;} + } + public class M_Language + { + public SupportLanguageType Type { get; set; } + public string LanguageData { get; set; } + + } +} diff --git a/Kiosk/Common/SPC.Kiosk.Common.Model/Properties/AssemblyInfo.cs b/Kiosk/Common/SPC.Kiosk.Common.Model/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..986aa52 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common.Model/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("SPC.Kiosk.Common.Model")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("SPC.Kiosk.Common.Model")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +//지역화 가능 응용 프로그램 빌드를 시작하려면 다음을 설정하세요. +//.csproj 파일에서 내에 CultureYouAreCodingWith를 +//설정하십시오. 예를 들어 소스 파일에서 영어(미국)를 +//사용하는 경우 를 en-US로 설정합니다. 그런 다음 아래 +//NeutralResourceLanguage 특성의 주석 처리를 제거합니다. 아래 줄의 "en-US"를 업데이트하여 +//프로젝트 파일의 UICulture 설정과 일치시킵니다. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //테마별 리소스 사전의 위치 + //(페이지 또는 응용 프로그램 리소스 사진에 + // 리소스가 없는 경우에 사용됨) + ResourceDictionaryLocation.SourceAssembly //제네릭 리소스 사전의 위치 + //(페이지 또는 응용 프로그램 리소스 사진에 + // 리소스가 없는 경우에 사용됨) +)] + + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호가 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Kiosk/Common/SPC.Kiosk.Common.Model/SPC.Kiosk.Common.Model.csproj b/Kiosk/Common/SPC.Kiosk.Common.Model/SPC.Kiosk.Common.Model.csproj new file mode 100644 index 0000000..026d6d8 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common.Model/SPC.Kiosk.Common.Model.csproj @@ -0,0 +1,70 @@ + + + + + Debug + AnyCPU + {7621F355-20D1-4DA0-A677-9DCBC1734BAB} + Library + SPC.Kiosk.Common.Model + SPC.Kiosk.Common.Model + v4.0 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + x86 + true + full + false + ..\..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + 4.0 + + + + + + + + + + + + Code + + + + + {bcc10fa2-c358-480c-8ff0-615750f3c306} + SPC.Kiosk.Base + + + + \ No newline at end of file diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/AnimationButton.xaml b/Kiosk/Common/SPC.Kiosk.Common/Controls/AnimationButton.xaml new file mode 100644 index 0000000..037291d --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/AnimationButton.xaml @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/AnimationButton.xaml.cs b/Kiosk/Common/SPC.Kiosk.Common/Controls/AnimationButton.xaml.cs new file mode 100644 index 0000000..c1b7e47 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/AnimationButton.xaml.cs @@ -0,0 +1,1565 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Runtime.InteropServices; +using System.Text; +using System.Threading; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Interop; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +namespace SPC.Kiosk.Common +{ + /// + /// AnimationButton.xaml에 대한 상호 작용 논리 + /// + public partial class AnimationButton : UserControl + { + #region [ Private Members ] + private bool MoseDown = false; + private Point MoseDownPosition; + private bool CircleMoseDown = false; + private Point CircleMoseDownPosition; + private Cursor DragCursor = null; + private Storyboard BreathigStoryboard = null; + #endregion Private Members + + #region [ Public Members ] + + #region [ DependencyProperty ] + /// + /// Noraml Bakcground + /// + public static readonly DependencyProperty NormalBrushProperty = + DependencyProperty.Register(nameof(NormalBrush), typeof(string), typeof(AnimationButton), new PropertyMetadata("Transparent", new PropertyChangedCallback(OnNormalBrushPropertyChanged))); + /// + /// Image Brush Stretch Type + /// + public static readonly DependencyProperty BrushStretchProperty = + DependencyProperty.Register(nameof(BrushStretch), typeof(Stretch), typeof(AnimationButton), new PropertyMetadata(Stretch.None, new PropertyChangedCallback(OnBrushStretchPropertyChanged))); + /// + /// Touch Down Bakcground + /// + public static readonly DependencyProperty DownBrushProperty = + DependencyProperty.Register(nameof(DownBrush), typeof(string), typeof(AnimationButton), new PropertyMetadata("Transparent")); + /// + /// Button Disable Background + /// + public static readonly DependencyProperty DisableBrushProperty = + DependencyProperty.Register(nameof(DisableBrush), typeof(string), typeof(AnimationButton), new PropertyMetadata("Transparent")); + /// + /// Drag Cursor Image Path + /// + public static readonly DependencyProperty DragCursorImageProperty = + DependencyProperty.Register(nameof(DragCursorImage), typeof(string), typeof(AnimationButton), new PropertyMetadata(string.Empty)); + /// + /// Drag Cursor HotSpot Type + /// + public static readonly DependencyProperty DragCursorHotSpotProperty = + DependencyProperty.Register(nameof(DragCursorHotSpot), typeof(HotSpotType), typeof(AnimationButton), new PropertyMetadata(HotSpotType.LeftTop)); + /// + /// Switch On Status Background + /// + public static readonly DependencyProperty SwitchOnBrushProperty = + DependencyProperty.Register(nameof(SwitchOnBrush), typeof(string), typeof(AnimationButton), new PropertyMetadata("Transparent")); + /// + /// Switch Status + /// + public static readonly DependencyProperty SwitchProperty = + DependencyProperty.Register(nameof(Switch), typeof(bool), typeof(AnimationButton), new PropertyMetadata(false, new PropertyChangedCallback(OnSwitchPropertyChanged))); + /// + /// Auto Switching Flag + /// + public static readonly DependencyProperty IsBreathingProperty = + DependencyProperty.Register(nameof(IsBreathing), typeof(bool), typeof(AnimationButton), new PropertyMetadata(false, new PropertyChangedCallback(IsBreathingPropertyChanged))); + /// + /// Auto Switching Flag + /// + public static readonly DependencyProperty AutoToggleProperty = + DependencyProperty.Register(nameof(AutoToggle), typeof(bool), typeof(AnimationButton), new PropertyMetadata(false)); + /// + /// Click Send Flag + /// + public static readonly DependencyProperty ClickSendProperty = + DependencyProperty.Register(nameof(ClickSend), typeof(bool), typeof(AnimationButton), new PropertyMetadata(false)); + /// + /// Button Enabled + /// + public static readonly DependencyProperty EnabledProperty = + DependencyProperty.Register(nameof(Enabled), typeof(bool), typeof(AnimationButton), new PropertyMetadata(true, new PropertyChangedCallback(OnEnabledPropertyChanged))); + /// + /// Base Grid Name + /// + public static readonly DependencyProperty BaseGridProperty = + DependencyProperty.Register(nameof(BaseGrid), typeof(string), typeof(AnimationButton), new PropertyMetadata(string.Empty)); + /// + /// Recive Element Name (AnimationButton) + /// + public static readonly DependencyProperty ReciveElementProperty = + DependencyProperty.Register(nameof(ReciveElement), typeof(string), typeof(AnimationButton), new PropertyMetadata(string.Empty)); + /// + /// Click Animation Type + /// + public static readonly DependencyProperty ClickAnimationTypeProperty = + DependencyProperty.Register(nameof(ClickAnimationType), typeof(ButtonAnimationType), typeof(AnimationButton), new PropertyMetadata(ButtonAnimationType.None)); + /// + /// Drop Animation Type + /// + public static readonly DependencyProperty DropAnimationTypeProperty = + DependencyProperty.Register(nameof(DropAnimationType), typeof(ButtonAnimationType), typeof(AnimationButton), new PropertyMetadata(ButtonAnimationType.None)); + /// + /// Button MultiLanguage Text + /// + public static readonly DependencyProperty LanguageTextProperty = + DependencyProperty.Register(nameof(LanguageText), typeof(List), typeof(AnimationButton), new PropertyMetadata(default(List))); + /// + /// Button Text + /// + public static readonly DependencyProperty TextProperty = + DependencyProperty.Register(nameof(Text), typeof(string), typeof(AnimationButton), new PropertyMetadata(default(List))); + /// + /// Button Text Visibility + /// + public static readonly DependencyProperty TextVisibleProperty = + DependencyProperty.Register(nameof(TextVisible), typeof(Visibility), typeof(AnimationButton), new PropertyMetadata(Visibility.Collapsed, new PropertyChangedCallback(OnTextVisiblePropertyChanged))); + /// + /// Button Text Foreground + /// + public static readonly DependencyProperty TextForegroundProperty = + DependencyProperty.Register(nameof(TextForeground), typeof(string), typeof(AnimationButton), new PropertyMetadata("Transparent", new PropertyChangedCallback(OnTextForegroundPropertyChanged))); + /// + /// Button Switch On Foreground + /// + public static readonly DependencyProperty SwitchOnForegroundProperty = + DependencyProperty.Register(nameof(SwitchOnForeground), typeof(string), typeof(AnimationButton), new PropertyMetadata("Transparent", new PropertyChangedCallback(OnSwitchOnForegroundPropertyChanged))); + /// + /// Button Disable Foreground + /// + public static readonly DependencyProperty DisableForegroundProperty = + DependencyProperty.Register(nameof(DisableForeground), typeof(string), typeof(AnimationButton), new PropertyMetadata("Transparent", new PropertyChangedCallback(OnDisableForegroundPropertyChanged))); + /// + /// Button Text VerticalAlignment + /// + public static readonly DependencyProperty TextVerticalAlignmentProperty = + DependencyProperty.Register(nameof(TextVerticalAlignment), typeof(VerticalAlignment), typeof(AnimationButton), new PropertyMetadata(VerticalAlignment.Center, new PropertyChangedCallback(OnTextVerticalAlignmentPropertyChanged))); + /// + /// Button Text HorizontalAlignment + /// + public static readonly DependencyProperty TextHorizontalAlignmentProperty = + DependencyProperty.Register(nameof(TextHorizontalAlignment), typeof(HorizontalAlignment), typeof(AnimationButton), new PropertyMetadata(HorizontalAlignment.Center, new PropertyChangedCallback(OnTextHorizontalAlignmentPropertyChanged))); + /// + /// Button Text FontFamily + /// + public static readonly DependencyProperty TextFontFamilyProperty = + DependencyProperty.Register(nameof(TextFontFamily), typeof(string), typeof(AnimationButton), new PropertyMetadata(Fonts.SystemFontFamilies.First().Source, new PropertyChangedCallback(OnTextFontFamilyPropertyChanged))); + /// + /// Button Text FontSize + /// + public static readonly DependencyProperty TextFontSizeProperty = + DependencyProperty.Register(nameof(TextFontSize), typeof(double), typeof(AnimationButton), new PropertyMetadata((double)10, new PropertyChangedCallback(OnTextFontSizePropertyChanged))); + /// + /// SwitchOn FontSize + /// + public static readonly DependencyProperty SwitchOnFontSizeProperty = + DependencyProperty.Register(nameof(SwitchOnFontSize), typeof(double), typeof(AnimationButton), new PropertyMetadata((double)0, new PropertyChangedCallback(OnSwitchOnFontSizePropertyChanged))); + /// + /// Disable FontSize + /// + public static readonly DependencyProperty DisableFontSizeProperty = + DependencyProperty.Register(nameof(DisableFontSize), typeof(double), typeof(AnimationButton), new PropertyMetadata((double)0, new PropertyChangedCallback(OnDisableFontSizePropertyChanged))); + + + + /// + /// Button Text Weight + /// + public static readonly DependencyProperty TextFontWeightProperty = + DependencyProperty.Register(nameof(TextFontWeight), typeof(FontWeight), typeof(AnimationButton), new PropertyMetadata(FontWeights.Normal, new PropertyChangedCallback(OnTextFontWeightPropertyChanged))); + /// + /// SwitchOn FontWeight + /// + public static readonly DependencyProperty SwitchOnFontWeightProperty = + DependencyProperty.Register(nameof(SwitchOnFontWeight), typeof(FontWeight), typeof(AnimationButton), new PropertyMetadata(FontWeights.Normal, new PropertyChangedCallback(OnSwitchOnFontWeightPropertyChanged))); + /// + /// Disable FontWeight + /// + public static readonly DependencyProperty DisableWeightProperty = + DependencyProperty.Register(nameof(DisableWeight), typeof(FontWeight), typeof(AnimationButton), new PropertyMetadata(FontWeights.Normal, new PropertyChangedCallback(OnDisableWeightPropertyChanged))); + + + /// + /// Button Text Wrapping + /// + public static readonly DependencyProperty TextWrappingProperty = + DependencyProperty.Register(nameof(TextWrapping), typeof(TextWrapping), typeof(AnimationButton), new PropertyMetadata(TextWrapping.NoWrap, new PropertyChangedCallback(OnTextWrappingPropertyChanged))); + /// + /// Button Text Alignment + /// + public static readonly DependencyProperty TextAlignmentProperty = + DependencyProperty.Register(nameof(TextAlignment), typeof(TextAlignment), typeof(AnimationButton), new PropertyMetadata(TextAlignment.Center, new PropertyChangedCallback(OnTextAlignmentPropertyChanged))); + /// + /// Button Text Margin + /// + public static readonly DependencyProperty TextMarginProperty = + DependencyProperty.Register(nameof(TextMargin), typeof(Thickness), typeof(AnimationButton), new PropertyMetadata(new Thickness(0, 0, 0, 0), new PropertyChangedCallback(OnTextMarginPropertyChanged))); + /// + /// Command + /// + public static readonly DependencyProperty CommandProperty = + DependencyProperty.Register(nameof(Command), typeof(ICommand), typeof(AnimationButton), new UIPropertyMetadata(null)); + + /// + /// Circle Clicked Command + /// + public static readonly DependencyProperty CircleCommandProperty = + DependencyProperty.Register(nameof(CircleCommand), typeof(ICommand), typeof(AnimationButton), new UIPropertyMetadata(null)); + /// + /// Drop Command + /// + public static readonly DependencyProperty DropCommandProperty = + DependencyProperty.Register(nameof(DropCommand), typeof(ICommand), typeof(AnimationButton), new UIPropertyMetadata(null)); + /// + /// Drag Enable + /// + public static readonly DependencyProperty DragEnableProperty = + DependencyProperty.Register(nameof(DragEnable), typeof(bool), typeof(AnimationButton), new PropertyMetadata(false)); + /// + /// DataParameter + /// + public static readonly DependencyProperty DataParameterProperty = + DependencyProperty.Register(nameof(DataParameter), typeof(object), typeof(AnimationButton), new PropertyMetadata(null, new PropertyChangedCallback(OnDataParameterPropertyChanged))); + /// + /// Circle Size + /// + public static readonly DependencyProperty CircleSizeProperty = + DependencyProperty.Register(nameof(CircleSize), typeof(double), typeof(AnimationButton), new PropertyMetadata((double)12, new PropertyChangedCallback(OnCircleSizePropertyChanged))); + /// + /// Circle Back Brush + /// + public static readonly DependencyProperty CircleBackBrushProperty = + DependencyProperty.Register(nameof(CircleBackBrush), typeof(string), typeof(AnimationButton), new PropertyMetadata("Transparent", new PropertyChangedCallback(OnCircleBackBrushPropertyChanged))); + /// + /// Circle Over Text Bruch Forground Brush + /// + public static readonly DependencyProperty CircleTextBruchProperty = + DependencyProperty.Register(nameof(CircleTextBruch), typeof(string), typeof(AnimationButton), new PropertyMetadata("Transparent", new PropertyChangedCallback(OnCircleTextBruchPropertyChanged))); + /// + /// Circle Over Text + /// + public static readonly DependencyProperty CircleTextProperty = + DependencyProperty.Register(nameof(CircleText), typeof(string), typeof(AnimationButton), new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnCircleTextPropertyChanged))); + /// + /// Circle Outer Option Flag + /// + public static readonly DependencyProperty CircleOuterProperty = + DependencyProperty.Register(nameof(CircleOuter), typeof(bool), typeof(AnimationButton), new PropertyMetadata(false, new PropertyChangedCallback(OnCircleOuterPropertyChanged))); + /// + /// Display Language Type + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(AnimationButton), new PropertyMetadata(SupportLanguageType.ko)); + + #endregion DependencyProperty + #region [ SendItem Properties ] + /// + /// Send Button + /// + public AnimationButton SendSource { get; set; } = null; + /// + /// Revice Button + /// + public UIElement ReciveTarget { get; set; } = null; + /// + /// Targer Grid + /// + public Grid TargetGrid { get; set; } = null; + #endregion SendItem Properties + + #region [ Propertis For DependencyProperty ] + + #region Base Propertis + + /// + /// Noraml Bakcground + /// + public string NormalBrush + { + get { return (string)GetValue(NormalBrushProperty); } + set { SetValue(NormalBrushProperty, value); } + } + /// + /// Image Brush Stretch Type + /// + public Stretch BrushStretch + { + get { return (Stretch)GetValue(BrushStretchProperty); } + set { SetValue(BrushStretchProperty, value); } + + } + /// + /// Mouse/Touch Down Bakcground + /// + public string DownBrush + { + get { return (string)GetValue(DownBrushProperty); } + set { SetValue(DownBrushProperty, value); } + } + /// + /// Button Disable Background + /// + public string DisableBrush + { + get { return (string)GetValue(DisableBrushProperty); } + set { SetValue(DisableBrushProperty, value); } + } + /// + /// Switch On Status Background + /// + public string SwitchOnBrush + { + get { return (string)GetValue(SwitchOnBrushProperty); } + set { SetValue(SwitchOnBrushProperty, value); } + } + /// + /// Switch Status + /// + public bool Switch + { + get { return (bool)GetValue(SwitchProperty); } + set { SetValue(SwitchProperty, value); } + } + /// + /// Breathing Status + /// + public bool IsBreathing + { + get { return (bool)GetValue(IsBreathingProperty); } + set { SetValue(IsBreathingProperty, value); } + } + /// + /// Auto Switching Flag + /// + public bool AutoToggle + { + get { return (bool)GetValue(AutoToggleProperty); } + set { SetValue(AutoToggleProperty, value); } + } + /// + /// ClickSend + /// + public bool ClickSend + { + get { return (bool)GetValue(ClickSendProperty); } + set { SetValue(ClickSendProperty, value); } + } + /// + /// ReciveElement + /// + public string ReciveElement + { + get { return (string)GetValue(ReciveElementProperty); } + set { SetValue(ReciveElementProperty, value); } + } + /// + /// BaseGrid + /// + public string BaseGrid + { + get { return (string)GetValue(BaseGridProperty); } + set { SetValue(BaseGridProperty, value); } + } + /// + /// Command + /// + public ICommand Command + { + get { return (ICommand)GetValue(CommandProperty); } + set { SetValue(CommandProperty, value); } + } + /// + /// Circle Clicked Command + /// + public ICommand CircleCommand + { + get { return (ICommand)GetValue(CircleCommandProperty); } + set { SetValue(CircleCommandProperty, value); } + } + /// + /// Drop Command + /// + public ICommand DropCommand + { + get { return (ICommand)GetValue(DropCommandProperty); } + set { SetValue(DropCommandProperty, value); } + } + /// + /// Data Parameter + /// + public object DataParameter + { + get { return (object)GetValue(DataParameterProperty); } + set { SetValue(DataParameterProperty, value); } + } + /// + /// Click Animation Type + /// + public ButtonAnimationType ClickAnimationType + { + get { return (ButtonAnimationType)GetValue(ClickAnimationTypeProperty); } + set { SetValue(ClickAnimationTypeProperty, value); } + } + /// + /// Drop Animation Type + /// + public ButtonAnimationType DropAnimationType + { + get { return (ButtonAnimationType)GetValue(DropAnimationTypeProperty); } + set { SetValue(DropAnimationTypeProperty, value); } + } + /// + /// Drag Enable + /// + public bool DragEnable + { + get { return (bool)GetValue(DragEnableProperty); } + set { SetValue(DragEnableProperty, value); } + } + /// + /// Enabled + /// + public bool Enabled + { + get { return (bool)GetValue(EnabledProperty); } + set { SetValue(EnabledProperty, value); } + } + /// + /// Drag Cursor Image Path + /// + public string DragCursorImage + { + get { return (string)GetValue(DragCursorImageProperty); } + set { SetValue(DragCursorImageProperty, value); } + } + /// + /// Drag Cursor Hot Spot Type + /// + public HotSpotType DragCursorHotSpot + { + get { return (HotSpotType)GetValue(DragCursorHotSpotProperty); } + set { SetValue(DragCursorHotSpotProperty, value); } + } + + + #endregion Base Propertis + + #region ButtonText Properties + /// + /// Display Language Type + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + /// + /// Button Text + /// + public string Text + { + get { return (string)GetValue(TextProperty); } + set { SetValue(TextProperty, value); } + } + /// + /// Button Text Multi Language Text + /// + public List LanguageText + { + get { return (List)GetValue(LanguageTextProperty); } + set { SetValue(LanguageTextProperty, value); } + } + /// + /// Button Text Visibility + /// + public Visibility TextVisible + { + get { return (Visibility)GetValue(TextVisibleProperty); } + set { SetValue(TextVisibleProperty, value); } + } + /// + /// Button Text Foreground + /// + public string TextForeground + { + get { return (string)GetValue(TextForegroundProperty); } + set { SetValue(TextForegroundProperty, value); } + } + /// + /// Button Switch On Foreground + /// + public string SwitchOnForeground + { + get { return (string)GetValue(SwitchOnForegroundProperty); } + set { SetValue(SwitchOnForegroundProperty, value); } + } + /// + /// Button Disable Foreground + /// + public string DisableForeground + { + get { return (string)GetValue(DisableForegroundProperty); } + set { SetValue(DisableForegroundProperty, value); } + } + + /// + /// Button Text VerticalAlignment + /// + public VerticalAlignment TextVerticalAlignment + { + get { return (VerticalAlignment)GetValue(TextVerticalAlignmentProperty); } + set { SetValue(TextVerticalAlignmentProperty, value); } + } + /// + /// Button Text HorizontalAlignment + /// + public HorizontalAlignment TextHorizontalAlignment + { + get { return (HorizontalAlignment)GetValue(TextHorizontalAlignmentProperty); } + set { SetValue(TextHorizontalAlignmentProperty, value); } + } + /// + /// Button Text FontFamily + /// + public string TextFontFamily + { + get { return (string)GetValue(TextFontFamilyProperty); } + set { SetValue(TextFontFamilyProperty, value); } + } + /// + /// Button Text FontSize + /// + public double TextFontSize + { + get { return (double)GetValue(TextFontSizeProperty); } + set { SetValue(TextFontSizeProperty, value); } + } + /// + /// Switch On FontSize + /// + public double SwitchOnFontSize + { + get { return (double)GetValue(SwitchOnFontSizeProperty); } + set { SetValue(SwitchOnFontSizeProperty, value); } + } + /// + /// Disable FontSize + /// + public double DisableFontSize + { + get { return (double)GetValue(DisableFontSizeProperty); } + set { SetValue(DisableFontSizeProperty, value); } + } + /// + /// Button Text FontWeight + /// + public FontWeight TextFontWeight + { + get { return (FontWeight)GetValue(TextFontWeightProperty); } + set { SetValue(TextFontWeightProperty, value); } + } + /// + /// SwitchOn FontWeight + /// + public FontWeight SwitchOnFontWeight + { + get { return (FontWeight)GetValue(SwitchOnFontWeightProperty); } + set { SetValue(SwitchOnFontWeightProperty, value); } + } + /// + /// Disable Font Weight + /// + public FontWeight DisableWeight + { + get { return (FontWeight)GetValue(DisableWeightProperty); } + set { SetValue(DisableWeightProperty, value); } + } + /// + /// Button Text Wrapping + /// + public TextWrapping TextWrapping + { + get { return (TextWrapping)GetValue(TextWrappingProperty); } + set { SetValue(TextWrappingProperty, value); } + } + /// + /// Button Text Alignment + /// + public TextAlignment TextAlignment + { + get { return (TextAlignment)GetValue(TextAlignmentProperty); } + set { SetValue(TextAlignmentProperty, value); } + } + /// + /// Button Text Margin + /// + public Thickness TextMargin + { + get { return (Thickness)GetValue(TextMarginProperty); } + set { SetValue(TextMarginProperty, value); } + } + + #endregion + + #region Circle Options Properties + /// + /// Circle BAck Brush + /// + public string CircleBackBrush + { + get { return (string)GetValue(CircleBackBrushProperty); } + set { SetValue(CircleBackBrushProperty, value); } + + } + /// + /// Circle Over Text + /// + public string CircleText + { + get { return (string)GetValue(CircleTextProperty); } + set { SetValue(CircleTextProperty, value); } + } + /// + /// Circle Over Text Foregraund Brush + /// + public string CircleTextBruch + { + get { return (string)GetValue(CircleTextBruchProperty); } + set { SetValue(CircleTextBruchProperty, value); } + } + /// + /// Circle Size + /// + public double CircleSize + { + get { return (double)GetValue(CircleSizeProperty); } + set { SetValue(CircleSizeProperty, value); } + } + /// + /// Circle Outer Option Flag + /// + public bool CircleOuter + { + get { return (bool)GetValue(CircleOuterProperty); } + set { SetValue(CircleOuterProperty, value); } + + } + #endregion Circle Options Properties + + #endregion Propertis For DependencyProperty + + #region [ RoutedEvent 'MouseClicked' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent MouseClickedEvent = EventManager.RegisterRoutedEvent(nameof(MouseClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(AnimationButton)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler MouseClicked + { + add { AddHandler(MouseClickedEvent, value); } + remove { RemoveHandler(MouseClickedEvent, value); } + } + #endregion RoutedEvent 'MouseClicked' + + #region [ RoutedEvent 'CircleClicked' ] + + /// + /// CircleClicked Event + /// + public static readonly RoutedEvent CircleClickedEvent = EventManager.RegisterRoutedEvent(nameof(CircleClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(AnimationButton)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler CircleClicked + { + add { AddHandler(CircleClickedEvent, value); } + remove { RemoveHandler(CircleClickedEvent, value); } + } + #endregion RoutedEvent 'CircleClicked' + + #region [ RoutedEvent 'ItemDrop' ] + + /// + /// CircleClicked Event + /// + public static readonly RoutedEvent ItemDropEvent = EventManager.RegisterRoutedEvent(nameof(ItemDrop), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(AnimationButton)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler ItemDrop + { + add { AddHandler(ItemDropEvent, value); } + remove { RemoveHandler(ItemDropEvent, value); } + } + #endregion RoutedEvent 'ItemDrop' + + + #region [ RoutedEvent 'SendStart' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent SendStartEvent = EventManager.RegisterRoutedEvent(nameof(SendStart), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(AnimationButton)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler SendStart + { + add { AddHandler(SendStartEvent, value); } + remove { RemoveHandler(SendStartEvent, value); } + } + #endregion RoutedEvent 'SendStart' + + #region [ RoutedEvent 'SendEnd' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent SendEndEvent = EventManager.RegisterRoutedEvent(nameof(SendEnd), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(AnimationButton)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler SendEnd + { + add { AddHandler(SendEndEvent, value); } + remove { RemoveHandler(SendEndEvent, value); } + } + #endregion RoutedEvent 'SendEnd' + + #endregion Public Members + + #region [ Ctor ] + /// + /// Ctor + /// + public AnimationButton() + { + try + { + InitializeComponent(); + this.ButtonText.Visibility = Visibility.Collapsed; + this.CountCircle.Visibility = Visibility.Collapsed; + this.CountText.Visibility = Visibility.Collapsed; + this.AllowDrop = true; + this.Drop += AnimationButton_Drop; + this.MouseLeave += AnimationButton_MouseLeave; + this.MouseDown += AnimationButton_MouseDown; + this.MouseUp += AnimationButton_MouseUp; + this.CountText.MouseLeave += Circle_MouseLeave; + this.CountText.MouseDown += Circle_MouseDown; + this.CountText.MouseUp += Circle_MouseUp; + this.GiveFeedback += AnimationButton_GiveFeedback; + } + catch(Exception ex) + { + CommonLog.ErrorLogWrite(this, "Ctor", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + ~AnimationButton() + { + this.Drop -= AnimationButton_Drop; + this.MouseLeave -= AnimationButton_MouseLeave; + this.MouseDown -= AnimationButton_MouseDown; + this.MouseUp -= AnimationButton_MouseUp; + this.CountText.MouseLeave -= Circle_MouseLeave; + this.CountText.MouseDown -= Circle_MouseDown; + this.CountText.MouseUp -= Circle_MouseUp; + this.GiveFeedback -= AnimationButton_GiveFeedback; + } + #endregion Ctor + + #region [ Methods ] + + protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) + { + try + { + var targetText = this.ButtonText; + if (this.Enabled) + { + if (this.Switch) + { + ResourceManager.SetBrush(this.ButtonGrid, "Background", this.SwitchOnBrush, this.BrushStretch, sizeInfo.NewSize); + ResourceManager.SetBrush(targetText, "Foreground", this.SwitchOnForeground); + targetText.FontSize = this.SwitchOnFontSize > 0 ? this.SwitchOnFontSize : this.TextFontSize > 0 ? this.TextFontSize : 12; + targetText.FontWeight = this.SwitchOnFontWeight; + + } + else + { + ResourceManager.SetBrush(this.ButtonGrid, "Background", this.NormalBrush, this.BrushStretch, sizeInfo.NewSize); + ResourceManager.SetBrush(targetText, "Foreground", this.TextForeground); + targetText.FontSize = this.TextFontSize > 0 ? this.TextFontSize : 12; + targetText.FontWeight = this.TextFontWeight; + } + } + else + { + ResourceManager.SetBrush(this.ButtonGrid, "Background", this.DisableBrush, this.BrushStretch, sizeInfo.NewSize); + ResourceManager.SetBrush(targetText, "Foreground", this.DisableForeground); + targetText.FontSize = this.DisableFontSize > 0 ? this.DisableFontSize : this.TextFontSize > 0 ? this.TextFontSize : 12; + targetText.FontWeight = this.DisableWeight; + } + base.OnRenderSizeChanged(sizeInfo); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OnRenderSizeChanged()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + private void RaiseSendStartEvent() + { + if (ClickSend) + { + RoutedEventArgs newEventArgs = new RoutedEventArgs(AnimationButton.SendStartEvent); + RaiseEvent(newEventArgs); + } + } + private void RaiseSendEndEvent() + { + if (ClickSend) + { + RoutedEventArgs newEventArgs = new RoutedEventArgs(AnimationButton.SendEndEvent); + RaiseEvent(newEventArgs); + } + } + /// + /// Raise MouseClicked Event + /// + private void RaiseMouseClickedEvent() + { + //Auto Toggle Process + if (AutoToggle) Switch = !Switch; + //Command Excute + if (Command != null && Command.CanExecute(DataParameter)) + { + Command.Execute(DataParameter); + } + // Click SendObject + if (ClickSend) + { + SendItem(this); + } + //Raise MouseClicked Event + RoutedEventArgs newEventArgs = new RoutedEventArgs(AnimationButton.MouseClickedEvent); + RaiseEvent(newEventArgs); + } + + /// + /// Raise CircleClicked Event + /// + private void RaiseCircleClickedEvent() + { + if (CircleCommand != null && CircleCommand.CanExecute(DataParameter)) + { + CircleCommand.Execute(DataParameter); + } + RoutedEventArgs newEventArgs = new RoutedEventArgs(AnimationButton.CircleClickedEvent); + RaiseEvent(newEventArgs); + } + /// + /// Raise ItemDrop Event + /// + /// + private void RaiseItemDropEvent(object sender) + { + + if (DropCommand != null && DropCommand.CanExecute(sender)) + { + DropCommand.Execute(sender); + } + RoutedEventArgs newEventArgs = new RoutedEventArgs(AnimationButton.ItemDropEvent, sender); + RaiseEvent(newEventArgs); + } + + /// + /// Get Target By ButtonAnimationType + /// + /// + /// + private FrameworkElement GetAnimationTarget(ButtonAnimationType _buttonAnimationType) + { + FrameworkElement AnimationTarget = null; + switch (_buttonAnimationType) + { + case ButtonAnimationType.TextBounceUp: + case ButtonAnimationType.TextBounceDown: + case ButtonAnimationType.TextSizeDown: + case ButtonAnimationType.TextSizeUp: + case ButtonAnimationType.TextTwist: + AnimationTarget = this.ButtonText; + break; + case ButtonAnimationType.BounceUp: + case ButtonAnimationType.BounceDown: + case ButtonAnimationType.SizeDown: + case ButtonAnimationType.SizeUp: + case ButtonAnimationType.Twist: + case ButtonAnimationType.OpacityDown: + case ButtonAnimationType.OpacityUp: + AnimationTarget = this.ButtonGrid; + break; + } + return AnimationTarget; + } + /// + /// Click Animation Run + /// + private void ClickAnimationRun() + { + + var target = GetAnimationTarget(ClickAnimationType); + if (target != null) Animations.GetClickAnimation(target, ClickAnimationType).Begin(); + } + /// + /// Drop Animation Run + /// + private void DropAnimationRun() + { + var target = GetAnimationTarget(DropAnimationType); + if (target != null) Animations.GetClickAnimation(target, DropAnimationType).Begin(); + } + /// + /// Item Image Send + /// + /// + private void SendItem(AnimationButton source) + { + try + { + RaiseSendStartEvent(); + SendSource = source; + var _targetGrid = source.FindParent(source.BaseGrid); + if (_targetGrid is Grid) + { + TargetGrid = _targetGrid as Grid; + var _reviceTarget = TargetGrid.FindName(source.ReciveElement); + switch (_reviceTarget.GetType().Name) + { + case "AnimationButton": + ReciveTarget = _reviceTarget as AnimationButton; + break; + case "ButtonList": + var listTarget = _reviceTarget as ButtonList; + if (listTarget.DefaultIndex > -1) + { + ReciveTarget = listTarget.DefaultItem; + } + else + { + ReciveTarget = null; + } + break; + } + } + if (TargetGrid != null && SendSource != null && ReciveTarget != null) + { + SendSource.IsEnabled = false; + ReciveTarget.IsEnabled = false; + var targetCanvas = new Canvas() { Name = "SendItemCanvas" }; + var sendImage = new Image + { + Width = SendSource.RenderSize.Width, + Height = SendSource.RenderSize.Height, + Name = "SendImage" + }; + var sourcePosition = SendSource.TranslatePoint(new Point(0, 0), TargetGrid); + var targetPosition = ReciveTarget.TranslatePoint(new Point(0, 0), TargetGrid); + sendImage.Source = ResourceManager.GetBitmapImage(SendSource.NormalBrush); + targetCanvas.Children.Add(sendImage); + targetCanvas.Background = new SolidColorBrush(Colors.Transparent); + TargetGrid.Children.Add(targetCanvas); + TargetGrid.ReregisterName("SendImage", sendImage); + TargetGrid.ReregisterName("SendItemCanvas", targetCanvas); + Canvas.SetLeft(sendImage, sourcePosition.X); + Canvas.SetTop(sendImage, sourcePosition.Y); + Canvas.SetZIndex(sendImage, int.MaxValue); + var moveX = targetPosition.X + (ReciveTarget.RenderSize.Width / 2);//- sourcePosition.X + (SendSource.RenderSize.Width / 2); + var moveY = targetPosition.Y - (ReciveTarget.RenderSize.Height / 2);// - sourcePosition.Y - (SendSource.RenderSize.Height / 2); + var SendAnimations = Animations.GetSendAnimation(sendImage, ButtonSendAnimationType.Normal, targetPosition.X - sourcePosition.X, targetPosition.Y - sourcePosition.Y); + if (SendAnimations != null) + { + SendAnimations.Completed += SendAnimations_Completed; + SendAnimations.Begin(); + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "SendItem()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + private static void SetButton(AnimationButton _thisButton, M_AnimationButton _m_ButtonData) + { + try + { + _thisButton.Width = _m_ButtonData.Width; + _thisButton.Height = _m_ButtonData.Height; + _thisButton.Margin = _m_ButtonData.Margin; + _thisButton.NormalBrush = _m_ButtonData.NormalBrush; + _thisButton.DownBrush = _m_ButtonData.DownBrush; + _thisButton.DisableBrush = _m_ButtonData.DisableBrush; + _thisButton.SwitchOnBrush = _m_ButtonData.SwitchOnBrush; + _thisButton.DragCursorImage = _m_ButtonData.DragCursorImage; + _thisButton.DragCursorHotSpot = _m_ButtonData.DragCursorHotSpot; + _thisButton.BrushStretch = _m_ButtonData.BrushStretch; + _thisButton.Enabled = _m_ButtonData.Enabled; + _thisButton.Switch = _m_ButtonData.Switch; + _thisButton.IsBreathing = _m_ButtonData.IsBreathing; + _thisButton.AutoToggle = _m_ButtonData.AutoToggle; + _thisButton.ClickSend = _m_ButtonData.ClickSend; + _thisButton.BaseGrid = _m_ButtonData.BaseGrid; + _thisButton.ReciveElement = _m_ButtonData.ReciveElement; + _thisButton.ClickAnimationType = _m_ButtonData.ClickAnimationType; + _thisButton.DropAnimationType = _m_ButtonData.DropAnimationType; + _thisButton.Text = _m_ButtonData.Text; + _thisButton.LanguageText = _m_ButtonData.LanguageText; + _thisButton.TextVisible = _m_ButtonData.TextVisible; + _thisButton.TextForeground = _m_ButtonData.TextForeground; + _thisButton.SwitchOnForeground = _m_ButtonData.SwitchOnForeground; + _thisButton.DisableForeground = _m_ButtonData.DisableForeground; + _thisButton.TextVerticalAlignment = _m_ButtonData.TextVerticalAlignment; + _thisButton.TextHorizontalAlignment = _m_ButtonData.TextHorizontalAlignment; + _thisButton.TextFontFamily = _m_ButtonData.TextFontFamily; + _thisButton.TextFontSize = _m_ButtonData.TextFontSize; + _thisButton.SwitchOnFontSize = _m_ButtonData.SwitchOnFontSize; + _thisButton.DisableFontSize = _m_ButtonData.DisableFontSize; + _thisButton.TextFontWeight = _m_ButtonData.TextFontWeight; + _thisButton.SwitchOnFontWeight = _m_ButtonData.SwitchOnFontWeight; + _thisButton.DisableWeight = _m_ButtonData.DisableWeight; + _thisButton.TextWrapping = _m_ButtonData.TextWrapping; + _thisButton.TextAlignment = _m_ButtonData.TextAlignment; + _thisButton.TextMargin = _m_ButtonData.TextMargin; + _thisButton.DragEnable = _m_ButtonData.DragEnable; + _thisButton.CircleSize = _m_ButtonData.CircleSize; + _thisButton.CircleBackBrush = _m_ButtonData.CircleBackBrush; + _thisButton.CircleTextBruch = _m_ButtonData.CircleTextBruch; + _thisButton.CircleText = _m_ButtonData.CircleText; + _thisButton.CircleOuter = _m_ButtonData.CircleOuter; + _thisButton.DisplayLanguage = _m_ButtonData.DisplayLanguage; + SetNormalBrush(_thisButton); + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(_thisButton, "SetButton()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + private static void SetNormalBrush(AnimationButton _thisButton) + { + try + { + var targetText = _thisButton.ButtonText; + if (_thisButton.Enabled) + { + if (_thisButton.Switch) + { + ResourceManager.SetBrush(_thisButton.ButtonGrid, "Background", _thisButton.SwitchOnBrush, _thisButton.BrushStretch, new Size(_thisButton.Width, _thisButton.Height)); + ResourceManager.SetBrush(targetText, "Foreground", _thisButton.SwitchOnForeground); + if (_thisButton.TextVisible.Equals(Visibility.Visible)) + { + targetText.FontSize = _thisButton.SwitchOnFontSize > 0 ? _thisButton.SwitchOnFontSize : _thisButton.TextFontSize > 0 ? _thisButton.TextFontSize : 12; + targetText.FontWeight = _thisButton.SwitchOnFontWeight; + } + } + else + { + ResourceManager.SetBrush(_thisButton.ButtonGrid, "Background", _thisButton.NormalBrush, _thisButton.BrushStretch, new Size(_thisButton.Width, _thisButton.Height)); + ResourceManager.SetBrush(targetText, "Foreground", _thisButton.TextForeground); + if (_thisButton.TextVisible.Equals(Visibility.Visible)) + { + targetText.FontSize = _thisButton.TextFontSize > 0 ? _thisButton.TextFontSize : 12; + targetText.FontWeight = _thisButton.TextFontWeight; + } + } + } + else + { + ResourceManager.SetBrush(_thisButton.ButtonGrid, "Background", _thisButton.DisableBrush, _thisButton.BrushStretch, new Size(_thisButton.Width, _thisButton.Height)); + ResourceManager.SetBrush(targetText, "Foreground", _thisButton.DisableForeground); + if (_thisButton.TextVisible.Equals(Visibility.Visible)) + { + targetText.FontSize = _thisButton.DisableFontSize > 0 ? _thisButton.DisableFontSize : _thisButton.TextFontSize > 0 ? _thisButton.TextFontSize : 12; + targetText.FontWeight = _thisButton.DisableWeight; + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(_thisButton, "SetButton()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + #endregion Methods + + #region [ Event Handlers ] + + #region [ SendItem Animation Completed ] + private void SendAnimations_Completed(object sender, EventArgs e) + { + + try + { + if (TargetGrid.FindName("SendItemCanvas") is Canvas sendItemCanvas) + { + sendItemCanvas.Children.Clear(); + TargetGrid.Children.Remove(sendItemCanvas); + sendItemCanvas = null; + TargetGrid.UnregisterName("SendImage"); + TargetGrid.UnregisterName("SendItemCanvas"); + var eventArgs = new M_ItemDropEventArgs + { + SourceObject = SendSource, + TargetObject = ReciveTarget + }; + if (ReciveTarget is AnimationButton animationButton) + { + animationButton.DropAnimationRun(); + animationButton.RaiseItemDropEvent(eventArgs); + + } + SendSource.IsEnabled = true; + ReciveTarget.IsEnabled = true; + } + RaiseSendEndEvent(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "SetButton()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + #endregion SendItem Animation Completed + + #region [ DependencyProperty OnChanged Event Handler ] + + private static void IsBreathingPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as AnimationButton; + if ((bool)e.NewValue) + { + if (target.BreathigStoryboard is Storyboard storyboard) + { + storyboard.Resume(); + } + else + { + target.BreathigStoryboard = Animations.GetClickAnimation(target.ButtonGrid, ButtonAnimationType.OpacityDown, 0.5); + target.BreathigStoryboard.RepeatBehavior = RepeatBehavior.Forever; + target.BreathigStoryboard.Begin(); + } + } + else + { + if (target.BreathigStoryboard is Storyboard storyboard) + { + storyboard.Pause(); + } + } + } + + + private static void OnDataParameterPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null && !e.NewValue.Equals(e.OldValue)) + { + var target = d as AnimationButton; + var getType = e.NewValue.GetType(); + if (e.NewValue is M_ItemData m_ItemData) + { + if (m_ItemData.DataParameter is M_AnimationButton m_ButtonData) + { + SetButton(target, m_ButtonData); + } + } + else if (e.NewValue is M_AnimationButton m_ButtonData) + { + SetButton(target, m_ButtonData); + } + } + } + private static void OnNormalBrushPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue !=null) + { + var target = d as AnimationButton; + ResourceManager.SetBrush(target.ButtonGrid, "Background", target.SwitchOnBrush, target.BrushStretch, new Size(target.Width, target.Height)); + SetNormalBrush(target); + } + } + private static void OnBrushStretchPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null) + { + var target = d as AnimationButton; + SetNormalBrush(target); + } + } + private static void OnSwitchPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null) + { + var target = d as AnimationButton; + SetNormalBrush(target); + } + } + private static void OnEnabledPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue is bool enabled) + { + var target = d as AnimationButton; + SetNormalBrush(target); + target.IsEnabled = enabled; + } + } + private static void OnTextVisiblePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var targetText = (d as AnimationButton).ButtonText; + targetText.Visibility = (Visibility)e.NewValue; + } + private static void OnTextForegroundPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null) + { + var target = d as AnimationButton; + if (string.IsNullOrEmpty(target.SwitchOnForeground) + || target.SwitchOnForeground.Equals("Transparent")) target.SwitchOnForeground = (string)e.NewValue; + if (string.IsNullOrEmpty(target.DisableForeground) + || target.DisableForeground.Equals("Transparent")) target.DisableForeground = (string)e.NewValue; + SetNormalBrush(target); + } + + } + private static void OnSwitchOnForegroundPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null) + { + var target = d as AnimationButton; + SetNormalBrush(target); + } + } + private static void OnDisableForegroundPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null) + { + var target = d as AnimationButton; + SetNormalBrush(target); + } + } + + private static void OnTextVerticalAlignmentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var targetText = (d as AnimationButton).ButtonText; + targetText.VerticalAlignment = (VerticalAlignment)e.NewValue; + } + private static void OnTextHorizontalAlignmentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var targetText = (d as AnimationButton).ButtonText; + targetText.HorizontalAlignment = (HorizontalAlignment)e.NewValue; + } + private static void OnTextFontFamilyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var targetText = (d as AnimationButton).ButtonText; + try + { + targetText.FontFamily = new FontFamily((string)e.NewValue); + } + catch + { + targetText.FontFamily = Fonts.SystemFontFamilies.First(); + } + } + private static void OnTextFontSizePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var targetText = (d as AnimationButton).ButtonText; + try + { + targetText.FontSize = (double)e.NewValue; + } + catch + { + targetText.FontSize = 10; + } + } + private static void OnSwitchOnFontSizePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null) + { + var target = d as AnimationButton; + SetNormalBrush(target); + } + } + private static void OnDisableFontSizePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null) + { + var target = d as AnimationButton; + SetNormalBrush(target); + } + } + + private static void OnTextFontWeightPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var targetText = (d as AnimationButton).ButtonText; + targetText.FontWeight = (FontWeight)e.NewValue; + } + private static void OnSwitchOnFontWeightPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null) + { + var target = d as AnimationButton; + SetNormalBrush(target); + } + } + private static void OnDisableWeightPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null) + { + var target = d as AnimationButton; + SetNormalBrush(target); + } + } + + private static void OnTextWrappingPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var targetText = (d as AnimationButton).ButtonText; + targetText.TextWrapping = (TextWrapping)e.NewValue; + } + private static void OnTextAlignmentPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var targetText = (d as AnimationButton).ButtonText; + targetText.TextAlignment = (TextAlignment)e.NewValue; + } + private static void OnTextMarginPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var targetText = (d as AnimationButton).ButtonText; + targetText.Margin = (Thickness)e.NewValue; + } + private static void OnCircleSizePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if ((double)e.NewValue > 12) + { + var target = d as AnimationButton; + target.CountCircle.Width = (double)e.NewValue; + target.CountCircle.Height = (double)e.NewValue; + target.CountCircle.StrokeThickness = (double)e.NewValue * 0.07; + target.CountText.Width = (double)e.NewValue; + target.CountText.Height = (double)e.NewValue; + target.CountText.FontSize = (double)e.NewValue * 0.7; + } + } + private static void OnCircleTextBruchPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as AnimationButton; + ResourceManager.SetBrush(target.CountText, "Foreground", (string)e.NewValue); + ResourceManager.SetBrush(target.CountCircle, "Stroke", (string)e.NewValue); + } + private static void OnCircleTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as AnimationButton; + if (e.NewValue.Equals(string.Empty)) + { + target.CountText.Visibility = Visibility.Collapsed; + } + else + { + target.CountText.Visibility = Visibility.Visible; + target.CountText.Text = (string)e.NewValue; + } + + } + private static void OnCircleBackBrushPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as AnimationButton; + if (e.NewValue.Equals("Transparent")) + { + target.CountCircle.Visibility = Visibility.Collapsed; + } + else + { + target.CountCircle.Visibility = Visibility.Visible; + ResourceManager.SetBrush(target.CountCircle, "Fill", (string)e.NewValue); + } + } + private static void OnCircleOuterPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if ((bool)e.NewValue) + { + var target = d as AnimationButton; + target.CountCircle.RenderTransform = new TranslateTransform(); + var _circleTranslateTransform = target.CountCircle.RenderTransform as TranslateTransform; + _circleTranslateTransform.X = target.CountCircle.Width / 2; + _circleTranslateTransform.Y = target.CountCircle.Height / 2 * -1; + target.CountText.RenderTransform = new TranslateTransform(); + var _textTranslateTransform = target.CountText.RenderTransform as TranslateTransform; + _textTranslateTransform.X = target.CountText.Width / 2; + _textTranslateTransform.Y = target.CountText.Height / 2 * -1; + + } + } + private static void OnBadgeImagesProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue is List badgeImages) + { + var target = d as AnimationButton; + target.BadgeStack.Children.Clear(); + foreach (var aBadge in badgeImages) + { + var sourceImage = ResourceManager.GetBitmapImage(aBadge); + if (sourceImage is BitmapImage) + { + var aBadgeImage = new Image() + { + Width = sourceImage.Width, + Height = sourceImage.Height, + Source = sourceImage + }; + target.BadgeStack.Children.Add(aBadgeImage); + } + } + + } + } + #endregion DependencyProperty OnChanged Event Handler + + #region Drag & Drap Event Handler + private void AnimationButton_GiveFeedback(object sender, GiveFeedbackEventArgs e) + { + var dropSource = e.Source as AnimationButton; + if (e.Effects.Equals(DragDropEffects.Link) && !string.IsNullOrEmpty(dropSource.DragCursorImage) && DragEnable) + { + if (DragCursor == null) DragCursor = ResourceManager.GetCursorByImage(dropSource.DragCursorImage, dropSource.DragCursorHotSpot, dropSource.Width); + if (DragCursor != null) + { + e.UseDefaultCursors = false; + Mouse.SetCursor(DragCursor); + } + else + { + e.UseDefaultCursors = true; + } + } + else + { + e.UseDefaultCursors = true; + } + e.Handled = DragEnable; + } + private void AnimationButton_Drop(object sender, DragEventArgs e) + { + var source = (sender as AnimationButton); + if (e.Data.GetData(sender.GetType()) is AnimationButton dropSource && !source.Equals(dropSource) && e.AllowedEffects.Equals(DragDropEffects.Link)) + { + var eventArgs = new M_ItemDropEventArgs + { + SourceObject = dropSource, + TargetObject = source + }; + DropAnimationRun(); + RaiseItemDropEvent(eventArgs); + } + MoseDown = false; + } + #endregion Drag & Drap Event Handler + + #region Mouse Events Handler + private void AnimationButton_MouseLeave(object sender, MouseEventArgs e) + { + + if ( MoseDown && DragEnable) + { + DragDrop.DoDragDrop(sender as DependencyObject, sender, DragDropEffects.Link); + } + if (!Switch ) + { + SetNormalBrush(this); + MoseDown = false; + } + } + + private void AnimationButton_MouseDown(object sender, MouseButtonEventArgs e) + { + if (!MoseDown && !(CountCircle.IsMouseOver || CountText.IsMouseOver)) + { + if (!string.IsNullOrEmpty(DownBrush) + && !DownBrush.Equals("Transparent")) ResourceManager.SetBrush(ButtonGrid, "Background", DownBrush, BrushStretch, RenderSize); + if (this.IsEnabled) + { + ClickAnimationRun(); + MoseDown = true; + } + MoseDownPosition = e.GetPosition(this); + } + } + + private void AnimationButton_MouseUp(object sender, MouseButtonEventArgs e) + { + if (MoseDown && !(CountCircle.IsMouseOver || CountText.IsMouseOver)) + { + if (Math.Abs(e.GetPosition(this).X - MoseDownPosition.X) > 50) MoseDown = false; + if (Math.Abs(e.GetPosition(this).Y - MoseDownPosition.Y) > 50) MoseDown = false; + if (MoseDown ) + { + RaiseMouseClickedEvent(); + } + SetNormalBrush(this); + MoseDown = false; + } + } + #endregion Mouse Events + + #region CircleMouse Events Handler + private void Circle_MouseLeave(object sender, MouseEventArgs e) + { + CircleMoseDown = false; + } + + private void Circle_MouseDown(object sender, MouseButtonEventArgs e) + { + if (!CircleMoseDown ) + { + if (this.IsEnabled) + { + Animations.GetClickAnimation(this.CountCircle, ButtonAnimationType.SizeDown).Begin(); + CircleMoseDown = true; + } + CircleMoseDownPosition = e.GetPosition(this); + } + } + + private void Circle_MouseUp(object sender, MouseButtonEventArgs e) + { + if (CircleMoseDown) + { + if (Math.Abs(e.GetPosition(this).X - CircleMoseDownPosition.X) > this.CountText.Width) MoseDown = false; + if (Math.Abs(e.GetPosition(this).Y - CircleMoseDownPosition.Y) > this.CountText.Height) MoseDown = false; + RaiseCircleClickedEvent(); + CircleMoseDown = false; + } + } + #endregion CircleMouse Events Handler + + #endregion Event Handlers + + + } + + +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/ButtonList.xaml b/Kiosk/Common/SPC.Kiosk.Common/Controls/ButtonList.xaml new file mode 100644 index 0000000..da3c754 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/ButtonList.xaml @@ -0,0 +1,16 @@ + + + + + + + + diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/ButtonList.xaml.cs b/Kiosk/Common/SPC.Kiosk.Common/Controls/ButtonList.xaml.cs new file mode 100644 index 0000000..ce6768a --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/ButtonList.xaml.cs @@ -0,0 +1,1142 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +namespace SPC.Kiosk.Common +{ + /// + /// ButtonList.xaml에 대한 상호 작용 논리 + /// + public partial class ButtonList : UserControl + { + #region [ Members ] + /// + /// ListItems + /// + public static readonly DependencyProperty ListItemsProperty = + DependencyProperty.Register(nameof(ListItems), typeof(ObservableCollection), typeof(ButtonList), new PropertyMetadata(null, new PropertyChangedCallback(OnListItemsPropertyChanged))); + /// + /// Command + /// + public static readonly DependencyProperty CommandProperty = + DependencyProperty.Register(nameof(Command), typeof(ICommand), typeof(ButtonList), new UIPropertyMetadata(null)); + /// + /// DropCommand + /// + public static readonly DependencyProperty CircleCommandProperty = + DependencyProperty.Register(nameof(CircleCommand), typeof(ICommand), typeof(ButtonList), new UIPropertyMetadata(null)); + /// + /// DropCommand + /// + public static readonly DependencyProperty DropCommandProperty = + DependencyProperty.Register(nameof(DropCommand), typeof(ICommand), typeof(ButtonList), new UIPropertyMetadata(null)); + /// + /// Columns Count + /// + public static readonly DependencyProperty ColumnCountProperty = + DependencyProperty.Register(nameof(ColumnCount), typeof(int), typeof(ButtonList), new PropertyMetadata(3)); + /// + /// Page Stack Orientation + /// + public static readonly DependencyProperty StackOrientationProperty = + DependencyProperty.Register(nameof(StackOrientation), typeof(Orientation), typeof(ButtonList), new PropertyMetadata(Orientation.Vertical, new PropertyChangedCallback(OnStackOrientationPropertyChanged))); + /// + /// Vertical Scroll Offset + /// + public static readonly DependencyProperty VerticalOffsetProperty = + DependencyProperty.Register(nameof(VerticalOffset), typeof(double), typeof(ButtonList), new PropertyMetadata(0d, new PropertyChangedCallback(OnVerticalOffsetPropertyChanged))); + /// + /// Horizontal Scroll Offset + /// + public static readonly DependencyProperty HorizontalOffsetProperty = + DependencyProperty.Register(nameof(HorizontalOffset), typeof(double), typeof(ButtonList), new PropertyMetadata(0d, new PropertyChangedCallback(OnHorizontalOffsetPropertyChanged))); + /// + /// Rows Count + /// + public static readonly DependencyProperty RowCountProperty = + DependencyProperty.Register(nameof(RowCount), typeof(int), typeof(ButtonList), new PropertyMetadata(1)); + /// + /// ItemWidth + /// + public static readonly DependencyProperty ItemWidthProperty = + DependencyProperty.Register(nameof(ItemWidth), typeof(double), typeof(ButtonList), new PropertyMetadata(double.NaN)); + /// + /// ItemHeight + /// + public static readonly DependencyProperty ItemHeightProperty = + DependencyProperty.Register(nameof(ItemHeight), typeof(double), typeof(ButtonList), new PropertyMetadata(double.NaN)); + /// + /// Default PageNo + /// + public static readonly DependencyProperty DefaultPageNoProperty = + DependencyProperty.Register(nameof(DefaultPageNo), typeof(int), typeof(ButtonList), new PropertyMetadata(0, new PropertyChangedCallback(OnDefaultPageNoPropertyChanged))); + /// + /// TextPosition + /// + public static readonly DependencyProperty TextPositionProperty = + DependencyProperty.Register(nameof(TextPosition), typeof(TextPosition), typeof(ButtonList), new PropertyMetadata(TextPosition.InnerButton)); + /// + /// ClickSend + /// + public static readonly DependencyProperty ClickSendProperty = + DependencyProperty.Register(nameof(ClickSend), typeof(bool), typeof(ButtonList), new PropertyMetadata(false, new PropertyChangedCallback(OnClickSendPropertyChanged))); + + + /// + /// BaseGrid + /// + public static readonly DependencyProperty BaseGridProperty = + DependencyProperty.Register(nameof(BaseGrid), typeof(string), typeof(ButtonList), new PropertyMetadata(string.Empty)); + /// + /// ReciveElement + /// + public static readonly DependencyProperty ReciveElementProperty = + DependencyProperty.Register(nameof(ReciveElement), typeof(string), typeof(ButtonList), new PropertyMetadata(string.Empty)); + /// + /// DefaultItem + /// + public static readonly DependencyProperty DefaultItemProperty = + DependencyProperty.Register(nameof(DefaultItem), typeof(AnimationButton), typeof(ButtonList), new PropertyMetadata(null)); + /// + /// DefaultIndex + /// + public static readonly DependencyProperty DefaultIndexProperty = + DependencyProperty.Register(nameof(DefaultIndex), typeof(int), typeof(ButtonList), new PropertyMetadata(0, new PropertyChangedCallback(OnDefaultIndexPropertyChanged))); + /// + /// Display Language + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(ButtonList), new PropertyMetadata(SupportLanguageType.ko, new PropertyChangedCallback(OnDisplayLanguageProperyChanged))); + /// + /// Drag Enable Flag + /// + public static readonly DependencyProperty DragEnablePropery = + DependencyProperty.Register(nameof(DragEnable), typeof(bool), typeof(ButtonList), new PropertyMetadata(false, new PropertyChangedCallback(OnDragEnableProperyChanged))); + /// + /// AutoToggle Flag + /// + public static readonly DependencyProperty AutoTogglePropery = + DependencyProperty.Register(nameof(AutoToggle), typeof(bool), typeof(ButtonList), new PropertyMetadata(false, new PropertyChangedCallback(OnAutoToggleProperyChanged))); + /// + /// Selected Item Switch On Flag + /// + public static readonly DependencyProperty SelectOnPropery = + DependencyProperty.Register(nameof(SelectOn), typeof(bool), typeof(ButtonList), new PropertyMetadata(false, new PropertyChangedCallback(OnSelectOnProperyChanged))); + + + private int TargetPageNo = 0; + private double mouseDownYposition = -1; + private double mouseDownXposition = -1; + private bool MoseDown = false; + /// + /// Drag Enable Flag + /// + public bool DragEnable + { + get { return (bool)GetValue(DragEnablePropery); } + set { SetValue(DragEnablePropery, value); } + } + /// + /// AutoToggle Flag + /// + public bool AutoToggle + { + get { return (bool)GetValue(AutoTogglePropery); } + set { SetValue(AutoTogglePropery, value); } + } + /// + /// Selected Item Switch On Flag + /// + public bool SelectOn + { + get { return (bool)GetValue(SelectOnPropery); } + set { SetValue(SelectOnPropery, value); } + } + + /// + /// ListItems + /// + public ObservableCollection ListItems + { + get { return (ObservableCollection)GetValue(ListItemsProperty); } + set { SetValue(ListItemsProperty, value); } + } + /// + /// Command + /// + public ICommand Command + { + get { return (ICommand)GetValue(CommandProperty); } + set { SetValue(CommandProperty, value); } + } + /// + /// Circle Clicked Command + /// + public ICommand CircleCommand + { + get { return (ICommand)GetValue(CircleCommandProperty); } + set { SetValue(CircleCommandProperty, value); } + } + /// + /// DropCommand + /// + public ICommand DropCommand + { + get { return (ICommand)GetValue(DropCommandProperty); } + set { SetValue(DropCommandProperty, value); } + } + /// + /// StackOrientation + /// + public Orientation StackOrientation + { + get { return (Orientation)GetValue(StackOrientationProperty); } + set { SetValue(StackOrientationProperty, value); } + } + /// + /// ColumnCount + /// + public int ColumnCount + { + get { return (int)GetValue(ColumnCountProperty); } + set { SetValue(ColumnCountProperty, value); } + } + /// + /// RowCount + /// + public int RowCount + { + get { return (int)GetValue(RowCountProperty); } + set { SetValue(RowCountProperty, value); } + } + /// + /// ItemWidth + /// + public double ItemWidth + { + get { return (double)GetValue(ItemWidthProperty); } + set { SetValue(ItemWidthProperty, value); } + } + /// + /// ItemHeight + /// + public double ItemHeight + { + get { return (double)GetValue(ItemHeightProperty); } + set { SetValue(ItemHeightProperty, value); } + } + + /// + /// DefaultPageNo + /// + public int DefaultPageNo + { + get { return (int)GetValue(DefaultPageNoProperty); } + set { SetValue(DefaultPageNoProperty, value); } + } + /// + /// TextPosition + /// + public TextPosition TextPosition + { + get { return (TextPosition)GetValue(TextPositionProperty); } + set { SetValue(TextPositionProperty, value); } + } + /// + /// DefaultItem + /// + public AnimationButton DefaultItem + { + get { return (AnimationButton)GetValue(DefaultItemProperty); } + set { SetValue(DefaultItemProperty, value); } + } + /// + /// DefaultIndex + /// + public int DefaultIndex + { + get { return (int)GetValue(DefaultIndexProperty); } + set { SetValue(DefaultIndexProperty, value); } + } + /// + /// ClickSend + /// + public bool ClickSend + { + get { return (bool)GetValue(ClickSendProperty); } + set { SetValue(ClickSendProperty, value); } + } + /// + /// ReciveElement + /// + public string ReciveElement + { + get { return (string)GetValue(ReciveElementProperty); } + set { SetValue(ReciveElementProperty, value); } + } + /// + /// BaseGrid + /// + public string BaseGrid + { + get { return (string)GetValue(BaseGridProperty); } + set { SetValue(BaseGridProperty, value); } + } + /// + /// VerticalOffset + /// + public double VerticalOffset + { + get { return (double)GetValue(VerticalOffsetProperty); } + set { SetValue(VerticalOffsetProperty, value); } + } + /// + /// HorizontalOffset + /// + public double HorizontalOffset + { + get { return (double)GetValue(HorizontalOffsetProperty); } + set { SetValue(HorizontalOffsetProperty, value); } + } + /// + /// Display Language + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + + #region [ RoutedEvent 'MouseClicked' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent MouseClickedEvent = EventManager.RegisterRoutedEvent(nameof(MouseClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ButtonList)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler MouseClicked + { + add { AddHandler(MouseClickedEvent, value); } + remove { RemoveHandler(MouseClickedEvent, value); } + } + #endregion RoutedEvent 'MouseClicked' + + #region [ RoutedEvent 'CircleClicked' ] + + /// + /// CircleClicked Event + /// + public static readonly RoutedEvent CircleClickedEvent = EventManager.RegisterRoutedEvent(nameof(CircleClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ButtonList)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler CircleClicked + { + add { AddHandler(CircleClickedEvent, value); } + remove { RemoveHandler(CircleClickedEvent, value); } + } + #endregion RoutedEvent 'CircleClicked' + + #region [ RoutedEvent 'ItemDrop' ] + + /// + /// CircleClicked Event + /// + public static readonly RoutedEvent ItemDropEvent = EventManager.RegisterRoutedEvent(nameof(ItemDrop), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(ButtonList)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler ItemDrop + { + add { AddHandler(ItemDropEvent, value); } + remove { RemoveHandler(ItemDropEvent, value); } + } + #endregion RoutedEvent 'ItemDrop' + + #endregion Members + + #region [ Ctor & Etc ] + /// + /// Ctor + /// + public ButtonList() + { + InitializeComponent(); + this.Unloaded += ButtonList_Unloaded; + } + + #endregion Ctor & Etc + + #region [ Methods ] + /// + /// Default Item Set By Index + /// + /// + public void SetDefaultItem(int _itemIndex) + { + if (this.FindName(string.Format("ButtonListItem{0}", _itemIndex)) is AnimationButton findItem) + { + DefaultItem = findItem; + findItem.Switch = SelectOn; + } + } + /// + /// Reset Default Item + /// + /// + public void ResetDefaultItem(int _itemIndex) + { + if (this.FindName(string.Format("ButtonListItem{0}", _itemIndex)) is AnimationButton findItem) + { + findItem.Switch = false; + } + } + + /// + /// Raise MouseClicked Event + /// + private void RaiseMouseClickedEvent(object _sender) + { + //Command Excute + if (Command != null && Command.CanExecute(_sender)) + { + Command.Execute(_sender); + } + RoutedEventArgs newEventArgs = new RoutedEventArgs(ButtonList.MouseClickedEvent, _sender); + RaiseEvent(newEventArgs); + } + /// + /// Raise CircleClicked Event + /// + private void RaiseCircleClickedEvent(object _sender) + { + if (CircleCommand != null && CircleCommand.CanExecute(_sender)) + { + CircleCommand.Execute(_sender); + } + RoutedEventArgs newEventArgs = new RoutedEventArgs(ButtonList.CircleClickedEvent, _sender); + RaiseEvent(newEventArgs); + } + private void RaiseItemDropEvent(object sender) + { + + if (DropCommand != null && DropCommand.CanExecute(sender)) + { + DropCommand.Execute(sender); + } + RoutedEventArgs newEventArgs = new RoutedEventArgs(ButtonList.ItemDropEvent, sender); + RaiseEvent(newEventArgs); + } + private static void ItemsButtonCreate(ButtonList _target, object _listItems) + { + try + { + if (_listItems is ObservableCollection lstItems && lstItems.Count > 0) + { + int itemCnt = 0; + int PageCount = 0; + int RowsCount = 0; + Grid PageGrid = null; + StackPanel PageStak = null; + Grid RowGrid = null; + StackPanel RowStack = null; + foreach (var aItem in lstItems) + { + if (itemCnt % (_target.ColumnCount * _target.RowCount) == 0) + { + PageGrid = new Grid + { + Background = new SolidColorBrush(Colors.Transparent), + Width = _target.Width, + Height = _target.Height, + HorizontalAlignment = HorizontalAlignment.Right, + Name = string.Format("PageGrid{0}", PageCount), + }; + PageGrid.IsEnabled = PageCount.Equals(_target.DefaultPageNo); + PageGrid.Width = _target.Width; + PageGrid.Height = _target.RowCount * _target.ItemHeight; + _target.ReregisterName(string.Format("PageGrid{0}", PageCount), PageGrid); + + + PageStak = new StackPanel + { + Background = new SolidColorBrush(Colors.Transparent), + HorizontalAlignment = HorizontalAlignment.Left, + VerticalAlignment = VerticalAlignment.Top, + Orientation = Orientation.Vertical, + Name = string.Format("PageStak{0}", PageCount) + }; + _target.ReregisterName(string.Format("PageStak{0}", PageCount), PageStak); + + } + if (itemCnt % _target.ColumnCount == 0) + { + RowGrid = new Grid + { + Background = new SolidColorBrush(Colors.Transparent), + Width = _target.Width + }; + RowStack = new StackPanel + { + Background = new SolidColorBrush(Colors.Transparent), + HorizontalAlignment = HorizontalAlignment.Center, + Orientation = Orientation.Horizontal + }; + if (!_target.ItemHeight.Equals(double.NaN)) RowStack.Height = _target.ItemHeight; + RowStack.Name = string.Format("RowStack{0}", RowsCount); + _target.ReregisterName(string.Format("RowStack{0}", RowsCount), RowStack); + RowGrid.Children.Add(RowStack); + } + var ItemStack = new StackPanel + { + Background = new SolidColorBrush(Colors.Transparent), + Width = _target.ItemWidth, + Height = _target.ItemHeight + }; + if (aItem.BadgeHeight > 0) + { + var bageGrid = new Grid + { + Width = _target.ItemWidth, + Height = aItem.BadgeHeight, + }; + var bageStack = new StackPanel + { + Background = new SolidColorBrush(Colors.Transparent), + Orientation = aItem.BadgeOrientation, + HorizontalAlignment = aItem.BadgeHorizontalAlignment, + VerticalAlignment = aItem.BadgeVerticalAlignment, + }; + if (aItem.BadgeImages is List) + { + foreach (var bageImage in aItem.BadgeImages) + { + var sourceImage = ResourceManager.GetBitmapImage(bageImage); + if (sourceImage !=null) + { + var aBadgeImage = new Image() + { + Width = sourceImage.Width, + Height = sourceImage.Height, + Source = sourceImage, + HorizontalAlignment = aItem.BadgeHorizontalAlignment, + }; + bageStack.Children.Add(aBadgeImage); + } + } + } + bageStack.Name = string.Format("BageStack{0}", itemCnt); + _target.ReregisterName(string.Format("BageStack{0}", itemCnt), bageStack); + bageGrid.Children.Add(bageStack); + ItemStack.Children.Add(bageGrid); + + } + var aItemButton = new AnimationButton(); + if (aItem.DataParameter.Width.Equals(double.NaN) || aItem.DataParameter.Width.Equals(0d)) + { + aItem.DataParameter.Width = _target.ItemWidth; + } + Grid baseTextGrid = null; + StackPanel textStack = null; + MutiLanguageTextBlock baseText = null; + MutiLanguageTextBlock additionText = null; + if (!_target.TextPosition.Equals(TextPosition.InnerButton)) + { + baseTextGrid = new Grid + { + Background = new SolidColorBrush(Colors.Transparent) + }; + textStack = new StackPanel + { + Background = new SolidColorBrush(Colors.Transparent) + }; + baseText = new MutiLanguageTextBlock + { + FontSize = aItem.BaseTextBlock.TextSize, + Background = new SolidColorBrush(Colors.Transparent) + }; + ResourceManager.SetBrush(baseText, "Foreground", aItem.BaseTextBlock.TextBrush); + baseText.Width = aItem.BaseTextBlock.Width; + baseText.Height = aItem.BaseTextBlock.Height; + baseText.HorizontalAlignment = aItem.BaseTextBlock.TextHorizontalAlignment; + baseText.VerticalAlignment = aItem.BaseTextBlock.TextVerticalAlignment; + baseText.TextAlignment = aItem.BaseTextBlock.TextAlignment; + baseText.Margin = aItem.BaseTextBlock.TextMargin; + baseText.AutoTextTrim = aItem.BaseTextBlock.AutoTextTrim; + baseText.TextWrapping = aItem.BaseTextBlock.TextWrapping; + baseText.FontWeight = aItem.BaseTextBlock.TextWeight; + baseText.FontFamily = new FontFamily(aItem.BaseTextBlock.TextFontFamily); + baseText.TextWrapping = TextWrapping.Wrap; + baseText.MultiLanguage = aItem.BaseTextBlock.LanguageData; + baseText.DisplayLanguage = _target.DisplayLanguage; + additionText = new MutiLanguageTextBlock + { + FontSize = aItem.AdditionTextBlock.TextSize, + Background = new SolidColorBrush(Colors.Transparent) + }; + ResourceManager.SetBrush(additionText, "Foreground", aItem.AdditionTextBlock.TextBrush); + additionText.Width = aItem.AdditionTextBlock.Width; + additionText.Height = aItem.AdditionTextBlock.Height; + additionText.HorizontalAlignment = aItem.AdditionTextBlock.TextHorizontalAlignment; + additionText.VerticalAlignment = aItem.AdditionTextBlock.TextVerticalAlignment; + additionText.TextAlignment = aItem.AdditionTextBlock.TextAlignment; + additionText.TextWrapping = aItem.AdditionTextBlock.TextWrapping; + additionText.Margin = aItem.AdditionTextBlock.TextMargin; + additionText.AutoTextTrim = aItem.AdditionTextBlock.AutoTextTrim; + additionText.FontWeight = aItem.AdditionTextBlock.TextWeight; + additionText.FontFamily = new FontFamily(aItem.AdditionTextBlock.TextFontFamily); + additionText.TextWrapping = TextWrapping.Wrap; + additionText.MultiLanguage = aItem.AdditionTextBlock.LanguageData; + additionText.DisplayLanguage = _target.DisplayLanguage; + } + switch (_target.TextPosition) + { + case TextPosition.Left: + baseTextGrid.Width = (_target.ItemWidth - aItem.DataParameter.Width) < 0 ? 0 : _target.ItemWidth - aItem.DataParameter.Width; + baseTextGrid.Height = _target.ItemHeight; + ItemStack.Orientation = Orientation.Horizontal; + textStack.HorizontalAlignment = HorizontalAlignment.Left; + textStack.VerticalAlignment = VerticalAlignment.Center; + break; + case TextPosition.Right: + baseTextGrid.Width = (_target.ItemWidth - aItem.DataParameter.Width) < 0 ? 0 : _target.ItemWidth - aItem.DataParameter.Width; + baseTextGrid.Height = _target.ItemHeight; + ItemStack.Orientation = Orientation.Horizontal; + textStack.HorizontalAlignment = HorizontalAlignment.Right; + textStack.VerticalAlignment = VerticalAlignment.Center; + break; + case TextPosition.Top: + baseTextGrid.Width = _target.ItemWidth; + baseTextGrid.Height = (_target.ItemHeight - aItem.DataParameter.Height) < 0 ? 0 : _target.ItemHeight - aItem.DataParameter.Height; + ItemStack.Orientation = Orientation.Vertical; + textStack.HorizontalAlignment = HorizontalAlignment.Center; + textStack.VerticalAlignment = VerticalAlignment.Bottom; + break; + case TextPosition.Bottom: + baseTextGrid.Width = _target.ItemWidth; + baseTextGrid.Height = (_target.ItemHeight - aItem.DataParameter.Height) < 0 ? 0 : _target.ItemHeight - aItem.DataParameter.Height; + ItemStack.Orientation = Orientation.Vertical; + textStack.HorizontalAlignment = HorizontalAlignment.Center; + textStack.VerticalAlignment = VerticalAlignment.Top; + break; + } + aItemButton.VerticalAlignment = VerticalAlignment.Center; + aItemButton.HorizontalAlignment = HorizontalAlignment.Center; + aItemButton.DataParameter = aItem; + aItemButton.DisplayLanguage = _target.DisplayLanguage; + aItemButton.BaseGrid = _target.BaseGrid; + aItemButton.ReciveElement = _target.ReciveElement; + aItemButton.ClickSend = !string.IsNullOrEmpty(_target.BaseGrid) + && !string.IsNullOrEmpty(_target.ReciveElement); + aItemButton.Name = string.Format("ButtonListItem{0}", itemCnt); + _target.ReregisterName(string.Format("ButtonListItem{0}", itemCnt), aItemButton); + ItemStack.Name = string.Format("ItemStack{0}", itemCnt); + _target.ReregisterName(string.Format("ItemStack{0}", itemCnt), ItemStack); + switch (_target.TextPosition) + { + case TextPosition.Left: + case TextPosition.Top: + textStack.Children.Add(baseText); + textStack.Children.Add(additionText); + baseTextGrid.Children.Add(textStack); + ItemStack.Children.Add(baseTextGrid); + ItemStack.Children.Add(aItemButton); + break; + case TextPosition.Right: + case TextPosition.Bottom: + ItemStack.Children.Add(aItemButton); + textStack.Children.Add(baseText); + textStack.Children.Add(additionText); + baseTextGrid.Children.Add(textStack); + ItemStack.Children.Add(baseTextGrid); + break; + default: + ItemStack.Children.Add(aItemButton); + break; + } + + RowStack.Children.Add(ItemStack); + + itemCnt++; + if (itemCnt % _target.ColumnCount == 0) + { + PageStak.Children.Add(RowGrid); + RowsCount++; + } + if (itemCnt % (_target.ColumnCount * _target.RowCount) == 0) + { + PageGrid.Children.Add(PageStak); + _target.MainStack.Children.Add(PageGrid); + PageCount++; + } + } + if (itemCnt % _target.ColumnCount != 0) + { + for (int i = 0; i < _target.ColumnCount - (itemCnt % _target.ColumnCount); i++) + { + var ItemStack = new StackPanel + { + Background = new SolidColorBrush(Colors.Transparent), + Width = _target.ItemWidth, + Height = _target.ItemHeight + }; + RowStack.Children.Add(ItemStack); + } + PageStak.Children.Add(RowGrid); + } + if (itemCnt % (_target.ColumnCount * _target.RowCount) != 0) + { + PageGrid.Children.Add(PageStak); + _target.MainStack.Children.Add(PageGrid); + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(_target, "ItemsButtonCreate()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// Events Set + /// + public void GridEventsSet() + { + try + { + MainGrid.PreviewMouseDown += Grid_PreviewMouseDown; + MainGrid.PreviewMouseUp += Grid_PreviewMouseUp; + foreach (Grid pageGrid in this.MainStack.Children) + { + + foreach (StackPanel aPageStack in pageGrid.Children) + { + foreach (Grid aRowGrid in aPageStack.Children) + { + foreach (StackPanel sRowStack in aRowGrid.Children) + { + foreach (StackPanel ItemStack in sRowStack.Children) + { + foreach (var aItem in ItemStack.Children) + { + if (aItem is AnimationButton ItemContent) + { + ItemContent.MouseClicked += ItemContent_MouseClicked; + ItemContent.CircleClicked += ItemContent_CircleClicked; + ItemContent.ItemDrop += ItemContent_ItemDrop; + ItemContent.SendStart += ItemContent_SendStart; + ItemContent.SendEnd += ItemContent_SendEnd; + } + } + } + + } + + } + } + + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GridEventsSet()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + + /// + /// Events Remove + /// + public void GridEventsRemove() + { + try + { + MainGrid.PreviewMouseDown -= Grid_PreviewMouseDown; + MainGrid.PreviewMouseUp -= Grid_PreviewMouseUp; + foreach (Grid pageGrid in this.MainStack.Children) + { + foreach (StackPanel aPageStack in pageGrid.Children) + { + foreach (Grid aRowGrid in aPageStack.Children) + { + foreach (StackPanel sRowStack in aRowGrid.Children) + { + foreach (StackPanel ItemStack in sRowStack.Children) + { + foreach (var aItem in ItemStack.Children) + { + if (aItem is AnimationButton ItemContent) + { + ItemContent.MouseClicked -= ItemContent_MouseClicked; + ItemContent.CircleClicked -= ItemContent_CircleClicked; + ItemContent.ItemDrop -= ItemContent_ItemDrop; + ItemContent.SendStart -= ItemContent_SendStart; + ItemContent.SendEnd -= ItemContent_SendEnd; + + } + } + ItemStack.Children.Clear(); + } + sRowStack.Children.Clear(); + } + aRowGrid.Children.Clear(); + } + aPageStack.Children.Clear(); + } + pageGrid.Children.Clear(); + + } + this.MainStack.Children.Clear(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GridEventsRemove()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// Set Button Parameter + /// + public void SetButtonParameter() + { + try + { + foreach (Grid pageGrid in this.MainStack.Children) + { + + foreach (StackPanel aPageStack in pageGrid.Children) + { + foreach (Grid aRowGrid in aPageStack.Children) + { + foreach (StackPanel sRowStack in aRowGrid.Children) + { + foreach (StackPanel ItemStack in sRowStack.Children) + { + foreach (var aItem in ItemStack.Children) + { + if (aItem is AnimationButton ItemContent) + { + ItemContent.ClickSend = this.ClickSend; + ItemContent.AutoToggle = this.AutoToggle; + ItemContent.DragEnable = this.DragEnable; + } + } + } + + } + + } + } + + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "SetButtonParameter()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + /// + /// PageChange + /// + /// + /// + public void ChangePageTo( int _toPageNo) + { + try + { + var fromOffset = 0d; + var toOffset = 0d; + var totalTime = 0.3; + if (this.MainStack.Orientation.Equals(Orientation.Horizontal)) + { + fromOffset = this.MainScroll.HorizontalOffset; + toOffset = this.Width * _toPageNo; + totalTime = Math.Abs(toOffset - fromOffset) / (this.Width) * totalTime; + + } + else + { + fromOffset = this.MainScroll.VerticalOffset; + toOffset = this.ItemHeight * this.RowCount * _toPageNo; + totalTime = Math.Abs(toOffset - fromOffset) / (this.ItemHeight * this.RowCount) * totalTime; + } + var scrollAnimation = Animations.GetScrollAnimation(this, this.MainStack.Orientation, fromOffset, toOffset, totalTime); + if (scrollAnimation != null) + { + scrollAnimation.Completed += ScrollAnimation_Completed; + scrollAnimation.Begin(); + } + TargetPageNo = _toPageNo; + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ChangePageTo()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + private void ScrollAnimation_Completed(object sender, EventArgs e) + { + var targetGrid = this.FindName(string.Format("PageGrid{0}", TargetPageNo)) ; + if (targetGrid is Grid selectGrid) + { + DefaultPageNo = TargetPageNo; + selectGrid.IsEnabled = true; + } + } + + #endregion Methods + + #region [ Event Handlers ] + private void ButtonList_Unloaded(object sender, RoutedEventArgs e) + { + this.MainStack.Children.Clear(); + this.ListItems = null; + } + private static void OnDisplayLanguageProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + try + { + if (e.NewValue != null && !e.NewValue.Equals(e.OldValue)) + { + var target = d as ButtonList; + foreach (Grid pageGrid in target.MainStack.Children) + { + foreach (StackPanel aPageStack in pageGrid.Children) + { + foreach (Grid aRowGrid in aPageStack.Children) + { + foreach (StackPanel sRowStack in aRowGrid.Children) + { + foreach (StackPanel ItemStack in sRowStack.Children) + { + foreach (var aItem in ItemStack.Children) + { + if (aItem is AnimationButton ItemContent) + { + ItemContent.DisplayLanguage = (SupportLanguageType)e.NewValue; + } + else if (aItem is Grid textGrid) + { + foreach (StackPanel textStack in textGrid.Children) + { + foreach (var aTextItem in textStack.Children) + { + if (aTextItem is MutiLanguageTextBlock textItem) + { + textItem.DisplayLanguage = (SupportLanguageType)e.NewValue; + + } + } + + } + } + } + } + + } + + } + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(d, "OnDisplayLanguageProperyChanged()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + private static void OnDefaultPageNoPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null) + { + + var target = d as ButtonList; + target.ChangePageTo((int)e.NewValue); + } + } + + private static void OnStackOrientationPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != e.OldValue) + { + var target = d as ButtonList; + target.MainStack.Orientation = (Orientation)e.NewValue; + switch ((Orientation)e.NewValue) + { + case Orientation.Horizontal: + target.MainScroll.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled; + target.MainScroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden; + break; + case Orientation.Vertical: + target.MainScroll.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden; + target.MainScroll.HorizontalScrollBarVisibility = ScrollBarVisibility.Disabled; + break; + } + } + } + + private static void OnHorizontalOffsetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != e.OldValue) + { + var target = d as ButtonList; + target.MainScroll.ScrollToHorizontalOffset((double)e.NewValue); + } + } + + private static void OnVerticalOffsetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != e.OldValue) + { + var target = d as ButtonList; + target.MainScroll.ScrollToVerticalOffset((double)e.NewValue); + } + } + + private static void OnListItemsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue!=null && !e.NewValue.Equals(e.OldValue)) + { + var target = d as ButtonList; + target.GridEventsRemove(); + ItemsButtonCreate(target, e.NewValue); + target.UpdateLayout(); + CommonFunction.ReregisterName(target.Parent as FrameworkElement, target.Name, target); + target.GridEventsSet(); + target.SetDefaultItem(target.DefaultIndex); + + } + } + private static void OnDefaultIndexPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as ButtonList; + if (!e.NewValue.Equals(e.OldValue)) + { + if (e.OldValue != null) + { + target.ResetDefaultItem((int)e.OldValue); + } + if (target.ListItems != null && target.ListItems.Count > 0 && (int)e.NewValue > -1) + { + target.SetDefaultItem((int)e.NewValue); + target.DefaultPageNo = (int)e.NewValue / (target.ColumnCount * target.RowCount); + } + } + } + private static void OnClickSendPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (!e.NewValue.Equals(e.OldValue)) + { + var target = d as ButtonList; + target.SetButtonParameter(); + } + } + private static void OnDragEnableProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (!e.NewValue.Equals(e.OldValue)) + { + var target = d as ButtonList; + target.SetButtonParameter(); + } + } + private static void OnAutoToggleProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (!e.NewValue.Equals(e.OldValue)) + { + var target = d as ButtonList; + target.SetButtonParameter(); + } + } + private static void OnSelectOnProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue !=null) + { + var target = d as ButtonList; + if (target.FindName(string.Format("ButtonListItem{0}", target.DefaultIndex)) is AnimationButton findItem) + { + findItem.Switch=(bool)e.NewValue; + } + + } + } + + private void Grid_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + var requstGrid = sender as Grid; + mouseDownXposition = e.GetPosition(sender as Grid).X; + mouseDownYposition = e.GetPosition(sender as Grid).Y; + MoseDown = true; + } + private void Grid_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + if (!MoseDown) return; + var requstGrid = sender as Grid; + var curMouseXposition = e.GetPosition(requstGrid).X; + var curMouseYposition = e.GetPosition(requstGrid).Y; + if (this.StackOrientation.Equals(Orientation.Horizontal)) + { + if (!mouseDownXposition.Equals(-1) && (mouseDownXposition - curMouseXposition) > 50) + { + if (this.DefaultPageNo < this.MainStack.Children.Count - 1) this.DefaultPageNo++; + } + else if (!mouseDownXposition.Equals(-1) && (mouseDownXposition - curMouseXposition) < -50) + { + if (this.DefaultPageNo > 0) this.DefaultPageNo--; + } + } + else + { + if (!mouseDownYposition.Equals(-1) && (mouseDownYposition - curMouseYposition) > 50) + { + if (this.DefaultPageNo < this.MainStack.Children.Count - 1) this.DefaultPageNo++; + } + else if (!mouseDownYposition.Equals(-1) && (mouseDownYposition - curMouseYposition) < -50) + { + if (this.DefaultPageNo > 0) this.DefaultPageNo--; + } + } + mouseDownXposition = curMouseXposition; + mouseDownYposition = curMouseYposition; + MoseDown = false; + } + + private void ItemContent_MouseClicked(object sender, RoutedEventArgs e) + { + RaiseMouseClickedEvent(e.OriginalSource); + } + private void ItemContent_CircleClicked(object sender, RoutedEventArgs e) + { + RaiseCircleClickedEvent(e.OriginalSource); + } + private void ItemContent_ItemDrop(object sender, RoutedEventArgs e) + { + RaiseItemDropEvent(e.OriginalSource); + } + private void ItemContent_SendEnd(object sender, RoutedEventArgs e) + { + this.IsEnabled = true; + } + + private void ItemContent_SendStart(object sender, RoutedEventArgs e) + { + this.IsEnabled = false; + } + + #endregion Event Handlers + } +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/IntroView.xaml b/Kiosk/Common/SPC.Kiosk.Common/Controls/IntroView.xaml new file mode 100644 index 0000000..d8bc431 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/IntroView.xaml @@ -0,0 +1,13 @@ + + + + + + diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/IntroView.xaml.cs b/Kiosk/Common/SPC.Kiosk.Common/Controls/IntroView.xaml.cs new file mode 100644 index 0000000..d57c419 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/IntroView.xaml.cs @@ -0,0 +1,229 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +namespace SPC.Kiosk.Common +{ + /// + /// IntroView.xaml에 대한 상호 작용 논리 + /// + public partial class IntroView : UserControl + { + #region [ Members ] + /// + /// Intro Items + /// + public static readonly DependencyProperty IntroItemsProperty = + DependencyProperty.Register(nameof(IntroItems), typeof(ObservableCollection), typeof(IntroView), new PropertyMetadata(null, new PropertyChangedCallback(OnIntroItemsPropertyChanged))); + /// + /// Click Command + /// + public static readonly DependencyProperty CommandProperty = + DependencyProperty.Register(nameof(Command), typeof(ICommand), typeof(IntroView), new UIPropertyMetadata(null)); + /// + /// Intro ITems + /// + public ObservableCollection IntroItems + { + get { return (ObservableCollection)GetValue(IntroItemsProperty); } + set { SetValue(IntroItemsProperty, value); } + } + /// + /// Click Commad + /// + public ICommand Command + { + get { return (ICommand)GetValue(CommandProperty); } + set { SetValue(CommandProperty, value); } + } + #region [ RoutedEvent 'MouseClicked' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent MouseClickedEvent = EventManager.RegisterRoutedEvent(nameof(MouseClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(IntroView)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler MouseClicked + { + add { AddHandler(MouseClickedEvent, value); } + remove { RemoveHandler(MouseClickedEvent, value); } + } + #endregion RoutedEvent 'MouseClicked' + + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public IntroView() + { + InitializeComponent(); + } + #endregion Ctor + + #region [ Methods ] + private void RaiseMouseClickedEvent(object _sender) + { + //Command Excute + if (Command != null && Command.CanExecute(_sender)) + { + Command.Execute(_sender); + } + RoutedEventArgs newEventArgs = new RoutedEventArgs(IntroView.MouseClickedEvent, _sender); + RaiseEvent(newEventArgs); + } + private void AddStack(StackPanel _targetStack, M_IntroItems _stackContents) + { + try + { + if (_stackContents.StackContents is List stackContents) + { + foreach (var aContents in stackContents) + { + var newName = string.Format("MediaRoll{0}_{1}", _stackContents.ItemsStack, stackContents.IndexOf(aContents)); + var newMediaRoll = new MediaRoll + { + Width = _stackContents.StackWidth, + ListMedia = new ObservableCollection(aContents.MediaRollItems) + }; + newMediaRoll.MouseClicked += NewMediaRoll_MouseClicked; + _targetStack.Children.Add(newMediaRoll); + this.ReregisterName(newName, newMediaRoll); + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "AddStack()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + private void RemoveStack(StackPanel _targetStack, M_IntroItems _stackContents) + { + try + { + if (_stackContents.StackContents is List stackContents) + { + foreach (var aContents in stackContents) + { + var oldName = string.Format("MediaRoll{0}_{1}", _stackContents.ItemsStack, stackContents.IndexOf(aContents)); + var oldMediaRoll = this.FindName(oldName); + if (oldMediaRoll is MediaRoll removeMedia) + { + removeMedia.MouseClicked -= NewMediaRoll_MouseClicked; + } + } + _targetStack.Children.Clear(); + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "RemoveStack()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + private void NewMediaRoll_MouseClicked(object sender, RoutedEventArgs e) + { + if (e.OriginalSource is FrameworkElement getElement) + { + if (getElement.Tag is M_MediaRollItem selectItem) + { + RaiseMouseClickedEvent(selectItem); + } + } + } + #endregion Methods + + #region [ Event Handlers ] + private static void OnIntroItemsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + try + { + var target = d as IntroView; + if (e.NewValue is ObservableCollection introItems && introItems.Count > 0) + { + if (e.OldValue is ObservableCollection oldIntroItems) + { + if (introItems.Count.Equals(1)) + { + target.RemoveStack(target.IntroMain, introItems.FirstOrDefault()); + + } + else if (introItems.Count.Equals(2)) + { + foreach (var aIntroItem in introItems) + { + var oldStack = target.FindName(string.Format("IntroStack{0}", introItems.IndexOf(aIntroItem))); + if (oldStack is StackPanel removeStack) + { + target.RemoveStack(removeStack, aIntroItem); + } + + } + target.IntroMain.Children.Clear(); + } + } + if (introItems.Count.Equals(1)) + { + target.IntroMain.Orientation = Orientation.Vertical; + target.AddStack(target.IntroMain, introItems.FirstOrDefault()); + + } + else if (introItems.Count.Equals(2)) + { + target.IntroMain.Orientation = Orientation.Horizontal; + foreach (var aIntroItem in introItems) + { + var newStackPanel = new StackPanel { Orientation = Orientation.Vertical }; + target.AddStack(newStackPanel, aIntroItem); + target.IntroMain.Children.Add(newStackPanel); + target.ReregisterName(string.Format("IntroStack{0}", introItems.IndexOf(aIntroItem)), newStackPanel); + } + } + } + else + { + if (e.OldValue is ObservableCollection oldIntroItems) + { + if (oldIntroItems.Count.Equals(1)) + { + target.RemoveStack(target.IntroMain, oldIntroItems.FirstOrDefault()); + + } + else if (oldIntroItems.Count.Equals(2)) + { + foreach (var aIntroItem in oldIntroItems) + { + var oldStack = target.FindName(string.Format("IntroStack{0}", oldIntroItems.IndexOf(aIntroItem))); + if (oldStack is StackPanel removeStack) + { + target.RemoveStack(removeStack, aIntroItem); + } + + } + target.IntroMain.Children.Clear(); + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(d, "OnIntroItemsPropertyChanged()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + #endregion Event Handlers + } +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/MediaPlayer.xaml b/Kiosk/Common/SPC.Kiosk.Common/Controls/MediaPlayer.xaml new file mode 100644 index 0000000..68da169 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/MediaPlayer.xaml @@ -0,0 +1,11 @@ + + + + + diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/MediaPlayer.xaml.cs b/Kiosk/Common/SPC.Kiosk.Common/Controls/MediaPlayer.xaml.cs new file mode 100644 index 0000000..c19f59b --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/MediaPlayer.xaml.cs @@ -0,0 +1,259 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; + +namespace SPC.Kiosk.Common +{ + /// + /// MediaPlayer.xaml에 대한 상호 작용 논리 + /// + public partial class MediaPlayer : UserControl + { + #region [ Members ] + private bool MoseDown = false; + private Point MoseDownPosition; + /// + /// Noraml Bakcground + /// + public static readonly DependencyProperty MediaFileProperty = + DependencyProperty.Register(nameof(MediaFile), typeof(string), typeof(MediaPlayer), new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnMediaFilePropertyChanged))); + /// + /// OD Repeat Flag + /// + public static readonly DependencyProperty RepeatMediaProperty = + DependencyProperty.Register(nameof(RepeatMedia), typeof(bool), typeof(MediaPlayer), new PropertyMetadata(false)); + /// + /// Play Media File (Path) + /// + public string MediaFile + { + get { return (string)GetValue(MediaFileProperty); } + set { SetValue(MediaFileProperty, value); } + } + /// + /// VOD Repeat Flag + /// + public bool RepeatMedia + { + get { return (bool)GetValue(RepeatMediaProperty); } + set { SetValue(RepeatMediaProperty, value); } + } + #endregion Members + + #region [ Ctor / Method ] + /// + /// Ctor + /// + public MediaPlayer() + { + InitializeComponent(); + this.VideoMediaPlayer.LoadedBehavior = MediaState.Manual; + this.VideoMediaPlayer.Loaded += VideoMediaPlayer_Loaded; + this.VideoMediaPlayer.MediaEnded += VideoMediaPlayer_MediaEnded; + this.VideoMediaPlayer.MouseUp += VideoMediaPlayer_MouseUp; + this.VideoMediaPlayer.MouseDown += VideoMediaPlayer_MouseDown; + this.VideoMediaPlayer.MouseLeave += VideoMediaPlayer_MouseLeave; + } + + ~MediaPlayer() + { + this.VideoMediaPlayer.Loaded -= VideoMediaPlayer_Loaded; + this.VideoMediaPlayer.MediaEnded -= VideoMediaPlayer_MediaEnded; + this.VideoMediaPlayer.MouseUp -= VideoMediaPlayer_MouseUp; + this.VideoMediaPlayer.MouseDown -= VideoMediaPlayer_MouseDown; + this.VideoMediaPlayer.MouseLeave -= VideoMediaPlayer_MouseLeave; + } + + /// + /// VOD Restart + /// + public void Restart() + { + try + { + this.VideoMediaPlayer.Stop(); + this.VideoMediaPlayer.Position = TimeSpan.Zero; + this.VideoMediaPlayer.Play(); + } + catch + { + } + } + /// + /// VOD Stop + /// + public void Stop() + { + try + { + this.VideoMediaPlayer.Stop(); + + } + catch + { + } + } + /// + /// VOD Play + /// + public void Play() + { + try + { + this.VideoMediaPlayer.Play(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "Play()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// VOD Pause + /// + public void Pause() + { + this.VideoMediaPlayer.Pause(); + } + + #endregion Ctor + + #region [ Events Create ] + + #region [ Make RoutedEvent 'MouseClicked'] + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent MouseClickedEvent = EventManager.RegisterRoutedEvent(nameof(MouseClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MediaPlayer)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler MouseClicked + { + add { AddHandler(MouseClickedEvent, value); } + remove { RemoveHandler(MouseClickedEvent, value); } + } + /// + /// Raise MouseClicked Event + /// + private void RaiseMouseClickedEvent(object source) + { + RoutedEventArgs newEventArgs = new RoutedEventArgs(MediaPlayer.MouseClickedEvent, source); + RaiseEvent(newEventArgs); + } + #endregion Make RoutedEvent 'MouseClicked' + + #region [ Make RoutedEvent 'MediaLoaded'] + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent MediaLoadedEvent = EventManager.RegisterRoutedEvent(nameof(MediaLoaded), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MediaPlayer)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler MediaLoaded + { + add { AddHandler(MediaLoadedEvent, value); } + remove { RemoveHandler(MediaLoadedEvent, value); } + } + /// + /// Raise MouseClicked Event + /// + private void RaiseMediaOpend(object source) + { + RoutedEventArgs newEventArgs = new RoutedEventArgs(MediaPlayer.MediaLoadedEvent,source); + RaiseEvent(newEventArgs); + } + #endregion Make RoutedEvent 'MediaLoaded' + + #endregion Events Create + + #region [ Evnets Handler ] + private static void OnMediaFilePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as MediaPlayer; + target.VideoMediaPlayer.Source = string.IsNullOrEmpty((string)e.NewValue) + ? null + : new Uri((string)e.NewValue); + } + + #region Mouse Events Handler + private void VideoMediaPlayer_MouseUp(object sender, MouseButtonEventArgs e) + { + if (MoseDown) + { + if (Math.Abs(e.GetPosition(this).X - MoseDownPosition.X) > 50) MoseDown = false; + if (Math.Abs(e.GetPosition(this).Y - MoseDownPosition.Y) > 50) MoseDown = false; + if (MoseDown) RaiseMouseClickedEvent(this); + MoseDown = false; + } + } + + private void VideoMediaPlayer_MouseDown(object sender, MouseButtonEventArgs e) + { + MoseDown = true; + MoseDownPosition = e.GetPosition(this); + } + + private void VideoMediaPlayer_MouseLeave(object sender, MouseEventArgs e) + { + MoseDown = false; + } + #endregion + + #region Player Events Handler + private void VideoMediaPlayer_Loaded(object sender, RoutedEventArgs e) + { + if (VideoMediaPlayer.Source is Uri) + { + + if (RepeatMedia) + { + if (VideoMediaPlayer.Source.AbsolutePath.ToLower().EndsWith(".gif")) + { + + VideoMediaPlayer.Position = TimeSpan.FromMilliseconds(1); + } + VideoMediaPlayer.Play(); + } + RaiseMediaOpend(e.OriginalSource); + } + } + + private void VideoMediaPlayer_MediaEnded(object sender, RoutedEventArgs e) + { + if (RepeatMedia) + { + if (VideoMediaPlayer.Source is Uri) + { + if (VideoMediaPlayer.Source.AbsolutePath.ToLower().EndsWith(".gif")) + { + + VideoMediaPlayer.Position = TimeSpan.FromMilliseconds(1); + } + else + { + VideoMediaPlayer.Position = TimeSpan.Zero; + } + VideoMediaPlayer.Play(); + } + + } + } + #endregion Player Events Handler + + #endregion Evnets Handler + } +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/MediaRoll.xaml b/Kiosk/Common/SPC.Kiosk.Common/Controls/MediaRoll.xaml new file mode 100644 index 0000000..cbf642c --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/MediaRoll.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/MediaRoll.xaml.cs b/Kiosk/Common/SPC.Kiosk.Common/Controls/MediaRoll.xaml.cs new file mode 100644 index 0000000..c70076c --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/MediaRoll.xaml.cs @@ -0,0 +1,302 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Collections.ObjectModel; +using System.IO; +using System.Windows.Threading; +namespace SPC.Kiosk.Common +{ + + /// + /// MediaRoll.xaml에 대한 상호 작용 논리 + /// + public partial class MediaRoll : UserControl + { + #region [ Members ] + /// + /// Media Info List + /// (ObservableCollection) + /// + public static readonly DependencyProperty ListMediaProperty = + DependencyProperty.Register(nameof(ListMedia), typeof(ObservableCollection), typeof(MediaRoll), new PropertyMetadata(null, new PropertyChangedCallback(OnListMediaProperty))); + /// + /// Command + /// + public static readonly DependencyProperty CommandProperty = + DependencyProperty.Register(nameof(Command), typeof(ICommand), typeof(MediaRoll), new UIPropertyMetadata(null)); + + private DispatcherTimer RollTimer; + + private int CurrentDisplayItem = 0; + /// + /// Media Info List + /// + public ObservableCollection ListMedia + { + get { return (ObservableCollection)GetValue(ListMediaProperty); } + set { SetValue(ListMediaProperty, value); } + } + /// + /// Command + /// + public ICommand Command + { + get { return (ICommand)GetValue(CommandProperty); } + set { SetValue(CommandProperty, value); } + } + #region [ RoutedEvent 'MouseClicked' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent MouseClickedEvent = EventManager.RegisterRoutedEvent(nameof(MouseClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MediaRoll)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler MouseClicked + { + add { AddHandler(MouseClickedEvent, value); } + remove { RemoveHandler(MouseClickedEvent, value); } + } + #endregion RoutedEvent 'MouseClicked' + + #endregion Members + + #region [ Ctor ] + /// + /// MediaRoll Ctor + /// + public MediaRoll() + { + InitializeComponent(); + RollTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(5) + }; + RollTimer.Tick += RollTimer_Tick; + } + #endregion Ctor + + #region [ Methods ] + /// + /// Add Media Control to MediaRollStack + /// + /// + /// + private void AddMedia(MediaRoll _target, M_MediaRollItem _aMedia) + { + try + { + switch (_aMedia.Type) + { + case MediaType.Image: + var imageGrid = new Grid(); + var aImage = new AnimationButton + { + NormalBrush = _aMedia.MediaPath, + DownBrush = _aMedia.MediaPath, + Width = _target.Width, + VerticalAlignment = VerticalAlignment.Top, + BrushStretch = Stretch.Fill, + ClickAnimationType = ButtonAnimationType.None, + Tag = _aMedia, + Name = string.Format("RollItemContent{0}", _target.MediaRollStack.Children.Count) + }; + aImage.MouseClicked += RollItemContent_MouseClick; + _target.ReregisterName(string.Format("RollItemContent{0}", _target.MediaRollStack.Children.Count), aImage); + imageGrid.Tag = _aMedia.RunnigSeconds; + imageGrid.IsEnabled = true; + imageGrid.Children.Add(aImage); + imageGrid.Name = string.Format("RollItem{0}", _target.MediaRollStack.Children.Count); + _target.ReregisterName(string.Format("RollItem{0}", _target.MediaRollStack.Children.Count), imageGrid); + _target.MediaRollStack.Children.Add(imageGrid); + break; + case MediaType.VOD: + var vodGrid = new Grid(); + var aVod = new MediaPlayer + { + MediaFile = _aMedia.MediaPath, + RepeatMedia = _aMedia.RepeatMedia, + Width = _target.Width, + Tag = _aMedia, + Name = string.Format("RollItemContent{0}", _target.MediaRollStack.Children.Count) + }; + aVod.MouseClicked += RollItemContent_MouseClick; + _target.ReregisterName(string.Format("RollItemContent{0}", _target.MediaRollStack.Children.Count), aVod); + vodGrid.Tag = _aMedia.RunnigSeconds; + vodGrid.IsEnabled = true; + vodGrid.Children.Add(aVod); + vodGrid.Name = string.Format("RollItem{0}", _target.MediaRollStack.Children.Count); + _target.ReregisterName(string.Format("RollItem{0}", _target.MediaRollStack.Children.Count), vodGrid); + _target.MediaRollStack.Children.Add(vodGrid); + break; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(_target, "AddMedia()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// Raise MouseClicked Event + /// + private void RaiseMouseClickedEvent(object _sender) + { + //Command Excute + if (Command != null && Command.CanExecute((_sender as FrameworkElement).Tag)) + { + Command.Execute((_sender as FrameworkElement).Tag); + } + RoutedEventArgs newEventArgs = new RoutedEventArgs(MediaRoll.MouseClickedEvent, _sender); + RaiseEvent(newEventArgs); + } + + #endregion Methods + + #region [ Event Handlers ] + private static void OnListMediaProperty(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as MediaRoll; + if (e.NewValue is ObservableCollection lstMedia) + { + target.MediaRollStack.Children.Clear(); + foreach (var aMedia in lstMedia) + { + if (File.Exists(aMedia.MediaPath)) target.AddMedia(target, aMedia); + } + if (target.MediaRollStack.Children.Count > 0) + { + var firstItem = target.FindName("RollItem0") as Grid; + var mediaObject = target.FindName(string.Format("RollItemContent{0}", 0)); + var mediaObjectType = mediaObject.GetType(); + if (mediaObject is MediaPlayer mediaPlayer) + { + mediaPlayer.Stop(); + mediaPlayer.Play(); + } + if (target.RollTimer != null) + { + target.RollTimer.Interval = TimeSpan.FromSeconds((double)firstItem.Tag); + target.RollTimer.Start(); + } + + } + } + } + + private void RollItemContent_MouseClick(object sender, RoutedEventArgs e) + { + RaiseMouseClickedEvent(e.OriginalSource); + } + + private void RollTimer_Tick(object sender, EventArgs e) + { + + try + { + RollTimer.Stop(); + if (this.MediaRollStack.Children.Count > 1) + { + var currentObject = this.MediaRollStack.Children[CurrentDisplayItem] as FrameworkElement; + bool Selected = false; + var targetIndex = CurrentDisplayItem + 1; + var mediaSourceObject = this.FindName(string.Format("RollItemContent{0}", CurrentDisplayItem)); + if (mediaSourceObject is MediaPlayer) + { + (mediaSourceObject as MediaPlayer).Stop(); + } + FrameworkElement targetObject = null; + object mediaObject = null; + while (!Selected) + { + if (targetIndex.Equals(this.MediaRollStack.Children.Count)) targetIndex = 0; + targetObject = this.MediaRollStack.Children[targetIndex] as FrameworkElement; + mediaObject = this.FindName(string.Format("RollItemContent{0}", targetIndex)); + var targetData = mediaObject is FrameworkElement selectObject ? selectObject.Tag : null; + if (targetData is M_MediaRollItem selectData) + { + var CurrentDateTime = DateTime.Now.TimeOfDay; + if (!(selectData.StartTime.Equals(default(TimeSpan)) || selectData.EndTime.Equals(default(TimeSpan)))) + { + if (selectData.StartTime <= CurrentDateTime && selectData.EndTime >= CurrentDateTime) + { + Selected = true; + break; + } + } + else + { + Selected = true; + break; + } + } + else + { + Selected = true; + break; + } + targetIndex++; + } + if (mediaObject is MediaPlayer playObject) + { + playObject.Stop(); + playObject.Play(); + } + if (!currentObject.Equals(targetObject)) + { + currentObject.IsEnabled = true; + targetObject.IsEnabled = false; + var targetAnimation = Animations.GetOpenAndCloseAnimation(currentObject, targetObject, OpenCloseAnimationType.GotoLeft, this.Width, 1, 0.3); + if (targetAnimation != null) + { + targetAnimation.Completed += TargetAnimation_Completed; + targetAnimation.Begin(); + } + } + else + { + RollTimer.Start(); + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "RollTimer_Tick()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + private void TargetAnimation_Completed(object sender, EventArgs e) + { + CurrentDisplayItem += 1; + if (CurrentDisplayItem.Equals(this.MediaRollStack.Children.Count)) + { + //(this.MediaRollStack.Children[CurrentDisplayItem] as FrameworkElement).Width = 0; + //(this.MediaRollStack.Children[0] as FrameworkElement).Width = this.Width; + CurrentDisplayItem = 0; + } + if (this.MediaRollStack.Children[CurrentDisplayItem] is FrameworkElement viewMedia) + { + viewMedia.IsEnabled = true; + if (this.RollTimer != null) + { + this.RollTimer.Interval = TimeSpan.FromSeconds((double)viewMedia.Tag); + this.RollTimer.Start(); + } + } + } + + + + #endregion Event Handlers + } +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/MessageBoxForm.xaml b/Kiosk/Common/SPC.Kiosk.Common/Controls/MessageBoxForm.xaml new file mode 100644 index 0000000..3b152d3 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/MessageBoxForm.xaml @@ -0,0 +1,116 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/MessageBoxForm.xaml.cs b/Kiosk/Common/SPC.Kiosk.Common/Controls/MessageBoxForm.xaml.cs new file mode 100644 index 0000000..872bb86 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/MessageBoxForm.xaml.cs @@ -0,0 +1,286 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Forms; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Threading; +using SPC.Kiosk.Base; +namespace SPC.Kiosk.Common +{ + /// + /// MessageBoxForm.xaml에 대한 상호 작용 논리 + /// + public partial class MessageBoxForm : Window + { + #region [ Members ] + private DispatcherTimer ShowTimer; + /// + /// MessageBox 응답 결과 + /// + public MessageBoxResult BoxResult { get; set; } + /// + /// MessageBox Button 구성 종류 + /// + public MessageBoxButton BoxButton { get; set; } + /// + /// MessageBox Open Animation Type + /// + public OpenCloseAnimationType BoxOpenAnimationType { get; set; } + /// + /// MessageBox Close Animation Type + /// + public OpenCloseAnimationType BoxCloseAnimationType { get; set; } + /// + /// 시작 종료 투명도 + /// + public double StartEndOpacity { get; set; } + /// + /// Animation 시강(초) + /// + public double AnimationSeconds { get; set; } + /// + /// 표시 대기 시간 (초) 0= 무한대 + /// + public double ShowWaitTime { get; set; } + private int ScreenNo { get; set; } + private Size PopupSize { get; set; } + + public SupportLanguageType LanguageType { get; set; } + #endregion Members + + #region [ Ctor / Etc ] + /// + /// MesssageBox 초기화 (for ShowMesssageBox) + /// + /// + /// + /// + /// + /// + /// + /// + /// + public MessageBoxForm(int _screenNo, + Size _size, + MessageBoxButton _boxButton, + OpenCloseAnimationType _openAnimationType , + OpenCloseAnimationType _closeAnimationType , + double _startEndOpacity , + double animationSeconds , + double _waitTime) + { + ScreenNo = _screenNo; + PopupSize = _size; + BoxButton = _boxButton; + BoxOpenAnimationType = _openAnimationType; + BoxCloseAnimationType = _closeAnimationType; + StartEndOpacity = _startEndOpacity; + AnimationSeconds = animationSeconds; + ShowWaitTime = _waitTime; + InitializeComponent(); + if (ShowWaitTime > 0) + { + ShowTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(ShowWaitTime), + IsEnabled = true + }; + ShowTimer.Tick += ShowTimer_Tick; + } + BaseInit(); + this.Yes_Button.MouseClicked += Yes_Button_MouseClicked; + this.No_Button.MouseClicked += No_Button_MouseClicked; + this.Cancel_Button.MouseClicked += Cancel_Button_MouseClicked; + } + /// + /// MesssageBox 초기화 (for TimeMesssageBox) + /// + /// + /// + /// + /// + /// + /// + /// + public MessageBoxForm(int _screenNo, + Size _size, + OpenCloseAnimationType _openAnimationType, + OpenCloseAnimationType _closeAnimationType, + double _startEndOpacity, + double animationSeconds, + double _waitTime) + { + ScreenNo = _screenNo; + PopupSize = _size; + BoxOpenAnimationType = _openAnimationType; + BoxCloseAnimationType = _closeAnimationType; + StartEndOpacity = _startEndOpacity; + AnimationSeconds = animationSeconds; + InitializeComponent(); + ShowWaitTime = _waitTime.Equals(0) ? 5 : _waitTime; + ShowTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(ShowWaitTime), + IsEnabled = false + }; + ShowTimer.Tick += ShowTimer_Tick; + BaseInit(); + this.ButtonStackHight.Height = new GridLength(0); + } + private void BaseInit() + { + this.Yes_Button.DisplayLanguage= CommonValue.CommonLanguageType; + this.No_Button.DisplayLanguage = CommonValue.CommonLanguageType; + this.Cancel_Button.DisplayLanguage = CommonValue.CommonLanguageType; + this.MessageHeader.DisplayLanguage = CommonValue.CommonLanguageType; + this.Message.DisplayLanguage = CommonValue.CommonLanguageType; + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = PopupSize.Width.Equals(0) ? Screen.AllScreens[ScreenNo].Bounds.Width : PopupSize.Width; + this.Height = PopupSize.Height.Equals(0) ? Screen.AllScreens[ScreenNo].Bounds.Height : PopupSize.Height; + this.IsEnabled = false; + this.Loaded += MessageBoxForm_Loaded; + } + #endregion Ctor / Etc + + #region [ Methods ] + private void CloseBase() + { + if (ShowTimer != null) + { + ShowTimer.Stop(); + ShowTimer.Tick -= ShowTimer_Tick; + ShowTimer = null; + } + this.Loaded -= MessageBoxForm_Loaded; + this.Yes_Button.MouseClicked -= Yes_Button_MouseClicked; + this.No_Button.MouseClicked -= No_Button_MouseClicked; + this.Cancel_Button.MouseClicked -= Cancel_Button_MouseClicked; + + if (!BoxCloseAnimationType.Equals(OpenCloseAnimationType.None)) + { + var animationVector = BoxCloseAnimationType.Equals(OpenCloseAnimationType.GotoLeft) || BoxCloseAnimationType.Equals(OpenCloseAnimationType.GotoRight) + ? this.BoxBase.Width : this.BoxBase.Height; + var CloseAnimation = Animations.GetCloseAnimation(this.BoxBase, BoxCloseAnimationType, animationVector, StartEndOpacity, AnimationSeconds); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + else + { + this.Close(); + } + } + + #endregion Methods + + #region [ Event Handlers ] + private void ShowTimer_Tick(object sender, EventArgs e) + { + ShowTimer.Stop(); + BoxResult = MessageBoxResult.None; + CloseBase(); + } + + private void MessageBoxForm_Loaded(object sender, RoutedEventArgs e) + { + if (!BoxOpenAnimationType.Equals(OpenCloseAnimationType.None)) + { + var animationVector = BoxOpenAnimationType.Equals(OpenCloseAnimationType.GotoLeft) || BoxOpenAnimationType.Equals(OpenCloseAnimationType.GotoRight) + ? this.BoxBase.Width : this.BoxBase.Height; + var OpenAnimations = Animations.GetOpenAnimation(this.BoxBase, BoxOpenAnimationType, animationVector, StartEndOpacity, AnimationSeconds); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Begin(); + } + } + else + { + if (ShowTimer != null) ShowTimer.Start(); + this.IsEnabled = true; + } + } + + private void OpenAnimations_Completed(object sender, EventArgs e) + { + if (ShowTimer != null) ShowTimer.Start(); + this.IsEnabled = true; + } + + private void CloseAnimation_Completed(object sender, EventArgs e) + { + + this.Close(); + } + + private void Cancel_Button_MouseClicked(object sender, RoutedEventArgs e) + { + if (ShowTimer != null) ShowTimer.Stop(); + switch (BoxButton) + { + case MessageBoxButton.OKCancel: + case MessageBoxButton.YesNoCancel: + BoxResult = MessageBoxResult.Cancel; + break; + default: + BoxResult = MessageBoxResult.None; + break; + } + this.Cancel_Button.Switch = true; + CloseBase(); + } + + private void No_Button_MouseClicked(object sender, RoutedEventArgs e) + { + if (ShowTimer != null) ShowTimer.Stop(); + switch (BoxButton) + { + case MessageBoxButton.YesNo: + case MessageBoxButton.YesNoCancel: + BoxResult = MessageBoxResult.No; + break; + default: + BoxResult = MessageBoxResult.None; + break; + } + this.No_Button.Switch = true; + CloseBase(); + } + + private void Yes_Button_MouseClicked(object sender, RoutedEventArgs e) + { + if (ShowTimer != null) ShowTimer.Stop(); + switch (BoxButton) + { + case MessageBoxButton.OK: + case MessageBoxButton.OKCancel: + BoxResult = MessageBoxResult.OK; + break; + case MessageBoxButton.YesNo: + case MessageBoxButton.YesNoCancel: + BoxResult = MessageBoxResult.Yes; + break; + default: + BoxResult = MessageBoxResult.None; + break; + } + this.Yes_Button.Switch = true; + CloseBase(); + } + + + #endregion Event Handlers + } +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/MutiLanguageTextBlock.cs b/Kiosk/Common/SPC.Kiosk.Common/Controls/MutiLanguageTextBlock.cs new file mode 100644 index 0000000..2c57dcb --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/MutiLanguageTextBlock.cs @@ -0,0 +1,214 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Threading; +using SPC.Kiosk.Base; +namespace SPC.Kiosk.Common +{ + /// + /// 다국어 지원 TextBlock + /// + public class MutiLanguageTextBlock : TextBlock + { + #region [ Members ] + /// + /// Muti Language Data + /// + public static readonly DependencyProperty MultiLanguageProperty = + DependencyProperty.Register(nameof(MultiLanguage), typeof(List), typeof(MutiLanguageTextBlock), new PropertyMetadata(default(List), new PropertyChangedCallback(OnMultiLanguagePropertyChanged))); + /// + /// Display Language + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(MutiLanguageTextBlock), new PropertyMetadata(SupportLanguageType.ko, new PropertyChangedCallback(OnDisplayLanguageProperyChanged))); + /// + /// Guid Text (if Show Text is empty) + /// + public static readonly DependencyProperty GuidTextProperty = + DependencyProperty.Register(nameof(GuidText), typeof(List), typeof(MutiLanguageTextBlock), new PropertyMetadata(default(List), new PropertyChangedCallback(OnGuidTextPropertyChanged))); + /// + /// Text Blinking Flag + /// + public static readonly DependencyProperty BlinkTextProperty = + DependencyProperty.Register(nameof(BlinkText), typeof(bool), typeof(MutiLanguageTextBlock), new PropertyMetadata(false, new PropertyChangedCallback(OnBlinkTextPropertyChanged))); + /// + /// Auto Text Trim + /// + public static readonly DependencyProperty AutoTextTrimProperty = + DependencyProperty.Register(nameof(AutoTextTrim), typeof(bool), typeof(MutiLanguageTextBlock), new PropertyMetadata(false, new PropertyChangedCallback(OnAutoTextTrimPropertyChanged))); + + ~MutiLanguageTextBlock() + { + if (this.BlickTimer != null) + { + this.BlickTimer.Stop(); + this.BlickTimer.Tick -= this.BlickTimer_Tick; + this.BlickTimer = null; + } + } + + /// + /// Blinking Timer + /// + public DispatcherTimer BlickTimer { get; protected set; } + public bool AutoTextTrim + { + get { return (bool)GetValue(AutoTextTrimProperty); } + set { SetValue(AutoTextTrimProperty, value); } + } + + /// + /// Text Blinking Flag + /// + public bool BlinkText + { + get { return (bool)GetValue(BlinkTextProperty); } + set { SetValue(BlinkTextProperty, value); } + } + /// + /// Guid Text (if Show Text is empty) + /// + public List GuidText + { + get { return (List)GetValue(GuidTextProperty); } + set { SetValue(GuidTextProperty, value); } + } + /// + /// Muti Language Data + /// + public List MultiLanguage + { + get { return (List)GetValue(MultiLanguageProperty); } + set { SetValue(MultiLanguageProperty, value); } + } + /// + /// Display Language + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + #endregion Members + + #region [ Methods ] + protected override void OnTextInput(TextCompositionEventArgs e) + { + base.OnTextInput(e); + if (string.IsNullOrEmpty(e.Text)) + { + var target = e.OriginalSource as MutiLanguageTextBlock; + target.Text = target.GuidText.GetLanguageData(target.DisplayLanguage); + } + } + private void AutoTextTrimming() + { + if (this.AutoTextTrim) + { + this.Text = this.Text.TextTrimming(this.DisplayLanguage + , this.FontSize + , this.FontFamily + , this.FontStyle + , this.FontWeight + , this.FontStretch + , this.Width); + } + } + #endregion Methods + + #region [ Event Handlers ] + private static void OnMultiLanguagePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null && !e.NewValue.Equals(e.OldValue)) + { + var target = d as MutiLanguageTextBlock; + target.Text = string.Empty; + if (e.NewValue is List multiLnaguage) + { + target.Text = multiLnaguage.GetLanguageData(target.DisplayLanguage); + target.AutoTextTrimming(); + } + + } + } + private static void OnBlinkTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (!e.NewValue.Equals(e.OldValue)) + { + var target = d as MutiLanguageTextBlock; + if ((bool)e.OldValue) + { + if (target.BlickTimer != null) + { + target.BlickTimer.Stop(); + target.BlickTimer = null; + } + } + if ((bool)e.NewValue) + { + target.BlickTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(0.5d), + }; + target.BlickTimer.Tick += target.BlickTimer_Tick; + target.BlickTimer.Start(); + } + } + } + + private void BlickTimer_Tick(object sender, EventArgs e) + { + BlickTimer.Stop(); + if (this.Visibility.Equals(Visibility.Visible)) + { + this.Visibility = Visibility.Hidden; + } + else + { + this.Visibility = Visibility.Visible; + } + BlickTimer.Start(); + } + + private static void OnGuidTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as MutiLanguageTextBlock; + if (e.NewValue is List guideText) + { + target.Text = guideText.GetLanguageData(target.DisplayLanguage); + target.AutoTextTrimming(); + } + } + private static void OnDisplayLanguageProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null && !e.NewValue.Equals(e.OldValue)) + { + var target = d as MutiLanguageTextBlock; + target.Text = string.Empty; + if (target.MultiLanguage is List multiLnaguage && e.NewValue is SupportLanguageType languageType) + { + target.Text = multiLnaguage.GetLanguageData(languageType); + target.AutoTextTrimming(); + } + } + } + private static void OnAutoTextTrimPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if ((bool)e.NewValue) + { + var target = d as MutiLanguageTextBlock; + target.AutoTextTrimming(); + + } + } + + #endregion Event Handlers + + } +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericCombo.xaml b/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericCombo.xaml new file mode 100644 index 0000000..2e8a434 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericCombo.xaml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericCombo.xaml.cs b/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericCombo.xaml.cs new file mode 100644 index 0000000..7eb961a --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericCombo.xaml.cs @@ -0,0 +1,649 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +namespace SPC.Kiosk.Common +{ + /// + /// NumericCombo.xaml에 대한 상호 작용 논리 + /// + public partial class NumericCombo : UserControl + { + + #region [ Members ] + /// + /// Text Backgroung Brush + /// + public static readonly DependencyProperty BackgroungBrushProperty = + DependencyProperty.Register(nameof(BackgroungBrush), typeof(string), typeof(NumericCombo), new PropertyMetadata("White", new PropertyChangedCallback(OnBackgroungBrushPropertyChanged))); + /// + /// Text Foregroung Brush + /// + public static readonly DependencyProperty ForegroungBrushProperty = + DependencyProperty.Register(nameof(ForegroungBrush), typeof(string), typeof(NumericCombo), new PropertyMetadata("Black", new PropertyChangedCallback(OnForegroungBrushPropertyChanged))); + /// + /// Selected Text BackgroundBrush + /// + public static readonly DependencyProperty SelectBackgroundBrushProperty = + DependencyProperty.Register(nameof(SelectBackgroundBrush), typeof(string), typeof(NumericCombo), new PropertyMetadata("DarkGray")); + /// + /// Selected Text ForegroundBrush + /// + public static readonly DependencyProperty SelectForegroundBrushProperty = + DependencyProperty.Register(nameof(SelectForegroundBrush), typeof(string), typeof(NumericCombo), new PropertyMetadata("Black")); + /// + /// Left Button AnimationButton Data + /// + public static readonly DependencyProperty LeftButtonDataProperty = + DependencyProperty.Register(nameof(LeftButtonData), typeof(M_AnimationButton), typeof(NumericCombo), new PropertyMetadata(null, new PropertyChangedCallback(OnLeftButtonDataPropertyChanged))); + /// + /// Right Button AnimationButton Data + /// + public static readonly DependencyProperty RightButtonDataProperty = + DependencyProperty.Register(nameof(RightButtonData), typeof(M_AnimationButton), typeof(NumericCombo), new PropertyMetadata(null, new PropertyChangedCallback(OnRightButtonDataPropertyChanged))); + /// + /// Min Value + /// + public static readonly DependencyProperty MinValueProperty = + DependencyProperty.Register(nameof(MinValue), typeof(int), typeof(NumericCombo), new PropertyMetadata(1, new PropertyChangedCallback(OnMinValuePropertyChanged))); + /// + /// Max Value + /// + public static readonly DependencyProperty MaxValueProperty = + DependencyProperty.Register(nameof(MaxValue), typeof(int), typeof(NumericCombo), new PropertyMetadata(4, new PropertyChangedCallback(OnMaxValuePropertyPropertyChanged))); + /// + /// Selected Value + /// + public static readonly DependencyProperty SelectedValueProperty = + DependencyProperty.Register(nameof(SelectedValue), typeof(int), typeof(NumericCombo), new PropertyMetadata(-1, new PropertyChangedCallback(OnSelectedValuePropertyChanged))); + /// + /// Value Step + /// + public static readonly DependencyProperty ValueStepProperty = + DependencyProperty.Register(nameof(ValueStep), typeof(int), typeof(NumericCombo), new PropertyMetadata(1, new PropertyChangedCallback(OnValueStepPropertyChanged))); + /// + /// Value List + /// + public static readonly DependencyProperty ValueListProperty = + DependencyProperty.Register(nameof(ValueList), typeof(List), typeof(NumericCombo), new PropertyMetadata(null, new PropertyChangedCallback(OnValueListPropertyChanged))); + /// + /// Drop Down Show Flag + /// + public static readonly DependencyProperty IsDropDownProperty = + DependencyProperty.Register(nameof(IsDropDown), typeof(bool), typeof(NumericCombo), new PropertyMetadata(false)); + /// + /// Show DropDown Item Count + /// + public static readonly DependencyProperty DropDownCountProperty = + DependencyProperty.Register(nameof(DropDownCount), typeof(int), typeof(NumericCombo), new PropertyMetadata(0, new PropertyChangedCallback(OnDropDownCountPropertyChanged))); + /// + /// Text FontSize + /// + public static readonly DependencyProperty TextFontSizeProperty = + DependencyProperty.Register(nameof(TextFontSize), typeof(double), typeof(NumericCombo), new PropertyMetadata(0d, new PropertyChangedCallback(OnTextFontSizePropertyChanged))); + /// + /// Text Width + /// + public static readonly DependencyProperty TextWidthProperty = + DependencyProperty.Register(nameof(TextWidth), typeof(double), typeof(NumericCombo), new PropertyMetadata(20d, new PropertyChangedCallback(OnTextWidthPropertyChanged))); + + + /// + /// Scroll Offset + /// + public static readonly DependencyProperty VerticalOffsetProperty = + DependencyProperty.Register(nameof(VerticalOffset), typeof(double), typeof(NumericCombo), new PropertyMetadata(0d, new PropertyChangedCallback(OnVerticalOffsetPropertyChanged))); + /// + /// Text Area Width + /// + public double TextWidth + { + get { return (double)GetValue(TextWidthProperty); } + set { SetValue(TextWidthProperty, value); } + } + /// + /// Text Area FontSize + /// + public double TextFontSize + { + get { return (double)GetValue(TextFontSizeProperty); } + set { SetValue(TextFontSizeProperty, value); } + } + /// + /// Scroll Offset + /// + public double VerticalOffset + { + get { return (double)GetValue(VerticalOffsetProperty); } + set { SetValue(VerticalOffsetProperty, value); } + } + /// + /// Show DropDown Item Count + /// + public int DropDownCount + { + get { return (int)GetValue(DropDownCountProperty); } + set { SetValue(DropDownCountProperty, value); } + } + /// + /// Drop Down Show Flag + /// + public bool IsDropDown + { + get { return (bool)GetValue(IsDropDownProperty); } + set { SetValue(IsDropDownProperty, value); } + } + /// + /// Value List + /// + public List ValueList + { + get { return (List)GetValue(ValueListProperty); } + set { SetValue(ValueListProperty, value); } + } + /// + /// Right Button AnimationButton Data + /// + public M_AnimationButton RightButtonData + { + get { return (M_AnimationButton)GetValue(RightButtonDataProperty); } + set { SetValue(RightButtonDataProperty, value); } + } + /// + /// Left Button AnimationButton Data + /// + public M_AnimationButton LeftButtonData + { + get { return (M_AnimationButton)GetValue(LeftButtonDataProperty); } + set { SetValue(LeftButtonDataProperty, value); } + } + /// + /// Min Value + /// + public int MinValue + { + get { return (int)GetValue(MinValueProperty); } + set { SetValue(MinValueProperty, value); } + } + /// + /// Max Value + /// + public int MaxValue + { + get { return (int)GetValue(MaxValueProperty); } + set { SetValue(MaxValueProperty, value); } + } + /// + /// Selected Value + /// + public int SelectedValue + { + get { return (int)GetValue(SelectedValueProperty); } + set + { + SetValue(SelectedValueProperty, value); + RaiseSelectChangeEvent(value); + } + } + /// + /// Value Step + /// + public int ValueStep + { + get { return (int)GetValue(ValueStepProperty); } + set { SetValue(ValueStepProperty, value); } + } + /// + /// Text ForegroungBrush + /// + public string ForegroungBrush + { + get { return (string)GetValue(ForegroungBrushProperty); } + set { SetValue(ForegroungBrushProperty, value); } + } + /// + /// Text BackgroungBrush + /// + public string BackgroungBrush + { + get { return (string)GetValue(BackgroungBrushProperty); } + set { SetValue(BackgroungBrushProperty, value); } + } + /// + /// Selected Text ForegroundBrush + /// + public string SelectForegroundBrush + { + get { return (string)GetValue(SelectForegroundBrushProperty); } + set { SetValue(SelectForegroundBrushProperty, value); } + } + /// + /// Selected Text BackgroundBrush + /// + public string SelectBackgroundBrush + { + get { return (string)GetValue(SelectBackgroundBrushProperty); } + set { SetValue(SelectBackgroundBrushProperty, value); } + } + + private double mouseDownYposition = -1; + private bool MoseDown = false; + private bool CurrentMoseDown = false; + #region [ RoutedEvent 'SelectChange' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent SelectChangeEvent = EventManager.RegisterRoutedEvent(nameof(SelectChange), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(NumericCombo)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler SelectChange + { + add { AddHandler(SelectChangeEvent, value); } + remove { RemoveHandler(SelectChangeEvent, value); } + } + #endregion RoutedEvent 'MouseClicked' + + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public NumericCombo() + { + InitializeComponent(); + this.NumericButtonCanvas.Visibility = Visibility.Collapsed; + this.NumericButtonStack.MouseDown += NumericButtonStack_MouseDown; + this.NumericButtonStack.MouseUp += NumericButtonStack_MouseUp; + this.LeftButton.MouseClicked += LeftButton_MouseClicked; + this.RightButton.MouseClicked += RightButton_MouseClicked; + this.CurrentNumberText.MouseDown += CurrentNumberText_MouseDown; + this.CurrentNumberText.MouseUp += CurrentNumberText_MouseUp; + } + #endregion Ctor + + #region [ Methods ] + private void RaiseSelectChangeEvent(object _sender) + { + RoutedEventArgs newEventArgs = new RoutedEventArgs(NumericCombo.SelectChangeEvent, _sender); + RaiseEvent(newEventArgs); + } + protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo) + { + this.LeftButton.Width = sizeInfo.NewSize.Height; + this.LeftButton.Height = sizeInfo.NewSize.Height; + this.RightButton.Width = sizeInfo.NewSize.Height; + this.RightButton.Height = sizeInfo.NewSize.Height; + SetNumericData(this); + base.OnRenderSizeChanged(sizeInfo); + + } + private static void SetNumericData(NumericCombo _target) + { + try + { + _target.CurrentNumberText.Width = _target.TextWidth; + _target.CurrentNumberText.Height = _target.Height; + if (_target.ValueList is List valueList) + { + _target.NumericButtonStack.Children.Clear(); + foreach (var i in valueList) + { + var newTextBlock = new TextBlock + { + Name = string.Format("NumberText{0}", i), + Text = i.ToString(), + Width = _target.CurrentNumberText.Width, + Height = _target.Height, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + TextAlignment = TextAlignment.Center, + FontSize = _target.TextFontSize, + FontWeight = _target.CurrentNumberText.FontWeight, + Foreground = _target.CurrentNumberText.Foreground, + + }; + _target.NumericButtonStack.Children.Add(newTextBlock); + _target.ReregisterName(string.Format("NumberText{0}", i), newTextBlock); + } + } + else if (_target.MaxValue > _target.MinValue && _target.MaxValue >= _target.ValueStep) + { + _target.NumericButtonStack.Children.Clear(); + for (int i = _target.MinValue; i <= _target.MaxValue; i += _target.ValueStep) + { + var newTextBlock = new TextBlock + { + Name = string.Format("NumberText{0}", i), + Text = i.ToString(), + Width = _target.CurrentNumberText.Width, + Height = _target.Height, + HorizontalAlignment = HorizontalAlignment.Center, + VerticalAlignment = VerticalAlignment.Center, + TextAlignment = TextAlignment.Center, + FontSize = _target.TextFontSize, + FontWeight = _target.CurrentNumberText.FontWeight, + Foreground = _target.CurrentNumberText.Foreground + + }; + _target.NumericButtonStack.Children.Add(newTextBlock); + _target.ReregisterName(string.Format("NumberText{0}", i), newTextBlock); + } + } + else + { + return; + } + _target.NumericButtonCanvas.Width = _target.CurrentNumberText.Width; + _target.NumericButtonCanvas.Height = _target.Height + * (_target.DropDownCount > 0 ? _target.DropDownCount + : _target.NumericButtonStack.Children.Count); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(_target, "SetNumericData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + + } + + #endregion Methods + + #region [ Event Handlers ] + private static void OnTextFontSizePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != e.OldValue) + { + var target = d as NumericCombo; + target.CurrentNumberText.FontSize = (double)e.NewValue; + } + } + private static void OnTextWidthPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != e.OldValue) + { + var target = d as NumericCombo; + target.CurrentNumberText.Width = (double)e.NewValue; + } + } + + private static void OnVerticalOffsetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != e.OldValue) + { + var target = d as NumericCombo; + target.NumericScroll.ScrollToVerticalOffset((double)e.NewValue); + } + } + private static void OnDropDownCountPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null && !e.NewValue.Equals(e.OldValue)) + { + var target = d as NumericCombo; + target.NumericButtonCanvas.Height = target.Height + * (target.DropDownCount > 0 ? target.DropDownCount + : target.NumericButtonStack.Children.Count); + } + } + + private static void OnValueListPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null && !e.NewValue.Equals(e.OldValue)) + { + var target = d as NumericCombo; + SetNumericData(target); + + } + } + private static void OnMinValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null && !e.NewValue.Equals(e.OldValue)) + { + var target = d as NumericCombo; + SetNumericData(target); + } + } + private static void OnMaxValuePropertyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null && !e.NewValue.Equals(e.OldValue)) + { + var target = d as NumericCombo; + SetNumericData(target); + } + } + private static void OnSelectedValuePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null && !e.NewValue.Equals(e.OldValue)) + { + var target = d as NumericCombo; + var selectValue = (int)e.NewValue; + if (selectValue >= target.MinValue && selectValue <= target.MaxValue) + { + target.CurrentNumberText.Text = selectValue.ToString(); + } + else + { + target.SelectedValue = (int)e.OldValue; + } + } + + } + private static void OnValueStepPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null && !e.NewValue.Equals(e.OldValue)) + { + var target = d as NumericCombo; + SetNumericData(target); + } + } + private static void OnRightButtonDataPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null && !e.NewValue.Equals(e.OldValue)) + { + var target = d as NumericCombo; + var newData = e.NewValue as M_AnimationButton; ; + target.Height = newData.Height; + target.RightButton.DataParameter = newData; + if (!target.Height.Equals(double.NaN)) + { + target.NumericStackGrid.Margin = new Thickness(0, target.Height, 0, 0); + SetNumericData(target); + } + } + } + private static void OnLeftButtonDataPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null && !e.NewValue.Equals(e.OldValue)) + { + var target = d as NumericCombo; + var newData = e.NewValue as M_AnimationButton; ; + target.Height = newData.Height; + target.LeftButton.DataParameter = newData; + if (!target.Height.Equals(double.NaN)) + { + target.NumericStackGrid.Margin = new Thickness(0, target.Height, 0, 0); + SetNumericData(target); + } + } + } + private static void OnForegroungBrushPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null && !e.NewValue.Equals(e.OldValue)) + { + var target = d as NumericCombo; + ResourceManager.SetBrush(target.CurrentNumberGrid, "Background", (string)e.NewValue); + SetNumericData(target); + } + } + private static void OnBackgroungBrushPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null && !e.NewValue.Equals(e.OldValue)) + { + var target = d as NumericCombo; + ResourceManager.SetBrush(target.CurrentNumberGrid, "Background", (string)e.NewValue, Stretch.Fill); + ResourceManager.SetBrush(target.NumericButtonCanvas, "Background", (string)e.NewValue, Stretch.Fill); + } + } + private void CurrentNumberText_MouseDown(object sender, MouseButtonEventArgs e) + { + CurrentMoseDown = true; + } + + private void CurrentNumberText_MouseUp(object sender, MouseButtonEventArgs e) + { + if (!CurrentMoseDown) return; + if (sender is TextBlock currentText) + { + if (this.NumericButtonCanvas.Visibility.Equals(Visibility.Visible)) + { + this.NumericButtonCanvas.Visibility = Visibility.Collapsed; + } + else + { + if (this.IsDropDown) + { + this.NumericButtonCanvas.Visibility = Visibility.Visible; + foreach (var aNumber in this.NumericButtonStack.Children) + { + var findNumber = aNumber as TextBlock; + + if (aNumber != null) + { + if (aNumber != null && findNumber.Text.Equals(this.CurrentNumberText.Text)) + { + ResourceManager.SetBrush(findNumber, "Background", this.SelectBackgroundBrush); + ResourceManager.SetBrush(findNumber, "Foreground", this.SelectForegroundBrush); + } + else + { + ResourceManager.SetBrush(findNumber, "Background", this.BackgroungBrush); + ResourceManager.SetBrush(findNumber, "Foreground", this.ForegroungBrush); + } + } + } + } + } + } + CurrentMoseDown = false; + } + private void NumericButtonStack_MouseDown(object sender, MouseButtonEventArgs e) + { + if (sender is StackPanel numStack) + { + mouseDownYposition = e.GetPosition(numStack).Y; + MoseDown = true; + } + } + private void NumericButtonStack_MouseUp(object sender, MouseButtonEventArgs e) + { + if (sender is StackPanel numStack) + { + if (!MoseDown) return; + var curMouseYposition = e.GetPosition(numStack).Y; + var fromOffset = this.NumericScroll.VerticalOffset; + var toOffset = 0d; + var totalTime = 0.3; + Storyboard scrollAnimation = null; + if (!mouseDownYposition.Equals(-1) && (mouseDownYposition - curMouseYposition) > 14) + { + if (this.DropDownCount > 0 && this.NumericButtonStack.Children.Count > this.DropDownCount) + { + toOffset = fromOffset + this.CurrentNumberText.Height * DropDownCount; + scrollAnimation = Animations.GetScrollAnimation(this, Orientation.Vertical, fromOffset, toOffset, totalTime); + } + + } + else if (!mouseDownYposition.Equals(-1) && (mouseDownYposition - curMouseYposition) < -14) + { + if (this.DropDownCount > 0 && this.NumericButtonStack.Children.Count > this.DropDownCount) + { + toOffset = fromOffset - this.CurrentNumberText.Height * DropDownCount; + scrollAnimation = Animations.GetScrollAnimation(this, Orientation.Vertical, fromOffset, toOffset, totalTime); + + } + } + else + { + foreach (var aNumber in numStack.Children) + { + if (aNumber is TextBlock findNumber && findNumber.IsMouseOver) + { + var findIndex = this.NumericButtonStack.Children.IndexOf(findNumber); + this.SelectedValue = int.Parse(findNumber.Text); + this.NumericScroll.ScrollToVerticalOffset(findIndex * this.CurrentNumberText.Height); + this.NumericButtonCanvas.Visibility = Visibility.Collapsed; + break; + } + } + } + mouseDownYposition = curMouseYposition; + MoseDown = false; + if (scrollAnimation != null) + { + scrollAnimation.Begin(); + } + } + } + + + private void RightButton_MouseClicked(object sender, RoutedEventArgs e) + { + if (sender is AnimationButton rightButton) + { + foreach (var aNumber in this.NumericButtonStack.Children) + { + if (aNumber is TextBlock findNumber) + { + if (findNumber.Text.Equals(this.CurrentNumberText.Text)) + { + var findIndex = this.NumericButtonStack.Children.IndexOf(findNumber); + if (findIndex < this.NumericButtonStack.Children.Count - 1) + { + this.SelectedValue = int.Parse((this.NumericButtonStack.Children[findIndex + 1] as TextBlock).Text); + this.NumericScroll.ScrollToVerticalOffset((findIndex + 1) * this.CurrentNumberText.Height); + break; + } + } + } + } + } + this.NumericButtonCanvas.Visibility = Visibility.Collapsed; + } + private void LeftButton_MouseClicked(object sender, RoutedEventArgs e) + { + if (sender is AnimationButton LeftButton) + { + foreach (var aNumber in this.NumericButtonStack.Children) + { + if (aNumber is TextBlock findNumber) + { + if (findNumber.Text.Equals(this.CurrentNumberText.Text)) + { + var findIndex = this.NumericButtonStack.Children.IndexOf(findNumber); + if (findIndex > 0) + { + this.SelectedValue = int.Parse((this.NumericButtonStack.Children[findIndex - 1] as TextBlock).Text); + this.NumericScroll.ScrollToVerticalOffset((findIndex -1) * this.CurrentNumberText.Height); + break; + } + } + } + } + } + this.NumericButtonCanvas.Visibility = Visibility.Collapsed; + } + #endregion Event Handlers + } +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericPad.xaml b/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericPad.xaml new file mode 100644 index 0000000..88f0ccc --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericPad.xaml @@ -0,0 +1,239 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericPad.xaml.cs b/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericPad.xaml.cs new file mode 100644 index 0000000..39cc24e --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericPad.xaml.cs @@ -0,0 +1,671 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +namespace SPC.Kiosk.Common +{ + /// + /// NumericPad.xaml에 대한 상호 작용 논리 + /// + public partial class NumericPad : UserControl + { + #region [ Members ] + /// + /// Noraml Bakcground + /// + public static readonly DependencyProperty NormalBrushProperty = + DependencyProperty.Register(nameof(NormalBrush), typeof(string), typeof(NumericPad), new PropertyMetadata("White", new PropertyChangedCallback(OnNormalBrushPropertyChanged))); + /// + /// Touch Down Bakcground + /// + public static readonly DependencyProperty DownBrushProperty = + DependencyProperty.Register(nameof(DownBrush), typeof(string), typeof(NumericPad), new PropertyMetadata("DarkGray")); + /// + /// Cancel Noraml Bakcground + /// + public static readonly DependencyProperty CancelNormalBrushProperty = + DependencyProperty.Register(nameof(CancelNormalBrush), typeof(string), typeof(NumericPad), new PropertyMetadata("DarkRed")); + /// + /// Cancel Down Bakcground + /// + public static readonly DependencyProperty CancelDownBrushProperty = + DependencyProperty.Register(nameof(CancelDownBrush), typeof(string), typeof(NumericPad), new PropertyMetadata("DarkGray")); + /// + /// Ok Noraml Bakcground + /// + public static readonly DependencyProperty OkNormalBrushProperty = + DependencyProperty.Register(nameof(OkNormalBrush), typeof(string), typeof(NumericPad), new PropertyMetadata("LightBlue")); + /// + /// Ok Down Bakcground + /// + public static readonly DependencyProperty OkDownBrushProperty = + DependencyProperty.Register(nameof(OkDownBrush), typeof(string), typeof(NumericPad), new PropertyMetadata("DarkRed")); + /// + /// Ok Disable Bakcground + /// + public static readonly DependencyProperty OkDisableBrushProperty = + DependencyProperty.Register(nameof(OkDisableBrush), typeof(string), typeof(NumericPad), new PropertyMetadata("Gray")); + /// + /// Ok Switch Enable Background + /// + public static readonly DependencyProperty OkSwitchOnBrushProperty = + DependencyProperty.Register(nameof(OkSwitchOnBrush), typeof(string), typeof(NumericPad), new PropertyMetadata("LightBlue")); + /// + /// Click Animation Type + /// + public static readonly DependencyProperty ClickAnimationTypeProperty = + DependencyProperty.Register(nameof(ClickAnimationType), typeof(ButtonAnimationType), typeof(NumericPad), new PropertyMetadata(ButtonAnimationType.None)); + /// + /// Button Text Foreground + /// + public static readonly DependencyProperty TextForegroundProperty = + DependencyProperty.Register(nameof(TextForeground), typeof(string), typeof(NumericPad), new PropertyMetadata("Black", new PropertyChangedCallback(OnTextForegroundPropertyChanged))); + /// + /// Cancel & Back Button Foreground + /// + public static readonly DependencyProperty CancelForegroundProperty = + DependencyProperty.Register(nameof(CancelForeground), typeof(string), typeof(NumericPad), new PropertyMetadata("White")); + /// + /// Input Text + /// + public static readonly DependencyProperty InputTextProperty = + DependencyProperty.Register(nameof(InputText), typeof(string), typeof(NumericPad), new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnInputTextPropertyChanged))); + /// + /// Show Text With Mask + /// + public static readonly DependencyProperty ShowTextProperty = + DependencyProperty.Register(nameof(ShowText), typeof(string), typeof(NumericPad), new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnShowTextPropertyChanged))); + /// + /// Text Area Visible + /// + public static readonly DependencyProperty TextVisibleProperty = + DependencyProperty.Register(nameof(TextVisibility), typeof(Visibility), typeof(NumericPad), new PropertyMetadata(Visibility.Visible)); + /// + /// Guid Text (Mutil Language) + /// + public static readonly DependencyProperty GuidTextProperty = + DependencyProperty.Register(nameof(GuidText), typeof(List), typeof(NumericPad), new PropertyMetadata(default(List))); + /// + /// Cancel Text + /// + public static readonly DependencyProperty CancelTextProperty = + DependencyProperty.Register(nameof(CancelText), typeof(string), typeof(NumericPad), new PropertyMetadata("Cancel", new PropertyChangedCallback(OnCancelTextPropertyChanged))); + /// + /// Cancel Text (Mutil Language) + /// + public static readonly DependencyProperty CancelLanguageTextProperty = + DependencyProperty.Register(nameof(CancelLanguageText), typeof(List), typeof(NumericPad), new PropertyMetadata(default(List), new PropertyChangedCallback(OnCancelLanguageTextPropertyChanged))); + /// + /// Ok Text + /// + public static readonly DependencyProperty OkTextProperty = + DependencyProperty.Register(nameof(OkText), typeof(string), typeof(NumericPad), new PropertyMetadata("OK", new PropertyChangedCallback(OnOkTextPropertyChanged))); + /// + /// Ok Text (Mutil Language) + /// + public static readonly DependencyProperty OkLanguageTextProperty = + DependencyProperty.Register(nameof(OkLanguageText), typeof(List), typeof(NumericPad), new PropertyMetadata(default(List), new PropertyChangedCallback(OnOkLanguageTextPropertyChanged))); + /// + /// Display Language Type + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(NumericPad), new PropertyMetadata(SupportLanguageType.ko, new PropertyChangedCallback(OnDisplayLanguageProperyChanged))); + /// + /// Ok Button Enabled + /// + public static readonly DependencyProperty OkEnabledProperty = + DependencyProperty.Register(nameof(OkEnabled), typeof(bool), typeof(NumericPad), new PropertyMetadata(false)); + /// + /// Etc Button Text + /// + public static readonly DependencyProperty EtcTextProperty = + DependencyProperty.Register(nameof(EtcText), typeof(string), typeof(NumericPad), new PropertyMetadata("00", new PropertyChangedCallback(OnEtcTextPropertyChanged))); + /// + /// OkCommand (parameter this Object) + /// + public static readonly DependencyProperty OkCommandProperty = + DependencyProperty.Register(nameof(OkCommand), typeof(ICommand), typeof(NumericPad), new UIPropertyMetadata(null)); + /// + /// Cancel Command (parameter this Object) + /// + public static readonly DependencyProperty CancelCommandProperty = + DependencyProperty.Register(nameof(CancelCommand), typeof(ICommand), typeof(NumericPad), new UIPropertyMetadata(null)); + /// + /// OkCommand + /// + public ICommand OkCommand + { + get { return (ICommand)GetValue(OkCommandProperty); } + set { SetValue(OkCommandProperty, value); } + } + /// + /// Cancel Command + /// + public ICommand CancelCommand + { + get { return (ICommand)GetValue(CancelCommandProperty); } + set { SetValue(CancelCommandProperty, value); } + } + /// + /// Text Area Visibility + /// + public Visibility TextVisibility + { + get { return (Visibility)GetValue(TextVisibleProperty); } + set { SetValue(TextVisibleProperty, value); } + } + /// + /// Etc Button Text + /// + public string EtcText + { + get { return (string)GetValue(EtcTextProperty); } + set { SetValue(EtcTextProperty, value); } + } + /// + /// Input Text (Real Data) + /// + public string InputText + { + get { return (string)GetValue(InputTextProperty); } + set { SetValue(InputTextProperty, value); } + } + /// + /// Show Text With Mask + /// + public string ShowText + { + get { return (string)GetValue(ShowTextProperty); } + set { SetValue(ShowTextProperty, value); } + } + /// + /// Guid Text (Multi Language) + /// + public List GuidText + { + get { return (List)GetValue(GuidTextProperty); } + set { SetValue(GuidTextProperty, value); } + } + /// + /// Display Language Type + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + /// + /// Ok Button Enabled + /// + public bool OkEnabled + { + get { return (bool)GetValue(OkEnabledProperty); } + set { SetValue(OkEnabledProperty, value); } + } + /// + /// Cancel Text + /// + public string CancelText + { + get { return (string)GetValue(CancelTextProperty); } + set { SetValue(CancelTextProperty, value); } + } + /// + /// Cancel Text (Multi Language) + /// + public List CancelLanguageText + { + get { return (List)GetValue(CancelLanguageTextProperty); } + set { SetValue(CancelLanguageTextProperty, value); } + } + /// + /// Ok Text + /// + public string OkText + { + get { return (string)GetValue(OkTextProperty); } + set { SetValue(OkTextProperty, value); } + } + /// + /// Ok Text (Multi Language) + /// + public List OkLanguageText + { + get { return (List)GetValue(OkLanguageTextProperty); } + set { SetValue(OkLanguageTextProperty, value); } + } + /// + /// Noraml Bakcground + /// + public string NormalBrush + { + get { return (string)GetValue(NormalBrushProperty); } + set { SetValue(NormalBrushProperty, value); } + } + /// + /// Mouse/Touch Down Bakcground + /// + public string DownBrush + { + get { return (string)GetValue(DownBrushProperty); } + set { SetValue(DownBrushProperty, value); } + } + /// + /// Cancel Button NormalBrush + /// + public string CancelNormalBrush + { + get { return (string)GetValue(CancelNormalBrushProperty); } + set { SetValue(CancelNormalBrushProperty, value); } + } + /// + /// Mouse/Touch Down Bakcground + /// + public string CancelDownBrush + { + get { return (string)GetValue(CancelDownBrushProperty); } + set { SetValue(CancelDownBrushProperty, value); } + } + /// + /// OK Button NormalBrush + /// + public string OkNormalBrush + { + get { return (string)GetValue(OkNormalBrushProperty); } + set { SetValue(OkNormalBrushProperty, value); } + } + /// + /// Mouse/Touch Down Bakcground + /// + public string OkDownBrush + { + get { return (string)GetValue(OkDownBrushProperty); } + set { SetValue(OkDownBrushProperty, value); } + } + /// + /// Ok Button DisableBrush + /// + public string OkDisableBrush + { + get { return (string)GetValue(OkDisableBrushProperty); } + set { SetValue(OkDisableBrushProperty, value); } + } + + /// + /// Ok Switch Enable Background + /// + public string OkSwitchOnBrush + { + get { return (string)GetValue(OkSwitchOnBrushProperty); } + set { SetValue(OkSwitchOnBrushProperty, value); } + } + /// + /// Button Animation Type + /// + public ButtonAnimationType ClickAnimationType + { + get { return (ButtonAnimationType)GetValue(ClickAnimationTypeProperty); } + set { SetValue(ClickAnimationTypeProperty, value); } + } + /// + /// Button Text Foreground + /// + public string TextForeground + { + get { return (string)GetValue(TextForegroundProperty); } + set { SetValue(TextForegroundProperty, value); } + } + /// + /// Cancel Button Foreground + /// + public string CancelForeground + { + get { return (string)GetValue(CancelForegroundProperty); } + set { SetValue(CancelForegroundProperty, value); } + } + #endregion Members + + #region [ Ctor/Etc ] + /// + /// Ctor + /// + public NumericPad() + { + InitializeComponent(); + + foreach (var aElement in this.BaseGrid.Children) + { + if (aElement is AnimationButton aNumberButton) + { + aNumberButton.MouseClicked += NumberButton_MouseClicked; + } + } + } + + #endregion Ctor + + #region [ Methods ] + + private void SetShowText(string _showText) + { + string displayText = _showText; + if (!string.IsNullOrEmpty(displayText)) + { + if (displayText.Length <11) + { + //pass + } + else if (displayText.Length.Equals(11)) + { + var displayChars = displayText.ToCharArray(); + displayText = string.Empty; + for (int i = 0; i < displayChars.Length; i++) + { + if (i > 2 && i < 7) + { + displayText += '*'; + } + else + { + displayText += displayChars[i]; + } + } + } + else if (displayText.Length < 17) + { + var displayChars = displayText.ToCharArray(); + displayText = string.Empty; + for (int i = 0; i < displayChars.Length; i++) + { + if (i > 5 && i < 14) + { + displayText += '*'; + } + else + { + displayText += displayChars[i]; + } + } + + } + else + { + var displayChars = displayText.ToCharArray(); + displayText = string.Empty; + for (int i = 0; i < displayChars.Length; i++) + { + if (i > 3 && i < 16) + { + displayText += '*'; + } + else + { + displayText += displayChars[i]; + } + } + } + string formatedString = string.Empty; + + if (displayText.Length.Equals(11)) + { + formatedString = string.Format("{0}-{1}-{2}" + , displayText.Substring(0, 3) + , displayText.Substring(3, 4) + , displayText.Substring(7, 4)); + } + else if (displayText.Length.Equals(16)) + { + formatedString = string.Format("{0}-{1}-{2}-{3}" + , displayText.Substring(0, 4) + , displayText.Substring(4, 4) + , displayText.Substring(8, 4) + , displayText.Substring(12, 4)); + } + else if (displayText.Length.Equals(20)) + { + formatedString = string.Format("{0}-{1}-{2}-{3}-{4}" + , displayText.Substring(0, 4) + , displayText.Substring(4, 4) + , displayText.Substring(8, 4) + , displayText.Substring(12, 4) + , displayText.Substring(16, 4)); + } + if (!string.IsNullOrEmpty(formatedString)) displayText = formatedString; + + } + if (string.IsNullOrEmpty(displayText)) + { + + this.ShowText = this.GuidText.GetLanguageData(this.DisplayLanguage); + this.OkEnabled = false; + } + else + { + this.ShowText = displayText; + this.OkEnabled = true; + } + } + private double SetEtcTextFontSize(AnimationButton _target, string _text) + { + double result = 20d; + try + { + var textLength = string.IsNullOrEmpty(_text.Trim()) ? 1 : _text.Trim().Length; + var fontSize = 0d; + switch (textLength) + { + case 1: + case 2: + fontSize = 0.7; + break; + case 3: + fontSize = 0.5; + break; + case 4: + fontSize = 0.45; + break; + default: + fontSize = 0.40; + break; + } + result = _target.ActualHeight > 0 ? _target.ActualHeight * fontSize : 20d; + + } + catch + { + result = 20d; + } + return result; + } + #endregion Methods + + #region [ Event Handlers ] + private static void OnNormalBrushPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null ) + { + var target = d as NumericPad; + ResourceManager.SetBrush(target.ShowDataGrid, "Background", (string)e.NewValue); + } + } + private static void OnTextForegroundPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null ) + { + var target = d as NumericPad; + ResourceManager.SetBrush(target.ShowData, "Foreground", (string)e.NewValue); + } + } + private static void OnEtcTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null ) + { + var target = d as NumericPad; + var aElement = target.BaseGrid.FindName("ButtonEtc"); + if (aElement is AnimationButton aNumberButton) + { + //aNumberButton.Text = (string)e.NewValue; + var newFontSize = target.SetEtcTextFontSize(aNumberButton, (string)e.NewValue); + if (!newFontSize.Equals(20)) target.ButtonEtc.TextFontSize = newFontSize; + + } + } + } + private static void OnCancelTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null ) + { + var target = d as NumericPad; + var aElement = target.BaseGrid.FindName("ButtonCancel"); + if (aElement is AnimationButton aNumberButton) + { + var newFontSize = target.SetEtcTextFontSize(aNumberButton, (string)e.NewValue); + if (newFontSize < target.ButtonOK.TextFontSize) + { + target.ButtonOK.TextFontSize = newFontSize; + target.ButtonCancel.TextFontSize = newFontSize; + } + } + + } + } + private static void OnCancelLanguageTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null ) + { + var target = d as NumericPad; + var aElement = target.BaseGrid.FindName("ButtonCancel"); + if (aElement is AnimationButton aNumberButton) + { + var newFontSize = target.SetEtcTextFontSize(aNumberButton + ,((List)e.NewValue).GetLanguageData(target.DisplayLanguage)); + if (newFontSize < target.ButtonOK.TextFontSize) + { + target.ButtonOK.TextFontSize = newFontSize; + target.ButtonCancel.TextFontSize = newFontSize; + } + } + } + } + private static void OnOkTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null ) + { + var target = d as NumericPad; + var aElement = target.BaseGrid.FindName("ButtonOK"); + if (aElement is AnimationButton aNumberButton) + { + var newFontSize = target.SetEtcTextFontSize(aNumberButton, (string)e.NewValue); + if (newFontSize < target.ButtonCancel.TextFontSize) + { + target.ButtonOK.TextFontSize = newFontSize; + target.ButtonCancel.TextFontSize = newFontSize; + } + } + } + } + private static void OnOkLanguageTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null ) + { + var target = d as NumericPad; + var aElement = target.BaseGrid.FindName("ButtonOK"); + if (aElement is AnimationButton aNumberButton) + { + var newFontSize = target.SetEtcTextFontSize(aNumberButton + , ((List)e.NewValue).GetLanguageData(target.DisplayLanguage)); + if (newFontSize < target.ButtonCancel.TextFontSize) + { + target.ButtonOK.TextFontSize = newFontSize; + target.ButtonCancel.TextFontSize = newFontSize; + } + } + } + } + private static void OnDisplayLanguageProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null ) + { + var target = d as NumericPad; + foreach (var aElement in target.BaseGrid.Children) + { + if (aElement is AnimationButton aNumberButton + && (aNumberButton.Name.StartsWith("ButtonOK") + || aNumberButton.Name.StartsWith("ButtonCancel")) + ) + { + aNumberButton.DisplayLanguage = (SupportLanguageType)e.NewValue; + } + } + target.SetShowText(target.InputText); + } + } + private static void OnInputTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as NumericPad; + var inputText = (string)e.NewValue; + target.SetShowText(inputText); + } + private static void OnShowTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as NumericPad; + var showText = (string)e.NewValue; + target.ShowData.Text = showText; + + } + private void NumberButton_MouseClicked(object sender, RoutedEventArgs e) + { + if (sender is AnimationButton aNumberButton) + { + switch (aNumberButton.Name) + { + case nameof(ButtonOK): + if (OkCommand != null && OkCommand.CanExecute(this)) + { + OkCommand.Execute(this); + } + break; + case nameof(ButtonCancel): + this.InputText = string.Empty; + if (CancelCommand != null && CancelCommand.CanExecute(this)) + { + CancelCommand.Execute(this); + } + break; + case nameof(ButtonBack): + if (this.InputText != null && this.InputText.Length > 0) + { + if (this.InputText.Equals(this.EtcText)) + { + this.InputText = string.Empty; + } + else + { + this.InputText = this.InputText.Remove(this.InputText.Length - 1, 1); + } + } + break; + default: + this.InputText = this.InputText + aNumberButton.Text; + break; + } + } + } + + #endregion Event Handlers + } + +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericPad2.xaml b/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericPad2.xaml new file mode 100644 index 0000000..7993a27 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericPad2.xaml @@ -0,0 +1,226 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericPad2.xaml.cs b/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericPad2.xaml.cs new file mode 100644 index 0000000..affd9d3 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/NumericPad2.xaml.cs @@ -0,0 +1,508 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +namespace SPC.Kiosk.Common +{ + /// + /// NumericPad.xaml에 대한 상호 작용 논리 + /// + public partial class NumericPad2 : UserControl + { + #region [ Members ] + /// + /// Noraml Bakcground + /// + public static readonly DependencyProperty NormalBrushProperty = + DependencyProperty.Register(nameof(NormalBrush), typeof(string), typeof(NumericPad2), new PropertyMetadata("White")); + /// + /// Touch Down Bakcground + /// + public static readonly DependencyProperty DownBrushProperty = + DependencyProperty.Register(nameof(DownBrush), typeof(string), typeof(NumericPad2), new PropertyMetadata("DarkGray")); + /// + /// Cancel Noraml Bakcground + /// + public static readonly DependencyProperty CancelNormalBrushProperty = + DependencyProperty.Register(nameof(CancelNormalBrush), typeof(string), typeof(NumericPad2), new PropertyMetadata("DarkRed")); + /// + /// Cancel Down Bakcground + /// + public static readonly DependencyProperty CancelDownBrushProperty = + DependencyProperty.Register(nameof(CancelDownBrush), typeof(string), typeof(NumericPad2), new PropertyMetadata("DarkGray")); + /// + /// Click Animation Type + /// + public static readonly DependencyProperty ClickAnimationTypeProperty = + DependencyProperty.Register(nameof(ClickAnimationType), typeof(ButtonAnimationType), typeof(NumericPad2), new PropertyMetadata(ButtonAnimationType.None)); + /// + /// Button Text Foreground + /// + public static readonly DependencyProperty TextForegroundProperty = + DependencyProperty.Register(nameof(TextForeground), typeof(string), typeof(NumericPad2), new PropertyMetadata("Black")); + /// + /// Cancel & Back Button Foreground + /// + public static readonly DependencyProperty CancelForegroundProperty = + DependencyProperty.Register(nameof(CancelForeground), typeof(string), typeof(NumericPad2), new PropertyMetadata("White")); + /// + /// Input Text + /// + public static readonly DependencyProperty InputTextProperty = + DependencyProperty.Register(nameof(InputText), typeof(string), typeof(NumericPad2), new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnInputTextPropertyChanged))); + /// + /// Show Text With Mask + /// + public static readonly DependencyProperty ShowTextProperty = + DependencyProperty.Register(nameof(ShowText), typeof(string), typeof(NumericPad2), new PropertyMetadata(string.Empty)); + /// + /// Text Area Visible + /// + public static readonly DependencyProperty TextVisibleProperty = + DependencyProperty.Register(nameof(TextVisibility), typeof(Visibility), typeof(NumericPad2), new PropertyMetadata(Visibility.Visible)); + /// + /// Guid Text (Mutil Language) + /// + public static readonly DependencyProperty GuidTextProperty = + DependencyProperty.Register(nameof(GuidText), typeof(List), typeof(NumericPad2), new PropertyMetadata(default(List), new PropertyChangedCallback(OnGuidTextPropertyChanged))); + /// + /// Cancel Text + /// + public static readonly DependencyProperty CancelTextProperty = + DependencyProperty.Register(nameof(CancelText), typeof(string), typeof(NumericPad2), new PropertyMetadata("Cancel", new PropertyChangedCallback(OnCancelTextPropertyChanged))); + /// + /// Cancel Text (Mutil Language) + /// + public static readonly DependencyProperty CancelLanguageTextProperty = + DependencyProperty.Register(nameof(CancelLanguageText), typeof(List), typeof(NumericPad2), new PropertyMetadata(default(List), new PropertyChangedCallback(OnCancelLanguageTextPropertyChanged))); + /// + /// Display Language Type + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(NumericPad2), new PropertyMetadata(SupportLanguageType.ko, new PropertyChangedCallback(OnDisplayLanguageProperyChanged))); + /// + /// Max input Length + /// + public static readonly DependencyProperty MaxLengthPropery = + DependencyProperty.Register(nameof(MaxLength), typeof(int), typeof(NumericPad2), new PropertyMetadata(0)); + /// + /// Is Formated Show Text + /// + public static readonly DependencyProperty FormatedPropery = + DependencyProperty.Register(nameof(Formated), typeof(bool), typeof(NumericPad2), new PropertyMetadata(false)); + /// + /// Is Formated Show Text + /// + public bool Formated + { + get { return (bool)GetValue(FormatedPropery); } + set { SetValue(FormatedPropery, value); } + } + /// + /// Max input Length + /// + public int MaxLength + { + get { return (int)GetValue(MaxLengthPropery); } + set { SetValue(MaxLengthPropery, value); } + } + + /// + /// Text Area Visibility + /// + public Visibility TextVisibility + { + get { return (Visibility)GetValue(TextVisibleProperty); } + set { SetValue(TextVisibleProperty, value); } + } + /// + /// Input Text (Real Data) + /// + public string InputText + { + get { return (string)GetValue(InputTextProperty); } + set { SetValue(InputTextProperty, value); } + } + /// + /// Show Text With Mask + /// + public string ShowText + { + get { return (string)GetValue(ShowTextProperty); } + set { SetValue(ShowTextProperty, value); } + } + /// + /// Guid Text (Multi Language) + /// + public List GuidText + { + get { return (List)GetValue(GuidTextProperty); } + set { SetValue(GuidTextProperty, value); } + } + /// + /// Display Language Type + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + /// + /// Cancel Text + /// + public string CancelText + { + get { return (string)GetValue(CancelTextProperty); } + set { SetValue(CancelTextProperty, value); } + } + /// + /// Cancel Text (Multi Language) + /// + public List CancelLanguageText + { + get { return (List)GetValue(CancelLanguageTextProperty); } + set { SetValue(CancelLanguageTextProperty, value); } + } + /// + /// Noraml Bakcground + /// + public string NormalBrush + { + get { return (string)GetValue(NormalBrushProperty); } + set { SetValue(NormalBrushProperty, value); } + } + /// + /// Mouse/Touch Down Bakcground + /// + public string DownBrush + { + get { return (string)GetValue(DownBrushProperty); } + set { SetValue(DownBrushProperty, value); } + } + /// + /// Cancel Button NormalBrush + /// + public string CancelNormalBrush + { + get { return (string)GetValue(CancelNormalBrushProperty); } + set { SetValue(CancelNormalBrushProperty, value); } + } + /// + /// Mouse/Touch Down Bakcground + /// + public string CancelDownBrush + { + get { return (string)GetValue(CancelDownBrushProperty); } + set { SetValue(CancelDownBrushProperty, value); } + } + /// + /// Button Animation Type + /// + public ButtonAnimationType ClickAnimationType + { + get { return (ButtonAnimationType)GetValue(ClickAnimationTypeProperty); } + set { SetValue(ClickAnimationTypeProperty, value); } + } + /// + /// Button Text Foreground + /// + public string TextForeground + { + get { return (string)GetValue(TextForegroundProperty); } + set { SetValue(TextForegroundProperty, value); } + } + /// + /// Cancel Button Foreground + /// + public string CancelForeground + { + get { return (string)GetValue(CancelForegroundProperty); } + set { SetValue(CancelForegroundProperty, value); } + } + #endregion Members + + #region [ Ctor/Etc ] + /// + /// Ctor + /// + public NumericPad2() + { + InitializeComponent(); + + foreach (var aElement in this.BaseGrid.Children) + { + if (aElement is AnimationButton aNumberButton) + { + aNumberButton.MouseClicked += NumberButton_MouseClicked; + } + } + } + + #endregion Ctor + + #region [ Methods ] + + private void SetShowText(string _showText) + { + string displayText = _showText; + if (!string.IsNullOrEmpty(displayText)) + { + if (displayText.Length < 10) + { + //pass + } + else if (displayText.Length.Equals(10) && Formated) + { + var displayChars = displayText.ToCharArray(); + displayText = string.Empty; + for (int i = 0; i < displayChars.Length; i++) + { + if (i > 2 && i < 6) + { + displayText += '*'; + } + else + { + displayText += displayChars[i]; + } + } + } + else if (displayText.Length.Equals(11) && Formated) + { + var displayChars = displayText.ToCharArray(); + displayText = string.Empty; + for (int i = 0; i < displayChars.Length; i++) + { + if (i > 2 && i < 7) + { + displayText += '*'; + } + else + { + displayText += displayChars[i]; + } + } + } + else if (displayText.Length < 17 && Formated) + { + var displayChars = displayText.ToCharArray(); + displayText = string.Empty; + for (int i = 0; i < displayChars.Length; i++) + { + if (i > 5 && i < 14) + { + displayText += '*'; + } + else + { + displayText += displayChars[i]; + } + } + + } + else if (Formated) + { + var displayChars = displayText.ToCharArray(); + displayText = string.Empty; + for (int i = 0; i < displayChars.Length; i++) + { + if (i > 3 && i < 16) + { + displayText += '*'; + } + else + { + displayText += displayChars[i]; + } + } + } + string formatedString = string.Empty; + if (Formated) + { + if (displayText.Length.Equals(10)) + { + formatedString = string.Format("{0}-{1}-{2}" + , displayText.Substring(0, 3) + , displayText.Substring(3, 3) + , displayText.Substring(6, 4)); + } + else if (displayText.Length.Equals(11)) + { + formatedString = string.Format("{0}-{1}-{2}" + , displayText.Substring(0, 3) + , displayText.Substring(3, 4) + , displayText.Substring(7, 4)); + } + else if (displayText.Length.Equals(16)) + { + formatedString = string.Format("{0}-{1}-{2}-{3}" + , displayText.Substring(0, 4) + , displayText.Substring(4, 4) + , displayText.Substring(8, 4) + , displayText.Substring(12, 4)); + } + else if (displayText.Length.Equals(20)) + { + formatedString = string.Format("{0}-{1}-{2}-{3}-{4}" + , displayText.Substring(0, 4) + , displayText.Substring(4, 4) + , displayText.Substring(8, 4) + , displayText.Substring(12, 4) + , displayText.Substring(16, 4)); + } + } + else + { + formatedString = (int.Parse(displayText)).ToString("#,###"); + } + if (!string.IsNullOrEmpty(formatedString)) displayText = formatedString; + this.ShowText = displayText; + } + else + { + this.ShowText = this.GuidText.GetLanguageData(this.DisplayLanguage); + } + } + private double SetEtcTextFontSize(AnimationButton _target, string _text) + { + double result = 20d; + try + { + var textLength = string.IsNullOrEmpty(_text.Trim()) ? 1 : _text.Trim().Length; + var fontSize = 0d; + switch (textLength) + { + case 1: + case 2: + case 3: + case 4: + fontSize = 0.35; + break; + default: + fontSize = 0.3; + break; + } + result = _target.ActualHeight > 0 ? _target.ActualHeight * fontSize : 20d; + + } + catch + { + result = 20d; + } + return result; + } + #endregion Methods + + #region [ Event Handlers ] + private static void OnCancelTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null ) + { + var target = d as NumericPad2; + var aElement = target.BaseGrid.FindName("ButtonCancel"); + if (aElement is AnimationButton aNumberButton) + { + var newFontSize = target.SetEtcTextFontSize(aNumberButton, (string)e.NewValue); + target.ButtonCancel.TextFontSize = newFontSize; + } + + } + } + private static void OnCancelLanguageTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null ) + { + var target = d as NumericPad2; + var aElement = target.BaseGrid.FindName("ButtonCancel"); + if (aElement is AnimationButton aNumberButton) + { + var newFontSize = target.SetEtcTextFontSize(aNumberButton + ,((List)e.NewValue).GetLanguageData(target.DisplayLanguage)); + target.ButtonCancel.TextFontSize = newFontSize; + } + } + } + private static void OnGuidTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null) + { + var target = d as NumericPad2; + target.SetShowText(target.InputText); + } + } + + private static void OnDisplayLanguageProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null ) + { + var target = d as NumericPad2; + foreach (var aElement in target.BaseGrid.Children) + { + if (aElement is AnimationButton aNumberButton + && aNumberButton.Name.StartsWith("ButtonCancel")) + { + aNumberButton.DisplayLanguage = (SupportLanguageType)e.NewValue; + } + } + target.SetShowText(target.InputText); + } + } + private static void OnInputTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as NumericPad2; + var inputText = (string)e.NewValue; + target.SetShowText(inputText); + } + private void NumberButton_MouseClicked(object sender, RoutedEventArgs e) + { + if (sender is AnimationButton aNumberButton) + { + switch (aNumberButton.Name) + { + case nameof(ButtonCancel): + this.InputText = string.Empty; + break; + case nameof(ButtonBack): + if (this.InputText != null && this.InputText.Length > 0) + { + this.InputText = this.InputText.Remove(this.InputText.Length - 1, 1); + } + break; + default: + if (!this.MaxLength.Equals(0) ) + { + if (this.InputText.Length < this.MaxLength) + { + this.InputText = this.InputText + aNumberButton.Text; + } + } + else + { + if (!(this.InputText.Length.Equals(0) && aNumberButton.Text.Equals("0"))) + { + this.InputText = this.InputText + aNumberButton.Text; + } + + } + break; + } + } + } + + #endregion Event Handlers + } + +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/PopupMessage.xaml b/Kiosk/Common/SPC.Kiosk.Common/Controls/PopupMessage.xaml new file mode 100644 index 0000000..c23bec3 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/PopupMessage.xaml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/PopupMessage.xaml.cs b/Kiosk/Common/SPC.Kiosk.Common/Controls/PopupMessage.xaml.cs new file mode 100644 index 0000000..fe129b5 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/PopupMessage.xaml.cs @@ -0,0 +1,272 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Forms; +using System.Drawing; +using SPC.Kiosk.Base; +using System.Windows.Threading; + +namespace SPC.Kiosk.Common +{ + /// + /// PopupMessage.xaml에 대한 상호 작용 논리 + /// + public partial class PopupMessage : Window + { + #region [ Members ] + private DispatcherTimer ShowTimer; + /// + /// MessageBox 응답 결과 + /// + public MessageBoxResult BoxResult { get; set; } + /// + /// MessageBox Button 구성 종류 + /// + public MessageBoxButton BoxButton { get; set; } + /// + /// MessageBox Open Animation Type + /// + public OpenCloseAnimationType BoxOpenAnimationType { get; set; } + /// + /// MessageBox Close Animation Type + /// + public OpenCloseAnimationType BoxCloseAnimationType { get; set; } + /// + /// 시작 종료 투명도 + /// + public double StartEndOpacity { get; set; } + /// + /// Animation 시강(초) + /// + public double AnimationSeconds { get; set; } + /// + /// 표시 대기 시간 (초) 0= 무한대 + /// + public double ShowWaitTime { get; set; } + private int ScreenNo { get; set; } = 0; + /// + /// LanguageType Code + /// + public SupportLanguageType LanguageType { get; set; } + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public PopupMessage(SupportLanguageType _languageType, + OpenCloseAnimationType _openAnimationType, + OpenCloseAnimationType _closeAnimationType, + double _startEndOpacity, + double animationSeconds, + double _waitTime) + { + LanguageType = _languageType; + BoxOpenAnimationType = _openAnimationType; + BoxCloseAnimationType = _closeAnimationType; + StartEndOpacity = _startEndOpacity; + AnimationSeconds = animationSeconds; + ShowWaitTime = _waitTime; + InitializeComponent(); + if (ShowWaitTime > 0) + { + ShowTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(ShowWaitTime), + IsEnabled = true + }; + ShowTimer.Tick += ShowTimer_Tick; + } + InitializeComponent(); + BaseInit(); + this.Loaded += PopupMessage_Loaded; + + } + #endregion Ctor + + #region [ Methods ] + private void BaseInit() + { + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + this.Yes_Button.DisplayLanguage = LanguageType; + this.No_Button.DisplayLanguage = LanguageType; + this.Cancel_Button.DisplayLanguage = LanguageType; + this.Cancel_Button.DisplayLanguage = LanguageType; + this.Message1.DisplayLanguage = LanguageType; + this.Message2.DisplayLanguage = LanguageType; + this.Yes_Button.MouseClicked += Yes_Button_MouseClicked; + this.No_Button.MouseClicked += No_Button_MouseClicked; + this.Cancel_Button.MouseClicked += Cancel_Button_MouseClicked; + + this.IsEnabled = false; + } + private void OpenWindow() + { + if (!BoxOpenAnimationType.Equals(OpenCloseAnimationType.None)) + { + var animationVector = BoxOpenAnimationType.Equals(OpenCloseAnimationType.GotoLeft) || BoxOpenAnimationType.Equals(OpenCloseAnimationType.GotoRight) + ? this.FrameBase.Width : this.FrameBase.Height; + + var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase + , BoxOpenAnimationType + , animationVector + , StartEndOpacity + , AnimationSeconds); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Begin(); + } + } + else + { + if (ShowTimer != null) ShowTimer.Start(); + this.IsEnabled = true; + } + } + private void CloseWindow() + { + if (ShowTimer != null) + { + ShowTimer.Stop(); + ShowTimer.Tick -= ShowTimer_Tick; + ShowTimer = null; + } + this.Loaded -= PopupMessage_Loaded; + this.Yes_Button.MouseClicked -= Yes_Button_MouseClicked; + this.No_Button.MouseClicked -= No_Button_MouseClicked; + this.Cancel_Button.MouseClicked -= Cancel_Button_MouseClicked; + if (!BoxCloseAnimationType.Equals(OpenCloseAnimationType.None)) + { + var animationVector = BoxCloseAnimationType.Equals(OpenCloseAnimationType.GotoLeft) || BoxCloseAnimationType.Equals(OpenCloseAnimationType.GotoRight) + ? this.FrameBase.Width : this.FrameBase.Height; + + var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase + , BoxCloseAnimationType + , animationVector + , StartEndOpacity + , AnimationSeconds); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + else + { + this.Close(); + } + } + #endregion Methods + + #region [ Event Handlers ] + private void ShowTimer_Tick(object sender, EventArgs e) + { + ShowTimer.Stop(); + BoxResult = MessageBoxResult.None; + CloseWindow(); + } + private void OpenAnimations_Completed(object sender, EventArgs e) + { + if (ShowTimer != null) ShowTimer.Start(); + this.IsEnabled = true; + } + private void CloseAnimation_Completed(object sender, EventArgs e) + { + this.Close(); + } + + + private void PopupMessage_Loaded(object sender, RoutedEventArgs e) + { + if (DesignerProperties.GetIsInDesignMode(this)) + { + if (ShowTimer != null) + { + ShowTimer.Stop(); + ShowTimer.Tick -= ShowTimer_Tick; + ShowTimer = null; + } + this.Close(); + } + else + { + OpenWindow(); + } + } + + private void Cancel_Button_MouseClicked(object sender, RoutedEventArgs e) + { + if (ShowTimer != null) ShowTimer.Stop(); + switch (BoxButton) + { + case MessageBoxButton.OKCancel: + case MessageBoxButton.YesNoCancel: + BoxResult = MessageBoxResult.Cancel; + break; + default: + BoxResult = MessageBoxResult.None; + break; + } + CloseWindow(); + } + + private void No_Button_MouseClicked(object sender, RoutedEventArgs e) + { + if (ShowTimer != null) ShowTimer.Stop(); + switch (BoxButton) + { + case MessageBoxButton.YesNo: + case MessageBoxButton.YesNoCancel: + BoxResult = MessageBoxResult.No; + break; + default: + BoxResult = MessageBoxResult.None; + break; + } + CloseWindow(); + } + + private void Yes_Button_MouseClicked(object sender, RoutedEventArgs e) + { + if (ShowTimer != null) ShowTimer.Stop(); + switch (BoxButton) + { + case MessageBoxButton.OK: + case MessageBoxButton.OKCancel: + BoxResult = MessageBoxResult.OK; + break; + case MessageBoxButton.YesNo: + case MessageBoxButton.YesNoCancel: + BoxResult = MessageBoxResult.Yes; + break; + default: + BoxResult = MessageBoxResult.None; + break; + } + CloseWindow(); + } + + + + + + #endregion Event Handlers + } + + +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/SignPad.xaml b/Kiosk/Common/SPC.Kiosk.Common/Controls/SignPad.xaml new file mode 100644 index 0000000..b6f6ab7 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/SignPad.xaml @@ -0,0 +1,12 @@ + + + + + diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/SignPad.xaml.cs b/Kiosk/Common/SPC.Kiosk.Common/Controls/SignPad.xaml.cs new file mode 100644 index 0000000..dcc3fb7 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/SignPad.xaml.cs @@ -0,0 +1,409 @@ +using Cosmos.Common; +using Cosmos.ServiceProvider; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Drawing; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Ink; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Threading; + +namespace SPC.Kiosk.Common +{ + /// + /// SignPad.xaml에 대한 상호 작용 논리 + /// + public partial class SignPad : UserControl + { + + #region [ Member ] + /// + /// Brush Color + /// + public static readonly DependencyProperty BrushColorProperty = + DependencyProperty.Register(nameof(BrushColor), typeof(System.Windows.Media.Color), typeof(SignPad), new PropertyMetadata(Colors.Black, new PropertyChangedCallback(OnBrushColorPropertyChanged))); + /// + /// Brush Size + /// + public static readonly DependencyProperty BrushSizeProperty = + DependencyProperty.Register(nameof(BrushSize), typeof(double), typeof(SignPad), new PropertyMetadata(5d, new PropertyChangedCallback(OnBrushSizePropertyChanged))); + /// + /// Background Color + /// + public static readonly DependencyProperty BackgroundColorProperty = + DependencyProperty.Register(nameof(BackgroundColor), typeof(System.Windows.Media.Color), typeof(SignPad), new PropertyMetadata(Colors.White, new PropertyChangedCallback(OnBackgroundColorPropertyChanged))); + /// + /// Saved File + /// + public static readonly DependencyProperty SavedFileProperty = + DependencyProperty.Register(nameof(SavedFile), typeof(string), typeof(SignPad), new PropertyMetadata(string.Empty)); + /// + /// SignData + /// + public static readonly DependencyProperty SignDataProperty = + DependencyProperty.Register(nameof(SignData), typeof(string), typeof(SignPad), new PropertyMetadata(string.Empty)); + /// + /// SignPoints + /// + public static readonly DependencyProperty SignPointsProperty = + DependencyProperty.Register(nameof(SignPoints), typeof(long), typeof(SignPad), new PropertyMetadata(0L, new PropertyChangedCallback(OnSignPointsPropertyChanged))); + /// + /// Useable Sign + /// + public static readonly DependencyProperty UseableSignProperty = + DependencyProperty.Register(nameof(UseableSign), typeof(bool), typeof(SignPad), new PropertyMetadata(false)); + /// + /// TimeOutSeconds + /// + public static readonly DependencyProperty TimeOutSecondsProperty = + DependencyProperty.Register(nameof(TimeOutSeconds), typeof(double), typeof(SignPad), new PropertyMetadata(0d, new PropertyChangedCallback(OnTimeOutSecondsPropertyChanged))); + /// + /// SignReset + /// + public static readonly DependencyProperty SignResetProperty = + DependencyProperty.Register(nameof(SignReset), typeof(bool), typeof(SignPad), new PropertyMetadata(false, new PropertyChangedCallback(OnSignResetPropertyChanged))); + /// + /// SignEnd + /// + public static readonly DependencyProperty SignEndProperty = + DependencyProperty.Register(nameof(SignEnd), typeof(bool), typeof(SignPad), new PropertyMetadata(false, new PropertyChangedCallback(OnSignEndPropertyChanged))); + /// + /// Brush Color + /// + public System.Windows.Media.Color BrushColor + { + get { return (System.Windows.Media.Color)GetValue(BrushColorProperty); } + set { SetValue(BrushColorProperty, value); } + } + /// + /// Brush Size + /// + public double BrushSize + { + get { return (double)GetValue(BrushSizeProperty); } + set { SetValue(BrushSizeProperty, value); } + } + + /// + /// Background Color + /// + public System.Windows.Media.Color BackgroundColor + { + get { return (System.Windows.Media.Color)GetValue(BackgroundColorProperty); } + set { SetValue(BackgroundColorProperty, value); } + } + + /// + /// Saved File + /// + public string SavedFile + { + get { return (string)GetValue(SavedFileProperty); } + set { SetValue(SavedFileProperty, value); } + } + /// + /// Sign Data + /// + public string SignData + { + get { return (string)GetValue(SignDataProperty); } + set { SetValue(SignDataProperty, value); } + } + /// + /// SignPoints + /// + public long SignPoints + { + get { return (long)GetValue(SignPointsProperty); } + set { SetValue(SignPointsProperty, value); } + } + /// + /// Useable Sign + /// + public bool UseableSign + { + get { return (bool)GetValue(UseableSignProperty); } + set { SetValue(UseableSignProperty, value); } + } + /// + /// TimeOutSeconds + /// + public double TimeOutSeconds + { + get { return (double)GetValue(TimeOutSecondsProperty); } + set { SetValue(TimeOutSecondsProperty, value); } + } + /// + /// SignReset + /// + public bool SignReset + { + get { return (bool)GetValue(SignResetProperty); } + set { SetValue(SignResetProperty, value); } + } + /// + /// SignEnd + /// + public bool SignEnd + { + get { return (bool)GetValue(SignEndProperty); } + set { SetValue(SignEndProperty, value); } + } + private DateTime LastAccessTime { get; set; } = DateTime.Now; + private DispatcherTimer SignTimer; + #endregion + #region [ Ctor / Etc] + public SignPad() + { + try + { + InitializeComponent(); + StrokeCollectionChangedEventHandler strokes_StrokesChanged = Strokes_StrokesChanged; + inkCanvas.Strokes.StrokesChanged += strokes_StrokesChanged; + inkCanvas.DefaultDrawingAttributes.Color = BrushColor; + inkCanvas.DefaultDrawingAttributes.Height = BrushSize; + inkCanvas.DefaultDrawingAttributes.Width = BrushSize; + inkCanvas.DefaultDrawingAttributes.IgnorePressure = false; + inkCanvas.DefaultDrawingAttributes.IsHighlighter = false; + inkCanvas.DefaultDrawingAttributes.StylusTip = StylusTip.Ellipse; + inkCanvas.Background = new SolidColorBrush(BackgroundColor); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "Ctor", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + private void SignPad_Unloaded(object sender, RoutedEventArgs e) + { + if (this.SignTimer != null) + { + SignTimer.Stop(); + SignTimer.Tick -= SignTimer_Tick; + SignTimer = null; + } + } + #endregion + + #region [ Methods ] + private void TimerEnable() + { + if (DesignerProperties.GetIsInDesignMode(this)) return; + + if (this.SignTimer != null) + { + LastAccessTime = DateTime.Now; + this.SignTimer.Start(); + } + else + { + this.SignTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1), + }; + SignTimer.Tick += SignTimer_Tick; + LastAccessTime = DateTime.Now; + SignTimer.Start(); + } + } + private void TimerDisable() + { + if (this.SignTimer != null) + { + this.SignTimer.Stop(); + LastAccessTime = DateTime.Now; + } + } + + private void ConvertToBitmapSource() + { + try + { + var width = CommonValue.SignWidth; + var height = CommonValue.SignHeight; + var target = new RenderTargetBitmap((int)(inkCanvas.RenderSize.Width), (int)(inkCanvas.RenderSize.Height), 96, 96, PixelFormats.Default); + var brush = new VisualBrush(inkCanvas); + + var visual = new DrawingVisual(); + var drawingContext = visual.RenderOpen(); + + + drawingContext.DrawRectangle(brush, null, new Rect(new System.Windows.Point(0, 0), + new System.Windows.Point(inkCanvas.RenderSize.Width, inkCanvas.RenderSize.Height))); + + drawingContext.Close(); + target.Render(visual); + + var bitmapSource = (BitmapSource)target.Clone(); + var memoryStream = new MemoryStream(); + var bmpBitmapEncoder = new BmpBitmapEncoder(); + var bitmapFrame = BitmapFrame.Create(bitmapSource); + bmpBitmapEncoder.Frames.Add(bitmapFrame); + bmpBitmapEncoder.Save(memoryStream); + using (var bitMap = new Bitmap(memoryStream)) + { + + var targetSize = new System.Drawing.Size(width, height); + var sizedImage = new Bitmap(bitMap, targetSize); + var targetRectangle = new System.Drawing.Rectangle(0, 0, width, height); + var lastImg = sizedImage.Clone(targetRectangle, System.Drawing.Imaging.PixelFormat.Format1bppIndexed); + + var filePath = ResourceManager.SignDataPath; + if (!Directory.Exists(filePath)) Directory.CreateDirectory(filePath); + var savedFile = System.IO.Path.Combine(filePath, CommonValue.SignFileName); + lastImg.Save(savedFile, System.Drawing.Imaging.ImageFormat.Bmp); + if (File.Exists(savedFile)) + { + var sManager = new SManager(); + var m_cSignPad = (ISignPadUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_SIGNPAD); + var signData = string.Empty; + if (m_cSignPad.GetSign_BmpToData(savedFile, ref signData)) + { + SignData = signData; + SavedFile = savedFile; + } + m_cSignPad = null; + sManager = null; + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ConvertToBitmapSource()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + + } + private void CheckSignOK(long strokePoints) + { + if (strokePoints < CommonValue.SingPointsMin) + { + UseableSign = false; + } + else if (strokePoints >= CommonValue.SingPointsMin && strokePoints < CommonValue.SingPointsMax) + { + UseableSign = true; + } + else + { + UseableSign = false; + } + + + } + #endregion + + #region [ Event Handlers ] + private void SignTimer_Tick(object sender, EventArgs e) + { + if ((DateTime.Now - LastAccessTime) > TimeSpan.FromSeconds(TimeOutSeconds)) + { + TimerDisable(); + if (UseableSign) + { + ConvertToBitmapSource(); + inkCanvas.Strokes.Clear(); + } + else + { + TimerEnable(); + } + } + } + private static void OnSignEndPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is SignPad target) + { + if (e.NewValue is bool newValue && newValue) + { + target.TimerDisable(); + target.ConvertToBitmapSource(); + target.inkCanvas.Strokes.Clear(); + target.SignEnd = false; + } + } + } + + private static void OnSignResetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is SignPad target) + { + if (e.NewValue is bool newValue && newValue) + { + target.LastAccessTime = DateTime.Now; + target.inkCanvas.Strokes.Clear(); + target.SignReset = false; + } + } + } + + private static void OnTimeOutSecondsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is SignPad target) + { + if (e.NewValue is double newTimeout && newTimeout > 0 ) + { + target.TimerEnable(); + + } + } + } + + private static void OnBrushColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is SignPad target) + { + target.inkCanvas.DefaultDrawingAttributes.Color = (System.Windows.Media.Color)e.NewValue; + } + } + private static void OnBackgroundColorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is SignPad target) + { + target.inkCanvas.Background = new SolidColorBrush((System.Windows.Media.Color)e.NewValue); + } + } + private static void OnBrushSizePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is SignPad target) + { + target.inkCanvas.DefaultDrawingAttributes.Height = (double)e.NewValue < 1 ? 1 : (double)e.NewValue; + target.inkCanvas.DefaultDrawingAttributes.Width = (double)e.NewValue < 1 ? 1 : (double)e.NewValue; + } + } + private static void OnSignPointsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is SignPad target) + { + if (e.NewValue is long strokePoints) + { + target.CheckSignOK(strokePoints); + } + } + } + + private void Strokes_StrokesChanged(object sender, StrokeCollectionChangedEventArgs e) + { + LastAccessTime = DateTime.Now; + var signPoints = 0L; + foreach (var aStroke in inkCanvas.Strokes) + { + signPoints += aStroke.StylusPoints.Count; + } + SignPoints = signPoints; + } + #endregion + + } + +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/WaitForm.xaml b/Kiosk/Common/SPC.Kiosk.Common/Controls/WaitForm.xaml new file mode 100644 index 0000000..eeefaa6 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/WaitForm.xaml @@ -0,0 +1,30 @@ + + + + + + diff --git a/Kiosk/Common/SPC.Kiosk.Common/Controls/WaitForm.xaml.cs b/Kiosk/Common/SPC.Kiosk.Common/Controls/WaitForm.xaml.cs new file mode 100644 index 0000000..5a05ebd --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Controls/WaitForm.xaml.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Forms; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Media.Animation; +using System.Threading.Tasks; +using System.Windows.Threading; +using System.Threading; +using System.ComponentModel; + +namespace SPC.Kiosk.Common +{ + /// + /// WaitForm.xaml에 대한 상호 작용 논리 + /// + public partial class WaitForm : Window + { + #region [ Members ] + #endregion Members + + #region [ Ctor / Etc ] + /// + /// Ctor + /// + public WaitForm() + { + InitializeComponent(); + } + + #endregion Ctor / Etc + + #region [ Event Handlers ] + + #endregion Event Handlers + + + } +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Converters/CommonConverters.cs b/Kiosk/Common/SPC.Kiosk.Common/Converters/CommonConverters.cs new file mode 100644 index 0000000..04e782c --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Converters/CommonConverters.cs @@ -0,0 +1,516 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Data; + +namespace SPC.Kiosk.Common +{ + /// + /// Double 값을 Percent에 따라 변환 + /// + public class DoublePercentValue : IValueConverter + { + /// + /// Convert + /// + /// + /// + /// + /// + /// + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + double result = double.NaN; + try + { + if (value is double getValue) + { + if (parameter != null && getValue > 0 ) + { + result = getValue * double.Parse(parameter.ToString()) / 100; + } + else + { + result = getValue; + } + } + } + catch + { + result = double.NaN; + } + return result; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + /// + /// bool 값을 Visibility 값으로 변환 + /// + public class BoolToVisibility : IValueConverter + { + /// + /// Convert + /// + /// + /// + /// + /// + /// + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Visibility result = Visibility.Collapsed; + try + { + if (value is bool getValue) + { + result = getValue ? Visibility.Visible : Visibility.Collapsed; + } + } + catch + { + result = Visibility.Collapsed; + } + return result; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + public class BoolToUnvisibility : IValueConverter + { + /// + /// Convert + /// + /// + /// + /// + /// + /// + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Visibility result = Visibility.Collapsed; + try + { + if (value is bool getValue) + { + result = getValue ? Visibility.Collapsed : Visibility.Visible; + } + } + catch + { + result = Visibility.Collapsed; + } + return result; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + /// + /// 숫자 을 문자열로 + /// + public class NumericToString : IValueConverter + { + object IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + string result = string.Empty; + try + { + if (value is double getValue) + { + if (parameter is string getFormetString) + { + result = getValue.ToString(getFormetString); + } + else + { + result = getValue.ToString(); + } + } + else if (value is int getInt) + { + if (parameter is string getFormetString ) + { + result = getInt.ToString(getFormetString); + } + else + { + result = getInt.ToString(); + } + } + else if (value is long getlong) + { + if (parameter is string getFormetString) + { + result = getlong.ToString(getFormetString); + } + else + { + result = getlong.ToString(); + } + } + } + catch + { + result = string.Empty; + } + return result; + } + + object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + + /// + /// Numeric To Visibility 값으로 변환 + /// + public class NumericExistToVisibility : IValueConverter + { + /// + /// Convert + /// + /// + /// + /// + /// + /// + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + Visibility result = Visibility.Collapsed; + try + { + double checkValue = 0d; + try + { + checkValue = double.Parse(value.ToString()); + } + catch + { + checkValue = 0d; + } + bool setValue = false; + try + { + + setValue = bool.Parse(parameter.ToString()); + + } + catch + { + setValue = true; + } + setValue = checkValue > 0d ? setValue : !setValue; + result = setValue ? Visibility.Visible : Visibility.Collapsed; + } + catch + { + result = Visibility.Collapsed; + } + return result; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + /// + /// Numeric To Bool 값으로 변환 + /// + public class NumericExistToBool : IValueConverter + { + /// + /// Convert + /// + /// + /// + /// + /// + /// + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + bool result = false; + try + { + double checkValue = 0d; + try + { + checkValue = double.Parse(value.ToString()); + } + catch + { + checkValue = 0d; + } + bool setValue = false; + try + { + + setValue = bool.Parse(parameter.ToString()); + + } + catch + { + setValue = true; + } + result = checkValue > 0d ? setValue : !setValue; + } + catch + { + result = false; + } + return result; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + + /// + /// Langeuage Code To Multi Language Data + /// + public class CodeToMultiLanguage : IValueConverter + { + /// + /// Convert + /// + /// + /// + /// + /// + /// + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + List result = null; + try + { + if (parameter is string _parameter) + { + if (_parameter.Equals(string.Empty)) + { + result = null; + } + else + { + result = Languages.GetMessages(_parameter); + } + } + else + { + result = null; + } + } + catch + { + result = null; + } + return result; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + + /// + /// Langeuage Code To Multi Language Data(자동계산 혹은 바코드계산) + /// + public class CodeToMultiLanguageAutoOrBarcode : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + List result = null; + var opt810 = values[0]; + var opt811 = values[1]; + + try + { + if (parameter is string _parameter) + { + // OPT810값이 0이고 OPT811값이 1인경우(바코드계산) + if (opt810.ToString() == "0" + && opt811.ToString() == "1") + { + result = new List() { new M_Language { LanguageData = "바코드 계산", Type = SupportLanguageType.ko } }; + } + else if (_parameter.Equals(string.Empty)) + { + result = null; + } + else + { + result = Languages.GetMessages(_parameter); + } + } + else + { + result = null; + } + } + catch + { + result = null; + } + return result; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + + /// + /// Pos Option Value값에 따라 Barcode 하단 버튼 및 텍스트 Visible처리 + /// + public class PosOptionValuesBarcodeToVisibility : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + var opt810 = values[0]; + var opt811 = values[1]; + + if (parameter?.ToString() == "bottomButtonText") + { + if (opt810.ToString() == "0" + && opt811.ToString() == "1") + { + return Visibility.Collapsed; + } + } + else if (parameter?.ToString() == "toggleGrid") + { + if (opt810.ToString() == "0" + && opt811.ToString() == "0") + { + return Visibility.Collapsed; + } + } + + return Visibility.Visible; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + + /// + /// Pos Option Value값에 따라 Barcode이미지 Margin처리 + /// + public class PosOptionValuesBarcodeToMargin : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + var opt810 = values[0]; + var opt811 = values[1]; + + if (parameter?.ToString() == "image") + { + if (opt810.ToString() == "0" + && opt811.ToString() == "1") + { + // 센터정렬 + return new Thickness(0, 71 + 50, 0, 0); + } + } + else if (parameter?.ToString() == "textBlock") + { + if (opt810.ToString() == "0" + && opt811.ToString() == "1") + { + // 센터정렬 + return new Thickness(57, 245 + 50, 0, 0); + } + } + + return parameter?.ToString() == "image" ? new Thickness(0, 71, 0, 0) : new Thickness(57, 245, 0, 0); + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + + /// + /// Point Saving Popup우측화면 Visible처리 + /// + public class PointSavingAndStoreAgreeViewToVisibility : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + var pointSaving = values[0]; + var storeAgreeView = values[1]; + + if (pointSaving?.ToString().ToLower() == "true") + { + return Visibility.Collapsed; + } + else if (pointSaving?.ToString().ToLower() == "false" + && storeAgreeView?.ToString().ToLower() == "true") + { + return Visibility.Collapsed; + } + + return Visibility.Visible; + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } + + /// + /// string 값을 Visibility 값으로 변환 + /// + public class StringToVisibility : IValueConverter + { + /// + /// Convert + /// + /// + /// + /// + /// + /// + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + try + { + if (value?.ToString() == "0") + { + return Visibility.Collapsed; + } + } + catch + { + return Visibility.Collapsed; + } + + return Visibility.Visible; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Functions/AiScannerProcess.cs b/Kiosk/Common/SPC.Kiosk.Common/Functions/AiScannerProcess.cs new file mode 100644 index 0000000..2dced9f --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Functions/AiScannerProcess.cs @@ -0,0 +1,97 @@ +using System; +using System.Diagnostics; +using System.IO; +using System.Runtime.InteropServices; + +namespace SPC.Kiosk.Common +{ + public static class AiScannerProcess + { + [DllImport("user32.dll")] + static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); + + [DllImport("user32.dll")] + private static extern IntPtr FindWindow(string SClassName, string SWindowName); + [DllImport("user32.dll")] + private static extern bool SetForegroundWindow(IntPtr findname); + [DllImport("user32.dll")] + private static extern bool ShowWindowAsync(IntPtr findname, int howShow); + [DllImport("user32.dll")] + private static extern bool BringWindowToTop(IntPtr findname); + [DllImport("user32.dll")] + static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, uint uFlags); + + static readonly IntPtr HWND_TOPMOST = new IntPtr(-1); + const UInt32 SWP_NOSIZE = 0x0001; + const UInt32 SWP_NOMOVE = 0x0002; + const UInt32 SWP_SHOWWINDOW = 0x0040; + + private static Process AiScannerExe = null; + + public static bool Excuted + { + get + { + if (AiScannerExe != null) + { + return !AiScannerExe.HasExited; + } + else + { + return false; + } + } + } + + public static void ExcuteAiScanner(IntPtr _openner) + { + try + { + if (Excuted || AiScannerExe != null) StopAiScanner(); + var fileName = Path.Combine(ResourceManager.BinPath, CommonValue.AiScannerPath); + if (File.Exists(fileName)) + { + var newStartInfo = new ProcessStartInfo + { + FileName = fileName, + UseShellExecute = false, + //WindowStyle= ProcessWindowStyle.Hidden, + ErrorDialog = false, + CreateNoWindow = true, + }; + AiScannerExe = new Process(); + AiScannerExe.StartInfo = newStartInfo; + if (AiScannerExe.Start()) + { + AiScannerExe.WaitForInputIdle(500); + SetParent(AiScannerExe.MainWindowHandle, _openner); + //AiScannerExe.StartInfo.WindowStyle = ProcessWindowStyle.Normal; + } + } + else + { + CommonLog.ErrorLogWrite("SPC.Kiosk.Common", "AiScannerProcess", "ExcuteAiScanner()", "File Not Exists !!", string.Format("\nFile Path: {0}", fileName)); + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite("SPC.Kiosk.Common", "AiScannerProcess", "ExcuteAiScanner()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + public static void StopAiScanner() + { + if (Excuted) + { + AiScannerExe.Kill(); + AiScannerExe.WaitForExit(); + AiScannerExe.Dispose(); + AiScannerExe = null; + } + else + { + if (AiScannerExe != null) AiScannerExe = null; + } + } + } +} \ No newline at end of file diff --git a/Kiosk/Common/SPC.Kiosk.Common/Functions/Animations.cs b/Kiosk/Common/SPC.Kiosk.Common/Functions/Animations.cs new file mode 100644 index 0000000..aead5b9 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Functions/Animations.cs @@ -0,0 +1,577 @@ +using System; +using System.Collections.Generic; +using System.Drawing.Printing; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Media.Animation; +using SPC.Kiosk.Base; +namespace SPC.Kiosk.Common +{ + /// + /// Animation Actions + /// + public static class Animations + { + /// + /// ScrollAnimation for + /// + /// + /// + /// + /// + /// + /// + public static Storyboard GetScrollAnimation(FrameworkElement _animationTarget, Orientation _animationType, double _fromValue, double _toValue, double _sconds = 0.3) + { + Storyboard resultStoryboard = null; + try + { + resultStoryboard = new Storyboard(); + var totalDuration = new Duration(TimeSpan.FromSeconds(_sconds)); + var scrollAnimation = new DoubleAnimation(_fromValue, _toValue, totalDuration); + Storyboard.SetTarget(scrollAnimation, _animationTarget); + Storyboard.SetTargetProperty(scrollAnimation, new PropertyPath(_animationType.Equals(Orientation.Horizontal) ? "HorizontalOffset" : "VerticalOffset")); + resultStoryboard.Children.Add(scrollAnimation); + } + catch + { + resultStoryboard = null; + } + return resultStoryboard; + } + /// + /// Create MoveAnimation with Opacity + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static List GetMoveAnimation(FrameworkElement _animationTarget, OpenCloseAnimationType _animationType, double _fromValue, double _toValue, double _opacityFrom, double _opacityTo, double _sconds) + { + List resultAnimation = null; + try + { + resultAnimation = new List(); + var totalDuration = new Duration(TimeSpan.FromSeconds(_sconds)); + var opacityAnimation = new DoubleAnimation(_opacityFrom, _opacityTo, totalDuration); + //var centerX = _animationTarget.ActualWidth / 2; + //var centerY = _animationTarget.ActualHeight / 2; + var centerX = _animationTarget.Width / 2; + var centerY = _animationTarget.Height / 2; + Storyboard.SetTarget(opacityAnimation, _animationTarget); + Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath("Opacity")); + resultAnimation.Add(opacityAnimation); + + switch (_animationType) + { + case OpenCloseAnimationType.GotoLeft: + case OpenCloseAnimationType.GotoRight: + _animationTarget.RenderTransform = new TranslateTransform(0, 0); + var addAnimation = new DoubleAnimation(_fromValue, _toValue, totalDuration); + Storyboard.SetTarget(addAnimation, _animationTarget); + Storyboard.SetTargetProperty(addAnimation, new PropertyPath("RenderTransform.X")); + resultAnimation.Add(addAnimation); + break; + case OpenCloseAnimationType.GotoUp: + case OpenCloseAnimationType.GotoDown: + _animationTarget.RenderTransform = new TranslateTransform(0, 0); + var add2Animation = new DoubleAnimation(_fromValue, _toValue, totalDuration); + Storyboard.SetTarget(add2Animation, _animationTarget); + Storyboard.SetTargetProperty(add2Animation, new PropertyPath("RenderTransform.Y")); + resultAnimation.Add(add2Animation); + break; + case OpenCloseAnimationType.FullSizeDown: + case OpenCloseAnimationType.FullSizeUp: + _animationTarget.RenderTransform = new ScaleTransform(1, 1, centerX, centerY); + var flipXAni = new DoubleAnimation(_animationType.Equals(OpenCloseAnimationType.FullSizeUp) ? 0 : 1 + , _animationType.Equals(OpenCloseAnimationType.FullSizeUp) ? 1 : 0 + , totalDuration); + var flipYAni = new DoubleAnimation(_animationType.Equals(OpenCloseAnimationType.FullSizeUp) ? 0 : 1 + , _animationType.Equals(OpenCloseAnimationType.FullSizeUp) ? 1 : 0 + , totalDuration); + Storyboard.SetTarget(flipXAni, _animationTarget); + Storyboard.SetTarget(flipYAni, _animationTarget); + Storyboard.SetTargetProperty(flipXAni, new PropertyPath("RenderTransform.ScaleX")); + Storyboard.SetTargetProperty(flipYAni, new PropertyPath("RenderTransform.ScaleY")); + resultAnimation.Add(flipXAni); + resultAnimation.Add(flipYAni); + break; + } + } + catch + { + resultAnimation = null; + } + return resultAnimation; + } + /// + /// Close and Open Animation + /// + /// + /// + /// + /// + /// + /// + public static Storyboard GetOpenAndCloseAnimation(FrameworkElement _closeTarget, FrameworkElement _openTarget, OpenCloseAnimationType _animationType, double _objectSize, double _sconds = 0.5) + { + return GetOpenAndCloseAnimation(_closeTarget, _openTarget, _animationType, _objectSize, 1, _sconds); + } + /// + /// Close and Open Animation + /// + /// + /// + /// + /// + /// + /// + public static Storyboard GetOpenAndCloseAnimation(FrameworkElement _closeTarget, FrameworkElement _openTarget, OpenCloseAnimationType _animationType, double _objectSize, double _opacityValue , double _sconds = 0.5) + { + Storyboard resultStoryboard = null; + try + { + resultStoryboard = new Storyboard(); + _openTarget.Width = _objectSize; + _openTarget.Visibility = Visibility.Visible; + _closeTarget.IsEnabled = false; + double toValue = _objectSize; + switch (_animationType) + { + case OpenCloseAnimationType.GotoLeft: + case OpenCloseAnimationType.GotoUp: + toValue = toValue * -1; + break; + } + foreach (var aAnimation in GetMoveAnimation(_closeTarget, _animationType, 0, toValue, 1, _opacityValue, _sconds)) resultStoryboard.Children.Add(aAnimation); + double fromValue = _objectSize; + switch (_animationType) + { + case OpenCloseAnimationType.GotoRight: + case OpenCloseAnimationType.GotoDown: + fromValue = fromValue * -1; + break; + } + foreach (var aAnimation in GetMoveAnimation(_openTarget, _animationType, fromValue, 0, _opacityValue, 1, _sconds)) resultStoryboard.Children.Add(aAnimation); + } + catch + { + resultStoryboard = null; + } + return resultStoryboard; + } + /// + /// Open Animation + /// + /// + /// + /// + /// + /// + public static Storyboard GetOpenAnimation(FrameworkElement _animationTarget, OpenCloseAnimationType _animationType, double _objectSize, double _sconds = 0.5) + { + return GetOpenAnimation( _animationTarget, _animationType, _objectSize, 0, _sconds ); + } + /// + /// Open Animation + /// + /// + /// + /// + /// + /// + public static Storyboard GetOpenAnimation(FrameworkElement _animationTarget, OpenCloseAnimationType _animationType, double _objectSize, double _opacityValue, double _sconds = 0.5) + { + Storyboard resultStoryboard = null; + try + { + resultStoryboard = new Storyboard(); + switch (_animationType) + { + case OpenCloseAnimationType.GotoLeft: + case OpenCloseAnimationType.GotoRight: + _animationTarget.Width = _objectSize; + break; + case OpenCloseAnimationType.GotoUp: + case OpenCloseAnimationType.GotoDown: + _animationTarget.Height = _objectSize; + break; + } + _animationTarget.Visibility = Visibility.Visible; + double fromValue = _objectSize; + switch (_animationType) + { + case OpenCloseAnimationType.GotoRight: + case OpenCloseAnimationType.GotoDown: + fromValue = fromValue * -1; + break; + } + foreach (var aAnimation in GetMoveAnimation(_animationTarget, _animationType, fromValue, 0, _opacityValue, 1, _sconds)) resultStoryboard.Children.Add(aAnimation); + } + catch + { + resultStoryboard = null; + } + return resultStoryboard; + } + /// + /// Close Animation + /// + /// + /// + /// + /// + /// + public static Storyboard GetCloseAnimation(FrameworkElement _animationTarget, OpenCloseAnimationType _animationType, double _objectSize, double _sconds = 0.5) + { + return GetCloseAnimation(_animationTarget, _animationType, _objectSize, 0, _sconds); + } + /// + /// Close Animation + /// + /// + /// + /// + /// + /// + public static Storyboard GetCloseAnimation(FrameworkElement _animationTarget, OpenCloseAnimationType _animationType, double _objectSize, double _opacityValue, double _sconds = 0.5) + { + Storyboard resultStoryboard = null; + try + { + resultStoryboard = new Storyboard(); + switch (_animationType) + { + case OpenCloseAnimationType.GotoLeft: + case OpenCloseAnimationType.GotoRight: + _animationTarget.Width = _objectSize; + break; + case OpenCloseAnimationType.GotoUp: + case OpenCloseAnimationType.GotoDown: + _animationTarget.Height = _objectSize; + break; + } + _animationTarget.IsEnabled = false; + double toValue = _objectSize; + switch (_animationType) + { + case OpenCloseAnimationType.GotoLeft: + case OpenCloseAnimationType.GotoUp: + toValue = toValue * -1; + break; + } + foreach (var aAnimation in GetMoveAnimation(_animationTarget, _animationType, 0, toValue, 1, _opacityValue, _sconds)) resultStoryboard.Children.Add(aAnimation); + } + catch + { + resultStoryboard = null; + } + return resultStoryboard; + } + /// + /// Get a Shutter Animation Storyboard + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static Storyboard GetShutterAnimation(FrameworkElement _animationTarget, ShutterAnchor _directionType, double _fromValue, double _toValue,double _opacityFrom, double _opacityTo, double _sconds=0.5) + { + Storyboard gridAnimation = null; + try + { + var targetType = _animationTarget.GetType(); + _animationTarget.RenderTransform = new TranslateTransform(0, 0); + gridAnimation = new Storyboard(); + string targetProperty = _directionType.Equals(ShutterAnchor.Left) || _directionType.Equals(ShutterAnchor.Right) ? "Width":"Height"; + switch (_directionType) + { + case ShutterAnchor.Left: + _animationTarget.HorizontalAlignment = HorizontalAlignment.Left; + //var sizeBounds1 = new DoubleAnimation(0, _animationTarget.Width * -1, new Duration(TimeSpan.FromSeconds(_sconds))); + //Storyboard.SetTarget(sizeBounds1, _animationTarget); + //Storyboard.SetTargetProperty(sizeBounds1, new PropertyPath("RenderTransform.X")); + //gridAnimation.Children.Add(sizeBounds1); + + break; + case ShutterAnchor.Right: + _animationTarget.HorizontalAlignment = HorizontalAlignment.Right; + //var sizeAni = new DoubleAnimation(_animationTarget.Width * -1, 0, new Duration(TimeSpan.FromSeconds(_sconds))); + //Storyboard.SetTarget(sizeAni, _animationTarget); + //Storyboard.SetTargetProperty(sizeAni, new PropertyPath("RenderTransform.X")); + //gridAnimation.Children.Add(sizeAni); + break; + case ShutterAnchor.Top: + _animationTarget.VerticalAlignment = VerticalAlignment.Top; + break; + case ShutterAnchor.Bottom: + _animationTarget.VerticalAlignment = VerticalAlignment.Bottom; + break; + } + var sizeAni = new DoubleAnimation(_fromValue, _toValue, new Duration(TimeSpan.FromSeconds(_sconds))); + Storyboard.SetTarget(sizeAni, _animationTarget); + Storyboard.SetTargetProperty(sizeAni, new PropertyPath(targetProperty)); + gridAnimation.Children.Add(sizeAni); + + var opacityAni = new DoubleAnimation(_opacityFrom, _opacityTo, new Duration(TimeSpan.FromSeconds(_sconds))); + Storyboard.SetTarget(opacityAni, _animationTarget); + Storyboard.SetTargetProperty(opacityAni, new PropertyPath("Opacity")); + gridAnimation.Children.Add(opacityAni); + + } + catch + { + gridAnimation = null; + } + return gridAnimation; + } + /// + /// Get a Button Animation + /// + /// Target + /// Animation Type + /// + public static Storyboard GetClickAnimation(FrameworkElement _target, ButtonAnimationType _clickAnimationType,double _durationSeconds = 0.2) + { + Storyboard targetAnimation = null; + try + { + targetAnimation = new Storyboard(); + + var boucedHeight = 0d; + var sizeScale = 1d; + switch (_clickAnimationType) + { + case ButtonAnimationType.BounceUp: + boucedHeight = _target.ActualHeight * -0.2; + break; + case ButtonAnimationType.TextBounceUp: + boucedHeight = _target.ActualHeight * -0.3; + break; + case ButtonAnimationType.BounceDown: + boucedHeight = _target.ActualHeight * 0.2; + break; + case ButtonAnimationType.TextBounceDown: + boucedHeight = _target.ActualHeight * 0.3; + break; + case ButtonAnimationType.SizeDown: + case ButtonAnimationType.TextSizeDown: + sizeScale = 0.85; + break; + case ButtonAnimationType.SizeUp: + case ButtonAnimationType.TextSizeUp: + sizeScale = 1.15; + break; + case ButtonAnimationType.FlipX: + case ButtonAnimationType.FlipY: + sizeScale = 0; + break; + } + + var centerX = _target.ActualWidth / 2; + var centerY = _target.ActualHeight / 2; + switch (_clickAnimationType) + { + case ButtonAnimationType.OpacityDown: + var opacityDown = new DoubleAnimation(1, 0.5, new Duration(TimeSpan.FromSeconds(_durationSeconds))) + { + AutoReverse = true + }; + Storyboard.SetTarget(opacityDown, _target); + Storyboard.SetTargetProperty(opacityDown, new PropertyPath("Opacity")); + targetAnimation.Children.Add(opacityDown); + break; + case ButtonAnimationType.OpacityUp: + var opacityUp = new DoubleAnimation(0.5, 1, new Duration(TimeSpan.FromSeconds(_durationSeconds))) + { + AutoReverse = true + }; + Storyboard.SetTarget(opacityUp, _target); + Storyboard.SetTargetProperty(opacityUp, new PropertyPath("Opacity")); + targetAnimation.Children.Add(opacityUp); + break; + case ButtonAnimationType.BounceUp: + case ButtonAnimationType.BounceDown: + case ButtonAnimationType.TextBounceUp: + case ButtonAnimationType.TextBounceDown: + _target.RenderTransform = new TranslateTransform(0, 0); + var sizeBounds1 = new DoubleAnimation(0, boucedHeight, new Duration(TimeSpan.FromSeconds(_durationSeconds * 0.75))); + var sizeBounds2 = new DoubleAnimation(boucedHeight, 0, new Duration(TimeSpan.FromSeconds(_durationSeconds * 0.25))); + sizeBounds1.BeginTime = TimeSpan.FromSeconds(0); + sizeBounds2.BeginTime = TimeSpan.FromSeconds(_durationSeconds * 0.75); + Storyboard.SetTarget(sizeBounds1, _target); + Storyboard.SetTargetProperty(sizeBounds1, new PropertyPath("RenderTransform.Y")); + Storyboard.SetTarget(sizeBounds2, _target); + Storyboard.SetTargetProperty(sizeBounds2, new PropertyPath("RenderTransform.Y")); + targetAnimation.Duration = TimeSpan.FromSeconds(_durationSeconds); + targetAnimation.Children.Add(sizeBounds1); + targetAnimation.Children.Add(sizeBounds2); + break; + case ButtonAnimationType.SizeDown: + case ButtonAnimationType.TextSizeDown: + case ButtonAnimationType.SizeUp: + case ButtonAnimationType.TextSizeUp: + _target.RenderTransform = new ScaleTransform(1, 1, centerX, centerY); + var sizeXAni = new DoubleAnimation(1, sizeScale, new Duration(TimeSpan.FromSeconds(_durationSeconds))); + var sizeYAni = new DoubleAnimation(1, sizeScale, new Duration(TimeSpan.FromSeconds(_durationSeconds))); + sizeXAni.AutoReverse = true; + sizeYAni.AutoReverse = true; + Storyboard.SetTarget(sizeXAni, _target); + Storyboard.SetTargetProperty(sizeXAni, new PropertyPath("RenderTransform.ScaleX")); + Storyboard.SetTarget(sizeYAni, _target); + Storyboard.SetTargetProperty(sizeYAni, new PropertyPath("RenderTransform.ScaleY")); + targetAnimation.Children.Add(sizeXAni); + targetAnimation.Children.Add(sizeYAni); + break; + case ButtonAnimationType.Twist: + case ButtonAnimationType.TextTwist: + _target.RenderTransform = new RotateTransform(0, centerX, centerY); + var sizeAngleLeft = new DoubleAnimation(0, 9, new Duration(TimeSpan.FromSeconds(_durationSeconds * 0.25))); + var sizeAngleRight = new DoubleAnimation(0, -9, new Duration(TimeSpan.FromSeconds(_durationSeconds * 0.5))); + var sizeAngleCenter = new DoubleAnimation(-9, 0, new Duration(TimeSpan.FromSeconds(_durationSeconds * 0.25))); + sizeAngleLeft.BeginTime = TimeSpan.FromSeconds(0); + sizeAngleRight.BeginTime = TimeSpan.FromSeconds(_durationSeconds * 0.25); + sizeAngleCenter.BeginTime = TimeSpan.FromSeconds(_durationSeconds * 0.75); + Storyboard.SetTarget(sizeAngleLeft, _target); + Storyboard.SetTargetProperty(sizeAngleLeft, new PropertyPath("RenderTransform.Angle")); + Storyboard.SetTarget(sizeAngleRight, _target); + Storyboard.SetTargetProperty(sizeAngleRight, new PropertyPath("RenderTransform.Angle")); + Storyboard.SetTarget(sizeAngleCenter, _target); + Storyboard.SetTargetProperty(sizeAngleCenter, new PropertyPath("RenderTransform.Angle")); + targetAnimation.Duration = TimeSpan.FromSeconds(_durationSeconds); + targetAnimation.Children.Add(sizeAngleLeft); + targetAnimation.Children.Add(sizeAngleRight); + targetAnimation.Children.Add(sizeAngleCenter); + break; + case ButtonAnimationType.FlipX: + _target.RenderTransform = new ScaleTransform(1, 1, centerX, centerY); + var flipXAni = new DoubleAnimation(1, sizeScale, new Duration(TimeSpan.FromSeconds(_durationSeconds))); + flipXAni.AutoReverse = true; + Storyboard.SetTarget(flipXAni, _target); + Storyboard.SetTargetProperty(flipXAni, new PropertyPath("RenderTransform.ScaleX")); + targetAnimation.Children.Add(flipXAni); + break; + case ButtonAnimationType.FlipY: + _target.RenderTransform = new ScaleTransform(1, 1, centerX, centerY); + var flipYAni = new DoubleAnimation(1, sizeScale, new Duration(TimeSpan.FromSeconds(_durationSeconds))); + flipYAni.AutoReverse = true; + Storyboard.SetTarget(flipYAni, _target); + Storyboard.SetTargetProperty(flipYAni, new PropertyPath("RenderTransform.ScaleY")); + targetAnimation.Children.Add(flipYAni); + break; + default: + targetAnimation = null; + break; + } + } + catch + { + targetAnimation = null; + } + return targetAnimation; + } + /// + /// Send Image Animation + /// + /// + /// + /// + /// + /// + /// + public static Storyboard GetSendAnimation(FrameworkElement _target, ButtonSendAnimationType _sendAnimationType, double _moveX,double _moveY, double _durationSeconds = 0.5) + { + Storyboard targetAnimation = null; + try + { if (!_sendAnimationType.Equals(ButtonSendAnimationType.None)) + { + + targetAnimation = new Storyboard(); + var transformGroup = new TransformGroup(); + var translateTransform = new TranslateTransform(0, 0); + transformGroup.Children.Add(translateTransform); + + if (_sendAnimationType.Equals(ButtonSendAnimationType.SpeedChage) + || _sendAnimationType.Equals(ButtonSendAnimationType.SizeUpDown)) + { + var moveX1 = new DoubleAnimation(0, _moveX * 0.25, new Duration(TimeSpan.FromSeconds(_durationSeconds * 0.5))); + var moveX2 = new DoubleAnimation(_moveX * 0.25, _moveX, new Duration(TimeSpan.FromSeconds(_durationSeconds * 0.5))); + var moveY1 = new DoubleAnimation(0, _moveY * 0.25, new Duration(TimeSpan.FromSeconds(_durationSeconds * 0.5))); + var moveY2 = new DoubleAnimation(_moveY * 0.25, _moveY, new Duration(TimeSpan.FromSeconds(_durationSeconds * 0.5))); + moveX1.BeginTime = TimeSpan.FromSeconds(0); + moveX2.BeginTime = TimeSpan.FromSeconds(_durationSeconds * 0.5); + moveY1.BeginTime = TimeSpan.FromSeconds(0); + moveY2.BeginTime = TimeSpan.FromSeconds(_durationSeconds * 0.5); + Storyboard.SetTarget(moveX1, _target); + Storyboard.SetTargetProperty(moveX1, new PropertyPath(string.Format("RenderTransform.Children[{0}].(TranslateTransform.X)", transformGroup.Children.Count - 1))); + Storyboard.SetTarget(moveX2, _target); + Storyboard.SetTargetProperty(moveX2, new PropertyPath(string.Format("RenderTransform.Children[{0}].(TranslateTransform.X)", transformGroup.Children.Count - 1))); + Storyboard.SetTarget(moveY1, _target); + Storyboard.SetTargetProperty(moveY1, new PropertyPath(string.Format("RenderTransform.Children[{0}].(TranslateTransform.Y)", transformGroup.Children.Count - 1))); + Storyboard.SetTarget(moveY2, _target); + Storyboard.SetTargetProperty(moveY2, new PropertyPath(string.Format("RenderTransform.Children[{0}].(TranslateTransform.Y)", transformGroup.Children.Count - 1))); + targetAnimation.Duration = TimeSpan.FromSeconds(_durationSeconds); + targetAnimation.Children.Add(moveX1); + targetAnimation.Children.Add(moveX2); + targetAnimation.Children.Add(moveY1); + targetAnimation.Children.Add(moveY2); + if (_sendAnimationType.Equals(ButtonSendAnimationType.SizeUpDown)) + { + var scaleTransform = new ScaleTransform(1, 1, 0, 0); + transformGroup.Children.Add(scaleTransform); + var sizeAniX1 = new DoubleAnimation(1, 1.5, new Duration(TimeSpan.FromSeconds(_durationSeconds * 0.1))); + var sizeAniX2 = new DoubleAnimation(1.5, 1, new Duration(TimeSpan.FromSeconds(_durationSeconds * 0.9))); + var sizeAniY1 = new DoubleAnimation(1, 1.5, new Duration(TimeSpan.FromSeconds(_durationSeconds * 0.1))); + var sizeAniY2 = new DoubleAnimation(1.5, 1, new Duration(TimeSpan.FromSeconds(_durationSeconds * 0.9))); + sizeAniX1.BeginTime = TimeSpan.FromSeconds(0); + sizeAniX2.BeginTime = TimeSpan.FromSeconds(_durationSeconds * 0.1); + sizeAniY1.BeginTime = TimeSpan.FromSeconds(0); + sizeAniY2.BeginTime = TimeSpan.FromSeconds(_durationSeconds * 0.1); + Storyboard.SetTarget(sizeAniX1, _target); + Storyboard.SetTargetProperty(sizeAniX1, new PropertyPath(string.Format("RenderTransform.Children[{0}].(ScaleTransform.ScaleX)", transformGroup.Children.Count - 1))); + Storyboard.SetTarget(sizeAniX2, _target); + Storyboard.SetTargetProperty(sizeAniX2, new PropertyPath(string.Format("RenderTransform.Children[{0}].(ScaleTransform.ScaleX)", transformGroup.Children.Count - 1))); + Storyboard.SetTarget(sizeAniY1, _target); + Storyboard.SetTargetProperty(sizeAniY1, new PropertyPath(string.Format("RenderTransform.Children[{0}].(ScaleTransform.ScaleY)", transformGroup.Children.Count - 1))); + Storyboard.SetTarget(sizeAniY2, _target); + Storyboard.SetTargetProperty(sizeAniY2, new PropertyPath(string.Format("RenderTransform.Children[{0}].(ScaleTransform.ScaleY)", transformGroup.Children.Count - 1))); + targetAnimation.Children.Add(sizeAniX1); + targetAnimation.Children.Add(sizeAniX2); + targetAnimation.Children.Add(sizeAniY1); + targetAnimation.Children.Add(sizeAniY2); + + } + } + else if (_sendAnimationType.Equals(ButtonSendAnimationType.Normal)) + { + var moveX = new DoubleAnimation(0, _moveX, new Duration(TimeSpan.FromSeconds(_durationSeconds))); + var moveY = new DoubleAnimation(0, _moveY, new Duration(TimeSpan.FromSeconds(_durationSeconds))); + Storyboard.SetTarget(moveX, _target); + Storyboard.SetTargetProperty(moveX, new PropertyPath(string.Format("RenderTransform.Children[{0}].(TranslateTransform.X)", transformGroup.Children.Count - 1))); + Storyboard.SetTarget(moveY, _target); + Storyboard.SetTargetProperty(moveY, new PropertyPath(string.Format("RenderTransform.Children[{0}].(TranslateTransform.Y)", transformGroup.Children.Count - 1))); + targetAnimation.Children.Add(moveX); + targetAnimation.Children.Add(moveY); + } + _target.RenderTransform = transformGroup; + } + } + catch + { + targetAnimation = null; + } + return targetAnimation; + } + } +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Functions/CacheManager.cs b/Kiosk/Common/SPC.Kiosk.Common/Functions/CacheManager.cs new file mode 100644 index 0000000..c8f116c --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Functions/CacheManager.cs @@ -0,0 +1,109 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Runtime.Caching; + +namespace SPC.Kiosk.Common +{ + /// + /// Concurrent Dictionary Cache + /// + public static class CacheManager + { + private static MemoryCache _cache = MemoryCache.Default; + public static void CacheRemove(this string _key) + { + try + { + _cache.Remove(_key); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite("SPC.Kiosk.Common", "CacheManager", "CacheRemove()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// Add Cache a Item + /// + /// Item Type + /// Store Key + /// Store Item + /// IsSuccess + public static bool AddCache(this string _key,T _content) + { + bool result = false; + try + { + if (!_cache.Contains(_key) && _content !=null) + { + var policy = new CacheItemPolicy { SlidingExpiration = new TimeSpan(24, 0, 0) }; + _cache.Add(_key, _content, policy); + result = true; + } + + } + catch + { + result = false; + } + return result; + } + /// + /// Get Stored Item + /// + /// Item Type + /// Store Key + /// Item + public static T GetCache(this string _key) + { + var result = default(T); + try + { + if (_cache.Contains(_key)) + { + result = (T)_cache[_key]; + } + } + catch + { + result = default(T); + } + return result; + + } + /// + /// Check Cache Contain Item + /// + /// + /// + /// + public static bool CacheContain(this string _key) + { + bool result = false; + try + { + result = _cache.Contains(_key); + } + catch + { + result = false; + } + return result; + + } + #region Disposable Support + /// + /// Clear Dictionaly + /// + public static void Dispose() + { + _cache.Dispose(); + _cache = null; + } + #endregion + } + + +} \ No newline at end of file diff --git a/Kiosk/Common/SPC.Kiosk.Common/Functions/CommonChecker.cs b/Kiosk/Common/SPC.Kiosk.Common/Functions/CommonChecker.cs new file mode 100644 index 0000000..7d71193 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Functions/CommonChecker.cs @@ -0,0 +1,672 @@ + +namespace SPC.Kiosk.Common +{ + + public static class CommonChecker + { + + #region ASCII 영역체크 + /// + /// 문자,문자열이 모두 영문인지 체크 + /// + /// + /// + public static bool rIsAlpa(this string _inString) + { + bool result = false; + try + { + if (_inString != null && _inString.Length > 0) + { + char[] getChars = _inString.ToLower().ToCharArray(); + foreach (char getChar in getChars) + { + result = getChar.rIsAlpa(); + if (!result) break; + } + } + + } + catch + { + result = false; + } + return result; + } + /// + /// 문자가 영문자인지 체크 + /// + /// + /// + public static bool rIsAlpa(this char _inChar) + { + + return ((int)_inChar > 0x40 && (int)_inChar < 0x5B + || (int)_inChar > 0x60 && (int)_inChar < 0x7B); + + } + /// + /// 문자,문자열이 모두 영문 대문자인지 체크 + /// + /// + /// + public static bool rIsBigAlpa(this string _inString) + { + bool result = false; + try + { + if (_inString != null && _inString.Length > 0) + { + char[] getChars = _inString.ToCharArray(); + foreach (char getChar in getChars) + { + result = getChar.rIsBigAlpa(); + if (!result) break; + } + } + + } + catch + { + result = false; + } + return result; + } + /// + /// 문자가 대문자인지 체크 + /// + /// + /// + public static bool rIsBigAlpa(this char _inChar) + { + + return (int)_inChar > 0x40 && (int)_inChar < 0x5B; + + } + /// + /// 문자열이 모두 소문자인지 체크 + /// + /// + /// + public static bool rIsSmallAlpa(this string _inString) + { + bool result = false; + try + { + if (_inString != null && _inString.Length > 0) + { + char[] getChars = _inString.ToCharArray(); + foreach (char getChar in getChars) + { + result = getChar.rIsSmallAlpa(); + if (!result) break; + } + } + + } + catch + { + result = false; + } + return result; + } + /// + /// 문자열이 숫자인지 체크 + /// + /// + /// + public static bool rIsNum(this string _inString) + { + bool result = false; + try + { + if (_inString != null && _inString.Length > 0) + { + char[] getChars = _inString.ToCharArray(); + foreach (char getChar in getChars) + { + result = getChar.rIsNum(); + if (!result) break; + } + } + } + catch + { + result = false; + } + return result; + } + /// + /// 문자가 숫자인지 체크 + /// + /// + /// + public static bool rIsNum(this char _inChar) + { + + try + { + return ((int)_inChar > 0x2F && (int)_inChar < 0x3A); + } + catch + { + return false; + } + } + /// + /// 문자가 영문 소문자인지 체크 + /// + /// + /// + public static bool rIsSmallAlpa(this char _inChar) + { + + return (int)_inChar > 0x60 && (int)_inChar < 0x7B; + + } + /// + /// 문자열이 영문대소문자 또는 숫자로 인지 체크 + /// + /// + /// + public static bool rIsAlpaNum(this string _inString) + { + bool result = false; + try + { + + if (_inString != null && _inString.Length > 0) + { + char[] getChars = _inString.ToCharArray(); + foreach (char getChar in getChars) + { + result = getChar.rIsAlpaNum(); + if (!result) break; + } + } + + } + catch + { + result = false; + } + return result; + } + + /// + /// 문자가 영문자 또는 숫자인지 체크 + /// + /// + /// + public static bool rIsAlpaNum(this char _inChar) + { + return ((int)_inChar > 0x60 && (int)_inChar < 0x7B) + || ((int)_inChar > 0x40 && (int)_inChar < 0x5B) + || ((int)_inChar > 0x2F && (int)_inChar < 0x3A); + } + /// + /// 문자열이 Hex문자열인지 체크 + /// + /// + /// + public static bool rIsHexaNum(this string _inString) + { + bool result = false; + try + { + if (_inString != null && _inString.Length > 0) + { + if (_inString.Length % 2 > 0) + { + result = false; + } + else + { + char[] getChars = _inString.ToCharArray(); + foreach (char getChar in getChars) + { + result = getChar.rIsHexaNum(); + if (!result) break; + } + } + } + } + catch + { + result = false; + } + return result; + } + /// + /// 문자가 Hex문자에 속하는지 체크 + /// + /// + /// + public static bool rIsHexaNum(this char _inChar) + { + return ((int)_inChar > 0x60 && (int)_inChar < 0x67) + || ((int)_inChar > 0x40 && (int)_inChar < 0x47) + || ((int)_inChar > 0x2F && (int)_inChar < 0x3A); + } + /// + /// 문자열 Bit형(0,1)인지 체크 + /// + /// + /// + public static bool rIsBitNum(this string _inString) + { + bool result = false; + try + { + if (_inString != null && _inString.Length > 0) + { + if (_inString.Length % 8 > 0) + { + result = false; + } + else + { + char[] getChars = _inString.ToCharArray(); + foreach (char getChar in getChars) + { + result = getChar.rIsBitNum(); + if (!result) break; + } + } + } + } + catch + { + result = false; + } + return result; + } + /// + /// 문자가 Bit형(0,1)인지 체크 + /// + /// + /// + public static bool rIsBitNum(this char _inChar) + { + return (_inChar.Equals((char)0x30) || _inChar.Equals((char)0x31)); + } + #endregion + + #region 갯수 분석 + /// + /// 문자열내 특정문자 갯수 + /// + /// + /// + /// + public static int rCountChar(this string _inString, char _inChar) + { + return _inString.rCountChar(_inChar, CodeType.Default); + } + /// + /// 인코딩 된 문자열내 특정문자 갯수 + /// + /// + /// + /// + /// + public static int rCountChar(this string _inString, char _inChar, CodeType _CodeType) + { + int result = 0; + try + { + foreach (char _aChar in _inString.rToEncChar(_CodeType)) + { + if (_aChar.Equals(_inChar)) result++; + } + } + catch + { + result = 0; + } + return result; + } + /// + /// 문자열내 특정문자 갯수 + /// + /// + /// + /// + public static int rCountChar(this string _inString, string _inChar) + { + return _inString.rCountChar(_inChar, CodeType.Default); + } + /// + /// 문자열내 특정문자 갯수 + /// + /// + /// + /// + /// + public static int rCountChar(this string _inString, string _inChar, CodeType _CodeType) + { + int result = 0; + try + { + foreach (char _aChar in _inString.rToEncChar(_CodeType)) + { + if (_aChar.Equals(_inChar.ToCharArray()[0])) result++; + } + } + catch + { + result = 0; + } + return result; + } + /// + /// Byte배열내에 특정 바이트 갯수 + /// + /// + /// + /// + public static int rCountChar(this byte[] _inBytes, byte[] _inByte) + { + int result = 0; + try + { + foreach (byte _aByte in _inBytes) + { + if (_aByte.Equals(_inByte)) result++; + } + } + catch + { + result = 0; + } + return result; + } + + /// + /// 문자열내 대문자 숫자 갯수 + /// + /// + /// + public static int rCountBigAlpa(this string _inString) + { + int result = 0; + try + { + if (_inString != null && _inString.Length > 0) + { + char[] getChars = _inString.ToCharArray(); + foreach (char getChar in getChars) + { + result = getChar.rIsBigAlpa() ? result + 1 : result; + } + } + + } + catch + { + result = 0; + } + return result; + } + /// + /// 문자열내 소문자 갯수 + /// + /// + /// + public static int rCountSmallAlpa(this string _inString) + { + int result = 0; + try + { + if (_inString != null && _inString.Length > 0) + { + char[] getChars = _inString.ToCharArray(); + foreach (char getChar in getChars) + { + result = getChar.rIsSmallAlpa() ? result + 1 : result; + } + } + + } + catch + { + result = 0; + } + return result; + } + /// + /// 문자열내 숫자 갯수 + /// + /// + /// + public static int rCountNumber(this string _inString) + { + int result = 0; + try + { + if (_inString != null && _inString.Length > 0) + { + char[] getChars = _inString.ToCharArray(); + foreach (char getChar in getChars) + { + result = getChar.rIsNum() ? result + 1 : result; + } + } + + } + catch + { + result = 0; + } + return result; + } + /// + /// 문자열내 영문자 또는 숫자 갯수 + /// + /// + /// + public static int rCountAlpaNum(this string _inString) + { + int result = 0; + try + { + if (_inString != null && _inString.Length > 0) + { + char[] getChars = _inString.ToCharArray(); + foreach (char getChar in getChars) + { + result = getChar.rIsAlpaNum() ? result + 1 : result; + } + } + + } + catch + { + result = 0; + } + return result; + } + /// + /// 문자열내 특수문자 숫자 + /// + /// + /// + public static int rCountSpecialChar(this string _inString) + { + int result = 0; + try + { + if (_inString != null && _inString.Length > 0) + { + char[] getChars = _inString.ToCharArray(); + foreach (char getChar in getChars) + { + result = getChar.rIsAlpaNum() || (int)getChar > 0x92 ? result : result + 1; + } + } + + } + catch + { + result = 0; + } + return result; + } + /// + /// 문자열내 최대 동일문자 반복숫자 + /// + /// + /// + public static int rCountMaxRepeat(this string _inString) + { + int result = 0; + int count = 0; + try + { + if (_inString != null && _inString.Length > 0) + { + char[] getChars = _inString.ToCharArray(); + char lastChar = ' '; + foreach (char getChar in getChars) + { + if (getChar != lastChar) + { + if (count > result) result = count; + count = 1; + lastChar = getChar; + } + else + { + count++; + } + } + if (count > result) result = count; + } + + } + catch + { + result = 0; + } + return result; + } + #endregion + + #region 숫자 형식 체크 (정수,실수) + + /// + /// 문자열이 정수형인지 체크 + /// + /// + /// + public static bool rIsPlusInteger(this string _inString) + { + bool result = false; + try + { + if (_inString != null && _inString.Length > 0) + { + char[] getChars = _inString.ToCharArray(); + foreach (char getChar in getChars) + { + result = getChar.rIsNum(); + if (!result) break; + } + } + } + catch + { + result = false; + } + return result; + } + /// + /// 문자열이 정수형인지 체크 + /// + /// + /// + public static bool rIsInteger(this string _inString) + { + bool result = false; + try + { + if (_inString != null && _inString.Length > 0) + { + if (_inString.Length > 1 && _inString.StartsWith("-")) _inString = _inString.Substring(1); + char[] getChars = _inString.ToCharArray(); + foreach (char getChar in getChars) + { + result = getChar.rIsNum(); + if (!result) break; + } + } + + } + catch + { + result = false; + } + return result; + } + /// + /// 문자열이 실수형인지 체크 + /// + /// + /// + public static bool rIsFloat(this string _inString) + { + bool result = false; + try + { + if (_inString != null && _inString.Length > 0) + { + if (_inString.Length > 1 && _inString.StartsWith("-")) _inString = _inString.Substring(1); + int _firstPoint = _inString.IndexOf('.'); + if (_inString.IndexOf('.', _firstPoint + 1) == -1) + { + _inString = _inString.Replace(".", ""); + char[] getChars = _inString.ToCharArray(); + foreach (char getChar in getChars) + { + result = getChar.rIsNum(); + if (!result) break; + } + } + } + + } + catch + { + result = false; + } + return result; + } + + #endregion + + #region 암호등급 + /// + /// 암호 등급[ + /// 8자이하 0, + /// 반복문자가 있는 경우는 -1 Level, + /// 연속으로 동일 문자가 있으면 0, + /// 형태수 + 8자이상이면 4자마다 1식추가 + /// ] + /// + /// + /// + public static int rPassWordLevel(this string _inString) + { + int level = 0; + level += _inString.rCountBigAlpa() > 0 ? 1 : 0; + level += _inString.rCountSmallAlpa() > 0 ? 1 : 0; + level += _inString.rCountSpecialChar() > 0 ? 1 : 0; + level += _inString.rCountNumber() > 0 ? 1 : 0; + level = _inString.Length > 7 ? level + _inString.Length / 4 - 1 : 0; + level = _inString.rCountMaxRepeat() > 1 ? level - 1 : level; + return level; + } + #endregion + + } +} \ No newline at end of file diff --git a/Kiosk/Common/SPC.Kiosk.Common/Functions/CommonConverter.cs b/Kiosk/Common/SPC.Kiosk.Common/Functions/CommonConverter.cs new file mode 100644 index 0000000..cc30f91 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Functions/CommonConverter.cs @@ -0,0 +1,1942 @@ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace SPC.Kiosk.Common +{ + #region ASCII 제어 문자 정의 + /// + /// Control Char + /// + public static class Ctrl_CHAR + { + + /// + /// NULL [00]0x00 + /// + public static char Null = (char)Ctrl_ASCII.Null; + /// + /// SOH [01]0x01 + /// + public static char SOH = (char)Ctrl_ASCII.SOH; + /// + /// STX [02]0x02 + /// + public static char STX = (char)Ctrl_ASCII.STX; + /// + /// ETX [03]0x03 + /// + public static char ETX = (char)Ctrl_ASCII.ETX; + /// + /// EOT [04]0x04 + /// + public static char EOT = (char)Ctrl_ASCII.EOT; + /// + /// ENQ [05]0x05 + /// + public static char ENQ = (char)Ctrl_ASCII.ENQ; + /// + /// ACK [06]0x06 + /// + public static char ACK = (char)Ctrl_ASCII.ACK; + /// + /// BEL [07]0x07 + /// + public static char BEL = (char)Ctrl_ASCII.BEL; + /// + /// BS [08]0x08 + /// + public static char BS = (char)Ctrl_ASCII.BS; + /// + /// HT [09]0x09 + /// + public static char HT = (char)Ctrl_ASCII.HT; + /// + /// LF [0A]0x10 + /// + public static char LF = (char)Ctrl_ASCII.LF; + /// + /// VT [0B]0x11 + /// + public static char VT = (char)Ctrl_ASCII.VT; + /// + /// FF [0C]0x12 + /// + public static char FF = (char)Ctrl_ASCII.FF; + /// + /// CR [0D]0x13 + /// + public static char CR = (char)Ctrl_ASCII.CR; + /// + /// SO [0E]0x14 + /// + public static char SO = (char)Ctrl_ASCII.SO; + /// + /// SI [0F]0x15 + /// + public static char SI = (char)Ctrl_ASCII.SI; + /// + /// DLE [10]0x16 + /// + public static char DLE = (char)Ctrl_ASCII.DLE; + /// + /// DC1 [11]0x17 + /// + public static char DC1 = (char)Ctrl_ASCII.DC1; + /// + /// DC2 [12]0x18 + /// + public static char DC2 = (char)Ctrl_ASCII.DC2; + /// + /// DC3 [13]0x19 + /// + public static char DC3 = (char)Ctrl_ASCII.DC3; + /// + /// DC4 [14]0x20 + /// + public static char DC4 = (char)Ctrl_ASCII.DC4; + /// + /// NAK [15]0x21 + /// + public static char NAK = (char)Ctrl_ASCII.NAK; + /// + /// SYN [16]0x22 + /// + public static char SYN = (char)Ctrl_ASCII.SYN; + /// + /// ETB [17]0x23 + /// + public static char ETB = (char)Ctrl_ASCII.ETB; + /// + /// CAN [18]0x24 + /// + public static char CAN = (char)Ctrl_ASCII.CAN; + /// + /// EM [19]0x25 + /// + public static char EM = (char)Ctrl_ASCII.EM; + /// + /// SUB [1A]0x26 + /// + public static char SUB = (char)Ctrl_ASCII.SUB; + /// + /// ESC [1B]0x27 + /// + public static char ESC = (char)Ctrl_ASCII.ESC; + /// + /// FS [1C]0x28 + /// + public static char FS = (char)Ctrl_ASCII.FS; + /// + /// GS [1D]0x29 + /// + public static char GS = (char)Ctrl_ASCII.GS; + /// + /// RS [1E]0x30 + /// + public static char RS = (char)Ctrl_ASCII.RS; + /// + /// US [1F]0x32 + /// + public static char US = (char)Ctrl_ASCII.US; + } + + /// + /// Control Byte + /// + public static class Ctrl_BYTE + { + /// + /// NULL + /// + public static byte Null = (byte)Ctrl_ASCII.Null; + /// + /// SOH + /// + public static byte SOH = (byte)Ctrl_ASCII.SOH; + /// + /// STX + /// + public static byte STX = (byte)Ctrl_ASCII.STX; + /// + /// ETX + /// + public static byte ETX = (byte)Ctrl_ASCII.ETX; + /// + /// EOT + /// + public static byte EOT = (byte)Ctrl_ASCII.EOT; + /// + /// ENQ + /// + public static byte ENQ = (byte)Ctrl_ASCII.ENQ; + /// + /// ACK + /// + public static byte ACK = (byte)Ctrl_ASCII.ACK; + /// + /// BEL + /// + public static byte BEL = (byte)Ctrl_ASCII.BEL; + /// + /// BS + /// + public static byte BS = (byte)Ctrl_ASCII.BS; + /// + /// HT + /// + public static byte HT = (byte)Ctrl_ASCII.HT; + /// + /// LF + /// + public static byte LF = (byte)Ctrl_ASCII.LF; + /// + /// VT + /// + public static byte VT = (byte)Ctrl_ASCII.VT; + /// + /// FF + /// + public static byte FF = (byte)Ctrl_ASCII.FF; + /// + /// CR + /// + public static byte CR = (byte)Ctrl_ASCII.CR; + /// + /// SO + /// + public static byte SO = (byte)Ctrl_ASCII.SO; + /// + /// SI + /// + public static byte SI = (byte)Ctrl_ASCII.SI; + /// + /// DLE + /// + public static byte DLE = (byte)Ctrl_ASCII.DLE; + /// + /// DC1 + /// + public static byte DC1 = (byte)Ctrl_ASCII.DC1; + /// + /// DC2 + /// + public static byte DC2 = (byte)Ctrl_ASCII.DC2; + /// + /// DC3 + /// + public static byte DC3 = (byte)Ctrl_ASCII.DC3; + /// + /// DC4 + /// + public static byte DC4 = (byte)Ctrl_ASCII.DC4; + /// + /// NAK + /// + public static byte NAK = (byte)Ctrl_ASCII.NAK; + /// + /// SYN + /// + public static byte SYN = (byte)Ctrl_ASCII.SYN; + /// + /// ETB + /// + public static byte ETB = (byte)Ctrl_ASCII.ETB; + /// + /// CAN + /// + public static byte CAN = (byte)Ctrl_ASCII.CAN; + /// + /// EM + /// + public static byte EM = (byte)Ctrl_ASCII.EM; + /// + /// SUB + /// + public static byte SUB = (byte)Ctrl_ASCII.SUB; + /// + /// ESC + /// + public static byte ESC = (byte)Ctrl_ASCII.ESC; + /// + /// FS + /// + public static byte FS = (byte)Ctrl_ASCII.FS; + /// + /// GS + /// + public static byte GS = (byte)Ctrl_ASCII.GS; + /// + /// RS + /// + public static byte RS = (byte)Ctrl_ASCII.RS; + /// + /// US + /// + public static byte US = (byte)Ctrl_ASCII.US; + } + + /// + /// Cotrol Char String Type + /// + public static class Ctrl_STRING + { + /// + /// NULL + /// + public static string Null = ""; + /// + /// SOH + /// + public static string SOH = Convert.ToString((char)Ctrl_ASCII.SOH); + /// + /// STX + /// + public static string STX = Convert.ToString((char)Ctrl_ASCII.STX); + /// + /// ETX + /// + public static string ETX = Convert.ToString((char)Ctrl_ASCII.ETX); + /// + /// EOT + /// + public static string EOT = Convert.ToString((char)Ctrl_ASCII.EOT); + /// + /// ENQ + /// + public static string ENQ = Convert.ToString((char)Ctrl_ASCII.ENQ); + /// + /// ACK + /// + public static string ACK = Convert.ToString((char)Ctrl_ASCII.ACK); + /// + /// BEL + /// + public static string BEL = Convert.ToString((char)Ctrl_ASCII.BEL); + /// + /// BS + /// + public static string BS = Convert.ToString((char)Ctrl_ASCII.BS); + /// + /// HT + /// + public static string HT = Convert.ToString((char)Ctrl_ASCII.HT); + /// + /// LF + /// + public static string LF = Convert.ToString((char)Ctrl_ASCII.LF); + /// + /// VT + /// + public static string VT = Convert.ToString((char)Ctrl_ASCII.VT); + /// + /// FF + /// + public static string FF = Convert.ToString((char)Ctrl_ASCII.FF); + /// + /// CR + /// + public static string CR = Convert.ToString((char)Ctrl_ASCII.CR); + /// + /// SO + /// + public static string SO = Convert.ToString((char)Ctrl_ASCII.SO); + /// + /// SI + /// + public static string SI = Convert.ToString((char)Ctrl_ASCII.SI); + /// + /// DLE + /// + public static string DLE = Convert.ToString((char)Ctrl_ASCII.DLE); + /// + /// DC1 + /// + public static string DC1 = Convert.ToString((char)Ctrl_ASCII.DC1); + /// + /// DC2 + /// + public static string DC2 = Convert.ToString((char)Ctrl_ASCII.DC2); + /// + /// DC3 + /// + public static string DC3 = Convert.ToString((char)Ctrl_ASCII.DC3); + /// + /// DC4 + /// + public static string DC4 = Convert.ToString((char)Ctrl_ASCII.DC4); + /// + /// NAK + /// + public static string NAK = Convert.ToString((char)Ctrl_ASCII.NAK); + /// + /// SYN + /// + public static string SYN = Convert.ToString((char)Ctrl_ASCII.SYN); + /// + /// ETB + /// + public static string ETB = Convert.ToString((char)Ctrl_ASCII.ETB); + /// + /// CAN + /// + public static string CAN = Convert.ToString((char)Ctrl_ASCII.CAN); + /// + /// EM + /// + public static string EM = Convert.ToString((char)Ctrl_ASCII.EM); + /// + /// SUB + /// + public static string SUB = Convert.ToString((char)Ctrl_ASCII.SUB); + /// + /// ESC + /// + public static string ESC = Convert.ToString((char)Ctrl_ASCII.ESC); + /// + /// FS + /// + public static string FS = Convert.ToString((char)Ctrl_ASCII.FS); + /// + /// GS + /// + public static string GS = Convert.ToString((char)Ctrl_ASCII.GS); + /// + /// RS + /// + public static string RS = Convert.ToString((char)Ctrl_ASCII.RS); + /// + /// US + /// + public static string US = Convert.ToString((char)Ctrl_ASCII.US); + } + #endregion + public static class CommonConverter + { + #region For DB string + /// + /// 실수로 변환 + /// + /// 입력객체 + /// 실수 + public static float rDBToFloat(this object o) + { + float result; + try + { + if (o == DBNull.Value || o == null) result = 0F; + else + { + if (!float.TryParse(o.ToString(), out result)) result = 0F; + } + + } + catch + { + + result = 0F; + } + return result; + } + /// + /// 정수로 변환 + /// + /// + /// + public static int rDBToInt(this object o) + { + int result; + try + { + if (o == DBNull.Value || o == null) result = 0; + else + { + if (!Int32.TryParse(o.ToString(), out result)) result = 0; + } + + } + catch + { + + result = 0; + } + return result; + } + + /// + /// 문자로 변환 + /// + /// + /// + public static char rDBToChar(this object o) + { + char result; + try + { + if (o == DBNull.Value) + result = Ctrl_CHAR.Null; + else + result = o.ToString()[0]; + + } + catch + { + result = Ctrl_CHAR.Null; + } + return result; + } + /// + /// 문자열로 변환 + /// + /// + /// + public static string rDBToString(this object o) + { + string result; + try + { + if (o == DBNull.Value || o == null) + result = string.Empty; + else + result = o.ToString(); + + } + catch + { + result = string.Empty; + } + return result; + } + #endregion + + #region Hexa & Bit + /// + /// 숫자를 16진수 문자열로 + /// + /// + /// + public static string rToHexString(this int _inInt) + { + try + { + return (Convert.ToString(_inInt, 16)).ToUpper().PadLeft(2, '0'); + + } + catch + { + return string.Empty; + } + } + /// + /// Byte를 16진수 문자열로 + /// + /// + /// + public static string rToHexString(this byte _inByte) + { + try + { + return ((int)_inByte).rToHexString(); + + } + catch + { + return string.Empty; + } + } + /// + /// Char를 16진수 문자열로 + /// + /// + /// + public static string rToHexString(this char _inChar) + { + try + { + return ((int)_inChar).rToHexString(); + + } + catch + { + return string.Empty; + } + } + /// + /// Char배열을 Hex문자열로 + /// + /// + /// + public static string rToHexString(this char[] _inChars) + { + string result = string.Empty; + try + { + foreach (char _inChar in _inChars) + { + result += ((int)_inChar).rToHexString(); + } + } + catch + { + result = string.Empty; + } + return result; + } + /// + /// Byte배열을 Hex문자열로 + /// + /// + /// + public static string rToHexString(this byte[] _inBytes) + { + string result = string.Empty; + try + { + foreach (byte _inByte in _inBytes) + { + result += ((int)_inByte).rToHexString(); + } + } + catch + { + result = string.Empty; + } + return result; + } + /// + /// Integer배열을 Hex문자열로 + /// + /// + /// + public static string rToHexString(this int[] _inInts) + { + string result = string.Empty; + try + { + foreach (int _inInt in _inInts) + { + result += _inInt.rToHexString(); + } + } + catch + { + result = string.Empty; + } + return result; + } + + /// + /// 정수를 Bit문자열로 + /// + /// + /// + public static string rToBitString(this int _inInt) + { + try + { + return (Convert.ToString(_inInt, 2)).PadLeft(8, '0'); + + } + catch + { + return string.Empty; + } + } + + /// + /// Byte를 Bit문자열로 + /// + /// + /// + public static string rToBitString(this byte _inByte) + { + try + { + return ((int)_inByte).rToBitString(); + + } + catch + { + return string.Empty; + } + } + + /// + /// Char를 Bit문자열로 + /// + /// + /// + public static string rToBitString(this char _inChar) + { + try + { + return ((int)_inChar).rToBitString(); + + } + catch + { + return string.Empty; + } + } + /// + /// Char배열을 비트 문자열로 + /// + /// + /// + public static string rToBitString(this char[] _inChars) + { + return _inChars.rToByte().rToBitString(); + } + /// + /// Byte배열을 Bit문자열로 + /// + /// + /// + public static string rToBitString(this byte[] _inBytes) + { + string result = string.Empty; + try + { + for (int i = 0; i < _inBytes.Length; i++) + { + result += _inBytes[i].rToBitString(); + } + } + catch + { + result = string.Empty; + } + return result; + } + /// + /// Bit문자열을 Bool 배열로 + /// + /// + /// + public static bool[] rToBoolArray(this string _inString) + { + return _inString.ToCharArray().rToBoolArray(false); + } + /// + /// Bit문자열을 Bool 배열로 + /// + /// + /// 상위비트가 앞에 오도록 + /// + public static bool[] rToBoolArray(this string _inString, bool _Height2Low) + { + return _inString.ToCharArray().rToBoolArray(_Height2Low); + } + /// + /// Bit문자열을 옵션에 따라 Boolean 배열로 + /// + /// 입력Char배열 + /// 상위비트가 앞에 오도록 + /// + public static bool[] rToBoolArray(this char[] _getBit, bool _Height2Low) + { + bool[] result = null; + try + { + if (_Height2Low) + { + result = new bool[_getBit.Length]; + for (int i = 0; i < _getBit.Length; i++) + { + result[i] = _getBit[i] == '1'; + } + + } + else + { + + result = new bool[_getBit.Length]; + int pos = 0; + for (int i = 7; i > -1; i--) + { + result[pos] = _getBit[i] == '1'; + pos++; + } + } + } + catch + { + result = null; + } + return result; + } + + /// + /// 정수를 Bit값을 Boolean 배열로 (LowBit 가 0) + /// + /// + /// + public static bool[] rToBoolArray(this int _inInt) + { + bool[] result = null; + try + { + result = _inInt.rToBitString().rToBoolArray(); + } + catch + { + result = null; + } + return result; + } + /// + /// 정수의 Bit값을 Boolean 배열로 (HighBit 가 0) + /// + /// + /// + public static bool[] rToBoolArrayHL(this int _inInt) + { + bool[] result = null; + try + { + result = _inInt.rToBitString().rToBoolArray(true); + } + catch + { + result = null; + } + return result; + } + /// + /// Byte의 Byte값을 Boolean 배열로 (LowBit 가 0) + /// + /// + /// + public static bool[] rToBoolArray(this byte _inByte) + { + return ((int)_inByte).rToBoolArray(); + } + /// + /// Byte의 Bit값을 Boolean 배열로 (HighBit 가 0) + /// + /// + /// + public static bool[] rToBoolArrayHL(this byte _inByte) + { + return ((int)_inByte).rToBoolArrayHL(); + } + /// + /// Char값을 Boolean 배열로 (LowBit 가 0) + /// + /// + /// + public static bool[] rToBoolArray(this char _inChar) + { + return ((int)_inChar).rToBoolArray(); + } + /// + /// Char값을 Boolean 배열로 (HighBit 가 0) + /// + /// + /// + public static bool[] rToBoolArrayHL(this char _inChar) + { + return ((int)_inChar).rToBoolArrayHL(); + } + + /// + /// 정수문자열을 정수로(int) + /// + /// + /// + public static int rToInteger(this string _inString) + { + try + { + if (_inString.rIsInteger()) return int.Parse(_inString); + else return 0; + + } + catch + { + return 0; + } + } + /// + /// 정수문자열을 정수로(long) + /// + /// + /// + public static long rToLongInteger(this string _inString) + { + try + { + if (_inString.rIsInteger()) return long.Parse(_inString); + else return 0; + + } + catch + { + return 0; + } + } + /// + /// 16진수 문자열을 정수로 + /// + /// + /// + public static int rHexStrToInt(this string _inString) + { + try + { + if (_inString.StartsWith("0x")) _inString = _inString.Substring(_inString.IndexOf("x") + 1); + return Convert.ToInt16(_inString, 16); + + + } + catch + { + return 0; + } + } + /// + /// 16진수 문자열을 Byte로 + /// + /// + /// + public static byte rHexStrToByte(this string _inString) + { + return (byte)_inString.rHexStrToInt(); + } + /// + /// 16진수 문자열을 Byte배열로 + /// + /// + /// + public static byte[] rHexStrToBytes(this string _inString) + { + byte[] result = null; + try + { + if (_inString.Length % 2 == 1) _inString.PadLeft(_inString.Length + 1, '0'); + result = new byte[_inString.Length / 2]; + for (int i = 0; i < _inString.Length / 2; i++) + { + result[i] = (byte)_inString.Substring(i * 2, 2).rHexStrToInt(); + } + } + catch + { + result = null; + } + return result; + } + /// + /// 16진수 문자열을 Integer String으로 + /// + /// + /// + public static string rHexStringToIntStr(this string _inString) + { + string result = string.Empty; + try + { + if (_inString.Length % 2 == 1) _inString.PadLeft(_inString.Length + 1, '0'); + for (int i = 0; i < _inString.Length / 2; i++) + { + result += ((char)_inString.Substring(i * 2, 2).rHexStrToInt()).ToString(); + } + } + catch + { + result = null; + } + return result; + } + + + /// + /// 16진수 문자열을 CHar로 + /// + /// + /// + public static char rHexStrToChar(this string _inString) + { + return (char)_inString.rHexStrToInt(); + } + /// + /// 비트문자열을 정수로 + /// + /// + /// + public static int rBitStrToInt(this string _inString) + { + try + { + return Convert.ToInt16(_inString, 2); + + } + catch + { + return 0; + } + } + /// + /// 비트문자열을 Byte로 + /// + /// + /// + public static byte rBitStrToByte(this string _inString) + { + return (byte)_inString.rBitStrToInt(); + } + /// + /// 비트배열을 정수로 + /// + /// 8개짜리 bool배열 + /// + /// + public static int rToInteger(this bool[] _inBools, bool _Height2Low) + { + int result = 0; + try + { + string _bits = String.Empty; + if (_Height2Low) + { + for (int i = 0; i < _inBools.Length; i++) + { + _bits += _inBools[i] ? "1" : "0"; + } + + } + else + { + for (int i = 7; i > -1; i--) + { + _bits += _inBools[i] ? "1" : "0"; + } + } + result = _bits.rBitStrToInt(); + } + catch + { + result = 0; + } + return result; + } + /// + /// Highbit가 먼저인 Boolean 배열을 Integer로 + /// + /// + /// + public static int rHLtoInt(this bool[] _inBools) + { + return _inBools.rToInteger(true); + } + /// + /// Lowbit가 먼저인 Boolean 배열을 Integer로 + /// + /// + /// + public static int rToInteger(this bool[] _inBools) + { + return _inBools.rToInteger(false); + } + /// + /// Boolrean 배열을 Byte로 + /// + /// + /// true=High가 첫번째,false=Lowbit가 첫번째 + /// + public static byte rToByte(this bool[] _inBools, bool _Height2Low) + { + return (byte)_inBools.rToInteger(_Height2Low); + } + /// + /// Highbit가 먼저인 Boolean 배열을 Byte로 + /// + /// + /// + public static byte rHLtoByte(this bool[] _inBools) + { + return (byte)_inBools.rToInteger(true); + } + /// + /// Lowbit가 먼저인 Boolrean 배열을 Byte로 + /// + /// + /// + public static byte rToByte(this bool[] _inBools) + { + return (byte)_inBools.rToInteger(false); + } + /// + /// char 배열을 byte배열로 + /// + /// + /// + public static byte[] rToByte(this char[] _inChars) + { + byte[] result = null; + try + { + result = new byte[_inChars.Length]; + for (int i = 0; i < _inChars.Length; i++) + { + result[i] = (byte)_inChars[i]; + } + } + catch + { + result = null; + } + return result; + } + /// + /// byte배열을 char배열로 + /// + /// + /// + public static char[] rToChar(this byte[] _inByte) + { + char[] result = null; + try + { + result = new char[_inByte.Length]; + for (int i = 0; i < _inByte.Length; i++) + { + result[i] = (char)_inByte[i]; + } + } + catch + { + result = null; + } + return result; + } + #endregion + + #region MakeLRC + /// + /// LRC Make + /// + /// + /// + public static string rMakeLRC(this string _Data) + { + return rMakeLRC(_Data, CodeType.Default); + } + /// + /// LRC Make + /// + /// + /// + /// + public static string rMakeLRC(this string _Data, CodeType _CodeType) + { + try + { + //long makeCheckSum = 0; + //byte[] DataBytes = _Data.rToByteArray(); + //foreach (byte abyte in DataBytes) makeCheckSum += abyte; + //string checksum = makeCheckSum.ToString("X2"); + return rMakeLRC(_Data.rToByteArray(_CodeType)).ToString(); + + } + catch + { + + return string.Empty; + } + } + /// + /// LRC Make + /// + /// + /// + public static byte rMakeLRC(this byte[] _Data) + { + try + { + byte LRC = _Data[0]; + for (int i = 1; i < _Data.Length; i++) + { + LRC = (byte)(LRC ^ _Data[i]); + } + return LRC; + } + catch + { + return 0x00; + } + } + /// + /// LRC Make + /// + /// + /// + public static char rMakeLRC(this char[] _Data) + { + try + { + return (char)rMakeLRC(_Data.rToByte()); + + } + catch + { + return (char)0x00; + } + } + + #endregion + + #region Checksum Make + /// + /// Checksum Make + /// + /// + /// + public static string rCheckSum(this string _Data) + { + return rCheckSum(_Data, CodeType.Default); + } + /// + /// Checksum Make + /// + /// + /// + /// + public static string rCheckSum(this string _Data, CodeType _CodeType) + { + try + { + //long makeCheckSum = 0; + //byte[] DataBytes = _Data.rToByteArray(); + //foreach (byte abyte in DataBytes) makeCheckSum += abyte; + //string checksum = makeCheckSum.ToString("X2"); + return rCheckSum(_Data.rToByteArray(_CodeType)).rToEncString(_CodeType); + + } + catch + { + + return string.Empty; + } + } + /// + /// Checksum Make + /// + /// + /// + public static byte[] rCheckSum(this byte[] _Data) + { + try + { + long makeCheckSum = 0; + foreach (byte abyte in _Data) makeCheckSum += abyte; + string checksum = makeCheckSum.ToString("X2"); + return checksum.Substring(checksum.Length - 2, 2).rToByteArray(); + + } + catch + { + return null; + } + } + /// + /// Checksum Make + /// + /// + /// + public static char[] rCheckSum(this char[] _Data) + { + try + { + return rCheckSum(_Data.rToByte()).rToChar(); + + } + catch + { + return null; + } + } + #endregion + + #region Encodings & Decoding + /// + /// 문자열을 Char배열로(Encodeing by Default) + /// + /// + /// 코드페이지 오류시 null + public static char[] rToEncChar(this string _inString) + { + return _inString.rToEncChar(CodeType.Default); + } + /// + /// 문자열을 Char배열로 + /// + /// + /// + /// 코드페이지 오류시 null + public static char[] rToEncChar(this string _inString, CodeType _CodeType) + { + return _inString.rToByteArray(_CodeType).rToChar(); + } + /// + /// 문자열을 Byte배열로(Encodeing by Default) + /// + /// + /// 코드페이지 오류시 null + public static byte[] rToByteArray(this string _inString) + { + return _inString.rToByteArray(CodeType.Default); + } + /// + /// 문자열을 Byte배열로 + /// + /// + /// + /// + public static byte[] rToByteArray(this string _inString, CodeType _CodeType) + { + return _CodeType.rGetEncoding().GetBytes(_inString); + } + /// + /// 문자열로 CodeType 형식 구하기 + /// + /// + /// + public static CodeType rGetCodeType(this Encoding _Encoding) + { + CodeType result = CodeType.Default; + try + { + switch (_Encoding.ToString()) + { + case "ASCII": + result = CodeType.ASCII; + break; + case "BigEndianUnicode": + result = CodeType.BigEdianUnicode; + break; + case "Unicode": + result = CodeType.Unicode; + break; + case "UTF7": + result = CodeType.UTF7; + break; + case "UTF8": + result = CodeType.UTF8; + break; + case "UTF32": + result = CodeType.UTF32; + break; + case "Default": + result = CodeType.Default; + break; + } + + } + catch + { + } + return result; + } + /// + /// Code Type에 + /// 맞는 Encoding 가져오기 + /// + /// + /// Encoding + public static Encoding rGetEncoding(this CodeType _CodeType) + { + Encoding result = Encoding.Default; + try + { + switch (_CodeType) + { + case CodeType.ASCII: + result = Encoding.ASCII; + break; + case CodeType.BigEdianUnicode: + result = Encoding.BigEndianUnicode; + break; + case CodeType.Unicode: + result = Encoding.Unicode; + break; + case CodeType.UTF7: + result = Encoding.UTF7; + break; + case CodeType.UTF8: + result = Encoding.UTF8; + break; + case CodeType.UTF32: + result = Encoding.UTF32; + break; + case CodeType.Default: + result = Encoding.Default; + break; + } + } + catch + { + result = Encoding.Default; + } + return result; + + } + /// + /// Char배열을 문자열로(Encodeing by Default) + /// + /// + /// 코드페이지 오류시 빈문자열 + public static string rToEncString(this char[] _inChars) + { + return _inChars.rToByte().rToEncString(CodeType.Default); + } + /// + /// Char배열을 문자열로 + /// + /// + /// + /// 코드페이지 오류시 빈문자열 + public static string rToEncString(this char[] _inChars, CodeType _CodeType) + { + return _inChars.rToByte().rToEncString(_CodeType); + } + /// + /// Byte배열을 문자열로(Encodeing by Default) + /// + /// + /// 코드페이지 오류시 빈문자열 + public static string rToEncString(this byte[] _inBytes) + { + return _inBytes.rToEncString(CodeType.Default); + } + /// + /// Byte배열을 문자열로 + /// + /// + /// + /// 코드페이지 오류시 빈문자열 + public static string rToEncString(this byte[] _inBytes, CodeType _CodeType) + { + string result = null; + try + { + + switch (_CodeType) + { + case CodeType.ASCII: + result = Encoding.ASCII.GetString(_inBytes); + break; + case CodeType.BigEdianUnicode: + result = Encoding.BigEndianUnicode.GetString(_inBytes); + break; + case CodeType.Unicode: + result = Encoding.Unicode.GetString(_inBytes); + break; + case CodeType.UTF7: + result = Encoding.UTF7.GetString(_inBytes); + break; + case CodeType.UTF8: + result = Encoding.UTF8.GetString(_inBytes); + break; + case CodeType.UTF32: + result = Encoding.UTF32.GetString(_inBytes); + break; + case CodeType.Default: + result = Encoding.Default.GetString(_inBytes); + break; + } + } + catch + { + result = string.Empty; + } + return result; + } + + /// + /// Base64 인코딩을 합니다 + /// + /// 입력문자열 + /// 오류시 빈문자열 + public static string rBase64Encode(this string _inString) + { + return _inString.rBase64Encode(CodeType.Default); + } + /// + /// Base64 인코딩을 합니다 + /// + /// 입력문자열 + /// + /// 코드페이지 오류시 빈문자열 + public static string rBase64Encode(this string _inString, CodeType _CodeType) + { + try + { + return Convert.ToBase64String(_inString.rToByteArray(_CodeType)); + + } + catch + { + return string.Empty; + } + } + /// + /// Base64 인코딩을 합니다 + /// + /// 엔코딩한 문자열 Byte배열 + /// 오류시 빈문자열 + public static string rBase64Encode(this byte[] _inBytes) + { + try + { + return Convert.ToBase64String(_inBytes); + + } + catch + { + return string.Empty; + } + } + /// + /// Base64 인코딩을 합니다 + /// + /// 엔코딩한 문자열 Byte배열 + /// 오류시 빈문자열 + public static string rBase64Encode(this char[] _inChars) + { + try + { + return _inChars.rToByte().rBase64Encode(); + + } + catch + { + return string.Empty; + } + } + /// + /// Base64 인코딩을 합니다 + /// + /// + /// + public static char[] rBase64EncodeChars(this byte[] _inBytes) + { + try + { + return rBase64Encode(_inBytes).ToCharArray(); + + } + catch + { + return null; + } + } + /// + /// Base64 인코딩을 합니다 + /// + /// + /// + public static char[] rBase64EncodeChars(this string _inString) + { + return _inString.rBase64Encode(CodeType.Default).ToCharArray(); + } + /// + /// Base64 인코딩을 합니다 + /// + /// + /// + /// + public static char[] rBase64EncodeChars(this string _inString, CodeType _CodeType) + { + return _inString.rBase64Encode(_CodeType).ToCharArray(); + } + /// + /// Base64 인코딩을 합니다 + /// + /// + /// + public static byte[] rBase64EncodeBytes(this string _inString) + { + return _inString.rBase64EncodeChars().rToByte(); + } + /// + /// Base64 인코딩을 합니다 + /// + /// + /// + /// + public static byte[] rBase64EncodeBytes(this string _inString, CodeType _CodeType) + { + return _inString.rBase64EncodeChars(_CodeType).rToByte(); + } + + /// + /// Base64 디코딩을 합니다 + /// + /// 입력문자열 + /// 오류시 빈문자열 + public static byte[] rBase64DecodeBytes(this string _inString) + { + try + { + return Convert.FromBase64String(_inString); + + } + catch + { + return null; + } + } + /// + /// Base64 디코딩을 합니다 + /// + /// 입력문자열 + /// 코드페이지 오류시 빈문자열 + public static byte[] rBase64DecodeBytes(this byte[] _inBytes) + { + return _inBytes.rToChar().rBase64DecodeBytes(); + } + /// + /// Base64 디코딩을 합니다 + /// + /// + /// + public static byte[] rBase64DecodeBytes(this char[] _inChars) + { + try + { + return Convert.FromBase64CharArray(_inChars, 0, _inChars.Length); + + } + catch + { + return null; + } + } + /// + /// Base64 디코딩을 합니다 + /// + /// + /// + public static string rBase64Decode(this string _inString) + { + return _inString.rBase64Decode(CodeType.Default); + } + /// + /// Base64 디코딩을 합니다 + /// + /// + /// + /// + public static string rBase64Decode(this string _inString, CodeType _CodeType) + { + return _inString.rBase64DecodeBytes().rToEncString(_CodeType); + } + /// + /// Base64 디코딩을 합니다 + /// + /// + /// + public static string rBase64Decode(this byte[] _inBytes) + { + return _inBytes.rToChar().rBase64Decode(); + } + /// + /// Base64 디코딩을 합니다 + /// + /// + /// + public static string rBase64Decode(this char[] _inChars) + { + return _inChars.rBase64Decode(CodeType.Default); + } + /// + /// Base64 디코딩을 합니다 + /// + /// + /// + /// + public static string rBase64Decode(this byte[] _inBytes, CodeType _CodeType) + { + return _inBytes.rToChar().rBase64Decode(_CodeType); + } + /// + /// Base64 디코딩을 합니다 + /// + /// + /// + /// + public static string rBase64Decode(this char[] _inChars, CodeType _CodeType) + { + try + { + return Convert.FromBase64CharArray(_inChars, 0, _inChars.Length).rToEncString(_CodeType); + + } + catch + { + return null; + } + } + #endregion + + #region 컨트롤 문자를 컨트롤 문자명으로 찾기 + /// + /// Find Cotrol ANSI by Cotrol Code Name + /// + /// + /// + public static Ctrl_ASCII rGetControlANSI(this string _inCode) + { + try + { + return (Ctrl_ASCII)Array.IndexOf(Enum.GetNames(typeof(Ctrl_ASCII)), _inCode.ToUpper().Replace("<", "").Replace(">", "")); + + } + catch + { + return Ctrl_ASCII.Null; + } + } + /// + /// Find Cotrol ANSI by Cotrol Code Name + /// + /// + /// + public static char rGetControlChar(this string _inCode) + { + return (char)(_inCode.Replace("<", "").Replace(">", "").rGetControlANSI()); + } + /// + /// Find Cotrol ANSI by Cotrol Code Name + /// + /// + /// + public static byte rGetControlByte(this string _inCode) + { + return (byte)(_inCode.Replace("<", "").Replace(">", "").rGetControlANSI()); + } + /// + /// Find Cotrol ANSI by Cotrol Code Name + /// + /// + /// + public static string rGetControlString(this string _inCode) + { + try + { + return _inCode.Equals(string.Empty) ? string.Empty : Convert.ToString(_inCode.Replace("<", "").Replace(">", "").rGetControlChar()); + } + catch + { + return string.Empty; + } + } + + /// + /// ASCII Control Code to CodeName + /// 문자에 대한 ASCII control 코드명 구하기 + /// + /// + /// + public static string rReplaceANSIToTag(this string _inString) + { + try + { + _inString = _inString.Replace("\0", ""); + foreach (string ctrlCode in Enum.GetNames(typeof(Ctrl_ASCII))) + { + + if (!ctrlCode.Equals(string.Empty)) + _inString = _inString.Replace(ctrlCode.rGetControlString(), string.Format("<{0}>", ctrlCode)); + } + return _inString; + + } + catch + { + return string.Empty; + } + } + /// + /// CodeName to ASCII Control Code + /// 문자열을 바이트 표시 문자열로 변환 + /// + /// + /// + public static string rReplaceToANSI(this string _inString) + { + try + { + foreach (string ctrlCode in Enum.GetNames(typeof(Ctrl_ASCII))) + { + + if (!ctrlCode.Equals(string.Empty)) + _inString = _inString.Replace(string.Format("<{0}>", ctrlCode), ctrlCode.rGetControlString()); + } + return _inString; + + } + catch + { + return string.Empty; + } + } + /// + /// 바이트 표시 형식 문자열을 바이트 배열로 반환 + /// + /// + /// + public static byte[] rReplaceToByte(this string _inString) + { + try + { + string strbuff = _inString; + foreach (string ctrlCode in Enum.GetNames(typeof(Ctrl_ASCII))) + { + + if (!ctrlCode.Equals(string.Empty)) + strbuff = strbuff.Replace(string.Format("<{0}>", ctrlCode), ctrlCode.rGetControlString()); + } + string[] inChars = strbuff.Split('<'); + byte[] result = new byte[0]; + byte[] makeBlock = new byte[0]; + foreach (string aChar in inChars) + { + if (aChar.StartsWith("0x")) + { + string[] inChars2 = aChar.Split('>'); + foreach (string aChar2 in inChars2) + { + if (!aChar2.Equals(string.Empty)) + { + if (aChar2.StartsWith("0x")) + { + makeBlock = new byte[] { aChar2.Replace("0x", "").rHexStrToByte() }; + } + else + { + makeBlock = aChar2.rToByteArray(); + } + int addPos = result.Length; + Array.Resize(ref result, result.Length + makeBlock.Length); + Array.Copy(makeBlock, 0, result, addPos, makeBlock.Length); + } + } + + } + else + { + makeBlock = aChar.rToByteArray(); + int addPos = result.Length; + Array.Resize(ref result, result.Length + makeBlock.Length); + Array.Copy(makeBlock, 0, result, addPos, makeBlock.Length); + } + } + return result; + + } + catch + { + return null; + } + } + + #endregion + + #region byte수를 문자열로 표시 + /// + /// 바이트수를 문자열로 표시 + /// + /// 바이트수 + /// + public static string rByteCountToString(this int _inInt) + { + return rByteCountToString((long)_inInt); + } + /// + /// 바이트수를 문자열로 표시 + /// + /// 바이트수 + /// + public static string rByteCountToString(this long _inLong) + { + return rByteCountToString((double)_inLong); + } + /// + /// 바이트수를 문자열로 표시 + /// + /// + /// + public static string rByteCountToString(this double _inDeouble) + { + string result = string.Empty; + try + { + result = string.Format("{0}Bytes", _inDeouble.ToString("#,##0")); + if (_inDeouble > 512d) + { + if (_inDeouble > (1024d * 512d)) + { + if (_inDeouble > (1024d * 1024d * 512d)) + { + if (_inDeouble > (1024d * 1024d * 1024d * 512d)) + { + result = string.Format("{0}TB", (_inDeouble / 1024d / 1024d / 1024d / 1024d).ToString("#,##0.00")); + } + else + { + result = string.Format("{0}GB", (_inDeouble / 1024d / 1024d / 1024d).ToString("#,##0.00")); + } + } + else + { + result = string.Format("{0}MB", (_inDeouble / 1024d / 1024d).ToString("#,##0.00")); + } + } + else + { + result = string.Format("{0}KB", (_inDeouble / 1024d).ToString("#,##0.00")); + } + } + } + catch + { + } + return result; + } + #endregion + /// + /// 문자열 중 숫자만 뽑기 + /// + /// + /// + public static string rGetOnlyNum(this string _inString) + { + string result = string.Empty; + try + { + if (_inString != null && _inString.Length > 0) + { + char[] getChars = _inString.ToCharArray(); + foreach (char getChar in getChars) + { + if (getChar.rIsNum()) + { + result += getChar; + } + } + } + } + catch + { + + result = string.Empty; + } + return result; + } + } +} \ No newline at end of file diff --git a/Kiosk/Common/SPC.Kiosk.Common/Functions/CommonFunction.cs b/Kiosk/Common/SPC.Kiosk.Common/Functions/CommonFunction.cs new file mode 100644 index 0000000..0d29578 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Functions/CommonFunction.cs @@ -0,0 +1,275 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; +using System.Globalization; +using SPC.Kiosk.Base; +using System.Windows.Media; +using System.Collections.ObjectModel; +using Cosmos.UserFrame; +namespace SPC.Kiosk.Common +{ + public static class CommonFunction + { + /// + /// Reregister Name an Object + /// + /// + /// + /// + public static void ReregisterName(this FrameworkElement _frameworkElement, string _registerName,object _registerObject) + { + try + { + if (_frameworkElement.FindName(_registerName) != null) + { + _frameworkElement.UnregisterName(_registerName); + } + _frameworkElement.RegisterName(_registerName, _registerObject); + } + catch + { + } + } + + /// + /// Find Parent object by name + /// + /// + /// + /// + public static object FindParent(this object _child, string _findName) + { + object result = null; + try + { + var _parent = _child; + while (_parent != null) + { + var getType = _parent.GetType(); + var nameProperty = getType.GetProperty("Name"); + var getName = nameProperty.GetValue(_parent, null); + if (getName.Equals(_findName) && getType.Name.Equals("Grid")) + { + result = _parent; + break; + } + var parentProperty = getType.GetProperty("Parent"); + _parent = parentProperty.GetValue(_parent, null); + } + } + catch + { + result = null; + } + return result; + } + /// + /// String Text Show Rander Size Caculate + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static Size GetFormatedTextSize(this string _inString + , SupportLanguageType _languageType + , double _fontSize + , FontFamily _fontFamily + , FontStyle _fontStyle + , FontWeight _fontWeight + , FontStretch _fontStretch) + { + var result = new Size(0,0); + try + { + if (string.IsNullOrEmpty(_inString)) + { + result = new Size(0, 0); + } + else + { + var formattedText = new FormattedText(_inString, + CultureInfo.GetCultureInfo(_languageType.ToString()), + FlowDirection.LeftToRight, + new Typeface(_fontFamily, _fontStyle, _fontWeight, _fontStretch), + _fontSize, + Brushes.Black); + result = new Size(formattedText.Width, formattedText.Height); + } + } + catch + { + result = new Size(0, 0); + } + return result; + } + /// + /// 문자열 길이를 목적 폭에 마춰서 자르기 (... 뒤에 추가) + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static string TextTrimming(this string _inString + , SupportLanguageType _languageType + , double _fontSize + , FontFamily _fontFamily + , FontStyle _fontStyle + , FontWeight _fontWeight + , FontStretch _fontStretch + , double _targetWidth) + { + var result = _inString; + try + { + if (!string.IsNullOrEmpty(_inString) + && !_targetWidth.Equals(double.NaN) + && _targetWidth > 0) + { + var sourceWidth = _inString.GetFormatedTextSize(_languageType + , _fontSize + , _fontFamily + , _fontStyle + , _fontWeight + , _fontStretch).Width; + if (sourceWidth > _targetWidth) + { + int subCount = 1; + var subString = _inString; + var newStringWidth = 0d; + do + { + subCount++; + if (subString.Length > subCount) + { + subString = subString.Substring(0, _inString.Length - subCount) + "..."; + newStringWidth = subString.GetFormatedTextSize(_languageType + , _fontSize + , _fontFamily + , _fontStyle + , _fontWeight + , _fontStretch).Width; + } + else + { + break; + } + } while (newStringWidth > _targetWidth); + result = subString; + } + } + } + catch + { + result = _inString; + } + return result; + } + /// + /// Make Option Label + /// + /// + /// + public static List GetOptionLabel(List _option) + { + List result = null; + try + { + if (_option is List) + { + var index = 0; + result = new List(); + foreach (var aGroup in _option) + { + foreach (var aOption in aGroup.Options) + { + if (aOption.IsSelected) + { + if (aOption.Name is List) + { + if (index.Equals(0)) + { + foreach (var aName in aOption.Name) + { + result.Add(aName.Clone()); + } + } + else + { + foreach (var aName in result) + { + var addLanguageData = Languages.GetLanguageData(aOption.Name, aName.Type); + aName.LanguageData += "/" + addLanguageData; + if (aOption.Kind.Equals(OptionKind.Count)) + { + aName.LanguageData += string.Format("({0})", aOption.SelectValue.ToString("#,##0")); + } + } + } + index++; + } + } + } + } + } + } + catch + { + result = null; + } + return result; + } + /// + /// GetDate from string + /// + /// + /// + public static DateTime GetDate(string _dateString) + { + var result = DateTime.MinValue; + try + { + + if (_dateString.Length.Equals(6)) + { + result = DateTime.Parse(String.Format("{0}-{1}-{2}" + , _dateString.Substring(0, 2), _dateString.Substring(2, 2), _dateString.Substring(4, 2))).Date; + } + else if (_dateString.Length.Equals(8)) + { + result = DateTime.Parse(String.Format("{0}-{1}-{2}" + , _dateString.Substring(0, 4), _dateString.Substring(4, 2), _dateString.Substring(6, 2))).Date; + } + else + { + result = DateTime.Parse(_dateString).Date; + } + } + catch + { + result = DateTime.MinValue; + } + if (result.Equals(DateTime.MinValue)) + { + result = DateTime.Now.Date; + } + return result; + } + + + } +} \ No newline at end of file diff --git a/Kiosk/Common/SPC.Kiosk.Common/Functions/CommonLog.cs b/Kiosk/Common/SPC.Kiosk.Common/Functions/CommonLog.cs new file mode 100644 index 0000000..212b637 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Functions/CommonLog.cs @@ -0,0 +1,377 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +namespace SPC.Kiosk.Common +{ + /// + /// Common Logging Class + /// + public static class CommonLog + { + /// + /// Info Log Write + /// + /// + /// + /// + /// + /// + public static void InfoLogWrite(string _nameSpace, string _className, string _functionName, string _logString, string _subString = "") + { + try + { + InfoLogWrite(string.Format("{0}.{1} {2} {3}", _nameSpace, _className, _functionName, _logString), _subString); + } + catch + { + } + } + /// + /// Info Log Write + /// + /// + /// + /// + /// + public static void InfoLogWrite(object _sendClass, string _functionName, string _logString="", string _subString = "") + { + try + { + LogWrite(Log_Type.Info, _sendClass, _functionName, _logString, _subString); + + } + catch + { + } + } + + /// + /// Info Log Write + /// + /// + /// + public static void InfoLogWrite(string _logString, string _subString = "") + { + try + { + LogWrite(Log_Type.Info, _logString, _subString); + + } + catch + { + } + } + + /// + /// Error Log Write + /// + /// + /// + /// + /// + /// + public static void ErrorLogWrite(string _nameSpace, string _className, string _functionName, string _errorLogString, string _errorSubString = "") + { + try + { + ErrorLogWrite(string.Format("{0}.{1} {2} {3}", _nameSpace, _className, _functionName, _errorLogString), _errorSubString); + } + catch + { + } + } + /// + /// Error Log Write + /// + /// + /// + /// + /// + public static void ErrorLogWrite(object _sendClass, string _functionName, string _errorLogString="", string _errorSubString = "") + { + try + { + LogWrite(Log_Type.Error, _sendClass, _functionName, _errorLogString, _errorSubString); + + } + catch + { + } + } + /// + /// Error Log Write + /// + /// + /// + public static void ErrorLogWrite(string _errorLogString, string _errorSubString = "") + { + try + { + LogWrite(Log_Type.Error, _errorLogString, _errorSubString); + + } + catch + { + } + } + /// + /// Bebug Log Write + /// + /// + /// + /// + /// + /// + public static void DebugLogWrite(string _nameSpace, string _className, string _functionName, string _debugLogString, string _debugSubString = "") + { + try + { + DebugLogWrite(string.Format("{0}.{1} {2} {3}", _nameSpace, _className, _functionName, _debugLogString), _debugSubString); + } + catch + { + } + } + /// + /// Bebug Log Write + /// + /// + /// + /// + /// + public static void DebugLogWrite(object _sendClass, string _functionName, string _debugLogString="", string _debugSubString = "") + { + try + { + LogWrite(Log_Type.Debug, _sendClass, _functionName, _debugLogString, _debugSubString); + + } + catch + { + } + } + /// + /// Bebug Log Write + /// + /// + /// + public static void DebugLogWrite(string _debugLogString, string _debugSubString = "") + { + try + { + LogWrite(Log_Type.Debug, _debugLogString, _debugSubString); + } + catch + { + } + } + /// + /// Log Write + /// + /// + /// + /// + /// + /// + private static void LogWrite(Log_Type _logType, object sendClass, string _functionName, string _logString, string _subString) + { + try + { + var type = sendClass.GetType(); + LogWrite(_logType, string.Format("{0}.{1} {2} {3}", type.Namespace, type.Name, _functionName, _logString), _subString); + } + catch + { + LogWrite(_logType, string.Format("{0} {1}", _functionName, _logString), _subString); + } + } + + /// + /// Log Write + /// + /// + /// + /// + private static void LogWrite(Log_Type _logType, string _logString,string _logSubString) + { + try + { + using (var oLog = new logging(CommonValue.KioskLogSetting)) + { + oLog.LogWrite + ( + new Log_Message + { + LogDate = DateTime.Now, + LogFrom = CommonValue.LogName, + LogType = _logType, + LogMessage = string.IsNullOrEmpty(_logString) + ? _logString + : string.Format("{0}\n\t{1}", _logString, _logSubString), + } + ); + } + + } + catch + { + } + } + + } + + #region Log Writer Class + /// + /// Log Store Object + /// + public class logging : IDisposable + { + private Log_Setting Log_CFG; //Object Configuration Infomation + private DateTime LastLogTime; //Last Log Create Time + private String _LogPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Log"); + /// + /// Log Configuration Setting + /// + public Log_Setting Log_Set + { + get { return Log_CFG; } + set { Log_CFG = value; } + } + /// + /// logging a Message object + /// + /// + public logging(Log_Setting _LogCFG) + { + Log_Set = _LogCFG; + if (!Log_Set.LogPath.Equals(string.Empty) && !Log_Set.LogName.Equals(string.Empty)) + { + if (Log_Set.LogPath.IndexOf('\\') > -1) + { + _LogPath = Path.Combine(Log_Set.LogPath, Log_Set.LogName); + } + else + { + _LogPath = Path.Combine(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Log_Set.LogPath), Log_Set.LogName); + } + } + else if (!Log_Set.LogPath.Equals(string.Empty)) + { + if (Log_Set.LogPath.IndexOf('\\') > -1) + { + _LogPath = Log_Set.LogPath; + } + else + { + _LogPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Log_Set.LogPath); + } + + } + else + { + _LogPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ".Log"); + } + + if (!Directory.Exists(_LogPath)) Directory.CreateDirectory(_LogPath); + LastLogTime = DateTime.Now.AddDays(-1F); + } + + public void Dispose() + { + + } + /// + /// logging function + /// + /// log data + public void LogWrite(Log_Message _LogData) + { + int retryCount = 0; + bool result = false; + do + { + result = LogWriteToFile(_LogData); + retryCount++; + } while (!result && retryCount < 100); + if (!result) + { + Console.WriteLine(string.Format("Log Write Fail:{0}", _LogData.LogMessage)); + } + } + /// + /// Log Write Internal Function + /// + /// + /// + private bool LogWriteToFile(Log_Message _LogData) + { + bool result = false; + try + { + if (Array.IndexOf(Log_Set.LogFrom, _LogData.LogFrom) > -1 + && Array.IndexOf(Log_Set.LogType, _LogData.LogType) > -1) + { + string _filePath = Path.Combine(_LogPath, string.Format("{0}_{1}.log", _LogData.LogFrom, _LogData.LogDate.ToString("yyyyMMdd"))); + result = rTextFileWrite(string.Format("{0},{1},{2},{3}\r\n" + , _LogData.LogDate.ToString("yyyy-MM-dd HH:mm:ss.fff") + , _LogData.LogFrom + , _LogData.LogType + , _LogData.LogMessage), _filePath, true); + if (LastLogTime.Date != DateTime.Now.Date) + { + DateTime _chkDate = DateTime.Now.AddDays(Log_Set.LogDates * -1); + string[] getFiles = Directory.GetFiles(_LogPath); + foreach (string aFile in getFiles) + { + if (File.GetCreationTime(aFile).Date < _chkDate.Date) + { + File.Delete(aFile); + } + } + } + LastLogTime = _LogData.LogDate; + } + else + { + result = true; + } + } + catch + { + + } + return result; + } + /// + /// String Add to File + /// + /// + /// + /// + /// + public bool rTextFileWrite(string _dataString, string _filePath, bool _append) + { + bool result = false; + try + { + using (StreamWriter sw = new StreamWriter(_filePath, _append)) + { + sw.Write(_dataString); + sw.Flush(); + sw.Close(); + } + result = true; + } + catch + { + result = false; + } + return result; + } + } + #endregion + + +} \ No newline at end of file diff --git a/Kiosk/Common/SPC.Kiosk.Common/Functions/CommonValue.cs b/Kiosk/Common/SPC.Kiosk.Common/Functions/CommonValue.cs new file mode 100644 index 0000000..d893582 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Functions/CommonValue.cs @@ -0,0 +1,138 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; +using System.Globalization; +using SPC.Kiosk.Base; +using Cosmos.BaseFrame; +namespace SPC.Kiosk.Common +{ + public static class CommonValue + { + /// + /// PB Design Image Store Path + /// + public static string PBdesignImagesPath { get; set; } = @"Kiosk\PB"; + /// + /// Intro Media Path + /// + public static string IntroMediaPath { get; set; } = @"Screen"; + + /// + /// Sign Save Width + /// + public static int SignWidth { get; set; } = 128; + /// + /// Sign Save Height + /// + public static int SignHeight { get; set; } = 64; + /// + /// Presave Sign File Name + /// + public static string SignFileName { get; set; } = "SIGN.BMP"; + /// + /// Sign Poinnts Min + /// + public static long SingPointsMin { get; set; } = 30L; + /// + /// Sign Points Max Limit + /// + public static long SingPointsMax { get; set; } = 2048L; + /// + /// No Sign Amonut Limit + /// + public static double NoSignAmountMaxLimit { get; set; } = 50000d; + /// + /// AiScanner Program Path + /// + public static string AiScannerPath { get; set; } = "O2AiScannerHS.exe"; + /// + /// Payments EndType + /// + public static PaymentEndWindowEndType PaymentEndType { get; set; } = PaymentEndWindowEndType.Bell; + /// + /// Payments Disable EndType + /// + public static PaymentEndWindowEndType DisableEndType { get; set; } = PaymentEndWindowEndType.Talk; + + /// + /// Input Wait Time Out Seconds + /// + public static double TimeOutSeconds { get; set; } = 30d; + /// + /// Display Language + /// + public static SupportLanguageType CommonLanguageType { get; set; } = SupportLanguageType.ko; + + public static string CashReceiptDefaultNo { get; set; } = "0100001234"; + /// + /// check Touch Device Exist + /// + public static bool IsHasTouchDevice + { + get + { + return Tablet.TabletDevices.OfType().Any(t => t.Type.Equals(TabletDeviceType.Touch)); + } + } + /// + /// check Mouse Exist + /// + public static bool IsHasMouse + { + get + { + return Mouse.PrimaryDevice != null; + } + + } + /// + /// Default Item Image + /// + public static string ItemDefaultImage + { + get + { + return ResourceManager.GetNximagePathAdd("img_contents_default.png", CommonValue.PBdesignImagesPath); + } + } + public static string OptionDefaultImage + { + get + { + return ResourceManager.GetNximagePathAdd("ic_option_takein.png", CommonValue.PBdesignImagesPath); + } + } + /// + /// Log 파일 시작명 '명칭_YYYMMDD.log' + /// + public static string LogName { get; set; } = @"KioskPB"; + /// + /// Log 보관 기한 + /// + public static int LogSaveDays { get; set; } = 30; + /// + /// Log Setting + /// + public static Log_Setting KioskLogSetting + { + get + { + return new Log_Setting + { + LogPath = Path.Combine(BaseCom.NxBinPath ,@"Kiosk"), + LogName = LogName, + LogFrom = new string[] { LogName }, + LogDates = LogSaveDays, + LogType = new Log_Type[] { Log_Type.Info,Log_Type.Error,Log_Type.Debug } + }; + } + } + + } +} \ No newline at end of file diff --git a/Kiosk/Common/SPC.Kiosk.Common/Functions/KioskMessageBox.cs b/Kiosk/Common/SPC.Kiosk.Common/Functions/KioskMessageBox.cs new file mode 100644 index 0000000..676fc4e --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Functions/KioskMessageBox.cs @@ -0,0 +1,426 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; +using System.Globalization; +using SPC.Kiosk.Base; +namespace SPC.Kiosk.Common +{ + public static class KioskMessageBox + { + /// + /// ShowMessageBox + /// + /// + /// + /// + /// + /// + /// + /// + public static MessageBoxResult ShowMessageBox(List _message, + OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None, + OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None, + double _startEndOpacity = 0.5, + double _animationSeconds = 0.2, + double _waitTime = 0) + { + return ShowMessageBox(0, new Size(0, 0), null, null, _message, MessageBoxButton.OK, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime); + } + /// + /// ShowMessageBox + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static MessageBoxResult ShowMessageBox(List _message, + MessageBoxButton _boxButton, + OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None, + OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None, + double _startEndOpacity = 0.5, + double _animationSeconds = 0.2, + double _waitTime = 0) + { + return ShowMessageBox(0, new Size(0, 0), null, null, _message, _boxButton, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime); + } + /// + /// ShowMessageBox + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static MessageBoxResult ShowMessageBox(List _title, + List _message, + MessageBoxButton _boxButton = MessageBoxButton.OK, + OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None, + OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None, + double _startEndOpacity = 0.5, + double _animationSeconds = 0.2, + double _waitTime = 0) + { + return ShowMessageBox(0, new Size(0, 0), _title, null, _message, _boxButton, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime); + } + /// + /// ShowMessageBox + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static MessageBoxResult ShowMessageBox(List _title, + List _subtitle, + List _message, + MessageBoxButton _boxButton = MessageBoxButton.OK, + OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None, + OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None, + double _startEndOpacity = 0.5, + double _animationSeconds = 0.2, + double _waitTime = 0) + { + return ShowMessageBox(0, new Size(0, 0), _title, _subtitle, _message, _boxButton, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime); + } + /// + /// ShowMessageBox + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static MessageBoxResult ShowMessageBox(int _screenNo, + List _title, + List _subtitle, + List _message, + MessageBoxButton _boxButton = MessageBoxButton.OK, + OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None, + OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None, + double _startEndOpacity = 0.5, + double _animationSeconds = 0.2, + double _waitTime = 0) + { + return ShowMessageBox(_screenNo, new Size(0, 0), _title, _subtitle, _message, _boxButton, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime); + } + /// + /// ShowMessageBox + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static MessageBoxResult ShowMessageBox(Size _size, + List _title, + List _subtitle, + List _message, + MessageBoxButton _boxButton, + OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None, + OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None, + double _startEndOpacity = 0.5, + double _animationSeconds = 0.2, + double _waitTime = 0) + { + return ShowMessageBox(0, _size, _title, _subtitle, _message, _boxButton, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime); + } + /// + /// ShowMessageBox + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static MessageBoxResult ShowMessageBox(int _screenNo, + Size _size, + List _title, + List _subtitle, + List _message, + MessageBoxButton _boxButton, + OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None, + OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None, + double _startEndOpacity = 0.5, + double _animationSeconds = 0.2, + double _waitTime = 0) + { + var result = MessageBoxResult.None; + try + { + + + var frmMessageBox = new MessageBoxForm(_screenNo, _size, _boxButton, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime); + + if (_title == null) + { + frmMessageBox.MessageHeader.Visibility = Visibility.Collapsed; + } + else + { + frmMessageBox.MessageHeader.MultiLanguage = _title; + } + if (_subtitle == null) + { + frmMessageBox.MessageSubHeader.Visibility = Visibility.Collapsed; + } + else + { + frmMessageBox.MessageSubHeader.MultiLanguage = _subtitle; + } + frmMessageBox.Message.MultiLanguage = _message; + switch (_boxButton) + { + case MessageBoxButton.OK: + frmMessageBox.Yes_Button.Width = frmMessageBox.BoxBase.Width; + frmMessageBox.Yes_Button.LanguageText = Languages.GetMessages("BTN0039"); + frmMessageBox.Yes_Button.HorizontalAlignment = HorizontalAlignment.Center; + frmMessageBox.No_Button.Visibility = Visibility.Collapsed; + frmMessageBox.Cancel_Button.Visibility = Visibility.Collapsed; + break; + case MessageBoxButton.OKCancel: + frmMessageBox.Yes_Button.Width = frmMessageBox.BoxBase.Width / 2; + frmMessageBox.Yes_Button.LanguageText = Languages.GetMessages("BTN0039"); + frmMessageBox.Yes_Button.HorizontalAlignment = HorizontalAlignment.Left; + frmMessageBox.No_Button.Visibility = Visibility.Collapsed; + frmMessageBox.Cancel_Button.Width = frmMessageBox.BoxBase.Width / 2; + frmMessageBox.Cancel_Button.LanguageText = Languages.GetMessages("BTN0033"); + frmMessageBox.Cancel_Button.HorizontalAlignment = HorizontalAlignment.Right; + break; + case MessageBoxButton.YesNo: + frmMessageBox.Yes_Button.Width = frmMessageBox.BoxBase.Width / 2; + frmMessageBox.Yes_Button.LanguageText = Languages.GetMessages("BTN0005"); + frmMessageBox.Yes_Button.HorizontalAlignment = HorizontalAlignment.Left; + frmMessageBox.No_Button.Width = frmMessageBox.BoxBase.Width / 2; + frmMessageBox.No_Button.LanguageText = Languages.GetMessages("BTN0021"); + frmMessageBox.No_Button.HorizontalAlignment = HorizontalAlignment.Right; + frmMessageBox.Cancel_Button.Visibility = Visibility.Collapsed; + break; + case MessageBoxButton.YesNoCancel: + frmMessageBox.Yes_Button.Width = frmMessageBox.BoxBase.Width / 3; + frmMessageBox.Yes_Button.LanguageText = Languages.GetMessages("BTN0005"); + frmMessageBox.Yes_Button.HorizontalAlignment = HorizontalAlignment.Left; + frmMessageBox.No_Button.Width = frmMessageBox.BoxBase.Width / 3; + frmMessageBox.No_Button.LanguageText = Languages.GetMessages("BTN0021"); + frmMessageBox.No_Button.HorizontalAlignment = HorizontalAlignment.Center; + frmMessageBox.Cancel_Button.Width = frmMessageBox.BoxBase.Width / 3; + frmMessageBox.Cancel_Button.LanguageText = Languages.GetMessages("BTN0033"); + frmMessageBox.Cancel_Button.HorizontalAlignment = HorizontalAlignment.Right; + break; + } + frmMessageBox.ShowDialog(); + result = frmMessageBox.BoxResult; + frmMessageBox = null; + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite("SPC.Kiosk.Common", "KioskMessageBox", "ShowMessageBox()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = MessageBoxResult.None; + } + + return result; + } + /// + /// Show Time Message Box + /// + /// + /// + /// + /// + /// + /// + public static void TimeMessageBox(List _message, + OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None, + OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None, + double _startEndOpacity = 0.5, + double _animationSeconds = 0.2, + double _waitTime = 5) + { + TimeMessageBox(0, new Size(0, 0), null, null, _message, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime); + } + /// + /// Show Time Message Box + /// + /// + /// + /// + /// + /// + /// + /// + public static void TimeMessageBox(List _title, + List _message, + OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None, + OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None, + double _startEndOpacity = 0.5, + double _animationSeconds = 0.2, + double _waitTime = 5) + { + TimeMessageBox(0, new Size(0, 0), _title, null, _message, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime); + } + /// + /// Show Time Message Box + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static void TimeMessageBox(List _title, + List _subtitle, + List _message, + OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None, + OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None, + double _startEndOpacity = 0.5, + double _animationSeconds = 0.2, + double _waitTime = 5) + { + TimeMessageBox(0, new Size(0, 0), _title, _subtitle, _message, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime); + } + /// + /// Show Time Message Box + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static void TimeMessageBox(int _screenNo, + List _title, + List _subtitle, + List _message, + OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None, + OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None, + double _startEndOpacity = 0.5, + double _animationSeconds = 0.2, + double _waitTime = 5) + { + TimeMessageBox(_screenNo, new Size(0, 0), _title, _subtitle, _message, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime); + } + /// + /// Show Time Message Box + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static void TimeMessageBox( + Size _size, + List _title, + List _subtitle, + List _message, + OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None, + OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None, + double _startEndOpacity = 0.5, + double _animationSeconds = 0.2, + double _waitTime = 5) + { + TimeMessageBox(0, _size, _title, _subtitle, _message, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime); + } + /// + /// Show Time Message Box + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static void TimeMessageBox(int _screenNo, + Size _size, + List _title, + List _subtitle, + List _message, + OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.None, + OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.None, + double _startEndOpacity = 0.5, + double _animationSeconds = 0.2, + double _waitTime = 5) + { + try + { + if (_message is List && !string.IsNullOrEmpty(_message.GetLanguageData(SupportLanguageType.ko))) + { + + var frmMessageBox = new MessageBoxForm(_screenNo, _size, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime); + if (_title == null) + { + frmMessageBox.MessageHeader.Visibility = Visibility.Collapsed; + } + else + { + frmMessageBox.MessageHeader.MultiLanguage = _title; + } + if (_subtitle == null) + { + frmMessageBox.MessageSubHeader.Visibility = Visibility.Collapsed; + } + else + { + frmMessageBox.MessageHeader.MultiLanguage = _title; + } + frmMessageBox.Message.MultiLanguage = _message; + frmMessageBox.ShowDialog(); + frmMessageBox = null; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite("SPC.Kiosk.Common", "KioskMessageBox", "TimeMessageBox()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + } +} \ No newline at end of file diff --git a/Kiosk/Common/SPC.Kiosk.Common/Functions/Languages.cs b/Kiosk/Common/SPC.Kiosk.Common/Functions/Languages.cs new file mode 100644 index 0000000..26d7d62 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Functions/Languages.cs @@ -0,0 +1,371 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Globalization; +using SPC.Kiosk.Base; +namespace SPC.Kiosk.Common +{ + /// + /// 다국어 지원 Helper + /// + public static class Languages + { + private static List MultiLanguagesStore = new List(); + private static bool Init { get; set; } = false; + private static void initClass() + { + SetMessage("CommonYes", SupportLanguageType.en, "Yes"); + SetMessage("CommonYes", SupportLanguageType.ko, "예"); + SetMessage("CommonOK", SupportLanguageType.en, "OK"); + SetMessage("CommonOK", SupportLanguageType.ko, "확인"); + SetMessage("CommonNo", SupportLanguageType.en, "No"); + SetMessage("CommonNo", SupportLanguageType.ko, "아니오"); + SetMessage("CommonCancel", SupportLanguageType.en, "Cancel"); + SetMessage("CommonCancel", SupportLanguageType.ko, "취소"); + SetMessage("CommonClear", SupportLanguageType.en, "Clear"); + SetMessage("CommonClear", SupportLanguageType.ko, "삭제"); + SetMessage("CommonPrevious", SupportLanguageType.en, "Previous"); + SetMessage("CommonPrevious", SupportLanguageType.ko, "이전으로"); + SetMessage("CommonNext", SupportLanguageType.en, "Next"); + SetMessage("CommonNext", SupportLanguageType.ko, "다음으로"); + SetMessage("CommonRetry", SupportLanguageType.en, "Retry"); + SetMessage("CommonRetry", SupportLanguageType.ko, "재시도"); + SetMessage("CommonDetail", SupportLanguageType.en, "Detail"); + SetMessage("CommonDetail", SupportLanguageType.ko, "상세보기"); + SetMessage("CommonPayment", SupportLanguageType.en, "Payment"); + SetMessage("CommonPayment", SupportLanguageType.ko, "결제하기"); + SetMessage("CommonPopup", SupportLanguageType.en, "Popup"); + SetMessage("CommonPopup", SupportLanguageType.ko, "팝업"); + SetMessage("CommonExist", SupportLanguageType.en, "Exist"); + SetMessage("CommonExist", SupportLanguageType.ko, "종료"); + SetMessage("CommonToggle", SupportLanguageType.en, "Toggle"); + SetMessage("CommonToggle", SupportLanguageType.ko, "토글"); + SetMessage("TradeHeader", SupportLanguageType.en, "Test Item List"); + SetMessage("TradeHeader", SupportLanguageType.ko, "테스트 상품 목록"); + + SetMessage("PopupHeader", SupportLanguageType.en, "PopupTest"); + SetMessage("PopupHeader", SupportLanguageType.ko, "팝업 테스트"); + SetMessage("PopupMessage", SupportLanguageType.en, "Test Message"); + SetMessage("PopupMessage", SupportLanguageType.ko, "테스트 메세지"); + SetMessage("TimePopupMessage", SupportLanguageType.en, "Time Popup Message"); + SetMessage("TimePopupMessage", SupportLanguageType.ko, "타임 팝업 메세지"); + + SetMessage("MemberLoginTitle", SupportLanguageType.en, "Happy Point Member Login"); + SetMessage("MemberLoginTitle", SupportLanguageType.ko, "해피 포인트 회원 확인"); + SetMessage("MobileNumberMessage", SupportLanguageType.en, "Input HP number."); + SetMessage("MobileNumberMessage", SupportLanguageType.ko, "휴대폰 번호"); + SetMessage("CompanyNumberMessage", SupportLanguageType.en, "Input Compay number."); + SetMessage("CompanyNumberMessage", SupportLanguageType.ko, "사업자번호"); + SetMessage("VibrationBellNumber", SupportLanguageType.en, "Vibration bell number"); + SetMessage("VibrationBellNumber", SupportLanguageType.ko, "진동벨번호"); + + SetMessage("InputBarCodeMessage", SupportLanguageType.en, "Input BarCode number."); + SetMessage("InputBarCodeMessage", SupportLanguageType.ko, "바코드 번호"); + SetMessage("InputPassword", SupportLanguageType.en, "Input Password"); + SetMessage("InputPassword", SupportLanguageType.ko, "비밀번호 입력"); + SetMessage("TimeOver", SupportLanguageType.en, "Operation Time Over"); + SetMessage("TimeOver", SupportLanguageType.ko, "입력 시간이 초과 되었습니다."); + SetMessage("CommonReserve", SupportLanguageType.en, "Reserve"); + SetMessage("CommonReserve", SupportLanguageType.ko, "적립"); + SetMessage("CommonUsing", SupportLanguageType.en, "Using"); + SetMessage("CommonUsing", SupportLanguageType.ko, "사용"); + SetMessage("CommonUsingAll", SupportLanguageType.en, "Using All"); + SetMessage("CommonUsingAll", SupportLanguageType.ko, "모두 사용"); + SetMessage("InputUsingPoints", SupportLanguageType.en, "Input Using Points"); + SetMessage("InputUsingPoints", SupportLanguageType.ko, "사용포인트"); + SetMessage("PriceForPayment", SupportLanguageType.en, "Price for payment"); + SetMessage("PriceForPayment", SupportLanguageType.ko, "최종 결제금액"); + SetMessage("ProcessingOK", SupportLanguageType.en, "Processing Sucess."); + SetMessage("ProcessingOK", SupportLanguageType.ko, "정상 처리 되었습니다."); + + SetMessage("CommonPaymentAgain", SupportLanguageType.en, "Retry"); + SetMessage("CommonPaymentAgain", SupportLanguageType.ko, "다시 결제"); + SetMessage("CommonPaymentCancel", SupportLanguageType.en, "Cancel Payment"); + SetMessage("CommonPaymentCancel", SupportLanguageType.ko, "결제 취소"); + + SetMessage("CommonPerson", SupportLanguageType.en, "Person"); + SetMessage("CommonPerson", SupportLanguageType.ko, "개인"); + SetMessage("CommonCompany", SupportLanguageType.en, "Company"); + SetMessage("CommonCompany", SupportLanguageType.ko, "사업자"); + Init = true; + } + /// + /// Get Language Native Name + /// + /// + /// + public static string GetLanguageNativeName(this SupportLanguageType _languageType) + { + string result = string.Empty; + try + { + result = _languageType.ToString().GetLanguageNativeName(); + } + catch + { + result = string.Empty; + } + return result; + } + /// + /// Get Language Native Name + /// + /// + /// + public static string GetLanguageNativeName(this string _languageTypeString) + { + string result = string.Empty; + try + { + var cultureInfo = CultureInfo.GetCultureInfo(_languageTypeString); + result = cultureInfo.NativeName; + + } + catch + { + result = string.Empty; + } + return result; + } + /// + /// 특정 코드 다국어 객체 가져오기 + /// + /// + /// + public static List GetMessages(this string _code) + { + List result = new List(); + try + { + if (!Init) initClass(); + if (MultiLanguagesStore != null && MultiLanguagesStore.Count > 0) + { + var getLanguage = MultiLanguagesStore.Where(r => r.MessageCode.Equals(_code)).FirstOrDefault(); + if (getLanguage is M_MultiLanguage) + { + result = getLanguage.MessageData; + } + } + if (result.Count.Equals(0)) + { + foreach (var aLanguage in Enum.GetValues(typeof(SupportLanguageType)).Cast()) + { + result.Add(new M_Language { Type = aLanguage, LanguageData = string.Format("{0}_{1}", _code, aLanguage.ToString()) }); + } + + } + } + catch + { + result = new List(); + } + return result; + } + /// + /// 다국어 정보 등록 + /// + /// + /// + /// + public static void SetMessage(this string _code, SupportLanguageType _languageType, string _messageData) + { + try + { + if (string.IsNullOrEmpty(_code)) return; + if (string.IsNullOrEmpty(_messageData)) _messageData=string.Empty; + if (MultiLanguagesStore == null) MultiLanguagesStore = new List(); + var getLanguage = MultiLanguagesStore.Where(r => r.MessageCode.Equals(_code)).FirstOrDefault(); + if (getLanguage != null) + { + var getMessage = getLanguage.MessageData.Where(r => r.Type.Equals(_languageType)).FirstOrDefault(); + if (getMessage is M_Language) + { + getMessage.LanguageData = _messageData; //update + + } + else //Language Type Data 가 없는 경우 추가 + { + getLanguage.MessageData.Add + ( + new M_Language + { + Type = _languageType, + LanguageData = _messageData + } + ); + } + } + else //해당 Language Code Data가 없는 경우 + { + MultiLanguagesStore.Add + ( + new M_MultiLanguage + { + MessageCode = _code, + MessageData = new List + { + new M_Language + { + Type = _languageType, + LanguageData = _messageData + } + } + } + ); + } + } + catch + { + } + } + /// + /// 특정 코드, 대상 언어 정보 가져오기 + /// + /// + /// + /// + public static string GetLanguageData(this string _code, SupportLanguageType _supportLanguageType) + { + string result = string.Empty; + try + { + if (!Init) initClass(); + if (MultiLanguagesStore != null && MultiLanguagesStore.Count > 0) + { + var getLanguage = MultiLanguagesStore.Where(r => r.MessageCode.Equals(_code)).FirstOrDefault().MessageData; + if (getLanguage is List) + { + result = getLanguage.GetLanguageData(_supportLanguageType); + } + } + } + catch + { + result = string.Empty; + } + return result; + } + /// + /// 다국어 객체에서 특정 언어 정보 가져오기 + /// + /// + /// + /// + public static string GetLanguageData(this List _multiLanguageData, SupportLanguageType _supportLanguageType) + { + string result = string.Empty; + try + { + if (_multiLanguageData != null) + { + var getMessage = _multiLanguageData.Where(r => r.Type.Equals(_supportLanguageType)).FirstOrDefault(); + if (getMessage == null) + { + getMessage = _multiLanguageData.Where(r => r.Type.Equals(SupportLanguageType.ko)).FirstOrDefault(); + } + if (getMessage is M_Language) result = getMessage.LanguageData.Replace("\\n", "\n"); + } + } + catch + { + result = string.Empty; + } + return result; + } + /// + /// 다국어 문자열 연결 + /// + /// + /// + /// + /// + public static List CombineLanguageData(this List _multiLanguageData1, List _multiLanguageData2, string _format = "") + { + List result = null; + try + { + + if (_multiLanguageData1 != null && _multiLanguageData2 !=null) + { + result = new List(); + foreach (var aLanguage in Enum.GetValues(typeof(SupportLanguageType)).Cast()) + { + if (string.IsNullOrEmpty(_format)) _format = "{0}{1}"; + var addedData = new M_Language + { + Type = aLanguage, + LanguageData = string.Format(_format, _multiLanguageData1.GetLanguageData(aLanguage), _multiLanguageData2.GetLanguageData(aLanguage)) + }; + result.Add(addedData); + } + } + } + catch + { + result = null; + } + return result; + + } + /// + /// 다국어 문자열 연결 + /// + /// + /// + /// + public static List JoinLanguage(this List[] _multiLanguageDatas, string _joinString = "") + { + List result = null; + try + { + + if (_multiLanguageDatas != null ) + { + result = new List(); + foreach (var aLanguageData in _multiLanguageDatas) + { + if (_multiLanguageDatas.Last().Equals(aLanguageData)) + { + result = result.CombineLanguageData(aLanguageData); + } + else + { + result = result.CombineLanguageData(aLanguageData, "{0}{1}" + _joinString); + } + } + } + } + catch + { + result = null; + } + return result; + + } + /// + /// 다국어 정보 모두 삭제 + /// + public static void ClearMessage() + { + if (MultiLanguagesStore != null) + { + MultiLanguagesStore.Clear(); + } + } + /// + /// 다국어 정보 모두 삭제 후 해제 + /// + public static void Dispose() + { + if (MultiLanguagesStore != null) + { + MultiLanguagesStore.Clear(); + MultiLanguagesStore = null; + } + + } + + } +} \ No newline at end of file diff --git a/Kiosk/Common/SPC.Kiosk.Common/Functions/PopupMessageBox.cs b/Kiosk/Common/SPC.Kiosk.Common/Functions/PopupMessageBox.cs new file mode 100644 index 0000000..3aaafbc --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Functions/PopupMessageBox.cs @@ -0,0 +1,158 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; +using System.Globalization; +using SPC.Kiosk.Base; +namespace SPC.Kiosk.Common +{ + public static class PopupMessageBox + { + /// + /// Show Message Box + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + public static MessageBoxResult ShowMessageBox(SupportLanguageType _languageType, + List _message1, + List _Message2, + MessageBoxButton _boxButton, + OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.FullSizeUp, + OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.FullSizeDown, + double _startEndOpacity = 0.5, + double _animationSeconds = 0.2, + double _waitTime = 10d) + { + var result = MessageBoxResult.None; + try + { + + + var frmMessageBox = new PopupMessage(_languageType, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime); + if (_message1 == null) + { + frmMessageBox.Message1.Visibility = Visibility.Collapsed; + } + else + { + frmMessageBox.Message1.MultiLanguage = _message1; + } + if (_Message2 == null) + { + frmMessageBox.Message2.Visibility = Visibility.Collapsed; + } + else + { + frmMessageBox.Message2.MultiLanguage = _Message2; + } + frmMessageBox.BoxButton = _boxButton; + switch (_boxButton) + { + case MessageBoxButton.OK: + frmMessageBox.Yes_Button.Width = frmMessageBox.FrameBase.Width; + frmMessageBox.Yes_Button.LanguageText = Languages.GetMessages("BTN0039"); + frmMessageBox.Yes_Button.HorizontalAlignment = HorizontalAlignment.Center; + frmMessageBox.No_Button.Visibility = Visibility.Collapsed; + frmMessageBox.Cancel_Button.Visibility = Visibility.Collapsed; + break; + case MessageBoxButton.OKCancel: + frmMessageBox.Yes_Button.Width = frmMessageBox.FrameBase.Width / 2; + frmMessageBox.Yes_Button.LanguageText = Languages.GetMessages("BTN0039"); + frmMessageBox.Yes_Button.HorizontalAlignment = HorizontalAlignment.Left; + frmMessageBox.No_Button.Visibility = Visibility.Collapsed; + frmMessageBox.Cancel_Button.Width = frmMessageBox.FrameBase.Width / 2; + frmMessageBox.Cancel_Button.LanguageText = Languages.GetMessages("BTN0033"); + frmMessageBox.Cancel_Button.HorizontalAlignment = HorizontalAlignment.Right; + break; + case MessageBoxButton.YesNo: + frmMessageBox.Yes_Button.Width = frmMessageBox.FrameBase.Width / 2; + frmMessageBox.Yes_Button.LanguageText = Languages.GetMessages("BTN0005"); + frmMessageBox.Yes_Button.HorizontalAlignment = HorizontalAlignment.Left; + frmMessageBox.No_Button.Width = frmMessageBox.FrameBase.Width / 2; + frmMessageBox.No_Button.LanguageText = Languages.GetMessages("BTN0021"); + frmMessageBox.No_Button.HorizontalAlignment = HorizontalAlignment.Right; + frmMessageBox.Cancel_Button.Visibility = Visibility.Collapsed; + break; + case MessageBoxButton.YesNoCancel: + frmMessageBox.Yes_Button.Width = frmMessageBox.FrameBase.Width / 3; + frmMessageBox.Yes_Button.LanguageText = Languages.GetMessages("BTN0005"); + frmMessageBox.Yes_Button.HorizontalAlignment = HorizontalAlignment.Left; + frmMessageBox.No_Button.Width = frmMessageBox.FrameBase.Width / 3; + frmMessageBox.No_Button.LanguageText = Languages.GetMessages("BTN0021"); + frmMessageBox.No_Button.HorizontalAlignment = HorizontalAlignment.Center; + frmMessageBox.Cancel_Button.Width = frmMessageBox.FrameBase.Width / 3; + frmMessageBox.Cancel_Button.LanguageText = Languages.GetMessages("BTN0033"); + frmMessageBox.Cancel_Button.HorizontalAlignment = HorizontalAlignment.Right; + break; + } + frmMessageBox.ShowDialog(); + result = frmMessageBox.BoxResult; + frmMessageBox = null; + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite("SPC.Kiosk.Common", "PopupMessageBox", "TimeMessageBox()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = MessageBoxResult.None; + } + + return result; + } + + public static void TimeMessageBox(SupportLanguageType _languageType, + List _message1, + List _Message2, + OpenCloseAnimationType _openAnimationType = OpenCloseAnimationType.FullSizeUp, + OpenCloseAnimationType _closeAnimationType = OpenCloseAnimationType.FullSizeDown, + double _startEndOpacity = 0.5, + double _animationSeconds = 0.2, + double _waitTime = 0.5) + { + try + { + if (_message1 is List && !string.IsNullOrEmpty(_message1.GetLanguageData(SupportLanguageType.ko))) + { + + var frmMessageBox = new PopupMessage(_languageType, _openAnimationType, _closeAnimationType, _startEndOpacity, _animationSeconds, _waitTime); + if (_message1 == null) + { + frmMessageBox.Message1.Visibility = Visibility.Collapsed; + } + else + { + frmMessageBox.Message1.MultiLanguage = _message1; + } + if (_Message2 == null) + { + frmMessageBox.Message2.Visibility = Visibility.Collapsed; + } + else + { + frmMessageBox.Message2.MultiLanguage = _Message2; + } + frmMessageBox.Yes_Button.Width = 0; + frmMessageBox.No_Button.Width = 0; + frmMessageBox.Cancel_Button.Width = 0; + frmMessageBox.ShowDialog(); + frmMessageBox = null; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite("SPC.Kiosk.Common", "PopupMessageBox", "TimeMessageBox()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + } +} \ No newline at end of file diff --git a/Kiosk/Common/SPC.Kiosk.Common/Functions/ResourceManager.cs b/Kiosk/Common/SPC.Kiosk.Common/Functions/ResourceManager.cs new file mode 100644 index 0000000..bf45f21 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Functions/ResourceManager.cs @@ -0,0 +1,573 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using Cosmos.BaseFrame; +using Cosmos.Common; +using System.Windows.Controls; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows; +using System.Windows.Input; +using System.Windows.Interop; +using Microsoft.Win32.SafeHandles; +using System.Runtime.InteropServices; +using System.Reflection; +using SPC.Kiosk.Base; +namespace SPC.Kiosk.Common +{ + /// + /// Resource Management Class + /// + public static class ResourceManager + { + #region [ Resource Path ] + public static string BinPath + { + get + { + try + { + return BaseCom.NxBinPath; + } + catch + { + + return @"C:\SPC\POS\BIN"; + } + } + } + public static string SignDataPath + { + get + { + try + { + return BaseCom.NxDataPath + "SIGN\\"; + } + catch + { + + return @"C:\temp\"; + } + } + } + + /// + /// Get CDP Image File(Path) + /// + /// Path without Filename + /// + public static string GetCDPimagePath(string _imageFileName) + { + string result = null; + try + { + string ImagePath = Path.Combine(BaseCom.NxCDPPath + CommonValue.IntroMediaPath , _imageFileName); + if (File.Exists(ImagePath)) + { + result = ImagePath; + } + else + { + ImagePath = Path.Combine(BaseCom.NxImgPath, _imageFileName); + if (File.Exists(ImagePath)) result = ImagePath; + } + } + catch + { + result = null; + } + return result; + } + + /// + /// Get Default Image File(Path) + /// + /// Path without Filename + /// + public static string GetNximagePath(string _imageFileName) + { + string result = null; + try + { + string ImagePath = Path.Combine(BaseCom.NxImgPath, _imageFileName); + if (File.Exists(ImagePath)) result = ImagePath; + } + catch + { + result = null; + } + return result; + } + /// + /// Get Default Image File(Path) under Add path + /// + /// + /// + /// + public static string GetNximagePathAdd(string _imageFileName,string _addPath) + { + string result = null; + try + { + string ImagePath = Path.Combine(BaseCom.NxImgPath + _addPath, _imageFileName); + if (File.Exists(ImagePath)) result = ImagePath; + } + catch + { + result = null; + } + return result; + } + /// + /// Get CDP media File(Path) + /// + /// Path without Filename + /// + public static string GetCDPmediaPath(string _mediaFileName) + { + string result = null; + try + { + string ImagePath = Path.Combine(BaseCom.NxCDPPath + PosConst.MST_IMG_PATH.CUSTOMER, _mediaFileName); + if (File.Exists(ImagePath)) result = ImagePath; + } + catch + { + result = null; + } + return result; + } + /// + /// Get CDP Item Image File (Path) + /// + /// + /// + public static string GetCDPItemImagePath(string _ItemImageFileName) + { + string result = null; + try + { + string ImagePath = Path.Combine(BaseCom.NxCDPPath + PosConst.MST_IMG_PATH.ITEM, _ItemImageFileName); + if (File.Exists(ImagePath)) result = ImagePath; + } + catch + { + result = null; + } + return result; + } + + /// + /// Get CDP Option Item Image File (Path) + /// + /// + /// + public static string GetCDPOptionImagePath(string _ItemImageFileName) + { + string result = null; + try + { + string ImagePath = Path.Combine(BaseCom.NxCDPPath + PosConst.MST_IMG_PATH.OPTION, _ItemImageFileName); + if (File.Exists(ImagePath)) result = ImagePath; + } + catch + { + result = null; + } + return result; + } + + /// + /// All CDP Item Images + /// + /// + /// + public static string[] GetItemImages(string _searchKey) + { + string itemImagePath = Path.Combine(BaseCom.NxCDPPath, PosConst.MST_IMG_PATH.ITEM); + return Directory.GetFiles(itemImagePath, _searchKey); + } + /// + /// + /// + /// + /// + public static BitmapImage LoadBitmapImage(string _path) + { + var bitmapImage = default(BitmapImage); + try + { + if (File.Exists(_path)) + { + byte[] byteArray = null; + using (var fileStream = new FileStream(_path, FileMode.Open, FileAccess.Read)) + { + using (var binaryReader = new BinaryReader(fileStream)) + { + byteArray = binaryReader.ReadBytes((int)fileStream.Length); + } + } + var memoryStream = new MemoryStream(byteArray); + bitmapImage = new BitmapImage(); + bitmapImage.BeginInit(); + bitmapImage.StreamSource = memoryStream; + bitmapImage.EndInit(); + } + } + catch + { + bitmapImage = default(BitmapImage); + } + return bitmapImage; + } + /// + /// Get Bitmap Image From Cache + /// If Not Exist Add Chache + /// + /// + /// + public static BitmapImage GetBitmapImage(string _path) + { + BitmapImage getIamge = null; + try + { + if (!_path.CacheContain()) _path.AddCache(LoadBitmapImage(_path)); + getIamge = _path.CacheContain() ? _path.GetCache() : default(BitmapImage); + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite("SPC.Kiosk.Common", "ResourceManager", "GetBitmapImage()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + getIamge = null; + } + return getIamge; + } + /// + /// BitmapImage from UriPath + /// + /// + /// + public static BitmapImage GetUriBitmapImage(string _uriPath) + { + BitmapImage getIamge = null; + try + { + getIamge = new BitmapImage(new Uri(_uriPath)); + + } + catch (Exception) + { + getIamge = null; + } + return getIamge; + } + public static string GetItemImage(this string _ImageFile, string _itemDefaultBrush) + { + string result = _itemDefaultBrush; + try + { + if (!string.IsNullOrEmpty(_ImageFile)) + { + result = GetCDPItemImagePath(_ImageFile); + if (string.IsNullOrEmpty(result)) result = _itemDefaultBrush; + } + else + { + result = _itemDefaultBrush; + } + } + catch + { + result = _itemDefaultBrush; + } + return result; + } + + public static string GetOptionImage(this string _ImageFile, string _optionDefaultBrush) + { + string result = _optionDefaultBrush; + try + { + if (!string.IsNullOrEmpty(_ImageFile)) + { + result = GetCDPOptionImagePath(_ImageFile); + if (string.IsNullOrEmpty(result)) result = _optionDefaultBrush; + } + else + { + result = _optionDefaultBrush; + } + } + catch + { + result = _optionDefaultBrush; + } + return result; + } + + #endregion Resource Path + + #region [ SetBrush ] + /// + /// Get image Brush by BitmapImage + /// + /// + /// + /// + /// + /// + /// + /// + public static ImageBrush GetImageBrush(DependencyObject _getObject + , BitmapImage _bitmapImage + , Stretch _stretch + , Size _size + , PropertyInfo _widthProperty + , PropertyInfo _HeightProperty + , double _offsetX = 0d + , double _offsetY = 0d) + { + ImageBrush imageBrush = null; + try + { + imageBrush = new ImageBrush(_bitmapImage); + var imgSource = imageBrush.ImageSource as BitmapImage; + var ratio = _size.Width / imgSource.PixelWidth; + switch (_stretch) + { + case Stretch.UniformToFill: + imageBrush.Stretch = Stretch.UniformToFill; + _widthProperty.SetValue(_getObject, imgSource.PixelWidth, null); + _HeightProperty.SetValue(_getObject, imgSource.PixelHeight, null); + break; + case Stretch.Fill: + if (!_size.Width.Equals(double.NaN)) + { + imageBrush.Stretch = Stretch.Fill; + _widthProperty.SetValue(_getObject, _size.Width, null); + _HeightProperty.SetValue(_getObject, imgSource.PixelHeight * ratio, null); + } + break; + case Stretch.Uniform: + imageBrush.Stretch = Stretch.Uniform; + _widthProperty.SetValue(_getObject, _size.Width.Equals(double.NaN) ? imgSource.PixelWidth : _size.Width, null); + _HeightProperty.SetValue(_getObject, _size.Height.Equals(double.NaN) ? imgSource.PixelHeight : _size.Height, null); + break; + case Stretch.None: + imageBrush.Stretch = Stretch.Fill; + _widthProperty.SetValue(_getObject, imgSource.PixelWidth, null); + _HeightProperty.SetValue(_getObject, imgSource.PixelHeight, null); + break; + } + if (!_offsetX.Equals(0d) || !_offsetY.Equals(0d)) + { + imageBrush.Transform = new TranslateTransform(_offsetX, _offsetY); + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite("SPC.Kiosk.Common", "ResourceManager", "GetImageBrush()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + imageBrush = null; + } + return imageBrush; + } + public static void SetBrush(DependencyObject _getObject, string _setProperty, string _getBlush, Stretch _stretch = Stretch.None, Size _size = new Size()) + { + SetBrush( _getObject, _setProperty, _getBlush, 0d, 0d, _stretch, _size); + } + /// + /// Set a Brush by String to Object Property + /// + public static void SetBrush(DependencyObject _getObject, string _setProperty, string _getBlush,double _imageOffsetX, double _imageOffsetY, Stretch _stretch = Stretch.None, Size _size = new Size()) + { + Brush result = default(Brush); + try + { + + Type getObjectType = _getObject.GetType(); + var widthProperty = getObjectType.GetProperty("Width"); + var HeightProperty = getObjectType.GetProperty("Height"); + if (_getBlush.StartsWith("#")) + { + //String start with '#' (a Byte Data Color) + var colorByteString = _getBlush.Replace("#", ""); + //RGB + if (colorByteString.Length.Equals(6)) + { + byte byteRed = (byte)Convert.ToInt16(colorByteString.Substring(0, 2), 16); + byte byteGreen = (byte)Convert.ToInt16(colorByteString.Substring(2, 2), 16); + byte byteBlue = (byte)Convert.ToInt16(colorByteString.Substring(4, 2), 16); + if (!_size.Width.Equals(double.NaN) && _size.Width > 0) widthProperty.SetValue(_getObject, _size.Width, null); + if (!_size.Height.Equals(double.NaN) && _size.Height > 0) HeightProperty.SetValue(_getObject, _size.Height, null); + result = new SolidColorBrush(Color.FromRgb(byteRed, byteGreen, byteBlue)); + } + //SRGB + if (colorByteString.Length.Equals(8)) + { + byte byteAlpa = (byte)Convert.ToInt16(colorByteString.Substring(0, 2), 16); + byte byteRed = (byte)Convert.ToInt16(colorByteString.Substring(2, 2), 16); + byte byteGreen = (byte)Convert.ToInt16(colorByteString.Substring(4, 2), 16); + byte byteBlue = (byte)Convert.ToInt16(colorByteString.Substring(6, 2), 16); + if (!_size.Width.Equals(double.NaN) && _size.Width > 0) widthProperty.SetValue(_getObject, _size.Width, null); + if (!_size.Height.Equals(double.NaN) && _size.Height > 0) HeightProperty.SetValue(_getObject, _size.Height, null); + result = new SolidColorBrush(Color.FromScRgb(byteAlpa, byteRed, byteGreen, byteBlue)); + } + } + else if (_getBlush.StartsWith("pack://") && _getBlush.Contains(";component/")) + { + if (GetUriBitmapImage(_getBlush) is BitmapImage bitMapImage) + { + result = GetImageBrush(_getObject, bitMapImage, _stretch, _size, widthProperty, HeightProperty, _imageOffsetX, _imageOffsetY); + } + } + else + { + + //String start with out '#' (Not Byte Color) + var ColorNameProperties = typeof(Colors).GetProperties(); + bool FindColor = false; + //is Color Name ? + foreach (var aColorNamePropertie in ColorNameProperties) + { + if (aColorNamePropertie.Name.Equals(_getBlush)) + { + FindColor = true; + result = new SolidColorBrush((Color)ColorConverter.ConvertFromString(_getBlush)); + } + } + if (!FindColor) + { + //Is Not Colors + if (GetBitmapImage(_getBlush) is BitmapImage bitMapImage) + { + result = GetImageBrush(_getObject, bitMapImage, _stretch, _size, widthProperty, HeightProperty, _imageOffsetX, _imageOffsetY); + } + } + else + { + //Is Colors Set Brush Size + if (!_size.Width.Equals(double.NaN) && _size.Width > 0) widthProperty.SetValue(_getObject, _size.Width, null); + if (!_size.Height.Equals(double.NaN) && _size.Height > 0) HeightProperty.SetValue(_getObject, _size.Height, null); + + } + } + var setProperty = getObjectType.GetProperty(_setProperty); + if (setProperty != null) + { + setProperty.SetValue(_getObject, result == null ? default(Brush) : result, null); + } + + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite("SPC.Kiosk.Common", "ResourceManager", "SetBrush()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = default(Brush); + } + } + #endregion SetBrush + + #region [ GetCursorByImage ] + [StructLayout(LayoutKind.Sequential)] + private struct IconInfo + { + public bool fIcon; + public int xHotspot; + public int yHotspot; + public IntPtr hbmMask; + public IntPtr hbmColor; + } + [DllImport("user32.dll")] + [return: MarshalAs(UnmanagedType.Bool)] + private static extern bool GetIconInfo(IntPtr hIcon, ref IconInfo pIconInfo); + [DllImport("user32.dll")] + private static extern IntPtr CreateIconIndirect(ref IconInfo icon); + /// + /// Get Cursor By a Image + /// + /// + /// + /// + /// + public static Cursor GetCursorByImage(string _ImageFilePath, HotSpotType _cursorHotSpot, double _targetWidth = 0d) + { + Cursor _cursor = null; + try + { + var bitmapImage = GetBitmapImage(_ImageFilePath); + if (bitmapImage != default(BitmapImage)) + { + var curImage = new Image {Source = bitmapImage }; + using (MemoryStream ms = new MemoryStream()) + { + PngBitmapEncoder encoder = new PngBitmapEncoder(); + double ImageScale = _targetWidth.Equals(0) || _targetWidth.Equals(double.NaN) ? 1d : _targetWidth / curImage.Source.Width; + var bitmapFrame = new TransformedBitmap((BitmapSource)curImage.Source, new ScaleTransform(ImageScale, ImageScale)); + encoder.Frames.Add(BitmapFrame.Create((BitmapSource)bitmapFrame)); + encoder.Save(ms); + var cursorBitmap = new System.Drawing.Bitmap(ms); + var intPrt = cursorBitmap.GetHicon(); + var iconInfo = new IconInfo(); + GetIconInfo(intPrt, ref iconInfo); + switch (_cursorHotSpot) + { + case HotSpotType.LeftTop: + iconInfo.xHotspot = 0; + iconInfo.yHotspot = 0; + break; + case HotSpotType.LeftCenter: + iconInfo.xHotspot = 0; + iconInfo.yHotspot = cursorBitmap.Height / 2; + break; + case HotSpotType.LeftBottom: + iconInfo.xHotspot = 0; + iconInfo.yHotspot = cursorBitmap.Height; + break; + case HotSpotType.CenterTop: + iconInfo.xHotspot = cursorBitmap.Width / 2; + iconInfo.yHotspot = 0; + break; + case HotSpotType.Center: + iconInfo.xHotspot = cursorBitmap.Width / 2; + iconInfo.yHotspot = cursorBitmap.Height / 2; + break; + case HotSpotType.CenterBottom: + iconInfo.xHotspot = cursorBitmap.Width / 2; + iconInfo.yHotspot = cursorBitmap.Height; + break; + case HotSpotType.RightTop: + iconInfo.xHotspot = cursorBitmap.Width; + iconInfo.yHotspot = 0; + break; + case HotSpotType.RightCenter: + iconInfo.xHotspot = cursorBitmap.Width; + iconInfo.yHotspot = cursorBitmap.Height / 2; + break; + case HotSpotType.RightBottom: + iconInfo.xHotspot = cursorBitmap.Width; + iconInfo.yHotspot = cursorBitmap.Height; + break; + } + iconInfo.fIcon = false; + intPrt = CreateIconIndirect(ref iconInfo); + _cursor = CursorInteropHelper.Create(new SafeFileHandle(intPrt, false)); + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite("SPC.Kiosk.Common", "ResourceManager", "GetCursorByImage()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + _cursor = null; + } + return _cursor; + } + #endregion GetCursorByImage + + + + } + +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Functions/WaitWindow.cs b/Kiosk/Common/SPC.Kiosk.Common/Functions/WaitWindow.cs new file mode 100644 index 0000000..478256d --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Functions/WaitWindow.cs @@ -0,0 +1,80 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; + +namespace SPC.Kiosk.Common +{ + public sealed class WaitWindow : IDisposable + { + private static WaitWindow instance = null; + private static readonly object padlock = new object(); + /// + /// This Class Instance + /// + public static WaitWindow GetInstance + { + get + { + lock (padlock) + { + if (instance == null) + { + instance = new WaitWindow(); + } + return instance; + } + } + } + private WaitForm WaitWindowForm = null; + + + /// + /// Is Show Wait Window + /// + public bool IsShowWindow { get; set; } + public WaitWindow() + { + WaitWindowForm = new WaitForm(); + } + /// + /// Show Process Wait Window + /// + /// + /// + public void ShowWaitWindow() + { + if (WaitWindowForm == null || !IsShowWindow) + { + WaitWindowForm = new WaitForm(); + } + WaitWindowForm.Show(); + IsShowWindow=true; + } + /// + /// Close Process Wait Window + /// + public void CloseWaitWindow() + { + if (WaitWindowForm != null && IsShowWindow) + { + IsShowWindow = false; + WaitWindowForm.Close(); + //WaitWindowForm = null; + } + } + /// + /// Dispose Process Wait Window + /// + public void Dispose() + { + if (WaitWindowForm != null) + { + WaitWindowForm.Close(); + WaitWindowForm = null; + } + } + } +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Models/CommonModel.cs b/Kiosk/Common/SPC.Kiosk.Common/Models/CommonModel.cs new file mode 100644 index 0000000..ac88e11 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Models/CommonModel.cs @@ -0,0 +1,460 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Media; +using SPC.Kiosk.Base; +namespace SPC.Kiosk.Common +{ + public class M_PopupReturn + { + public bool OKAnswer { get; set; } + public bool TimeOut { get; set; } + public SupportLanguageType ReturnLanguage { get; set; } + public object PopupArgs { get; set; } = null; + public object PopupSubArgs { get; set; } = null; + public ParentPage PopupParentPage { get; set; } = ParentPage.EmptyPage; + + } + /// + /// a Basket Item + /// + /// 2019-04-05 - 1997fx11 : SetItem 관련 참조 + public class M_BasketItem : ViewModelBase + { + /// + /// Index No + /// + public int Index { get; set; } = 0; + + + /// + /// PLU_Index No + /// + public int p_Index { get; set; } = 0; + + /// + /// Item Add Type + /// + public BasketItemType ItemType { get; set; } + /// + /// Item Code + /// + public string ItemCode { get; set; } = string.Empty; + /// + /// Item Base Price + /// + public double BasePrice { get; set; } = 0d; + private double price = 0d; + /// + /// Item Price With Option + /// + public double Price + { + get { return price; } + set { price = value; PropertyChange("Price"); } + } + private double campaignPrice = 0d; + public double CampaignPrice + { + get { return campaignPrice; } + set { campaignPrice = value; PropertyChange("CampaignPrice"); } + } + private int count = 1; + /// + /// Item Count + /// + public int Count + { + get { return count; } + set { count = value; PropertyChange("Count"); } + } + /// + /// Is Coupon DC + /// + public bool IsCouponDC { get; set; } = false; + private double couponDiscount = 0d; + /// + /// Coupon DC Price + /// + public double CouponDiscount + { + get { return couponDiscount; } + set { couponDiscount = value; PropertyChange("CouponDiscount"); } + } + + /// + /// Item Image + /// + public string ItemImage { get; set; } + /// + /// Item Name + /// + public List ItemName { get; set; } + /// + /// Item Count Label + /// + public List ItemCountLabel { get; set; } + /// + /// Item Price Label + /// + public List ItemPriceLabel { get; set; } + + private List allOptionLabel; + + + /// + /// Selected Options Names + /// + public List AllOptionLabel + { + get { return allOptionLabel; } + set { allOptionLabel = value; PropertyChange("AllOptionLabel"); } + } + + private List option; + /// + /// Item Options + /// + public List Option + { + get { return option; } + set { option = value; PropertyChange("Option"); } + } + /// + /// Minus Normal Brush + /// + public string MinusNormalBrush { get; set; } = "pack://application:,,,/SPC.Kiosk.Common;component/Resource/btn_move01_left_basic.png"; + /// + /// Minus Down Brush + /// + public string MinusDownBrush { get; set; } = "pack://application:,,,/SPC.Kiosk.Common;component/Resource/btn_move01_left_press.png"; + /// + /// Plus Normal Brush + /// + public string PlusNormalBrush { get; set; } = "pack://application:,,,/SPC.Kiosk.Common;component/Resource/btn_move01_right_basic.png"; + /// + /// Plus Down Brush + /// + public string PlusDownBrush { get; set; } = "pack://application:,,,/SPC.Kiosk.Common;component/Resource/btn_move01_right_press.png"; + } + + /// + /// Button Send Events Args + /// + public class M_ItemDropEventArgs + { + /// + /// Send Object + /// + public object SourceObject { get; set; } = null; + /// + /// Target Object + /// + public object TargetObject { get; set; } = null; + } + public class M_IntroItems + { + public int ItemsStack { get; set; } = 1; + public double StackWidth { get; set; } = double.NaN; + public List StackContents { get; set; } = null; + } + public class M_StackContents + { + public int ItemsIndex { get; set; } = 0; + public List MediaRollItems { get; set; } = null; + } + /// + /// Media Rolling Item Model + /// + public class M_MediaRollItem + { + /// + /// Media Type Image or VOD + /// + public MediaType Type { get; set; } = MediaType.None; + /// + /// Media File Path + /// + public string MediaPath { get; set; } = string.Empty; + /// + /// Media Show Running Time Seconds + /// + public double RunnigSeconds { get; set; } = 0; + public bool RepeatMedia { get; set; } + public TimeSpan StartTime { get; set; } = default(TimeSpan); + public TimeSpan EndTime { get; set; } = default(TimeSpan); + public IntroLinkType LinkType { get; set; } = IntroLinkType.None; + public string LinkParameter { get; set; } = string.Empty; + } + /// + /// Button List Item Collection + /// + public class M_ItemData + { + public int Index { get; set; } = -1; + public string ItemCode { get; set; } = string.Empty; + public string Category1 { get; set; } = string.Empty; + public string Category2 { get; set; } = string.Empty; + public string ImageFile { get; set; } = string.Empty; + public double Price { get; set; } = 0d; + public bool IsOption { get; set; } + public bool IsSoldOut { get; set; } + public List Option { get; set; } + public M_AnimationButton DataParameter { get; set; } + public M_TextBlock BaseTextBlock { get; set; } + public M_TextBlock AdditionTextBlock { get; set; } + public List BadgeImages { get; set; } = null; + public double BadgeHeight { get; set; } = 0d; + public HorizontalAlignment BadgeHorizontalAlignment { get; set; } = HorizontalAlignment.Center; + public VerticalAlignment BadgeVerticalAlignment { get; set; } = VerticalAlignment.Center; + public Orientation BadgeOrientation { get; set; } = Orientation.Horizontal; + } + public class M_ItemOptionGroup + { + public int Index { get; set; } = -1; + public string Code { get; set; } = string.Empty; + public string ImageFile { get; set; } = string.Empty; + public OptionSelectMode SelectMode { get; set; } = OptionSelectMode.None; + public bool IsMustSelect { get; set; } + public List Name { get; set; } + public List Options { get; set; } + public M_ItemOptionGroup Clone() + { + M_ItemOptionGroup result = null; + try + { + result = new M_ItemOptionGroup + { + Index = Index, + Code = Code, + ImageFile = ImageFile, + SelectMode = SelectMode, + IsMustSelect = IsMustSelect, + }; + var newName = new List(); + foreach (var aLanguage in Name) + { + newName.Add(aLanguage.Clone()); + } + result.Name = newName; + var newOptions = new List(); + foreach (var aOption in Options) + { + newOptions.Add(aOption.Clone()); + } + result.Options = newOptions; + + } + catch + { + result = null; + } + return result; + } + } + public class M_ItemOption + { + public int Index { get; set; } = -1; + public string Code { get; set; } = string.Empty; + public List Name { get; set; } + public bool IsSelected { get; set; } + public double SelectValue { get; set; } = 0d; + public OptionKind Kind { get; set; } = OptionKind.None; + public string KindCode { get; set; } = string.Empty; + public double Amount { get; set; } = 0d; + public int AmountMin { get; set; } = 0; + public int AmountMax { get; set; } = 0; + public M_ItemOption Clone() + { + M_ItemOption result = null; + try + { + result = new M_ItemOption + { + Index = Index, + Code = Code, + IsSelected = IsSelected, + SelectValue = SelectValue, + Kind = Kind, + KindCode = KindCode, + Amount= Amount, + AmountMin = AmountMin, + AmountMax = AmountMax, + }; + var newName = new List(); + foreach (var aLanguage in Name) + { + newName.Add(aLanguage.Clone()); + } + result.Name = newName; + + } + catch + { + result = null; + } + return result; + } + + } + + public class M_AnimationButton + { + public double Width { get; set; } = double.NaN; + public double Height { get; set; } = double.NaN; + public Thickness Margin { get; set; } + public string NormalBrush { get; set; } = string.Empty; + public string DownBrush { get; set; } = string.Empty; + public string DisableBrush { get; set; } = string.Empty; + public string SwitchOnBrush { get; set; } = string.Empty; + public string DragCursorImage { get; set; } = string.Empty; + public HotSpotType DragCursorHotSpot { get; set; } = HotSpotType.LeftTop; + public Stretch BrushStretch { get; set; } = Stretch.Fill; + public bool Enabled { get; set; } = true; + public bool Switch { get; set; } + public bool IsBreathing { get; set; } = false; + public bool AutoToggle { get; set; } + public bool ClickSend { get; set; } + public string BaseGrid { get; set; } = string.Empty; + public string ReciveElement { get; set; } = string.Empty; + public ButtonAnimationType ClickAnimationType { get; set; } = ButtonAnimationType.None; + public ButtonAnimationType DropAnimationType { get; set; } = ButtonAnimationType.None; + public List LanguageText { get; set; } = null; + public string Text { get; set; } = string.Empty; + public Visibility TextVisible { get; set; } = Visibility.Collapsed; + public string TextForeground { get; set; } = string.Empty; + public string SwitchOnForeground { get; set; } = string.Empty; + public string DisableForeground { get; set; } = string.Empty; + public VerticalAlignment TextVerticalAlignment { get; set; } = VerticalAlignment.Center; + public HorizontalAlignment TextHorizontalAlignment { get; set; } = HorizontalAlignment.Center; + public string TextFontFamily { get; set; } = string.Empty; + public double TextFontSize { get; set; } = 12; + public double SwitchOnFontSize { get; set; } = 12; + public double DisableFontSize { get; set; } = 12; + public FontWeight TextFontWeight { get; set; } = FontWeights.Normal; + public FontWeight SwitchOnFontWeight { get; set; } = FontWeights.Normal; + public FontWeight DisableWeight { get; set; } = FontWeights.Normal; + public TextWrapping TextWrapping { get; set; } = TextWrapping.Wrap; + public TextAlignment TextAlignment { get; set; } = TextAlignment.Center; + public Thickness TextMargin { get; set; } + public bool DragEnable { get; set; } + public double CircleSize { get; set; } = 30d; + public string CircleBackBrush { get; set; } = string.Empty; + public string CircleTextBruch { get; set; } = string.Empty; + public string CircleText { get; set; } = string.Empty; + public bool CircleOuter { get; set; } + public SupportLanguageType DisplayLanguage { get; set; } + + + }; + /// + /// Button List Item Text Box Collection + /// + public class M_TextBlock + { + public List LanguageData { get; set; } = null; + public double Width { get; set; } = double.NaN; + public double Height { get; set; } = double.NaN; + public double TextSize { get; set; } = 12; + public string TextBrush { get; set; } = "Transparent"; + public FontWeight TextWeight { get; set; } = FontWeights.Normal; + public string TextFontFamily { get; set; } = "NanumSquare"; + public VerticalAlignment TextVerticalAlignment { get; set; } = VerticalAlignment.Center; + public HorizontalAlignment TextHorizontalAlignment { get; set; } = HorizontalAlignment.Center; + public TextAlignment TextAlignment { get; set; } = TextAlignment.Center; + public TextWrapping TextWrapping { get; set; } = TextWrapping.Wrap; + public bool AutoTextTrim { get; set; } = false; + public Thickness TextMargin { get; set; } + } + public class M_MultiLanguage + { + public string MessageCode { get; set; } + public List MessageData {get; set;} + } + public class M_Language + { + public SupportLanguageType Type { get; set; } + public string LanguageData { get; set; } + public M_Language Clone() + { + M_Language result = null; + try + { + result = new M_Language + { + Type = Type, + LanguageData = LanguageData, + }; + } + catch + { + result = null; + } + return result; + } + + } + + //public class NhsFuncInfo + //{ + // /// + // /// STEP01 포인트 적립 - 해피포인트 적립 + // /// + // public string SaveHappyPoint { get; set; } + // /// + // /// STEP01 포인트 적립 - OK CASHBAG 적립 + // /// + // public string SaveOkCashBag { get; set; } + // /// + // /// STEP01 통신사 할인 - SKT + // /// + // public string DiscountSKT { get; set; } + // /// + // /// STEP01 통신사 할인 - KT + // /// + // public string DiscountKT { get; set; } + // /// + // /// STEP01 통신사 할인 - LGT + // /// + // public string DiscountLG { get; set; } + // /// + // /// STEP02 포인트 사용 - 해피포인트 사용 + // /// + // public string UsePointHappyPoint { get; set; } + // /// + // /// STEP02 포인트 사용 - OK CASHBAG 사용 + // /// + // public string UsePointOkCashBag { get; set; } + // /// + // /// STEP02 쿠폰 사용 - 해피쿠폰할인 + // /// + // public string UseCouponHappy { get; set; } + // /// + // /// STEP02 쿠폰 사용 - 모바일쿠폰 + // /// + // public string UseCouponMobile { get; set; } + // /// + // /// STEP03 카드 결제 - 신용카드 + // /// + // public string UseCardPaymentCreditCard { get; set; } + // /// + // /// STEP03 카드 결제 - SPC 사원증 + // /// + // public string UseCardPaymentSPCEmployeeCertificate { get; set; } + // /// + // /// STEP03 카드 결제 - HAPPY GIFT + // /// + // public string UseCardPaymentHappyGift { get; set; } + // /// + // /// STEP03 카드 결제 - 삼성/LG 페이 + // /// + // public string UseCardPaymentSamsungLGPay { get; set; } + // /// + // /// STEP03 카드 결제 - 스마일페이 + // /// + // public string UseCardPaymentSmilePay { get; set; } + //} +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/Properties/AssemblyInfo.cs b/Kiosk/Common/SPC.Kiosk.Common/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..d231ce7 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("SPC.Kiosk.Common")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("SPC.Kiosk.Common")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("ba2d06e0-74c0-4785-b39f-d1eaac13b73d")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 +// 기본값으로 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Kiosk/Common/SPC.Kiosk.Common/Resource/btn_move01_left_basic.png b/Kiosk/Common/SPC.Kiosk.Common/Resource/btn_move01_left_basic.png new file mode 100644 index 0000000..78778e6 Binary files /dev/null and b/Kiosk/Common/SPC.Kiosk.Common/Resource/btn_move01_left_basic.png differ diff --git a/Kiosk/Common/SPC.Kiosk.Common/Resource/btn_move01_left_press.png b/Kiosk/Common/SPC.Kiosk.Common/Resource/btn_move01_left_press.png new file mode 100644 index 0000000..510e618 Binary files /dev/null and b/Kiosk/Common/SPC.Kiosk.Common/Resource/btn_move01_left_press.png differ diff --git a/Kiosk/Common/SPC.Kiosk.Common/Resource/btn_move01_right_basic.png b/Kiosk/Common/SPC.Kiosk.Common/Resource/btn_move01_right_basic.png new file mode 100644 index 0000000..8636b5c Binary files /dev/null and b/Kiosk/Common/SPC.Kiosk.Common/Resource/btn_move01_right_basic.png differ diff --git a/Kiosk/Common/SPC.Kiosk.Common/Resource/btn_move01_right_press.png b/Kiosk/Common/SPC.Kiosk.Common/Resource/btn_move01_right_press.png new file mode 100644 index 0000000..7e2960f Binary files /dev/null and b/Kiosk/Common/SPC.Kiosk.Common/Resource/btn_move01_right_press.png differ diff --git a/Kiosk/Common/SPC.Kiosk.Common/Resource/ic_alert_ing.gif b/Kiosk/Common/SPC.Kiosk.Common/Resource/ic_alert_ing.gif new file mode 100644 index 0000000..9f14a6e Binary files /dev/null and b/Kiosk/Common/SPC.Kiosk.Common/Resource/ic_alert_ing.gif differ diff --git a/Kiosk/Common/SPC.Kiosk.Common/Resource/wait_circle.png b/Kiosk/Common/SPC.Kiosk.Common/Resource/wait_circle.png new file mode 100644 index 0000000..99e0be9 Binary files /dev/null and b/Kiosk/Common/SPC.Kiosk.Common/Resource/wait_circle.png differ diff --git a/Kiosk/Common/SPC.Kiosk.Common/SPC.Kiosk.Common.csproj b/Kiosk/Common/SPC.Kiosk.Common/SPC.Kiosk.Common.csproj new file mode 100644 index 0000000..cfd9006 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/SPC.Kiosk.Common.csproj @@ -0,0 +1,199 @@ + + + + + Debug + AnyCPU + {BA2D06E0-74C0-4785-B39F-D1EAAC13B73D} + Library + Properties + SPC.Kiosk.Common + SPC.Kiosk.Common + v4.0 + 512 + true + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\BIN\Cosmos.BaseFrame.dll + + + False + ..\..\..\..\BIN\Cosmos.Common.dll + + + False + ..\..\..\..\BIN\Cosmos.ServiceProvider.dll + + + False + ..\..\..\..\BIN\Cosmos.UserFrame.dll + + + + + + + + + + + + + + + + ..\..\..\packages\WpfAnimatedGif.1.4.18\lib\net\WpfAnimatedGif.dll + + + + + AnimationButton.xaml + + + PopupMessage.xaml + + + SignPad.xaml + + + + ButtonList.xaml + + + + + + + + + + + + + IntroView.xaml + + + + MediaPlayer.xaml + + + MediaRoll.xaml + + + MessageBoxForm.xaml + + + + NumericCombo.xaml + + + NumericPad2.xaml + + + NumericPad.xaml + + + + + + + WaitForm.xaml + + + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + {bcc10fa2-c358-480c-8ff0-615750f3c306} + SPC.Kiosk.Base + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Kiosk/Common/SPC.Kiosk.Common/Types/CommonTypes.cs b/Kiosk/Common/SPC.Kiosk.Common/Types/CommonTypes.cs new file mode 100644 index 0000000..e5452e1 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/Types/CommonTypes.cs @@ -0,0 +1,779 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace SPC.Kiosk.Common +{ + /// + /// 모바일 쿠폰 종류 + /// + public enum MobileCouponType + { + /// + /// 물품형 일반 + /// + Normal, + /// + /// 금액형 일반 + /// + NormalValue, + /// + /// 물품형 횟수제한형 + /// + CountLimit, + /// + /// 금액형 금액제한 + /// + ValueLimit, + /// + /// 금액형 금액고정형 + /// + ValueFixed, + } + /// + /// 쿠폰 옵션 + /// + public enum MobileCouponOptionType + { + /// + /// 옵션없음 + /// + None, + /// + /// 타상품 교환 불가 + /// + ItemFixed + } + /// + /// 쿠폰 상태 + /// + public enum MobileCouponStatusType + { + /// + /// 사용 가능 'Y' + /// + CanUse, + /// + /// 사용 불가능 'N' + /// + CanNotUse, + /// + /// 사용된 'D' + /// + Used, + /// + /// 폐기됨 'C' + /// + Cancel, + /// + /// 환불 'R' + /// + Refound, + } + + /// + /// Basket Item Type + /// + public enum BasketItemType + { + /// + /// Default + /// + None, + /// + /// Add From Camera Scan + /// + Scan, + /// + /// Add From Barcode Scan + /// + Barcode, + /// + /// Add From Order UI + /// + Order, + } + /// + /// 결제 완료 형태 + /// + public enum PaymentEndWindowEndType + { + /// + /// 없음 + /// + None, + /// + /// 진동벨 + /// + Bell, + /// + /// 알림톡 + /// + Talk, + /// + /// 대기번호 + /// + WaitNumber, + } + /// + /// Happy Point Member Level + /// + public enum HappyPointMemberLevel + { + None, + Pink, + Gold, + VIP + } + /// + /// 지원 언어 + /// + public enum SupportLanguageType + { + /// + /// 한국어 + /// + ko, + /// + /// 영어 + /// + en, + /// + /// 일본어 + /// + ja, + /// + /// 중국어 + /// + zh, + } + /// + /// Option Select Mode + /// + public enum OptionSelectMode + { + /// + /// 없음 + /// + None, + /// + /// 단일 선택 모드 + /// + Single, + /// + /// 복수 선택 모드 + /// + Multi + } + /// + /// Option Type + /// + public enum OptionKind + { + /// + /// 없음 + /// + None, + /// + /// Button Type + /// + Button, + /// + /// 수량 타입 + /// + Count, + /// + /// 할인 타입 + /// + Discount, + /// + /// 추가금액 타입 + /// + UpCharge, + } + + /// + /// 대기화면 클릭 링크 + /// + public enum IntroLinkType + { + /// + /// 없음 + /// + None, + /// + /// 페이지 연결 + /// + Page, + /// + /// 일반 주문 카테고리 연결 + /// + Category, + /// + /// 특정 제품이 있는 목록으로 연결 + /// + ItemCode + } + /// + /// Click Button Animation Types + /// + public enum ButtonAnimationType + { + /// + /// No Animation + /// + None, + /// + /// Image Bounce Up + /// + BounceUp, + /// + /// Image Bounce Down + /// + BounceDown, + /// + /// Image SizeDown + /// + SizeDown, + /// + /// Image SizeUp + /// + SizeUp, + /// + /// Image Twist + /// + Twist, + /// + /// Text Bounce Up + /// + TextBounceUp, + /// + /// Text Bounce Down + /// + TextBounceDown, + /// + /// Text Down + /// + TextSizeDown, + /// + /// Text Up + /// + TextSizeUp, + /// + /// Text Twist + /// + TextTwist, + /// + /// Image Opacity Down + /// + OpacityDown, + /// + /// Image Opacity Up + /// + OpacityUp, + FlipX, + FlipY + } + /// + /// Image Send Type + /// + public enum ButtonSendAnimationType + { + /// + /// 없음 + /// + None, + /// + /// 크기 속도변경 없이 + /// + Normal, + /// + /// 시작 25%위치 50% 나머지 50%이동 + /// + SpeedChage, + /// + /// 키운후 줄이며 가속가기 + /// + SizeUpDown + } + /// + /// Open Close Animation Type + /// + public enum OpenCloseAnimationType + { + /// + /// 없음 + /// + None, + /// + /// 왼쪽으로 + /// + GotoLeft, + /// + /// 오른쪽으로 + /// + GotoRight, + /// + /// 위로 + /// + GotoUp, + /// + /// 아래로 + /// + GotoDown, + /// + /// 전체 줄이기 + /// + FullSizeDown, + /// + /// 전체 키우기 + /// + FullSizeUp, + } + /// + /// Shutter Animation Anchor Position Types + /// + public enum ShutterAnchor + { + /// + /// 왼쪽 + /// + Left, + /// + /// 오른쪽 + /// + Right, + /// + /// 상단 + /// + Top, + /// + /// 하단 + /// + Bottom + } + /// + /// Image HotSpot Type + /// + public enum HotSpotType + { + /// + /// 좌상 + /// + LeftTop, + /// + /// 좌중앙 + /// + LeftCenter, + /// + /// 좌하 + /// + LeftBottom, + /// + /// 중상 + /// + CenterTop, + /// + /// 정중앙 + /// + Center, + /// + /// 중하 + /// + CenterBottom, + /// + /// 우상 + /// + RightTop, + /// + /// 우중앙 + /// + RightCenter, + /// + /// 우하 + /// + RightBottom + } + /// + /// ButtonList TextPosition Type + /// + public enum TextPosition + { + /// + /// 버튼 안 + /// + InnerButton, + /// + /// 왼쪽 + /// + Left, + /// + /// 오른쪽 + /// + Right, + /// + /// 상단 + /// + Top, + /// + /// 하단 + /// + Bottom + } + /// + /// Media Type + /// + public enum MediaType + { + /// + /// 없음 + /// + None, + /// + /// 이미지 + /// + Image, + /// + /// 동영상 + /// + VOD + } + #region Encoding CodeType + /// + /// 문자열 엔코딩 CodeType + /// + public enum CodeType + { + /// + /// 시스템 기본 + /// + Default, + /// + /// ASCII + /// + ASCII, + /// + /// BigEdianUnicode(Unicode의 상하위 Byte가 바뀐 정보) + /// + BigEdianUnicode, + /// + /// Unicode + /// + Unicode, + /// + /// UTF-7 + /// + UTF7, + /// + /// UTF-8 + /// + UTF8, + /// + /// UTF-32 + /// + UTF32 + } + + #endregion + /// + /// Control Char Ctrl_ANSI Value + /// + public enum Ctrl_ASCII + { + /// + /// 0x00 + /// + Null, + /// + /// 0x01 + /// + SOH, + /// + /// 0x02 + /// + STX, + /// + /// 0x03 + /// + ETX, + /// + /// 0x04 + /// + EOT, + /// + /// 0x05 + /// + ENQ, + /// + /// 0x06 + /// + ACK, + /// + /// 0x07 + /// + BEL, + /// + /// 0x08 + /// + BS, + /// + /// 0x09 + /// + HT, + /// + /// 0x0A + /// + LF, + /// + /// 0x0B + /// + VT, + /// + /// 0x0C + /// + FF, + /// + /// 0x0D + /// + CR, + /// + /// 0x0E + /// + SO, + /// + /// 0x0F + /// + SI, + /// + /// 0x10 + /// + DLE, + /// + /// 0x11 + /// + DC1, + /// + /// 0x12 + /// + DC2, + /// + /// 0x13 + /// + DC3, + /// + /// 0x14 + /// + DC4, + /// + /// 0x15 + /// + NAK, + /// + /// 0x16 + /// + SYN, + /// + /// 0x17 + /// + ETB, + /// + /// 0x18 + /// + CAN, + /// + /// 0x19 + /// + EM, + /// + /// 0x1A + /// + SUB, + /// + /// 0x1B + /// + ESC, + /// + /// 0x1C + /// + FS, + /// + /// 0x1D + /// + GS, + /// + /// 0x1E + /// + RS, + /// + /// 0x1F + /// + US + } + /// + /// Log Type + /// + public enum Log_Type + { + /// + /// Infomation + /// + Info, + /// + /// Error + /// + Error, + /// Debug + /// + Debug + } + /// + /// Log Data Structure + /// + public struct Log_Message + { + /// + /// Log Create Time + /// + public DateTime LogDate; + /// + /// Log Create Object + /// + public String LogFrom; + /// + /// Log Type + /// + public Log_Type LogType; + /// + /// Log Message + /// + public string LogMessage; + } + /// + /// Log 설정 Structure + /// + public struct Log_Setting + { + /// + /// Log Save Path + /// default=AppDomain.CurrentDomain.BaseDirectory + "\\Log" + /// + public string LogPath; + /// + /// Log Name + /// + public string LogName; + /// + /// Selected Log Write Object Names + /// + public string[] LogFrom; + /// + /// Selected Log Types + /// + public Log_Type[] LogType; + /// + /// Maxium Log Store Dates + /// + public int LogDates; + } + + /// + /// Uri Type + /// + public enum UriTypes + { + None, + Item, + Events, + Web + } + + /// + /// Popup Parent Page + /// + public enum ParentPage + { + EmptyPage, + PBWindow, + PBPaymentsWindow + } + + /// + /// Kiosk 에서 사용가능한 결재수단 : 2019-06-10 - 1997fx11 + /// + public class NhsFuncInfoType + { + /// + /// STEP01 포인트 적립 - 해피포인트 적립 + /// + public const string SaveHappyPoint = "00058"; + /// + /// STEP01 포인트 적립 - OK CASHBAG 적립 + /// + public const string SaveOkCashBag = "00255"; + /// + /// STEP01 통신사 할인 - SKT + /// + public const string DiscountSKT = "00059"; + /// + /// STEP01 통신사 할인 - KT + /// + public const string DiscountKT = "00060"; + /// + /// STEP01 통신사 할인 - LGT + /// + public const string DiscountLG = "00061"; + /// + /// STEP02 포인트 사용 - 해피포인트 사용 + /// + public const string UsePointHappyPoint = "00078"; + /// + /// STEP02 포인트 사용 - OK CASHBAG 사용 + /// + public const string UsePointOkCashBag = "00080"; + /// + /// STEP02 쿠폰 사용 - 해피쿠폰할인 + /// + public const string UseCouponHappy = "00063"; + /// + /// STEP02 쿠폰 사용 - 모바일쿠폰 + /// + public const string UseCouponMobile = "00073"; + /// + /// STEP03 카드 결제 - 신용카드 + /// + public const string UseCardPaymentCreditCard = "00071"; + /// + /// STEP03 카드 결제 - SPC 사원증 + /// + public const string UseCardPaymentSPCEmployeeCertificate = "00088"; + /// + /// STEP03 카드 결제 - T-MONEY + /// + public const string UseCardPaymentTMoney = "00089"; + /// + /// STEP03 카드 결제 - 캐시비 + /// + public const string UseCardPaymentCashBee = "00091"; + /// + /// STEP03 카드 결제 - HAPPY GIFT + /// + public const string UseCardPaymentHappyGift = "00291"; + /// + /// STEP03 카드 결제 - 삼성/LG 페이 + /// + public const string UseCardPaymentSamsungLGPay = "00999"; + /// + /// STEP03 모바일 결제 - 알리페이 + /// + public const string UseCardPaymentAlipay = "00086"; + /// + /// STEP03 카드 결제 - 스마일페이 + /// + public const string UseCardPaymentSmilePay = "00258"; + /// + /// STEP03 모바일 결제 - 제로페이 + /// + public const string UseCardPaymentZeroPay = "00302"; + } +} diff --git a/Kiosk/Common/SPC.Kiosk.Common/packages.config b/Kiosk/Common/SPC.Kiosk.Common/packages.config new file mode 100644 index 0000000..8149635 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.Common/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Kiosk/Common/SPC.Kiosk.DataHelper/BackDataService.cs b/Kiosk/Common/SPC.Kiosk.DataHelper/BackDataService.cs new file mode 100644 index 0000000..c3bce89 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.DataHelper/BackDataService.cs @@ -0,0 +1,134 @@ +using System; +using System.Linq; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Runtime.InteropServices; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; +using Cosmos.Service; +using Cosmos.CommonManager; +using System.Timers; +//using System.Threading; +using SPC.Kiosk.Common; +using SPC.Kiosk.PB.Model; +namespace SPC.Kiosk.DataHelper +{ + public class BackDataService : IDisposable + { + #region [ Members ] + private SManager sManager = null; // 이 객체를 통해 업무 Service 호출 + private StateServer StateObject = null; // StateObject : StateServer Object (객체) + private PosStatus m_cPosStatus = null; // 기본정보 참조 + private TranStatus m_cTrnStatus = null; // 거래정보 참조 + protected IDataCommonUs m_cDataCommon = null; + private Timer objServiceTimer; + private DateTime lastTime; + + private IDataProcessUs m_cDataService = null; // 거래데이터 합계금액 계산 및 관리 + private ICampaignUs m_cCampaingMain = null; // 캠페인 관리 + private String m_sMstBatchDownDate = ""; + /// + /// POS 초기화 필요 유무 + /// + public bool NeedInitModule { get; set; } + #endregion Members + + #region [ Ctor & Dispose ] + /// + /// Ctor + /// + public BackDataService() + { + sManager = new SManager(); + StateObject = (StateServer)StateServer.GetInstance(); + if (!NeedInitModule) + { + m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 + m_cTrnStatus = (TranStatus)StateObject.TRAN; // POS 거래정보 + m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON); + + m_cDataService = (IDataProcessUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_SERVICE); + m_cCampaingMain = (ICampaignUs)sManager.InitServiceInstance(ServiceLists.ASV_CAMPAIGN.DLL, ServiceLists.ASV_CAMPAIGN.CAMPAIGN_MAIN); + + // 캠페인 마스터 로딩 + m_cDataService.InitTranHeader(); + m_sMstBatchDownDate = m_cPosStatus.Base.MstBatchDownDate; + m_cCampaingMain.LoadCampaignCondition(new string[] { }); + + + objServiceTimer = new Timer(1000); + lastTime = DateTime.Now; + objServiceTimer.Elapsed += ObjServiceTimer_Elapsed; + objServiceTimer.Start(); + } + } + + + private void ObjServiceTimer_Elapsed(object sender, ElapsedEventArgs e) + { + DateTime _dateTime = DateTime.Now; + //if ((DateTime.Now - lastTime) >= (TimeSpan.FromMinutes(0.5d))) + if ((_dateTime - lastTime) >= (TimeSpan.FromMinutes(0.5d))) + { + //TODO:5분마다 처리할 로직 추가 + lastTime = DateTime.Now; + + //string[] _list = m_cDataCommon.Select_NHS_CUST_BUY_HIST(string.Format("{0:yyyyMMddHHmmss}", DateTime.Now), @"1011175065"); + + // 2019-03-21 - 1997fx11 : 아이템 변경 수신 + int iRet01 = m_cDataCommon.Get_NEW_PRODUCT_BY_IRT(); + + // 2019-03-21 - 1997fx11 : 시스템정보 전송 + int iRet02 = m_cDataCommon.Send_SYSTEM_INFO(); + } + + // 2019-04-25 - 1997fx11 : 자동 마감/개점 ver 0.2 + // PosStart/frmPosStart.cs/tmrStart_Tick 내에 메인포스 개점여부에 따라 진행. (추가예정?? 부분) + string sCurrentTime = System.DateTime.Now.ToString("HHmmss"); + if (CmUtil.LongParse(sCurrentTime) == CmUtil.LongParse("050000")) + { + m_cDataCommon.SetSaleEndOpen(); + } + } + + + /// + /// Dispose + /// + public void Dispose() + { + if (objServiceTimer != null) + { + objServiceTimer.Stop(); + objServiceTimer.Elapsed -= ObjServiceTimer_Elapsed; + objServiceTimer.Dispose(); + objServiceTimer = null; + } + sManager = null; // 이 객체를 통해 업무 Service 호출 + StateObject = null; // StateObject : StateServer Object (객체) + m_cPosStatus = null; // 기본정보 참조 + m_cTrnStatus = null; // 거래정보 참조 + m_cDataCommon = null; + } + #endregion Ctor & Dispose + + #region [ Methods ] + + /// + /// 옵션값 획득 + /// + /// + /// + public string GetPosOption(string sOptCode) + { + return PosMstManager.GetPosOption(sOptCode); + } + + #endregion Methods + } +} diff --git a/Kiosk/Common/SPC.Kiosk.DataHelper/CommonDataHelper.cs b/Kiosk/Common/SPC.Kiosk.DataHelper/CommonDataHelper.cs new file mode 100644 index 0000000..472accf --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.DataHelper/CommonDataHelper.cs @@ -0,0 +1,811 @@ +using System; +using System.Linq; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Runtime.InteropServices; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; +using Cosmos.Service; +using Cosmos.CommonManager; +using System.Threading; +using SPC.Kiosk.Common; +using SPC.Kiosk.PB.Model; + +namespace SPC.Kiosk.DataHelper +{ + public class CommonDataHelper : IDisposable + { + #region [ Members ] + private SManager sManager = null; // 이 객체를 통해 업무 Service 호출 + private StateServer StateObject = null; // StateObject : StateServer Object (객체) + private PosStatus m_cPosStatus = null; // 기본정보 참조 + private TranStatus m_cTrnStatus = null; // 거래정보 참조 + protected IDataCommonUs m_cDataCommon = null; + /// + /// POS 초기화 필요 유무 + /// + public bool NeedInitModule { get; set; } + #endregion Members + + #region [ Ctor & Dispose ] + /// + /// Ctor + /// + public CommonDataHelper() + { + sManager = new SManager(); + StateObject = (StateServer)StateServer.GetInstance(); + if (!NeedInitModule) + { + m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 + m_cTrnStatus = (TranStatus)StateObject.TRAN; // POS 거래정보 + m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON); + } + } + /// + /// Dispose + /// + public void Dispose() + { + sManager = null; // 이 객체를 통해 업무 Service 호출 + StateObject = null; // StateObject : StateServer Object (객체) + m_cPosStatus = null; // 기본정보 참조 + m_cTrnStatus = null; // 거래정보 참조 + m_cDataCommon = null; + } + #endregion Ctor & Dispose + + #region [ Methods ] + /// + /// Set Common Language Data + /// + public void SetCommonLanguage() + { + try + { + if (NeedInitModule) return; + var getLanguageData = m_cDataCommon.Select_NHS_LANG_MSG("COMMON");//m_cDataCommon.Select_NHS_LANG_MSG("COMMON"); + if (getLanguageData is DataTable) + { + foreach (var aLanguageData in getLanguageData.Rows) + { + if (aLanguageData is DataRow aRow) + { + var languageCode = aRow["LANG_MESSAGE_CD"] is null ? string.Empty : aRow["LANG_MESSAGE_CD"].ToString(); + var languageType = SupportLanguageType.ko; + if (!(aRow["LANG_CD"] is null) && aRow["LANG_CD"].ToString().Length > 2) + { + try + { + languageType = (SupportLanguageType)Enum.Parse(typeof(SupportLanguageType), aRow["LANG_CD"].ToString().Substring(0, 2)); + } + catch + { + + languageType = SupportLanguageType.ko; + } + } + var languageData = aRow["LANG_MESSAGE"] is null ? string.Empty : aRow["LANG_MESSAGE"].ToString(); + Languages.SetMessage(languageCode, languageType, languageData); + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "SetCommonLanguage()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// Get Language Data + /// _gubunCD + /// 상품/제품 = "PROD" Item + /// 카데고리 = "CATE" Category + /// 옵션 = "OPTN" Option + /// 옵션그룹 = "OPTNGRP" Option Group + /// + /// + /// + /// + public List GetLaguageData(string _gubunCD, string _messageCD) + { + if (NeedInitModule) return null; + List result = new List(); + try + { + var getLanguageData = m_cDataCommon.Select_NHS_LANG_MSG(_gubunCD, _messageCD); + if (getLanguageData is DataTable && getLanguageData.Rows.Count > 0) + { + foreach (var aLanguageData in getLanguageData.Rows) + { + if (aLanguageData is DataRow aRow) + { + var languageCode = aRow["LANG_MESSAGE_CD"] is null ? string.Empty : aRow["LANG_MESSAGE_CD"].ToString(); + var languageType = SupportLanguageType.ko; + if (!(aRow["LANG_CD"] is null) && aRow["LANG_CD"].ToString().Length > 2) + { + try + { + languageType = (SupportLanguageType)Enum.Parse(typeof(SupportLanguageType), aRow["LANG_CD"].ToString().Substring(0, 2)); + } + catch + { + + languageType = SupportLanguageType.ko; + } + } + var languageData = aRow["LANG_MESSAGE"] is null ? string.Empty : aRow["LANG_MESSAGE"].ToString(); + var dataFinded = result.Where(r => r.Type.Equals(languageType)).FirstOrDefault(); + if (dataFinded is M_Language) + { + dataFinded.LanguageData = languageData; + } + else + { + var addDada = new M_Language + { + Type = languageType, + LanguageData = languageData + }; + result.Add(addDada); + } + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetLaguageData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = new List(); + } + return result; + } + /// + /// Get Into Data + /// + /// + public List GetIntroData(double _screenWidth) + { + if (NeedInitModule) return null; + List result = null; + try + { + + var getIntroItem = m_cDataCommon.Select_NHS_SCREEN(); + if (getIntroItem is DataTable && getIntroItem.Rows.Count > 0) + { + result = new List(); + var screenRow = getIntroItem.Rows[0]; + var screenCD = screenRow["SCREEN_CD"] is null ? string.Empty : screenRow["SCREEN_CD"].ToString(); + if (!string.IsNullOrEmpty(screenCD)) + { + var getFrames = m_cDataCommon.Select_NHS_SCREEN_LAYER_GROUPBY_FRAMECD(screenCD); + var stackWidth = _screenWidth; + if (getFrames.Rows.Count.Equals(2)) stackWidth = _screenWidth / 2; + var stackIndex = 0; + foreach (var getFramesItem in getFrames.Rows) + { + if (getFramesItem is DataRow aFrameRow) + { + + var frameCD = aFrameRow["FRAME_CD"] is null ? string.Empty : aFrameRow["FRAME_CD"].ToString(); + if (!string.IsNullOrEmpty(frameCD)) + { + var getStackContents = GetStackContents(screenCD, frameCD); + var newIntroItems = new M_IntroItems + { + ItemsStack = stackIndex, + StackWidth = stackWidth, + StackContents = getStackContents + }; + result.Add(newIntroItems); + stackIndex++; + } + } + } + + + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetIntroData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + + private List GetStackContents(string _screenCD, string _frameCD) + { + List result = null; + try + { + var getScreenLayer = m_cDataCommon.Select_NHS_SCREEN_LAYER(_screenCD, _frameCD); + if (getScreenLayer is DataTable && getScreenLayer.Rows.Count > 0) + { + result = new List(); + int setIndex = 0; + foreach (var aStackItem in getScreenLayer.Rows) + { + if (aStackItem is DataRow aRow) + { + var layerCD = aRow["LAYER_CD"] is null ? string.Empty : aRow["LAYER_CD"].ToString(); + if (!string.IsNullOrEmpty(layerCD)) + { + var mediaItems = GetMediaRollItems(_screenCD, _frameCD, layerCD); + var newStackItems = new M_StackContents + { + ItemsIndex = setIndex, + MediaRollItems = mediaItems, + }; + result.Add(newStackItems); + setIndex++; + } + + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetStackContents()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + + private List GetMediaRollItems(string _screenCD, string _frameCD, string _layerCD) + { + List result = null; + try + { + var getScreenContents = m_cDataCommon.Select_NHS_SCREEN_CONTENTS(_screenCD, _frameCD, _layerCD); + if (getScreenContents is DataTable && getScreenContents.Rows.Count > 0) + { + result = new List(); + foreach (var aContents in getScreenContents.Rows) + { + if (aContents is DataRow aRow) + { + var fileType = aRow["FILE_MIME_TYPE"].ToString().Equals("PNG") + ? MediaType.Image + : aRow["FILE_MIME_TYPE"].ToString().Equals("MP4") + ? MediaType.VOD + : MediaType.None; + var linkType = aRow["LINK_YN"].ToString().Equals("1") + ? IntroLinkType.Page + : aRow["LINK_YN"].ToString().Equals("2") + ? IntroLinkType.Category + : aRow["LINK_YN"].ToString().Equals("3") + ? IntroLinkType.ItemCode + : IntroLinkType.None; + var param1 = aRow["PRD_CATE_L"] is null ? string.Empty : aRow["PRD_CATE_L"].ToString(); + var param2 = aRow["PRD_CATE_M"] is null ? string.Empty : aRow["PRD_CATE_M"].ToString(); + var linkParameter = string.Empty; + switch (linkType) + { + case IntroLinkType.Page: + switch (param1) + { + case "0": + linkParameter = "FirstSelect"; + break; + case "1": + linkParameter = "SensingPage"; + break; + case "2": + linkParameter = "ItemPage"; + break; + default: + linkParameter = "FirstSelect"; + break; + } + break; + case IntroLinkType.Category: + linkParameter = string.Format("category&{0}&{1}", param1, param2); + break; + case IntroLinkType.ItemCode: + linkParameter = param1; + break; + + } + var mediaPath = aRow["FILE_NAME"] is null ? string.Empty : aRow["FILE_NAME"].ToString(); + var runnigSeconds = aRow["PLAY_TIME"] is null ? 0 : double.Parse(aRow["PLAY_TIME"].ToString()); + var startTime = aRow["DISPLAY_START_TIME"] is null ? string.Empty : aRow["DISPLAY_START_TIME"].ToString(); + var endTime = aRow["DISPLAY_END_TIME"] is null ? string.Empty : aRow["DISPLAY_END_TIME"].ToString(); + if (!startTime.Length.Equals(4)) startTime = string.Empty; + if (!endTime.Length.Equals(4)) startTime = string.Empty; + var newMediaItem = new M_MediaRollItem + { + Type = fileType, + MediaPath = ResourceManager.GetCDPimagePath(mediaPath), + LinkType = linkType, + LinkParameter = linkParameter, + RunnigSeconds = runnigSeconds, + StartTime = startTime.Equals(string.Empty) + ? default(TimeSpan) + : new TimeSpan(int.Parse(startTime.Substring(0,2)), int.Parse(startTime.Substring(2, 2)), 0), + EndTime = endTime.Equals(string.Empty) + ? default(TimeSpan) + : new TimeSpan(int.Parse(endTime.Substring(0, 2)), int.Parse(endTime.Substring(2, 2)), 59) + + }; + result.Add(newMediaItem); + } + } + + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetMediaRollItems()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + + /// + /// Get Category Data + /// + /// + public List GetCategoryData() + { + if (NeedInitModule) return null; + List result = null; + try + { + var getCategory1Items = m_cDataCommon.Select_NHS_PRD_CATE("0000"); + if (getCategory1Items is DataTable) + { + result = new List(); + int setIndex = 0; + foreach (var aCategoryItem in getCategory1Items.Rows) + { + if (aCategoryItem is DataRow aRow) + { + var category1Code = aRow["PRD_CATE_CD"] is null ? string.Empty : aRow["PRD_CATE_CD"].ToString(); + if (!result.Exists(r => r.Catalog1Item.Category1.Equals(category1Code))) + { + result.Add + ( + new M_CategoryItems + { + Catalog1Item = new M_ItemData + { + Index = setIndex, + ItemCode = category1Code, + Category1 = category1Code, + }, + Catalog2Items = GetCategory2Data(category1Code) + } + ); + setIndex++; + } + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetCategoryData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + /// + /// Get Category2 Data + /// + /// + public List GetCategory2Data(string _category1Code) + { + if (NeedInitModule) return new List(); + var result = new List(); + try + { + var getCategory2Item = m_cDataCommon.Select_NHS_PRD_CATE(_category1Code); + if (getCategory2Item is DataTable) + { + int setIndex = 0; + foreach (var aCategoryItem in getCategory2Item.Rows) + { + if (aCategoryItem is DataRow aRow) + { + var category2Code = aRow["PRD_CATE_CD"] is null ? string.Empty : aRow["PRD_CATE_CD"].ToString(); + if (!result.Exists(r => r.Category2.Equals(category2Code))) + { + result.Add + ( + new M_ItemData + { + Index = setIndex, + ItemCode = category2Code, + Category1 = _category1Code, + Category2 = category2Code, + } + ); + setIndex++; + } + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetCategory2Data()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = new List(); + } + return result; + } + /// + /// Get Item Data + /// + /// + /// + public List GetItemsData(string _itemcode = null, string _barcord = null) + { + if (NeedInitModule) return new List(); + var result = new List(); + try + { + var getItems = m_cDataCommon.Select_NHS_STOR_PRD_KEY(_itemcode, _barcord); + if (getItems is DataTable) + { + int setIndex = 0; + foreach (var aItem in getItems.Rows) + { + if (aItem is DataRow aRow) + { + var itemCode = aRow["ITEM_CD"] is null ? string.Empty : aRow["ITEM_CD"].ToString(); + if (!result.Exists(r => r.ItemCode.Equals(itemCode))) + { + var category1 = aRow["PRD_CATE_UP_CD"] is null ? string.Empty : aRow["PRD_CATE_UP_CD"].ToString(); + var category2 = aRow["PRD_CATE_CD"] is null ? string.Empty : aRow["PRD_CATE_CD"].ToString(); + var imageFile = aRow["FILE_NAME"] is null ? string.Empty : aRow["FILE_NAME"].ToString(); + var isOption = aRow["OPTN_YN"] is null ? false : aRow["OPTN_YN"].ToString().Equals("1"); + var isSoldOut = aRow["SOLDOUT_YN"] is null ? false : aRow["SOLDOUT_YN"].ToString().Equals("1"); + var itemPrice = aRow["SALES_PRC"] is null ? 0d : double.Parse(aRow["SALES_PRC"].ToString()); + var option = isOption ? GetItemOption(itemCode) : null; + var badgeImages = GetBadgeImages(itemCode); + result.Add + ( + new M_ItemData + { + Index = setIndex, + ItemCode = itemCode, + Category1 = category1, + Category2 = category2, + ImageFile = imageFile, + BadgeImages = badgeImages, + IsOption = isOption, + IsSoldOut = isSoldOut, + Price = itemPrice, + Option = option + } + ); + setIndex++; + } + else + { + CommonLog.ErrorLogWrite(this, "GetItemsData()", "Duplicate Item No", string.Format("{0} : {1}", itemCode, aRow["TOUCH_KEY_NM"].rDBToString())); + } + + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetItemsData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = new List(); + } + return result; + } + public M_ItemData GetBarcordItemsData(string _itemcode = null, string _barcord = null) + { + if (NeedInitModule) return null; + var result = new M_ItemData(); + try + { + var getItems = m_cDataCommon.Select_NHS_PRD_MST(_barcord,_itemcode); + if (getItems is DataTable && getItems.Rows.Count > 0) + { + if (getItems.Rows[0] is DataRow aRow) + { + var itemCode = aRow["ITEM_CD"] is null ? string.Empty : aRow["ITEM_CD"].ToString(); + var category2 = aRow["PRD_CATE_CD"] is null ? string.Empty : aRow["PRD_CATE_CD"].ToString(); + var imageFile = aRow["FILE_NAME"] is null ? string.Empty : aRow["FILE_NAME"].ToString(); + var itemPrice = aRow["TAKE_OUT_SALE_AMT"] is null ? 0d : double.Parse(aRow["TAKE_OUT_SALE_AMT"].ToString()); + result = new M_ItemData + { + ItemCode = itemCode, + Category2 = category2, + ImageFile = imageFile, + Price = itemPrice, + }; + } + + } + else + { + result = null; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetBarcordItemsData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + private List GetBadgeImages(string _itemCode) + { + List result = null; + try + { + var getBadgeImages = m_cDataCommon.Select_NHS_STOR_PRD_TAG(_itemCode); + if (getBadgeImages is DataTable && getBadgeImages.Rows.Count > 0) + { + result = new List(); + + int setIndex = 0; + foreach (var aItem in getBadgeImages.Rows) + { + if (aItem is DataRow aRow) + { + var badgeImage = aRow["FILE_NAME"] is null ? string.Empty : aRow["FILE_NAME"].ToString(); + if (!string.IsNullOrEmpty(badgeImage)) + { + result.Add(badgeImage); + setIndex++; + } + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetBadgeImages()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + + /// + /// Get Option Data + /// + /// + /// + public List GetItemOption(string _itemCode) + { + if (NeedInitModule) return null; + List result = null; + try + { + var getOptionGroup = m_cDataCommon.Select_NHS_PRD_OPTN(_itemCode); + if (getOptionGroup is DataTable && getOptionGroup.Rows.Count > 0 ) + { + result = new List(); + + int setIndex = 0; + foreach (var aItem in getOptionGroup.Rows) + { + if (aItem is DataRow aRow) + { + try + { + var optionGroupCode = aRow["ITEM_OPTN_GRP_CD"] is null ? string.Empty : aRow["ITEM_OPTN_GRP_CD"].ToString(); + + if (!result.Exists(r => r.Code.Equals(optionGroupCode))) + { + var getOptionGroupItem = m_cDataCommon.Select_NHS_PRD_OPTN_GRP(optionGroupCode); + if (getOptionGroupItem is DataTable && getOptionGroupItem.Rows.Count.Equals(1)) + { + var optionGroupItem = getOptionGroupItem.Rows[0]; + var selectMode = optionGroupItem["SEL_MTD"].ToString().Equals("S") + ? OptionSelectMode.Single + : optionGroupItem["SEL_MTD"].ToString().Equals("M") + ? OptionSelectMode.Multi + : OptionSelectMode.None; + var imageFile = optionGroupItem["FILE_NAME"] is null ? string.Empty : optionGroupItem["FILE_NAME"].ToString(); + var isMustSelect = optionGroupItem["RQRD_YN"] is null ? false : optionGroupItem["RQRD_YN"].ToString().Equals("1"); + result.Add + ( + new M_ItemOptionGroup + { + Index = setIndex, + Code = optionGroupCode, + ImageFile = imageFile, + SelectMode = selectMode, + IsMustSelect = isMustSelect, + Name = GetLaguageData("OPTNGRP", optionGroupCode), + Options = GetOptions(optionGroupCode), + } + ); + setIndex++; + } + } + } + catch + { + } + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetItemOption()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + /// + /// Get Option Group Data With Options Data + /// + /// + /// + public List GetOptions(string _optionGroupCode) + { + if (NeedInitModule) return null; + List result = null; + try + { + var getOption = m_cDataCommon.Select_NHS_OPTN_MST(_optionGroupCode); + if (getOption is DataTable && getOption.Rows.Count > 0) + { + result = new List(); + int setIndex = 0; + foreach (var aItem in getOption.Rows) + { + if (aItem is DataRow aRow) + { + try + { + var optionCode = aRow["ITEM_OPTN_CD"] is null ? string.Empty : aRow["ITEM_OPTN_CD"].ToString(); + if (!result.Exists(r => r.Code.Equals(optionCode))) + { + var kind = aRow["KIND"].ToString().Equals("DIS") + ? OptionKind.Discount + : aRow["KIND"].ToString().Equals("BTN") + ? OptionKind.Button + : aRow["KIND"].ToString().Equals("UPC") + ? OptionKind.UpCharge + : aRow["KIND"].ToString().Equals("CNT") + ? OptionKind.Count + : OptionKind.None; + var kindCode = aRow["KIND_CODE"] is null ? string.Empty : aRow["KIND_CODE"].ToString(); + var amountMin = aRow["MIN_AMT"] is null ? 0 : int.Parse(aRow["MIN_AMT"].ToString()); + var amountMax = aRow["MAX_AMT"] is null ? 0 : int.Parse(aRow["MAX_AMT"].ToString()); + var amount = aRow["AMT"] is null ? 0d : double.Parse(aRow["AMT"].ToString()); + result.Add + ( + new M_ItemOption + { + Index = setIndex, + Code = optionCode, + Name = GetLaguageData("OPTN", optionCode), + SelectValue = 0d, + Kind = kind, + KindCode = kindCode, + Amount = amount, + AmountMin = amountMin, + AmountMax = amountMax + } + ); + setIndex++; + } + } + catch + { + } + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetOptions()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + + /// + /// Kiosk 에서 사용가능한 결재수단 사용여부를 조회 : 2019-06-10 - 1997fx11 + /// + /// + public Dictionary GetNhsFuncInfo() + { + var nhsFuncInfoType = new NhsFuncInfoType(); + var dictionaryNhsFuncInfo = new Dictionary(); + + var dt = m_cDataCommon.Select_NHS_FUNC_INFO(); + + //전체 const로 잡힌 필드를 돌며 DB에서 받아온 Key와 매칭 + foreach (var item in nhsFuncInfoType.GetType().GetFields()) + { + //DataTable에서 키와 일치하는 값을 찾아냄 + var rowData = dt.Select($"FUNC_CD = {item.GetValue(item.Name)}").FirstOrDefault(); + if (rowData != null) + { + //Dictionary에 키와 Use_Yn값을 추가 + dictionaryNhsFuncInfo.Add(item.GetValue(item.Name)?.ToString(), rowData["USE_YN"]?.ToString()); + } + } + + return dictionaryNhsFuncInfo; + } + #endregion Methods + + + #region MyRegion + /// + /// 2019-03-19 - 1997fx11 : 구매고객 이력 호출 + /// + /// + /// + public string[] GetCustBuyHistory(string _custCd) + { + string[] aList = null; + string sToday = string.Empty; + + try + { + var custNo = _custCd.Length >= 10 ? _custCd.Substring(0, 10) : string.Empty; + sToday = string.Format("{0:yyyyMMddHHmmss}", DateTime.Now); + + aList = string.IsNullOrEmpty(custNo) ? null : m_cDataCommon.Select_NHS_CUST_BUY_HIST(sToday, _custCd); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetCustBuyHistory()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + aList = null; + } + + return aList; + } + //public int GetNewProduct(string _updateDate = ) + //{ + // int iRet = 0; + + // try + // { + // iRet = m_cDataCommon.Get_NEW_PRODUCT_BY_IRT(_updateDate); + // } + // catch + // { + // iRet = -1; + // } + + // return iRet; + //} + + /// + /// 2019-05-30 - 1997fx11 : 알림톡 전송 + /// + /// + /// + /// + public void Send_NoticeTalk(string sPhoneNo, string korItemName, string itemCount) + { + try + { + if (!string.IsNullOrEmpty(m_cPosStatus.Base.LastRcptBarcodeData)) + { + var result = m_cDataCommon.Send_NoticeTalk(sPhoneNo, korItemName, itemCount); + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "Send_NoticeTalk()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + #endregion + } +} \ No newline at end of file diff --git a/Kiosk/Common/SPC.Kiosk.DataHelper/PosDataService.cs b/Kiosk/Common/SPC.Kiosk.DataHelper/PosDataService.cs new file mode 100644 index 0000000..dc81c29 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.DataHelper/PosDataService.cs @@ -0,0 +1,724 @@ +using System; +using System.Linq; +using System.Text; +using System.Collections; +using System.Collections.Generic; +using System.Data; +using System.Runtime.InteropServices; + +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; +using Cosmos.Service; +using Cosmos.Win; +using Cosmos.CommonManager; +using System.Timers; +//using System.Threading; +using SPC.Kiosk.Common; +using SPC.Kiosk.PB.Model; +using System.Collections.ObjectModel; + +namespace SPC.Kiosk.DataHelper +{ + public class PosDataService : IDisposable + { + #region [ Members ] + private SManager sManager = null; // 이 객체를 통해 업무 Service 호출 + private StateServer StateObject = null; // StateObject : StateServer Object (객체) + private PosStatus m_cPosStatus = null; // 기본정보 참조 + private TranStatus m_cTrnStatus = null; // 거래정보 참조 + protected IDataCommonUs m_cDataCommon = null; + private IDataProcessUs m_cDataService = null; // 거래데이터 합계금액 계산 및 관리 + + + + + private SaleMainProcess m_cSaleMainProc = null; // 판매화면 기능 관리 + + /// + /// POS 초기화 필요 유무 + /// + public bool NeedInitModule { get; set; } + #endregion Members + + + #region [ Ctor & Dispose ] + /// + /// Ctor + /// + public PosDataService() + { + try + { + sManager = new SManager(); + StateObject = (StateServer)StateServer.GetInstance(); + if (!NeedInitModule) + { + m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 + m_cTrnStatus = (TranStatus)StateObject.TRAN; // POS 거래정보 + m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON); + + m_cDataService = (IDataProcessUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_SERVICE); + + + m_cSaleMainProc = new SaleMainProcess(); + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "Ctor", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + + /// + /// Dispose + /// + public void Dispose() + { + sManager = null; // 이 객체를 통해 업무 Service 호출 + StateObject = null; // StateObject : StateServer Object (객체) + m_cPosStatus = null; // 기본정보 참조 + m_cTrnStatus = null; // 거래정보 참조 + m_cDataCommon = null; + } + + public void DisposePos() + { + //sManager = null; + //StateObject = null; // StateObject : StateServer Object (객체) + + m_cTrnStatus.Sale.Clear(); + m_cTrnStatus.Head.Clear(); + + m_cDataService.InitTranHeader(); + m_cDataService.DeleteTranItem(); + } + #endregion Ctor & Dispose + + + #region [ Methods ] + /// + /// 점포명 조회 + /// + /// + public string StoreName() + { + if (NeedInitModule) return string.Empty; + string result = string.Empty; + try + { + + result = CmUtil.GetDataRowStr(PosMstManager.GetMstStore(), PosMst.MST_STORE.DATA.STORNM); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "StoreName()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = string.Empty; + } + return result; + } + public void GetCashBill(ref double _cashBill, ref double _taxbill) + { + _cashBill = m_cDataService.GetCashAmt(); + if (_cashBill > 0) + { + _taxbill = m_cDataService.GetPaymentAmtVAT(_cashBill); + } + } + + /// + /// 영수증 인쇄 + /// + /// 진동벨번호 + /// 알림톡유무 + /// HappyPoint 적립유무 + /// Ok CashBag 적립유무 + /// + public string PrintReceipt(string _bellNo, bool _isTalk, bool _isHappyPoint, bool _isOkCashBag) + { + if (NeedInitModule) return string.Empty; + string result = string.Empty; //대기번호 + var saleMain = new SaleMainProcess(); + var sRet = ""; + try + { + + //var m_cTrnStatus = + + if (_isHappyPoint) + { + var m_cHappyPoint = (IPaymentExpUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.POINTHAPPYPOINT); + Column.TR_ETC.DATA cEtcItem = (Column.TR_ETC.DATA)m_cHappyPoint.GetPayment(new string[] { }); + ArrayList alEtcItem = (ArrayList)StateObject.GetItemObject(Column.TR_ETC.ITEM); + //cEtcItem.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL; + //cEtcItem.AMT_ENTRY_09 = 4000d; + alEtcItem.Clear(); + alEtcItem.Add(cEtcItem); + } + else if (_isOkCashBag) + { + //var m_cPntOcbSave = (IPaymentExpUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.PNT_OCB_SAVE) + //Column.TR_ETC.DATA cEtcItem = (Column.TR_ETC.DATA)m_cPntOcbSave.GetPayment(new string[] { }); + //ArrayList alEtcItem = (ArrayList)StateObject.GetItemObject(Column.TR_ETC.ITEM); + ////cEtcItem.CANCEL_DIV = ItemConst.PAY_CANCEL_DIV.NORMAL; + ////cEtcItem.AMT_ENTRY_09 = 4000d; + //alEtcItem.Clear(); + //alEtcItem.Add(cEtcItem); + } + //영수증 인쇄 + if (!string.IsNullOrEmpty(_bellNo)) + { + m_cTrnStatus.Head.OrderNo = _bellNo; + m_cTrnStatus.Head.IsBellUse = "1"; + } + + + sRet = saleMain.CheckSaleComplete(true); + //ISaleCompleteUs m_cSaleComplete = (ISaleCompleteUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.SALE_COMPLETE); + //var sRet = m_cSaleComplete.PosSaleExecute(new string[] { }); + + string sFilePath = BaseCom.NxCDPPath + PosConst.MST_IMG_PATH.CDP_COM + "NHS_카드_결제_완료_여_.wav"; + CmUtil.PlaySound(sFilePath); + + + result = m_cTrnStatus.Head.OrderNo; //대기번호 + m_cTrnStatus.Head.OrderNo = ""; + + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "PrintReceipt()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = string.Empty; + } + finally + { + if (sRet.Equals(UserCom.ERROR)) DisposePos(); //에러발생 시 거래정보 초기화 에러 없으면 SaleMainProcess에서 초기화 하고 있음..2019.04.17 + } + return result; + } + + + /// + /// 장바구니 전체 변경 + /// + /// + /// + public bool ResetItems(List _basketItems) + { + if (NeedInitModule) return false; + bool result = true; + try + { + //TODO : Clear All Data + + + + + + m_cDataService.DeleteTranItem();//주문화면에서 사용한 모든 거래 데이터 삭제 + m_cDataService.InitTranHeader();//거래 정보 초기화 + + m_cTrnStatus.Head.TradeDiv = ItemConst.TRAN_DIV.NORMAL; + m_cTrnStatus.Head.TradeKind = ItemConst.TRAN_KIND.NORMAL.SALE; + + if (_basketItems is List && _basketItems.Count > 0) + { + foreach (var basketItem in _basketItems) + { + result = SetItem(basketItem); + if (!result) break; + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ResetItems()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = false; + } + return result; + } + + public bool IsExistITEM_PLU_CD(string _pluCD) + { + bool result = false; + try + { + var saleItems = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM); + foreach (var aSaleItem in saleItems) + { + if (aSaleItem is Column.TR_PLU.DATA aItem) + { + if (aItem.ITEM_PLU_CD.Equals(_pluCD)) + { + result = true; + break; + } + } + } + } + catch (Exception) + { + result = false; + } + return result; + } + + /// + /// 2019-04-10 - 1997fx11 : 장바구니 아이템 추가또는 업데이트 + /// (존재하는 아이템은 업데이트 그외는 추가처리) + /// + /// + /// + public bool SetItem(M_BasketItem _basketItem) + { + if (NeedInitModule) return false; + bool result = false; + try + { + //Set Item Process + string sRet = UserCom.RST_OK; + string sSubStoreNo = "", sItemCode = "", sScanCode = ""; // 점포코드, 상품코드, 스켄코드 + string sInPutTypeCode = "", sSelRow = "", sInPutData = ""; // (0:수입력, 1:메뉴, 2:스켄, 3:플레이버) + (메뉴코드,스캔코드), 선택행, 입력데이터 + + ISalePluItemUs cPluService = (ISalePluItemUs)sManager.InitServiceInstance(ServiceLists.BSV_SALE.DLL, ServiceLists.BSV_SALE.SALE_PLU_ITEM); + sSubStoreNo = m_cPosStatus.Base.StoreNo; // 점포코드 + sItemCode = _basketItem.ItemCode; // 상품코드 + + + sInPutTypeCode = "1" + sSubStoreNo.PadLeft(7, '0') + sItemCode.PadLeft(9, ' '); + //sInPutTypeCode = sSubStoreNo.PadLeft(7, '0') + sItemCode.PadLeft(9, ' '); + + if (_basketItem.Option == null) + { + //sRet = cPluService.SetItemCode(sSelRow, sInPutTypeCode, _basketItem.Count.ToString()); + result = m_cSaleMainProc.ExecuteSaleMainProcess(PosKey.MENU_KEY.REGISTER_PLU_ITEM + , _basketItem.Count.ToString() + , sSelRow + , PosConst.SALE_PLU_INPUT_TYPE.MENUKEY + sInPutTypeCode.Substring(1)); + } + else + { + string sTakeInOut = "1001"; // 기본값 : Take Out. + string sUpCharge = "1004"; // 기본값 : 샷추가안함. + + //foreach (var option in _basketItem.Option) + //{ + // foreach (var opt in option.Options) + // { + // if (opt.IsSelected) + // { + // if (opt.Kind == OptionKind.Button) { sTakeInOut = opt.Code; } + // else if (opt.Kind == OptionKind.UpCharge) { sUpCharge = opt.Code; } + // } + // } + //} + + //sRet = cPluService.SetItemCode(sSelRow, sInPutTypeCode, _basketItem.Count.ToString()); + result = m_cSaleMainProc.ExecuteSaleMainProcess(PosKey.MENU_KEY.REGISTER_PLU_ITEM + , _basketItem.Count.ToString() + , sSelRow + , PosConst.SALE_PLU_INPUT_TYPE.MENUKEY + sInPutTypeCode.Substring(1)); + + foreach (var option in _basketItem.Option) + { + foreach (var opt in option.Options) + { + if (opt.IsSelected) + { + ArrayList aSaleItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM); + Column.TR_PLU.DATA cPluItem = new Column.TR_PLU.DATA(); + DataTable dtDataInfo = new DataTable(); + DataRow drPlu; + sRet = UserCom.RST_OK; + + var findIndex = aSaleItem.Count - 1; + for (var i = aSaleItem.Count - 1; i > -1; i--) + { + if (((Column.TR_PLU.DATA)aSaleItem[i]).ITEM_PLU_CD.Equals(_basketItem.ItemCode)) + { + findIndex = i; + break; + } + } + + switch (opt.Kind) + { + case OptionKind.Button: + + + + dtDataInfo = m_cDataCommon.SearchNHSOption(sSubStoreNo, opt.Code); + drPlu = dtDataInfo.Rows[0]; + + cPluItem = new Column.TR_PLU.DATA(); + cPluItem.SUB_SHOP_CD = sSubStoreNo; + cPluItem.ITEM_PLU_CD = opt.Code; + cPluItem.ITEM_DIV = ItemConst.PLU_ITEM_DIV.OPT_MENU; + cPluItem.SALE_QTY = _basketItem.Count; + cPluItem.ITEM_NAME = ">>" + CmUtil.GetDataRowStr(drPlu, PosMst.NHS_OPTN_MST.DATA.ITEM_OPTN_NM); ; + cPluItem.SUBPRC_MENU_KEY_DIV = "1"; // 부가메뉴구분(1:속성,2:업차지,3:선택메뉴) + cPluItem.NONSALES_RSN_CD = "0"; + cPluItem.NONSALES_RSN_NM = ""; + cPluItem.SUB_MENU_MAIN_CD = sItemCode; + + aSaleItem.Add(cPluItem); // 등록 처리 + + + break; + case OptionKind.Count: + dtDataInfo = m_cDataCommon.SearchNHSOption(sSubStoreNo, opt.Code); + drPlu = dtDataInfo.Rows[0]; + + cPluItem = new Column.TR_PLU.DATA(); + cPluItem.SUB_SHOP_CD = sSubStoreNo; + cPluItem.ITEM_PLU_CD = opt.Code; // sItemCode; + cPluItem.ITEM_DIV = ItemConst.PLU_ITEM_DIV.OPT_MENU; + cPluItem.SALE_QTY = (long)opt.SelectValue; + cPluItem.ITEM_NAME = ">>" + CmUtil.GetDataRowStr(drPlu, PosMst.NHS_OPTN_MST.DATA.ITEM_OPTN_NM); + cPluItem.SUBPRC_MENU_KEY_DIV = "1"; // 부가메뉴구분(1:속성,2:업차지,3:선택메뉴) + cPluItem.NONSALES_RSN_CD = "0"; + cPluItem.NONSALES_RSN_NM = ""; + cPluItem.SUB_MENU_MAIN_CD = sItemCode; + + aSaleItem.Add(cPluItem); // 등록 처리 + break; + case OptionKind.Discount: + ((Column.TR_PLU.DATA)aSaleItem[findIndex]).EXCEP_DC_AMT = ((opt.SelectValue < 0 ? (opt.SelectValue * (-1)) : opt.SelectValue) * _basketItem.Count); + ((Column.TR_PLU.DATA)aSaleItem[findIndex]).EXCEP_DC_DIV = ((opt.SelectValue * (-1)) > 0 ? ItemConst.PLU_DC_DIV.ELOVE_DC : "0000"); + break; + case OptionKind.UpCharge: + dtDataInfo = m_cDataCommon.SearchNHSOption(sSubStoreNo, opt.Code); + drPlu = dtDataInfo.Rows[0]; + + cPluItem = new Column.TR_PLU.DATA(); + cPluItem.SUB_SHOP_CD = sSubStoreNo; + cPluItem.ITEM_PLU_CD = opt.KindCode; + cPluItem.ITEM_DIV = ItemConst.PLU_ITEM_DIV.OPT_MENU; + + cPluItem.SALE_QTY = _basketItem.Count; + cPluItem.ITEM_NAME = ">>" + CmUtil.GetDataRowStr(drPlu, PosMst.NHS_OPTN_MST.DATA.ITEM_OPTN_NM); + cPluItem.SUBPRC_MENU_KEY_DIV = "2"; // 부가메뉴구분(1:속성,2:업차지,3:선택메뉴) + cPluItem.NONSALES_RSN_CD = "0"; + cPluItem.NONSALES_RSN_NM = ""; + cPluItem.SUB_MENU_MAIN_CD = sItemCode; + + + cPluItem.SALE_PRC = CmUtil.DoubleParse(CmUtil.GetDataRowStr(drPlu, PosMst.NHS_OPTN_MST.DATA.AMT)); + + aSaleItem.Add(cPluItem); // 등록 처리 + break; + } + + + + + + //switch (opt.Kind) + //{ + // case OptionKind.Button: + // if (opt.Code.Equals("1001") || opt.Code.Equals("1002")) + // { + // dtDataInfo = m_cDataCommon.SearchNHSOption(sSubStoreNo, opt.Code); + // drPlu = dtDataInfo.Rows[0]; + + + // if (opt.Code.Equals("1001")) { ((Column.TR_PLU.DATA)aSaleItem[findIndex]).TAKE_IN_OUT_DIV = PosConst.TAKE_IN_OUT_DIV.TAKE_OUT; } + // else if (opt.Code.Equals("1002")) { ((Column.TR_PLU.DATA)aSaleItem[findIndex]).TAKE_IN_OUT_DIV = PosConst.TAKE_IN_OUT_DIV.TAKE_IN; } + + // cPluItem = new Column.TR_PLU.DATA(); + // cPluItem.SUB_SHOP_CD = sSubStoreNo; + // cPluItem.ITEM_PLU_CD = opt.Code; + // cPluItem.ITEM_DIV = ItemConst.PLU_ITEM_DIV.OPT_MENU; + // cPluItem.SALE_QTY = _basketItem.Count; + // cPluItem.ITEM_NAME = ">>" + CmUtil.GetDataRowStr(drPlu, PosMst.NHS_OPTN_MST.DATA.ITEM_OPTN_NM); ; + // cPluItem.SUBPRC_MENU_KEY_DIV = "1"; // 부가메뉴구분(1:속성,2:업차지,3:선택메뉴) + // cPluItem.NONSALES_RSN_CD = "0"; + // cPluItem.NONSALES_RSN_NM = ""; + // cPluItem.SUB_MENU_MAIN_CD = sItemCode; + // //cPluItem.PROD_TAKEINOUT_DIV = dgvPluItem.Rows[iRow].Cells[6].Value.ToString(); + + // aSaleItem.Add(cPluItem); // 등록 처리 + // } + + // break; + // case OptionKind.Discount: + // ((Column.TR_PLU.DATA)aSaleItem[findIndex]).EXCEP_DC_AMT = ((opt.SelectValue < 0 ? (opt.SelectValue * (-1)) : opt.SelectValue) * _basketItem.Count); + // ((Column.TR_PLU.DATA)aSaleItem[findIndex]).EXCEP_DC_DIV = ((opt.SelectValue * (-1)) > 0 ? ItemConst.PLU_DC_DIV.ELOVE_DC : "0000"); + // break; + // case OptionKind.UpCharge: + // dtDataInfo = m_cDataCommon.SearchItemCode(sSubStoreNo, opt.KindCode, sScanCode); + // drPlu = dtDataInfo.Rows[0]; + + // cPluItem = new Column.TR_PLU.DATA(); + // cPluItem.SUB_SHOP_CD = sSubStoreNo; + // cPluItem.ITEM_PLU_CD = opt.KindCode; + // cPluItem.ITEM_DIV = ItemConst.PLU_ITEM_DIV.OPT_MENU; + // if (sTakeInOut.Equals("1001")) + // { + // cPluItem.SALE_PRC = CmUtil.DoubleParse(CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.TAKE_OUT_SALE_AMT)); + // } + // else + // { + // cPluItem.SALE_PRC = CmUtil.DoubleParse(CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.TAKE_IN_SALE_AMT)); + // } + // cPluItem.SALE_QTY = _basketItem.Count; + // cPluItem.ITEM_NAME = ">>" + CmUtil.GetDataRowStr(drPlu, PosMst.MST_ITEM.DATA.ITEM_NM); + // cPluItem.SUBPRC_MENU_KEY_DIV = "2"; // 부가메뉴구분(1:속성,2:업차지,3:선택메뉴) + // cPluItem.NONSALES_RSN_CD = "0"; + // cPluItem.NONSALES_RSN_NM = ""; + // cPluItem.SUB_MENU_MAIN_CD = sItemCode; + // //cPluItem.PROD_TAKEINOUT_DIV = dgvPluItem.Rows[iRow].Cells[6].Value.ToString(); + + // aSaleItem.Add(cPluItem); // 등록 처리 + + // break; + // case OptionKind.Count: + // if (opt.Code.Equals("1006") || opt.Code.Equals("1007")) + // { + // dtDataInfo = m_cDataCommon.SearchNHSOption(sSubStoreNo, opt.Code); + // drPlu = dtDataInfo.Rows[0]; + + // cPluItem = new Column.TR_PLU.DATA(); + // cPluItem.SUB_SHOP_CD = sSubStoreNo; + // cPluItem.ITEM_PLU_CD = opt.Code; // sItemCode; + // cPluItem.ITEM_DIV = ItemConst.PLU_ITEM_DIV.OPT_MENU; + // cPluItem.SALE_QTY = (long)opt.SelectValue; + // cPluItem.ITEM_NAME = ">>" + CmUtil.GetDataRowStr(drPlu, PosMst.NHS_OPTN_MST.DATA.ITEM_OPTN_NM); + // cPluItem.SUBPRC_MENU_KEY_DIV = "1"; // 부가메뉴구분(1:속성,2:업차지,3:선택메뉴) + // cPluItem.NONSALES_RSN_CD = "0"; + // cPluItem.NONSALES_RSN_NM = ""; + // cPluItem.SUB_MENU_MAIN_CD = sItemCode; + // //cPluItem.PROD_TAKEINOUT_DIV = dgvPluItem.Rows[iRow].Cells[6].Value.ToString(); + + // aSaleItem.Add(cPluItem); // 등록 처리 + // } + + // break; + // default: + // break; + //} + + if (sRet != UserCom.RST_OK) { break; } + } + + if (sRet != UserCom.RST_OK) { break; } + } + } + } + + //if (sRet == UserCom.RST_OK) { result = true; } + //else { result = false; } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "SetItem()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = false; + } + return result; + } + + + /// + /// 장바구니 아이템 삭제 또는 업데이트 + /// (수량이 동일 하면 삭제 다르면 업데이트 필요) + /// + /// + /// + public bool DelItem(M_BasketItem _basketItem) + { + bool result = false; + try + { + //TODO : Delete Item Process + //result = m_cSaleMainProc.CancelPluItem(_basketItem.p_Index.ToString()); + + m_cSaleMainProc.CancelPluItem("0"); + result = true; + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "DelItem()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = false; + } + return result; + } + + + /// + /// 장바구니옵션 변경 + /// (수량이 동일 하면 삭제 다르면 업데이트 필요) + /// + /// + /// + public bool UpdatedItem(M_BasketItem _basketItem) + { + bool result = false; + try + { + //TODO : Delete Item Process + result = true; + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "DelItem()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = false; + } + return result; + } + #endregion Methods + + + public ObservableCollection AddItemToBasket(ObservableCollection _targetBasket + , int _itemCount + , double _unitPrice + , string _designImagesPath + , M_ItemData _itemData + , List _option + , BasketItemType _basketItemType = BasketItemType.Order) + { + ObservableCollection result = null; + try + { + var optionLabel = CommonFunction.GetOptionLabel(_option); + var findSameData = _targetBasket is ObservableCollection + ? _targetBasket.Where(r => r.ItemCode.Equals(_itemData.ItemCode) + && r.AllOptionLabel.GetLanguageData(SupportLanguageType.ko).Replace("[행사]", "").Equals(optionLabel.GetLanguageData(SupportLanguageType.ko))).FirstOrDefault() + + : null; + var itemIndex = 0; + if (findSameData is M_BasketItem findedItem) + { + itemIndex = findSameData.p_Index; + findedItem.Count += _itemCount; + //SetItem(findedItem); + //수량 증가 + //m_cSaleMainProc.ExecuteSaleMainProcess(PosKey.MENU_KEY.QTY_PLUS, "", itemIndex.ToString(), ""); + } + else + { + var newBasketData = _targetBasket is ObservableCollection + ? _targetBasket.ToList() + : new List(); + //foreach (var aitem in newBasketData) + //{ + // aitem.Index += 1; + //} + //var pIdx = 0; + //if (newBasketData.Count != 0) pIdx++; + itemIndex = newBasketData.Count.Equals(0) + ? 0 + : newBasketData.Max(r => r.p_Index) + 1; + + + + var newBasketItem = new M_BasketItem + { + Index = 0, + p_Index = itemIndex, + ItemType = _basketItemType, + ItemCode = _itemData.ItemCode, + ItemImage = _itemData.DataParameter.NormalBrush, + ItemName = _itemData.BaseTextBlock.LanguageData, + AllOptionLabel = optionLabel, + Option = _option, + Count = _itemCount, + BasePrice = _itemData.Price, + Price = _unitPrice, + ItemCountLabel = new List + { + new M_Language {Type=SupportLanguageType.ko,LanguageData=@"개"}, + new M_Language {Type=SupportLanguageType.en,LanguageData=@"EA"} + }, + ItemPriceLabel = new List + { + new M_Language {Type=SupportLanguageType.ko,LanguageData=@"\"} + }, + MinusNormalBrush = ResourceManager.GetNximagePathAdd("btn_count_minus_n.png", _designImagesPath), + MinusDownBrush = ResourceManager.GetNximagePathAdd("btn_count_minus_p.png", _designImagesPath), + PlusNormalBrush = ResourceManager.GetNximagePathAdd("btn_count_plus_n.png", _designImagesPath), + PlusDownBrush = ResourceManager.GetNximagePathAdd("btn_count_plus_p.png", _designImagesPath) + + }; + + //SetItem(newBasketItem); + //var saleItems = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM); + + //foreach(var aItems in saleItems) + //{ + // if(((Column.TR_PLU.DATA)aItems).CPI_DC_AMT > 0) + // { + // newBasketItem.Price = newBasketItem.Price - ((Column.TR_PLU.DATA)aItems).CPI_DC_AMT; + // } + //} + + //상품등록 처리(POS) + m_cPosStatus.Sale.SaleFlow = PosConst.SALE_FLOW.SALE_WAIT; //판매대기 + ISalePluItemUs cPluService = (ISalePluItemUs)sManager.InitServiceInstance(ServiceLists.BSV_SALE.DLL, ServiceLists.BSV_SALE.SALE_PLU_ITEM); + var sSubStoreNo = m_cPosStatus.Base.StoreNo; // 점포코드 + var sItemCode = newBasketItem.ItemCode; // 상품코드 + var sMenuCode = "1" + sSubStoreNo.PadLeft(7, '0') + sItemCode.PadLeft(9, ' '); + //bool bRet = m_cSaleMainProc.ExecuteSaleMainProcess(PosKey.MENU_KEY.REGISTER_PLU_ITEM, sInPutValue, "", PosConst.SALE_PLU_INPUT_TYPE.MENUKEY + sMenuCode.Substring(1)); + bool bRet = m_cSaleMainProc.ExecuteSaleMainProcess(PosKey.MENU_KEY.REGISTER_PLU_ITEM, "", itemIndex.ToString(), PosConst.SALE_PLU_INPUT_TYPE.MENUKEY + sMenuCode.Substring(1)); + + + + + + + //var nStat = cPluService.SetItemCode(itemIndex.ToString(), PosConst.SALE_PLU_INPUT_TYPE.MENUKEY, m_cPosStatus.Base.StoreNo, newBasketItem.ItemCode, "", newBasketItem.Count.ToString()); + if (bRet) + { + itemIndex = 0; + var saleItems = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM); + if (((Column.TR_PLU.DATA)saleItems[itemIndex]).CPI_DC_AMT > 0) + { + newBasketItem.CampaignPrice = ((Column.TR_PLU.DATA)saleItems[itemIndex]).CPI_DC_AMT; + newBasketItem.Price = _itemData.Price - newBasketItem.CampaignPrice; + var addOptionLabel = new List + { + new M_Language {Type=SupportLanguageType.ko,LanguageData=@"[행사]"}, + new M_Language {Type=SupportLanguageType.en,LanguageData=@"[EVENT]"} + }; + + newBasketItem.AllOptionLabel = optionLabel is List + ? Languages.CombineLanguageData(addOptionLabel, optionLabel) + : addOptionLabel; + } + + newBasketData.Insert(0, newBasketItem); + + DelItem(newBasketItem); + } + else + { + CommonLog.ErrorLogWrite(this, "AddItemToBasket()", "Fail !!", string.Format("\nItemCode={0}", newBasketItem.ItemCode)); + } + //if (bRet == true) + // newBasketData.Insert(0, newBasketItem); + + + + result = new ObservableCollection(newBasketData); + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "AddItemToBasket()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + + /// + /// 바코드 데이터 초기화 + /// + public void LastBarcodeDelete() + { + m_cPosStatus.Base.LastRcptBarcodeData = string.Empty; + } + + } +} \ No newline at end of file diff --git a/Kiosk/Common/SPC.Kiosk.DataHelper/Properties/AssemblyInfo.cs b/Kiosk/Common/SPC.Kiosk.DataHelper/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..fa5e4a3 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.DataHelper/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("SPC.Kiosk.DataHelper")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("SPC.Kiosk.DataHelper")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("fee44681-7f0e-469a-a833-dc324eb6d01a")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 +// 기본값으로 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Kiosk/Common/SPC.Kiosk.DataHelper/SPC.Kiosk.DataHelper.csproj b/Kiosk/Common/SPC.Kiosk.DataHelper/SPC.Kiosk.DataHelper.csproj new file mode 100644 index 0000000..854e8d0 --- /dev/null +++ b/Kiosk/Common/SPC.Kiosk.DataHelper/SPC.Kiosk.DataHelper.csproj @@ -0,0 +1,92 @@ + + + + + Debug + AnyCPU + {FEE44681-7F0E-469A-A833-DC324EB6D01A} + Library + Properties + SPC.Kiosk.DataHelper + SPC.Kiosk.DataHelper + v4.0 + 512 + true + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + False + ..\..\BIN\Cosmos.BaseFrame.dll + + + False + ..\..\BIN\Cosmos.Common.dll + + + False + ..\..\BIN\Cosmos.CommonManager.dll + + + False + ..\..\BIN\Cosmos.ServiceProvider.dll + + + False + ..\..\BIN\Cosmos.UserFrame.dll + + + + + + + + + + False + ..\..\..\..\BIN\Win.Sale.dll + + + + + + + + + + + {ba2d06e0-74c0-4785-b39f-d1eaac13b73d} + SPC.Kiosk.Common + + + {90ebd618-0409-458d-9829-a012223e8671} + SPC.Kiosk.PB.Model + + + {e139e39d-0047-45c6-a72d-dade3e929060} + AsvDataProcess + + + + \ No newline at end of file diff --git a/Kiosk/PB/SPC.Kiosk.PB.Model/PBModels.cs b/Kiosk/PB/SPC.Kiosk.PB.Model/PBModels.cs new file mode 100644 index 0000000..9112add --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB.Model/PBModels.cs @@ -0,0 +1,69 @@ +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +namespace SPC.Kiosk.PB.Model +{ + /// + /// Category Data + /// + public class M_CategoryItems + { + /// + /// a Root Catalog + /// + public M_ItemData Catalog1Item { get; set; } = new M_ItemData(); + /// + /// Sub Catalog Datas + /// + public List Catalog2Items { get; set; } = new List(); + } + /// + /// DiscountData + /// + public class M_DiscountAndAddValues + { + /// + /// Discount Type + /// + public PaymentsDiscountAndAddType DiscountType { get; set; } = PaymentsDiscountAndAddType.None; + /// + /// Diacount Name Text + /// + public List DiscountName { get; set; } + /// + /// Discount Value + /// + public double DiscountValue { get; set; } = 0d; + /// + /// Gift Item Code + /// + public string AddItemCode { get; set; } = string.Empty; + /// + /// Gift Item Count + /// + public int AddCount { get; set; } = 0; + /// + /// Gift Item Unit Price + /// + public double AddValue { get; set; } = 0d; + /// + /// Is Can Roll Back + /// + public bool IsCanRollBack { get; set; } + } + /// + /// Barcode Scan Or AIaScan Data + /// + public class M_ScanData + { + public string ItemCode { get; set; } + public string Barcord { get; set; } + public BasketItemType ItemType { get; set; } = BasketItemType.None; + } +} + + + diff --git a/Kiosk/PB/SPC.Kiosk.PB.Model/Properties/AssemblyInfo.cs b/Kiosk/PB/SPC.Kiosk.PB.Model/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..46cf2b4 --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB.Model/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("SPC.Kiosk.PB.Model")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Zin")] +[assembly: AssemblyProduct("SPC.Kiosk.PB.Model")] +[assembly: AssemblyCopyright("Copyright © Zin. 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("39558cc0-898a-41e5-b140-ea2b36018121")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 +// 기본값으로 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Kiosk/PB/SPC.Kiosk.PB.Model/SPC.Kiosk.PB.Model.csproj b/Kiosk/PB/SPC.Kiosk.PB.Model/SPC.Kiosk.PB.Model.csproj new file mode 100644 index 0000000..23e6fe9 --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB.Model/SPC.Kiosk.PB.Model.csproj @@ -0,0 +1,63 @@ + + + + + Debug + AnyCPU + {90EBD618-0409-458D-9829-A012223E8671} + Library + Properties + SPC.Kiosk.PB.Model + SPC.Kiosk.PB.Model + v4.0 + 512 + true + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + ..\..\..\..\BIN\ + TRACE + prompt + 4 + x86 + + + + + + + + + + + + + + + + + {bcc10fa2-c358-480c-8ff0-615750f3c306} + SPC.Kiosk.Base + + + {ba2d06e0-74c0-4785-b39f-d1eaac13b73d} + SPC.Kiosk.Common + + + + \ No newline at end of file diff --git a/Kiosk/PB/SPC.Kiosk.PB.Model/Types.cs b/Kiosk/PB/SPC.Kiosk.PB.Model/Types.cs new file mode 100644 index 0000000..c95bd16 --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB.Model/Types.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace SPC.Kiosk.PB.Model +{ + /// + /// PB Sensing Sub Page + /// + public enum PBSensingSubPageType + { + /// + /// Sensing Page + /// + SensingPage, + /// + /// Sensing Sub Page + /// + BarcordPage, + } + /// + /// PB Page Types + /// + public enum PBPageType + { + /// + /// Intro + /// + Intro, + /// + /// 객체인식,일반주문 선택화면 + /// + FirstSelect, + /// + /// 객체인식 + /// + Sensing, + /// + /// 일반주문 + /// + Items + } + public enum SensingPageType + { + /// + /// 카메라 스캔 안내 페이지 + /// + Infomation, + /// + /// 카메라 스캔중 및 종료후 표시 페이지 + /// + SensingMain, + /// + /// 바코드 리딩으로 제품 추가 하는 페이지 + /// + BarcodeRead + } + /// + /// PB Payments Page Type + /// + public enum PBPaymentPageType + { + /// + /// Parking Page + /// + None, + /// + /// 주문 내역 상세 + /// + DetailBasket, + //PaymentsSelect, + /// + /// 포인트 적립/통신사 할인 + /// + PointsDisCounts, + /// + /// 포인트 사용/ 쿠폰 사용 + /// + CouponUsePoints, + /// + /// 포인트 사용 더보기 + /// + MoreVIewPoints, + /// + /// 포인트 사용 더보기 뒤로가기 + /// + MoreVIewReturnPoints, + /// + /// 최종 결제 + /// + PaymentExcute, + } + /// + /// Payment Discount And And Add Type + /// + public enum PaymentsDiscountAndAddType + { + /// + /// None + /// + None, + /// + /// 사은품 + /// + BonusGift, + /// + /// SK 할인 + /// + SkTelecomDiscount, + /// + /// KT 할인 + /// + AllehKTDiscount, + /// + /// LGU+ 할인 + /// + LGUPlusDisCount, + /// + /// Happy Point + /// + HappyPoint, + /// + /// Ok Cash Bag Point + /// + OkCashBagPoint, + /// + /// Happy Coupon + /// + HappyCoupon, + /// + /// Mobile Coupon + /// + MobileCoupon, + /// + /// Lasy Payment + /// + LastPayment + } +} \ No newline at end of file diff --git a/Kiosk/PB/SPC.Kiosk.PB.ViewModel/PBPaymentsViewModel.cs b/Kiosk/PB/SPC.Kiosk.PB.ViewModel/PBPaymentsViewModel.cs new file mode 100644 index 0000000..74428f6 --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB.ViewModel/PBPaymentsViewModel.cs @@ -0,0 +1,3035 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.IO; +using System.ComponentModel; +using System.Windows.Input; +using System.Windows.Media.Animation; +using System.Windows; +using System.Collections.ObjectModel; +//using System.Windows.Forms; +using System.Text.RegularExpressions; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Threading; +#region SPC.Kiosk +using SPC.Kiosk.Common; +using SPC.Kiosk.Base; +using SPC.Kiosk.PB.Model; +using SPC.Kiosk.Popup; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; +using SPC.Kiosk.Payments; +using SPC.Kiosk.DataHelper; +#endregion + +namespace SPC.Kiosk.PB.ViewModel +{ + /// + /// PBPaymentsWindow View Model + /// + public class PBPaymentsViewModel : PopupViewModelBase + { + #region [ Members ] + private PosDataService posDataService = null; + public bool FirstLoaded { get; set; } = true; + private PopupManager popupManager = PopupManager.GetInstance; + + /// + /// Wait Wiondow + /// + public WaitWindow WaitWindowFrom { get; set; } + private PBPaymentPageType defaultPage = PBPaymentPageType.DetailBasket; + + private NhsFuncInfoItem nhsFuncInfo; + /// + /// NHS Func Info + /// + public NhsFuncInfoItem NhsFuncInfo + { + get { return nhsFuncInfo; } + set { nhsFuncInfo = value; PropertyChange("NhsFuncInfo"); } + } + + /// + /// Default Page + /// + public PBPaymentPageType DefaultPage + { + get { return defaultPage; } + set { defaultPage = value; PropertyChange("DefaultPage"); } + } + + private string optionValue802; + /// + /// 진동벨 사용유무 + /// + public string OptionValue802 + { + get { return optionValue802; } + set { optionValue802 = value; PropertyChange("OptionValue802"); } + } + private string optionValue803; + /// + /// 알림톡 사용유무 + /// + public string OptionValue803 + { + get { return optionValue803; } + set { optionValue803 = value; PropertyChange("OptionValue803"); } + } + private string optionValue804; + /// + /// 대기번호 사용유무 + /// + public string OptionValue804 + { + get { return optionValue804; } + set { optionValue804 = value; PropertyChange("OptionValue804"); } + } + + #region BaseValue + private ObservableCollection detailBasketData; + /// + /// Detail Basket Data + /// + public ObservableCollection DetailBasketData + { + get { return detailBasketData; } + set + { + + if (detailBasketData is ObservableCollection + && detailBasketData.Count > 0) + { + foreach (var DetailItem in detailBasketData) + { + DetailItem.PropertyChanged -= DetailItem_PropertyChanged; + } + } + detailBasketData = value; + PropertyChange("DetailBasketData"); + } + } + private ObservableCollection discountValues; + /// + /// 할인 금액,결제 금액,사은품 + /// + public ObservableCollection DiscountValues + { + get { return discountValues; } + set { discountValues = value; PropertyChange("DiscountValues"); } + } + + + private ObservableCollection scanBarcodeBasketData; + /// + /// ScanBarcode Detail Basket Data + /// + public ObservableCollection ScanBarcodeBasketData + { + get { return scanBarcodeBasketData; } + set + { + scanBarcodeBasketData = value; PropertyChange("ScanBarcodeBasketData"); + } + } + private ObservableCollection orderBasketData; + /// + /// Order Detail Basket Data + /// + public ObservableCollection OrderBasketData + { + get { return orderBasketData; } + set + { + orderBasketData = value; PropertyChange("OrderBasketData"); + } + } + private M_HappyPointReturn happyPointReturn; + /// + /// HappyPoint Data + /// + public M_HappyPointReturn HappyPointReturn + { + get { return happyPointReturn; } + set { happyPointReturn = value; PropertyChange("HappyPointReturn"); } + } + private M_OkCashBagReturn okCashBagReturn; + /// + /// Ok CashBag Data + /// + public M_OkCashBagReturn OkCashBagReturn + { + get { return okCashBagReturn; } + set { okCashBagReturn = value; PropertyChange("OkCashBagReturn"); } + } + private M_MobileCompanyReturn mobileCompanyReturn; + /// + /// MobileCompany Discount Data + /// + public M_MobileCompanyReturn MobileCompanyReturn + { + get { return mobileCompanyReturn; } + set { mobileCompanyReturn = value; PropertyChange("MobileCompanyReturn"); } + } + + private M_PaymentReturn paymentReturn; + /// + /// Payments Return + /// + public M_PaymentReturn PaymentReturn + { + get { return paymentReturn; } + set { paymentReturn = value; PropertyChange("PaymentReturn"); } + } + /// + /// Payments End Return + /// + private M_PaymentEndReturn paymentEndReturn; + /// + /// Payments Return + /// + public M_PaymentEndReturn PaymentEndReturn + { + get { return paymentEndReturn; } + set { paymentEndReturn = value; PropertyChange("PaymentEndReturn"); } + } + private M_MobileCouponReturn mobileCouponReturn; + /// + /// Mobile Coupon Return + /// + public M_MobileCouponReturn MobileCouponReturn + { + get { return mobileCouponReturn; } + set { mobileCouponReturn = value; PropertyChange("MobileCouponReturn"); } + } + private M_HappyCoupon usingHappyAppCoupon; + /// + /// Used Happy Coupon + /// + public M_HappyCoupon UsingHappyAppCoupon + { + get { return usingHappyAppCoupon; } + set { usingHappyAppCoupon = value; PropertyChange("UsingHappyAppCoupon"); } + } + #endregion + + #region GMB + + #region GMB Left + /// + /// Gmb Logo + /// + public string GmbLogo { get; set; } = ResourceManager.GetNximagePathAdd("Img_main_logo.png", CommonValue.PBdesignImagesPath); + #endregion + + #region GMB Center + private List gMBHeaderText; + /// + /// Top Header Text + /// + public List GMBHeaderText + { + get { return gMBHeaderText; } + set { gMBHeaderText = value; PropertyChange("GMBHeaderText"); } + } + + private string gmbMemberName; + /// + /// Gmb Member Name + /// /// + public string GmbMemberName + { + get { return gmbMemberName; } + set { gmbMemberName = value; PropertyChange("GmbMemberName"); } + } + + private bool memberLoginOK = false; + /// + /// Member Login OK + /// + public bool MemberLoginOK + { + get { return memberLoginOK; } + set { memberLoginOK = value; PropertyChange("MemberLoginOK"); } + } + + #endregion + + #region GMB Right + /// + /// GMB HappyPoint image + /// + public string GmbHappyPointimage { get; set; } = ResourceManager.GetNximagePathAdd("btn_happypoint_d.png", CommonValue.PBdesignImagesPath); + /// + /// GMB HappyPoint Disable Image + /// + public string GmbHappyPointDisable { get; set; } = ResourceManager.GetNximagePathAdd("btn_happypoint_n.png", CommonValue.PBdesignImagesPath); + /// + /// GMB Call Employee Image + /// + public string GmbCallimage { get; set; } = ResourceManager.GetNximagePathAdd("btn_help.png", CommonValue.PBdesignImagesPath); + /// + /// GMB Goto Home Image + /// + public string GmbHomeimage { get; set; } = ResourceManager.GetNximagePathAdd("btn_reset.png", CommonValue.PBdesignImagesPath); + private string gmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_kor.png", CommonValue.PBdesignImagesPath); + /// + /// GMB Language Image + /// + public string GmbLanguageimage + { + get { return gmbLanguageimage; } + set { gmbLanguageimage = value; PropertyChange("GmbLanguageimage"); } + } + private bool gmbHome = true; + /// + /// GMB Goto Home Enabled + /// GMB Language + /// + public bool GmbHome + { + get { return gmbHome; } + set { gmbHome = value; PropertyChange("GmbHome"); } + } + private bool gmbHappyPointEnable = true; + /// + /// Gmb Happy Point Button Enable + /// + public bool GmbHappyPointEnable + { + get { return gmbHappyPointEnable; } + set { gmbHappyPointEnable = value; PropertyChange("GmbHappyPointEnable"); } + } + private bool gmbEmpCall = true; + /// + /// GMB Call Employee Enabled + /// + public bool GmbEmpCall + { + get { return gmbEmpCall; } + set { gmbEmpCall = value; PropertyChange("GmbEmpCall"); } + } + private bool gmbLanguage = true; + /// + /// GMB Language Enabled + /// + public bool GmbLanguage + { + get { return gmbLanguage; } + set { gmbLanguage = value; PropertyChange("GmbLanguage"); } + } + /// + /// GMB Call Employee Command + /// + public ICommand CallEmployeeCommand { get; protected set; } = null; + /// + /// GMB Language Command + /// + public ICommand LanguageCommand { get; protected set; } = null; + /// + /// GMB Goto Intro Page Commad + /// + public ICommand GotoIntroPageCommad { get; protected set; } = null; + + #endregion + + #endregion + + #region Contents + /// + /// Info Logo + /// + public string InfoLogo { get; set; } = ResourceManager.GetNximagePathAdd("ic_info.png", CommonValue.PBdesignImagesPath); + /// + /// Info x mark Logo + /// + public string InfoLogoX { get; set; } = ResourceManager.GetNximagePathAdd("ic_info_x.png", CommonValue.PBdesignImagesPath); + /// + /// Step Buttons Background + /// + public string ButtonBackground { get; set; } = ResourceManager.GetNximagePathAdd("step_bg.png", CommonValue.PBdesignImagesPath); + /// + /// Step1 Selected Brush + /// + public string Step1DisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("step01.png", CommonValue.PBdesignImagesPath); + /// + /// Step2 Selected Brush + /// + public string Step2DisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("step02.png", CommonValue.PBdesignImagesPath); + /// + /// Step3 Selected Brush + /// + public string Step3DisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("step03.png", CommonValue.PBdesignImagesPath); + /// + /// Basket All Delete Brush + /// + public string BasketDeleteBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_basket_delete.png", CommonValue.PBdesignImagesPath); + /// + /// Basket EMpty Brush + /// + public string BasketNoneBrush { get; set; } = ResourceManager.GetNximagePathAdd("bg_basket_none.png", CommonValue.PBdesignImagesPath); + private bool gotoPointsDisCountsEnable = true; + /// + /// Goto Point & Discount Enabled + /// + public bool GotoPointsDisCountsEnable + { + get { return gotoPointsDisCountsEnable; } + set { gotoPointsDisCountsEnable = value; PropertyChange("GotoPointsDisCountsEnable"); } + } + /// + /// Goto Point & Discount Command + /// + public ICommand GotoPointsDisCountsCommand { get; protected set; } = null; + private bool gotoCouponUsePointsEnable = true; + /// + /// Goto Coupon & Using Points Enabled + /// + public bool GotoCouponUsePointsEnable + { + get { return gotoCouponUsePointsEnable; } + set { gotoCouponUsePointsEnable = value; PropertyChange("GotoCouponUsePointsEnable"); } + } + /// + /// Goto Coupon & Using Points Command + /// + public ICommand GotoCouponUsePointsCommand { get; protected set; } = null; + private bool gotoPaymentExcuteEnable = true; + /// + /// Goto Payment Execute Enabled + /// + public bool GotoPaymentExcuteEnable + { + get { return gotoPaymentExcuteEnable; } + set { gotoPaymentExcuteEnable = value; PropertyChange("GotoPaymentExcuteEnable"); } + } + /// + /// Goto Payment Execute Command + /// + public ICommand GotoPaymentExcuteCommand { get; protected set; } = null; + + #region Detail Basket + /// + /// Page to Left Normal Image + /// + public string Page2LeftNormalImage { get; set; } = ResourceManager.GetNximagePathAdd("btn_page_before_n.png", CommonValue.PBdesignImagesPath); + /// + /// Page to Right Normal Image + /// + public string Page2RightNormalImage { get; set; } = ResourceManager.GetNximagePathAdd("btn_page_after_n.png", CommonValue.PBdesignImagesPath); + private bool scanPage2LeftEnable; + /// + /// Scan Page 2 Left Button Enabled + /// + public bool ScanPage2LeftEnable + { + get { return scanPage2LeftEnable; } + set { scanPage2LeftEnable = value; PropertyChange("ScanPage2LeftEnable"); } + } + private bool scanPage2RightEnable; + /// + /// Scan Page to Right Button Enabled + /// + public bool ScanPage2RightEnable + { + get { return scanPage2RightEnable; } + set { scanPage2RightEnable = value; PropertyChange("ScanPage2RightEnable"); } + } + private bool orderPage2LeftEnable; + /// + /// Order Page to Left Button Enabled + /// + public bool OrderPage2LeftEnable + { + get { return orderPage2LeftEnable; } + set { orderPage2LeftEnable = value; PropertyChange("OrderPage2LeftEnable"); } + } + private bool orderPage2RightEnable; + /// + /// Order Page to Right Button Enabled + /// + public bool OrderPage2RightEnable + { + get { return orderPage2RightEnable; } + set { orderPage2RightEnable = value; PropertyChange("OrderPage2RightEnable"); } + } + private int scanItemCount; + /// + /// Scan Items Count + /// + public int ScanItemCount + { + get { return scanItemCount; } + set { scanItemCount = value; PropertyChange("ScanItemCount"); } + } + private int scanItemPageNo; + /// + /// Scan Items Page No + /// + public int ScanItemPageNo + { + get { return scanItemPageNo; } + set { scanItemPageNo = value; PropertyChange("ScanItemPageNo"); } + } + private int scanItemPageCount; + /// + /// Scan Items Page Count + /// + public int ScanItemPageCount + { + get { return scanItemPageCount; } + set { scanItemPageCount = value; PropertyChange("ScanItemPageCount"); } + } + private int orderItemCount; + /// + /// Order Items Count + /// + public int OrderItemCount + { + get { return orderItemCount; } + set { orderItemCount = value; PropertyChange("OrderItemCount"); } + } + + private int orderItemPageNo; + /// + /// Order Items PageNo + /// + public int OrderItemPageNo + { + get { return orderItemPageNo; } + set { orderItemPageNo = value; PropertyChange("OrderItemPageNo"); } + } + private int orderItemPageCount; + /// + /// Order Items Page Count + /// + public int OrderItemPageCount + { + get { return orderItemPageCount; } + set { orderItemPageCount = value; PropertyChange("OrderItemPageCount"); } + } + private ObservableCollection scanItemPageStatus; + /// + /// Scan Items Page Selector Data + /// + public ObservableCollection ScanItemPageStatus + { + get { return scanItemPageStatus; } + set { scanItemPageStatus = value; PropertyChange("ScanItemPageStatus"); } + } + private ObservableCollection orderItemPageStatus; + /// + /// Order Items Page Salector Data + /// + public ObservableCollection OrderItemPageStatus + { + get { return orderItemPageStatus; } + set { orderItemPageStatus = value; PropertyChange("OrderItemPageStatus"); } + } + private int scanPageStatusColumnCount; + /// + /// Scan Item Page Selector Column Count + /// + public int ScanPageStatusColumnCount + { + get { return scanPageStatusColumnCount; } + set { scanPageStatusColumnCount = value; PropertyChange("ScanPageStatusColumnCount"); } + } + private int orderPageStatusColumnCount; + /// + /// Order Items Page Selector Column Count + /// + public int OrderPageStatusColumnCount + { + get { return orderPageStatusColumnCount; } + set { orderPageStatusColumnCount = value; PropertyChange("OrderPageStatusColumnCount"); } + } + /// + /// Scan Item Page to Left Command + /// + public ICommand ScanPage2LeftCommand { get; protected set; } = null; + /// + /// Scan Item Page to Right Command + /// + public ICommand ScanPage2RightCommand { get; protected set; } = null; + /// + /// Order Item Page to left Command + /// + public ICommand OrderPage2LeftCommand { get; protected set; } = null; + /// + /// Order Item Page to right Command + /// + public ICommand OrderPage2RightCommand { get; protected set; } = null; + /// + /// Scan Page Selector Command + /// + public ICommand ScanPageSelectCommand { get; protected set; } = null; + /// + /// Order Page Selector Command + /// + public ICommand OrderPageSelectCommand { get; protected set; } = null; + /// + /// Scan Items Delete Command + /// + public ICommand ScanBarcodeDeleteCommand { get; protected set; } = null; + /// + /// Order Item Delete Command + /// + public ICommand OrderDeleteCommand { get; protected set; } = null; + /// + /// Scan Items All Delete Command + /// + public ICommand ScanBarcodeAllDeleteCommand { get; protected set; } = null; + /// + /// Order Items All Delete Command + /// + public ICommand OrderAllDeleteCommand { get; protected set; } = null; + #endregion + #region PointsDisCounts + /// + /// Happy Point Resrve Noraml Brush + /// + public string HappyPointResrveNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happypoint_n.png", CommonValue.PBdesignImagesPath); + /// + /// Happy Point Resrve SwitchOn Brush + /// + public string HappyPointResrveSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happypoint_f.png", CommonValue.PBdesignImagesPath); + /// + /// Happy Point Resrve Disabled Brush + /// + public string HappyPointResrveDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happypoint_d.png", CommonValue.PBdesignImagesPath); + + private bool happyPointResrveSwitch; + /// + /// Happy Point Resrve Switch + /// + public bool HappyPointResrveSwitch + { + get { return happyPointResrveSwitch; } + set { happyPointResrveSwitch = value; PropertyChange("HappyPointResrveSwitch"); } + } + private bool happyPointResrveEnable = true; + /// + /// Happy Point Resrve Enable + /// + public bool HappyPointResrveEnable + { + get { return happyPointResrveEnable; } + set { happyPointResrveEnable = value; PropertyChange("HappyPointResrveEnable"); } + } + /// + /// Happy Point Resrve Command + /// + public ICommand HappyPointResrveCommand { get; protected set; } = null; + + + /// + /// OkCashBag Resrve Noraml Brush + /// + public string OkCashBagResrveNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_ocb_n.png", CommonValue.PBdesignImagesPath); + /// + /// OkCashBag Resrve SwitchOn Brush + /// + public string OkCashBagResrveSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_ocb_f.png", CommonValue.PBdesignImagesPath); + /// + /// OkCashBag Resrve Disabled Brush + /// + public string OkCashBagResrveDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_ocb_d.png", CommonValue.PBdesignImagesPath); + private bool okCashBagResrveSwitch; + /// + /// OkCashBag Resrve Switch + /// + public bool OkCashBagResrveSwitch + { + get { return okCashBagResrveSwitch; } + set { okCashBagResrveSwitch = value; PropertyChange("OkCashBagResrveSwitch"); } + } + private bool okCashBagResrveEnable = true; + /// + /// OkCashBag Resrve Enabled + /// + public bool OkCashBagResrveEnable + { + get { return okCashBagResrveEnable; } + set { okCashBagResrveEnable = value; PropertyChange("OkCashBagResrveEnable"); } + } + /// + /// OkCashBag Resrve Command + /// + public ICommand OkCashBagResrveCommand { get; protected set; } = null; + + + + + /// + /// Discount SK Noraml Brush + /// + public string DiscountSKNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_sk_n.png", CommonValue.PBdesignImagesPath); + /// + /// Discount SK SwitchOn Brush + /// + public string DiscountSKSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_sk_f.png", CommonValue.PBdesignImagesPath); + /// + /// Discount SK Disables Brush + /// + public string DiscountSKDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_sk_d.png", CommonValue.PBdesignImagesPath); + private bool discountSKSwitch; + /// + /// Discount SK Switch + /// + public bool DiscountSKSwitch + { + get { return discountSKSwitch; } + set { discountSKSwitch = value; PropertyChange("DiscountSKSwitch"); } + } + private bool discountSKEnable = true; + /// + /// Discount SK Enable + /// + public bool DiscountSKEnable + { + get { return discountSKEnable; } + set { discountSKEnable = value; PropertyChange("DiscountSKEnable"); } + } + /// + /// Discount SK Command + /// + public ICommand DiscountSKCommand { get; protected set; } = null; + /// + /// Discount KT Noraml Brush + /// + public string DiscountKTNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_kt_n.png", CommonValue.PBdesignImagesPath); + /// + /// Discount KT SwitchOn Brush + /// + public string DiscountKTSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_kt_f.png", CommonValue.PBdesignImagesPath); + /// + /// Discount KT Disabled Brush + /// + public string DiscountKTDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_kt_d.png", CommonValue.PBdesignImagesPath); + private bool discountKTSwitch; + /// + /// Discount KT Switch + /// + public bool DiscountKTSwitch + { + get { return discountKTSwitch; } + set { discountKTSwitch = value; PropertyChange("DiscountKTSwitch"); } + } + private bool discountKTEnable = true; + /// + /// Discount KT Enabled + /// + public bool DiscountKTEnable + { + get { return discountKTEnable; } + set { discountKTEnable = value; PropertyChange("DiscountKTEnable"); } + } + /// + /// Discount KT Command + /// + public ICommand DiscountKTCommand { get; protected set; } = null; + /// + /// Discount LG Noraml Brush + /// + public string DiscountLGNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_lg_n.png", CommonValue.PBdesignImagesPath); + /// + /// Discount LG SwitchOn Brush + /// + public string DiscountLGSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_lg_f.png", CommonValue.PBdesignImagesPath); + /// + /// Discount LG Disables Brush + /// + public string DiscountLGDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_lg_d.png", CommonValue.PBdesignImagesPath); + private bool discountLGSwitch; + /// + /// Discount LG Switch + /// + public bool DiscountLGSwitch + { + get { return discountLGSwitch; } + set { discountLGSwitch = value; PropertyChange("DiscountLGSwitch"); } + } + private bool discountLGEnable = true; + /// + /// Discount LG Enabled + /// + public bool DiscountLGEnable + { + get { return discountLGEnable; } + set { discountLGEnable = value; PropertyChange("DiscountLGEnable"); } + } + /// + /// Discount LG Command + /// + public ICommand DiscountLGCommand { get; protected set; } = null; + + + /// + /// SpcDiscount2 Noraml Brush + /// + public string SpcDiscount2NoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_spc2_n.png", CommonValue.PBdesignImagesPath); + /// + /// SpcDiscount2 SwitchOn Brush + /// + public string SpcDiscount2SwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_spc2_f.png", CommonValue.PBdesignImagesPath); + /// + /// OkCashBag Resrve Disabled Brush + /// + public string SpcDiscount2DisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_spc2_d.png", CommonValue.PBdesignImagesPath); + private bool spcDiscount2Switch; + /// + /// SpcDiscount2 Switch + /// + public bool SpcDiscount2Switch + { + get { return spcDiscount2Switch; } + set { spcDiscount2Switch = value; PropertyChange("SpcDiscount2Switch"); } + } + private bool spcDiscount2Enable = true; + /// + /// SpcDiscount2 Resrve Enabled + /// + public bool SpcDiscount2Enable + { + get { return spcDiscount2Enable; } + set { spcDiscount2Enable = value; PropertyChange("SpcDiscount2Enable"); } + } + /// + /// SpcDiscount2 Command + /// + public ICommand SpcDiscount2Command { get; protected set; } = null; + + + #endregion + + #region CouponUsePoints + /// + /// Happy Point Using Noraml Brush + /// + public string HappyPointUsingNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happypoint_n.png", CommonValue.PBdesignImagesPath); + /// + /// Happy Point Using SwitchOn Brush + /// + public string HappyPointUsingSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happypoint_f.png", CommonValue.PBdesignImagesPath); + /// + /// Happy Point Using Disabled Brush + /// + public string HappyPointUsingDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happypoint_d.png", CommonValue.PBdesignImagesPath); + private bool happyPointUsingSwitch; + /// + /// Happy Point Using Switch + /// + public bool HappyPointUsingSwitch + { + get { return happyPointUsingSwitch; } + set { happyPointUsingSwitch = value; PropertyChange("HappyPointUsingSwitch"); } + } + /// + /// Happy Point Using Command + /// + public ICommand HappyPointUsingCommand { get; protected set; } = null; + /// + /// OkCashBag Using Noraml Brush + /// + public string OkCashBagUsingNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_ocb_n.png", CommonValue.PBdesignImagesPath); + /// + /// OkCashBag Using SwitchOn Brush + /// + public string OkCashBagUsingSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_ocb_f.png", CommonValue.PBdesignImagesPath); + /// + /// OkCashBag Using Disabled Brush + /// + public string OkCashBagUsingDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_ocb_d.png", CommonValue.PBdesignImagesPath); + private bool okCashBagUsingSwitch; + /// + /// OkCashBag Using Switch + /// + public bool OkCashBagUsingSwitch + { + get { return okCashBagUsingSwitch; } + set { okCashBagUsingSwitch = value; PropertyChange("OkCashBagUsingSwitch"); } + } + /// + /// OkCashBag Using Command + /// + public ICommand OkCashBagUsingCommand { get; protected set; } = null; + + + /// + /// SamsungPointUsing Noraml Brush + /// + public string SamsungPointUsingNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_samsung_n.png", CommonValue.PBdesignImagesPath); + /// + /// SamsungPointUsing Command + /// + public ICommand SamsungPointUsingCommand { get; protected set; } = null; + + /// + /// HyundaiPointUsing Noraml Brush + /// + public string HyundaiPointUsingNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_hyundai_n.png", CommonValue.PBdesignImagesPath); + /// + /// HyundaiPointUsing Command + /// + public ICommand HyundaiPointUsingCommand { get; protected set; } = null; + + /// + /// MoreView Noraml Brush + /// + public string MoreViewNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_more_n.png", CommonValue.PBdesignImagesPath); + /// + /// MoreView Command + /// + public ICommand MoreViewCommand { get; protected set; } = null; + + + + /// + /// ShinHanCardPointUsing Noraml Brush + /// + public string ShinHanCardPointUsingNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_shinhan_n.png", CommonValue.PBdesignImagesPath); + /// + /// ShinHanCardPointUsing Command + /// + public ICommand ShinHanCardPointUsingCommand { get; protected set; } = null; + + /// + /// HyundaiOilBankUsing Noraml Brush + /// + public string HyundaiOilBankUsingNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_hyundaioilbank_n.png", CommonValue.PBdesignImagesPath); + /// + /// HyundaiOilBankUsing Command + /// + public ICommand HyundaiOilBankUsingCommand { get; protected set; } = null; + + /// + /// HyundaiBlueMembersUsing Noraml Brush + /// + public string HyundaiBlueMembersUsingNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_bluemembers_n.png", CommonValue.PBdesignImagesPath); + /// + /// HyundaiBlueMembersUsing Command + /// + public ICommand HyundaiBlueMembersUsingCommand { get; protected set; } = null; + + /// + /// KiaMembersUsing Noraml Brush + /// + public string KiaMembersUsingNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_kiaredmembers_n.png", CommonValue.PBdesignImagesPath); + /// + /// KiaMembersUsing Command + /// + public ICommand KiaMembersUsingCommand { get; protected set; } = null; + + /// + /// MoreViewReturn Noraml Brush + /// + public string MoreViewReturnNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_back_n.png", CommonValue.PBdesignImagesPath); + /// + /// MoreViewReturn Command + /// + public ICommand MoreViewReturnCommand { get; protected set; } = null; + + + /// + /// Happy App My Coupon Noraml Brush + /// + public string HappyAppMyCouponNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happyapp_n.png", CommonValue.PBdesignImagesPath); + /// + /// Happy App My Coupon SwitchOn Brush + /// + public string HappyAppMyCouponSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happyapp_f.png", CommonValue.PBdesignImagesPath); + /// + /// Happy App My Coupon Disabled Brush + /// + public string HappyAppMyCouponDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happyapp_d.png", CommonValue.PBdesignImagesPath); + private bool happyAppMyCouponSwitch; + /// + /// Happy App My Coupon Switch + /// + public bool HappyAppMyCouponSwitch + { + get { return happyAppMyCouponSwitch; } + set { happyAppMyCouponSwitch = value; PropertyChange("HappyAppMyCouponSwitch"); } + } + /// + /// Happy App My Coupon Command + /// + public ICommand HappyAppMyCouponCommand { get; protected set; } = null; + /// + /// Mobile Coupon Noraml Brush + /// + public string MobileCouponNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_mobilecoupon_n.png", CommonValue.PBdesignImagesPath); + /// + /// Mobile Coupon SwitchOn Brush + /// + public string MobileCouponSwitchOnBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_mobilecoupon_f.png", CommonValue.PBdesignImagesPath); + /// + /// Mobile Coupon Disabled Brush + /// + public string MobileCouponDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_mobilecoupon_d.png", CommonValue.PBdesignImagesPath); + private bool mobileCouponSwitch; + /// + /// Mobile Coupon Switch + /// + public bool MobileCouponSwitch + { + get { return mobileCouponSwitch; } + set { mobileCouponSwitch = value; PropertyChange("MobileCouponSwitch"); } + } + /// + /// Mobile Coupon Command + /// + public ICommand MobileCouponCommand { get; protected set; } = null; + #endregion + + #region PaymentExcute + /// + /// ICcard Noraml Brush + /// + public string ICcardNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_creditcard_n.png", CommonValue.PBdesignImagesPath); + /// + /// ICcard Command + /// + public ICommand ICcardCommand { get; protected set; } = null; + /// + /// LGSSpay Noraml Brush + /// + public string LGSSpayNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_samsunglg_n.png", CommonValue.PBdesignImagesPath); + /// + /// LGSSpay Command + /// + public ICommand LGSSpayCommand { get; protected set; } = null; + /// + /// CashBee Noraml Brush + /// + public string CashBeeNoramlBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_cashbee_n.png", CommonValue.PBdesignImagesPath); + /// + /// CashBee Command + /// + public ICommand CashBeeCommand { get; protected set; } = null; + /// + /// HappyGift Brush + /// + public string HappyGiftBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_happygift_n.png", CommonValue.PBdesignImagesPath); + /// + /// HappyGift Command + /// + public ICommand HappyGiftCommand { get; protected set; } = null; + /// + /// Tmoney Brush + /// + public string TmoneyBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_tmoney_n.png", CommonValue.PBdesignImagesPath); + /// + /// Tmoney Command + /// + public ICommand TmoneyCommand { get; protected set; } = null; + /// + /// SPCemployee Brush + /// + public string SPCemployeeBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_spc_n.png", CommonValue.PBdesignImagesPath); + /// + /// KakaoPay Brush + /// + public string KakaoPayBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_kakao_n.png", CommonValue.PBdesignImagesPath); + /// + /// SPCemployee Command + /// + public ICommand SPCemployeeCommand { get; protected set; } = null; + /// + /// KakaoPay Command + /// + public ICommand KakaoPayCommand { get; protected set; } = null; + /// + /// SmilePay Brush + /// + public string SmilePayBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_smile_n.png", CommonValue.PBdesignImagesPath); + /// + /// SmilePay Command + /// + public ICommand SmilePayCommand { get; protected set; } = null; + /// + /// AliPay Brush + /// + public string AliPayBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_ali_n.png", CommonValue.PBdesignImagesPath); + /// + /// AliPay Command + /// + public ICommand AliPayCommand { get; protected set; } = null; + /// + /// ZeroPay Brush + /// + public string ZeroPayBrush { get; set; } = ResourceManager.GetNximagePathAdd("btn_pay_zero_n.png", CommonValue.PBdesignImagesPath); + /// + /// ZeroPay Command + /// + public ICommand ZeroPayCommand { get; protected set; } = null; + + #endregion + + #endregion + + #region PaymentsList + /// + /// Detail Basket Delete All Image + /// + public string DetailBasketDeleteAllImage { get; set; } = ResourceManager.GetNximagePathAdd("btn_delete.png", CommonValue.PBdesignImagesPath); + /// + /// Discount Bar Brush + /// + public string DiscountBarBrush { get; set; } = ResourceManager.GetNximagePathAdd("discount_bar.png", CommonValue.PBdesignImagesPath); + /// + /// Detail Basket Delete All Command + /// + public ICommand DetailBasketDeleteAllCommand { get; protected set; } = null; + private bool detailBasketDeleteAllShow = false; + /// + /// Detail Basket Delete All Show + /// + public bool DetailBasketDeleteAllShow + { + get { return detailBasketDeleteAllShow; } + set { detailBasketDeleteAllShow = value; PropertyChange("DetailBasketDeleteAllShow"); } + } + + #region PaymentValue + private int totalItemCount; + /// + /// Total Item Count + /// + public int TotalItemCount + { + get { return totalItemCount; } + set { totalItemCount = value; PropertyChange("TotalItemCount"); } + } + private double totalItemsPrice; + /// + /// Total Items Price + /// + public double TotalItemsPrice + { + get { return totalItemsPrice; } + set { totalItemsPrice = value; PropertyChange("TotalItemsPrice"); } + } + private double totalDiscountValue = 0d; + /// + /// Total Discount Value + /// + public double TotalDiscountValue + { + get { return totalDiscountValue; } + set { totalDiscountValue = value; PropertyChange("TotalDiscountValue"); } + } + private double totalPriceForPayments; + /// + /// Total Price For Payments + /// + public double TotalPriceForPayments + { + get { return totalPriceForPayments; } + set { totalPriceForPayments = value; PropertyChange("TotalPriceForPayments"); } + } + /// + /// Order Total Payment Icon + /// + public string OrderTotalPaymentIcon { get; set; } = ResourceManager.GetNximagePathAdd("Ic_totalcost.png", CommonValue.PBdesignImagesPath); + #endregion + + + #region Button + private List gotoLeftText; + /// + /// GotoLeft Button Text + /// + public List GotoLeftText + { + get { return gotoLeftText; } + set { gotoLeftText = value; PropertyChange("GotoLeftText"); } + } + private double gotoLeftWidth = 136d; + /// + /// Goto Left Button Width + /// + public double GotoLeftWidth + { + get { return gotoLeftWidth; } + set { gotoLeftWidth = value; PropertyChange("GotoLeftWidth"); } + } + + private bool gotoLeftEnable = true; + /// + /// Goto Left Button Enabled + /// + public bool GotoLeftEnable + { + get { return gotoLeftEnable; } + set { gotoLeftEnable = value; PropertyChange("GotoLeftEnable"); } + } + /// + /// Goto Left Command + /// + public ICommand GotoLeftCommand { get; protected set; } = null; + private List gotoRightText; + /// + /// GotoRight Button Text + /// + public List GotoRightText + { + get { return gotoRightText; } + set { gotoRightText = value; PropertyChange("GotoRightText"); } + } + private double gotoRightWidth = 254d; + /// + /// Goto Right Button Width + /// + public double GotoRightWidth + { + get { return gotoRightWidth; } + set { gotoRightWidth = value; PropertyChange("GotoRightWidth"); } + } + + private bool gotoRightEnable = true; + /// + /// Goto Right Button Enabled + /// + public bool GotoRightEnable + { + get { return gotoRightEnable; } + set { gotoRightEnable = value; PropertyChange("GotoRightEnable"); } + } + /// + /// Goto Right Command + /// + public ICommand GotoRightCommand { get; protected set; } = null; + #endregion + + #endregion PaymentsList + private PaymentsDiscountAndAddType CurrentRollBakType; + + /// + /// SPC 임직원 유무 + /// + private bool isCompanyMember; + + public bool IsCompanyMember + { + get { return isCompanyMember; } + set { isCompanyMember = value; PropertyChange("IsCompanyMember"); } + } + + #endregion Members + + #region [ Ctor/Etc ] + /// + /// Ctor + /// + public PBPaymentsViewModel() + { + InitViewModel(); + } + /// + /// Dispose + /// + public new void Dispose() + { + this.PropertyChanged -= PBPaymentsViewModel_PropertyChanged; + if (posDataService != null) + { + posDataService.Dispose(); + posDataService = null; + } + if (popupManager != null) + { + popupManager = null; + } + base.Dispose(); + GC.SuppressFinalize(this); + } + #endregion Ctor/Etc + + #region [ Methods ] + private void InitViewModel() + { + try + { + posDataService = new PosDataService(); + WaitWindowFrom = WaitWindow.GetInstance; + WaitWindowFrom.CloseWaitWindow(); + //GMB Right + LanguageCommand = new Command(LanguageCommandHandler); + CallEmployeeCommand = new Command(CallEmployeeCommandHandler); + GotoIntroPageCommad = new Command(GotoIntroPageCommadHandler); + + //Contents + GotoPointsDisCountsCommand = new Command(GotoPointsDisCountsCommandHandler); + GotoCouponUsePointsCommand = new Command(GotoCouponUsePointsCommandHandler); + GotoPaymentExcuteCommand = new Command(GotoPaymentExcuteCommandHandler); + //Detail Basket + ScanPage2LeftCommand = new Command(ScanPage2LeftCommandHandler); + ScanPage2RightCommand = new Command(ScanPage2RightCommandHandler); + OrderPage2LeftCommand = new Command(OrderPage2LeftCommandHandler); + OrderPage2RightCommand = new Command(OrderPage2RightCommandHandler); + ScanPageSelectCommand = new Command(ScanPageSelectCommandHandler); + OrderPageSelectCommand = new Command(OrderPageSelectCommandHandler); + ScanBarcodeDeleteCommand = new Command(ScanBarcodeDeleteCommandHandler); + OrderDeleteCommand = new Command(OrderDeleteCommandHandler); + ScanBarcodeAllDeleteCommand = new Command(ScanBarcodeAllDeleteCommandHandler); + OrderAllDeleteCommand = new Command(OrderAllDeleteCommandHandler); + + //Reserve + HappyPointResrveCommand = new Command(HappyPointResrveCommadHandler); + OkCashBagResrveCommand = new Command(OkCashBagResrveCommandHandler); + + //Discount + DiscountSKCommand = new Command(DiscountSKCommandHandler); + DiscountKTCommand = new Command(DiscountKTCommandHandler); + DiscountLGCommand = new Command(DiscountLGCommandHandler); + + //PointUsing + HappyPointUsingCommand = new Command(HappyPointUsingCommandHandler); + OkCashBagUsingCommand = new Command(OkCashBagUsingCommandHandler); + + //PointUsing MoreView + MoreViewCommand = new Command(MoreViewCommandHandler); + + //PointUsing MoreViewReturn + MoreViewReturnCommand = new Command(MoreViewReturnCommandHandler); + + //Coupon + HappyAppMyCouponCommand = new Command(HappyAppMyCouponCommandHandler); + MobileCouponCommand = new Command(MobileCouponCommandHandler); + + //PaymentsKind + ICcardCommand = new Command(ICcardCommandHandler); + LGSSpayCommand = new Command(LGSSpayCommandHandler); + CashBeeCommand = new Command(CashBeeCommandHandler); + HappyGiftCommand = new Command(HappyGiftCommandHandler); + TmoneyCommand = new Command(TmoneyCommandHandler); + SPCemployeeCommand = new Command(SPCemployeeCommandHandler); + KakaoPayCommand = new Command(KakaoPayCommandHandler); + SmilePayCommand = new Command(SmilePayCommandHandler); + AliPayCommand = new Command(AliPayCommandHandler); + ZeroPayCommand = new Command(ZeroPayCommandHandler); + //PaymentsList + DetailBasketDeleteAllCommand = new Command(DetailBasketDeleteAllCommandHandler); + GotoLeftCommand = new Command(GotoLeftCommandHandler); + GotoRightCommand = new Command(GotoRightCommandHandler); + + this.GetPosOption(); + this.GetNhsFuncInfo(); + this.IsCompanyMember = new posHappyPoint().IsCompanyMember; + + this.PropertyChanged += PBPaymentsViewModel_PropertyChanged; + + ShowLanguageType = CommonValue.CommonLanguageType; + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "InitViewModel()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + } + } + + private void GetPosOption() + { + //PosOption 값 획득 + using (var backDataService = new BackDataService()) + { + this.OptionValue802 = backDataService.GetPosOption(nameof(PosOptionType.OPT802)); + this.OptionValue803 = backDataService.GetPosOption(nameof(PosOptionType.OPT803)); + this.OptionValue804 = backDataService.GetPosOption(nameof(PosOptionType.OPT804)); + } + } + + private void GetNhsFuncInfo() + { + using (var commonDataHelper = new CommonDataHelper()) + { + //Get NHS_FUNC_INFO Data Dictionary + var nhsFuncInfoData = commonDataHelper.GetNhsFuncInfo(); + //고유식별 Type + var nhsFuncInfoType = new NhsFuncInfoType(); + //View Binding 데이터 + if (NhsFuncInfo == null) { NhsFuncInfo = new NhsFuncInfoItem(); } + + //전체 const로 잡힌 필드를 돌며 DB에서 받아온 Key와 매칭 + foreach (var item in nhsFuncInfoType.GetType().GetFields()) + { + if (nhsFuncInfoData.ContainsKey(item.GetValue(nhsFuncInfoType)?.ToString())) + { + //받아온 데이터 키와 고유식별 Type을 매칭해 View Binding데이터와 일치하게 삽입 + NhsFuncInfo.GetType().GetProperty(item.Name).SetValue(NhsFuncInfo, nhsFuncInfoData[item.GetValue(nhsFuncInfoType)?.ToString()], System.Reflection.BindingFlags.SetField, null, null, null); + } + } + } + } + + #region Contents + private void InitailizeDetailBasket() + { + GMBHeaderText = Languages.GetMessages("LBL0098"); + GotoLeftWidth = 136d; + GotoRightWidth = 254d; + GotoLeftText = Languages.GetMessages("BTN0026"); + GotoRightText = Languages.GetMessages("BTN0004"); + DetailBasketDeleteAllShow = true; + + } + private void SubDataReset() + { + if (DetailBasketData is ObservableCollection + && DetailBasketData.Count > 0) + { + ScanBarcodeBasketData = new ObservableCollection(DetailBasketData.Where(r => r.ItemType.Equals(BasketItemType.Barcode) || r.ItemType.Equals(BasketItemType.Scan)).ToList()); + OrderBasketData = new ObservableCollection(DetailBasketData.Where(r => r.ItemType.Equals(BasketItemType.Order)).ToList()); + } + else + { + ScanBarcodeBasketData = null; + OrderBasketData = null; + } + ScanItemPageNo = 0; + OrderItemPageNo = 0; + } + private ObservableCollection SetPageNumber(int _pageCount) + { + var pageNumbers = new ObservableCollection(); + try + { + if (_pageCount > 0) + { + + for (int index = 0; index < _pageCount; index++) + { + pageNumbers.Add(new M_ItemData + { + Index = index, + DataParameter = new M_AnimationButton + { + NormalBrush = ResourceManager.GetNximagePathAdd("Img_page_dot_off.png", CommonValue.PBdesignImagesPath), + SwitchOnBrush = ResourceManager.GetNximagePathAdd("Img_page_dot_on.png", CommonValue.PBdesignImagesPath), + Width = 20, + Height = 20, + BrushStretch = Stretch.Fill, + ClickAnimationType = ButtonAnimationType.SizeDown, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty, + TextVisible = Visibility.Collapsed, + } + }); + + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "SetPageNumber()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + pageNumbers = new ObservableCollection(); + } + return pageNumbers; + } + private void DeleteBasketItem(M_BasketItem _deleteItem) + { + if (DetailBasketData is ObservableCollection) + { + var newBasketData = DetailBasketData.ToList(); + using (var posDataService = new PosDataService()) + { + if (posDataService.DelItem(_deleteItem)) + { + newBasketData.Remove(_deleteItem); + } + } + newBasketData.Remove(_deleteItem); + DetailBasketData = new ObservableCollection(newBasketData); + + } + } + private void DeleteScanAndBarcordItem() + { + if (DetailBasketData is ObservableCollection) + { + var newBasketData = DetailBasketData.ToList(); + using (var posDataService = new PosDataService()) + { + foreach (var aitem in newBasketData.Where(r => r.ItemType.Equals(BasketItemType.Scan) + || r.ItemType.Equals(BasketItemType.Barcode)).ToList()) + { + if (posDataService.DelItem(aitem)) + { + newBasketData.Remove(aitem); + } + } + } + DetailBasketData = new ObservableCollection(newBasketData); + } + } + private void DeleteSelfOrderItem() + { + if (DetailBasketData is ObservableCollection) + { + var newBasketData = DetailBasketData.ToList(); + using (var posDataService = new PosDataService()) + { + foreach (var aitem in newBasketData.Where(r => r.ItemType.Equals(BasketItemType.Order)).ToList()) + { + if (posDataService.DelItem(aitem)) + { + newBasketData.Remove(aitem); + } + } + } + DetailBasketData = new ObservableCollection(newBasketData); + } + } + public void DeledteAllBasket() + { + + using (var posDataService = new PosDataService()) + { + foreach (var aitem in DetailBasketData) + { + posDataService.DelItem(aitem); + } + } + DetailBasketData = null; + } + private void InitailizePointsDisCounts() + { + GMBHeaderText = Languages.GetMessages("LBL0035"); + GotoPointsDisCountsEnable = false; + GotoCouponUsePointsEnable = true; + GotoPaymentExcuteEnable = true; + GotoLeftWidth = 136d; + GotoRightWidth = 254d; + GotoLeftText = Languages.GetMessages("BTN0028"); + GotoRightText = Languages.GetMessages("BTN0008"); + DetailBasketDeleteAllShow = false; + } + private void InitailizeCouponUsePoints() + { + GMBHeaderText = Languages.GetMessages("LBL0035"); + GotoPointsDisCountsEnable = true; + GotoCouponUsePointsEnable = false; + GotoPaymentExcuteEnable = true; + GotoLeftWidth = 136d; + GotoRightWidth = 254d; + GotoLeftText = Languages.GetMessages("BTN0028"); + GotoRightText = Languages.GetMessages("BTN0008"); + DetailBasketDeleteAllShow = false; + + } + private void InitailizeMoreView() + { + GMBHeaderText = Languages.GetMessages("LBL0035"); + GotoPointsDisCountsEnable = true; + GotoCouponUsePointsEnable = false; + GotoPaymentExcuteEnable = true; + GotoLeftWidth = 136d; + GotoRightWidth = 254d; + GotoLeftText = Languages.GetMessages("BTN0028"); + GotoRightText = Languages.GetMessages("BTN0008"); + DetailBasketDeleteAllShow = false; + } + private void InitailizePaymentExcute() + { + GMBHeaderText = Languages.GetMessages("LBL0035"); + GotoPointsDisCountsEnable = true; + GotoPointsDisCountsEnable = true; + GotoCouponUsePointsEnable = true; + GotoPaymentExcuteEnable = false; + GotoLeftWidth = 390d; + GotoRightWidth = 0d; + GotoLeftText = Languages.GetMessages("BTN0028"); + DetailBasketDeleteAllShow = false; + + } + + public void OpenFistPopup() + { + FirstLoaded = false; + var setPosItems = false; + using (var newPosDataService = new PosDataService()) + { + setPosItems = newPosDataService.ResetItems(DetailBasketData.ToList()); + } + if (setPosItems) + { + popupManager.OpenStepInfoPopup(); + } + else + { + PopupMessageBox.ShowMessageBox(ShowLanguageType + , Languages.GetMessages("LBL0077") + , null + , MessageBoxButton.OK + , OpenCloseAnimationType.FullSizeUp + , OpenCloseAnimationType.FullSizeDown + , 0.5, 0.2, 10); + RollBacklEnd(); + } + } + + private void OpenReserveHappyPoint() + { + TimerEnabled = false; + try + { + var popupReturn = popupManager.OpenHappyPointCertify(false, false, ParentPage.PBPaymentsWindow); + if (popupReturn is M_PopupReturn) + { + if (popupReturn.OKAnswer) + { + if (popupReturn.PopupArgs is M_HappyPointReturn _HappyPointReturn) + { + HappyPointReturn = _HappyPointReturn; + } + else + { + HappyPointReturn = null; + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenReserveHappyPoint()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + TimerEnabled = true; + } + } + private void OpenReserveOkCashBag() + { + TimerEnabled = false; + try + { + var popupReturn = popupManager.OpenOkCashBagCertify(); + if (popupReturn is M_PopupReturn) + { + if (popupReturn.OKAnswer) + { + if (popupReturn.PopupArgs is M_OkCashBagReturn okCashBagReturnValue) + { + OkCashBagReturn = okCashBagReturnValue; + } + else + { + OkCashBagReturn = null; + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenReserveOkCashBag()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + TimerEnabled = true; + } + } + private bool OpenRollbackConfirmDiscountOrPayments(PaymentsDiscountAndAddType _discountType) + { + bool result = false; + TimerEnabled = false; + try + { + + var miniPopup = new M_MiniPopup + { + Icon = MiniPopupIcon.DiscountCancel, + DisplayLanguage = ShowLanguageType, + Message = GetPaymentsDiscountAndAddTypeText(_discountType).CombineLanguageData(Languages.GetMessages("LBL0080")), + CencalButtonText = Languages.GetMessages("BTN0021"), + OkButtonText = Languages.GetMessages("BTN0005"), + IsCencalButton = true, + TimeoutSeconds = 10, + }; + var popupReturn = popupManager.OpenMiniPopup(miniPopup); + if (popupReturn is M_PopupReturn) + { + result = popupReturn.OKAnswer; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenRollbackConfirmDiscountOrPayments()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = false; + } + finally + { + TimerEnabled = true; + } + return result; + } + private List GetPaymentsDiscountAndAddTypeText(PaymentsDiscountAndAddType _discountType) + { + var result = new List(); + try + { + switch (_discountType) + { + case PaymentsDiscountAndAddType.HappyPoint: + result = new List + { + new M_Language + { + Type=SupportLanguageType.ko, + LanguageData = "해피포인트 사용" + } + }; + break; + case PaymentsDiscountAndAddType.HappyCoupon: + result = new List + { + new M_Language + { + Type=SupportLanguageType.ko, + LanguageData = "해피앱 쿠폰" + } + }; + break; + + case PaymentsDiscountAndAddType.MobileCoupon: + result = new List + { + new M_Language + { + Type=SupportLanguageType.ko, + LanguageData = "모바일 쿠폰 사용" + } + }; + break; + case PaymentsDiscountAndAddType.SkTelecomDiscount: + result = new List + { + new M_Language + { + Type=SupportLanguageType.ko, + LanguageData = "SKT 멤버쉽 할인" + } + }; + break; + case PaymentsDiscountAndAddType.AllehKTDiscount: + result = new List + { + new M_Language + { + Type=SupportLanguageType.ko, + LanguageData = "KT 멤버쉽 할인" + } + }; + break; + case PaymentsDiscountAndAddType.LGUPlusDisCount: + result = new List + { + new M_Language + { + Type=SupportLanguageType.ko, + LanguageData = "LG U+ 멤버쉽 할인" + } + }; + break; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetPaymentsDiscountAndAddTypeText()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = new List(); + } + return result; + } + private void MobileCompanyDiscountExcute(MobileCompanyType _mobileCompany) + { + if (MobileCompanyReturn is M_MobileCompanyReturn mobileCompanyReturn + && mobileCompanyReturn.Company.Equals(_mobileCompany) + && mobileCompanyReturn.DiscountValue > 0) + { + + var paymentsDiscountType = PaymentsDiscountAndAddType.None; + switch (_mobileCompany) + { + case MobileCompanyType.KT_Mobile: + paymentsDiscountType = PaymentsDiscountAndAddType.AllehKTDiscount; + break; + case MobileCompanyType.SK_Telecom: + paymentsDiscountType = PaymentsDiscountAndAddType.SkTelecomDiscount; + break; + case MobileCompanyType.LG_Uplus: + paymentsDiscountType = PaymentsDiscountAndAddType.LGUPlusDisCount; + break; + } + if (!paymentsDiscountType.Equals(PaymentsDiscountAndAddType.None) && OpenRollbackConfirmDiscountOrPayments(paymentsDiscountType)) + { + TimerEnabled = false; + WaitWindowFrom.ShowWaitWindow(); + RollBackExcute(paymentsDiscountType, MobileCompanyReturn.PaySEQ); + WaitWindowFrom.CloseWaitWindow(); + TimerEnabled = true; + } + } + else + { + OpenMobileCompanyDiscount(_mobileCompany); + } + } + private void OpenMobileCompanyDiscount(MobileCompanyType _mobileCompany) + { + TimerEnabled = false; + try + { + var popupReturn = popupManager.OpenMobileCompanyCertify(_mobileCompany, TotalItemsPrice); + if (popupReturn is M_PopupReturn) + { + if (popupReturn.OKAnswer) + { + if (popupReturn.PopupArgs is M_MobileCompanyReturn mobileCompanyReturnValue) + { + MobileCompanyReturn = mobileCompanyReturnValue; + var discountType = PaymentsDiscountAndAddType.None; + switch (MobileCompanyReturn.Company) + { + case MobileCompanyType.SK_Telecom: + discountType = PaymentsDiscountAndAddType.SkTelecomDiscount; + break; + case MobileCompanyType.KT_Mobile: + discountType = PaymentsDiscountAndAddType.AllehKTDiscount; + break; + case MobileCompanyType.LG_Uplus: + discountType = PaymentsDiscountAndAddType.LGUPlusDisCount; + break; + } + AddDiscountValue + ( + new M_DiscountAndAddValues + { + DiscountType = discountType, + DiscountName = GetPaymentsDiscountAndAddTypeText(discountType), + DiscountValue = MobileCompanyReturn.DiscountValue, + IsCanRollBack = true + } + ); + } + else + { + MobileCompanyReturn = null; + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenMobileCompanyDiscount()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + TimerEnabled = true; + } + } + private void OpenHappyPointUsing() + { + TimerEnabled = false; + try + { + var popupReturn = popupManager.OpenHappyPointUsing(HappyPointReturn, TotalPriceForPayments); + if (popupReturn is M_PopupReturn) + { + if (popupReturn.OKAnswer) + { + if (popupReturn.PopupArgs is M_HappyPointReturn _HappyPointReturn) + { + HappyPointReturn = _HappyPointReturn; + if (HappyPointReturn.PointUse) + { + HappyPointUsingSwitch = true; + AddDiscountValue(new M_DiscountAndAddValues + { + DiscountType = PaymentsDiscountAndAddType.HappyPoint, + DiscountName = GetPaymentsDiscountAndAddTypeText(PaymentsDiscountAndAddType.HappyPoint), + DiscountValue = HappyPointReturn.UsingPoints, + IsCanRollBack = true + }); + if (TotalPriceForPayments.Equals(HappyPointReturn.UsingPoints)) + { + HappyPointReturn.ReservePoint = false; + HappyPointResrveSwitch = false; + } + else if (!GetReserveOKChashBag()) + { + HappyPointReturn.ReservePoint = true; + HappyPointResrveSwitch = true; + } + } + + } + else + { + HappyPointReturn = null; + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenHappyPointUsing()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + TimerEnabled = true; + } + } + + private void OpenHappyAppCoupon() + { + TimerEnabled = false; + try + { + var popupReturn = popupManager.OpenHappyAppCoupon(HappyPointReturn, TotalItemsPrice); + if (popupReturn is M_PopupReturn) + { + if (popupReturn.OKAnswer) + { + if (popupReturn.PopupArgs is M_HappyCoupon _usingHappyAppCoupon) + { + UsingHappyAppCoupon = _usingHappyAppCoupon; + HappyAppMyCouponSwitch = true; + AddDiscountValue(new M_DiscountAndAddValues + { + DiscountType = PaymentsDiscountAndAddType.HappyCoupon, + DiscountName = GetPaymentsDiscountAndAddTypeText(PaymentsDiscountAndAddType.HappyCoupon), + DiscountValue = UsingHappyAppCoupon.UseAmount, + IsCanRollBack = true + }); + } + else + { + UsingHappyAppCoupon = null; + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenHappyAppCoupon()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + TimerEnabled = true; + } + } + + private void OpenMobileCoupon() + { + try + { + var popupReturn = popupManager.OpenMobileHappyCoupon(DetailBasketData.ToList(), TotalPriceForPayments); + if (popupReturn is M_PopupReturn) + { + if (popupReturn.OKAnswer) + { + if (popupReturn.PopupArgs is M_MobileCouponReturn _mobileCouponReturn) + { + MobileCouponReturn = _mobileCouponReturn; + if (MobileCouponReturn.TotalUseAmount > 0) + { + MobileCouponSwitch = true; + AddDiscountValue(new M_DiscountAndAddValues + { + DiscountType = PaymentsDiscountAndAddType.MobileCoupon, + DiscountName = GetPaymentsDiscountAndAddTypeText(PaymentsDiscountAndAddType.MobileCoupon), + DiscountValue = MobileCouponReturn.TotalUseAmount, + IsCanRollBack = true + }); + } + + } + else + { + MobileCouponReturn = null; + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenMobileCoupon()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + TimerEnabled = true; + } + } + + private void OpenPaymetsProcess(LastPaymentsType _paymentType) + { + TimerEnabled = false; + try + { + var popupReturn = popupManager.OpenPaymentProcess(_paymentType, TotalPriceForPayments); + if (popupReturn is M_PopupReturn) + { + if (popupReturn.OKAnswer) + { + if (popupReturn.PopupArgs is M_PaymentReturn paymentReturn) + { + PaymentReturn = paymentReturn; + AddDiscountValue(new M_DiscountAndAddValues + { + DiscountType = PaymentsDiscountAndAddType.LastPayment, + DiscountName = Languages.GetMessages("BTN0031"), + DiscountValue = PaymentReturn.PaymentsTotal, + IsCanRollBack = false + }); + } + else + { + PaymentReturn = null; + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenPaymetsProcess()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + TimerEnabled = true; + } + } + private void OpenPaymentEndProcess() + { + TimerEnabled = false; + try + { + + PaymentEndWindowEndType paymentEndType; + //var paymentEndType = DetailBasketData.Where(r => r.ItemType.Equals(BasketItemType.Order)).Count().Equals(0) + // ? PaymentEndWindowEndType.None + // : CommonValue.PaymentEndType; + var happyPointReturn = HappyPointReturn is M_HappyPointReturn + && !string.IsNullOrEmpty(HappyPointReturn.MemberNumber) + && HappyPointReturn.IsAppMamber + ? HappyPointReturn + : null; + + if (DetailBasketData.Where(r => r.ItemType.Equals(BasketItemType.Order)).Count().Equals(0)) + { + paymentEndType = PaymentEndWindowEndType.None; + } + else if (OptionValue802 == "1") + { + paymentEndType = PaymentEndWindowEndType.Bell; + } + else if (OptionValue803 == "1") + { + paymentEndType = PaymentEndWindowEndType.Talk; + } + else if (OptionValue804 == "1") + { + paymentEndType = PaymentEndWindowEndType.WaitNumber; + } + else + { + paymentEndType = PaymentEndWindowEndType.None; + } + + popupManager.OpenPaymentsEnd(paymentEndType, DetailBasketData.ToList(), GetReserveHappyPoint(), GetReserveOKChashBag(), happyPointReturn); + WaitWindowFrom.ShowWaitWindow(); + ProcessOK(); + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenPaymentEndProcess()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + TimerEnabled = true; + WaitWindowFrom.CloseWaitWindow(); + } + } + + + #endregion + + #region Total Values + private void SetBasketSum() + { + if (DetailBasketData is ObservableCollection) + { + TotalItemCount = DetailBasketData.Sum(r => r.Count) + + (DiscountValues is ObservableCollection + ? DiscountValues.Sum(r=>r.AddCount) + : 0) ; + TotalItemsPrice = DetailBasketData.Sum(r => r.Count * r.Price) + + (DiscountValues is ObservableCollection + ? DiscountValues.Sum(r=> r.AddCount * r.AddValue) + : 0) ; + } + else + { + TotalItemCount = 0; + TotalItemsPrice = 0; + } + ScanItemCount = ScanBarcodeBasketData is ObservableCollection && DetailBasketData.Count > 0 + ? ScanBarcodeBasketData.Sum(r => r.Count) + : 0; + OrderItemCount = OrderBasketData is ObservableCollection && OrderBasketData.Count > 0 + ? OrderBasketData.Sum(r => r.Count) + : 0; + + } + private void SetDiscountValue() + { + if (DiscountValues is ObservableCollection) + { + TotalDiscountValue = DiscountValues.Sum(r => r.DiscountValue); + } + else + { + TotalDiscountValue = 0; + } + + } + + #endregion + + #region DiscountValue + private void AddDiscountValue(M_DiscountAndAddValues _discountValues) + { + var listDiscountValues = DiscountValues is ObservableCollection + ? DiscountValues.ToList() + : new List(); + if (!listDiscountValues.Exists(r => r.DiscountType.Equals(_discountValues.DiscountType))) + { + listDiscountValues.Add(_discountValues); + DiscountValues = new ObservableCollection(listDiscountValues); + } + else + { + CommonLog.ErrorLogWrite(this, "AddDiscountValue()", "Duplicate Discount", string.Format("Type:{0}", _discountValues.DiscountType)); + } + + } + private void RemoveDiscountValue(PaymentsDiscountAndAddType _discountType) + { + if (DiscountValues is ObservableCollection) + { + var listDiscountValues = DiscountValues.ToList(); + listDiscountValues.Remove(listDiscountValues.Find(r => r.DiscountType.Equals(_discountType))); + DiscountValues = new ObservableCollection(listDiscountValues); + + } + } + + private void DiscountsRollBack() + { + if (DiscountValues is ObservableCollection) + { + foreach (var aDiscountValue in DiscountValues) + { + switch (aDiscountValue.DiscountType) + { + case PaymentsDiscountAndAddType.HappyPoint: + if (HappyPointReturn is M_HappyPointReturn happyPointReturn) + { + RollBackExcute(aDiscountValue.DiscountType, HappyPointReturn.PaySEQ); + } + break; + case PaymentsDiscountAndAddType.OkCashBagPoint: + break; + case PaymentsDiscountAndAddType.HappyCoupon: + RollBackExcute(PaymentsDiscountAndAddType.HappyCoupon, UsingHappyAppCoupon.PaySEQ); + break; + case PaymentsDiscountAndAddType.MobileCoupon: + if (MobileCouponReturn is M_MobileCouponReturn mobileCouponReturn) + { + foreach (var aCoupon in mobileCouponReturn.VirtureCoupons) + { + if (aCoupon.PaySEQ > -1) RollBackExcute(PaymentsDiscountAndAddType.MobileCoupon, HappyPointReturn.PaySEQ); + } + } + break; + case PaymentsDiscountAndAddType.SkTelecomDiscount: + case PaymentsDiscountAndAddType.AllehKTDiscount: + case PaymentsDiscountAndAddType.LGUPlusDisCount: + if (MobileCompanyReturn is M_MobileCompanyReturn mobileCompanyReturn) + { + RollBackExcute(aDiscountValue.DiscountType,MobileCompanyReturn.PaySEQ); + } + break; + } + } + } + } + + + #endregion + + #region Discount RollBack Process + private void RollBackExcute(PaymentsDiscountAndAddType _discountType, long _paySEQ) + { + TimerEnabled = false; + try + { + using (var posRollBack = new posPaymentsCancel()) + { + CurrentRollBakType = _discountType; + if (posRollBack != null) + { + posRollBack.ReadEnd += posRollBack_ReadEnd; + posRollBack.ErrorEvent += posRollBack_ErrorEvent; + posRollBack.ErrorMessageEvent += posRollBack_ErrorMessageEvent; + posRollBack.StartProcessing(_paySEQ); + posRollBack.ReadEnd -= posRollBack_ReadEnd; + posRollBack.ErrorEvent -= posRollBack_ErrorEvent; + posRollBack.ErrorMessageEvent -= posRollBack_ErrorMessageEvent; + } + + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "RollBackExcute()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + TimerEnabled = true; + } + } + + + #endregion + + private bool GetReserveHappyPoint() + { + bool result = false; + try + { + if (HappyPointReturn is M_HappyPointReturn) + { + result = HappyPointReturn.ReservePoint; + } + } + catch + { + result = false; + } + return result; + } + private bool GetReserveOKChashBag() + { + bool result = false; + try + { + if (OkCashBagReturn is M_OkCashBagReturn) + { + result = OkCashBagReturn.ReservePoint; + } + } + catch + { + result = false; + } + return result; + } + + + private void TimeOutEnd() + { + DiscountsRollBack(); + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = true, + ReturnLanguage = ShowLanguageType, + PopupArgs = DetailBasketData is ObservableCollection + ? DetailBasketData.ToList() + : null , + }; + CanWindowClose = true; + } + private void RollBacklEnd() + { + DiscountsRollBack(); + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = DetailBasketData is ObservableCollection + ? DetailBasketData.ToList() + : null, + }; + CanWindowClose = true; + } + private void ProcessOK() + { + ReturnValue = new M_PopupReturn + { + OKAnswer = true, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + #endregion Methods + + #region [ Event Handlers ] + private void PBPaymentsViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "IsTimeout": + if (IsTimeout) TimeOutEnd(); + break; + case "ShowLanguageType": + switch (ShowLanguageType) + { + case SupportLanguageType.ko: + GmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_kor.png", CommonValue.PBdesignImagesPath); + break; + case SupportLanguageType.en: + GmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_eng.png", CommonValue.PBdesignImagesPath); + break; + case SupportLanguageType.ja: + GmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_jap.png", CommonValue.PBdesignImagesPath); + break; + case SupportLanguageType.zh: + GmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_chi.png", CommonValue.PBdesignImagesPath); + break; + } + break; + case "DefaultPage": + switch (DefaultPage) + { + case PBPaymentPageType.DetailBasket: + InitailizeDetailBasket(); + break; + case PBPaymentPageType.PointsDisCounts: + InitailizePointsDisCounts(); + break; + case PBPaymentPageType.CouponUsePoints: + InitailizeCouponUsePoints(); + break; + case PBPaymentPageType.MoreVIewPoints: + InitailizeMoreView(); + break; + case PBPaymentPageType.PaymentExcute: + InitailizePaymentExcute(); + break; + } + break; + case "DetailBasketData": + SubDataReset(); + if (DetailBasketData is ObservableCollection + && DetailBasketData.Count > 0) + { + foreach (var DetailItem in DetailBasketData) + { + DetailItem.PropertyChanged += DetailItem_PropertyChanged; + } + SetBasketSum(); + } + else + { + RollBacklEnd(); + } + break; + case "ScanItemPageNo": + ScanPage2LeftEnable = !ScanItemPageNo.Equals(0); + ScanPage2RightEnable = !ScanItemPageNo.Equals(ScanItemPageCount.Equals(0) ? 0: ScanItemPageCount-1); + break; + case "OrderItemPageNo": + OrderPage2LeftEnable = !OrderItemPageNo.Equals(0); + OrderPage2RightEnable = !OrderItemPageNo.Equals(OrderItemPageCount.Equals(0) ? 0 : OrderItemPageCount - 1); + break; + case "ScanItemPageCount": + ScanPageStatusColumnCount = ScanItemPageCount; + ScanItemPageStatus = SetPageNumber(ScanItemPageCount); + break; + case "OrderItemPageCount": + OrderPageStatusColumnCount = OrderItemPageCount; + OrderItemPageStatus = SetPageNumber(OrderItemPageCount); + break; + case "DiscountValues": + SetDiscountValue(); + break; + case "MemberLoginOK": + GmbHappyPointEnable = !MemberLoginOK; + break; + case "HappyPointReturn": + if (HappyPointReturn is M_HappyPointReturn happyPointReturn) + { + HappyPointResrveSwitch = happyPointReturn.ReservePoint; + } + else + { + HappyPointResrveSwitch = false; + } + break; + case "HappyPointResrveSwitch": + OkCashBagResrveEnable = !HappyPointResrveSwitch; + break; + case "OkCashBagReturn": + if (OkCashBagReturn is M_OkCashBagReturn okCashBagReturn) + { + OkCashBagResrveSwitch = okCashBagReturn.ReservePoint; + } + else + { + OkCashBagResrveSwitch = false; + } + break; + case "OkCashBagResrveSwitch": + HappyPointResrveEnable = !OkCashBagResrveSwitch; + break; + case "MobileCompanyReturn": + if (MobileCompanyReturn is M_MobileCompanyReturn mobileCompanyReturn) + { + if (mobileCompanyReturn.DiscountValue > 0) + { + switch (mobileCompanyReturn.Company) + { + case MobileCompanyType.SK_Telecom: + DiscountSKSwitch = true; + break; + case MobileCompanyType.KT_Mobile: + DiscountKTSwitch = true; + break; + case MobileCompanyType.LG_Uplus: + DiscountLGSwitch = true; + break; + } + } + } + break; + case "DiscountSKSwitch": + DiscountKTEnable = !DiscountSKSwitch; + DiscountLGEnable = !DiscountSKSwitch; + break; + case "DiscountKTSwitch": + DiscountSKEnable = !DiscountKTSwitch; + DiscountLGEnable = !DiscountKTSwitch; + break; + case "DiscountLGSwitch": + DiscountSKEnable = !DiscountLGSwitch; + DiscountKTEnable = !DiscountLGSwitch; + break; + case "TotalItemsPrice": + case "TotalDiscountValue": + TotalPriceForPayments = TotalItemsPrice - TotalDiscountValue; + break; + case "TotalPriceForPayments": + if (TotalPriceForPayments.Equals(0d)) OpenPaymentEndProcess(); + break; + } + } + private void DetailItem_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + LastAccessTime = DateTime.Now; + if (sender is M_BasketItem updatedItem) + { + using (var posDataService = new PosDataService()) + { + posDataService.UpdatedItem(updatedItem); + } + } + SetBasketSum(); + } + + + + #region GMB Right Click + + private void CallEmployeeCommandHandler(object obj) + { + TimerEnabled = false; + try + { + var popupReturn = popupManager.OpenCallEmployee(); + if (popupReturn is M_PopupReturn) + { + if (popupReturn.TimeOut) + { + TimeOutEnd(); + return; + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "CallEmployeeCommandHandler()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + TimerEnabled = true; + } + } + private void LanguageCommandHandler(object obj) + { + TimerEnabled = false; + try + { + var popupReturn = popupManager.OpenLanguageSelector(ShowLanguageType); + if (popupReturn is M_PopupReturn) + { + if (popupReturn.TimeOut) + { + TimeOutEnd(); + return; + } + else + { + ShowLanguageType = popupReturn.ReturnLanguage; + } + } + } + catch + { + throw; + } + finally + { + TimerEnabled = true; + } + } + private void GotoIntroPageCommadHandler(object obj) + { + TimerEnabled=false; + try + { + var miniPopup = new M_MiniPopup + { + Icon = MiniPopupIcon.Cancel, + DisplayLanguage = ShowLanguageType, + Message = Languages.GetMessages("LBL0085"), + CencalButtonText = Languages.GetMessages("BTN0021"), + OkButtonText = Languages.GetMessages("BTN0005"), + IsCencalButton = true, + TimeoutSeconds = 10, + }; + var popupReturn = popupManager.OpenMiniPopup(miniPopup); + if (popupReturn is M_PopupReturn && popupReturn.OKAnswer) + { + TimeOutEnd(); + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GotoIntroPageCommadHandler()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + { + TimerEnabled = true; + } + + } + #endregion + + #region Contents Click + private void GotoPointsDisCountsCommandHandler(object obj) + { + DefaultPage = PBPaymentPageType.PointsDisCounts; + } + + private void GotoCouponUsePointsCommandHandler(object obj) + { + DefaultPage = PBPaymentPageType.CouponUsePoints; + } + + private void GotoPaymentExcuteCommandHandler(object obj) + { + DefaultPage = PBPaymentPageType.PaymentExcute; + } + private void ScanPage2LeftCommandHandler(object obj) + { + ScanItemPageNo -= 1; + } + + private void ScanPage2RightCommandHandler(object obj) + { + ScanItemPageNo += 1; + } + + private void OrderPage2LeftCommandHandler(object obj) + { + OrderItemPageNo -= 1; + } + + private void OrderPage2RightCommandHandler(object obj) + { + OrderItemPageNo += 1; + } + private void ScanPageSelectCommandHandler(object obj) + { + if (obj is AnimationButton targetButton && targetButton.DataParameter is M_ItemData _ItemData) + { + ScanItemPageNo = ScanItemPageStatus.IndexOf(_ItemData); + } + } + private void OrderPageSelectCommandHandler(object obj) + { + if (obj is AnimationButton targetButton && targetButton.DataParameter is M_ItemData _ItemData) + { + OrderItemPageNo = OrderItemPageStatus.IndexOf(_ItemData); + } + } + + + private void ScanBarcodeDeleteCommandHandler(object obj) + { + if (obj is M_BasketItem deleteItem) + { + DeleteBasketItem(deleteItem); + } + } + + private void OrderDeleteCommandHandler(object obj) + { + if (obj is M_BasketItem deleteItem) + { + DeleteBasketItem(deleteItem); + } + } + private void ScanBarcodeAllDeleteCommandHandler(object obj) + { + TimerEnabled = false; + try + { + var miniPopup = new M_MiniPopup + { + Icon = MiniPopupIcon.Delete, + DisplayLanguage = ShowLanguageType, + Message = Languages.GetMessages("LBL0094"), + CencalButtonText = Languages.GetMessages("BTN0021"), + OkButtonText = Languages.GetMessages("BTN0005"), + IsCencalButton = true, + TimeoutSeconds = 10, + }; + var popupReturn = popupManager.OpenMiniPopup(miniPopup); + if (popupReturn is M_PopupReturn && popupReturn.OKAnswer) + { + DeleteScanAndBarcordItem(); + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ScanBarcodeAllDeleteCommandHandler()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + TimerEnabled = true; + } + } + + private void OrderAllDeleteCommandHandler(object obj) + { + TimerEnabled = false; + try + { + var topMessage = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "커피주문 제품들을 삭제하시겠습니까?" + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "en커피주문 제품들을 삭제하시겠습니까?" + }, + }; + var miniPopup = new M_MiniPopup + { + Icon = MiniPopupIcon.Delete, + DisplayLanguage = ShowLanguageType, + Message = topMessage, + CencalButtonText = Languages.GetMessages("BTN0021"), + OkButtonText = Languages.GetMessages("BTN0005"), + IsCencalButton = true, + TimeoutSeconds = 10, + }; + var popupReturn = popupManager.OpenMiniPopup(miniPopup); + if (popupReturn is M_PopupReturn && popupReturn.OKAnswer) + { + DeleteSelfOrderItem(); + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OrderAllDeleteCommandHandler()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + TimerEnabled = true; + } + } + + private void HappyPointResrveCommadHandler(object _param) + { + if (HappyPointReturn is M_HappyPointReturn happyPointReturn) + { + if (happyPointReturn.ReservePoint) + { + happyPointReturn.ReservePoint = false; + HappyPointResrveSwitch = false; + } + else + { + happyPointReturn.ReservePoint = true; + HappyPointResrveSwitch = true; + } + } + else + { + OpenReserveHappyPoint(); + } + } + + private void OkCashBagResrveCommandHandler(object _param) + { + if (OkCashBagReturn is M_OkCashBagReturn okCashBagReturn + && okCashBagReturn.ReservePoint) + { + OkCashBagReturn = null; //적립 취소 + } + else + { + OpenReserveOkCashBag(); + } + } + + + private void DiscountSKCommandHandler(object _param) + { + MobileCompanyDiscountExcute(MobileCompanyType.SK_Telecom); + } + private void DiscountKTCommandHandler(object _param) + { + MobileCompanyDiscountExcute(MobileCompanyType.KT_Mobile); + } + private void DiscountLGCommandHandler(object _param) + { + MobileCompanyDiscountExcute(MobileCompanyType.LG_Uplus); + } + + private void HappyPointUsingCommandHandler(object _param) + { + if (HappyPointReturn is M_HappyPointReturn happyPointReturn + && happyPointReturn.PointUse + && happyPointReturn.UsingPoints > 0 + && HappyPointUsingSwitch) + { + if (OpenRollbackConfirmDiscountOrPayments(PaymentsDiscountAndAddType.HappyPoint)) + { + TimerEnabled = false; + WaitWindowFrom.ShowWaitWindow(); + RollBackExcute(PaymentsDiscountAndAddType.HappyPoint, HappyPointReturn.PaySEQ); + WaitWindowFrom.CloseWaitWindow(); + TimerEnabled = true; + } + } + else + { + OpenHappyPointUsing(); + } + } + + + private void OkCashBagUsingCommandHandler(object _param) + { + + } + + private void MoreViewCommandHandler(object _param) + { + DefaultPage = PBPaymentPageType.MoreVIewPoints; + } + + private void MoreViewReturnCommandHandler(object _param) + { + DefaultPage = PBPaymentPageType.CouponUsePoints; + } + + private void HappyAppMyCouponCommandHandler(object _param) + { + if (UsingHappyAppCoupon is M_HappyCoupon happyAppCoupon + && happyAppCoupon.IsUsed) + { + if (OpenRollbackConfirmDiscountOrPayments(PaymentsDiscountAndAddType.HappyCoupon)) + { + TimerEnabled = false; + WaitWindowFrom.ShowWaitWindow(); + RollBackExcute(PaymentsDiscountAndAddType.HappyCoupon, UsingHappyAppCoupon.PaySEQ); + WaitWindowFrom.CloseWaitWindow(); + TimerEnabled = true; + } + } + else + { + OpenHappyAppCoupon(); + } + } + private void MobileCouponCommandHandler(object _param) + { + if (MobileCouponReturn is M_MobileCouponReturn mobileCouponReturn + && mobileCouponReturn.TotalUseAmount > 0) + { + if (OpenRollbackConfirmDiscountOrPayments(PaymentsDiscountAndAddType.MobileCoupon)) + { + TimerEnabled = false; + WaitWindowFrom.ShowWaitWindow(); + foreach (var aCoupon in mobileCouponReturn.VirtureCoupons) + { + if (aCoupon.PaySEQ > -1) RollBackExcute(PaymentsDiscountAndAddType.MobileCoupon, aCoupon.PaySEQ); + } + WaitWindowFrom.CloseWaitWindow(); + TimerEnabled = true; + } + } + else + { + OpenMobileCoupon(); + } + + } + + private void ICcardCommandHandler(object _param) + { + OpenPaymetsProcess(LastPaymentsType.IcCard); + } + + + private void LGSSpayCommandHandler(object _param) + { + OpenPaymetsProcess(LastPaymentsType.SsLgPay); + } + + private void CashBeeCommandHandler(object _param) + { + } + + private void HappyGiftCommandHandler(object _param) + { + } + + private void TmoneyCommandHandler(object _param) + { + } + + private void SPCemployeeCommandHandler(object _param) + { + } + + private void KakaoPayCommandHandler(object _param) + { + } + + private void SmilePayCommandHandler(object _param) + { + OpenPaymetsProcess(LastPaymentsType.SmilePay); + } + + private void AliPayCommandHandler(object _param) + { + } + + private void ZeroPayCommandHandler(object _param) + { + } + #endregion + + #region PaymentsList Click + private void DetailBasketDeleteAllCommandHandler(object _param) + { + + TimerEnabled = false; + try + { + var miniPopup = new M_MiniPopup + { + Icon = MiniPopupIcon.ListCancel, + DisplayLanguage = ShowLanguageType, + Message = Languages.GetMessages("LBL0099"), + CencalButtonText = Languages.GetMessages("BTN0021"), + OkButtonText = Languages.GetMessages("BTN0005"), + IsCencalButton = true, + TimeoutSeconds = 10, + }; + var popupReturn = popupManager.OpenMiniPopup(miniPopup); + if (popupReturn is M_PopupReturn && popupReturn.OKAnswer) + { + DeledteAllBasket(); + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "DetailBasketDeleteAllCommandHandler()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + TimerEnabled = true; + } + + } + + private void GotoLeftCommandHandler(object _param) + { + switch (DefaultPage) + { + case PBPaymentPageType.DetailBasket: + RollBacklEnd(); + break; + case PBPaymentPageType.PointsDisCounts: + case PBPaymentPageType.CouponUsePoints: + case PBPaymentPageType.PaymentExcute: + TimerEnabled = false; + try + { + var miniPopup = new M_MiniPopup + { + Icon = MiniPopupIcon.OrderCancel, + DisplayLanguage = ShowLanguageType, + Message = Languages.GetMessages("LBL0100"), + CencalButtonText = Languages.GetMessages("BTN0021"), + OkButtonText = Languages.GetMessages("BTN0005"), + IsCencalButton = true, + TimeoutSeconds = 10, + }; + var popupReturn = popupManager.OpenMiniPopup(miniPopup); + if (popupReturn is M_PopupReturn && popupReturn.OKAnswer) + { + RollBacklEnd(); + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GotoLeftCommandHandler()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + TimerEnabled = true; + } + break; + } + } + + private void GotoRightCommandHandler(object _param) + { + switch (DefaultPage) + { + case PBPaymentPageType.DetailBasket: + DefaultPage = PBPaymentPageType.PointsDisCounts; + break; + case PBPaymentPageType.PointsDisCounts: + DefaultPage = PBPaymentPageType.CouponUsePoints; + break; + case PBPaymentPageType.CouponUsePoints: + DefaultPage = PBPaymentPageType.PaymentExcute; + break; + } + } + + #region Discount Rollback Events + private void posRollBack_ReadEnd(object sender) + { + if (sender is posPaymentsCancel getRollBack) + { + if (getRollBack.ProcessOK) + { + RemoveDiscountValue(CurrentRollBakType); + switch (CurrentRollBakType) + { + case PaymentsDiscountAndAddType.HappyPoint: + if (HappyPointReturn is M_HappyPointReturn happyPointReturn) + { + HappyPointReturn.PaySEQ = -1L; + HappyPointReturn.PointUse = false; + HappyPointReturn.UsingPoints = 0d; + } + HappyPointUsingSwitch = false; + break; + case PaymentsDiscountAndAddType.OkCashBagPoint: + break; + case PaymentsDiscountAndAddType.HappyCoupon: + HappyAppMyCouponSwitch = false; + UsingHappyAppCoupon = null; + break; + case PaymentsDiscountAndAddType.MobileCoupon: + MobileCouponSwitch = false; + MobileCouponReturn = null; + break; + case PaymentsDiscountAndAddType.SkTelecomDiscount: + DiscountSKSwitch = false; + MobileCompanyReturn = null; + break; + case PaymentsDiscountAndAddType.AllehKTDiscount: + DiscountKTSwitch = false; + MobileCompanyReturn = null; + break; + case PaymentsDiscountAndAddType.LGUPlusDisCount: + DiscountLGSwitch = false; + MobileCompanyReturn = null; + break; + } + } + } + } + + private void posRollBack_ErrorEvent(posPaymentsCancel.ErrorCode _errorCode) + { + var errorText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = _errorCode.ToString() + }, + }; + KioskMessageBox.ShowMessageBox(errorText + , MessageBoxButton.OK + , OpenCloseAnimationType.FullSizeUp + , OpenCloseAnimationType.FullSizeDown + , 0.5, 0.2, 5); + } + + #endregion + + #region Common Rollback Error Message Popup Event + private void posRollBack_ErrorMessageEvent(string ErrorString) + { + var errorText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = ErrorString.Replace("\n"," ").Replace("\r","") + }, + }; + KioskMessageBox.ShowMessageBox(errorText + , MessageBoxButton.OK + , OpenCloseAnimationType.FullSizeUp + , OpenCloseAnimationType.FullSizeDown + , 0.5, 0.2, 5); + } + #endregion + + #endregion + + #endregion Event Handlers + } +} diff --git a/Kiosk/PB/SPC.Kiosk.PB.ViewModel/PBViewModel.cs b/Kiosk/PB/SPC.Kiosk.PB.ViewModel/PBViewModel.cs new file mode 100644 index 0000000..56331d8 --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB.ViewModel/PBViewModel.cs @@ -0,0 +1,2853 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.IO; +using System.ComponentModel; +using System.Windows.Input; +using System.Windows.Media.Animation; +using System.Windows; +using System.Collections.ObjectModel; +using System.Text.RegularExpressions; +using System.Windows.Threading; +using System.Threading.Tasks; +using System.Windows.Controls; +#region SPC.Kiosk +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.DataHelper; +using SPC.Kiosk.PB.Model; +using SPC.Kiosk.Popup; +using SPC.Kiosk.Popup.Model; +using System.Threading; +#endregion +namespace SPC.Kiosk.PB.ViewModel +{ + /// + /// PBWindow View Model + /// + public class VmPBViewModel : ViewModelBase + { + #region [ Members ] + private PopupManager popupManager = PopupManager.GetInstance; + private BackDataService backDataService; + private Queue scanQueue = new Queue(); + private bool IsScanProcess = true; + private Task ScanProcess = null; + //public Dictionary PosOptionValues; + + private string optionValue810; + /// + /// 자동계산 사용여부 + /// + public string OptionValue810 + { + get { return optionValue810; } + set { optionValue810 = value; PropertyChange("OptionValue810"); } + } + private string optionValue811; + /// + /// 바코드계산 사용여부 + /// + public string OptionValue811 + { + get { return optionValue811; } + set { optionValue811 = value; PropertyChange("OptionValue811"); } + } + + private string optionValue812; + /// + /// 직원호출 사용여부 + /// + public string OptionValue812 + { + get { return optionValue812; } + set { optionValue812 = value; PropertyChange("OptionValue812"); } + } + + /// + /// 처리중 화면 + /// + public WaitWindow WaitWindowFrom { get; set; } + private DispatcherTimer ToIntoroTimer; + /// + /// 입력 대기 초과시 연장 팝업 사용 유무 + /// + public bool IsTimeoutPopup { get; set; } = false; + private DateTime LastAccessTime { get; set; } + /// + /// 대기 화면에서 다음 화면 연결시 옵션 + /// + public string DefaultLinkValue { get; set; } + /// + /// 상품 목록 초기화 필요 유무 + /// + public bool NeedIntailizeItems { get; set; } + + private SupportLanguageType showLanguageType; + /// + /// 다국어 코드 + /// + public SupportLanguageType ShowLanguageType + { + get { return showLanguageType; } + set { showLanguageType = value; PropertyChange("ShowLanguageType"); } + } + private PBPageType defaultPage = PBPageType.Intro; + /// + /// 현재 화면 + /// + public PBPageType DefaultPage + { + get { return defaultPage; } + set { defaultPage = value; PropertyChange("DefaultPage"); } + } + private bool canWindowClose = false; + /// + /// 화면 닫기 (true 이면 바로 닫음) + /// + public bool CanWindowClose + { + get { return canWindowClose; } + set { canWindowClose = value; PropertyChange("CanWindowClose"); } + } + + #region Intro & Page + private ObservableCollection introItems; + /// + /// 대기 화면 Contents + /// + public ObservableCollection IntroItems + { + get { return introItems; } + set { introItems = value; PropertyChange("IntroItems"); } + } + private M_HappyPointReturn happyPointReturn; + /// + /// 해피 포인트 인증 정보 + /// + public M_HappyPointReturn HappyPointReturn + { + get { return happyPointReturn; } + set { happyPointReturn = value; PropertyChange("HappyPointReturn"); } + } + /// + /// Alt+F4 대한 Command + /// + public ICommand ToExecuteNothing { get; protected set; } = null; + /// + /// 대기 화면 클릭 + /// + public ICommand RollMediaCommand { get; protected set; } = null; + + #endregion + + #region GMB + + #region GMB Left + /// + /// 공통 메뉴 로고 + /// + public string GmbLogo { get; set; } = ResourceManager.GetNximagePathAdd("Img_main_logo.png", CommonValue.PBdesignImagesPath); + /// + /// 공통 메뉴 관리자 기능 클릭 + /// + public ICommand ReaderCheckCommand { get; protected set; } = null; + /// + /// 로로 클릭 > 홈 화면으로 이동 + /// + public ICommand GotoFirstCommand { get; protected set; } = null; + /// + /// 관리자 기능 클릭 수 + /// + public int ReaderCheckClickCount { get; set; } = 0; + private bool gmbReaderCheckOpen = false; + /// + /// 관리자 기늘 오픈 + /// + public bool GmbReaderCheckOpen + { + get { return gmbReaderCheckOpen; } + set { gmbReaderCheckOpen = value; PropertyChange("GmbReaderCheckOpen"); } + } + #endregion + + #region GMB Center + /// + /// 공통 토글 메뉴 배경 (센싱,일반주문 전환 배경) + /// + public string GmbToggleOff { get; set; } = ResourceManager.GetNximagePathAdd("Btn_toggle_off.png", CommonValue.PBdesignImagesPath); + /// + /// 공통 토글 메뉴 전경 (센싱,일반주문 전환 전경) + /// + public string GmbToggleOn { get; set; } = ResourceManager.GetNximagePathAdd("Btn_toggle_on.png", CommonValue.PBdesignImagesPath); + /// + /// 자동 주문 배경 + /// + public string GmbAIscannerNormal { get; set; } = ResourceManager.GetNximagePathAdd("Ic_ai_off.png", CommonValue.PBdesignImagesPath); + /// + /// 자동 주문 Disable 배경 + /// + public string GmbAIscannerDisable { get; set; } = ResourceManager.GetNximagePathAdd("Ic_ai_on.png", CommonValue.PBdesignImagesPath); + private bool gmbAIscannerEnable; + /// + /// 자동 주문 버튼 Enabled + /// + public bool GmbAIscannerEnable + { + get { return gmbAIscannerEnable; } + set { gmbAIscannerEnable = value; PropertyChange("GmbAIscannerEnable"); } + } + /// + /// 일반 주문 배경 + /// + public string GmbOrderNormal { get; set; } = ResourceManager.GetNximagePathAdd("Ic_order_off.png", CommonValue.PBdesignImagesPath); + /// + /// 일반 주문 Disable 배경 + /// + public string GmbOrderDisable { get; set; } = ResourceManager.GetNximagePathAdd("Ic_order_on.png", CommonValue.PBdesignImagesPath); + private bool gmbOrderEnable; + /// + /// 일반 주문 버튼 Enabled + /// + public bool GmbOrderEnable + { + get { return gmbOrderEnable; } + set { gmbOrderEnable = value; PropertyChange("GmbOrderEnable"); } + } + /// + /// 자동 주문 Command + /// + public ICommand GmbAIscannerCommand { get; protected set; } = null; + /// + /// 일반 주문 Command + /// + public ICommand GmbOrderCommand { get; protected set; } = null; + private string gmbMemberName; + /// + /// 해피 포인트 가입 고객명 + /// + public string GmbMemberName + { + get { return gmbMemberName; } + set { gmbMemberName = value; PropertyChange("GmbMemberName"); } + } + /// + /// 해피 포인트 안내 배경 + /// + public string GmbHappyInfoBackGround { get; set; } = ResourceManager.GetNximagePathAdd("btn_happypoint_info.png", CommonValue.PBdesignImagesPath); + private bool gmbHappyInfoEnable = false; + /// + /// 해피 포인트 안내 Enabled + /// + public bool GmbHappyInfoEnable + { + get { return gmbHappyInfoEnable; } + set { gmbHappyInfoEnable = value; PropertyChange("GmbHappyInfoEnable"); } + } + /// + /// 해피 포인트 안내 표시 시점 + /// + public DateTime GmbHappyInfoEnableTime { get; set; } + #endregion + + #region GMB Right + /// + /// 해피 포인트 로그인 아이콘 + /// + public string GmbHappyPointimage { get; set; } = ResourceManager.GetNximagePathAdd("btn_happypoint_d.png", CommonValue.PBdesignImagesPath); + /// + /// 해피 포인트 로그인 Disabled 아이콘 + /// + public string GmbHappyPointDisable { get; set; } = ResourceManager.GetNximagePathAdd("btn_happypoint_n.png", CommonValue.PBdesignImagesPath); + /// + /// 직원 호출 아이콘 + /// + public string GmbCallimage { get; set; } = ResourceManager.GetNximagePathAdd("btn_help.png", CommonValue.PBdesignImagesPath); + /// + /// 로그 아웃 아이콘 + /// + public string GmbHomeimage { get; set; } = ResourceManager.GetNximagePathAdd("btn_reset.png", CommonValue.PBdesignImagesPath); + private string gmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_kor.png", CommonValue.PBdesignImagesPath); + /// + /// 다국어 변경 아이콘 + /// + public string GmbLanguageimage + { + get { return gmbLanguageimage; } + set { gmbLanguageimage = value; PropertyChange("GmbLanguageimage"); } + } + private bool gmbHome = true; + /// + /// 로그 아웃 Enabled + /// + public bool GmbHome + { + get { return gmbHome; } + set { gmbHome = value; PropertyChange("GmbHome"); } + } + private bool gmbHappyPointEnable = true; + /// + /// 해피 포인트 로그인 Enabled + /// + public bool GmbHappyPointEnable + { + get { return gmbHappyPointEnable; } + set { gmbHappyPointEnable = value; PropertyChange("GmbHappyPointEnable"); } + } + private bool gmbEmpCall = true; + /// + /// 직원 호출 Enabled + /// + public bool GmbEmpCall + { + get { return gmbEmpCall; } + set { gmbEmpCall = value; PropertyChange("GmbEmpCall"); } + } + private bool gmbLanguage = true; + /// + /// 다국어 변경 Enabled + /// + public bool GmbLanguage + { + get { return gmbLanguage; } + set { gmbLanguage = value; PropertyChange("GmbLanguage"); } + } + private bool memberLoginOK = false; + /// + /// 해피 포인트 로그인 유무 + /// + public bool MemberLoginOK + { + get { return memberLoginOK; } + set { memberLoginOK = value; PropertyChange("MemberLoginOK"); } + } + /// + /// 해피 포인트 로그인 Command + /// + public ICommand HappyPointCommand { get; protected set; } = null; + /// + /// 직원 호출 Command + /// + public ICommand CallEmployeeCommand { get; protected set; } = null; + /// + /// 다국어 변경 Command + /// + public ICommand LanguageCommand { get; protected set; } = null; + /// + /// 로그 아웃 Command + /// + public ICommand GotoIntroPageCommand { get; protected set; } = null; + + #endregion + + + #endregion + + #region First Page Contents + /// + /// 홈페이지 자동 주문 배경 + /// + public string First2CameraBackNormal { get; set; } = ResourceManager.GetNximagePathAdd("btn_main_camerascan_n.png", CommonValue.PBdesignImagesPath); + /// + /// 홈페이지 자동 주문 마우스 다운 배경 + /// + public string First2CameraBackDown { get; set; } = ResourceManager.GetNximagePathAdd("btn_main_camerascan_f.png", CommonValue.PBdesignImagesPath); + /// + /// 홈페이지 일반 주문 배경 + /// + public string First2SelfOrderBackNormal { get; set; } = ResourceManager.GetNximagePathAdd("btn_main_selforder_n.png", CommonValue.PBdesignImagesPath); + /// + /// 홈페이지 일반 주문 마우스 다운 배경 + /// + public string First2SelfOrderBackDown { get; set; } = ResourceManager.GetNximagePathAdd("btn_main_selforder_f.png", CommonValue.PBdesignImagesPath); + + #endregion + + #region Items Contents + + #region Category + /// + /// Category1 Background + /// + public string Category1Background { get; set; } = ResourceManager.GetNximagePathAdd("btn_main_menu_n.png", CommonValue.PBdesignImagesPath); + /// + /// All Category Data + /// + public List AllCategory { get; set; } + + private ObservableCollection category1Data; + /// + /// Category1 Data + /// + public ObservableCollection Category1Data + { + get { return category1Data; } + set { category1Data = value; PropertyChange("Category1Data"); } + } + private ObservableCollection category2Data; + /// + /// Category2 Data + /// + public ObservableCollection Category2Data + { + get { return category2Data; } + set { category2Data = value; PropertyChange("Category2Data"); } + } + private int defaultCategory1Item; + /// + /// Default Category1 Item + /// + public int DefaultCategory1Item + { + get { return defaultCategory1Item; } + set { defaultCategory1Item = value; PropertyChange("DefaultCategory1Item"); } + } + private int defaultCategory2Item; + /// + /// Default Category2 Item + /// + public int DefaultCategory2Item + { + get { return defaultCategory2Item; } + set { defaultCategory2Item = value; PropertyChange("DefaultCategory2Item"); } + } + private int defaultCategory1PageNo; + /// + /// Default Category1 Page No + /// + public int DefaultCategory1PageNo + { + get { return defaultCategory1PageNo; } + set { defaultCategory1PageNo = value; PropertyChange("DefaultCategory1PageNo"); } + } + private int defaultCategory2PageNo; + /// + /// Default Category2 Page No + /// + public int DefaultCategory2PageNo + { + get { return defaultCategory2PageNo; } + set { defaultCategory2PageNo = value; PropertyChange("DefaultCategory2PageNo"); } + } + /// + /// Category1 Commad + /// + public ICommand Category1Command { get; protected set; } = null; + /// + /// Category2 Commad + /// + public ICommand Category2Command { get; protected set; } = null; + /// + /// OrderHistory Command (open) + /// + public ICommand OrderHistoryCommand { get; protected set; } = null; + /// + /// OrderHistory Close Command + /// + public ICommand OrderHistoryCloseCommand { get; protected set; } = null; + #endregion + + #region Items + /// + /// AllI tems + /// + public List AllItems { get; set; } + /// + /// Order(item) Column Count + /// + public int OrderColumnCount { get; set; } + /// + /// Order(item) Row Count + /// + public int OrderRowCount { get; set; } + private int defaultOrderItem; + /// + /// Default Order Item + /// + public int DefaultOrderItem + { + get { return defaultOrderItem; } + set { defaultOrderItem = value; PropertyChange("DefaultOrderItem"); } + } + private int orderItemPageNo; + /// + /// Default Order Item Page No + /// + public int OrderItemPageNo + { + get { return orderItemPageNo; } + set { orderItemPageNo = value; PropertyChange("OrderItemPageNo"); } + } + + private ObservableCollection orderItems; + /// + /// Order Items Data + /// + public ObservableCollection OrderItems + { + get { return orderItems; } + set { orderItems = value; PropertyChange("OrderItems"); } + } + /// + /// Item Command + /// + public ICommand ItemCommand { get; protected set; } = null; + /// + /// Page to Left Normal Image + /// + public string Page2LeftNormalImage { get; set; } = ResourceManager.GetNximagePathAdd("btn_page_before_n.png", CommonValue.PBdesignImagesPath); + /// + /// Page to Right Normal Image + /// + public string Page2RightNormalImage { get; set; } = ResourceManager.GetNximagePathAdd("btn_page_after_n.png", CommonValue.PBdesignImagesPath); + private bool page2LeftEnable; + /// + /// Page to Left Enabled + /// + public bool Page2LeftEnable + { + get { return page2LeftEnable; } + set { page2LeftEnable = value; PropertyChange("Page2LeftEnable"); } + } + private bool page2RightEnable; + /// + /// Page to Right Enabled + /// + public bool Page2RightEnable + { + get { return page2RightEnable; } + set { page2RightEnable = value; PropertyChange("Page2RightEnable"); } + } + /// + /// Page to Left Command + /// + public ICommand Page2LeftCommand { get; protected set; } = null; + /// + /// Page to Right Command + /// + public ICommand Page2RightCommand { get; protected set; } = null; + + private ObservableCollection itemPageStatus; + /// + /// Item Page Status + /// + public ObservableCollection ItemPageStatus + { + get { return itemPageStatus; } + set { itemPageStatus = value; PropertyChange("ItemPageStatus"); } + } + private int pageStatusColumnCount; + /// + /// Page Status Column Count + /// + public int PageStatusColumnCount + { + get { return pageStatusColumnCount; } + set { pageStatusColumnCount = value; PropertyChange("PageStatusColumnCount"); } + } + /// + /// Page Select Command + /// + public ICommand PageSelectCommand { get; protected set; } = null; + + #endregion + + #region Order History + /// + /// Order History Normal Brush + /// + public string OrderHistoryNormalBrush { get; set; } = ResourceManager.GetNximagePathAdd("Ic_mylist_d.png", CommonValue.PBdesignImagesPath); + /// + /// Order History Disable Brush + /// + public string OrderHistoryDisableBrush { get; set; } = ResourceManager.GetNximagePathAdd("Ic_mylist_n.png", CommonValue.PBdesignImagesPath); + /// + /// Order History Close NormalB rush + /// + public string CloseOrderHistoryNormalBrush { get; set; } = ResourceManager.GetNximagePathAdd("Ic_mylist_s.png", CommonValue.PBdesignImagesPath); + private bool orderHistoryView = false; + /// + /// Is Order History View + /// + public bool OrderHistoryView + { + get { return orderHistoryView; } + set { orderHistoryView = value; PropertyChange("OrderHistoryView"); } + } + private List findOrderHistoryItems; + /// + /// Find Order History Items + /// + public List FindOrderHistoryItems + { + get { return findOrderHistoryItems; } + set { findOrderHistoryItems = value; PropertyChange("FindOrderHistoryItems"); } + } + + private ObservableCollection orderHistoryItems; + /// + /// Order History Items + /// + public ObservableCollection OrderHistoryItems + { + get { return orderHistoryItems; } + set { orderHistoryItems = value; PropertyChange("OrderHistoryItems"); } + } + private bool orderHistoryItemsEnable; + /// + /// Order History Items Enable + /// + public bool OrderHistoryItemsEnable + { + get { return orderHistoryItemsEnable; } + set { orderHistoryItemsEnable = value; PropertyChange("OrderHistoryItemsEnable"); } + } + #endregion + #endregion Contents + + #region Scan Contents + /// + /// Scan Info GIF + /// + public string ScanInfoGIF { get; set; } = ResourceManager.GetNximagePathAdd("img_gif_barcodescan.gif", CommonValue.PBdesignImagesPath); + /// + /// Scan Header Bar + /// + public string ScanHeaderBar { get; set; } = ResourceManager.GetNximagePathAdd("Bl_bar.png", CommonValue.PBdesignImagesPath); + /// + /// Scan Payment1 Normal + /// + public string ScanPayment1Normal { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder_payment_n.png", CommonValue.PBdesignImagesPath); + /// + /// Scan Payment1 Down + /// + public string ScanPayment1Down { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder_payment_f.png", CommonValue.PBdesignImagesPath); + /// + /// Add Scan1 Normal + /// + public string AddScan1Normal { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder_camerascan_n.png", CommonValue.PBdesignImagesPath); + /// + /// Add Scan1 Down + /// + public string AddScan1Down { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder_camerascan_f.png", CommonValue.PBdesignImagesPath); + /// + /// Scan Order1 Normal + /// + public string ScanOrder1Normal { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder_selforder_n.png", CommonValue.PBdesignImagesPath); + /// + /// Scan Order1 Down + /// + public string ScanOrder1Down { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder_selforder_f.png", CommonValue.PBdesignImagesPath); + /// + /// Scan Button Small Normal + /// + public string ScanButtonSmallNormal { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder_n.png", CommonValue.PBdesignImagesPath); + /// + /// Scan Button Small Down + /// + public string ScanButtonSmallDown { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder_f.png", CommonValue.PBdesignImagesPath); + /// + /// Scan Button Large Normal + /// + public string ScanButtonLargeNormal { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder2_n.png", CommonValue.PBdesignImagesPath); + /// + /// Scan Button Large Down + /// + public string ScanButtonLargeDown { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder2_f.png", CommonValue.PBdesignImagesPath); + /// + /// Scan Button Normal + /// + public string ScanButtonNormal { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder3_n.png", CommonValue.PBdesignImagesPath); + /// + /// Scan Button Down + /// + public string ScanButtonDown { get; set; } = ResourceManager.GetNximagePathAdd("btn_addorder3_f.png", CommonValue.PBdesignImagesPath); + /// + /// Info Logo + /// + public string InfoLogo { get; set; } = ResourceManager.GetNximagePathAdd("ic_info.png", CommonValue.PBdesignImagesPath); + /// + /// Info LogoX + /// + public string InfoLogoX { get; set; } = ResourceManager.GetNximagePathAdd("btn_help.png", CommonValue.PBdesignImagesPath); + private PBSensingSubPageType sensingSubPage = PBSensingSubPageType.SensingPage; + /// + /// PB Sensing SubPage Type + /// + public PBSensingSubPageType SensingSubPage + { + get { return sensingSubPage; } + set { sensingSubPage = value; PropertyChange("SensingSubPage"); } + } + private string readBarCode; + /// + /// Read Barcode + /// + public string ReadBarCode + { + get { return readBarCode; } + set { readBarCode = value; PropertyChange("ReadBarCode"); } + } + private int aIScanCount; + /// + /// AI Scan Count + /// + public int AIScanCount + { + get { return aIScanCount; } + set { aIScanCount = value; PropertyChange("AIScanCount"); } + } + /// + /// Rescan Commad + /// + public ICommand RescanCommand { get; protected set; } = null; + /// + /// Goto Barcode Commad + /// + public ICommand GotoBarcodeCommand { get; protected set; } = null; + #endregion + + #region MiniBasket + /// + /// MiniBasket Delete All Image + /// + public string MiniBasketDeleteAllImage { get; set; } = ResourceManager.GetNximagePathAdd("btn_delete.png", CommonValue.PBdesignImagesPath); + private bool miniBasketDeleteAllEnable; + /// + /// MiniBasket Delete All Enabled + /// + public bool MiniBasketDeleteAllEnable + { + get { return miniBasketDeleteAllEnable; } + set { miniBasketDeleteAllEnable = value; PropertyChange("MiniBasketDeleteAllEnable"); } + } + /// + /// Empty Basket Image + /// + public string EmptyBasketImage { get; set; } = ResourceManager.GetNximagePathAdd("Ic_Basket.png", CommonValue.PBdesignImagesPath); + /// + /// Empty Basket DropCommand + /// + public ICommand EmptyBasketDropCommand { get; protected set; } = null; + /// + /// MiniBasket Delete All Command + /// + public ICommand MiniBasketDeleteAllCommand { get; protected set; } = null; + private Visibility orderNoneDataGridVisibility = Visibility.Visible; + /// + /// Order None Data Grid Visibility + /// + public Visibility OrderNoneDataGridVisibility + { + get { return orderNoneDataGridVisibility; } + set { orderNoneDataGridVisibility = value; PropertyChange("OrderNoneDataGridVisibility"); } + + } + private Visibility orderExistDataGridVisibility = Visibility.Hidden; + /// + /// Order Exist Data Grid Visibility + /// + public Visibility OrderExistDataGridVisibility + { + get { return orderExistDataGridVisibility; } + set { orderExistDataGridVisibility = value; PropertyChange("OrderExistDataGridVisibility"); } + + } + #region BasketItems + + private ObservableCollection miniBasketData; + /// + /// Mini Basket Data + /// + public ObservableCollection MiniBasketData + { + get { return miniBasketData; } + set { miniBasketData = value; PropertyChange("MiniBasketData"); } + } + /// + /// Basket Item Delete Command + /// + public ICommand BasketItemDeleteCommand { get; protected set; } = null; + #endregion + #region Total + /// + /// Order Total Payment Icon + /// + public string OrderTotalPaymentIcon { get; set; } = ResourceManager.GetNximagePathAdd("Ic_totalcost.png", CommonValue.PBdesignImagesPath); + private int orderTotalCount = 0; + /// + /// Order Total Count + /// + public int OrderTotalCount + { + get { return orderTotalCount; } + set { orderTotalCount = value; PropertyChange("OrderTotalCount"); } + + } + private double orderTotalPayment = 0d; + /// + /// Order Total Payment + /// + public double OrderTotalPayment + { + get { return orderTotalPayment; } + set { orderTotalPayment = value; PropertyChange("OrderTotalPayment"); } + + } + #endregion + #region Button + private bool orderDetailEnable; + /// + /// Order Detail Enabled + /// + public bool OrderDetailEnable + { + get { return orderDetailEnable; } + set { orderDetailEnable = value; PropertyChange("OrderDetailEnable"); } + } + /// + /// Order Detail Command + /// + public ICommand OrderDetailCommand { get; protected set; } = null; + + private bool gotoPaymentEnable; + /// + /// Goto Payment Enabled + /// + public bool GotoPaymentEnable + { + get { return gotoPaymentEnable; } + set { gotoPaymentEnable = value; PropertyChange("GotoPaymentEnable"); } + } + /// + /// Goto Payment Command + /// + public ICommand GotoPaymentCommand { get; protected set; } = null; + + private PBPaymentPageType openPBPaymentPage = PBPaymentPageType.DetailBasket; + /// + /// Open PB Payment Page + /// + public PBPaymentPageType OpenPBPaymentPage + { + get { return openPBPaymentPage; } + set { openPBPaymentPage = value; PropertyChange("OpenPBPaymentPage"); } + } + #endregion + #endregion MiniBasket + + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public VmPBViewModel() + { + WaitWindowFrom = WaitWindow.GetInstance; + InitViewModel(); + LastAccessTime = DateTime.Now; + ToIntoroTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1d), + }; + ToIntoroTimer.Tick += ToIntoroTimer_Tick; + backDataService = new BackDataService(); + } + + + /// + /// Dispose + /// + public void Dispose() + { + if (ScanProcess != null) + { + IsScanProcess = false; + ScanProcess.Wait(); + ScanProcess = null; + } + if (backDataService != null) + { + backDataService.Dispose(); + backDataService = null; + } + this.PropertyChanged -= VmPBViewModel_PropertyChanged; + if (WaitWindowFrom != null) + { + WaitWindowFrom.CloseWaitWindow(); + WaitWindowFrom = null; + } + if (ToIntoroTimer != null) + { + ToIntoroTimer.Stop(); + ToIntoroTimer.Tick -= ToIntoroTimer_Tick; + ToIntoroTimer = null; + } + if (popupManager != null) + { + popupManager = null; + } + GC.SuppressFinalize(this); + } + #endregion Ctor + + #region [ Methods ] + private void InitViewModel() + { + WaitWindowFrom.ShowWaitWindow(); + try + { + //Intro + SetCommon(); + SetIntro(); + ToExecuteNothing = new Command(ToExecuteNothingHandler); + RollMediaCommand = new Command(RollMediaCommandHandler); + //GMB Left + GotoFirstCommand = new Command(GotoFirstCommandHandler); + ReaderCheckCommand = new Command(ReaderCheckCommandHandler); + //GMB Right + LanguageCommand = new Command(LanguageCommandHandler); + HappyPointCommand = new Command(HappyPointCommandHandler); + CallEmployeeCommand = new Command(CallEmployeeCommandHandler); + GotoIntroPageCommand = new Command(GotoIntroPageCommadHandler); + //GMB Center + GmbAIscannerCommand = new Command(GmbAIscannerCommandHandler); + GmbOrderCommand = new Command(GmbOrderCommandHandler); + GmbAIscannerEnable = false; + //Scan Contents + RescanCommand = new Command(RescanCommandHandler); + GotoBarcodeCommand = new Command(GotoBarcodeCommandHandler); + //Item Contents + ItemCommand = new Command(ItemCommandCommandHandler); + Category1Command = new Command(Category1CommandHandler); + Category2Command = new Command(Category2CommandHandler); + OrderHistoryCommand = new Command(OrderHistoryCommandHandler); + OrderHistoryCloseCommand = new Command(OrderHistoryCloseCommandHandler); + Page2LeftCommand = new Command(Page2LeftCommandHandler); + Page2RightCommand = new Command(Page2RightCommandHandler); + OrderColumnCount = 5; + OrderRowCount = 2; + PageSelectCommand = new Command(PageSelectCommandHandler); + //MiniBasket + MiniBasketDeleteAllCommand = new Command(MiniBasketDeleteAllCommandHandler); + EmptyBasketDropCommand = new Command(EmptyBasketDropCommandHandler); + BasketItemDeleteCommand = new Command(BasketItemDeleteCommandHandler); + OrderDetailCommand = new Command(OrderDetailCommandHandler); + GotoPaymentCommand = new Command(GotoPaymentCommandHandler); + this.PropertyChanged += VmPBViewModel_PropertyChanged; + ShowLanguageType = CommonValue.CommonLanguageType; + ScanProcess = new Task(ScanDataProcessor); + ScanProcess.Start(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "InitViewModel()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + WaitWindowFrom.CloseWaitWindow(); + } + } + + private void SetCommon() + { +#if TESTMODE + using (var dataHelper = new CommonDataHelper()) + { + if (!dataHelper.NeedInitModule) dataHelper.SetCommonLanguage(); + } +#endif + + //PosOption 값 획득 + using (var backDataService = new BackDataService()) + { + this.OptionValue810 = backDataService.GetPosOption(nameof(PosOptionType.OPT810)); + this.OptionValue811 = backDataService.GetPosOption(nameof(PosOptionType.OPT811)); + this.OptionValue812 = backDataService.GetPosOption(nameof(PosOptionType.OPT812)); + + //if (this.PosOptionValues == null) this.PosOptionValues = new Dictionary(); + //if (!this.PosOptionValues.ContainsKey(nameof(PosOptionType.OPT810))) { this.PosOptionValues.Add(nameof(PosOptionType.OPT810), this.optionValue810); } + //if (!this.PosOptionValues.ContainsKey(nameof(PosOptionType.OPT811))) { this.PosOptionValues.Add(nameof(PosOptionType.OPT811), this.optionValue811); } + } + } + + + #region Intro + private void SetIntro() + { + + using (var dataHelper = new CommonDataHelper()) + { + var getIntro = dataHelper.GetIntroData(1920d); + if (getIntro is List && getIntro.Count > 0) + { + IntroItems = new ObservableCollection(getIntro); + } + else + { + #region Default Intro + IntroItems = new ObservableCollection + { + new M_IntroItems + { + ItemsStack=0, + StackWidth=1920, + StackContents = new List + { + new M_StackContents + { + ItemsIndex = 0, + MediaRollItems = new List + { + new M_MediaRollItem + { + Type = MediaType.Image, + MediaPath =ResourceManager.GetNximagePathAdd("nextstation_img.jpg", CommonValue.PBdesignImagesPath), + LinkType = IntroLinkType.Page, + LinkParameter = "FirstSelect", + RunnigSeconds =10 + }, + } + }, + new M_StackContents + { + ItemsIndex = 1, + MediaRollItems = new List + { + new M_MediaRollItem{ + Type = MediaType.Image, + MediaPath = ResourceManager.GetNximagePathAdd("nextstation_button.jpg", CommonValue.PBdesignImagesPath), + LinkType = IntroLinkType.Page, + LinkParameter = "ItemPage", + RunnigSeconds =10 + }, + } + } + } + }, + }; + #endregion + + } + } + } + #endregion Intro + + #region Contents + + #region Self Order + private void SetContents() + { + if (!string.IsNullOrEmpty(DefaultLinkValue)) + { + if (DefaultLinkValue.ToLower().StartsWith("category&")) + { + DataModelInit(); + var getCategory = DefaultLinkValue.Split('&'); + switch (getCategory.Length) + { + case 2: + DefaultCategory1Item = Category1Data.IndexOf(Category1Data.Where(r => r.Category1.Equals(getCategory[1])).FirstOrDefault()); + if (DefaultCategory1Item < 0) DefaultCategory1Item = 0; + DefaultCategory2Item = 0; + break; + case 3: + DefaultCategory1Item = Category1Data.IndexOf(Category1Data.Where(r => r.Category1.Equals(getCategory[1])).FirstOrDefault()); + if (DefaultCategory1Item < 0) DefaultCategory1Item = 0; + if (!string.IsNullOrEmpty(getCategory[2])) + { + DefaultCategory2Item = Category2Data.IndexOf(Category2Data.Where(r => r.Category2.Equals(getCategory[2])).FirstOrDefault()); + if (DefaultCategory2Item < 0) DefaultCategory2Item = 0; + } + else + { + DefaultCategory2Item = 0; + } + break; + default: + DefaultCategory1Item = 0; + DefaultCategory2Item = 0; + break; + } + DefaultOrderItem = 0; + } + else + { + DataModelInit(); + var findItem = AllItems.Where(r => r.ItemCode.Equals(DefaultLinkValue)).FirstOrDefault(); + if (findItem is M_ItemData) + { + DefaultCategory1Item = Category1Data.IndexOf(Category1Data.Where(r => r.Category1.Equals(findItem.Category1)).FirstOrDefault()); + DefaultCategory2Item = Category2Data.IndexOf(Category2Data.Where(r => r.Category2.Equals(findItem.Category2)).FirstOrDefault()); + DefaultOrderItem = OrderItems.IndexOf(OrderItems.Where(r => r.ItemCode.Equals(DefaultLinkValue)).FirstOrDefault()); + } + else + { + DefaultCategory1Item = 0; + DefaultCategory2Item = 0; + DefaultOrderItem = 0; + } + } + } + else + { + DataModelInit(); + DefaultCategory1Item = 0; + DefaultCategory2Item = 0; + DefaultOrderItem = 0; + } + } + private void DataModelInit() + { + try + { + if (NeedIntailizeItems) + { + ItemCacheClear(); + this.SetItemData(); + SetCategory1(); + + NeedIntailizeItems = false; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "DataModelInit()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + private void ItemCacheClear() + { + if (AllItems is List) + { + foreach (var aitem in AllItems) + { + if (aitem.DataParameter.NormalBrush != null) + { + CacheManager.CacheRemove(aitem.DataParameter.NormalBrush); + } + if (aitem.DataParameter.SwitchOnBrush != null) + { + CacheManager.CacheRemove(aitem.DataParameter.SwitchOnBrush); + } + if (aitem.DataParameter.DisableBrush != null) + { + CacheManager.CacheRemove(aitem.DataParameter.DisableBrush); + } + if (aitem.DataParameter.DownBrush != null) + { + CacheManager.CacheRemove(aitem.DataParameter.DownBrush); + } + if (aitem.DataParameter.DragCursorImage != null) + { + CacheManager.CacheRemove(aitem.DataParameter.DragCursorImage); + } + } + } + } + private void SetItemData() + { + try + { + #region Item Data From DB + using (var dataHelper = new CommonDataHelper()) + { + //Categoty Data + AllCategory = dataHelper.GetCategoryData(); + if (AllCategory is List) + { + //Category Design Parameter Add + foreach (var category1Item in AllCategory) + { + //Category1 Design Parameter + category1Item.Catalog1Item.DataParameter = new M_AnimationButton + { + NormalBrush = ResourceManager.GetNximagePathAdd("btn_main_menu_n.png", CommonValue.PBdesignImagesPath), + SwitchOnBrush = ResourceManager.GetNximagePathAdd("btn_main_menu_p.png", CommonValue.PBdesignImagesPath), + Width = 150, + Height = 160, + BrushStretch = Stretch.Fill, + ClickAnimationType = ButtonAnimationType.TextSizeDown, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty, + TextVisible = Visibility.Visible, + TextFontSize = 28, + SwitchOnFontSize = 30, + TextForeground = "#adadad", + TextWrapping = TextWrapping.Wrap, + SwitchOnForeground = "White", + TextFontFamily = "NanumSquare", + TextFontWeight = FontWeights.Normal, + SwitchOnFontWeight = FontWeights.Bold, + TextAlignment = TextAlignment.Right, + TextHorizontalAlignment = HorizontalAlignment.Right, + TextVerticalAlignment = VerticalAlignment.Top, + TextMargin = new Thickness(5, 21, 20, 21), + LanguageText = dataHelper.GetLaguageData("CATE", category1Item.Catalog1Item.Category1) + }; + foreach (var category2Item in category1Item.Catalog2Items) + { + //Category2 Design Parameter + category2Item.DataParameter = new M_AnimationButton + { + NormalBrush = "Transparent", + SwitchOnBrush = "Transparent", + Width = 194, + Height = 86, + BrushStretch = Stretch.Fill, + ClickAnimationType = ButtonAnimationType.TextBounceDown, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty, + TextVisible = Visibility.Visible, + TextFontSize = 24, + SwitchOnFontSize = 24, + TextForeground = "Black", + SwitchOnForeground = "#1469cc", + TextFontFamily = "NanumSquare", + TextFontWeight = FontWeights.Normal, + SwitchOnFontWeight = FontWeights.Bold, + TextAlignment = TextAlignment.Center, + TextMargin = new Thickness(0, 0, 18, 0), + TextWrapping = TextWrapping.Wrap, + TextHorizontalAlignment = HorizontalAlignment.Center, + TextVerticalAlignment = VerticalAlignment.Center, + LanguageText = dataHelper.GetLaguageData("CATE", category2Item.Category2) + }; + }; + } + + } + //Item Master + AllItems = dataHelper.GetItemsData(); + if (AllItems is List && AllItems.Count > 0) + { + //Item Design Parameter Add + foreach (var aItem in AllItems) + { + aItem.BadgeHeight = 30; + aItem.BadgeOrientation = Orientation.Horizontal; + if (aItem.BadgeImages is List && aItem.BadgeImages.Count > 0) + { + var newBadgeImages = new List(); + foreach (var aBadgeImage in aItem.BadgeImages) + { + var strBadgeImage = ResourceManager.GetNximagePathAdd(aBadgeImage, CommonValue.PBdesignImagesPath); + if (!string.IsNullOrEmpty(strBadgeImage)) + { + newBadgeImages.Add(strBadgeImage); + } + } + aItem.BadgeImages = newBadgeImages; + } + if (aItem.Option is List && aItem.Option.Count > 0) + { + foreach (var aOptionGRP in aItem.Option) + { + if (aOptionGRP is M_ItemOptionGroup) + { + aOptionGRP.ImageFile = aOptionGRP.Index.Equals(0) + ? "ic_option_takein.png" + : aOptionGRP.Index.Equals(1) + ? "ic_option_shot.png" + : "ic_option_candle.png"; + } + } + } + var itemImage = ResourceManager.GetItemImage(aItem.ImageFile, CommonValue.ItemDefaultImage);//파일 없을 경우 DefaultImage로 + aItem.DataParameter = new M_AnimationButton + { + NormalBrush = itemImage, + DragCursorImage = itemImage, + DisableBrush = ResourceManager.GetNximagePathAdd("img_contents_soldout.png", CommonValue.PBdesignImagesPath), + Width = 100, + Height = 100, + Margin = new Thickness(80, 30, 80, 40), + BrushStretch = Stretch.Fill, + DragCursorHotSpot = HotSpotType.Center, + ClickAnimationType = ButtonAnimationType.SizeDown, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + Enabled = !aItem.IsSoldOut, + CircleText = string.Empty, + }; + aItem.BaseTextBlock = new M_TextBlock() + { + LanguageData = dataHelper.GetLaguageData("PROD", aItem.ItemCode), + TextSize = 24, + Width = 250, + Height = 82, + TextBrush = "Black", + TextFontFamily = "NanumSquare", + TextVerticalAlignment = VerticalAlignment.Center, + TextMargin = new Thickness(5, 0, 5, 0), + TextWeight = FontWeights.Bold, + TextWrapping = TextWrapping.Wrap + }; + aItem.AdditionTextBlock = new M_TextBlock() + { + LanguageData = new List + { + new M_Language{ Type = SupportLanguageType.ko, LanguageData = string.Format("₩{0:#,##0}", aItem.Price)}, + }, + TextSize = 26, + Width = 250, + Height = 40, + TextBrush = "#1469cc", + TextFontFamily = "NanumSquare", + TextVerticalAlignment = VerticalAlignment.Top, + TextMargin = new Thickness(5, 0, 5, 0), + TextWeight = FontWeights.Bold, + }; + } + + } + else + { + +#if TESTMODE + #region Test Item + AllItems = new List(); + AllCategory = new List(); + var itemFiles = ResourceManager.GetItemImages("*.png"); + int index = 0; + foreach (var aItemFles in itemFiles) + { + var aFile = new FileInfo(aItemFles); + if (Regex.IsMatch(aFile.Name.Replace(aFile.Extension, ""), "^[0-9]") && !aFile.Name.Contains("_FULL")) + { + var category1Code = aFile.Name.Substring(0, 1); + var category2Code = aFile.Name.Substring(1, 2); + var testPrice = 2000d; + int intCategory1Code = int.Parse(category1Code); + if (intCategory1Code < 4) + { + //Add ItemData + AllItems.Add(new M_ItemData() + { + Index = index, + ItemCode = aFile.Name.Replace(aFile.Extension, ""), + Category1 = category1Code, + Category2 = category2Code, + Price = testPrice, + BadgeHeight = 30, + BadgeOrientation = Orientation.Horizontal, + BadgeImages = index.Equals(0) + ? new List + { + ResourceManager.GetNximagePathAdd("Img_best.png", CommonValue.PBdesignImagesPath), + ResourceManager.GetNximagePathAdd("Img_new.png", CommonValue.PBdesignImagesPath), + ResourceManager.GetNximagePathAdd("img_like.png", CommonValue.PBdesignImagesPath), + ResourceManager.GetNximagePathAdd("img_event.png", CommonValue.PBdesignImagesPath) + } + : index.Equals(1) + ? new List + { + ResourceManager.GetNximagePathAdd("Img_best.png", CommonValue.PBdesignImagesPath), + ResourceManager.GetNximagePathAdd("Img_new.png", CommonValue.PBdesignImagesPath), + } + : index.Equals(2) + ? new List + { + ResourceManager.GetNximagePathAdd("img_like.png", CommonValue.PBdesignImagesPath), + ResourceManager.GetNximagePathAdd("img_event.png", CommonValue.PBdesignImagesPath), + } + : index.Equals(3) + ? new List + { + ResourceManager.GetNximagePathAdd("Img_best.png", CommonValue.PBdesignImagesPath), + } + : null, + DataParameter = new M_AnimationButton + { + NormalBrush = aItemFles, + DragCursorImage = aItemFles, + DisableBrush = ResourceManager.GetNximagePathAdd("img_contents_soldout.png", CommonValue.PBdesignImagesPath), + Width = 100, + Height = 100, + Margin = new Thickness(80, 30, 80, 40), + BrushStretch = Stretch.Fill, + DragCursorHotSpot = HotSpotType.Center, + ClickAnimationType = ButtonAnimationType.SizeDown, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + Enabled = !index.Equals(7), + CircleText = string.Empty, + }, + BaseTextBlock = new M_TextBlock() + { + LanguageData = index.Equals(0) + ? new List + { + new M_Language{ Type = SupportLanguageType.en, LanguageData = "en아메리카노"}, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = "아메리카노"} + } + : index.Equals(1) + ? new List + { + new M_Language{ Type = SupportLanguageType.en, LanguageData = "3mm 황금비율로 바삭하고 en고소한 전병세트"}, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = "3mm 황금비율로 바삭하고 고소한 전병세트"} + } + : index.Equals(2) + ? new List + { + new M_Language{ Type = SupportLanguageType.en, LanguageData = "en카푸치노"}, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = "카푸치노"} + } + : index.Equals(3) + ? new List + { + new M_Language{ Type = SupportLanguageType.en, LanguageData = "en바닐라라떼"}, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = "바닐라라떼"} + } + : new List + { + new M_Language{ Type = SupportLanguageType.en, LanguageData = aFile.Name.Replace(aFile.Extension, "")}, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = aFile.Name.Replace(aFile.Extension, "")} + }, + TextSize = 24, + Width = 250, + Height = 82, + TextBrush = "Black", + TextFontFamily = "NanumSquare", + TextVerticalAlignment = VerticalAlignment.Center, + TextMargin = new Thickness(5, 0, 5, 0), + TextWeight = FontWeights.Bold, + TextWrapping = TextWrapping.Wrap + }, + AdditionTextBlock = new M_TextBlock() + { + LanguageData = new List { + new M_Language{ Type = SupportLanguageType.ko, LanguageData = string.Format("₩{0:#,##0}", testPrice)}, + }, + TextSize = 26, + Width = 250, + Height = 40, + TextBrush = "#1469cc", + TextFontFamily = "NanumSquare", + TextVerticalAlignment = VerticalAlignment.Top, + TextMargin = new Thickness(5, 0, 5, 0), + TextWeight = FontWeights.Bold, + }, + + }); + //Add CategoryData + if (!CheckExistCategory1(category1Code)) + { + var mItemData = new M_ItemData + { + Index = -1, + ItemCode = category1Code, + Category1 = category1Code, + DataParameter = new M_AnimationButton + { + NormalBrush = ResourceManager.GetNximagePathAdd("btn_main_menu_n.png", CommonValue.PBdesignImagesPath), + SwitchOnBrush = ResourceManager.GetNximagePathAdd("btn_main_menu_p.png", CommonValue.PBdesignImagesPath), + Width = 150, + Height = 160, + BrushStretch = Stretch.Fill, + ClickAnimationType = ButtonAnimationType.TextSizeDown, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty, + TextVisible = Visibility.Visible, + TextFontSize = 27, + SwitchOnFontSize = 40, + TextForeground = "#adadad", + TextWrapping = TextWrapping.Wrap, + SwitchOnForeground = "White", + TextFontFamily = "NanumSquare", + TextFontWeight = FontWeights.Normal, + SwitchOnFontWeight = FontWeights.Bold, + TextAlignment = TextAlignment.Right, + TextHorizontalAlignment = HorizontalAlignment.Right, + TextVerticalAlignment = VerticalAlignment.Top, + TextMargin = new Thickness(10, 21, 27, 21), + LanguageText = new List { + new M_Language{ Type = SupportLanguageType.en, LanguageData = category1Code+"en" }, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = category1Code+"ko" } + }, + } + }; + switch (category1Code) + { + case "0": + mItemData.DataParameter.LanguageText = new List { + new M_Language{ Type = SupportLanguageType.en, LanguageData = "Coffee" }, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = "커피" } + }; + break; + case "1": + mItemData.DataParameter.LanguageText = new List { + new M_Language{ Type = SupportLanguageType.en, LanguageData = "Beverage" }, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = "음료" } + }; + break; + case "2": + mItemData.DataParameter.LanguageText = new List { + new M_Language{ Type = SupportLanguageType.en, LanguageData = "Sherbet" }, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = "빙수" } + }; + break; + case "3": + mItemData.DataParameter.LanguageText = new List { + new M_Language{ Type = SupportLanguageType.en, LanguageData = "Cake" }, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = "케이크" } + }; + break; + } + AddCategory1(category1Code, mItemData); + } + if (!CheckExistCategory2(category1Code, category2Code)) + { + var mItemData = new M_ItemData + { + Index = -1, + ItemCode = category2Code, + Category1 = category1Code, + Category2 = category2Code, + DataParameter = new M_AnimationButton + { + NormalBrush = "Transparent", + SwitchOnBrush = "Transparent", + //SwitchOnBrush = ResourceManager.GetNximagePathAdd("line_main_tab.png", CommonValue.PBdesignImagesPath), + Width = 194, + Height = 86, + BrushStretch = Stretch.Fill, + ClickAnimationType = ButtonAnimationType.TextBounceDown, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty, + TextVisible = Visibility.Visible, + TextFontSize = 24, + SwitchOnFontSize = 28, + TextForeground = "Black", + SwitchOnForeground = "#1469cc", + TextFontFamily = "NanumSquare", + TextFontWeight = FontWeights.Normal, + SwitchOnFontWeight = FontWeights.Bold, + TextAlignment = TextAlignment.Center, + TextMargin = new Thickness(0, 0, 18, 0), + TextWrapping = TextWrapping.Wrap, + TextHorizontalAlignment = HorizontalAlignment.Center, + TextVerticalAlignment = VerticalAlignment.Center, + LanguageText = new List { + new M_Language{ Type = SupportLanguageType.en, LanguageData = category2Code+"en" }, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = category2Code+"ko" } + }, + } + }; + if (category1Code.Equals("0")) + { + switch (category2Code) + { + case "01": + mItemData.DataParameter.LanguageText = new List { + new M_Language{ Type = SupportLanguageType.en, LanguageData = "Cafe Adagio" }, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = "카페 아다지오" } + }; + break; + case "10": + mItemData.DataParameter.LanguageText = new List { + new M_Language{ Type = SupportLanguageType.en, LanguageData = "Latte&Tea" }, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = "라떼&티" } + }; + break; + case "50": + mItemData.DataParameter.LanguageText = new List { + new M_Language{ Type = SupportLanguageType.en, LanguageData = "Juice&Ade" }, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = "주스&에이드" } + }; + break; + case "51": + mItemData.DataParameter.LanguageText = new List { + new M_Language{ Type = SupportLanguageType.en, LanguageData = "Smoothies" }, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = "스무디" } + }; + break; + case "52": + mItemData.DataParameter.LanguageText = new List { + new M_Language{ Type = SupportLanguageType.en, LanguageData = "Sherbet" }, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = "빙수" } + }; + break; + case "71": + mItemData.DataParameter.LanguageText = new List { + new M_Language{ Type = SupportLanguageType.en, LanguageData = "Product Beverage" }, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = "완제음료" } + }; + break; + + } + } + AddCategory2(category1Code, category2Code, mItemData); + } + index++; + } + + } + } + #endregion +#endif + } + } + #endregion + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "SetOrderHistoryItems()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + private void SetOrderHistoryItems() + { + try + { + if (FindOrderHistoryItems is List + && FindOrderHistoryItems.Count > 0 + && AllItems is List + && AllItems.Count > 0) + { + var newOrderHistoryItems = new List(); + foreach (var aHistoryItem in FindOrderHistoryItems) + { + var findItem = AllItems.Find(r => r.ItemCode.Equals(aHistoryItem)); + if (findItem is M_ItemData) newOrderHistoryItems.Add(findItem); + } + if (newOrderHistoryItems.Count > 0) + { + OrderHistoryItems = new ObservableCollection(newOrderHistoryItems); + } + else + { + OrderHistoryItems = null; + } + } + else + { + OrderHistoryItems = null; + } + + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "SetOrderHistoryItems()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + private void SetCategory1(int _index = 0) + { + if (AllCategory != null) + { + if (NeedIntailizeItems) Category1Data = new ObservableCollection((from aRow in AllCategory + select aRow.Catalog1Item).ToList()); + DefaultCategory1Item = _index < 0 ? 0 : _index; + } + } + private void SetCategory2(int _index = 0) + { + if (Category1Data != null) + { + var catalog2Items = AllCategory[DefaultCategory1Item].Catalog2Items; + Category2Data = new ObservableCollection(catalog2Items); + DefaultCategory2Item = _index < 0 ? 0 : _index; + } + } + private void SetItemList(int _index = 0) + { + if (AllItems != null) + { + var category1Code = Category1Data[DefaultCategory1Item < 0 ? 0 : DefaultCategory1Item].Category1; + var category2Code = Category2Data[DefaultCategory2Item < 0 ? 0 : DefaultCategory2Item].Category2; + if (OrderItems != null) OrderItemPageNo = 0; + OrderItems = new ObservableCollection + ( + from aRow in AllItems + where aRow.Category1.Equals(category1Code) + && aRow.Category2.Equals(category2Code) + select aRow + ); + DefaultOrderItem = _index < 0 ? 0 : _index; + } + } + private bool CheckExistCategory1(string _categoryCode) + { + bool result = false; + try + { + if (AllCategory != null) + { + result = !AllCategory.Where(r => r.Catalog1Item.Category1.Equals(_categoryCode)).Count().Equals(0); + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "CheckExistCategory1()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = false; + } + return result; + } + private bool CheckExistCategory2(string _category1Code, string _category2Code) + { + bool result = false; + try + { + if (AllCategory != null) + { + var category1Items = AllCategory.Where(r => r.Catalog1Item.Category1.Equals(_category1Code)).FirstOrDefault(); + if (category1Items != null && category1Items.Catalog2Items != null) + { + result = !category1Items.Catalog2Items.Where(r => r.Category2.Equals(_category2Code)).Count().Equals(0); + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "CheckExistCategory2()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = false; + } + return result; + + } + private void AddCategory1(string _categoryCode, M_ItemData _categoryItem) + { + if (AllCategory != null) + { + if (AllCategory.Where(r => r.Catalog1Item.Category1.Equals(_categoryCode)).Count().Equals(0)) + { + _categoryItem.Index = AllCategory.Count; + AllCategory.Add( + new M_CategoryItems + { + Catalog1Item = _categoryItem, + Catalog2Items = new List() + } + ); + } + } + } + private void AddCategory2(string _category1Code, string _category2Code, M_ItemData _categoryItem) + { + if (AllCategory != null) + { + var category1Items = AllCategory.Where(r => r.Catalog1Item.Category1.Equals(_category1Code)).FirstOrDefault(); + if (category1Items != null && category1Items.Catalog2Items != null) + { + if (category1Items.Catalog2Items.Where(r => r.Category2.Equals(_category2Code)).Count().Equals(0)) + { + _categoryItem.Index = category1Items.Catalog2Items.Count; + category1Items.Catalog2Items.Add(_categoryItem); + } + } + } + + } + private void SetPageNumber() + { + var pageCount = GetItemPageCount(); + var pageNumbers = new ObservableCollection(); + for (int index = 0; index < pageCount; index++) + { + pageNumbers.Add(new M_ItemData + { + Index = index, + DataParameter = new M_AnimationButton + { + NormalBrush = ResourceManager.GetNximagePathAdd("Img_page_dot_off.png", CommonValue.PBdesignImagesPath), + SwitchOnBrush = ResourceManager.GetNximagePathAdd("Img_page_dot_on.png", CommonValue.PBdesignImagesPath), + Width = 20, + Height = 20, + BrushStretch = Stretch.Fill, + ClickAnimationType = ButtonAnimationType.SizeDown, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty, + TextVisible = Visibility.Collapsed, + } + }); + + } + ItemPageStatus = pageNumbers; + } + #endregion + + #region Senssing + private M_ItemData SetItemDesignData(CommonDataHelper dataHelper, M_ItemData aItem) + { + var result = aItem; + try + { + aItem.BadgeHeight = 30; + aItem.BadgeOrientation = Orientation.Horizontal; + if (aItem.BadgeImages is List && aItem.BadgeImages.Count > 0) + { + var newBadgeImages = new List(); + foreach (var aBadgeImage in aItem.BadgeImages) + { + var strBadgeImage = ResourceManager.GetNximagePathAdd(aBadgeImage, CommonValue.PBdesignImagesPath); + if (!string.IsNullOrEmpty(strBadgeImage)) + { + newBadgeImages.Add(strBadgeImage); + } + } + aItem.BadgeImages = newBadgeImages; + } + //if (aItem.Option is List && aItem.Option.Count > 0) + //{ + // foreach (var aOptionGRP in aItem.Option) + // { + // if (aOptionGRP is M_ItemOptionGroup) + // { + // aOptionGRP.ImageFile = aOptionGRP.Index.Equals(0) + // ? "ic_option_takein.png" + // : aOptionGRP.Index.Equals(1) + // ? "ic_option_shot.png" + // : "ic_option_candle.png"; + // } + // } + //} + var itemImage = ResourceManager.GetItemImage(aItem.ImageFile, CommonValue.ItemDefaultImage); + aItem.DataParameter = new M_AnimationButton + { + NormalBrush = itemImage, + DragCursorImage = itemImage, + DisableBrush = ResourceManager.GetNximagePathAdd("img_contents_soldout.png", CommonValue.PBdesignImagesPath), + Width = 100, + Height = 100, + Margin = new Thickness(80, 30, 80, 40), + BrushStretch = Stretch.Fill, + DragCursorHotSpot = HotSpotType.Center, + ClickAnimationType = ButtonAnimationType.SizeDown, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + Enabled = !aItem.IsSoldOut, + CircleText = string.Empty, + }; + aItem.BaseTextBlock = new M_TextBlock() + { + LanguageData = dataHelper.GetLaguageData("PROD", aItem.ItemCode), + TextSize = 24, + Width = 250, + Height = 82, + TextBrush = "Black", + TextFontFamily = "NanumSquare", + TextVerticalAlignment = VerticalAlignment.Center, + TextMargin = new Thickness(5, 0, 5, 0), + TextWeight = FontWeights.Bold, + TextWrapping = TextWrapping.Wrap + }; + aItem.AdditionTextBlock = new M_TextBlock() + { + LanguageData = new List + { + new M_Language{ Type = SupportLanguageType.ko, LanguageData = string.Format("₩{0:#,##0}", aItem.Price)}, + }, + TextSize = 26, + Width = 250, + Height = 40, + TextBrush = "#1469cc", + TextFontFamily = "NanumSquare", + TextVerticalAlignment = VerticalAlignment.Top, + TextMargin = new Thickness(5, 0, 5, 0), + TextWeight = FontWeights.Bold, + }; + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "SetItemDesignData()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = aItem; + } + return result; + } + private void ProcessBardcord() + { + Console.WriteLine("Paag={0},SubPage={1},Barcord={2}", DefaultPage, SensingSubPage, ReadBarCode); + if (string.IsNullOrEmpty(ReadBarCode) || !DefaultPage.Equals(PBPageType.Sensing)) return; + var barcordData = ReadBarCode.Trim().ToUpper(); + if (barcordData.rIsBigAlpa() && barcordData.Contains("SCANSTART")) + { + AIScanCount = 0; + } + else + { + var isNumeric = barcordData.rIsNum(); + var isAlpaNumaric = barcordData.rIsAlpaNum(); + var barcord = isNumeric && isAlpaNumaric ? barcordData : null; + var itemcode = !isNumeric && isAlpaNumaric ? barcordData.rGetOnlyNum() : null; + var itemType = string.IsNullOrEmpty(itemcode) && !string.IsNullOrEmpty(barcord) && SensingSubPage.Equals(PBSensingSubPageType.BarcordPage) + ? BasketItemType.Barcode + : !string.IsNullOrEmpty(itemcode) && string.IsNullOrEmpty(barcord) && SensingSubPage.Equals(PBSensingSubPageType.SensingPage) + ? BasketItemType.Scan + : BasketItemType.None; + if (!itemType.Equals(BasketItemType.None)) + { + var newScanData = new M_ScanData + { + ItemCode = itemcode, + Barcord = barcord, + ItemType = itemType, + }; + scanQueue.Enqueue(newScanData); + + } + } + } + private void ScanDataProcessor() + { + while (IsScanProcess) + { + try + { + var scanData = scanQueue.Count > 0 ? scanQueue.Dequeue() : null; + if (scanData is M_ScanData) + { + using (var dataHelper = new CommonDataHelper()) + { + var getItemData = dataHelper.GetBarcordItemsData(scanData.ItemCode, scanData.Barcord); + if (getItemData is M_ItemData) + { + var designItem = SetItemDesignData(dataHelper, getItemData); + AddItem2Basket(designItem, scanData.ItemType); + if (scanData.ItemType.Equals(BasketItemType.Scan)) AIScanCount += 1; + } + else + { + CommonLog.ErrorLogWrite(this, "ScanDataProcessor()", "Not Found Item Error !!", string.Format("\nItem={0},Barcord={1}", scanData.ItemCode, scanData.Barcord)); + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "Dispose", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + } + #endregion + + #region Basket + private void AddItem2Basket(M_ItemData _itemData, BasketItemType _itemType = BasketItemType.Order) + { + var option = new List(); + var itemCount = 1; + var unitPrice = _itemData.Price; + if (_itemType.Equals(BasketItemType.Order)) + { + if (_itemData.IsOption) + { + ToIntorTimerStop(); + try + { + var newOptions = new List(); + foreach (var aOptionGroup in _itemData.Option) + { + newOptions.Add(aOptionGroup.Clone()); + } + var popupReturn = popupManager.OpenOptionSelect(_itemData.BaseTextBlock.LanguageData + , newOptions + , _itemData.DataParameter.NormalBrush + , itemCount + , _itemData.Price); + if (popupReturn is M_PopupReturn) + { + if (popupReturn.TimeOut) + { + DefaultPage = PBPageType.Intro; + option = null; + } + else + { + if (popupReturn.PopupArgs is M_OptionReturn getOption) + { + option = getOption.Options; + itemCount = getOption.ItemCount; + unitPrice = getOption.PriceWithOption; + } + else + { + option = null; + } + } + } + else + { + option = null; + } + } + catch + { + option = null; + } + finally + { + ToIntorTimerStart(); + } + if (option == null) return; + } + else + { + option = null; + itemCount = 1; + unitPrice = _itemData.Price; + } + } + else + { + option = null; + } + using (var posDataService = new PosDataService()) + { + var getNewBasketData = posDataService.AddItemToBasket(MiniBasketData + , itemCount + , unitPrice + , CommonValue.PBdesignImagesPath + , _itemData + , option + , _itemType); + if (getNewBasketData is ObservableCollection) MiniBasketData = getNewBasketData; + } + } + private double GetItemPrice(M_ItemData _itemData, List _option) + { + double result = _itemData.Price; + try + { + foreach (var aOptionGroup in _option) + { + foreach (var aOption in aOptionGroup.Options) + { + if (aOption.IsSelected) + { + + } + } + } + } + catch + { + + result = _itemData.Price; + } + return result; + } + private void SetBasketSum() + { + if (MiniBasketData is ObservableCollection) + { + OrderTotalCount = MiniBasketData.Sum(r => r.Count); + OrderTotalPayment = MiniBasketData.Sum(r => r.Count * r.Price); + } + else + { + OrderTotalCount = 0; + OrderTotalPayment = 0; + } + } + private void DeleteBasketItem(M_BasketItem _deleteItem) + { + if (MiniBasketData is ObservableCollection) + { + var newBasketData = MiniBasketData.ToList(); + using (var posDataService = new PosDataService()) + { + if (posDataService.DelItem(_deleteItem)) + { + newBasketData.Remove(_deleteItem); + } + } + MiniBasketData = new ObservableCollection(newBasketData); + + } + } + private void DeleteScanItem() + { + if (MiniBasketData is ObservableCollection) + { + var newBasketData = MiniBasketData.ToList(); + using (var posDataService = new PosDataService()) + { + foreach (var aitem in newBasketData.Where(r => r.ItemType.Equals(BasketItemType.Scan)).ToList()) + { + if (posDataService.DelItem(aitem)) + { + newBasketData.Remove(aitem); + } + } + } + newBasketData.RemoveAll(r => r.ItemType.Equals(BasketItemType.Scan)); + MiniBasketData = new ObservableCollection(newBasketData); + } + } + public void DeledteAllBasket() + { + + if (MiniBasketData is ObservableCollection) + { + using (var posDataService = new PosDataService()) + { + foreach (var aitem in MiniBasketData) + { + posDataService.DelItem(aitem); + } + } + MiniBasketData = null; + } + } + #endregion + + #endregion Contents + + #region Etc + /// + /// 타이머 스톱 + /// + public void ToIntorTimerStart() + { + + LastAccessTime = DateTime.Now; + ToIntoroTimer.Start(); + + } + /// + /// 타이머 재시작 + /// + public void ToIntorTimerStop() + { + LastAccessTime = DateTime.Now; + ToIntoroTimer.Stop(); + } + private int GetMaxItemPageNo() + { + int result = 0; + try + { + result = OrderItems.Count / (OrderColumnCount * OrderRowCount); + if ((OrderItems.Count % (OrderColumnCount * OrderRowCount)).Equals(0)) result -= 1; + + } + catch + { + result = 0; + } + return result; + } + private int GetItemPageCount() + { + int result = 0; + try + { + result = OrderItems.Count / (OrderColumnCount * OrderRowCount); + if (!(OrderItems.Count % (OrderColumnCount * OrderRowCount)).Equals(0)) result += 1; + + } + catch + { + result = 0; + } + return result; + } + #endregion Etc + + #endregion Methods + + #region [ Event Handlers ] + private void ToExecuteNothingHandler(object obj) + { + + } + private void VmPBViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + LastAccessTime = DateTime.Now; + try + { + switch (e.PropertyName) + { + case "DefaultPage": + if (DefaultPage.Equals(PBPageType.FirstSelect) + || DefaultPage.Equals(PBPageType.Items)) + { + GmbHappyInfoEnable = !MemberLoginOK; + } + else + { + GmbHappyInfoEnable = false; + } + switch (DefaultPage) + { + case PBPageType.Intro: + ToIntorTimerStop(); + OrderHistoryView = false; + MemberLoginOK = false; + HappyPointReturn = null; + FindOrderHistoryItems = null; + SetIntro(); + DeledteAllBasket(); + break; + case PBPageType.FirstSelect: + ToIntorTimerStart(); + break; + case PBPageType.Items: + GmbOrderEnable = false; + SetContents(); + SetOrderHistoryItems(); + ToIntorTimerStart(); + break; + case PBPageType.Sensing: + GmbAIscannerEnable = false; + AIScanCount = 0; + ToIntorTimerStart(); + break; + } + break; + case "MemberLoginOK": + GmbHappyPointEnable = !MemberLoginOK; + GmbHappyInfoEnable = !MemberLoginOK; + break; + case "GmbHappyInfoEnable": + if (GmbHappyInfoEnable) + { + GmbHappyInfoEnableTime = DateTime.Now; + } + break; + case "DefaultCategory1Item": + if (DefaultCategory1Item > -1) + { + if (Category2Data == null) + { + SetCategory2(); + } + else + { + if (!Category1Data[DefaultCategory1Item].Category1.Equals(Category2Data.FirstOrDefault().Category1)) + { + SetCategory2(); + } + } + } + OrderItemPageNo = 0; + break; + case "DefaultCategory2Item": + if (DefaultCategory1Item > -1) + { + SetItemList(); + } + OrderItemPageNo = 0; + ToIntorTimerStart(); + break; + case "DefaultCategory1PageNo": + case "DefaultCategory2PageNo": + break; + case "ShowLanguageType": + CommonValue.CommonLanguageType = ShowLanguageType; + switch (ShowLanguageType) + { + case SupportLanguageType.ko: + GmbLanguageimage=ResourceManager.GetNximagePathAdd("btn_language_kor.png", CommonValue.PBdesignImagesPath); + break; + case SupportLanguageType.en: + GmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_eng.png", CommonValue.PBdesignImagesPath); + break; + case SupportLanguageType.ja: + GmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_jap.png", CommonValue.PBdesignImagesPath); + break; + case SupportLanguageType.zh: + GmbLanguageimage = ResourceManager.GetNximagePathAdd("btn_language_chi.png", CommonValue.PBdesignImagesPath); + break; + } + break; + case "OrderItems": + PageStatusColumnCount = GetItemPageCount(); + SetPageNumber(); + break; + case "OrderItemPageNo": + Page2LeftEnable = !OrderItemPageNo.Equals(0); + Page2RightEnable = !OrderItemPageNo.Equals(GetMaxItemPageNo()); + break; + case "MiniBasketData": + SetBasketSum(); + if (MiniBasketData is ObservableCollection miniBasketItems + && miniBasketItems.Count > 0) + { + OrderDetailEnable = true; + GotoPaymentEnable = true; + MiniBasketDeleteAllEnable = true; + OrderNoneDataGridVisibility = Visibility.Hidden; + OrderExistDataGridVisibility = Visibility.Visible; + foreach (var aBasketItem in miniBasketItems ) + { + aBasketItem.PropertyChanged += ABasketItem_PropertyChanged; + } + } + else + { + OrderDetailEnable = false; + GotoPaymentEnable = false; + MiniBasketDeleteAllEnable = false; + OrderNoneDataGridVisibility = Visibility.Visible; + OrderExistDataGridVisibility = Visibility.Hidden; + } + break; + case "FindOrderHistoryItems": + SetOrderHistoryItems(); + break; + case "OrderHistoryItems": + //OrderHistoryItemsEnable = OrderHistoryItems != null && OrderHistoryItems.Count > 0; + OrderHistoryItemsEnable = MemberLoginOK; + GmbHappyPointEnable = !MemberLoginOK; + GmbHappyInfoEnable = !MemberLoginOK; + break; + case "ReadBarCode": + ProcessBardcord(); + break; + default: + break; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "VmPBViewModel_PropertyChanged()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + + } + + + + #region Intro Click + private void RollMediaCommandHandler(object _param) + { + try + { + if (_param is M_MediaRollItem selectItem) + { + NeedIntailizeItems = true; + PBPageType targetPage = PBPageType.Intro; + switch (selectItem.LinkType) + { + case IntroLinkType.Page: + DefaultLinkValue = string.Empty; + switch (selectItem.LinkParameter) + { + case "IntroPage": + targetPage = PBPageType.Intro; + break; + case "ItemPage": + targetPage = PBPageType.Items; + break; + case "SensingPage": + targetPage = PBPageType.Sensing; + break; + case "FirstSelect": + targetPage = PBPageType.FirstSelect; + break; + } + break; + case IntroLinkType.Category: + DefaultLinkValue = selectItem.LinkParameter; + targetPage = PBPageType.Items; + break; + case IntroLinkType.ItemCode: + DefaultLinkValue = selectItem.LinkParameter; + targetPage = PBPageType.Items; + break; + default: + targetPage = PBPageType.FirstSelect; + break; + } + ShowLanguageType = SupportLanguageType.ko; + #region 인트로에서 벗어 날때 해피포인트 맴버 인증 (사용 않음) + //if (!targetPage.Equals(PBPageType.Intro)) + //{ + // var popupReturn = popupManager.OpenHappyPointCertify(); + // if (popupReturn is M_PopupReturn) + // { + // MemberLoginOK = popupReturn.OKAnswer; + // if (popupReturn.PopupArgs is M_HappyPointReturn _HappyPointReturn) + // { + // HappyPointReturn = _HappyPointReturn; + // GmbMemberName = HappyPointReturn.MemberName; + // } + // if (!popupReturn.ReturnLanguage.Equals(ShowLanguageType)) + // { + // ShowLanguageType = popupReturn.ReturnLanguage; + // } + // if (popupReturn.TimeOut) targetPage = PBPageType.Intro; + // } + //} + #endregion + WaitWindowFrom.ShowWaitWindow(); + DefaultPage = targetPage; + if (!targetPage.Equals(PBPageType.Intro)) IntroItems = null; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "RollMediaCommandHandler()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + WaitWindowFrom.CloseWaitWindow(); + } + } + #endregion + + #region GMB Left Click + private void GotoFirstCommandHandler(object obj) + { + DefaultPage = PBPageType.FirstSelect; + } + + private void ReaderCheckCommandHandler(object obj) + { + try + { + ReaderCheckClickCount += 1; + if (ReaderCheckClickCount.Equals(10)) + { + ToIntorTimerStop(); + try + { + var popupReturn = popupManager.OpenNumPadPopup(ShowLanguageType + , Languages.GetMessages("InputPassword") + , false,true,5,5); + if (popupReturn is M_PopupReturn) + { + if (popupReturn.TimeOut) + { + DefaultPage = PBPageType.Intro; + return; + } + else + { + if (popupReturn.OKAnswer) + { + if (popupReturn.PopupArgs is string getPassword + && getPassword.Equals(DateTime.Now.ToString("ddMM") + + ((int.Parse(DateTime.Now.ToString("dd")) + * int.Parse(DateTime.Now.ToString("MM"))) % 10).ToString())) + { + GmbReaderCheckOpen = true; + } + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ReaderCheckCommandHandler()", "OpenNumPadPopup Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + ReaderCheckClickCount = 0; + ToIntorTimerStart(); + } + + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ReaderCheckCommandHandler()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + + } + + #endregion + + #region GMB Right Click + private void HappyPointCommandHandler(object obj) + { + if (HappyPointReturn is M_HappyPointReturn) + { + GmbHappyPointEnable = false; + return; + } + ToIntorTimerStop(); + try + { + OrderHistoryView = false; + FindOrderHistoryItems = null; + var popupReturn = popupManager.OpenHappyPointCertify(false, true, ParentPage.PBWindow); + if (popupReturn is M_PopupReturn) + { + if (popupReturn.TimeOut) + { + DefaultPage = PBPageType.Intro; + return; + } + else + { + MemberLoginOK = popupReturn.OKAnswer; + if (popupReturn.PopupArgs is M_HappyPointReturn _HappyPointReturn) + { + HappyPointReturn = _HappyPointReturn; + GmbMemberName = HappyPointReturn.IsCardNoUsed ? HappyPointReturn.MemberName : "고객"; + if (HappyPointReturn.OrderHistoryItems is List orderHistoryItems + && orderHistoryItems.Count > 0) + { + FindOrderHistoryItems = orderHistoryItems; + } + else + { + FindOrderHistoryItems = null; + } + if (DefaultPage.Equals(PBPageType.Items)) OrderHistoryView = OrderHistoryItemsEnable; + + } + else + { + HappyPointReturn = null; + } + if (!popupReturn.ReturnLanguage.Equals(ShowLanguageType)) + { + ShowLanguageType = popupReturn.ReturnLanguage; + } + + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "HappyPointCommandHandler()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + ToIntorTimerStart(); + } + } + private void CallEmployeeCommandHandler(object obj) + { + ToIntorTimerStop(); + try + { + var popupReturn = popupManager.OpenCallEmployee(); + if (popupReturn is M_PopupReturn) + { + if (popupReturn.TimeOut) + { + DefaultPage = PBPageType.Intro; + return; + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "CallEmployeeCommandHandler()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + ToIntorTimerStart(); + } + } + private void LanguageCommandHandler(object obj) + { + ToIntorTimerStop(); + try + { + var popupReturn = popupManager.OpenLanguageSelector(ShowLanguageType); + if (popupReturn is M_PopupReturn) + { + if (popupReturn.TimeOut) + { + DefaultPage = PBPageType.Intro; + return; + } + else + { + ShowLanguageType = popupReturn.ReturnLanguage; + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "LanguageCommandHandler()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + ToIntorTimerStart(); + } + } + private void GotoIntroPageCommadHandler(object obj) + { + ToIntorTimerStop(); + try + { + if (MiniBasketData != null && MiniBasketData.Count > 0) + { + var miniPopup = new M_MiniPopup + { + Icon = MiniPopupIcon.Cancel, + DisplayLanguage = ShowLanguageType, + Message = Languages.GetMessages("LBL0085"), + CencalButtonText = Languages.GetMessages("BTN0021"), + OkButtonText = Languages.GetMessages("BTN0005"), + IsCencalButton = true, + TimeoutSeconds = 10, + }; + var popupReturn = popupManager.OpenMiniPopup(miniPopup); + if (popupReturn is M_PopupReturn) + { + if (popupReturn.OKAnswer) + { + DefaultPage = PBPageType.Intro; + } + } + } + else + { + DefaultPage = PBPageType.Intro; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GotoIntroPageCommadHandler()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + ToIntorTimerStart(); + } + } + #endregion + + #region GMB Center Click + private void GmbOrderCommandHandler(object obj) + { + DefaultPage = PBPageType.Items; + } + private void GmbAIscannerCommandHandler(object obj) + { + DefaultPage = PBPageType.Sensing; + if (this.OptionValue810 == "0" + && this.OptionValue811 == "1") + { + SensingSubPage = PBSensingSubPageType.BarcordPage; + } + } + #endregion + + #region Contents + private void RescanCommandHandler(object obj) + { + DeleteScanItem(); + DefaultPage = PBPageType.Sensing; + } + private void GotoBarcodeCommandHandler(object obj) + { + if (DefaultPage.Equals(PBPageType.Sensing)) + { + SensingSubPage = PBSensingSubPageType.BarcordPage; + } + } + + private void Page2LeftCommandHandler(object obj) + { + OrderItemPageNo -= 1; + } + + private void Page2RightCommandHandler(object obj) + { + OrderItemPageNo += 1; + } + private void ItemCommandCommandHandler(object _param) + { + if (_param is AnimationButton targetButton && targetButton.DataParameter is M_ItemData _ItemData) + { + //AddItem2Basket(_ItemData); + } + } + + + private void Category2CommandHandler(object _param) + { + ToIntorTimerStart(); + if (_param is AnimationButton targetButton && targetButton.DataParameter is M_ItemData _ItemData) + { + DefaultCategory2Item = Category2Data.IndexOf(_ItemData); + } + + } + + private void Category1CommandHandler(object _param) + { + ToIntorTimerStart(); + if (_param is AnimationButton targetButton && targetButton.DataParameter is M_ItemData _ItemData) + { + DefaultCategory1Item = Category1Data.IndexOf(_ItemData); + } + } + private void PageSelectCommandHandler(object _param) + { + if (_param is AnimationButton targetButton && targetButton.DataParameter is M_ItemData _ItemData) + { + OrderItemPageNo = ItemPageStatus.IndexOf(_ItemData); + } + } + private void OrderHistoryCommandHandler(object obj) + { + OrderHistoryView = true; + } + + private void OrderHistoryCloseCommandHandler(object obj) + { + OrderHistoryView = false; + } + + #endregion + + #region MiniBasket + private void ABasketItem_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (sender is M_BasketItem basketItem) + { + using (var posDataService = new PosDataService()) + { + posDataService.UpdatedItem(basketItem); + } + SetBasketSum(); + } + + + } + + private void MiniBasketDeleteAllCommandHandler(object _param) + { + + ToIntorTimerStop(); + try + { + var miniPopup = new M_MiniPopup + { + Icon = MiniPopupIcon.ListCancel, + DisplayLanguage = ShowLanguageType, + Message = Languages.GetMessages("LBL0099"), + CencalButtonText = Languages.GetMessages("BTN0021"), + OkButtonText = Languages.GetMessages("BTN0005"), + IsCencalButton = true, + TimeoutSeconds = 10, + }; + var popupReturn = popupManager.OpenMiniPopup(miniPopup); + if (popupReturn is M_PopupReturn && popupReturn.OKAnswer) + { + DeledteAllBasket(); + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "MiniBasketDeleteAllCommandHandler()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + ToIntorTimerStart(); + } + + } + + private void EmptyBasketDropCommandHandler(object _param) + { + if (_param is M_ItemDropEventArgs dropedItem) + { + if (dropedItem.SourceObject is AnimationButton sourceButton && sourceButton.DataParameter is M_ItemData _ItemData) + { + AddItem2Basket(_ItemData); + } + } + } + + private void BasketItemDeleteCommandHandler(object _param) + { + if (_param is M_BasketItem deleteItem) + { + DeleteBasketItem(deleteItem); + } + } + + private void OrderDetailCommandHandler(object _param) + { + OpenPBPaymentPage = PBPaymentPageType.DetailBasket; + } + + private void GotoPaymentCommandHandler(object _param) + { + if (MiniBasketData is ObservableCollection + && MiniBasketData.Count > 0) + { + OpenPBPaymentPage = PBPaymentPageType.PointsDisCounts; + } + else + { + ToIntorTimerStop(); + var topMessage = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "선택한 제품이 없습니다." + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "en선택한 제품이 없습니다." + }, + }; + var popupReturn = PopupMessageBox.ShowMessageBox(ShowLanguageType + , topMessage + , null + , MessageBoxButton.OK + , OpenCloseAnimationType.FullSizeUp + , OpenCloseAnimationType.FullSizeDown + , 0.5, 0.2, 5); + ToIntorTimerStart(); + } + } + #endregion + + private void ToIntoroTimer_Tick(object sender, EventArgs e) + { + if (GmbHappyInfoEnable) + { + if (GmbHappyInfoEnableTime.AddSeconds(3) <= DateTime.Now) + { + GmbHappyInfoEnableTime = DateTime.Now; + GmbHappyInfoEnable = false; + } + + } + if (DefaultPage.Equals(PBPageType.Intro)) + { + LastAccessTime = DateTime.Now; + } + else if ((DateTime.Now - LastAccessTime) > TimeSpan.FromSeconds(CommonValue.TimeOutSeconds)) + { + ReaderCheckClickCount = 0; +#if !TESTMODE + if (IsTimeoutPopup) + { + ToIntorTimerStop(); + var popupReturn = PopupMessageBox.ShowMessageBox(ShowLanguageType + , Languages.GetMessages("LBL0067") + , Languages.GetMessages("LBL0021") + , MessageBoxButton.YesNo + , OpenCloseAnimationType.FullSizeUp + , OpenCloseAnimationType.FullSizeDown + , 0.5, 0.2, 10); + if (popupReturn.Equals(MessageBoxResult.Yes)) + { + ToIntorTimerStart(); + } + else + { + + if (!DefaultPage.Equals(PBPageType.Intro)) DefaultPage = PBPageType.Intro; + } + } +#else + LastAccessTime = DateTime.Now; + Console.WriteLine(">>> PBViewModel.DefaultPage=PBPageType.Intro"); +#endif + } + } + #endregion Event Handlers + } + +} diff --git a/Kiosk/PB/SPC.Kiosk.PB.ViewModel/Properties/AssemblyInfo.cs b/Kiosk/PB/SPC.Kiosk.PB.ViewModel/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2e761ae --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB.ViewModel/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("SPC.Kiosk.PB.ViewModel")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Zin")] +[assembly: AssemblyProduct("SPC.Kiosk.PB")] +[assembly: AssemblyCopyright("Copyright © Zin. 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("7d7c6385-b4cf-4e81-a79c-3b6cde8c1eac")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 +// 기본값으로 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Kiosk/PB/SPC.Kiosk.PB.ViewModel/SPC.Kiosk.PB.ViewModel.csproj b/Kiosk/PB/SPC.Kiosk.PB.ViewModel/SPC.Kiosk.PB.ViewModel.csproj new file mode 100644 index 0000000..e78404a --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB.ViewModel/SPC.Kiosk.PB.ViewModel.csproj @@ -0,0 +1,92 @@ + + + + + Debug + AnyCPU + {BCA39AE9-B2EB-495E-BE62-AB95B0325CFF} + Library + Properties + SPC.Kiosk.PB.ViewModel + SPC.Kiosk.PB.ViewModel + v4.0 + 512 + true + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\..\BIN\ + TRACE;DEBUG;TESTMODE + prompt + 4 + x86 + + + pdbonly + true + ..\..\..\..\BIN\ + TRACE + prompt + 4 + x86 + + + + + + + + + + + + + + + + + + + + + + {bcc10fa2-c358-480c-8ff0-615750f3c306} + SPC.Kiosk.Base + + + {BA2D06E0-74C0-4785-B39F-D1EAAC13B73D} + SPC.Kiosk.Common + + + {fee44681-7f0e-469a-a833-dc324eb6d01a} + SPC.Kiosk.DataHelper + + + {36fe9011-b9bc-4348-b9c1-1c063dbfa926} + SPC.Kiosk.Payments + + + {be7fc15c-325b-4ad4-8ea0-a8244193e431} + SPC.Kiosk.Popup.Model + + + {9ef1fec9-5f0a-4a4e-8723-e93f30798fd2} + SPC.Kiosk.Popup.ViewModel + + + {7c64409c-24e1-4d9e-a686-b13061f1c61b} + SPC.Kiosk.Popup + + + {90ebd618-0409-458d-9829-a012223e8671} + SPC.Kiosk.PB.Model + + + + \ No newline at end of file diff --git a/Kiosk/PB/SPC.Kiosk.PB/DetailBasketItem.xaml b/Kiosk/PB/SPC.Kiosk.PB/DetailBasketItem.xaml new file mode 100644 index 0000000..775e754 --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/DetailBasketItem.xaml @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/PB/SPC.Kiosk.PB/DetailBasketItem.xaml.cs b/Kiosk/PB/SPC.Kiosk.PB/DetailBasketItem.xaml.cs new file mode 100644 index 0000000..963050a --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/DetailBasketItem.xaml.cs @@ -0,0 +1,251 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.PB.Model; +using SPC.Kiosk.Popup; +using SPC.Kiosk.Popup.Model; +namespace SPC.Kiosk.PB +{ + /// + /// DetailBasketItem.xaml에 대한 상호 작용 논리 + /// + public partial class DetailBasketItem : UserControl + { + #region [ Members ] + /// + /// ItemData + /// + public static readonly DependencyProperty ItemDataProperty = + DependencyProperty.Register(nameof(ItemData), typeof(M_BasketItem), typeof(DetailBasketItem), new PropertyMetadata(null, new PropertyChangedCallback(OnItemDataPropertyChanged))); + /// + /// Display Language + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(DetailBasketItem), new PropertyMetadata(SupportLanguageType.ko));//, new PropertyChangedCallback(OnDisplayLanguageProperyChanged) + + + /// + /// ItemData + /// + public M_BasketItem ItemData + { + get { return (M_BasketItem)GetValue(ItemDataProperty); } + set { SetValue(ItemDataProperty, value); } + } + /// + /// Display Language + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + #region [ RoutedEvent 'MouseClicked' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent MouseClickedEvent = EventManager.RegisterRoutedEvent(nameof(MouseClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(DetailBasketItem)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler MouseClicked + { + add { AddHandler(MouseClickedEvent, value); } + remove { RemoveHandler(MouseClickedEvent, value); } + } + #endregion RoutedEvent 'MouseClicked' + + public string BackImage { get; set;} + public string DeleteImageData { get; set; } + public string DeleteDownImageData { get; set; } + public string OptionImageData { get; set; } + public List OptionButtonLabel { get; set; } + private PopupManager popupManager = PopupManager.GetInstance; + #endregion Members + + #region [ Ctor & Etc ] + /// + /// Ctor + /// + public DetailBasketItem() + { + BackImage=ResourceManager.GetNximagePathAdd("basket_list_bg.png", CommonValue.PBdesignImagesPath); + DeleteImageData = ResourceManager.GetNximagePathAdd("btn_delete_2.png", CommonValue.PBdesignImagesPath); + DeleteDownImageData = ResourceManager.GetNximagePathAdd("btn_delete_2_p.png", CommonValue.PBdesignImagesPath); + OptionImageData = ResourceManager.GetNximagePathAdd("btn_option.png", CommonValue.PBdesignImagesPath); + OptionButtonLabel = new List + { + new M_Language + { + Type =SupportLanguageType.ko, + LanguageData = "옵션변경", + }, + }; + InitializeComponent(); + } + #endregion Ctor & Etc + + #region [ Methods ] + /// + /// Raise MouseClicked Event + /// + private void RaiseMouseClickedEvent(object _sender) + { + RoutedEventArgs newEventArgs = new RoutedEventArgs(DetailBasketItem.MouseClickedEvent, _sender); + RaiseEvent(newEventArgs); + } + private void DeleteAnimationRun() + { + var deteleAnimation = Animations.GetShutterAnimation(this.MainGrid, ShutterAnchor.Bottom, this.MainGrid.ActualHeight, 0, 1, 0.5, 0.5); + deteleAnimation.Completed += DeteleAnimation_Completed; + deteleAnimation.Begin(); + } + + #endregion Methods + + #region [ Event Handlers ] + private void DeteleAnimation_Completed(object sender, EventArgs e) + { + RaiseMouseClickedEvent(this.ItemData); + } + private static void OnItemDataPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + try + { + if (e.NewValue is M_BasketItem newValue) + { + var target = d as DetailBasketItem; + if (e.OldValue is M_BasketItem oldValue) + { + oldValue.PropertyChanged -= target.NewValue_PropertyChanged; + } + target.ItemPrice.Text = (newValue.Count * newValue.Price).ToString("#,##0"); + target.ItemCountCombo.LeftButtonData = new M_AnimationButton + { + NormalBrush = newValue.MinusNormalBrush, + DownBrush = newValue.MinusDownBrush, + BrushStretch = Stretch.Fill, + DragEnable = false, + Width = 36, + Height = 36, + Switch = false, + AutoToggle = false, + TextVisible = Visibility.Collapsed, + ClickAnimationType = ButtonAnimationType.None, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty, + }; + target.ItemCountCombo.RightButtonData = new M_AnimationButton + { + NormalBrush = newValue.PlusNormalBrush, + DownBrush = newValue.PlusDownBrush, + BrushStretch = Stretch.Fill, + DragEnable = false, + Width = 36, + Height = 36, + Switch = false, + AutoToggle = false, + TextVisible = Visibility.Collapsed, + ClickAnimationType = ButtonAnimationType.None, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty, + }; + + if (newValue.Option is List options + && options.Count > 0) + { + target.OptionChange.Visibility = Visibility.Visible; + } + else + { + target.OptionChange.Visibility = Visibility.Collapsed; + } + newValue.PropertyChanged += target.NewValue_PropertyChanged; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(d, "OnItemDataPropertyChanged()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + private void NewValue_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (sender is M_BasketItem newValue) + { + switch (e.PropertyName) + { + case "Count": + case "Price": + this.ItemPrice.Text = (newValue.Count * newValue.Price).ToString("#,##0"); + break; + } + } + } + + private void DeleteItem_MouseClicked(object sender, RoutedEventArgs e) + { + //RaiseMouseClickedEvent(this.ItemData); + DeleteAnimationRun(); + } + private void OptionChange_MouseClicked(object sender, RoutedEventArgs e) + { + try + { + if (this.ItemData.Option is List + && this.ItemData.Option.Count > 0) + { + var newOptions = new List(); + foreach (var aOptionGroup in this.ItemData.Option) + { + newOptions.Add(aOptionGroup.Clone()); + } + var popupReturn = popupManager.OpenOptionSelect(this.ItemData.ItemName + , newOptions + , this.ItemData.ItemImage + , this.ItemData.Count + , this.ItemData.BasePrice - this.ItemData.CampaignPrice + , true); + if (popupReturn is M_PopupReturn) + { + if (popupReturn.OKAnswer) + { + if (popupReturn.PopupArgs is M_OptionReturn getOption) + { + this.ItemData.Option = getOption.Options; + this.ItemData.Count = getOption.ItemCount; + this.ItemData.Price = getOption.PriceWithOption; + this.ItemData.AllOptionLabel = CommonFunction.GetOptionLabel(getOption.Options); + } + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OptionChange_MouseClicked()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + #endregion Event Handlers + + } +} diff --git a/Kiosk/PB/SPC.Kiosk.PB/DetailBasketItems.xaml b/Kiosk/PB/SPC.Kiosk.PB/DetailBasketItems.xaml new file mode 100644 index 0000000..639e566 --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/DetailBasketItems.xaml @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/Kiosk/PB/SPC.Kiosk.PB/DetailBasketItems.xaml.cs b/Kiosk/PB/SPC.Kiosk.PB/DetailBasketItems.xaml.cs new file mode 100644 index 0000000..77fb228 --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/DetailBasketItems.xaml.cs @@ -0,0 +1,370 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.PB.Model; +namespace SPC.Kiosk.PB +{ + /// + /// DetailBasketItems.xaml에 대한 상호 작용 논리 + /// + public partial class DetailBasketItems : UserControl + { + #region [ Members ] + /// + /// ListItems + /// + public static readonly DependencyProperty ListItemsProperty = + DependencyProperty.Register(nameof(ListItems), typeof(ObservableCollection), typeof(DetailBasketItems), new PropertyMetadata(null, new PropertyChangedCallback(OnListItemsPropertyChanged))); + /// + /// Command + /// + public static readonly DependencyProperty CommandProperty = + DependencyProperty.Register(nameof(Command), typeof(ICommand), typeof(DetailBasketItems), new UIPropertyMetadata(null)); + /// + /// Horizontal Scroll Offset + /// + public static readonly DependencyProperty HorizontalOffsetProperty = + DependencyProperty.Register(nameof(HorizontalOffset), typeof(double), typeof(DetailBasketItems), new PropertyMetadata(0d, new PropertyChangedCallback(OnHorizontalOffsetPropertyChanged))); + /// + /// Display Language + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(DetailBasketItems), new PropertyMetadata(SupportLanguageType.ko, new PropertyChangedCallback(OnDisplayLanguageProperyChanged))); + /// + /// Default PageNo + /// + public static readonly DependencyProperty DefaultPageNoProperty = + DependencyProperty.Register(nameof(DefaultPageNo), typeof(int), typeof(DetailBasketItems), new PropertyMetadata(0, new PropertyChangedCallback(OnDefaultPageNoPropertyChanged))); + /// + /// Page Count + /// + public static readonly DependencyProperty PageCountProperty = + DependencyProperty.Register(nameof(PageCount), typeof(int), typeof(DetailBasketItems), new PropertyMetadata(0)); + + private int TargetPageNo = 0; + private double mouseDownXposition = -1; + private bool MoseDown = false; + /// + /// ListItems + /// + public ObservableCollection ListItems + { + get { return (ObservableCollection)GetValue(ListItemsProperty); } + set { SetValue(ListItemsProperty, value); } + } + /// + /// Command + /// + public ICommand Command + { + get { return (ICommand)GetValue(CommandProperty); } + set { SetValue(CommandProperty, value); } + } + /// + /// HorizontalOffset + /// + public double HorizontalOffset + { + get { return (double)GetValue(HorizontalOffsetProperty); } + set { SetValue(HorizontalOffsetProperty, value); } + } + /// + /// Display Language + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + /// + /// DefaultPageNo + /// + public int DefaultPageNo + { + get { return (int)GetValue(DefaultPageNoProperty); } + set { SetValue(DefaultPageNoProperty, value); } + } + /// + /// Page Count + /// + public int PageCount + { + get { return (int)GetValue(PageCountProperty); } + set { SetValue(PageCountProperty, value); } + } + #region [ RoutedEvent 'MouseClicked' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent MouseClickedEvent = EventManager.RegisterRoutedEvent(nameof(MouseClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(DetailBasketItems)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler MouseClicked + { + add { AddHandler(MouseClickedEvent, value); } + remove { RemoveHandler(MouseClickedEvent, value); } + } + #endregion RoutedEvent 'MouseClicked' + + #endregion Members + + #region [ Ctor & Etc ] + /// + /// Ctor + /// + public DetailBasketItems() + { + InitializeComponent(); + this.Unloaded += DetailBasketItems_Unloaded; + } + + #endregion Ctor & Etc + + #region [ Methods ] + /// + /// Raise MouseClicked Event + /// + private void RaiseMouseClickedEvent(object _sender) + { + //Command Excute + if (Command != null && Command.CanExecute(_sender)) + { + Command.Execute(_sender); + } + RoutedEventArgs newEventArgs = new RoutedEventArgs(DetailBasketItems.MouseClickedEvent, _sender); + RaiseEvent(newEventArgs); + } + private void FlipItem(FrameworkElement _target) + { + try + { + var targetAnimation = new Storyboard(); + var getAnimations = Animations.GetMoveAnimation(_target, OpenCloseAnimationType.GotoDown, _target.ActualHeight *-1, 0, 0.5, 1, 0.5); + foreach (var aAnimation in getAnimations) targetAnimation.Children.Add(aAnimation); + targetAnimation.Begin(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "FlipItem()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + private void ItemsButtonCreate(object _listItems) + { + try + { + this.GridEventsRemove(); + this.MainStack.Children.Clear(); + if (_listItems is ObservableCollection lstItems && lstItems.Count > 0) + { + foreach (var aItem in lstItems) + { + var newItemObject = new DetailBasketItem(); + newItemObject.ItemData = aItem; + newItemObject.DisplayLanguage = this.DisplayLanguage; + newItemObject.Name = string.Format("ItemStack{0}", aItem.Index); + this.ReregisterName(newItemObject.Name, newItemObject); + this.MainStack.Children.Add(newItemObject); + } + this.UpdateLayout(); + CommonFunction.ReregisterName(this.Parent as FrameworkElement, this.Name, this); + + this.GridEventsSet(); + this.DefaultPageNo = 0; + this.PageCount = lstItems.Count / 5 + (lstItems.Count % 5 > 0 ? 1 : 0); + } + else + { + this.PageCount = 0; + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ItemsButtonCreate()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// Events Set + /// + public void GridEventsSet() + { + try + { + MainGrid.PreviewMouseDown += Grid_PreviewMouseDown; + MainGrid.PreviewMouseUp += MainGrid_PreviewMouseUp; + foreach (var aItem in this.MainStack.Children) + { + if (aItem is DetailBasketItem ItemContent) + { + ItemContent.MouseClicked += ItemContent_MouseClicked; + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GridEventsSet()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + + + /// + /// Events Remove + /// + public void GridEventsRemove() + { + try + { + MainGrid.PreviewMouseDown -= Grid_PreviewMouseDown; + MainGrid.PreviewMouseMove -= MainGrid_PreviewMouseUp; + foreach (var aItem in this.MainStack.Children) + { + if (aItem is DetailBasketItem ItemContent) + { + ItemContent.MouseClicked -= ItemContent_MouseClicked; + } + } + this.MainStack.Children.Clear(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GridEventsRemove()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + public void ChangePageTo(int _toPageNo) + { + try + { + if (_toPageNo > -1 && _toPageNo < PageCount) + { + var fromOffset = 0d; + var toOffset = 0d; + var totalTime = 0.3; + fromOffset = this.MainScroll.HorizontalOffset; + toOffset = this.Width * _toPageNo; + var scrollAnimation = Animations.GetScrollAnimation(this, Orientation.Horizontal, fromOffset, toOffset, totalTime); + if (scrollAnimation != null) + { + scrollAnimation.Completed += ScrollAnimation_Completed; + scrollAnimation.Begin(); + } + TargetPageNo = _toPageNo; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ChangePageTo()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + #endregion Methods + + #region [ Event Handlers ] + private void ScrollAnimation_Completed(object sender, EventArgs e) + { + var targetGrid = this.FindName(string.Format("PageGrid{0}", TargetPageNo)); + if (targetGrid is Grid selectGrid) + { + DefaultPageNo = TargetPageNo; + selectGrid.IsEnabled = true; + } + } + + private void DetailBasketItems_Unloaded(object sender, RoutedEventArgs e) + { + this.MainStack.Children.Clear(); + this.ListItems = null; + } + private static void OnDisplayLanguageProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + try + { + if (e.NewValue is SupportLanguageType newValue && !e.NewValue.Equals(e.OldValue)) + { + var target = d as DetailBasketItems; + foreach (var aItem in target.MainStack.Children) + { + if (aItem is DetailBasketItem ItemContent) + { + ItemContent.DisplayLanguage = newValue; + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(d, "OnDisplayLanguageProperyChanged()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + private static void OnHorizontalOffsetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != e.OldValue) + { + var target = d as DetailBasketItems; + target.MainScroll.ScrollToHorizontalOffset((double)e.NewValue); + } + } + private static void OnDefaultPageNoPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null) + { + + var target = d as DetailBasketItems; + target.ChangePageTo((int)e.NewValue); + } + } + private static void OnListItemsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as DetailBasketItems; + target.ItemsButtonCreate(e.NewValue); + } + + + private void Grid_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + var requstGrid = sender as Grid; + mouseDownXposition = e.GetPosition(sender as Grid).X; + MoseDown = true; + } + private void MainGrid_PreviewMouseUp(object sender, MouseEventArgs e) + { + if (!MoseDown) return; + var requstGrid = sender as Grid; + var curMouseXposition = e.GetPosition(requstGrid).X; + if (!mouseDownXposition.Equals(-1) && (mouseDownXposition - curMouseXposition) > 50) + { + if (this.DefaultPageNo < this.PageCount - 1) this.DefaultPageNo++; + } + else if (!mouseDownXposition.Equals(-1) && (mouseDownXposition - curMouseXposition) < -50) + { + if (this.DefaultPageNo > 0) this.DefaultPageNo--; + } + mouseDownXposition = curMouseXposition; + MoseDown = false; + } + + private void ItemContent_MouseClicked(object sender, RoutedEventArgs e) + { + RaiseMouseClickedEvent(e.OriginalSource); + } + + #endregion Event Handlers + } +} diff --git a/Kiosk/PB/SPC.Kiosk.PB/DiscountAndValue.xaml b/Kiosk/PB/SPC.Kiosk.PB/DiscountAndValue.xaml new file mode 100644 index 0000000..a30cf4b --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/DiscountAndValue.xaml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + diff --git a/Kiosk/PB/SPC.Kiosk.PB/DiscountAndValue.xaml.cs b/Kiosk/PB/SPC.Kiosk.PB/DiscountAndValue.xaml.cs new file mode 100644 index 0000000..68fb0de --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/DiscountAndValue.xaml.cs @@ -0,0 +1,107 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.PB.Model; + +namespace SPC.Kiosk.PB +{ + /// + /// DiscountAndValue.xaml에 대한 상호 작용 논리 + /// + public partial class DiscountAndValue : UserControl + { + #region [ Members ] + /// + /// ItemData + /// + public static readonly DependencyProperty ItemDataProperty = + DependencyProperty.Register(nameof(ItemData), typeof(M_DiscountAndAddValues), typeof(DiscountAndValue), new PropertyMetadata(null, new PropertyChangedCallback(OnItemDataPropertyChanged))); + /// + /// Display Language + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(DiscountAndValue), new PropertyMetadata(SupportLanguageType.ko)); + + + /// + /// ItemData + /// + public M_DiscountAndAddValues ItemData + { + get { return (M_DiscountAndAddValues)GetValue(ItemDataProperty); } + set { SetValue(ItemDataProperty, value); } + } + /// + /// Display Language + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + + #endregion Members + + #region [ Ctor & Etc ] + /// + /// Ctor + /// + public DiscountAndValue() + { + //this.ItemName.Text = string.Empty; + InitializeComponent(); + } + #endregion Ctor & Etc + + #region [ Methods ] + #endregion Methods + + #region [ Event Handlers ] + private static void OnItemDataPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + try + { + if (e.NewValue is M_DiscountAndAddValues newValue) + { + var target = d as DiscountAndValue; + switch (newValue.DiscountType) + { + case PaymentsDiscountAndAddType.BonusGift: + target.ItemPrice.Foreground = new SolidColorBrush(Colors.Black); + target.ItemCount.Text = newValue.AddCount.ToString("#0"); + target.ItemPrice.Text = (newValue.AddCount * newValue.AddValue).ToString("#,##0"); + break; + case PaymentsDiscountAndAddType.None: + default: + target.ItemPrice.Foreground = new SolidColorBrush(Color.FromRgb(0xFE, 0x3E, 0x3E)); + target.ItemCount.Text = string.Empty; + target.ItemPrice.Text = (newValue.DiscountValue * -1).ToString("#,##0"); + break; + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(d, "OnItemDataPropertyChanged()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + #endregion Event Handlers + + } +} diff --git a/Kiosk/PB/SPC.Kiosk.PB/DiscountAndValues.xaml b/Kiosk/PB/SPC.Kiosk.PB/DiscountAndValues.xaml new file mode 100644 index 0000000..ce8f812 --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/DiscountAndValues.xaml @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/Kiosk/PB/SPC.Kiosk.PB/DiscountAndValues.xaml.cs b/Kiosk/PB/SPC.Kiosk.PB/DiscountAndValues.xaml.cs new file mode 100644 index 0000000..3eddf65 --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/DiscountAndValues.xaml.cs @@ -0,0 +1,259 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.PB.Model; +namespace SPC.Kiosk.PB +{ + /// + /// DiscountAndValues.xaml에 대한 상호 작용 논리 + /// + public partial class DiscountAndValues : UserControl + { + #region [ Members ] + /// + /// ListItems + /// + public static readonly DependencyProperty ListItemsProperty = + DependencyProperty.Register(nameof(ListItems), typeof(ObservableCollection), typeof(DiscountAndValues), new PropertyMetadata(null, new PropertyChangedCallback(OnListItemsPropertyChanged))); + /// + /// Vertical Scroll Offset + /// + public static readonly DependencyProperty VerticalOffsetProperty = + DependencyProperty.Register(nameof(VerticalOffset), typeof(double), typeof(DiscountAndValues), new PropertyMetadata(0d, new PropertyChangedCallback(OnVerticalOffsetPropertyChanged))); + /// + /// Display Language + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(DiscountAndValues), new PropertyMetadata(SupportLanguageType.ko, new PropertyChangedCallback(OnDisplayLanguageProperyChanged))); + + + private double mouseDownYposition = -1; + private bool MoseDown = false; + /// + /// ListItems + /// + public ObservableCollection ListItems + { + get { return (ObservableCollection)GetValue(ListItemsProperty); } + set { SetValue(ListItemsProperty, value); } + } + + /// + /// VerticalOffset + /// + public double VerticalOffset + { + get { return (double)GetValue(VerticalOffsetProperty); } + set { SetValue(VerticalOffsetProperty, value); } + } + /// + /// Display Language + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + + + #endregion Members + + #region [ Ctor & Etc ] + /// + /// Ctor + /// + public DiscountAndValues() + { + InitializeComponent(); + this.Unloaded += DiscountAndValues_Unloaded; + } + + #endregion Ctor & Etc + + #region [ Methods ] + private void FlipItem(FrameworkElement _target) + { + try + { + var targetAnimation = new Storyboard(); + var getAnimations = Animations.GetMoveAnimation(_target, OpenCloseAnimationType.GotoDown, _target.ActualHeight *-1, 0, 0.5, 1, 0.5); + foreach (var aAnimation in getAnimations) targetAnimation.Children.Add(aAnimation); + targetAnimation.Begin(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "FlipItem()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + private void ItemsButtonCreate(object _listItems) + { + try + { + this.GridEventsRemove(); + this.MainStack.Children.Clear(); + if (_listItems is ObservableCollection lstItems && lstItems.Count > 0) + { + var index = 0; + foreach (var aItem in lstItems) + { + var newItemObject = new DiscountAndValue(); + newItemObject.ItemData = aItem; + newItemObject.DisplayLanguage = this.DisplayLanguage; + newItemObject.Name = string.Format("ItemStack{0}", index); + this.ReregisterName(newItemObject.Name, newItemObject); + this.MainStack.Children.Add(newItemObject); + index++; + } + this.UpdateLayout(); + CommonFunction.ReregisterName(this.Parent as FrameworkElement, this.Name, this); + + this.GridEventsSet(); + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ItemsButtonCreate()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// Events Set + /// + public void GridEventsSet() + { + try + { + MainGrid.PreviewMouseDown += Grid_PreviewMouseDown; + MainGrid.PreviewMouseUp += Grid_PreviewMouseUp; + MainGrid.PreviewMouseMove += MainGrid_PreviewMouseMove; + MainGrid.MouseLeave += MainGrid_MouseLeave; + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GridEventsSet()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + + + /// + /// Events Remove + /// + public void GridEventsRemove() + { + try + { + MainGrid.PreviewMouseDown -= Grid_PreviewMouseDown; + MainGrid.PreviewMouseUp -= Grid_PreviewMouseUp; + MainGrid.PreviewMouseMove -= MainGrid_PreviewMouseMove; + MainGrid.MouseLeave -= MainGrid_MouseLeave; + this.MainStack.Children.Clear(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GridEventsRemove()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + #endregion Methods + + #region [ Event Handlers ] + private void DiscountAndValues_Unloaded(object sender, RoutedEventArgs e) + { + this.MainStack.Children.Clear(); + this.ListItems = null; + } + private static void OnDisplayLanguageProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + try + { + if (e.NewValue is SupportLanguageType newValue && !e.NewValue.Equals(e.OldValue)) + { + var target = d as DiscountAndValues; + foreach (var aItem in target.MainStack.Children) + { + if (aItem is MiniBasketItem ItemContent) + { + ItemContent.DisplayLanguage = newValue; + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(d, "OnDisplayLanguageProperyChanged()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + private static void OnVerticalOffsetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != e.OldValue) + { + var target = d as DiscountAndValues; + target.MainScroll.ScrollToVerticalOffset((double)e.NewValue); + } + } + + private static void OnListItemsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as DiscountAndValues; + target.VerticalOffset = target.VerticalOffset + target.ActualHeight; + int oldCount = e.OldValue is ObservableCollection oldValue ? oldValue.Count : 0; + int newCount = e.NewValue is ObservableCollection newValue ? newValue.Count : 0; + target.ItemsButtonCreate(e.NewValue); + //if (newCount > oldCount ) + //{ + // if (target.VerticalOffset > 0) target.VerticalOffset = 0; + // if (newCount.Equals(oldCount + 1)) + // { + // target.FlipItem(target.MainStack.Children[0] as FrameworkElement); + // } + // else + // { + // target.FlipItem(target.MainStack as FrameworkElement); + // } + //} + } + + + private void Grid_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + var requstGrid = sender as Grid; + mouseDownYposition = e.GetPosition(sender as Grid).Y; + MoseDown = true; + } + private void MainGrid_PreviewMouseMove(object sender, MouseEventArgs e) + { + if (!MoseDown) return; + var requstGrid = sender as Grid; + var curMouseYposition = e.GetPosition(requstGrid).Y; + VerticalOffset = VerticalOffset + (mouseDownYposition - curMouseYposition) * 2; + mouseDownYposition = curMouseYposition; + } + + private void Grid_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + MoseDown = false; + } + private void MainGrid_MouseLeave(object sender, MouseEventArgs e) + { + MoseDown = false; + } + #endregion Event Handlers + } +} diff --git a/Kiosk/PB/SPC.Kiosk.PB/MiniBasketItem.xaml b/Kiosk/PB/SPC.Kiosk.PB/MiniBasketItem.xaml new file mode 100644 index 0000000..b95567a --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/MiniBasketItem.xaml @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/PB/SPC.Kiosk.PB/MiniBasketItem.xaml.cs b/Kiosk/PB/SPC.Kiosk.PB/MiniBasketItem.xaml.cs new file mode 100644 index 0000000..1932efc --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/MiniBasketItem.xaml.cs @@ -0,0 +1,199 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.PB.Model; + +namespace SPC.Kiosk.PB +{ + /// + /// MiniBasketItem.xaml에 대한 상호 작용 논리 + /// + public partial class MiniBasketItem : UserControl + { + #region [ Members ] + /// + /// ItemData + /// + public static readonly DependencyProperty ItemDataProperty = + DependencyProperty.Register(nameof(ItemData), typeof(M_BasketItem), typeof(MiniBasketItem), new PropertyMetadata(null, new PropertyChangedCallback(OnItemDataPropertyChanged))); + /// + /// Display Language + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(MiniBasketItem), new PropertyMetadata(SupportLanguageType.ko)); + + + /// + /// ItemData + /// + public M_BasketItem ItemData + { + get { return (M_BasketItem)GetValue(ItemDataProperty); } + set { SetValue(ItemDataProperty, value); } + } + /// + /// Display Language + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + #region [ RoutedEvent 'MouseClicked' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent MouseClickedEvent = EventManager.RegisterRoutedEvent(nameof(MouseClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MiniBasketItem)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler MouseClicked + { + add { AddHandler(MouseClickedEvent, value); } + remove { RemoveHandler(MouseClickedEvent, value); } + } + #endregion RoutedEvent 'MouseClicked' + public string BackImage { get; set;} + public string DeleteImageData { get; set; } + public string DeleteDownImageData { get; set; } + #endregion Members + + #region [ Ctor & Etc ] + /// + /// Ctor + /// + public MiniBasketItem() + { + BackImage=ResourceManager.GetNximagePathAdd("bg_basket_box.png", CommonValue.PBdesignImagesPath); + DeleteImageData = ResourceManager.GetNximagePathAdd("btn_delete_2.png", CommonValue.PBdesignImagesPath); + DeleteDownImageData = ResourceManager.GetNximagePathAdd("btn_delete_2_p.png", CommonValue.PBdesignImagesPath); + InitializeComponent(); + } + #endregion Ctor & Etc + + #region [ Methods ] + /// + /// Raise MouseClicked Event + /// + private void RaiseMouseClickedEvent(object _sender) + { + RoutedEventArgs newEventArgs = new RoutedEventArgs(MiniBasketItem.MouseClickedEvent, _sender); + RaiseEvent(newEventArgs); + } + private void DeleteAnimationRun() + { + var deteleAnimation = Animations.GetShutterAnimation(this.MainGrid, ShutterAnchor.Right, this.MainGrid.ActualWidth, 0, 1, 0.5, 0.3); + deteleAnimation.Completed += DeteleAnimation_Completed; + deteleAnimation.Begin(); + } + #endregion Methods + + #region [ Event Handlers ] + private void DeteleAnimation_Completed(object sender, EventArgs e) + { + RaiseMouseClickedEvent(this.ItemData); + } + private static void OnItemDataPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + try + { + if (e.NewValue is M_BasketItem newValue) + { + var target = d as MiniBasketItem; + if (e.OldValue is M_BasketItem oldValue) + { + oldValue.PropertyChanged -= target.NewValue_PropertyChanged; + } + target.ItemPrice.Text = (newValue.Count * newValue.Price).ToString("#,##0"); + target.ItemCountCombo.LeftButtonData = new M_AnimationButton + { + NormalBrush = newValue.MinusNormalBrush, + DownBrush = newValue.MinusDownBrush, + BrushStretch = Stretch.Fill, + DragEnable = false, + Width = 36, + Height = 36, + Switch = false, + AutoToggle = false, + TextVisible = Visibility.Collapsed, + ClickAnimationType = ButtonAnimationType.None, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty, + }; + target.ItemCountCombo.RightButtonData = new M_AnimationButton + { + NormalBrush = newValue.PlusNormalBrush, + DownBrush = newValue.PlusDownBrush, + BrushStretch = Stretch.Fill, + DragEnable = false, + Width = 36, + Height = 36, + Switch = false, + AutoToggle = false, + TextVisible = Visibility.Collapsed, + ClickAnimationType = ButtonAnimationType.None, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty, + }; + + newValue.PropertyChanged += target.NewValue_PropertyChanged; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(d, "OnItemDataPropertyChanged()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + private void NewValue_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + try + { + if (sender is M_BasketItem newValue) + { + switch (e.PropertyName) + { + case "Count": + case "Price": + this.Dispatcher.Invoke((Action)(() => + { + Animations.GetClickAnimation(this.MainGrid, ButtonAnimationType.FlipY, 0.2).Begin(); + ItemPrice.Text = (newValue.Count * newValue.Price).ToString("#,##0"); + })); + break; + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "NewValue_PropertyChanged()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + private void DeleteItem_MouseClicked(object sender, RoutedEventArgs e) + { + DeleteAnimationRun(); + } + + #endregion Event Handlers + + } +} diff --git a/Kiosk/PB/SPC.Kiosk.PB/MiniBasketItems.xaml b/Kiosk/PB/SPC.Kiosk.PB/MiniBasketItems.xaml new file mode 100644 index 0000000..a2d9af0 --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/MiniBasketItems.xaml @@ -0,0 +1,17 @@ + + + + + + + + + diff --git a/Kiosk/PB/SPC.Kiosk.PB/MiniBasketItems.xaml.cs b/Kiosk/PB/SPC.Kiosk.PB/MiniBasketItems.xaml.cs new file mode 100644 index 0000000..c168a7d --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/MiniBasketItems.xaml.cs @@ -0,0 +1,317 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.PB.Model; +namespace SPC.Kiosk.PB +{ + /// + /// MiniBasketItems.xaml에 대한 상호 작용 논리 + /// + public partial class MiniBasketItems : UserControl + { + #region [ Members ] + /// + /// ListItems + /// + public static readonly DependencyProperty ListItemsProperty = + DependencyProperty.Register(nameof(ListItems), typeof(ObservableCollection), typeof(MiniBasketItems), new PropertyMetadata(null, new PropertyChangedCallback(OnListItemsPropertyChanged))); + /// + /// Command + /// + public static readonly DependencyProperty CommandProperty = + DependencyProperty.Register(nameof(Command), typeof(ICommand), typeof(MiniBasketItems), new UIPropertyMetadata(null)); + /// + /// Vertical Scroll Offset + /// + public static readonly DependencyProperty VerticalOffsetProperty = + DependencyProperty.Register(nameof(VerticalOffset), typeof(double), typeof(MiniBasketItems), new PropertyMetadata(0d, new PropertyChangedCallback(OnVerticalOffsetPropertyChanged))); + /// + /// Display Language + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(MiniBasketItems), new PropertyMetadata(SupportLanguageType.ko, new PropertyChangedCallback(OnDisplayLanguageProperyChanged))); + + + private double mouseDownYposition = -1; + private bool MoseDown = false; + /// + /// ListItems + /// + public ObservableCollection ListItems + { + get { return (ObservableCollection)GetValue(ListItemsProperty); } + set { SetValue(ListItemsProperty, value); } + } + /// + /// Command + /// + public ICommand Command + { + get { return (ICommand)GetValue(CommandProperty); } + set { SetValue(CommandProperty, value); } + } + /// + /// VerticalOffset + /// + public double VerticalOffset + { + get { return (double)GetValue(VerticalOffsetProperty); } + set { SetValue(VerticalOffsetProperty, value); } + } + /// + /// Display Language + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + + #region [ RoutedEvent 'MouseClicked' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent MouseClickedEvent = EventManager.RegisterRoutedEvent(nameof(MouseClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MiniBasketItems)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler MouseClicked + { + add { AddHandler(MouseClickedEvent, value); } + remove { RemoveHandler(MouseClickedEvent, value); } + } + #endregion RoutedEvent 'MouseClicked' + + #endregion Members + + #region [ Ctor & Etc ] + /// + /// Ctor + /// + public MiniBasketItems() + { + InitializeComponent(); + this.Unloaded += MiniBasketItems_Unloaded; + } + + #endregion Ctor & Etc + + #region [ Methods ] + /// + /// Raise MouseClicked Event + /// + private void RaiseMouseClickedEvent(object _sender) + { + //Command Excute + if (Command != null && Command.CanExecute(_sender)) + { + Command.Execute(_sender); + } + RoutedEventArgs newEventArgs = new RoutedEventArgs(MiniBasketItems.MouseClickedEvent, _sender); + RaiseEvent(newEventArgs); + } + private void FlipItem(FrameworkElement _target) + { + try + { + var targetAnimation = new Storyboard(); + var getAnimations = Animations.GetMoveAnimation(_target, OpenCloseAnimationType.GotoDown, _target.ActualHeight *-1, 0, 0.5, 1, 0.5); + foreach (var aAnimation in getAnimations) targetAnimation.Children.Add(aAnimation); + targetAnimation.Begin(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "FlipItem()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + private void ItemsButtonCreate(object _listItems) + { + try + { + this.GridEventsRemove(); + this.MainStack.Children.Clear(); + if (_listItems is ObservableCollection lstItems && lstItems.Count > 0) + { + foreach (var aItem in lstItems) + { + var newItemObject = new MiniBasketItem(); + newItemObject.ItemData = aItem; + newItemObject.DisplayLanguage = this.DisplayLanguage; + newItemObject.Name = string.Format("ItemStack{0}", aItem.Index); + this.ReregisterName(newItemObject.Name, newItemObject); + this.MainStack.Children.Add(newItemObject); + } + this.UpdateLayout(); + CommonFunction.ReregisterName(this.Parent as FrameworkElement, this.Name, this); + + this.GridEventsSet(); + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ItemsButtonCreate()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// Events Set + /// + public void GridEventsSet() + { + try + { + MainGrid.PreviewMouseDown += Grid_PreviewMouseDown; + MainGrid.PreviewMouseUp += Grid_PreviewMouseUp; + MainGrid.PreviewMouseMove += MainGrid_PreviewMouseMove; + MainGrid.MouseLeave += MainGrid_MouseLeave; + foreach (var aItem in this.MainStack.Children) + { + if (aItem is MiniBasketItem ItemContent) + { + ItemContent.MouseClicked += ItemContent_MouseClicked; + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GridEventsSet()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + + + /// + /// Events Remove + /// + public void GridEventsRemove() + { + try + { + MainGrid.PreviewMouseDown -= Grid_PreviewMouseDown; + MainGrid.PreviewMouseUp -= Grid_PreviewMouseUp; + MainGrid.PreviewMouseMove -= MainGrid_PreviewMouseMove; + MainGrid.MouseLeave -= MainGrid_MouseLeave; + foreach (var aItem in this.MainStack.Children) + { + if (aItem is MiniBasketItem ItemContent) + { + ItemContent.MouseClicked -= ItemContent_MouseClicked; + } + } + this.MainStack.Children.Clear(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GridEventsRemove()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + #endregion Methods + + #region [ Event Handlers ] + private void MiniBasketItems_Unloaded(object sender, RoutedEventArgs e) + { + this.MainStack.Children.Clear(); + this.ListItems = null; + } + private static void OnDisplayLanguageProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + try + { + if (e.NewValue is SupportLanguageType newValue && !e.NewValue.Equals(e.OldValue)) + { + var target = d as MiniBasketItems; + foreach (var aItem in target.MainStack.Children) + { + if (aItem is MiniBasketItem ItemContent) + { + ItemContent.DisplayLanguage = newValue; + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(d, "OnDisplayLanguageProperyChanged()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + private static void OnVerticalOffsetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != e.OldValue) + { + var target = d as MiniBasketItems; + target.MainScroll.ScrollToVerticalOffset((double)e.NewValue); + } + } + + private static void OnListItemsPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as MiniBasketItems; + int oldCount = e.OldValue is ObservableCollection oldValue ? oldValue.Count : 0; + int newCount = e.NewValue is ObservableCollection newValue ? newValue.Count : 0; + if (target.VerticalOffset > 0) target.VerticalOffset = 0; + target.ItemsButtonCreate(e.NewValue); + if (newCount > oldCount ) + { + if (newCount.Equals(oldCount + 1)) + { + target.FlipItem(target.MainStack.Children[0] as FrameworkElement); + } + else + { + target.FlipItem(target.MainStack as FrameworkElement); + } + } + } + + + private void Grid_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + var requstGrid = sender as Grid; + mouseDownYposition = e.GetPosition(sender as Grid).Y; + MoseDown = true; + } + private void MainGrid_PreviewMouseMove(object sender, MouseEventArgs e) + { + if (!MoseDown) return; + var requstGrid = sender as Grid; + var curMouseYposition = e.GetPosition(requstGrid).Y; + VerticalOffset = VerticalOffset + (mouseDownYposition - curMouseYposition) * 2; + mouseDownYposition = curMouseYposition; + + } + + private void Grid_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + MoseDown = false; + } + private void MainGrid_MouseLeave(object sender, MouseEventArgs e) + { + MoseDown = false; + } + + private void ItemContent_MouseClicked(object sender, RoutedEventArgs e) + { + RaiseMouseClickedEvent(e.OriginalSource); + } + + #endregion Event Handlers + } +} diff --git a/Kiosk/PB/SPC.Kiosk.PB/PBPaymentsWindow.xaml b/Kiosk/PB/SPC.Kiosk.PB/PBPaymentsWindow.xaml new file mode 100644 index 0000000..5d61c53 --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/PBPaymentsWindow.xaml @@ -0,0 +1,1512 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/PB/SPC.Kiosk.PB/PBPaymentsWindow.xaml.cs b/Kiosk/PB/SPC.Kiosk.PB/PBPaymentsWindow.xaml.cs new file mode 100644 index 0000000..bb58e6d --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/PBPaymentsWindow.xaml.cs @@ -0,0 +1,303 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Windows; +using System.Runtime.InteropServices; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Forms; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using System.Threading.Tasks; +using SPC.Kiosk.Common; +using SPC.Kiosk.PB.Model; +using SPC.Kiosk.PB.ViewModel; +using SPC.Kiosk.Popup.Model; +namespace SPC.Kiosk.PB +{ + /// + /// PBPayments.xaml에 대한 상호 작용 논리 + /// + public partial class PBPaymentsWindow : Window + { + #region [ Members ] + private PBPaymentPageType ShowPage { get; set; } + private int ScreenNo { get; set; } = 0; + + private PBPaymentsViewModel ViewModel { get; set; } + private M_HappyPointReturn GetHappyPointReturn { get; set; } + private ObservableCollection GetBasketItems { get; set; } + private double GetPayments { get; set; } + + #endregion Members + + #region [ Ctor/Etc ] + /// + /// Ctor + /// + public PBPaymentsWindow() + { + StartInitialize(); + } + /// + /// Ctor + /// + /// + /// + /// + public PBPaymentsWindow(ObservableCollection _getBasketItems + , M_HappyPointReturn _getHappyPointReturn + , PBPaymentPageType _startPBPaymentPage) + { + GetHappyPointReturn = _getHappyPointReturn; + GetBasketItems = _getBasketItems; + StartInitialize(); + ShowPage = _startPBPaymentPage; + switch (_startPBPaymentPage) + { + //case PBPaymentPageType.PaymentsSelect: + // ContentGrid.Visibility = Visibility.Hidden; + // PaymentSelectGrid.RenderTransform = new TranslateTransform(0, 0); + // break; + case PBPaymentPageType.PointsDisCounts: + //PaymentSelectGrid.Visibility = Visibility.Hidden; + DetailBasketGrid.Visibility = Visibility.Hidden; + PaymentsGrid.Visibility = Visibility.Visible; + PointsDisCountsGrid.Visibility = Visibility.Visible; + CouponUsePointsGrid.Visibility = Visibility.Hidden; + PaymentExcuteGrid.Visibility = Visibility.Hidden; + PointsDisCountsGrid.RenderTransform = new TranslateTransform(0, 0); + CouponUsePointsGrid.RenderTransform = new TranslateTransform(CouponUsePointsGrid.Width, 0); + PaymentExcuteGrid.RenderTransform = new TranslateTransform(PaymentExcuteGrid.Width, 0); + break; + case PBPaymentPageType.CouponUsePoints: + //PaymentSelectGrid.Visibility = Visibility.Hidden; + DetailBasketGrid.Visibility = Visibility.Hidden; + PaymentsGrid.Visibility = Visibility.Visible; + PointsDisCountsGrid.Visibility = Visibility.Hidden; + CouponUsePointsGrid.Visibility = Visibility.Visible; + PaymentExcuteGrid.Visibility = Visibility.Hidden; + PointsDisCountsGrid.RenderTransform = new TranslateTransform(PointsDisCountsGrid.Width, 0); + CouponUsePointsGrid.RenderTransform = new TranslateTransform(0, 0); + PaymentExcuteGrid.RenderTransform = new TranslateTransform(PaymentExcuteGrid.Width, 0); + break; + case PBPaymentPageType.PaymentExcute: + //PaymentSelectGrid.Visibility = Visibility.Hidden; + DetailBasketGrid.Visibility = Visibility.Hidden; + PaymentsGrid.Visibility = Visibility.Visible; + PointsDisCountsGrid.Visibility = Visibility.Hidden; + CouponUsePointsGrid.Visibility = Visibility.Hidden; + PaymentExcuteGrid.Visibility = Visibility.Visible; + PointsDisCountsGrid.RenderTransform = new TranslateTransform(PointsDisCountsGrid.Width, 0); + CouponUsePointsGrid.RenderTransform = new TranslateTransform(CouponUsePointsGrid.Width, 0); + PaymentExcuteGrid.RenderTransform = new TranslateTransform(0, 0); + break; + case PBPaymentPageType.DetailBasket: + //PaymentSelectGrid.Visibility = Visibility.Hidden; + DetailBasketGrid.Visibility = Visibility.Visible; + PaymentsGrid.Visibility = Visibility.Hidden; + PointsDisCountsGrid.RenderTransform = new TranslateTransform(0, 0); + //PaymentSelectGrid.RenderTransform = new TranslateTransform(PaymentSelectGrid.Width, 0); + break; + + } + } + + #endregion + + #region [ Methods ] + private void StartInitialize() + { + InitializeComponent(); + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + this.Loaded += PBPayments_Loaded; + } + private void SetPage() + { + if (!ShowPage.Equals(ViewModel.DefaultPage)) + { + switch (ShowPage) + { + case PBPaymentPageType.DetailBasket: + switch (ViewModel.DefaultPage) + { + case PBPaymentPageType.PointsDisCounts: + PaymentsGrid.Visibility = Visibility.Visible; + PaymentsGrid.RenderTransform = new TranslateTransform(PaymentsGrid.Width, 0); + OpenAndClose(this.DetailBasketGrid, this.PaymentsGrid, OpenCloseAnimationType.GotoLeft); + break; + } + break; + case PBPaymentPageType.PointsDisCounts: + switch (ViewModel.DefaultPage) + { + case PBPaymentPageType.DetailBasket: + OpenAndClose(this.PaymentsGrid, this.DetailBasketGrid, OpenCloseAnimationType.GotoRight); + break; + case PBPaymentPageType.CouponUsePoints: + OpenAndClose(this.PointsDisCountsGrid, this.CouponUsePointsGrid, OpenCloseAnimationType.GotoLeft); + break; + case PBPaymentPageType.PaymentExcute: + OpenAndClose(this.PointsDisCountsGrid, this.PaymentExcuteGrid, OpenCloseAnimationType.GotoLeft); + break; + } + break; + case PBPaymentPageType.CouponUsePoints: + switch (ViewModel.DefaultPage) + { + case PBPaymentPageType.PointsDisCounts: + OpenAndClose(this.CouponUsePointsGrid, this.PointsDisCountsGrid, OpenCloseAnimationType.GotoRight); + break; + case PBPaymentPageType.PaymentExcute: + OpenAndClose(this.CouponUsePointsGrid, this.PaymentExcuteGrid, OpenCloseAnimationType.GotoLeft); + break; + case PBPaymentPageType.MoreVIewPoints: + OpenAndClose(this.CouponUsePointsGrid, this.MoreViewPointGrid, OpenCloseAnimationType.GotoRight); + break; + } + break; + + case PBPaymentPageType.MoreVIewPoints: + switch (ViewModel.DefaultPage) + { + + case PBPaymentPageType.PointsDisCounts: + OpenAndClose(this.MoreViewPointGrid, this.PointsDisCountsGrid, OpenCloseAnimationType.GotoRight); + break; + case PBPaymentPageType.PaymentExcute: + OpenAndClose(this.MoreViewPointGrid, this.PaymentExcuteGrid, OpenCloseAnimationType.GotoLeft); + break; + case PBPaymentPageType.CouponUsePoints: + OpenAndClose(this.MoreViewPointGrid, this.CouponUsePointsGrid, OpenCloseAnimationType.GotoLeft); + break; + } + break; + case PBPaymentPageType.PaymentExcute: + switch (ViewModel.DefaultPage) + { + case PBPaymentPageType.PointsDisCounts: + OpenAndClose(this.PaymentExcuteGrid, this.PointsDisCountsGrid, OpenCloseAnimationType.GotoRight); + break; + case PBPaymentPageType.CouponUsePoints: + OpenAndClose(this.PaymentExcuteGrid, this.CouponUsePointsGrid, OpenCloseAnimationType.GotoRight); + break; + } + break; + + } + } + } + private void OpenBase() + { + this.PaymentsMainGrid.IsEnabled = false; + var OpenAnimations = Animations.GetOpenAnimation(this.TopGrid, OpenCloseAnimationType.FullSizeUp, this.TopGrid.Width, 0.5); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Name = this.PaymentsMainGrid.Name; + OpenAnimations.Begin(); + } + + } + private void CloseBase() + { + var CloseAnimation = Animations.GetCloseAnimation(this.TopGrid, OpenCloseAnimationType.FullSizeDown, this.TopGrid.Width, 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + private void OpenAndClose(Grid _closeGrid, Grid _openGrid, OpenCloseAnimationType _animationType) + { + var OpenAnimations = Animations.GetOpenAndCloseAnimation(_closeGrid, _openGrid, _animationType, _closeGrid.ActualWidth, 0.3); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Name = _openGrid.Name; + OpenAnimations.Begin(); + } + } + #endregion Methods + + #region [ Event Handlers ] + private void PBPayments_Loaded(object sender, RoutedEventArgs e) + { + if (this.DataContext is PBPaymentsViewModel viewModel) + { + ViewModel = viewModel; + ViewModel.PropertyChanged += ViewModel_PropertyChanged; + ViewModel.HappyPointReturn = GetHappyPointReturn; + ViewModel.DetailBasketData = GetBasketItems; + ViewModel.DefaultPage = ShowPage; + if (GetHappyPointReturn is M_HappyPointReturn) + { + ViewModel.MemberLoginOK = true; + ViewModel.GmbMemberName = GetHappyPointReturn.IsCardNoUsed ? GetHappyPointReturn.MemberName : "고객"; + } + ViewModel.IsTimeoutPopup = true; + } + OpenBase(); + } + private void ViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + if (sender is PBPaymentsViewModel viewModel) + { + switch (e.PropertyName) + { + case "CanWindowClose": + if (this.ViewModel.CanWindowClose) + { + CloseBase(); + } + break; + case "DefaultPage": + SetPage(); + break; + default: + break; + } + } + } + + private void OpenAnimations_Completed(object sender, EventArgs e) + { + var senderStoryboard = (sender as ClockGroup).Timeline as Storyboard; + var getName = senderStoryboard.Name; + switch (senderStoryboard.Name) + { + case "PaymentsMainGrid": + break; + default: + this.ShowPage = ViewModel.DefaultPage; + break; + } + if (ShowPage.Equals(PBPaymentPageType.PointsDisCounts) + && this.ViewModel.FirstLoaded) + { + this.ViewModel.OpenFistPopup(); + } + if (this.FindName(getName) is Grid findGrid) findGrid.IsEnabled = true; + senderStoryboard = null; + + } + private void CloseAnimation_Completed(object sender, EventArgs e) + { + this.ViewModel.Dispose(); + this.Close(); + } + #endregion Event Handlers + + + + + } +} diff --git a/Kiosk/PB/SPC.Kiosk.PB/PBWindow.xaml b/Kiosk/PB/SPC.Kiosk.PB/PBWindow.xaml new file mode 100644 index 0000000..f62d5af --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/PBWindow.xaml @@ -0,0 +1,1631 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/PB/SPC.Kiosk.PB/PBWindow.xaml.cs b/Kiosk/PB/SPC.Kiosk.PB/PBWindow.xaml.cs new file mode 100644 index 0000000..9fe89c3 --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/PBWindow.xaml.cs @@ -0,0 +1,652 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Forms; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Animation; +using SPC.Kiosk.Common; +using System.Threading.Tasks; +using SPC.Kiosk.PB.Model; +using SPC.Kiosk.PB.ViewModel; +using SPC.Kiosk.Popup.Model; +using System.Windows.Interop; +using System.Windows.Threading; + +namespace SPC.Kiosk.PB +{ + /// + /// MainWindow.xaml에 대한 상호 작용 논리 + /// + public partial class PBWindow : Window + { + + #region [ Members ] + /// + /// IcReadStart Event + /// + /// + public delegate void IcReaderCheck(object sender); + /// + /// IcReadStart Event 반환용 + /// + public event IcReaderCheck ReaderCheck; + /// + /// PosRecipetRefund Event + /// + /// + public delegate void PosRecipetRefund(object sender); + /// + /// PosRecipetRefund Event 반환용 + /// + public event PosRecipetRefund RecipetRefund; + /// + /// PosRecipetReprint Event + /// + /// + public delegate void PosRecipetReprint(object sender); + /// + /// PosRecipetReprint Event 반환용 + /// + public event PosRecipetReprint RecipetReprint; + private VmPBViewModel ViewModel { get; set; } + private PBPageType ShowPage { get; set; } + private int ScreenNo { get; set; } = 0; + private DispatcherTimer BarcodeFocusing; + #endregion Members + + #region [ Ctor/Etc ] + /// + /// Ctor + /// + public PBWindow() + { + StartInitialize(); + } + /// + /// Ctor + /// + /// + public PBWindow(int _screenNo) + { + ScreenNo = _screenNo; + StartInitialize(); + } + #endregion + + #region [ Methods ] + + private void AiOpen(PBPageType _TargetPage) + { + //---------객체인식 화면 이동 시------------ + if (_TargetPage.Equals(PBPageType.Sensing)) + { + + this.Topmost = false; + if (this.ViewModel.OptionValue812 == "0") { this.GMB_CallButton.Visibility = Visibility.Collapsed; } + else { this.GMB_CallButton.Visibility = Visibility.Hidden; } + this.GMB_LanguageButton.Visibility = Visibility.Hidden; + this.GMB_PonitButton.Visibility = Visibility.Hidden; + this.ViewModel.ToIntorTimerStop(); + AiScannerProcess.ExcuteAiScanner(new WindowInteropHelper(this).Handle); + } + else + { + this.Topmost = true; + if (this.ViewModel.OptionValue812 == "0") { this.GMB_CallButton.Visibility = Visibility.Collapsed; } + else { this.GMB_CallButton.Visibility = Visibility.Visible; } + this.GMB_LanguageButton.Visibility = Visibility.Visible; + this.GMB_PonitButton.Visibility = Visibility.Visible; + //센싱 화면 종료 시 객체인식 프로세스 종료 + AiScannerProcess.StopAiScanner(); + this.ViewModel.ToIntorTimerStart(); + } + } + private void StartInitialize() + { + InitializeComponent(); + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + this.Loaded += PBWindow_Loaded; + } + private void GoRecipetReprint() + { + try + { + RecipetReprint(this); + } + catch + { + } + } + private void GoRecipetRefund() + { + try + { + RecipetRefund(this); + } + catch + { + } + } + private void GoReaderCheck() + { + try + { + ReaderCheck(this); + } + catch + { + } + } + private void SetPage(PBPageType _TargetPage) + { + switch (ShowPage) + { + case PBPageType.Intro: + switch (_TargetPage) + { + case PBPageType.Items: + ContentGrid.Visibility = Visibility.Visible; + FirstGrid.Visibility = Visibility.Hidden; + ItemGrid.Visibility = Visibility.Visible; + SenserGrid.Visibility = Visibility.Hidden; + ToggleGrid.Visibility = Visibility.Visible; + ContentGrid.RenderTransform = null; + ItemGrid.RenderTransform = null; + break; + case PBPageType.Sensing: + ContentGrid.Visibility = Visibility.Visible; + FirstGrid.Visibility = Visibility.Hidden; + ItemGrid.Visibility = Visibility.Hidden; + SenserGrid.Visibility = Visibility.Visible; + ToggleGrid.Visibility = Visibility.Visible; + SenserGrid.RenderTransform = null; + + break; + case PBPageType.FirstSelect: + ContentGrid.Visibility = Visibility.Visible; + FirstGrid.Visibility = Visibility.Visible; + ItemGrid.Visibility = Visibility.Hidden; + SenserGrid.Visibility = Visibility.Hidden; + ToggleGrid.Visibility = Visibility.Hidden; + FirstGrid.RenderTransform = null; + break; + } + OpenAndClose(this.BaseGrid, this.TradeGrid, OpenCloseAnimationType.GotoLeft); + break; + case PBPageType.FirstSelect: + switch (_TargetPage) + { + case PBPageType.Items: + SenserGrid.Visibility = Visibility.Hidden; + ItemGrid.Visibility = Visibility.Visible; + ToggleGrid.Visibility = Visibility.Visible; + ItemGrid.RenderTransform = new TranslateTransform(ItemGrid.Width, 0); + OpenAndClose(this.FirstGrid, this.ItemGrid, OpenCloseAnimationType.GotoLeft); + break; + case PBPageType.Sensing: + SenserGrid.Visibility = Visibility.Visible; + ItemGrid.Visibility = Visibility.Hidden; + ToggleGrid.Visibility = Visibility.Visible; + SenserGrid.RenderTransform = new TranslateTransform(SenserGrid.Width, 0); + OpenAndClose(this.FirstGrid, this.SenserGrid, OpenCloseAnimationType.GotoLeft); + break; + case PBPageType.Intro: + ItemGrid.Visibility = Visibility.Hidden; + SenserGrid.Visibility = Visibility.Hidden; + OpenAndClose(this.TradeGrid, this.BaseGrid, OpenCloseAnimationType.GotoRight); + break; + } + break; + case PBPageType.Items: + switch (_TargetPage) + { + case PBPageType.Intro: + SenserGrid.Visibility = Visibility.Hidden; + FirstGrid.Visibility = Visibility.Hidden; + OpenAndClose(this.TradeGrid, this.BaseGrid, OpenCloseAnimationType.GotoRight); + break; + case PBPageType.Sensing: + SenserGrid.Visibility = Visibility.Visible; + SenserGrid.RenderTransform = new TranslateTransform(SenserGrid.Width, 0); + OpenAndClose(this.ItemGrid, this.SenserGrid, OpenCloseAnimationType.GotoRight); + break; + case PBPageType.FirstSelect: + FirstGrid.Visibility = Visibility.Visible; + ToggleGrid.Visibility = Visibility.Hidden; + FirstGrid.RenderTransform = new TranslateTransform(FirstGrid.Width, 0); + OpenAndClose(this.ItemGrid, this.FirstGrid, OpenCloseAnimationType.GotoRight); + break; + } + break; + case PBPageType.Sensing: + + ScanFirst.Visibility = Visibility.Visible; + ScanSecond.Visibility = Visibility.Hidden; + switch (_TargetPage) + { + case PBPageType.Intro: + ItemGrid.Visibility = Visibility.Hidden; + FirstGrid.Visibility = Visibility.Hidden; + OpenAndClose(this.TradeGrid, this.BaseGrid, OpenCloseAnimationType.GotoRight); + break; + case PBPageType.Items: + ItemGrid.Visibility = Visibility.Visible; + ItemGrid.RenderTransform = new TranslateTransform(ItemGrid.Width * -1, 0); + OpenAndClose(this.SenserGrid, this.ItemGrid, OpenCloseAnimationType.GotoLeft); + break; + case PBPageType.FirstSelect: + FirstGrid.Visibility = Visibility.Visible; + ToggleGrid.Visibility = Visibility.Hidden; + FirstGrid.RenderTransform = new TranslateTransform(FirstGrid.Width, 0); + OpenAndClose(this.SenserGrid, this.FirstGrid, OpenCloseAnimationType.GotoRight); + break; + case PBPageType.Sensing: + this.ViewModel.SensingSubPage = PBSensingSubPageType.SensingPage; + ChangeWindow(); + break; + } + break; + } + } + private void ChangeWindow() + { + //this.Dispatcher.Invoke((Action)(() => + //{ + try + { + var _target = this.SenserGrid; + var targetAnimation = new Storyboard(); + var centerX = _target.ActualWidth / 2; + var centerY = _target.ActualHeight / 2; + _target.RenderTransform = new ScaleTransform(1, 1, centerX, centerY); + var flipXAni = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.2))); + Storyboard.SetTarget(flipXAni, _target); + Storyboard.SetTargetProperty(flipXAni, new PropertyPath("RenderTransform.ScaleX")); + targetAnimation.Children.Add(flipXAni); + targetAnimation.Completed += TargetAnimation_Completed; + targetAnimation.Begin(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ChangeWindow()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + //})); + } + private void ScanBoxEnable() + { + if (!this.BarCode.IsEnabled) this.BarCode.IsEnabled = true; + if (!this.BarCode.IsFocused) this.BarCode.Focus(); + } + private void ScanBoxDisable() + { + BarcodeFocusing.Stop(); + this.BarCode.IsEnabled = false; + } + private void TargetAnimation_Completed(object sender, EventArgs e) + { + ScanBoxEnable(); + } + private void GMBtoggle2Sensing() + { + var target = this.AiToggle; + var toSensing = new Storyboard(); + target.RenderTransform = new TranslateTransform(0, 0); + var toLeftAnimation = new DoubleAnimation(this.AiToggle.Width, 0, new Duration(TimeSpan.FromSeconds(0.2))); + Storyboard.SetTarget(toLeftAnimation, target); + Storyboard.SetTargetProperty(toLeftAnimation, new PropertyPath("RenderTransform.X")); + toSensing.Children.Add(toLeftAnimation); + toSensing.Completed += ToSensing_Completed; + toSensing.Begin(); + } + private void GMBtoggle2Order() + { + var target = this.AiToggle; + var toOrder = new Storyboard(); + target.RenderTransform = new TranslateTransform(0, 0); + var toLeftAnimation = new DoubleAnimation(0, this.AiToggle.Width, new Duration(TimeSpan.FromSeconds(0.2))); + Storyboard.SetTarget(toLeftAnimation, target); + Storyboard.SetTargetProperty(toLeftAnimation, new PropertyPath("RenderTransform.X")); + toOrder.Children.Add(toLeftAnimation); + toOrder.Completed += ToOrder_Completed; + toOrder.Begin(); + + } + private void OpenBase() + { + this.TradeGrid.IsEnabled = false; + this.TradeGrid.Visibility = Visibility.Hidden; + var OpenAnimations = Animations.GetOpenAnimation(this.TopGrid, OpenCloseAnimationType.FullSizeUp, this.Width, 0.5); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Name = this.BaseGrid.Name; + OpenAnimations.Begin(); + } + } + private void CloseBase() + { + var CloseAnimation = Animations.GetCloseAnimation(this.TopGrid, OpenCloseAnimationType.FullSizeDown, this.Width, 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + private void OpenAndClose(Grid _closeGrid, Grid _openGrid, OpenCloseAnimationType _animationType) + { + var OpenAnimations = Animations.GetOpenAndCloseAnimation(_closeGrid, _openGrid, _animationType, _closeGrid.ActualWidth, 0.3); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Name = _openGrid.Name; + OpenAnimations.Begin(); + } + } + private void OpenPaymentsWindow() + { + try + { + var newPBPayment = new PBPaymentsWindow(ViewModel.MiniBasketData + , ViewModel.HappyPointReturn + , ViewModel.OpenPBPaymentPage); + this.ViewModel.ToIntorTimerStop(); + this.ViewModel.WaitWindowFrom.ShowWaitWindow(); + newPBPayment.ShowDialog(); + this.ViewModel.WaitWindowFrom.CloseWaitWindow(); + this.ViewModel.ToIntorTimerStart(); + if (newPBPayment.DataContext is PBPaymentsViewModel returnViewModel) + { + ViewModel.ShowLanguageType = returnViewModel.ReturnValue.ReturnLanguage; + if (returnViewModel.ReturnValue.PopupArgs is List returnBasket + && returnBasket.Count > 0) + { + ViewModel.MiniBasketData = new System.Collections.ObjectModel.ObservableCollection(returnBasket); + } + else + { + ViewModel.DeledteAllBasket(); + } + if (returnViewModel.ReturnValue.TimeOut + || returnViewModel.ReturnValue.OKAnswer) ViewModel.DefaultPage = PBPageType.Intro; + } + newPBPayment = null; + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenPaymentsWindow()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + + } + #endregion Methods + + #region [ Event Handlers ] + private void PBWindow_Loaded(object sender, RoutedEventArgs e) + { + if (this.DataContext is VmPBViewModel viewModel) + { + ViewModel = viewModel; + viewModel.PropertyChanged += ViewModel_PropertyChanged; + ViewModel.IsTimeoutPopup = true; + } + this.BarCode.PreviewKeyDown += BarCode_PreviewKeyDown; + BarcodeFocusing = new DispatcherTimer + { + Interval = TimeSpan.FromMilliseconds(100d), + }; + BarcodeFocusing.Tick += BarcodeFocusing_Tick; + OpenBase(); + } + + private void BarcodeFocusing_Tick(object sender, EventArgs e) + { + try + { + if (this.ViewModel is VmPBViewModel) + { + if (ViewModel.DefaultPage.Equals(PBPageType.Sensing)) + { + ScanBoxEnable(); + } + } + + } + catch + { + } + } + + private void BarCode_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) + { + if (sender is System.Windows.Controls.TextBox textBox + && (e.Key.Equals(Key.Enter) || e.Key.Equals(Key.Return)) + && !string.IsNullOrEmpty(textBox.Text)) + { + this.ViewModel.ReadBarCode = textBox.Text.Trim(); + textBox.Text = string.Empty; + } + } + private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "DefaultPage": + SetPage(ViewModel.DefaultPage); + if (this.ViewModel.OptionValue810 == "0" + && this.ViewModel.OptionValue811 == "1") + { } + else + { + AiOpen(ViewModel.DefaultPage); + } + + break; + case "GmbReaderCheckOpen": + if (ViewModel.GmbReaderCheckOpen) + { + AiScannerProcess.StopAiScanner(); + this.ViewModel.ToIntorTimerStop(); + this.AdminGrid.Visibility = Visibility.Visible; + ViewModel.ReaderCheckClickCount = 0; + } + break; + case "OrderHistoryView": + if (this.ViewModel.OrderHistoryView + && this.ViewModel.DefaultPage.Equals(PBPageType.Items)) + { + this.OrderHisoty.Visibility = Visibility.Visible; + var OrderHisotyOpenAnimation = Animations.GetOpenAnimation(this.OrderHisotyItems, OpenCloseAnimationType.GotoUp, this.OrderHisotyItems.Height, 0.2); + if (OrderHisotyOpenAnimation != null) + { + OrderHisotyOpenAnimation.Completed += OrderHisotyOpenAnimation_Completed; + OrderHisotyOpenAnimation.Begin(); + } + } + else + { + var OrderHisotyCloseAnimation = Animations.GetCloseAnimation(this.OrderHisotyItems, OpenCloseAnimationType.GotoDown, this.OrderHisotyItems.Height, 0.2); + if (OrderHisotyCloseAnimation != null) + { + OrderHisotyCloseAnimation.Completed += OrderHisotyCloseAnimation_Completed; + OrderHisotyCloseAnimation.Begin(); + } + } + break; + case "SensingSubPage": + if (this.ViewModel.SensingSubPage.Equals(PBSensingSubPageType.BarcordPage)) + { + ScanFirst.Visibility = Visibility.Hidden; + ScanSecond.Visibility = Visibility.Visible; + ChangeWindow(); + } + break; + case "OpenPBPaymentPage": + OpenPaymentsWindow(); + break; + case "CanWindowClose": + CloseBase(); + break; + default: + break; + } + } + + private void OrderHisotyOpenAnimation_Completed(object sender, EventArgs e) + { + this.OrderHisotyItems.IsEnabled = true; + } + + private void OrderHisotyCloseAnimation_Completed(object sender, EventArgs e) + { + this.OrderHisoty.Visibility = Visibility.Collapsed; + } + + private void ToSensing_Completed(object sender, EventArgs e) + { + var senderStoryboard = (sender as ClockGroup).Timeline as Storyboard; + senderStoryboard = null; + this.SenserGrid.IsEnabled = true; + this.GMB_ic_order.Enabled = true; + BarcodeFocusing.Start(); + } + + + private void ToOrder_Completed(object sender, EventArgs e) + { + var senderStoryboard = (sender as ClockGroup).Timeline as Storyboard; + senderStoryboard = null; + this.ItemGrid.IsEnabled = true; + this.GMB_ai_order.Enabled = true; + } + + + + + private void OpenAnimations_Completed(object sender, EventArgs e) + { + var senderStoryboard = (sender as ClockGroup).Timeline as Storyboard; + var getName = senderStoryboard.Name; + ScanBoxDisable(); + switch (senderStoryboard.Name) + { + + case "BaseGrid": + this.ShowPage = PBPageType.Intro; + break; + case "SenserGrid": + this.ShowPage = PBPageType.Sensing; + this.ContentGrid.IsEnabled = true; + GMBtoggle2Sensing(); + ScanBoxEnable(); + break; + case "ItemGrid": + this.ShowPage = PBPageType.Items; + this.ContentGrid.IsEnabled = true; + GMBtoggle2Order(); + break; + case "ContentGrid": + this.ShowPage = ViewModel.DefaultPage; + switch (ViewModel.DefaultPage) + { + case PBPageType.Items: + GMBtoggle2Order(); + break; + case PBPageType.Sensing: + GMBtoggle2Sensing(); + break; + } + break; + case "FirstGrid": + this.ShowPage = ViewModel.DefaultPage; + break; + case "TradeGrid": + if (ShowPage.Equals(PBPageType.Intro)) + { + + this.ShowPage = ViewModel.DefaultPage; + switch (ViewModel.DefaultPage) + { + case PBPageType.Items: + GMBtoggle2Order(); + break; + case PBPageType.Sensing: + GMBtoggle2Sensing(); + break; + case PBPageType.FirstSelect: + FirstGrid.IsEnabled = true; + break; + } + } + else + { + switch (ViewModel.DefaultPage) + { + case PBPageType.Items: + ItemGrid.Visibility = Visibility.Visible; + ItemGrid.RenderTransform = new TranslateTransform(ItemGrid.Width * -1, 0); ; + OpenAndClose(this.SenserGrid, this.ItemGrid, OpenCloseAnimationType.GotoLeft); + break; + case PBPageType.Sensing: + SenserGrid.Visibility = Visibility.Visible; + SenserGrid.RenderTransform = new TranslateTransform(ItemGrid.Width, 0); ; + OpenAndClose(this.ItemGrid, this.SenserGrid, OpenCloseAnimationType.GotoRight); + + break; + } + } + break; + } + if (this.FindName(getName) is Grid findGrid) findGrid.IsEnabled = true; + senderStoryboard = null; + + } + private void CloseAnimation_Completed(object sender, EventArgs e) + { + AiScannerProcess.StopAiScanner(); + if (BarcodeFocusing != null) + { + BarcodeFocusing.Stop(); + BarcodeFocusing.Tick -= BarcodeFocusing_Tick; + BarcodeFocusing = null; + } + this.BarCode.PreviewKeyDown -= BarCode_PreviewKeyDown; + this.ViewModel.Dispose(); + this.Close(); + } + private void IcReaderCheckButton_MouseClicked(object sender, RoutedEventArgs e) + { + GoReaderCheck(); + } + private void RecipetRefundButton_MouseClicked(object sender, RoutedEventArgs e) + { + GoRecipetRefund(); + } + private void RecipetReprintButton_MouseClicked(object sender, RoutedEventArgs e) + { + GoRecipetReprint(); + } + private void ExitWindow_MouseClicked(object sender, RoutedEventArgs e) + { + CloseBase(); + } + private void CloseWindow_MouseClicked(object sender, RoutedEventArgs e) + { + ViewModel.GmbReaderCheckOpen = false; + this.AdminGrid.Visibility = Visibility.Collapsed; + this.ViewModel.ToIntorTimerStart(); + } + + #endregion Event Handlers + + } +} diff --git a/Kiosk/PB/SPC.Kiosk.PB/Properties/AssemblyInfo.cs b/Kiosk/PB/SPC.Kiosk.PB/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2191970 --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("SPC.Kiosk.PB")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Zin")] +[assembly: AssemblyProduct("SPC.Kiosk.PB")] +[assembly: AssemblyCopyright("Copyright © Zin. 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +//지역화 가능 응용 프로그램 빌드를 시작하려면 다음을 설정하세요. +//.csproj 파일에서 내에 CultureYouAreCodingWith를 +//설정하십시오. 예를 들어 소스 파일에서 영어(미국)를 +//사용하는 경우 를 en-US로 설정합니다. 그런 다음 아래 +//NeutralResourceLanguage 특성의 주석 처리를 제거합니다. 아래 줄의 "en-US"를 업데이트하여 +//프로젝트 파일의 UICulture 설정과 일치시킵니다. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //테마별 리소스 사전의 위치 + //(페이지 또는 응용 프로그램 리소스 사진에 + // 리소스가 없는 경우에 사용됨) + ResourceDictionaryLocation.SourceAssembly //제네릭 리소스 사전의 위치 + //(페이지 또는 응용 프로그램 리소스 사진에 + // 리소스가 없는 경우에 사용됨) +)] + + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호가 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Kiosk/PB/SPC.Kiosk.PB/SPC.Kiosk.PB.csproj b/Kiosk/PB/SPC.Kiosk.PB/SPC.Kiosk.PB.csproj new file mode 100644 index 0000000..b73a43a --- /dev/null +++ b/Kiosk/PB/SPC.Kiosk.PB/SPC.Kiosk.PB.csproj @@ -0,0 +1,155 @@ + + + + + Debug + AnyCPU + {38393190-821D-496D-A996-11833C20E476} + Library + SPC.Kiosk.PB + SPC.Kiosk.PB + v4.0 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + Svn + Svn + Svn + SubversionScc + + + x86 + true + full + false + ..\..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + + + x86 + none + true + ..\..\..\..\BIN\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + 4.0 + + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + DetailBasketItem.xaml + + + DetailBasketItems.xaml + + + DiscountAndValue.xaml + + + DiscountAndValues.xaml + + + MiniBasketItems.xaml + + + MiniBasketItem.xaml + + + PBPaymentsWindow.xaml + + + PBWindow.xaml + Code + + + + + Code + + + + + {bcc10fa2-c358-480c-8ff0-615750f3c306} + SPC.Kiosk.Base + + + {ba2d06e0-74c0-4785-b39f-d1eaac13b73d} + SPC.Kiosk.Common + + + {be7fc15c-325b-4ad4-8ea0-a8244193e431} + SPC.Kiosk.Popup.Model + + + {9ef1fec9-5f0a-4a4e-8723-e93f30798fd2} + SPC.Kiosk.Popup.ViewModel + + + {7c64409c-24e1-4d9e-a686-b13061f1c61b} + SPC.Kiosk.Popup + + + {90ebd618-0409-458d-9829-a012223e8671} + SPC.Kiosk.PB.Model + + + {bca39ae9-b2eb-495e-be62-ab95b0325cff} + SPC.Kiosk.PB.ViewModel + + + + \ No newline at end of file diff --git a/Kiosk/Payments/SPC.Kiosk.Payments/Properties/AssemblyInfo.cs b/Kiosk/Payments/SPC.Kiosk.Payments/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..45219c3 --- /dev/null +++ b/Kiosk/Payments/SPC.Kiosk.Payments/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("SPC.Kiosk.Payments")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("SPC.Kiosk.Payments")] +[assembly: AssemblyCopyright("Copyright © Zin Inc. 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("36fe9011-b9bc-4348-b9c1-1c063dbfa926")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호가 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Kiosk/Payments/SPC.Kiosk.Payments/SPC.Kiosk.Payments.csproj b/Kiosk/Payments/SPC.Kiosk.Payments/SPC.Kiosk.Payments.csproj new file mode 100644 index 0000000..18d483a --- /dev/null +++ b/Kiosk/Payments/SPC.Kiosk.Payments/SPC.Kiosk.Payments.csproj @@ -0,0 +1,84 @@ + + + + + Debug + AnyCPU + {36FE9011-B9BC-4348-B9C1-1C063DBFA926} + Library + SPC.Kiosk.Payments + SPC.Kiosk.Payments + v4.0 + 512 + true + + + x86 + true + full + false + ..\..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + ..\..\BIN\Cosmos.BaseFrame.dll + + + ..\..\BIN\Cosmos.Common.dll + + + ..\..\BIN\Cosmos.CommonManager.dll + + + ..\..\BIN\Cosmos.ServiceProvider.dll + + + ..\..\BIN\Cosmos.UserFrame.dll + + + + + + + + + + + + + + + + + + + + + + + + {ba2d06e0-74c0-4785-b39f-d1eaac13b73d} + SPC.Kiosk.Common + + + {be7fc15c-325b-4ad4-8ea0-a8244193e431} + SPC.Kiosk.Popup.Model + + + + \ No newline at end of file diff --git a/Kiosk/Payments/SPC.Kiosk.Payments/posHappyPoint.cs b/Kiosk/Payments/SPC.Kiosk.Payments/posHappyPoint.cs new file mode 100644 index 0000000..bc3a796 --- /dev/null +++ b/Kiosk/Payments/SPC.Kiosk.Payments/posHappyPoint.cs @@ -0,0 +1,1454 @@ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; +using Cosmos.CommonManager; +using System.Threading; +using System.Collections; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +using System.Data; + +namespace SPC.Kiosk.Payments +{ + /// + /// POS HappyPoint Approval Process + /// + public class posHappyPoint : IDisposable + { + //UserLog.WriteLogFile(UserCom.LOG_ERROR, "SPC.Kiosk.Payments", "posHappyPoint.?", "Exception." + ex.Message); + #region [ Members ] + /// + /// HappyPointCertify ErrorCode + /// + public enum ErrorCode + { + HappyPointCertifyMobilePhoneNumberError, + HappyPointCertifyMobileCardNumberError, + HappyPointCertifyMemInfoEncryptedCardNoError, + HappyPointCertifyEncrtipError, + HappyPointCertifyNotInitailzedError, + HappyPointCertifyProcessingTimeOut, + HappyPointUsingPointsError, + HappyCouponCannotUse, + HappyPointUnknownError, + } + /// + /// ErrorMessage Event + /// + /// 반환 로그 + public delegate void ErrorMessageEventHandler(string ErrorString); + /// + /// 로그메세지 이벤트 반환용 + /// + public event ErrorMessageEventHandler ErrorMessageEvent; + /// + /// Error 반환 Event + /// + /// 반환 Error Code + public delegate void LogErrorHandler(ErrorCode errorCode); + /// + /// Error Code 이벤트 반환용 + /// + public event LogErrorHandler ErrorEvent; + /// + /// IcReadStart Event + /// + /// + public delegate void IcReadStart(object sender); + /// + /// IcReadStart Event 반환용 + /// + public event IcReadStart ReadStart; + /// + /// IcReadStart Event + /// + /// + public delegate void IcReadEnd(object sender); + /// + /// IcReadStart Event 반환용 + /// + public event IcReadEnd ReadEnd; + + private SManager sManager = null; // 이 객체를 통해 업무 Service 호출 + private StateServer StateObject = null; // StateObject : StateServer Object (객체) + private PosStatus m_cPosStatus = null; // 기본정보 참조 + private TranStatus m_cTrnStatus = null; // 거래정보 참조 + private DeviceStatus m_cDevStatus = null; // 디바이스 관리 + private PosOLEDevice.DelegateIcReader delegateReader; // IC리더 콜백 + private IICReaderUs m_cDeviceICReader = null; + private IDataCommonUs m_cDataCommon = null; // POS 공통함수 인터페이스 + + + private IPaymentUs m_cHappyPointUse = null; + + + /// + /// 대상 금액 + /// + private double m_nDestAmt = 0; + /// + /// 상품 선택 행(-1:전체) + /// + private string m_sSelRow = "-1"; + + + /// + /// 입력구분 + /// + private string m_sInPutType = ""; + /// + /// 입력데이터 + /// + private string m_sInPutData = ""; + /// + /// 마스킹데이터 + /// + private string m_sInMaskData = ""; + /// + /// 카드데이터(암호화) + /// + private string m_sInEncData = ""; + /// + /// 서비스코드 + /// + private string m_sServiceCode = ""; + /// + /// 승인카드번호 + /// + private string m_sAppCardNo = ""; + /// + /// 조회 성공 여부 + /// + private bool m_bSearchSuccess = false; + /// + /// POS 초기화 필요 유무 + /// + public bool NeedInitModule { get; set; } + /// + /// 승인 수단 + /// + public string CertifyKey { get; set; } = string.Empty; + private bool icCallBack = false; + /// + /// Ic Reader CallBack Switch + /// + public bool IcCallBack + { + get { return icCallBack; } + set + { + if (value) + { + m_cDeviceICReader.RegIcCallback(delegateReader); + } + icCallBack = value; + } + } + /// + /// 마스크된 회원성명 + /// + public string MemberName { get; protected set; } = string.Empty; + public string MemberNumber { get; protected set; } = string.Empty; + /// + /// SPC 임직원 유무 + /// + public bool IsCompanyMember { get; protected set; } + /// + /// 적립 가능 유무 + /// + public bool CanReservePoint { get; protected set; } + /// + /// 회원 등급 + /// + public string MemberLevel { get; protected set; } = string.Empty; + /// + /// 회원 비밀번호 + /// + public string MemberPassword { get; protected set; } = string.Empty; + /// + /// HappyApp 가입 고객 + /// + public bool IsAppMamber { get; protected set; } = false; + /// + /// 단골 매장 유무 + /// + public bool IsFavoriteStore { get; protected set; } = false; + /// + /// 회원 적립 Point + /// + public double MemberPoint { get; protected set; } = 0d; + /// + /// 회원 가용 Point + /// + public double UseablePoint { get; protected set; } = 0d; + /// + /// 승인 요청 포인트 + /// + public double UseingPoint { get; set; } = 0d; + /// + /// 승인 포인트 + /// + public double ApprovalPoint { get; protected set; } = 0d; + /// + /// Point 사용시 비번 필요 유무 + /// + public bool NeedPassword { get; protected set; } + + public long PaySEQ { get; protected set; } + /// + /// 인증 처리 성공 유무 + /// + public bool ProcessOK + { + get { return m_bSearchSuccess; } + } + /// + /// Processing TimeOut + /// + public bool IsTimeout + { + set + { + if (value) + { + ErrorEvent(ErrorCode.HappyPointCertifyProcessingTimeOut); + } + } + } + public List MyHappyCoupons { get; protected set; } = new List(); + public M_HappyCoupon UsedCoupon { get; protected set; } + #endregion + + #region [ Ctor && Dispose ] + /// + /// Ctor + /// + public posHappyPoint() + { + try + { + sManager = new SManager(); + StateObject = (StateServer)StateServer.GetInstance(); + NeedInitModule = StateObject.POS == null + || StateObject.TRAN == null + || StateObject.DEVICE == null; + if (!NeedInitModule) + { + m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 + m_cTrnStatus = (TranStatus)StateObject.TRAN; // POS 거래정보 + m_cDevStatus = (DeviceStatus)StateObject.DEVICE; + m_cDeviceICReader = (IICReaderUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_ICREADER); + m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON); + + m_cHappyPointUse = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.POINTHAPPYPOINTUSE); + + delegateReader = new PosOLEDevice.DelegateIcReader(OnIcReaderCallBack); // IC리더 콜백 + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "Ctor", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// + /// + public void Dispose() + { + try + { + InDataToZeroFill(); + + sManager = null; + StateObject = null; + m_cPosStatus = null; // POS 기본정보 + m_cTrnStatus = null; // POS 거래정보 + m_cDevStatus = null; + m_cDataCommon = null; + m_cDeviceICReader = null; + delegateReader = null; // IC리더 콜백 + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "Dispose", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + #endregion + + #region [ Methods ] + /// + /// HappyPoint 회원 조회 (16 자리이면 Mobile BarCode, 그외는 전화 번호) + /// + /// + public void StartCertifyProcessing(string _inputString) + { + try + { + CommonLog.InfoLogWrite(this, "StartCertifyProcessing()", "Start"); + SendReadStart(); + if (NeedInitModule) + { + Thread.Sleep(1000); //진행창 보이기 위한 딜레이 + ErrorEvent(ErrorCode.HappyPointCertifyNotInitailzedError); + } + else + { + var startPorcess = false; + if (_inputString.Replace("=", "").Replace("@", "").Length.Equals(16)) + { + // Mobile BarCode + if (CmUtil.CheckHappyMobileCard(_inputString)) + { + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_MOBILE_SWIP; + m_sInMaskData = m_sAppCardNo = _inputString.Replace("=", "").Replace("@", ""); + m_sInPutData = _inputString + "@"; + startPorcess = true; + } + else + { + SendErrLogEvent(ErrorCode.HappyPointCertifyMobileCardNumberError); + } + } + else + { + // 전화 번호 + if (IsCellularPhoneNumber(_inputString)) + { + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN; + m_sInMaskData = m_sAppCardNo = m_sInPutData = _inputString; + startPorcess = true; + + } + else + { + SendErrLogEvent(ErrorCode.HappyPointCertifyMobilePhoneNumberError); + } + } + //조회 전문 처리 + if (startPorcess) + { + if (EncryptedCardNo(m_sInPutData, ref m_sInMaskData, ref m_sInEncData)) + { + SearchTxtInPut(); + } + else + { + SendErrLogEvent(ErrorCode.HappyPointCertifyEncrtipError); + } + } + + } + SendReadEnd(); + CommonLog.InfoLogWrite(this, "StartCertifyProcessing()", string.Format("End : Result={0}", ProcessOK ? "OK" : "Fail")); + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "StartCertifyProcessing()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// 쿠폰 사용 처리 + /// + /// + /// + public void StartCouponProcessing(string _inputString, double _totalPrice) + { + try + { + CommonLog.InfoLogWrite(this, "StartCouponProcessing()", "Start"); + SendReadStart(); + if (NeedInitModule) + { + Thread.Sleep(1000); //진행창 보이기 위한 딜레이 + ErrorEvent(ErrorCode.HappyPointCertifyNotInitailzedError); + } + else + { + var startPorcess = false; + if (_inputString.Length < 11) + { + SendErrLogEvent(ErrorCode.HappyCouponCannotUse); + } + else + { + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN; + m_sInMaskData = m_sAppCardNo = m_sInPutData = _inputString; + m_nDestAmt = _totalPrice; + startPorcess = true; + + } + if (startPorcess) + { + if (EncryptedCardNo(m_sInPutData, ref m_sInMaskData, ref m_sInEncData)) + { + CouponCompleteTxtInPut(); + } + else + { + SendErrLogEvent(ErrorCode.HappyPointCertifyEncrtipError); + } + } + + } + SendReadEnd(); + CommonLog.InfoLogWrite(this, "StartCouponProcessing()", string.Format("End : Result={0}", ProcessOK ? "OK" : "Fail")); + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "StartCouponProcessing()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// 해피포인트 사용을 위한 조회 + /// + private bool SearchTxtInPutForUsing() + { + string sRet = UserCom.RST_ERR; + try + { + m_bSearchSuccess = false; + var m_sPosMenuKey = PosKey.MENU_KEY.HAPPY_POINT_USE; + + // 조회 + string[] saRecvdData = null; + sRet = m_cHappyPointUse.SearchPayment(new string[] { m_sPosMenuKey, m_sInPutType, m_sInMaskData, m_sInEncData, "1", m_sAppCardNo }, ref saRecvdData); + if (sRet != UserCom.RST_OK) + { + InDataToZeroFill(); + return false; + } + + Column.TR_PAYMENT.DATA cPayItem = (Column.TR_PAYMENT.DATA)m_cHappyPointUse.GetPayment(new string[] { }); + + var m_bPassWord = true; + if (cPayItem.HP_ADD_INFO_SCH.Trim() != "") + { + int nNowPos = 0; + string[] aIrtRsp = new string[Column.POINT_ADD_INFO_SEARCH.LEN.Length]; + ItemColumn.ParseMessage(Column.POINT_ADD_INFO_SEARCH.LEN, Column.POINT_ADD_INFO_SEARCH.TYPE, Encoding.Default.GetBytes(cPayItem.HP_ADD_INFO_SCH), ref nNowPos, ref aIrtRsp); + + if (aIrtRsp[Column.POINT_ADD_INFO_SEARCH.SEQ.pointHPUSEYN] != "Y") + { + //WinManager.ConfirmMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0139)); + return false; + } + m_bPassWord = (aIrtRsp[Column.POINT_ADD_INFO_SEARCH.SEQ.pointHPUSEPWYN] == "Y") ? true : false; + + if (m_sInPutData.StartsWith(PosConst.HP_CARD_PRIFIX) == false) + { + // 고객정보 + string sMemInfo = aIrtRsp[Column.POINT_ADD_INFO_SEARCH.SEQ.pointMEMINFO].Trim(); + if (sMemInfo.Length >= 17 && CmUtil.LongParse(sMemInfo.Substring(0, 1)) > 0) + { + string sInPutData = sMemInfo.Substring(1, 16).Trim(); // 카드번호 + string sInMaskData = ""; + if (EncryptedCardNo(sInPutData, ref sInMaskData, ref m_sInEncData) == false) return false; + cPayItem.CanFiller1 = m_sInEncData; + + cPayItem.OCCUR_ENTRY_14 = m_sAppCardNo = sInPutData; // 승인카드번호 + } + } + + //#20171017 전자영수증 발행 start, phj + cPayItem.OCCUR_ENTRY_23 = CmUtil.MidH(cPayItem.HP_ADD_INFO_SCH, 144, 1).Trim(); + //#20171017 전자영수증 발행 end, phj + } + + if (cPayItem.OCCUR_ENTRY_12 == "Y") + { + m_cTrnStatus.Sale.HappyBuzzMemNo = m_sInPutData; + } + + cPayItem.CanFiller3 = m_sInPutData; + + // MoonSeokWoo 2017.09.26 마이원 카드 제약조건 제거. + //if (cPayItem.HP_RESERVED.StartsWith("M") == true) // 마이원카드 사용 불가 + //{ + // WinManager.ConfirmMessage(MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0139)); + // return false; + //} + + + // 할인 대상상품 합계 + double nDestPluAmt = 0; + ArrayList alTrPluItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM); + foreach (Column.TR_PLU.DATA cPluItem in alTrPluItem) + { + if (cPluItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cPluItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue; // 지정취소 + if (cPluItem.alTrSaleCpi == null) continue; + + foreach (Column.TR_SALE_CPI_RSLT.DATA cTrSaleCpi in cPluItem.alTrSaleCpi) + { + if (cTrSaleCpi.TRGT_CUST_TYPE == ItemConst.CPI_TRGT_CUST_TYPE.HPC_PAY && cTrSaleCpi.DC_SUM_AMT > 0) + { + nDestPluAmt = CmUtil.DoubleAdd(nDestPluAmt, cPluItem.BILL_AMT); + break; + } + } + } + + //// 결제포인트 + //txtUsePoint.Value = (m_nRemainPayAmt > cPayItem.AMT_ENTRY_04) ? cPayItem.AMT_ENTRY_04.ToString() : m_nRemainPayAmt.ToString(); + + + //#20180821 해피포인트 고객이름 마스킹 start + if (cPayItem.HP_CUST_NAME != "") { cPayItem.HP_CUST_NAME = m_cDataCommon.NameMasking(cPayItem.HP_CUST_NAME); } + //#20180821 해피포인트 고객이름 마스킹 end + + //lblTitle.Text = MessageManager.GetLabelMessage(POS_MESSAGE.LABEL.MSG_0109) + " [ " + cPayItem.HP_CUST_NAME + " ]"; + m_bSearchSuccess = true; + return true; + } + catch (Exception ex) + { + WinManager.ExceptionMessage(System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, + System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", ex.Message); + } + return false; + } + + + /// + /// 해피 포인트 사용 처리 + /// + /// + /// + /// + public void StartPaymentProcessing(string _inputString, double _usingPoints,string _memberPassword) + { + try + { + CommonLog.InfoLogWrite(this, "StartPaymentProcessing()", "Start"); + SendReadStart(); + if (NeedInitModule) + { + Thread.Sleep(3000); //진행창 보이기 위한 딜레이 + ErrorEvent(ErrorCode.HappyPointCertifyNotInitailzedError); + } + else + { + var startPorcess = false; + if (_inputString.Replace("=", "").Replace("@", "").Length.Equals(16) + && _usingPoints > 0) + { + UseingPoint = _usingPoints; + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_MOBILE_SWIP; + m_sInMaskData = _inputString; + m_sInPutData = _inputString + "@"; + startPorcess = true; + } + else + { + SendErrLogEvent(ErrorCode.HappyPointUsingPointsError); + } + //승인 전문 처리 + if (startPorcess) + { + if (EncryptedCardNo(m_sInPutData, ref m_sInMaskData, ref m_sInEncData)) + { + if (SearchTxtInPutForUsing()) CompleteTxtInPut(); + else SendErrLogEvent(ErrorCode.HappyPointCertifyEncrtipError); + } + else + { + SendErrLogEvent(ErrorCode.HappyPointCertifyEncrtipError); + } + } + + } + SendReadEnd(); + CommonLog.InfoLogWrite(this, "StartPaymentProcessing()", string.Format("End : Result={0}", ProcessOK ? "OK" : "Fail")); + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "StartPaymentProcessing()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// 단골 매장 처리 + /// + /// + /// + public void StartFavoriteStoreProcess(string _inputString, bool _regType) + { + CommonLog.InfoLogWrite(this, "StartFavoriteStoreProcess()", "Start"); + SendReadStart(); + if (NeedInitModule) + { + Thread.Sleep(3000); //진행창 보이기 위한 딜레이 + ErrorEvent(ErrorCode.HappyPointCertifyNotInitailzedError); + } + else + { + var m_cHappyPoint = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.POINTHPREGULARCUST); + m_bSearchSuccess = false; + try + { + var sReqDivCd = _regType ? "10" : "11"; + if (_inputString.Length > 15) + { + m_sInPutData = string.Format("{0}@", _inputString.Substring(0, 16)); + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_MOBILE_SWIP; + } + else + { + m_sInPutData = _inputString; + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN; + } + if (EncryptedCardNo(m_sInPutData, ref m_sInMaskData, ref m_sInEncData)) + { + var sRet = m_cHappyPoint.SetPayment(new string[] { m_sInPutType, m_sInMaskData, m_sInEncData, sReqDivCd }); + if (sRet != UserCom.RST_OK) + { + InDataToZeroFill(); + if (sRet == null || sRet.Equals(UserCom.RST_ERR)) + { + SendErrLogEvent(ErrorCode.HappyPointUnknownError); + } + else + { + SendErrorMessageEvent(sRet); + } + } + else + { + m_bSearchSuccess = true; + } + } + else + { + SendErrLogEvent(ErrorCode.HappyPointCertifyEncrtipError); + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "StartFavoriteStoreProcess()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + SendReadEnd(); + CommonLog.InfoLogWrite(this, "StartFavoriteStoreProcess()", string.Format("End : Result={0}", ProcessOK ? "OK" : "Fail")); + } + + + /// + /// 휴대폰 번호 형식 확인 + /// + /// + /// + private bool IsCellularPhoneNumber(string sInputData) + { + bool bRet = false; + try + { + if (sInputData.Length == 10 || sInputData.Length == 11) + { + if (sInputData.StartsWith("010") == true || sInputData.StartsWith("011") == true || sInputData.StartsWith("017") == true || + sInputData.StartsWith("016") == true || sInputData.StartsWith("018") == true || sInputData.StartsWith("019") == true) + { + bRet = true; + } + } + } + catch + { + bRet = false; + } + return bRet; + } + /// + /// Happoint 조회 전문 처리 + /// + private void SearchTxtInPut() + { + CommonLog.DebugLogWrite(this, "SearchTxtInPut()", "Start"); + var m_cHappyPoint = (IPaymentExpUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.POINTHAPPYPOINT); + string sRet = UserCom.RST_ERR; + try + { + + m_bSearchSuccess = false; + string[] saRecvdData = null; + sRet = m_cHappyPoint.SearchPayment(new string[] { m_sInPutType, m_sInMaskData, m_sInEncData, "0", "", m_sAppCardNo }, ref saRecvdData); + if (sRet != UserCom.RST_OK) + { + CertifyKey = string.Empty; + InDataToZeroFill(); + if (sRet == null || sRet.Equals(UserCom.RST_ERR)) + { + SendErrLogEvent(ErrorCode.HappyPointUnknownError); + } + else + { + SendErrorMessageEvent(sRet); + } + } + else + { + CertifyKey = m_sAppCardNo; + var cPointItem = (Column.TR_ETC.DATA)m_cHappyPoint.GetPayment(new string[] { }); + + NeedPassword = true; + if (cPointItem.HP_ADD_INFO_SCH.Trim() != "") + { + int nNowPos = 0; + string[] aIrtRsp = new string[Column.POINT_ADD_INFO_SEARCH.LEN.Length]; + ItemColumn.ParseMessage(Column.POINT_ADD_INFO_SEARCH.LEN, Column.POINT_ADD_INFO_SEARCH.TYPE, Encoding.Default.GetBytes(cPointItem.HP_ADD_INFO_SCH), ref nNowPos, ref aIrtRsp); + MemberNumber = cPointItem.OCCUR_ENTRY_10; + MemberLevel = cPointItem.OCCUR_ENTRY_15; + MemberPoint = cPointItem.AMT_ENTRY_03; + UseablePoint = cPointItem.AMT_ENTRY_04; + IsAppMamber = cPointItem.OCCUR_ENTRY_12.ToUpper().Equals("Y"); + IsCompanyMember = cPointItem.ETC_DTL_CD_04.StartsWith("3A"); + CanReservePoint = aIrtRsp[Column.POINT_ADD_INFO_SEARCH.SEQ.pointHPADDYN].Equals("Y"); + NeedPassword = (aIrtRsp[Column.POINT_ADD_INFO_SEARCH.SEQ.pointHPUSEPWYN] == "Y") ? true : false; + + // 고객정보 + string sMemInfo = aIrtRsp[Column.POINT_ADD_INFO_SEARCH.SEQ.pointMEMINFO].Trim(); + if (sMemInfo.Length >= 17 && CmUtil.LongParse(sMemInfo.Substring(0, 1)) > 0) + { + string sInPutData = sMemInfo.Substring(1, 16).Trim(); // 카드번호 + string sInMaskData = ""; + IsFavoriteStore = sMemInfo.Substring(53, 1).Equals("Y"); + if (EncryptedCardNo(sInPutData, ref sInMaskData, ref m_sInEncData) == false) + { + SendErrLogEvent(ErrorCode.HappyPointCertifyMemInfoEncryptedCardNoError); + return; + } + cPointItem.CanFiller1 = m_sInEncData; + } + + //#20171017 전자영수증 발행 start, phj + cPointItem.OCCUR_ENTRY_23 = CmUtil.MidH(cPointItem.HP_ADD_INFO_SCH, 144, 1).Trim(); + //#20171017 전자영수증 발행 end, phj + } + + if (cPointItem.OCCUR_ENTRY_12 == "Y") + { + m_cTrnStatus.Sale.HappyBuzzMemNo = m_sInPutData; + } + + cPointItem.CanFiller3 = m_sInPutData; + MemberName = cPointItem.HP_CUST_NAME; + + #region InCard Coupon Query + var m_cHappyCoupon = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.POINTHAPPYCOUPON); + try + { + sRet = m_cHappyCoupon.SearchPayment(new string[] { m_sInPutType, m_sInPutData, m_sInEncData, "1" }, ref saRecvdData); + if (sRet.Equals(UserCom.RST_OK)) + { + var cPayItem2 = (Column.TR_PAYMENT.DATA)m_cHappyCoupon.GetPayment(new string[] { }); + var aHP_CPN_INFO = cPayItem2.HP_CPN_INFO; + if (aHP_CPN_INFO is ArrayList && aHP_CPN_INFO.Count > 0) + { + var newCouponData = new List(); + foreach (var aCouponData in aHP_CPN_INFO) + { + if (aCouponData is string[] aCouponInfos + && aCouponInfos.Length > 3) + { + var couponName = CmUtil.MidH(aCouponInfos[1], 0, 40); + var aNewCouponData = new M_HappyCoupon + { + Number = string.IsNullOrEmpty(aCouponInfos[0]) + ? string.Empty + : aCouponInfos[0].Trim(), + Name = string.IsNullOrEmpty(couponName) + ? string.Empty + : couponName.Trim(), + StartDate = CommonFunction.GetDate(aCouponInfos[2]), + EndDate = CommonFunction.GetDate(aCouponInfos[2]), + }; + newCouponData.Add(aNewCouponData); + } + } + MyHappyCoupons = newCouponData; + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "SearchTxtInPut()", "Coupon Search Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + m_cHappyCoupon = null; + } + #endregion + m_bSearchSuccess = true; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "SearchTxtInPut()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + m_cHappyPoint = null; + } + CommonLog.DebugLogWrite(this, "SearchTxtInPut()", "End"); + } + + /// + /// 포인트 사용 승인 처리 + /// + /// + private void CompleteTxtInPut() + { + CommonLog.DebugLogWrite(this, "CompleteTxtInPut()", "Start"); + //var m_cHappyPointUse = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.POINTHAPPYPOINTUSE); + string sRet = UserCom.RST_ERR; + try + { + m_bSearchSuccess = false; + var m_sPosMenuKey = PosKey.MENU_KEY.HAPPY_POINT_USE; + // 포인트 사용 승인 처리 + sRet = m_cHappyPointUse.SetPayment(new string[] { m_sPosMenuKey, m_sInPutType, m_sInMaskData, m_sInEncData, UseingPoint.ToString(), MemberPassword, m_sAppCardNo, "", "" }); + if (sRet != UserCom.RST_OK) + { + CertifyKey = string.Empty; + MemberPassword = string.Empty; + InDataToZeroFill(); + if (sRet == null || sRet.Equals(UserCom.RST_ERR)) + { + SendErrLogEvent(ErrorCode.HappyPointUnknownError); + } + else + { + SendErrorMessageEvent(sRet); + } + } + else + { + var cPointItem = (Column.TR_PAYMENT.DATA)m_cHappyPointUse.GetPayment(new string[] { }); + PaySEQ = cPointItem.SEQ; + ApprovalPoint = UseingPoint; + m_bSearchSuccess = true; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "CompleteTxtInPut()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + m_cHappyPointUse = null; + } + CommonLog.DebugLogWrite(this, "CompleteTxtInPut()", "End"); + } + /// + /// 쿠폰 사용 승인 전문 + /// + private void CouponCompleteTxtInPut() + { + CommonLog.DebugLogWrite(this, "CouponCompleteTxtInPut()", "Start"); + var m_cHappyCoupon = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.POINTHAPPYCOUPON); + string sRet = UserCom.RST_ERR; + try + { + m_bSearchSuccess = false; + // 해피쿠폰 조회 + string[] saRecvdData = null; + sRet = m_cHappyCoupon.SearchPayment(new string[] { m_sInPutType, m_sInPutData, m_sInEncData, "0" }, ref saRecvdData); + if (sRet != UserCom.RST_OK) + { + CertifyKey = string.Empty; + InDataToZeroFill(); + if (sRet == null || sRet.Equals(UserCom.RST_ERR)) + { + SendErrLogEvent(ErrorCode.HappyPointUnknownError); + } + else + { + SendErrorMessageEvent(sRet); + } + } + else + { + var cPayItem = (Column.TR_PAYMENT.DATA)m_cHappyCoupon.GetPayment(new string[] { }); + var aprovalProcessStart = false; + //내려온 제품군 또는 상품코드가 존재 할 때 + if (cPayItem.CpnItemDcCode != "") + { + // 제품군 코드가 내려왔으면 제품군에 속하고, 등록 된 상품을 화면에 보여주고, 사용자가 선택한 제품 할인적용. + // 상품코드가 내려왔으면 바로 해당 상품으로 할인적용. + if (ChoiceCpnItem(cPayItem.CpnItemDcCode) == false) + { + SendErrLogEvent(ErrorCode.HappyCouponCannotUse); + } + else + { + aprovalProcessStart = true; + } + } + //내려온 제품군 또는 상품코드가 존재하지 않을 때 + else + { + + // 전체금액 대상 + m_sSelRow = "-1"; + aprovalProcessStart = true; + } + if (aprovalProcessStart) + { + // 해피포인트 쿠폰 등록 처리 + sRet = m_cHappyCoupon.SetPayment(new string[] { m_sInPutType, m_sInPutData, m_sInEncData, m_nDestAmt.ToString(), m_sSelRow }); + if (sRet != UserCom.RST_OK) + { + if (sRet == null || sRet.Equals(UserCom.RST_ERR)) + { + SendErrLogEvent(ErrorCode.HappyPointUnknownError); + } + else + { + SendErrorMessageEvent(sRet); + } + } + else + { + var cPayItem2 = (Column.TR_PAYMENT.DATA)m_cHappyCoupon.GetPayment(new string[] { }); + UsedCoupon = new M_HappyCoupon + { + Number = cPayItem.OCCUR_ENTRY_01, + Name = cPayItem.CanFiller2, + IsUsed = true, + PaySEQ = cPayItem2.SEQ, + UseAmount = cPayItem2.PAY_AMT, + }; + m_bSearchSuccess = true; + } + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "CouponCompleteTxtInPut()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + m_cHappyCoupon = null; + } + CommonLog.DebugLogWrite(this, "CouponCompleteTxtInPut()", "End"); + } + + + #region ChoicePluItem (대상 상품 선택) + /// + /// 대상 상품 선택 + /// + /// + private bool ChoiceCpnItem(string CpnItemDcCode) + { + + #region 변경 + string CpnItemDcType = string.Empty; + string sItemNm = string.Empty; + string sItemCode = string.Empty; + bool bItemCheck = false; // false: 등록된상품과 일치된상품없음. true: 등록된상품과 일치된상품있음. + double dPayAmt = -1; + + //#20180502 온라인쿠폰 제품군, 상품코드 할인 적용 기능 적용 start + string sGubun = string.Empty; + //#20180502 온라인쿠폰 제품군, 상품코드 할인 적용 기능 적용 end + + try + { + // 제품군의 속한 상품 리스트를 가져온다. + // 조회응답전문에 코드는 내려왔는데 제품군 마스터에 존재하지 않으면 상품코드로 간주한다. + DataTable dtCpnItemDcList = null; + dtCpnItemDcList = m_cDataCommon.CpnItemDCTargetList(CpnItemDcCode); + if (dtCpnItemDcList == null || dtCpnItemDcList.Rows.Count == 0) + { + // 상품코드 + CpnItemDcType = "2"; + } + else + { + // 제품군 + CpnItemDcType = "1"; + + + //#20180502 온라인쿠폰 제품군, 상품코드 할인 적용 기능 적용 start + DataRow dr = dtCpnItemDcList.Rows[0]; + // 00: 일반제품군, 01: 대분류 코드 ,02: 중분류 코드 ,03: 소분류 코드 + sGubun = CmUtil.GetDataRowStr(dr, PosMst.MST_CPN_ITEM_GRP_MNG.DATA.GUBUN); + //#20180502 온라인쿠폰 제품군, 상품코드 할인 적용 기능 적용 end + } + + + ArrayList alPluItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM); + Column.TR_PLU.DATA cPluItem = null; + if (CpnItemDcType == "1") + { + foreach (DataRow dr in dtCpnItemDcList.Rows) + { + for (int i = 0; i < alPluItem.Count; i++) + { + cPluItem = (Column.TR_PLU.DATA)alPluItem[i]; + if (cPluItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cPluItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue; // 지정취소 + if (cPluItem.DC_PRMT_YN == "1") continue; + + //#20180502 온라인쿠폰 제품군, 상품코드 할인 적용 기능 적용 start + //기존 + //if (CmUtil.GetDataRowStr(dr, PosMst.MST_CPN_ITEM_GRP_MNG_DTL.DATA.ITEM_CD) == cPluItem.ITEM_PLU_CD) + //{ + // if (dPayAmt > -1 && dPayAmt <= cPluItem.SALE_PRC) continue; + // dPayAmt = cPluItem.SALE_PRC;// 판매단가 + // + // m_sSelRow = i.ToString(); + // + // bItemCheck = true; + // sItemNm = cPluItem.ITEM_PLU_CD; + // sItemCode = cPluItem.ITEM_NAME; + // break; + //} + + //변경 + if (sGubun == "00") + { + if (CmUtil.GetDataRowStr(dr, PosMst.MST_CPN_ITEM_GRP_MNG_DTL.DATA.ITEM_CD) != cPluItem.ITEM_PLU_CD) continue; + } + else if (sGubun == "01") + { + if (CmUtil.GetDataRowStr(dr, PosMst.MST_CPN_ITEM_GRP_MNG_DTL.DATA.ITEM_CD) != cPluItem.L_CLSS) continue; + } + else if (sGubun == "02") + { + if (CmUtil.GetDataRowStr(dr, PosMst.MST_CPN_ITEM_GRP_MNG_DTL.DATA.ITEM_CD) != cPluItem.M_CLSS) continue; + } + else if (sGubun == "03") + { + if (CmUtil.GetDataRowStr(dr, PosMst.MST_CPN_ITEM_GRP_MNG_DTL.DATA.ITEM_CD) != cPluItem.S_CLSS) continue; + } + + + //#20181030 판매단가 제일 높은 것으로 원복 start + //기존 + /* + //#20180711 단가 제일 높은것으로 변경 start + //기존 + //if (dPayAmt > -1 && dPayAmt <= cPluItem.SALE_PRC) continue; + //변경 + //#15859 유형군 쿠폰 적용 시 오류 확인요청 start + //적용 대상 상품 체크시 실판매금액(BILL_AMT)로 체크 하도록 변경 + //단가가 동일한 상품이 있는 경우 수량에 따라 적용이 안되는 경우가 생김 + //기존 + //if (dPayAmt > -1 && dPayAmt >= cPluItem.SALE_PRC) continue; + //변경 + if (dPayAmt > -1 && dPayAmt >= cPluItem.BILL_AMT) continue; + //#15859 유형군 쿠폰 적용 시 오류 확인요청 end + //#20180711 단가 제일 높은것으로 변경 end + */ + + //변경 + if (dPayAmt > -1 && dPayAmt >= cPluItem.SALE_PRC) continue; + //#20181030 판매단가 제일 높은 것으로 원복 end + + //#20181030 판매단가 제일 높은 것으로 원복 start + //기존 + /* + //#15859 유형군 쿠폰 적용 시 오류 확인요청 start + //적용 대상 상품 체크시 실판매금액(BILL_AMT)로 체크 하도록 변경 + //단가가 동일한 상품이 있는 경우 수량에 따라 적용이 안되는 경우가 생김 + //기존 + //dPayAmt = cPluItem.SALE_PRC;// 판매단가 + //변경 + dPayAmt = cPluItem.BILL_AMT;// 판매단가 + //#15859 유형군 쿠폰 적용 시 오류 확인요청 end + */ + //변경 + dPayAmt = cPluItem.SALE_PRC;// 판매단가 + //#20181030 판매단가 제일 높은 것으로 원복 end + + m_sSelRow = i.ToString(); + + bItemCheck = true; + sItemNm = cPluItem.ITEM_PLU_CD; + sItemCode = cPluItem.ITEM_NAME; + //#20180502 온라인쿠폰 제품군, 상품코드 할인 적용 기능 적용 start,20180511 + //판매단가 가장 작은 제품에 적용되지 않고 첫번째 제품에 적용됨 + //break; + //#20180502 온라인쿠폰 제품군, 상품코드 할인 적용 기능 적용 end,20180511 + + //#20180502 온라인쿠폰 제품군, 상품코드 할인 적용 기능 적용 end + } + } + } + else + { + for (int i = 0; i < alPluItem.Count; i++) + { + cPluItem = (Column.TR_PLU.DATA)alPluItem[i]; + if (cPluItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cPluItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue; // 지정취소 + if (cPluItem.DC_PRMT_YN == "1") continue; + if (cPluItem.ITEM_PLU_CD == CpnItemDcCode) + { + m_sSelRow = i.ToString(); + + bItemCheck = true; + sItemNm = cPluItem.ITEM_PLU_CD; + sItemCode = cPluItem.ITEM_NAME; + break; + } + } + } + + + // 등록된 상품과 응답전문의 상품코드가 일치. + if (bItemCheck == true) + { + cPluItem = (Column.TR_PLU.DATA)alPluItem[CmUtil.IntParse(m_sSelRow)]; + m_nDestAmt = cPluItem.BILL_AMT; + return true; + } + // 등록된 상품과 응답전문의 상품코드가 불일치. + else + { + return false; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ChoiceCpnItem()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + + return false; + } + #endregion + //20171229 요건변경(할인대상 상품 중 제일 단가가 작은제품적용, 동일 판매가 일 경우 판매코드 제일 작은 상품) end, phj + } + #endregion + + /// + /// 카드 번호 암호화 + /// + /// + /// + /// + /// + private bool EncryptedCardNo(string sInData, ref string sInMaskData, ref string sInEncData) + { + string sEncData = sInData; + bool bRet = false; + try + { + + //#20170913 현금영수증, 포인트카드 마스킹 미적용 start + // "0"인 경우 마스킹 미처리 + //기존 + //sEncData = m_cDeviceICReader.GetEncryptedCardNo(sInData).Trim(); + //변경 + sEncData = m_cDeviceICReader.GetEncryptedCardNo(sInData, "0").Trim(); + //#20170913 현금영수증, 포인트카드 마스킹 미적용 end + + if (CmUtil.MidH(sEncData, 0, 2) == "00") + { + sInEncData = CmUtil.MidH(sEncData, 2, 512).Trim(); // 암호화 데이터 + sInMaskData = CmUtil.MidH(sEncData, 514, sEncData.Length - 514).Trim(); // 마스킹 데이터 + + //#20170913 현금영수증, 포인트카드 마스킹 미적용 start + sInMaskData = CmUtil.MidH(sInMaskData, 0, 6) + "********"; + //#20170913 현금영수증, 포인트카드 마스킹 미적용 end + + bRet = true; + } + else + { + //암호화 처리 실패! + CommonLog.ErrorLogWrite(this, "EncryptedCardNo()", "Fail !!"); + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "EncryptedCardNo()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + return bRet; + } + + #region DeviceEvent 관련 + + + /// + /// IC 카드 정보 입력 처리 + /// + /// + private bool GetIcCardData() + { + string sRsvStr = ""; + try + { + //IcCallBack = false; // IC리더 콜백 해지 + + ClearCardInfo(); // 카드 입력 정보 클리어 + + if (m_cDeviceICReader.GetCardInfo_ICReader(PosConst.IC_READER_TRAN_TYPE.POINT, 0, ref sRsvStr) == true) + { + if (CmUtil.MidH(sRsvStr, 0, 2) == "00") + { + m_sInEncData = CmUtil.MidH(sRsvStr, 6, 512).Trim(); + m_sInMaskData = CmUtil.MidH(sRsvStr, 1030, 37).Trim(); + m_sServiceCode = CmUtil.MidH(sRsvStr, 1067, 5).Trim(); + + m_sInPutData = m_sInMaskData; + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP; + + + + return true; + } + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetIcCardData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + // 여전법 대응//////////////////////////////////////////////////////////////////// + CmUtil.ZeroFillClear(ref sRsvStr); + ////////////////////////////////////////////////////////////////////////////////// + } + return false; + } + + /// + /// RF 카드 정보 입력 처리 + /// + /// + private bool GetRfCardData() + { + string sRsvStr = ""; + try + { + //IcCallBack = false; // IC리더 콜백 해지 + ClearCardInfo(); // 카드 입력 정보 클리어 + + //카드 정보 입력 + if (m_cDeviceICReader.GetRfCreditCardInfo("1", m_cTrnStatus.Head.NetSaleAmt.ToString(), "", "", "", ref sRsvStr) == false) + { + if (sRsvStr != "") SendErrorMessageEvent(sRsvStr); + return false; + } + + m_sInEncData = CmUtil.MidH(sRsvStr, 2, 512).Trim(); + m_sInMaskData = CmUtil.MidH(sRsvStr, 514, 40).Trim(); + m_sServiceCode = CmUtil.MidH(sRsvStr, 554, 5).Trim(); + + m_sInPutData = m_sInMaskData; + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF; + + //ReadBarCode= m_sInPutData.Length > 16 ? CmUtil.MidH(m_sInPutData, 0, 16) : m_sInPutData; + return true; + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetRfCardData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + // 여전법 대응//////////////////////////////////////////////////////////////////// + CmUtil.ZeroFillClear(ref sRsvStr); + ////////////////////////////////////////////////////////////////////////////////// + } + return false; + } + + /// + /// POP 카드 정보 입력 처리 + /// + /// + private bool GetPopCardData() + { + string sRsvStr = ""; + try + { + //IcCallBack = false; // IC리더 콜백 해지 + + ClearCardInfo(); // 카드 입력 정보 클리어 + + if (m_cDeviceICReader.RfPrepaidCardInfo(ref sRsvStr) == false) + { + if (sRsvStr != "") SendErrorMessageEvent(sRsvStr); + return false; + } + if (sRsvStr.StartsWith("T") == true) + { + m_sInPutData = sRsvStr.Substring(7, 16).Trim(); + } + else if (sRsvStr.StartsWith("E") == true) + { + m_sInPutData = sRsvStr.Substring(1, 20).Trim(); + } + else + { + return false; + } + + bool bRet = EncryptedCardNo(m_sInPutData, ref m_sInMaskData, ref m_sInEncData); + if (bRet == true) + { + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF; + } + return bRet; + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetPopCardData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + // 여전법 대응//////////////////////////////////////////////////////////////////// + CmUtil.ZeroFillClear(ref sRsvStr); + ////////////////////////////////////////////////////////////////////////////////// + } + return false; + } + #endregion + + #region 여전법 대응 + /// + /// ZeroFill 초기화 + /// + private void InDataToZeroFill() + { + try + { + + //여전법 대응! + ////////////////////////////////////////////////////////////////////////////////// + CmUtil.ZeroFillClear(ref m_sInPutData); + CmUtil.ZeroFillClear(ref m_sInEncData); + CmUtil.ZeroFillClear(ref m_sInMaskData); + ////////////////////////////////////////////////////////////////////////////////// + } + catch + { + } + + } + #endregion 여전법 대응 + + #region IC리더 콜백 + //delegate void DelegateIcReaderCallBack(int rc, StringBuilder str); + /// + /// IC리더 콜백 함수 + /// + /// + /// + public void OnIcReaderCallBack(int num, StringBuilder str) + { + try + { + SendReadStart(); + if (num == 1) + { + GetIcCardData(); + } + else + { + if (str.ToString().StartsWith("EN")) + { + ClearCardInfo(); // 카드 입력 정보 클리어 + + m_sInEncData = CmUtil.MidH(str.ToString(), 0, 512).Trim(); + m_sInMaskData = CmUtil.MidH(str.ToString(), 512, 40).Trim(); + m_sInPutData = m_sInMaskData; + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP; + } + } + if (!string.IsNullOrEmpty(m_sInPutData)) SearchTxtInPut(); + SendReadEnd(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OnIcReaderCallBack()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + #endregion + + #region Call Process에 이벤트 전송 + private void SendErrorMessageEvent(string _errorMessageString) + { + try + { + CommonLog.ErrorLogWrite(this, "SendErrorMessageEvent()", _errorMessageString); + ErrorMessageEvent(_errorMessageString); + } + catch + { + } + } + private void SendErrLogEvent(ErrorCode _errorCode) + { + try + { + CommonLog.DebugLogWrite(this, "SendErrLogEvent()", _errorCode.ToString()); + ErrorEvent(_errorCode); + } + catch + { + + } + } + private void SendReadStart() + { + try + { + CommonLog.DebugLogWrite(this, "SendReadStart()"); + ReadStart(this); + } + catch + { + + } + } + private void SendReadEnd() + { + try + { + CommonLog.DebugLogWrite(this, "SendReadEnd()"); + ReadEnd(this); + } + catch + { + + } + } + #endregion + + private void ClearCardInfo() + { + try + { + m_sInPutType = ""; // 입력구분 + m_sInPutData = ""; // 입력데이터 + m_sInMaskData = ""; // 마스킹 + m_sInEncData = ""; // 카드데이터 + m_sServiceCode = ""; // 서비스코드 + m_sAppCardNo = ""; // 승인카드번호 + + + m_bSearchSuccess = false; + } + catch + { + } + } + #endregion + + + + + } +} \ No newline at end of file diff --git a/Kiosk/Payments/SPC.Kiosk.Payments/posLastPayments.cs b/Kiosk/Payments/SPC.Kiosk.Payments/posLastPayments.cs new file mode 100644 index 0000000..e8dd342 --- /dev/null +++ b/Kiosk/Payments/SPC.Kiosk.Payments/posLastPayments.cs @@ -0,0 +1,1133 @@ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; +using Cosmos.CommonManager; +using System.Threading; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Common; +using System.Collections; + +namespace SPC.Kiosk.Payments +{ + /// + /// 통신사 할인 승인 + /// + public class posLastPayments : IDisposable + { + + //UserLog.WriteLogFile(UserCom.LOG_ERROR, "SPC.Kiosk.Payments", "posLastPayments.?", "Exception." + ex.Message); + #region [ Members ] + public enum ErrorCode + { + LastPaymentsCardNumberError, + LastPaymentsEncrtipError, + LastPaymentsNotInitailzedError, + LastPaymentsProcessingTimeOut, + LastPaymentsUnknownError, + LastPaymentsCardReadingError + } + /// + /// ErrorMessage Event + /// + /// 반환 로그 + public delegate void ErrorMessageEventHandler(string ErrorString); + /// + /// 로그메세지 이벤트 반환용 + /// + public event ErrorMessageEventHandler ErrorMessageEvent; + /// + /// Error 반환 Event + /// + /// 반환 Error Code + public delegate void LogErrorHandler(ErrorCode errorCode); + /// + /// Error Code 이벤트 반환용 + /// + public event LogErrorHandler ErrorEvent; + /// + /// IcReadStart Event + /// + /// + public delegate void IcReadStart(object sender); + /// + /// IcReadStart Event 반환용 + /// + public event IcReadStart ReadStart; + /// + /// IcReadStart Event + /// + /// + public delegate void IcReadEnd(object sender); + /// + /// IcReadStart Event 반환용 + /// + public event IcReadEnd ReadEnd; + /// + /// NeedSign Event + /// + /// + public delegate void NeedSignStart(object sender); + /// + /// NeedSign Event 반환용 + /// + public event NeedSignStart SignStartEvent; + /// + /// NeedSignEnd Event + /// + /// + public delegate void NeedSignEnd(object sender); + /// + /// NeedSignEnd Event 반환용 + /// + public event NeedSignEnd SignEndEvent; + + private SManager sManager = null; // 이 객체를 통해 업무 Service 호출 + private StateServer StateObject = null; // StateObject : StateServer Object (객체) + private PosStatus m_cPosStatus = null; // 기본정보 참조 + private TranStatus m_cTrnStatus = null; // 거래정보 참조 + private DeviceStatus m_cDevStatus = null; // 디바이스 관리 + private PosOLEDevice.CallbackIc delegateReaderCardInfo; // IC리더 콜백(CardInfo) + private IDataProcessUs m_cDataService = null; + private IICReaderUs m_cDeviceICReader = null; + + private IPaymentUs m_cSmilePay = null; + private IPaymentExpUs m_cHappyPoint = null; // 해피포인트 적립 + + private ICampaignUs m_cCampaingMain = null; // 캠페인 관리 + + private string m_sPosMenuKey = string.Empty; + private string m_sFallDiv; //FallBack구분 + private string m_sIcChip; //IC CHIP DATA(EMV) + private string m_sSign; //사인 데이터 + private string m_sTax; //세금 + private double m_dCreditCardDcAtm = 0d; //카드할인금액 + private string m_sCreditCardDcTy=string.Empty; //카드할인타입 + + //#15183 보안리더기 삼성페이 해피포인트 자동적립 기능 수정 start,phj + private string m_sMobileCode = ""; + //#15183 보안리더기 삼성페이 해피포인트 자동적립 기능 수정 end,phj + /// + /// 입력구분 + /// + private string m_InputType = string.Empty; + /// + /// 입력데이터 + /// + private string m_sInPutData = string.Empty; + /// + /// 마스킹데이터 + /// + private string m_sInMaskData = string.Empty; + /// + /// 카드데이터(암호화) + /// + private string m_sCardNo = string.Empty; + /// + /// 서비스코드 + /// + private string m_sService = string.Empty; + /// + /// 처리 성공 여부 + /// + private bool m_bProcessSuccess = false; + /// + /// POS 초기화 필요 유무 + /// + public bool NeedInitModule { get; set; } + /// + /// 승인 수단 + /// + public string CertifyKey { get; set; } = string.Empty; + public LastPaymentsType PaymentsType { get; set; } + + public double Payment { get; set; } = 0d; + private bool ReadProcessEnd { get; set; } = false; + + private bool icCallBack = false; + + + /// + /// Ic Reader CallBack Switch + /// + public bool IcCallBack + { + get { return icCallBack; } + set + { + if (value) + { + //m_cDeviceICReader.RegIcCallback(delegateReader); + + try + { + string sApprID = PosMstManager.GetMstVan(ItemConst.TR_ITEM_ID.CREDITCARD_ITEM, ItemConst.TR_ITEM_ID.CREDITCARD.CREDIT_CARD, PosMst.MST_VAN.DATA.APPR_ID); + bool icR = m_cDeviceICReader.RegIcCallbackCardInfo(sApprID, m_cDataService.IntParse(Payment.ToString()), delegateReaderCardInfo); + icCallBack = value; + CommonLog.DebugLogWrite(this,"IcCallBack","RegIcCallbackCardInfo Success !!"); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this,"IcCallBack","RegIcCallbackCardInfo Fail !!", string.Format("{0}\n{1}",ex.Message,ex.StackTrace)); + } + } + } + } + public double PaymentsValue { get; protected set; } = 0d; + /// + /// Point 사용시 비번 필요 유무 + /// + public bool NeedPassword { get; protected set; } + public long PaySEQ { get; protected set; } + /// + /// 인증 처리 성공 유무 + /// + public bool ProcessOK + { + get { return m_bProcessSuccess; } + } + public bool IsTimeout + { + set + { + if (value) + { + ErrorEvent(ErrorCode.LastPaymentsProcessingTimeOut); + } + } + } + public bool SignEndStatus { get; set; } + public string SignData + { + get { return m_sSign; } + set { m_sSign = value; } + } + public double NoSignLimitAmount { get; set; } = 0d; + + public string ReadBarcordNumber { get; set; } = string.Empty; + + public bool SelfCashBill { get; protected set; } = false; + #endregion + + #region [ Ctor && Dispose ] + /// + /// Ctor + /// + public posLastPayments() + { + try + { + sManager = new SManager(); + StateObject = (StateServer)StateServer.GetInstance(); + NeedInitModule = StateObject.POS == null + || StateObject.TRAN == null + || StateObject.DEVICE == null; + if (!NeedInitModule) + { + m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 + m_cTrnStatus = (TranStatus)StateObject.TRAN; // POS 거래정보 + m_cDevStatus = (DeviceStatus)StateObject.DEVICE; + m_cDeviceICReader = (IICReaderUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_ICREADER); + delegateReaderCardInfo = new PosOLEDevice.CallbackIc(OnIcReaderCallBackCardInfo); // IC리더 콜백(CardInfo) + m_cDataService = (IDataProcessUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_SERVICE); + + m_cCampaingMain = (ICampaignUs)sManager.InitServiceInstance(ServiceLists.ASV_CAMPAIGN.DLL, ServiceLists.ASV_CAMPAIGN.CAMPAIGN_MAIN); + m_cSmilePay = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.SMAILPAY); + m_cHappyPoint = (IPaymentExpUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.POINTHAPPYPOINT); + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "Ctor" ,"Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// + /// + public void Dispose() + { + + try + { + ReadProcessEnd = true; + if (IcCallBack ) + { + //m_cDeviceICReader.UnRegIcCallback(); + m_cDeviceICReader.UnRegIcCallbackCardInfo(); + IcCallBack = false; + } + InDataToZeroFill(); + + sManager = null; + StateObject = null; + m_cPosStatus = null; // POS 기본정보 + m_cTrnStatus = null; // POS 거래정보 + m_cDevStatus = null; + + m_cDeviceICReader = null; + delegateReaderCardInfo = null; + m_cDataService = null; + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this,"Dispose", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + #endregion + + #region [ Methods ] + public void StartCashBill(string _inputString, string _divType, double _cashAmount, double _taxAmount) + { + CommonLog.InfoLogWrite(this, "StartCashBill()", "Start"); + + try + { + m_bProcessSuccess = false; + SendReadStart(); + //사업자인 경우 길10자리가 아니면 자진 발급을 위해 입력번호 삭제 + if (_divType.Equals("1") && !_inputString.Length.Equals(10)) _inputString = string.Empty; + //개인(소극공제) 인 경우 6자리 이하면 자진 발급처리 + if (_divType.Equals("0") && _inputString.Length < 6) _inputString = string.Empty; + if (string.IsNullOrEmpty(_inputString)) + { + SelfCashBill = true; + _divType = "0"; //자진 발급은 개인(소득공제용만) + _inputString = CommonValue.CashReceiptDefaultNo; + } + m_sInPutData = EncryptedCashInputNo(_inputString, _divType); + if (string.IsNullOrEmpty(m_sInPutData)) + { + SelfCashBill = true; + _divType = "0"; //자진 발급은 개인(소득공제용만) + _inputString = CommonValue.CashReceiptDefaultNo; + m_sInPutData = EncryptedCashInputNo(_inputString, _divType); + } + if (!string.IsNullOrEmpty(m_sInPutData)) + { + int retry = 0; + do + { + CompleteTxtCashBilll(_inputString, _divType, _cashAmount, _taxAmount); + retry++; + if (!SelfCashBill) + { + if (retry.Equals(1)) + { + //승인 실패시 자진 발급 재승인 + SelfCashBill = true; + _divType = "0"; //자진 발급은 개인(소득공제용만) + _inputString = CommonValue.CashReceiptDefaultNo; + m_sInPutData = EncryptedCashInputNo(_inputString, _divType); + if (string.IsNullOrEmpty(m_sInPutData)) break; + } + else + { + break; + } + } + else + { + break; + } + + + } while (!m_bProcessSuccess && retry < 2);//1회만 재승인 + } + SendReadEnd(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "StartCashBill()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + CommonLog.InfoLogWrite(this, "StartCashBill()", string.Format("End : Result={0}", ProcessOK ? "OK" : "Fail")); + } + + private void CompleteTxtCashBilll(string inputString, string divType, double cashAmount, double taxAmount) + { + CommonLog.DebugLogWrite(this, "StartCashBill()", "Start"); + var m_cCashBill = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.CASHBILL); + try + { + double dNetAmt = CmUtil.DoubleSubtraction(cashAmount, taxAmount); + string sIssueType = "0"; + var sRet = m_cCashBill.SetPayment(new string[] { PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN, m_sInPutData, dNetAmt.ToString(), taxAmount.ToString(), "0", cashAmount.ToString(), divType, sIssueType, "", "", "", "", "", "", m_sInMaskData, SelfCashBill ? "1" : "0" }); + if (sRet != UserCom.RST_OK) + { + InDataToZeroFill(); + m_bProcessSuccess = false; + if (sRet == null || sRet.Equals(UserCom.RST_ERR)) + { + SendErrLogEvent(ErrorCode.LastPaymentsUnknownError); + } + else + { + SendErrorMessageEvent(sRet); + } + } + else + { + m_bProcessSuccess = true; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "CompleteTxtCashBilll()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + m_cCashBill = null; + } + CommonLog.DebugLogWrite(this, "StartCashBill()", "End"); + } + private string EncryptedCashInputNo(string sIndata,string divType) + { + string tmpEnc = ""; + + try + { + + if (sIndata.Length == 18 && sIndata.StartsWith("15442020") == true) + { + sIndata = sIndata + "="; + } + + //#20171024 START, PHJ + //DeviceICReader.cs로 결제코드,상세코드를 넘기기 위해서. + //해피포인트로 현금영수증 승인하는지 구분하기 위해서. + + m_cDeviceICReader.PAY_WAY_CD = ItemConst.TR_ITEM_ID.ETC_INFO_ITEM; + m_cDeviceICReader.PAY_DTL_CD = ItemConst.TR_ITEM_ID.ETC_INFO.CASHBILL; + //#20171024 END, PHJ + + //카드번호 처리 부분 임시 주석 2016-06-15 + //#20170913 현금영수증, 포인트카드 마스킹 미적용 start + // "0"인 경우 마스킹 미처리 + //기존 + //tmpEnc = m_cDeviceICReader.GetEncryptedCardNo(sIndata).Trim(); + //변경 + tmpEnc = m_cDeviceICReader.GetEncryptedCardNo(sIndata, "0").Trim(); + //#20170913 현금영수증, 포인트카드 마스킹 미적용 end + + if (CmUtil.MidH(tmpEnc, 0, 2) == "00") + { + //#20170913 현금영수증, 포인트카드 마스킹 미적용 start + //기존 + /* + // Mod, 2017.09.05, 전화번호 마스킹 변경 처리 + //m_sMaskingCardNo = CmUtil.MidH(tmpEnc, 514, 37).Trim(); + if (sIndata.Length == 10 || sIndata.Length == 11) + { + m_sMaskingCardNo = CmUtil.LeftH(sIndata, sIndata.Length - 4) + new string('*', 4); + } + else + { + m_sMaskingCardNo = CmUtil.MidH(tmpEnc, 514, 37).Trim(); + } + */ + //변경 + m_sInMaskData = CmUtil.MidH(tmpEnc, 514, 37).Trim(); + //#20170913 현금영수증, 포인트카드 마스킹 미적용 end + + m_sInPutData = m_sInMaskData; + + //#20180426 현금영수증 마스킹 변경 및 영수증 문구 변경 start + //기존 + /* + //#20170913 현금영수증, 포인트카드 마스킹 미적용 start + + if (sIndata.Length == 10 || sIndata.Length == 11) + { + //#20171121 전화번호 길이와 마스킹 된 값의 길이와 다름. start, phj + //기존 + //m_sMaskingCardNo = CmUtil.LeftH(m_sMaskingCardNo, m_sMaskingCardNo.Length - 4) + new string('*', 4); + + //변경 + m_sMaskingCardNo = CmUtil.LeftH(sIndata, 6) + new string('*', sIndata.Length - 6); + //#20171121 전화번호 길이와 마스킹 된 값의 길이와 다름. end, phj + } + else + { + m_sMaskingCardNo = CmUtil.MidH(m_sMaskingCardNo, 0, 6) + "********"; + } + + //#20170913 현금영수증, 포인트카드 마스킹 미적용 end + */ + //#20180426 현금영수증 마스킹 변경 및 영수증 문구 변경 end + + //#20171024 지출증빙으로 발행시 입력한 자리수까지만 영수증상에 표시 되도록 수정 start + //10자리 입력시 spcnpos.dll로 암호화 처리시 6자리+'******' 로 변환이 되어 11자리 입력 한 것으로 보임 + if (divType == "1") + { + m_sInMaskData = CmUtil.MidH(m_sInMaskData, 0, sIndata.Length); + } + //#20171024 지출증빙으로 발행시 입력한 자리수까지만 영수증상에 표시 되도록 수정 end + + tmpEnc = CmUtil.MidH(tmpEnc, 2, 512).Trim(); + } + else + { + tmpEnc = ""; + + + //암호화 처리 실패! + CommonLog.ErrorLogWrite(this, "EncryptedCashInputNo()", "Fail !!"); + } + } + catch (Exception ex) + { + tmpEnc = ""; + CommonLog.ErrorLogWrite(this, "EncryptedCashInputNo()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + + return tmpEnc; + + } + /// + /// 최종 결제 처리 + /// + /// + public void StartCertifyProcessing(LastPaymentsType _paymentsType, string _inputString, double _payments) + { + try + { + CommonLog.InfoLogWrite(this,"StartCertifyProcessing()","Start"); + m_bProcessSuccess = false; + ReadBarcordNumber = string.Empty; + if (NeedInitModule) + { + SendReadStart(); + Thread.Sleep(1000); //진행창 보이기 위한 딜레이 + ErrorEvent(ErrorCode.LastPaymentsNotInitailzedError); + } + else + { + PaymentsType = _paymentsType; + Payment = _payments; + m_cTrnStatus.Head.TradeDiv = ItemConst.TRAN_DIV.NORMAL; + switch(PaymentsType) + { + case LastPaymentsType.IcCard: + case LastPaymentsType.SsLgPay: + ReadProcessEnd = false; + IcCallBack = true; + while (!ReadProcessEnd) ; + + + + + + if (!string.IsNullOrEmpty(m_sInPutData)) + { + + + + CompleteTxtInPut(); + } + else + { + SendErrLogEvent(ErrorCode.LastPaymentsCardReadingError); + } + break; + case LastPaymentsType.HappyGift: + ReadProcessEnd = false; + IcCallBack = true; + while (!ReadProcessEnd && string.IsNullOrEmpty(ReadBarcordNumber)) ; + if (!ReadProcessEnd) + { + if (IcCallBack) + { + m_cDeviceICReader.UnRegIcCallbackCardInfo(); + IcCallBack = false; + } + ReadProcessEnd = true; + } + else + { + ReadBarcordNumber = string.Empty; + } + if (!string.IsNullOrEmpty(ReadBarcordNumber)) + { + m_InputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP; + m_sInMaskData = _inputString; + m_sInPutData = _inputString + "="; + if (EncryptedCardNo(m_sInPutData, ref m_sInMaskData, ref m_sCardNo)) + { + CompleteTxtInPut(); + } + else + { + SendErrLogEvent(ErrorCode.LastPaymentsEncrtipError); + } + } + else + { + if (!string.IsNullOrEmpty(m_sInPutData)) + { + CompleteTxtInPut(); + } + else + { + SendErrLogEvent(ErrorCode.LastPaymentsCardReadingError); + } + } + break; + case LastPaymentsType.CashBee: + case LastPaymentsType.Tmoney: + case LastPaymentsType.SpcEmployee: + SendReadStart(); + SendErrLogEvent(ErrorCode.LastPaymentsUnknownError); + break; + case LastPaymentsType.SmilePay: + case LastPaymentsType.AliPay: + case LastPaymentsType.ZeroPay: + //SendReadStart(); + if (_inputString.Replace("=", "").Replace("@", "").Length.Equals(16)) + { + m_InputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP; + m_sInMaskData = _inputString; + m_sInPutData = _inputString + "="; + if (EncryptedCardNo(m_sInPutData, ref m_sInMaskData, ref m_sCardNo)) + { + CompleteTxtInPut(); + } + else + { + SendErrLogEvent(ErrorCode.LastPaymentsEncrtipError); + } + } + else + { + SendErrLogEvent(ErrorCode.LastPaymentsCardNumberError); + } + break; + } + } + CommonLog.DebugLogWrite(this,"StartCertifyProcessing()","m_cDeviceICReader.Init_ICReader Before"); + m_cDeviceICReader.Init_ICReader(" "); + CommonLog.DebugLogWrite(this, "StartCertifyProcessing()", "m_cDeviceICReader.Init_ICReader After"); + SendReadEnd(); + CommonLog.InfoLogWrite(this, "StartCertifyProcessing()", string.Format("End : Result={0}", ProcessOK ? "OK" : "Fail")); + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "StartCertifyProcessing()","Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// 휴대폰 번호 형식 확인 + /// + /// + /// + private bool IsCellularPhoneNumber(string sInputData) + { + bool bRet = false; + try + { + if (sInputData.Length == 10 || sInputData.Length == 11) + { + if (sInputData.StartsWith("010") == true || sInputData.StartsWith("011") == true || sInputData.StartsWith("017") == true || + sInputData.StartsWith("016") == true || sInputData.StartsWith("018") == true || sInputData.StartsWith("019") == true) + { + bRet = true; + } + } + } + catch + { + bRet = false; + } + return bRet; + } + /// + /// 승인 전문 처리 + /// + private void CompleteTxtInPut() + { + CommonLog.DebugLogWrite(this, "CompleteTxtInPut()", "Start"); + string sRet = UserCom.RST_ERR; + object m_cPayments = null; + object m_cPaymentsGift = null; + try + { + m_bProcessSuccess = false; + switch (PaymentsType) + { + case LastPaymentsType.IcCard: + case LastPaymentsType.SsLgPay: + //0:마스킹 카드번호 1:입력구분 2:카드번호 3:할부개월 4:총금액 5:봉사료 + //6:세금 7:비밀번호 8:신용카드종류 9:칩데이터 10:사인 + //11:Fallback구분 12:제휴할인금액(캠페인) 13:원승인번호 14:원승인일자 15:아이템코드 + //16:매입사코드 17:매입사명 18:할인카드구분 19:할인금액 + //20:승인구분 21:매체구분 22:서비스코드 + + // 캠페인 처리 => 키값(취소시사용),카드번호,캠페인대상,지불구분,지불금액 + ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM); + double nDisAmt = m_cCampaingMain.ExecuteCampaignPayment(alPayItem.Count.ToString(), m_sCardNo + "0", ItemConst.CPI_CUST_PAY_TYPE.CREDTCARD, Payment); + var lastPayment = CmUtil.DoubleSubtraction(Payment, nDisAmt); + + m_sSign = string.Empty; + if (NoSignLimitAmount > 0 && lastPayment > NoSignLimitAmount) + { + SignEndStatus = false; + SignStart(); + while (!SignEndStatus) ; + SignEnd(); + + } + m_sTax = m_cDataService.GetPaymentAmtVAT(lastPayment).ToString(); + m_cPayments = sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.CREDITCARD); + m_cPaymentsGift = sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.HPGIFTCARD); + + + if (m_cPayments is IPaymentUs paymentUs) + { + + // 해피기프트카드 체크 2019.04.25 + //string[] aRet = new string[4]; + //string m_sCardDiv = ""; + //sRet = paymentUs.SearchPayment(new string[] { PosConst.CREDITCARD_SEARCH_TYPE.PREFIX, CmUtil.MidH(m_sInMaskData, 0, 6).ToString() }, ref aRet); + //if (sRet == UserCom.RST_OK) + //{ + // m_sCardDiv = aRet[0].Trim(); + //} + //else + //{ + // InDataToZeroFill(); + // m_bProcessSuccess = false; + // if (!sRet.Equals(UserCom.RST_ERR)) SendErrorMessageEvent(sRet); + //} + ////해피기프트카드 체크 끝 + //sRet = UserCom.RST_ERR; + + //if (aRet[0].Trim() == "C" )//&& aRet[2] == "98") + //{ + // // 해피기프트(신) + // if (m_cPaymentsGift is IPaymentUs paymentUsGift) + // { + // sRet = paymentUsGift.SetPayment(new string[] { + // /*0*/m_sInMaskData, /*1*/m_InputType, /*2*/m_sCardNo, /*3*/"00", /*4*/Payment.ToString(), /*5*/"0" + // , /*6*/m_sTax, /*7*/"", /*8*/"", /*9*/m_sIcChip, /*10*/"" + // , /*11*/m_sFallDiv, /*12*/"0",/*13*/"",/*14*/"",/*15*/"" + // , /*16*/"",/*17*/"",/*18*/"", /*19*/m_dCreditCardDcAtm.ToString() + // , /*20*/ItemConst.PAY_APP_DIV.NORMAL, /*21*/"", /*22*/m_sService }); + + // } + //} + //else + //{ + sRet = paymentUs.SetPayment(new string[] { + /*0*/m_sInMaskData, /*1*/m_InputType, /*2*/m_sCardNo, /*3*/"00", /*4*/lastPayment.ToString(), /*5*/"0" + , /*6*/m_sTax, /*7*/"", /*8*/"", /*9*/m_sIcChip, /*10*/m_sSign + , /*11*/m_sFallDiv, /*12*/"0",/*13*/"",/*14*/"",/*15*/"" + , /*16*/"",/*17*/"",/*18*/"", /*19*/m_dCreditCardDcAtm.ToString() + , /*20*/ItemConst.PAY_APP_DIV.NORMAL, /*21*/"", /*22*/m_sService }); + //} + + + if (sRet != UserCom.RST_OK) + { + InDataToZeroFill(); + m_bProcessSuccess = false; + if (sRet == null || sRet.Equals(UserCom.RST_ERR)) + { + SendErrLogEvent(ErrorCode.LastPaymentsUnknownError); + } + else + { + SendErrorMessageEvent(sRet); + } + } + else + { + PaymentsValue = lastPayment; + m_bProcessSuccess = true; + } + } + break; + + case LastPaymentsType.SmilePay: + + #region :: Smile Pay 결제로직 + + // 승인금액 또는 결제 금액을 확인 하세요. + //if (m_cDataService.DoubleParse(txtPayAmt.Text) <= 0) + //{ + // MessageManager.GetErrorMessage(POS_MESSAGE.ERROR.MSG_0597); + // return false; + //} + + string sInPutType = m_InputType; + string sInPutData = m_sInPutData; + string sInEncData = m_sCardNo; + string sInOrgData = m_sInPutData; + //if (m_sInEncData == "") + //{ + // if (m_sInPutData == "") + // { + // ///sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN; + // sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_MOBILE_SWIP; + // sInOrgData = txtCardNo.Value; + // //sInPutData = txtCardNo.Value; + // } + + // EncryptedCardNo(sInOrgData, ref sInPutData, ref sInEncData); + //} + + //#17169 스마일페이 변경요청 건 start, 20181113 + //기존소스 + /* + //#17169 스마일페이 변경요청 건 start + string sSmilepayCampaingCode = ""; + string sSmilepayPromotionCode = ""; + double dSmileCashTargetAmt = 0; + if (m_cDataService.DoubleParse(txtDCAmt.Text) > 0) + { + m_cCampaingMain.GetSmilepayPromotionCode(out sSmilepayCampaingCode, out sSmilepayPromotionCode); + if (sSmilepayCampaingCode != "" && sSmilepayPromotionCode != "") { dSmileCashTargetAmt = m_cCampaingMain.GetSmileCashTargetAmt(sSmilepayCampaingCode); } + } + //#17169 스마일페이 변경요청 건 end + */ + + //변경소스 + string sSmilepayPromotionCode = ""; //스마일페이로모션코드 + double dSmileCashTargetAmt = 0; //스마일캐시금액 + bool bApplyCampaign = false; // 적용된캠페인유무 + + m_cCampaingMain.GetSmailePayCampaignCheck(Payment, out sSmilepayPromotionCode, out dSmileCashTargetAmt, out bApplyCampaign); + //#17169 스마일페이 변경요청 건 end, 20181113 + + //#17169 스마일페이 변경요청 건 start + //기존 + //포인트 사용 승인 처리 + //sRet = m_cSmilePay.SetPayment(new string[] { m_sPosMenuKey, sInPutType, sInPutData, sInEncData, m_cDataService.DoubleParse(txtPayAmt.Text).ToString(), "", sInOrgData }); + //변경 + //포인트 사용 승인 처리 + m_sPosMenuKey = PosKey.MENU_KEY.SMILE_PAY; + sRet = m_cSmilePay.SetPayment(new string[] { m_sPosMenuKey, sInPutType, sInPutData, sInEncData, Payment.ToString(), "", sInOrgData, sSmilepayPromotionCode, m_cPosStatus.Global.NumericTOCurrency(dSmileCashTargetAmt) }); + //#17169 스마일페이 변경요청 건 end + + if (sRet != UserCom.RST_OK) + { + m_bProcessSuccess = false; + SendErrLogEvent(ErrorCode.LastPaymentsUnknownError); + return; + } + else + { // 자동적립사용이면 스마일페이 자동적립 처리 + if (PosMstManager.GetPosOption(POS_OPTION.OPT030) == "1") + { + sRet = m_cHappyPoint.SetSmilePayment(new string[] { sInPutType, sInPutData, sInEncData, "0", "", sInOrgData }); + } + if (!sRet.Equals(UserCom.RST_OK)) + { + + } + + } + + // 캠페인 처리 => 키값(취소시사용),카드번호,캠페인대상,지불구분,지불금액 + ArrayList alPayItem2 = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM); + m_cCampaingMain.CompleteCampaignPayment((alPayItem2.Count - 1).ToString()); + //#14538 스마일페이 캠페인 확인창 중복 팝업 확인요청 start,phj + //double nDisAmt2 = m_cCampaingMain.ExecuteCampaignPayment(alPayItem2.Count.ToString(), m_sCardNo, ItemConst.CPI_CUST_PAY_TYPE.SMILEPAY, Payment, false); + + PaymentsValue = Payment; + m_bProcessSuccess = true; + + #endregion + + break; + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this,"CompleteTxtInPut()","Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + if (m_cPayments != null) m_cPayments = null; + } + CommonLog.DebugLogWrite(this, "CompleteTxtInPut()", "End"); + } + /// + /// 카드 번호 암호화 + /// + /// + /// + /// + /// + private bool EncryptedCardNo(string sInData, ref string sInMaskData, ref string sInEncData) + { + string sEncData = sInData; + bool bRet = false; + try + { + + //#20170913 현금영수증, 포인트카드 마스킹 미적용 start + // "0"인 경우 마스킹 미처리 + //기존 + //sEncData = m_cDeviceICReader.GetEncryptedCardNo(sInData).Trim(); + //변경 + sEncData = m_cDeviceICReader.GetEncryptedCardNo(sInData, "0").Trim(); + //#20170913 현금영수증, 포인트카드 마스킹 미적용 end + + if (CmUtil.MidH(sEncData, 0, 2) == "00") + { + sInEncData = CmUtil.MidH(sEncData, 2, 512).Trim(); // 암호화 데이터 + sInMaskData = CmUtil.MidH(sEncData, 514, sEncData.Length - 514).Trim(); // 마스킹 데이터 + + //#20170913 현금영수증, 포인트카드 마스킹 미적용 start + sInMaskData = CmUtil.MidH(sInMaskData, 0, 6) + "********"; + //#20170913 현금영수증, 포인트카드 마스킹 미적용 end + + bRet = true; + } + else + { + CommonLog.ErrorLogWrite(this,"EncryptedCardNo()","Fail !!"); + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this,"EncryptedCardNo()","Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + return bRet; + } + + #region 여전법 대응 + /// + /// ZeroFill 초기화 + /// + private void InDataToZeroFill() + { + try + { + + //여전법 대응! + ////////////////////////////////////////////////////////////////////////////////// + CmUtil.ZeroFillClear(ref m_sInPutData); + CmUtil.ZeroFillClear(ref m_sCardNo); + CmUtil.ZeroFillClear(ref m_sInMaskData); + ////////////////////////////////////////////////////////////////////////////////// + } + catch + { + } + + } + #endregion 여전법 대응 + + #region IC리더 콜백 + + /// + /// IC리더 콜백 함수(CardInfo) + /// + /// + /// + public void OnIcReaderCallBackCardInfo(int num, StringBuilder str) + { + try + { + IcCallBack = false; + switch (PaymentsType) + { + case LastPaymentsType.IcCard: + case LastPaymentsType.SsLgPay: + case LastPaymentsType.HappyGift: + SendReadStart(); + break; + } + ClearCardInfo(); // 카드 입력 정보 클리어 + if (num > 0) + { + string sRsvStr = str.ToString(); + if (CmUtil.MidH(sRsvStr, 0, 2) == "00") + { + m_sCardNo = CmUtil.MidH(sRsvStr, 6, 512).Trim(); + m_sInMaskData = CmUtil.MidH(sRsvStr, 1030, 37).Trim(); + m_sService = CmUtil.MidH(sRsvStr, 1067, 5).Trim(); + m_sFallDiv = CmUtil.MidH(sRsvStr, 3, 1).Trim(); + m_sIcChip = CmUtil.MidH(sRsvStr, 518, 512).Trim(); + //#15183 보안리더기 삼성페이 해피포인트 자동적립 기능 수정 start,phj + m_sMobileCode = CmUtil.MidH(sRsvStr, 1072, 7).Trim(); + //#15183 보안리더기 삼성페이 해피포인트 자동적립 기능 수정 end,phj + if (CmUtil.MidH(sRsvStr, 4, 2).Trim() == "02") + //if (CmUtil.MidH(sRsvStr, 6, 2).Trim() == "EN") //모터드리븐 처리 (2019.04.23) + { + m_InputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP; + m_sIcChip = m_sFallDiv.Equals("3") ? m_sIcChip : string.Empty; + } + else + { + m_InputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC; + } + m_sInPutData = m_sInMaskData; + } + } + + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this,"OnIcReaderCallBackCardInfo()","Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + ReadProcessEnd = true; + } + + private bool GetIcCardData() + { + string sRsvStr = ""; + try + { + //IcCallBack = false; // IC리더 콜백 해지 + + + if (m_cDeviceICReader.GetCardInfo_ICReader(PosConst.IC_READER_TRAN_TYPE.CREDIT, CmUtil.IntParse(Payment.ToString()), ref sRsvStr) == true) + { + if (CmUtil.MidH(sRsvStr, 0, 2) == "00") + { + m_sCardNo = CmUtil.MidH(sRsvStr, 6, 512).Trim(); + m_sInMaskData = CmUtil.MidH(sRsvStr, 1030, 37).Trim(); + m_sIcChip = CmUtil.MidH(sRsvStr, 518, 512).Trim(); + if (CmUtil.MidH(sRsvStr, 4, 2).Trim() == "02") + { + m_InputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP; + } + else + { + m_InputType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_IC; + } + m_sService = CmUtil.MidH(sRsvStr, 1067, 5).Trim(); + m_sFallDiv = CmUtil.MidH(sRsvStr, 3, 1); // == "3" ? "0" : "1"; + m_sInPutData = m_sInMaskData; + //#15183 보안리더기 삼성페이 해피포인트 자동적립 기능 수정 start,phj + m_sMobileCode = CmUtil.MidH(sRsvStr, 1072, 7).Trim(); + //#15183 보안리더기 삼성페이 해피포인트 자동적립 기능 수정 end,phj + return true; + } + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetIcCardData()","Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + // 여전법 대응//////////////////////////////////////////////////////////////////// + CmUtil.ZeroFillClear(ref sRsvStr); + ////////////////////////////////////////////////////////////////////////////////// + } + return false; + } + #endregion + private void SendErrorMessageEvent(string _errorMessageString) + { + try + { + CommonLog.ErrorLogWrite(this, "SendErrorMessageEvent()", _errorMessageString); + ErrorMessageEvent(_errorMessageString); + } + catch + { + } + } + private void SendErrLogEvent(ErrorCode _errorCode) + { + try + { + CommonLog.DebugLogWrite(this, "SendErrLogEvent()", _errorCode.ToString()); + ErrorEvent(_errorCode); + } + catch + { + + } + } + private void SendReadStart() + { + try + { + CommonLog.DebugLogWrite(this, "SendReadStart()"); + ReadStart(this); + } + catch + { + + } + } + private void SendReadEnd() + { + try + { + CommonLog.DebugLogWrite(this, "SendReadEnd()"); + ReadEnd(this); + } + catch + { + + } + } + + private void SignStart() + { + try + { + CommonLog.DebugLogWrite(this, "SignStart()"); + SignStartEvent(this); + } + catch + { + + } + + } + private void SignEnd() + { + try + { + CommonLog.DebugLogWrite(this, "SignEnd()"); + SignEndEvent(this); + } + catch + { + + } + + } + + + private void ClearCardInfo() + { + try + { + m_sSign = ""; + m_InputType = ""; // 입력구분 + m_sInPutData = ""; // 입력데이터 + m_sInMaskData = ""; // 마스킹 + m_sCardNo = ""; // 카드데이터인카드번호 + + + m_bProcessSuccess = false; + } + catch + { + } + } + #endregion + + + + + } +} \ No newline at end of file diff --git a/Kiosk/Payments/SPC.Kiosk.Payments/posMobileCompanyDiscount.cs b/Kiosk/Payments/SPC.Kiosk.Payments/posMobileCompanyDiscount.cs new file mode 100644 index 0000000..1bda776 --- /dev/null +++ b/Kiosk/Payments/SPC.Kiosk.Payments/posMobileCompanyDiscount.cs @@ -0,0 +1,578 @@ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; +using Cosmos.CommonManager; +using System.Threading; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Common; +namespace SPC.Kiosk.Payments +{ + /// + /// 통신사 할인 승인 + /// + public class posMobileCompanyDiscount : IDisposable + { + //CommonLog.ErrorLogWrite("SPC.Kiosk.Payments.posMobileCompanyDiscount ?() Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + #region [ Members ] + public enum ErrorCode + { + MobileCompanyDiscountCardNumberError, + MobileCompanyDiscountEncrtipError, + MobileCompanyDiscountNotInitailzedError, + MobileCompanyDiscountProcessingTimeOut, + MobileCompanyDiscountUnknownError, + MobileCompanyDiscountCardNumError + } + /// + /// ErrorMessage Event + /// + /// 반환 로그 + public delegate void ErrorMessageEventHandler(string ErrorString); + /// + /// 로그메세지 이벤트 반환용 + /// + public event ErrorMessageEventHandler ErrorMessageEvent; + /// + /// Error 반환 Event + /// + /// 반환 Error Code + public delegate void LogErrorHandler(ErrorCode errorCode); + /// + /// Error Code 이벤트 반환용 + /// + public event LogErrorHandler ErrorEvent; + /// + /// IcReadStart Event + /// + /// + public delegate void IcReadStart(object sender); + /// + /// IcReadStart Event 반환용 + /// + public event IcReadStart ReadStart; + /// + /// IcReadStart Event + /// + /// + public delegate void IcReadEnd(object sender); + /// + /// IcReadStart Event 반환용 + /// + public event IcReadEnd ReadEnd; + + private SManager sManager = null; // 이 객체를 통해 업무 Service 호출 + private StateServer StateObject = null; // StateObject : StateServer Object (객체) + private PosStatus m_cPosStatus = null; // 기본정보 참조 + private TranStatus m_cTrnStatus = null; // 거래정보 참조 + private DeviceStatus m_cDevStatus = null; // 디바이스 관리 + private PosOLEDevice.DelegateIcReader delegateReader; // IC리더 콜백 + private IICReaderUs m_cDeviceICReader = null; + private IPaymentUs m_cMobilePoint = null; + + private string m_sPosMenuKey = string.Empty; + /// + /// 입력구분 + /// + private string m_sInPutType = string.Empty; + /// + /// 입력데이터 + /// + private string m_sInPutData = string.Empty; + /// + /// 마스킹데이터 + /// + private string m_sInMaskData = string.Empty; + /// + /// 카드데이터(암호화) + /// + private string m_sInEncData = string.Empty; + /// + /// 서비스코드 + /// + private string m_sServiceCode = string.Empty; + /// + /// 조회 성공 여부 + /// + private bool m_bSearchSuccess = false; + /// + /// POS 초기화 필요 유무 + /// + public bool NeedInitModule { get; set; } + /// + /// 승인 수단 + /// + public string CertifyKey { get; set; } = string.Empty; + public MobileCompanyType MobileCompany { get; set; } + + public double Payment { get; set; } = 0d; + + private bool icCallBack = false; + /// + /// Ic Reader CallBack Switch + /// + public bool IcCallBack + { + get { return icCallBack; } + set + { + if (value) + { + m_cDeviceICReader.RegIcCallback(delegateReader); + } + icCallBack = value; + } + } + /// + /// 마스크된 회원성명 + /// + public string MemberName { get; protected set; } = string.Empty; + /// + /// 할인 금액 + /// + public double DiscountValue { get; protected set; } = 0d; + public long PaySEQ { get; protected set; } + public bool KT_Double { get; set; } + /// + /// 인증 처리 성공 유무 + /// + public bool ProcessOK + { + get { return m_bSearchSuccess; } + } + public bool IsTimeout + { + set + { + if (value) + { + ErrorEvent(ErrorCode.MobileCompanyDiscountProcessingTimeOut); + } + } + } + #endregion + + #region [ Ctor && Dispose ] + /// + /// Ctor + /// + public posMobileCompanyDiscount() + { + try + { + sManager = new SManager(); + StateObject = (StateServer)StateServer.GetInstance(); + NeedInitModule = StateObject.POS == null + || StateObject.TRAN == null + || StateObject.DEVICE == null; + if (!NeedInitModule) + { + m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 + m_cTrnStatus = (TranStatus)StateObject.TRAN; // POS 거래정보 + m_cDevStatus = (DeviceStatus)StateObject.DEVICE; + m_cDeviceICReader = (IICReaderUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_ICREADER); + m_cMobilePoint = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.POINTMOBILECOM); + delegateReader = new PosOLEDevice.DelegateIcReader(OnIcReaderCallBack); // IC리더 콜백 + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "Ctor", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// + /// + public void Dispose() + { + + try + { + InDataToZeroFill(); + + sManager = null; + StateObject = null; + m_cPosStatus = null; // POS 기본정보 + m_cTrnStatus = null; // POS 거래정보 + m_cDevStatus = null; + + m_cDeviceICReader = null; + m_cMobilePoint = null; + delegateReader = null; // IC리더 콜백 + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "Dispose", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + #endregion + + #region [ Methods ] + + /// + /// 통신사 할인 처리 + /// + /// + public void StartCertifyProcessing(string _inputString, MobileCompanyType _mobileCompanyType,double _payments) + { + try + { + CommonLog.InfoLogWrite(this, "StartCertifyProcessing()", "Start"); + SendReadStart(); + if (NeedInitModule) + { + Thread.Sleep(1000); //진행창 보이기 위한 딜레이 + ErrorEvent(ErrorCode.MobileCompanyDiscountNotInitailzedError); + } + else + { + var startPorcess = false; + if (_inputString.Replace("=", "").Replace("@", "").Length.Equals(16)) + { + MobileCompany = _mobileCompanyType; + Payment = _payments; + m_cTrnStatus.Head.TradeDiv = ItemConst.TRAN_DIV.NORMAL; + switch (MobileCompany) + { + case MobileCompanyType.KT_Mobile: + if (KT_Double) + { + m_sPosMenuKey = PosKey.MENU_KEY.KT_DOUBLE; + } + else + { + m_sPosMenuKey = PosKey.MENU_KEY.KT; + } + break; + case MobileCompanyType.SK_Telecom: + m_sPosMenuKey = PosKey.MENU_KEY.SKT; + break; + case MobileCompanyType.LG_Uplus: + m_sPosMenuKey = PosKey.MENU_KEY.LGT; + break; + } + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP; + m_sInMaskData = _inputString; + m_sInPutData = _inputString + "="; + startPorcess = true; + } + else + { + SendErrLogEvent(ErrorCode.MobileCompanyDiscountCardNumError); + } + //승인 전문 처리 + if (startPorcess) + { + if (EncryptedCardNo(m_sInPutData, ref m_sInMaskData, ref m_sInEncData)) + { + CompleteTxtInPut(); + } + else + { + SendErrLogEvent(ErrorCode.MobileCompanyDiscountEncrtipError); + } + } + else + { + SendErrLogEvent(ErrorCode.MobileCompanyDiscountUnknownError); + } + } + SendReadEnd(); + CommonLog.InfoLogWrite(this, "StartCertifyProcessing()", string.Format("End : Result={0}", ProcessOK ? "OK" : "Fail")); + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "StartCertifyProcessing()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// 휴대폰 번호 형식 확인 + /// + /// + /// + private bool IsCellularPhoneNumber(string sInputData) + { + bool bRet = false; + try + { + if (sInputData.Length == 10 || sInputData.Length == 11) + { + if (sInputData.StartsWith("010") == true || sInputData.StartsWith("011") == true || sInputData.StartsWith("017") == true || + sInputData.StartsWith("016") == true || sInputData.StartsWith("018") == true || sInputData.StartsWith("019") == true) + { + bRet = true; + } + } + } + catch + { + bRet = false; + } + return bRet; + } + /// + /// Happoint 조회 전문 처리 + /// + private void CompleteTxtInPut() + { + CommonLog.DebugLogWrite(this, "CompleteTxtInPut()", "Start"); + string sRet = UserCom.RST_ERR; + try + { + + m_bSearchSuccess = false; + + // 승인 + sRet = m_cMobilePoint.SetPayment(new string[] { m_sPosMenuKey, m_sInPutType, m_sInMaskData, m_sInEncData, Payment.ToString(), "", "", "", "", "", "", "", "", "", "", "" }); + if (sRet != UserCom.RST_OK) + { + CertifyKey = string.Empty; + InDataToZeroFill(); + if (sRet == null || sRet.Equals(UserCom.RST_ERR)) + { + SendErrLogEvent(ErrorCode.MobileCompanyDiscountUnknownError); + } + else + { + SendErrorMessageEvent(sRet); + } + } + else + { + + CertifyKey = m_sInPutData; + var cPayItem = (Column.TR_PAYMENT.DATA)m_cMobilePoint.GetPayment(new string[] { }); + PaySEQ = cPayItem.SEQ; + DiscountValue = cPayItem.AMT_ENTRY_01; + m_bSearchSuccess = true; + + } } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "CompleteTxtInPut()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + CommonLog.DebugLogWrite(this, "CompleteTxtInPut()", "End"); + } + /// + /// 카드 번호 암호화 + /// + /// + /// + /// + /// + private bool EncryptedCardNo(string sInData, ref string sInMaskData, ref string sInEncData) + { + string sEncData = sInData; + bool bRet = false; + try + { + + //#20170913 현금영수증, 포인트카드 마스킹 미적용 start + // "0"인 경우 마스킹 미처리 + //기존 + //sEncData = m_cDeviceICReader.GetEncryptedCardNo(sInData).Trim(); + //변경 + sEncData = m_cDeviceICReader.GetEncryptedCardNo(sInData, "0").Trim(); + //#20170913 현금영수증, 포인트카드 마스킹 미적용 end + + if (CmUtil.MidH(sEncData, 0, 2) == "00") + { + sInEncData = CmUtil.MidH(sEncData, 2, 512).Trim(); // 암호화 데이터 + sInMaskData = CmUtil.MidH(sEncData, 514, sEncData.Length - 514).Trim(); // 마스킹 데이터 + + //#20170913 현금영수증, 포인트카드 마스킹 미적용 start + sInMaskData = CmUtil.MidH(sInMaskData, 0, 6) + "********"; + //#20170913 현금영수증, 포인트카드 마스킹 미적용 end + + bRet = true; + } + else + { + CommonLog.ErrorLogWrite(this, "EncryptedCardNo()", "Fail !!"); + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "EncryptedCardNo()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + return bRet; + } + + #region 여전법 대응 + /// + /// ZeroFill 초기화 + /// + private void InDataToZeroFill() + { + try + { + + //여전법 대응! + ////////////////////////////////////////////////////////////////////////////////// + CmUtil.ZeroFillClear(ref m_sInPutData); + CmUtil.ZeroFillClear(ref m_sInEncData); + CmUtil.ZeroFillClear(ref m_sInMaskData); + ////////////////////////////////////////////////////////////////////////////////// + } + catch + { + } + + } + #endregion 여전법 대응 + + #region IC리더 콜백 + //delegate void DelegateIcReaderCallBack(int rc, StringBuilder str); + /// + /// IC리더 콜백 함수 + /// + /// + /// + public void OnIcReaderCallBack(int num, StringBuilder str) + { + try + { + SendReadStart(); + if (num == 1) + { + GetIcCardData(); + } + else + { + if (str.ToString().StartsWith("EN")) + { + ClearCardInfo(); // 카드 입력 정보 클리어 + + m_sInEncData = CmUtil.MidH(str.ToString(), 0, 512).Trim(); + m_sInMaskData = CmUtil.MidH(str.ToString(), 512, 40).Trim(); + m_sInPutData = m_sInMaskData; + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP; + } + } + if (!string.IsNullOrEmpty(m_sInPutData)) CompleteTxtInPut(); + SendReadEnd(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OnIcReaderCallBack()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + private bool GetIcCardData() + { + string sRsvStr = ""; + try + { + //IcCallBack = false; // IC리더 콜백 해지 + + ClearCardInfo(); // 카드 입력 정보 클리어 + + if (m_cDeviceICReader.GetCardInfo_ICReader(PosConst.IC_READER_TRAN_TYPE.POINT, 0, ref sRsvStr) == true) + { + if (CmUtil.MidH(sRsvStr, 0, 2) == "00") + { + m_sInEncData = CmUtil.MidH(sRsvStr, 6, 512).Trim(); + m_sInMaskData = CmUtil.MidH(sRsvStr, 1030, 37).Trim(); + m_sServiceCode = CmUtil.MidH(sRsvStr, 1067, 5).Trim(); + + m_sInPutData = m_sInMaskData; + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP; + + + + return true; + } + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetIcCardData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + // 여전법 대응//////////////////////////////////////////////////////////////////// + CmUtil.ZeroFillClear(ref sRsvStr); + ////////////////////////////////////////////////////////////////////////////////// + } + return false; + } + #endregion + private void SendErrorMessageEvent(string _errorMessageString) + { + try + { + CommonLog.ErrorLogWrite(this, "SendErrorMessageEvent()", _errorMessageString); + ErrorMessageEvent(_errorMessageString); + } + catch + { + } + } + private void SendErrLogEvent(ErrorCode _errorCode) + { + try + { + CommonLog.DebugLogWrite(this, "SendErrLogEvent()", _errorCode.ToString()); + ErrorEvent(_errorCode); + } + catch + { + + } + } + private void SendReadStart() + { + try + { + CommonLog.DebugLogWrite(this, "SendReadStart()"); + ReadStart(this); + } + catch + { + + } + } + private void SendReadEnd() + { + try + { + CommonLog.DebugLogWrite(this, "SendReadEnd()"); + ReadEnd(this); + } + catch + { + + } + } + private void ClearCardInfo() + { + try + { + m_sInPutType = ""; // 입력구분 + m_sInPutData = ""; // 입력데이터 + m_sInMaskData = ""; // 마스킹 + m_sInEncData = ""; // 카드데이터인카드번호 + + + m_bSearchSuccess = false; + } + catch + { + } + } + #endregion + + + + + } +} \ No newline at end of file diff --git a/Kiosk/Payments/SPC.Kiosk.Payments/posMobileHappyCoupon.cs b/Kiosk/Payments/SPC.Kiosk.Payments/posMobileHappyCoupon.cs new file mode 100644 index 0000000..4a52165 --- /dev/null +++ b/Kiosk/Payments/SPC.Kiosk.Payments/posMobileHappyCoupon.cs @@ -0,0 +1,1111 @@ + +using System; +using System.Data; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; +using Cosmos.CommonManager; +using System.Threading; +using System.Collections; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +namespace SPC.Kiosk.Payments +{ + /// + /// POS HappyPoint Approval Process + /// + public class posMobileHappyCoupon : IDisposable + { + //CommonLog.ErrorLogWrite(this, "Ctor", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + #region [ Members ] + /// + /// HappyPointCertify ErrorCode + /// + public enum ErrorCode + { + MobileHappyCouponMobilePhoneNumberError, + MobileHappyCouponMobileCouponNumberError, + MobileHappyCouponMemInfoEncryptedCardNoError, + MobileHappyCouponNotInitailzedError, + MobileHappyCouponProcessingTimeOut, + MobileHappyCouponTotalAmount, + MobileHappyCouponCanUseCouponsIsZero, + MobileHappyCouponUnknownError, + } + /// + /// ErrorMessage Event + /// + /// 반환 로그 + public delegate void ErrorMessageEventHandler(string ErrorString); + /// + /// 로그메세지 이벤트 반환용 + /// + public event ErrorMessageEventHandler ErrorMessageEvent; + /// + /// Error 반환 Event + /// + /// 반환 Error Code + public delegate void LogErrorHandler(ErrorCode errorCode); + /// + /// Error Code 이벤트 반환용 + /// + public event LogErrorHandler ErrorEvent; + /// + /// IcReadStart Event + /// + /// + public delegate void IcReadStart(object sender); + /// + /// IcReadStart Event 반환용 + /// + public event IcReadStart ReadStart; + /// + /// IcReadStart Event + /// + /// + public delegate void IcReadEnd(object sender); + /// + /// IcReadStart Event 반환용 + /// + public event IcReadEnd ReadEnd; + + private SManager sManager = null; // 이 객체를 통해 업무 Service 호출 + private StateServer StateObject = null; // StateObject : StateServer Object (객체) + private PosStatus m_cPosStatus = null; // 기본정보 참조 + private TranStatus m_cTrnStatus = null; // 거래정보 참조 + private DeviceStatus m_cDevStatus = null; // 디바이스 관리 + private IDataProcessUs m_cDataService = null; + private IDataCommonUs m_cDataCommon = null; + private IPaymentUs m_cMobileCoupon = null; + + private string mPay_DC_Type = ""; // 결제 그룹 코드 + private string mPay_DC_CD = ""; // 결제 상세 코드 + private string m_sPosMenuKey = PosKey.MENU_KEY.MOBILE_COUPON_HAPPYCON; // 입력값 할인 + private string[] m_aRecvdData = null; + /// + /// 상품정보 작업용 + /// + private ArrayList m_aSaleItem = null; + private struct ITEM_PLU_CHECK + { + public string sCouponNo; // 쿠폰코드 + public string sVCouponNo; // 가상 쿠폰코드 + public string sProductID; // 프로덕트 코드 + public string iTemCD; // 상품코드 + public double T_Qty; // 구매해야될 건수 + public double S_Qty; // 구매한 건수 + public double SALE_PRC; // 상품단가 + public double SaleAmt; // 상품판매금액 + public double PayAmt; // 상품결제금액 + public double DCAmt; // 할인 + } + /// + /// 입력구분 + /// + private string m_sInPutType = ""; + /// + /// 입력데이터 + /// + private string m_sInPutData = ""; + /// + /// 마스킹데이터 + /// + private string m_sInMaskData = ""; + /// + /// 카드데이터(암호화) + /// + private string m_sInEncData = ""; + /// + /// 서비스코드 + /// + private string m_sServiceCode = ""; + /// + /// 승인카드번호 + /// + private string m_sAppCardNo = ""; + /// + /// 조회 성공 여부 + /// + private bool m_bSearchSuccess = false; + /// + /// POS 초기화 필요 유무 + /// + public bool NeedInitModule { get; set; } + /// + /// 승인 수단 + /// + public string CertifyKey { get; set; } = string.Empty; + /// + /// 마스크된 회원성명 + /// + public string MemberName { get; protected set; } = string.Empty; + public string MemberNumber { get; protected set; } = string.Empty; + /// + /// SPC 임직원 유무 + /// + public bool IsCompanyMember { get; protected set; } + /// + /// 적립 가능 유무 + /// + public bool CanReservePoint { get; protected set; } + /// + /// 회원 등급 + /// + public string MemberLevel { get; protected set; } = string.Empty; + /// + /// 회원 비밀번호 + /// + public string MemberPassword { get; protected set; } = string.Empty; + /// + /// HappyApp 가입 고객 + /// + public bool IsAppMamber { get; protected set; } = false; + /// + /// 단골 매장 유무 + /// + public bool IsFavoriteStore { get; protected set; } = false; + /// + /// 회원 적립 Point + /// + public double MemberPoint { get; protected set; } = 0d; + /// + /// 회원 가용 Point + /// + public double UseablePoint { get; protected set; } = 0d; + /// + /// 승인 요청 포인트 + /// + public double UseingPoint { get; set; } = 0d; + /// + /// 승인 포인트 + /// + public double ApprovalPoint { get; protected set; } = 0d; + /// + /// Point 사용시 비번 필요 유무 + /// + public bool NeedPassword { get; protected set; } + public double Payments { get; protected set; } + public long PaySEQ { get; protected set; } + /// + /// 인증 처리 성공 유무 + /// + public bool ProcessOK + { + get { return m_bSearchSuccess; } + } + /// + /// Processing TimeOut + /// + public bool IsTimeout + { + set + { + if (value) + { + ErrorEvent(ErrorCode.MobileHappyCouponProcessingTimeOut); + } + } + } + public M_MobileCouponReturn CouponData { get; protected set; } + #endregion + + #region [ Ctor && Dispose ] + /// + /// Ctor + /// + public posMobileHappyCoupon() + { + try + { + sManager = new SManager(); + StateObject = (StateServer)StateServer.GetInstance(); + NeedInitModule = StateObject.POS == null + || StateObject.TRAN == null + || StateObject.DEVICE == null; + if (!NeedInitModule) + { + m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 + m_cTrnStatus = (TranStatus)StateObject.TRAN; // POS 거래정보 + m_cDevStatus = (DeviceStatus)StateObject.DEVICE; + m_cDataService = (IDataProcessUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_SERVICE); + m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON); + m_cMobileCoupon = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.MOBILECOUPON_HAPPYCON); + + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "Ctor", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// + /// + public void Dispose() + { + try + { + InDataToZeroFill(); + + sManager = null; + StateObject = null; + m_cPosStatus = null; // POS 기본정보 + m_cTrnStatus = null; // POS 거래정보 + m_cDevStatus = null; + + + m_cDataService = null; + m_cDataCommon = null; + m_cMobileCoupon = null; + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "Dispose", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + #endregion + + #region [ Methods ] + /// + /// HappyPoint 회원 조회 (16 자리이면 Mobile BarCode, 그외는 전화 번호) + /// + /// + public void StartCertifyProcessing(string _inputString,double _payments) + { + try + { + CommonLog.InfoLogWrite(this, "StartCertifyProcessing()", "Start"); + SendReadStart(); + if (NeedInitModule) + { + Thread.Sleep(1000); //진행창 보이기 위한 딜레이 + ErrorEvent(ErrorCode.MobileHappyCouponNotInitailzedError); + } + else + { + var startPorcess = false; + if (_inputString.Length > 6) + { + startPorcess = GetPrefixToPayTypeInfo(_inputString); + Payments = _payments; + } + else + { + SendErrLogEvent(ErrorCode.MobileHappyCouponMobileCouponNumberError); + } + //조회 전문 처리 + if (startPorcess) + { + //SearchTxtInPut(PosConst.POS_INQ_MODE.SEARCH, "", ""); + SearchTxtInPut(_inputString, _payments); + } + + } + SendReadEnd(); + CommonLog.InfoLogWrite(this, "StartCertifyProcessing()", string.Format("End : Result={0}", ProcessOK ? "OK" : "Fail")); + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "StartCertifyProcessing()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + public void StartPaymentProcessing(M_MobileCouponReturn _mobileCouponReturn, double _payments) + { + try + { + CommonLog.InfoLogWrite(this, "StartPaymentProcessing()", "Start"); + SendReadStart(); + if (NeedInitModule) + { + Thread.Sleep(3000); //진행창 보이기 위한 딜레이 + ErrorEvent(ErrorCode.MobileHappyCouponNotInitailzedError); + } + else + { + var startPorcess = false; + if (_mobileCouponReturn is M_MobileCouponReturn + && _mobileCouponReturn.VirtureCoupons.Where(r=>r.RequestPrice > 0 ).Count() > 0) + { + CouponData = _mobileCouponReturn; + Payments = _payments; + startPorcess = true; + } + else + { + SendErrLogEvent(ErrorCode.MobileHappyCouponTotalAmount); + } + //승인 전문 처리 + if (startPorcess) + { + CompleteTxtInPut(); + } + + } + SendReadEnd(); + CommonLog.InfoLogWrite(this, "StartPaymentProcessing()", string.Format("End : Result={0}", ProcessOK ? "OK" : "Fail")); + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "StartPaymentProcessing()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + #region Prefix에 의한 사용 Van 정보 조회 + /// + /// Prefix에 의한 사용 Van 정보 조회 + /// + /// + /// + private bool GetPrefixToPayTypeInfo(string sCardNo) + { + bool result = false; + try + { + if (sCardNo.Length == 0) return false; + + // PreFix 검색 + DataTable dtVanInfo = m_cDataCommon.SeletPrefixToPayTypeInfo(sCardNo); + if (dtVanInfo == null || dtVanInfo.Rows.Count <= 0) + { + SendErrLogEvent(ErrorCode.MobileHappyCouponMobileCouponNumberError); + result = false; + } + else + { + DataRow drVanInfo = dtVanInfo.Rows[0]; + + // 결제 그룹 코드 + mPay_DC_Type = CmUtil.GetDataRowStr(drVanInfo, "PAY_DC_GRP_TYPE"); + // 결제 상세 코드 + mPay_DC_CD = CmUtil.GetDataRowStr(drVanInfo, "PAY_DC_CD"); + + result = true; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetPrefixToPayTypeInfo()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = false; + } + return result; + } + #endregion + #region CouponData 처리용 함수 + private MobileCouponType GetMobileCouponType(string _TypeCode) + { + MobileCouponType result = MobileCouponType.Normal; + try + { + switch (_TypeCode) + { + case "0": + result = MobileCouponType.Normal; + break; + case "1": + result = MobileCouponType.NormalValue; + break; + case "2": + result = MobileCouponType.CountLimit; + break; + case "3": + result = MobileCouponType.ValueLimit; + break; + case "4": + result = MobileCouponType.ValueFixed; + break; + default: + result = MobileCouponType.Normal; + break; + } + } + catch + { + result = MobileCouponType.Normal; + } + return result; + } + private string GetStringMobileCouponType(MobileCouponType _Type) + { + string result = "0"; + try + { + switch (_Type) + { + case MobileCouponType.Normal: + result = "0"; + break; + case MobileCouponType.NormalValue: + result = "1"; + break; + case MobileCouponType.CountLimit: + result = "2"; + break; + case MobileCouponType.ValueLimit: + result = "3"; + break; + case MobileCouponType.ValueFixed: + result = "4"; + break; + default: + result = "0"; + break; + } + } + catch + { + result = "0"; + } + return result; + } + private MobileCouponStatusType GetMobileCouponStatusType(string _TypeCode) + { + MobileCouponStatusType result = MobileCouponStatusType.CanNotUse; + try + { + switch (_TypeCode) + { + case "Y": + result = MobileCouponStatusType.CanUse; + break; + case "N": + result = MobileCouponStatusType.CanNotUse; + break; + case "D": + result = MobileCouponStatusType.Used; + break; + case "C": + result = MobileCouponStatusType.Cancel; + break; + case "R": + result = MobileCouponStatusType.Refound; + break; + default: + result = MobileCouponStatusType.CanNotUse; + break; + } + } + catch (Exception) + { + result = MobileCouponStatusType.CanNotUse; + } + return result; + + } + + private string GetNextData(ref int _index) + { + string result = string.Empty; + try + { + _index++; + if (m_aRecvdData.Length > _index) + { + result = m_aRecvdData[_index].Trim(); + } + + } + catch (Exception) + { + result = string.Empty; + } + return result; + } + private bool CouponDataCreate() + { + bool result = false; + try + { + int dataIndex = -1; + if (m_aRecvdData is string[] && m_aRecvdData.Length > 6) + { + if (GetNextData(ref dataIndex).Equals("0")) + { + GetNextData(ref dataIndex); // [1] 버림 + CouponData = new M_MobileCouponReturn + { + Number = GetNextData(ref dataIndex), //[2] + Name = GetNextData(ref dataIndex), //[3] + TotalAmount = CmUtil.LongParse(GetNextData(ref dataIndex)), //[4] + IsOnlyAllUse = GetNextData(ref dataIndex).Equals("1"), //[5] + }; + var virtureCouponCount = CmUtil.LongParse(GetNextData(ref dataIndex)); //[6] + var virtureCoupons = new List(); + for (int iLoop = 0; iLoop < virtureCouponCount; iLoop++) + { + var aVirtureCoupon = new M_MobileCouponDetail + { + Number = GetNextData(ref dataIndex), + Name = GetNextData(ref dataIndex), + BrandCode = GetNextData(ref dataIndex), + BrandName = GetNextData(ref dataIndex), + Type = GetMobileCouponType(GetNextData(ref dataIndex)), + Option = GetNextData(ref dataIndex).Equals("1") + ? MobileCouponOptionType.ItemFixed + : MobileCouponOptionType.None, + ShowPrice = CmUtil.LongParse(GetNextData(ref dataIndex)), + ByePrice = CmUtil.LongParse(GetNextData(ref dataIndex)), + RemainPrice = CmUtil.LongParse(GetNextData(ref dataIndex)), + CanUsingPrice = CmUtil.LongParse(GetNextData(ref dataIndex)), + GroupNo = CmUtil.IntParse(GetNextData(ref dataIndex)), + GroupLimitUsingCount = CmUtil.IntParse(GetNextData(ref dataIndex)), + StartDate = CommonFunction.GetDate(GetNextData(ref dataIndex)), + EndDate = CommonFunction.GetDate(GetNextData(ref dataIndex)), + Status = GetMobileCouponStatusType(GetNextData(ref dataIndex)), + StatusDetail = GetNextData(ref dataIndex), + ItemCodeKey = GetNextData(ref dataIndex), + }; + var itemCount = CmUtil.IntParse(GetNextData(ref dataIndex)); + var itemCodes = new List(); + if (itemCount > 0) + { + for (int iLoop2 = 0; iLoop2 < itemCount; iLoop2++) + { + itemCodes.Add(GetNextData(ref dataIndex)); + } + } + aVirtureCoupon.ItemCodes = itemCodes; + virtureCoupons.Add(aVirtureCoupon); + } + if (virtureCoupons.Where(r => r.Status.Equals(MobileCouponStatusType.CanUse)).Count() > 0) + { + CouponData.VirtureCoupons = virtureCoupons.OrderBy(r => r.Status).ToList(); + result = true; + } + else + { + SendErrLogEvent(ErrorCode.MobileHappyCouponCanUseCouponsIsZero); + CommonLog.ErrorLogWrite(this, "CouponDataCreate()", "Not found useable Coupons", string.Format("{0} : {1}", CouponData.Name, CouponData.Number)); + } + } + else + { + CommonLog.ErrorLogWrite(this, "CouponDataCreate()", "Fail !!", string.Format("{0}={1}", m_aRecvdData[0].Trim(), m_aRecvdData[1].Trim())); + } + } + else + { + CommonLog.ErrorLogWrite(this, "CouponDataCreate()", "Recive Data Length Fail !!"); + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "CouponDataCreate()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = false; + } + return result; + + } + + #endregion + /// + /// 조회 처리 + /// + /// + private void SearchTxtInPut(string _inputString, double _payments) + { + string sCoponinfo = ""; + string sInPutType = ""; + string sInPutData = ""; + string sInEncData = ""; + try + { + CommonLog.DebugLogWrite(this, "SearchTxtInPut()", "Start"); + + // 중복체크 + //if (DataGridSetting(4, ref aRet, ref aRet2, ref aRet3) != UserCom.RST_OK) return sRet; + var sSearchType = PosConst.POS_INQ_MODE.SEARCH; + sInPutType = m_sInPutType; + sInPutData = m_sInPutData; + sInEncData = m_sInEncData; + if (m_sInEncData == "") + { + if (m_sInPutData == "") + { + sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN_CP; + sInPutData = _inputString; + } + } + m_aRecvdData = null; + var sRet = m_cMobileCoupon.SearchPayment(new string[] { m_sPosMenuKey, sInPutType, sInPutData, sInPutData, _payments.ToString(), "", "", "", mPay_DC_Type, mPay_DC_CD, sSearchType, sCoponinfo }, ref m_aRecvdData); + if (sRet != UserCom.RST_OK) + { + InDataToZeroFill(); + if (sRet == null || sRet.Equals(UserCom.RST_ERR)) + { + SendErrLogEvent(ErrorCode.MobileHappyCouponUnknownError); + } + else + { + SendErrorMessageEvent(sRet); + } + + } + else + { + m_bSearchSuccess = CouponDataCreate(); + + } + CommonLog.DebugLogWrite(this, "SearchTxtInPut()", string.Format("End : Result={0}", sRet)); + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "SearchTxtInPut()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + /// + /// 사용 승인 처리 + /// + /// + private void CompleteTxtInPut() + { + CommonLog.DebugLogWrite(this, "CompleteTxtInPut()", "Start"); + string sProductiTem = string.Empty; + string sRet = UserCom.RST_ERR; + try + { + m_bSearchSuccess = false; + var sSendData = new StringBuilder(); + var sCounponIfo = new StringBuilder(); + bool biTemCheck = false; + // 상품정보 + ArrayList aSaleItem = (ArrayList)StateObject.GetItemObject(Column.TR_PLU.ITEM); + + m_aSaleItem = new ArrayList(); + for (int iRow = 0; iRow < aSaleItem.Count; iRow++) + { + Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)aSaleItem[iRow]; + m_aSaleItem.Add(cSaleItem.Clone()); + } + var checkOK = true; + sSendData.Append(CmUtil.MidH(CouponData.VirtureCoupons.Where(r => r.Status.Equals(MobileCouponStatusType.CanUse)).Sum(r2=>r2.DiscountPrice).ToString(), 0, 10)); + sSendData.Append(CmUtil.MidH(CouponData.VirtureCoupons.Where(r =>r.Status.Equals(MobileCouponStatusType.CanUse)).Count().ToString(), 0, 5)); + foreach (var aCoupon in CouponData.VirtureCoupons) + { + if (aCoupon.DiscountPrice > 0) + { + if (CouponData.IsOnlyAllUse) + { + var checkGrooup = aCoupon.GroupNo; + var groupItemCount = CouponData.VirtureCoupons.Where(r => r.GroupNo.Equals(checkGrooup) + && r.Status.Equals(MobileCouponStatusType.CanUse)).Count(); + var usingIgtemCount = CouponData.VirtureCoupons.Where(r => r.GroupNo.Equals(checkGrooup) && r.RequestPrice > 0 + && r.Status.Equals(MobileCouponStatusType.CanUse)).Count(); + if (usingIgtemCount < groupItemCount) + { + SendErrorMessageEvent(POS_MESSAGE.ERROR.MSG_0410); + checkOK = false; + break; + } + } + + if (!string.IsNullOrEmpty(aCoupon.ItemCodeKey) + && (aCoupon.Type.Equals(MobileCouponType.Normal) + || aCoupon.Type.Equals(MobileCouponType.CountLimit) + || aCoupon.Type.Equals(MobileCouponType.ValueFixed) + )) + { + sRet = GetDCItemAmount(aCoupon.ItemCodeKey + , CouponData.Number + , aCoupon.Number + , m_cDataService.DoubleParse(aCoupon.DiscountPrice.ToString()) + , aCoupon.Option.Equals(MobileCouponOptionType.ItemFixed) ? "1" : "0", ref sProductiTem); + if (sRet != UserCom.RST_OK && aCoupon.Option.Equals(MobileCouponOptionType.ItemFixed)) + { + SendErrorMessageEvent(sRet); + checkOK = false; + break; + } + } + sSendData.Append(CmUtil.MidH(CouponData.Number, 0, 32)); //쿠폰번호 + sSendData.Append(CmUtil.MidH(aCoupon.Number, 0, 32)); //가상쿠폰번호 + sSendData.Append(CmUtil.MidH(aCoupon.DiscountPrice.ToString(), 0, 10)); //사용금액 + + sCounponIfo.Append(CmUtil.MidH(CouponData.Number, 0, 32)); //쿠폰번호 + sCounponIfo.Append("|"); + sCounponIfo.Append(CmUtil.MidH(aCoupon.Number, 0, 32)); //가상쿠폰번호 + sCounponIfo.Append("|"); + sCounponIfo.Append(GetStringMobileCouponType(aCoupon.Type)); //쿠폰종류 + sCounponIfo.Append("@~"); + if (aCoupon.Option.Equals(MobileCouponOptionType.ItemFixed)) biTemCheck = true; + } + } + if (checkOK) + { + if (biTemCheck == true) + { + sSendData.Append(CmUtil.MidH(m_aSaleItem.Count.ToString(), 0, 5)); // POS 상품갯수 + for (int iRow = 0; iRow < m_aSaleItem.Count; iRow++) + { + Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)m_aSaleItem[iRow]; + + if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue;// 지정취소 + + sSendData.Append(CmUtil.MidH(cSaleItem.ITEM_PLU_CD, 0, 32)); // POS 상품코드 + // 전문 설정 오류 수정(2017.05.22) + sSendData.Append(CmUtil.MidH(cSaleItem.SALE_AMT.ToString(), 0, 10)); // POS 상품금액 + //sSendData += m_cDataService.DoubleParse(CmUtil.MidH(cSaleItem.SALE_AMT.ToString(), 0, 10)); // POS 상품금액 + } + } + else + { + sSendData.Append(CmUtil.MidH("0", 0, 5)); // POS 상품갯수 + } + string sInPutType = m_sInPutType; + string sInPutData = m_sInPutData; + string sInEncData = m_sInEncData; + if (m_sInEncData == "") + { + if (m_sInPutData == "") + { + sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN_CP; + sInPutData = CouponData.Number; + + } + } + // 승인 처리 + sRet = m_cMobileCoupon.SetPayment(new string[] { m_sPosMenuKey, sInPutType, sInPutData, sInPutData, "0", "", "", "", mPay_DC_Type, mPay_DC_CD, sSendData.ToString(), sCounponIfo.ToString(), sProductiTem }); + if (sRet != UserCom.RST_OK) + { + InDataToZeroFill(); + if (sRet == null || sRet.Equals(UserCom.RST_ERR)) + { + SendErrLogEvent(ErrorCode.MobileHappyCouponUnknownError); + } + else + { + SendErrorMessageEvent(sRet); + } + } + else + { + CouponData.TotalUseAmount = CouponData.VirtureCoupons.Where(r => r.Status.Equals(MobileCouponStatusType.CanUse)).Sum(r2 => r2.DiscountPrice); + foreach (var aCoupon in CouponData.VirtureCoupons) + { + if (aCoupon.DiscountPrice > 0) aCoupon.PaySEQ = FindPaySEQ(aCoupon.Number); + } + m_bSearchSuccess = true; + } + } + sSendData.Remove(0, sSendData.Length); + sCounponIfo.Remove(0, sCounponIfo.Length); + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "CompleteTxtInPut()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + CommonLog.DebugLogWrite(this, "CompleteTxtInPut()", "End"); + } + private long FindPaySEQ(string _virtureCouponNo) + { + var result = -1L; + try + { + var alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM); + foreach (var aitem in alPayItem) + { + if (aitem is Column.TR_PAYMENT.DATA aPayTem) + { + if (aPayTem.PAY_WAY_CD.Trim().Equals(mPay_DC_Type) + && aPayTem.PAY_DTL_CD_01.Trim().Equals(mPay_DC_CD) + && aPayTem.OCCUR_ENTRY_09.Trim().Equals(_virtureCouponNo)) + { + result = aPayTem.SEQ; + break; + } + } + } + + } + catch + { + result = -1L; + } + return result; + } + #region ProductID로 등록된 상품 체크 + /// + /// ProductID로 등록된 상품 체크 + /// + /// + /// + /// + /// + /// + /// + public string GetDCItemAmount(string sProductID, string sCouponNo, string sVCouponNo, double nPayAmt, string sItemChgUse, ref string siTemCheck) + { + string sRet = UserCom.RST_ERR; + + double niTemSum = 0; + double nQty = 0; + int iMaxIndex = -1; + + try + { + // 프로덕트 id 없으면 Skip + if (sProductID.Trim().Length <= 0) return sRet; + + // 쿠폰 List 조회 + DataTable dtMemu = m_cDataCommon.SeletProductIDToItemCD(sProductID); + if (dtMemu == null || dtMemu.Rows.Count <= 0) + { + //WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0149); + return UserCom.RST_OK; + } + + ITEM_PLU_CHECK iTemCheck = new ITEM_PLU_CHECK(); + + if (m_aSaleItem.Count <= 0) + { + return POS_MESSAGE.ERROR.MSG_0149; + } + + foreach (DataRow dr in dtMemu.Rows) + { + // Product ID로 결제구분을 재설정한다. + string sDC_Type = CmUtil.GetDataRowStr(dr, "PAY_DC_GRP_TYPE").Trim(); + if (sDC_Type.Trim().Length > 0) mPay_DC_Type = sDC_Type.Trim(); + + // Product ID로 결제상세코드를 재설정한다. + string sDC_CD = CmUtil.GetDataRowStr(dr, "PAY_DC_CD").Trim(); + if (sDC_Type.Trim().Length > 0) mPay_DC_CD = sDC_CD.Trim(); + + for (int iRow = 0; iRow < m_aSaleItem.Count; iRow++) + { + Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)m_aSaleItem[iRow]; + + if (cSaleItem.CANCEL_DIV == PosConst.CANCEL_DIV.CANCEL || cSaleItem.CANCEL_DIV_MAIN == PosConst.CANCEL_DIV.CANCEL) continue;// 지정취소 + if (cSaleItem.DC_DIV == ItemConst.PLU_DC_DIV.FREE) continue; // 서비스(무료) + if (cSaleItem.NONSALES_RSN_CD != "0") continue; // 비매출구분 + if (cSaleItem.BILLSPR_NO != m_cTrnStatus.Sale.BillSplitNo) continue; // 빌분리번호 + if (cSaleItem.BILL_AMT <= 0) continue; // 영수금액 + //if (cSaleItem.DC_PRMT_YN != "0") continue; // 할인가능 여부 + + if (CmUtil.GetDataRowStr(dr, "ITEM_CHECK_YN") == "1") + { + // 등록된 상품과 쿠폰마스터 상품 체크용 저장 + if (CmUtil.GetDataRowStr(dr, "ITEM_CD") == cSaleItem.ITEM_PLU_CD) + { + // 할인 대상 iTemCD/수량 체크용 저장 + nQty = CmUtil.GetDataRowDouble(dr, "QTY"); + + // 할인금액+결제요금액 보다 상품판매금액이 같거나 큰 경우만 + if (nQty > 0 && cSaleItem.SALE_QTY > 0 && cSaleItem.BILL_AMT >= nPayAmt + CmUtil.GetDataRowDouble(dr, "DC_AMT")) + { + // 제일 큰 금액에 설정 + if (iTemCheck.SALE_PRC == 0 || iTemCheck.SALE_PRC < cSaleItem.SALE_PRC) + { + iMaxIndex = iRow; + + iTemCheck.sCouponNo = sCouponNo.Trim(); + iTemCheck.sVCouponNo = sVCouponNo.Trim(); + iTemCheck.sProductID = CmUtil.GetDataRowStr(dr, "PRODUCT_CD").Trim(); + iTemCheck.iTemCD = cSaleItem.ITEM_PLU_CD; + iTemCheck.SALE_PRC = cSaleItem.SALE_PRC; + iTemCheck.SaleAmt = cSaleItem.BILL_AMT; + iTemCheck.PayAmt = nPayAmt; + iTemCheck.DCAmt = CmUtil.GetDataRowDouble(dr, "DC_AMT"); + + // 대상 금액 sum + niTemSum = CmUtil.DoubleAdd(CmUtil.GetDataRowDouble(dr, "DC_AMT"), nPayAmt); + } + } + } + } + else + { + nQty = CmUtil.GetDataRowDouble(dr, "QTY"); + + // 프로덕트 코드 미설정 오류로 인한 수정(2017.05.18) + //if (nQty > 0 && cSaleItem.SALE_QTY > 0 && cSaleItem.BILL_AMT >= nPayAmt + CmUtil.GetDataRowDouble(dr, "DC_AMT")) + //{ + // 제일 큰 금액에 설정 + if (iTemCheck.SALE_PRC == 0 || iTemCheck.SALE_PRC < cSaleItem.SALE_PRC) + { + iMaxIndex = iRow; + + iTemCheck.sCouponNo = sCouponNo.Trim(); + iTemCheck.sVCouponNo = sVCouponNo.Trim(); + iTemCheck.sProductID = CmUtil.GetDataRowStr(dr, "PRODUCT_CD").Trim(); + iTemCheck.iTemCD = cSaleItem.ITEM_PLU_CD; + iTemCheck.SALE_PRC = cSaleItem.SALE_PRC; + iTemCheck.SaleAmt = cSaleItem.BILL_AMT; + iTemCheck.PayAmt = nPayAmt; + iTemCheck.DCAmt = CmUtil.GetDataRowDouble(dr, "DC_AMT"); + + // 대상 금액 sum + niTemSum = CmUtil.DoubleAdd(CmUtil.GetDataRowDouble(dr, "DC_AMT"), nPayAmt); + } + //} + } + } + } + + // 적용 상품의 상품금액 변경 + if (iMaxIndex > -1) + { + Column.TR_PLU.DATA cSaleItem = (Column.TR_PLU.DATA)m_aSaleItem[iMaxIndex]; + + cSaleItem.CPN_DC_DIV = mPay_DC_Type + mPay_DC_CD; + cSaleItem.CPN_DC_AMT = CmUtil.DoubleAdd(cSaleItem.CPN_DC_AMT, iTemCheck.DCAmt); + cSaleItem.BILL_AMT = CmUtil.DoubleSubtraction(cSaleItem.BILL_AMT, iTemCheck.DCAmt); + } + + //// 구매수량 체크 + //for (int index = 0; index < m_aSaleItem.Count; index++) + //{ + // if (iTemCheck.iTemCD != "") + // { + // if (iTemCheck.T_Qty >= 0 && iTemCheck.S_Qty != 0) + // { + // WinManager.ErrorMessage(POS_MESSAGE.ERROR.MSG_0160); + // return sRet; + // } + // } + //} + + // 금액 체크 + if (niTemSum > Payments) + { + return POS_MESSAGE.ERROR.MSG_0160; + } + + // 가능한 상품 미존재시 && 타상품 교환 불가시 + if (niTemSum <= 0 && sItemChgUse == "1") + { + return POS_MESSAGE.ERROR.MSG_0160; + } + + // 프로덕트 정보 체크용 + if (!string.IsNullOrEmpty(iTemCheck.sCouponNo) && iTemCheck.sCouponNo.Trim() != "") + { + siTemCheck += iTemCheck.sCouponNo; + siTemCheck += "!~"; + siTemCheck += iTemCheck.sVCouponNo; + siTemCheck += "!~"; + siTemCheck += iTemCheck.sProductID; + siTemCheck += "!~"; + siTemCheck += iTemCheck.iTemCD; + siTemCheck += "!~"; + siTemCheck += iTemCheck.PayAmt; + siTemCheck += "!~"; + siTemCheck += iTemCheck.DCAmt; + siTemCheck += "$~"; + } + + sRet = UserCom.RST_OK; + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetDCItemAmount()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + return sRet; + } + #endregion + + #region 여전법 대응 + /// + /// ZeroFill 초기화 + /// + private void InDataToZeroFill() + { + try + { + + //여전법 대응! + ////////////////////////////////////////////////////////////////////////////////// + CmUtil.ZeroFillClear(ref m_sInPutData); + CmUtil.ZeroFillClear(ref m_sInEncData); + CmUtil.ZeroFillClear(ref m_sInMaskData); + ////////////////////////////////////////////////////////////////////////////////// + } + catch + { + } + + } + #endregion 여전법 대응 + + private void SendErrorMessageEvent(string _errorMessageString) + { + try + { + CommonLog.ErrorLogWrite(this, "SendErrorMessageEvent()", _errorMessageString); + ErrorMessageEvent(_errorMessageString); + } + catch + { + } + } + private void SendErrLogEvent(ErrorCode _errorCode) + { + try + { + CommonLog.DebugLogWrite(this, "SendErrLogEvent()", _errorCode.ToString()); + ErrorEvent(_errorCode); + } + catch + { + + } + } + private void SendReadStart() + { + try + { + CommonLog.DebugLogWrite(this, "SendReadStart()"); + ReadStart(this); + } + catch + { + + } + } + private void SendReadEnd() + { + try + { + CommonLog.DebugLogWrite(this, "SendReadEnd()"); + ReadEnd(this); + } + catch + { + + } + } + private void ClearCardInfo() + { + try + { + m_sInPutType = ""; // 입력구분 + m_sInPutData = ""; // 입력데이터 + m_sInMaskData = ""; // 마스킹 + m_sInEncData = ""; // 카드데이터 + m_sServiceCode = ""; // 서비스코드 + m_sAppCardNo = ""; // 승인카드번호 + + + m_bSearchSuccess = false; + } + catch + { + } + } + #endregion + + + + + } +} \ No newline at end of file diff --git a/Kiosk/Payments/SPC.Kiosk.Payments/posOkCashBag.cs b/Kiosk/Payments/SPC.Kiosk.Payments/posOkCashBag.cs new file mode 100644 index 0000000..952a773 --- /dev/null +++ b/Kiosk/Payments/SPC.Kiosk.Payments/posOkCashBag.cs @@ -0,0 +1,672 @@ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; +using Cosmos.CommonManager; +using System.Threading; +using SPC.Kiosk.Common; +namespace SPC.Kiosk.Payments +{ + public class posOkCashBag : IDisposable + { + #region [ Members ] + /// + /// OkCashBagCertify Error Code + /// + public enum ErrorCode + { + OkCashBagCertifyMobilePhoneNumberError, + OkCashBagCertifyMobileCardNumberError, + OkCashBagCertifyMemInfoEncryptedCardNoError, + OkCashBagCertifyEncrtipError, + OkCashBagCertifyNotInitailzedError, + OkCashBagCertifyProcessingTimeOut, + OkCashBagUnknownError + } + /// + /// ErrorMessage Event + /// + /// 반환 로그 + public delegate void ErrorMessageEventHandler(string ErrorString); + /// + /// 로그메세지 이벤트 반환용 + /// + public event ErrorMessageEventHandler ErrorMessageEvent; + /// + /// Error 반환 Event + /// + /// 반환 Error Code + public delegate void LogErrorHandler(ErrorCode errorCode); + /// + /// Error Code 이벤트 반환용 + /// + public event LogErrorHandler ErrorEvent; + /// + /// IcReadStart Event + /// + /// + public delegate void IcReadStart(object sender); + /// + /// IcReadStart Event 반환용 + /// + public event IcReadStart ReadStart; + /// + /// IcReadStart Event + /// + /// + public delegate void IcReadEnd(object sender); + /// + /// IcReadStart Event 반환용 + /// + public event IcReadEnd ReadEnd; + + private SManager sManager = null; // 이 객체를 통해 업무 Service 호출 + private StateServer StateObject = null; // StateObject : StateServer Object (객체) + private PosStatus m_cPosStatus = null; // 기본정보 참조 + private TranStatus m_cTrnStatus = null; // 거래정보 참조 + private DeviceStatus m_cDevStatus = null; // 디바이스 관리 + private PosOLEDevice.DelegateIcReader delegateReader; // IC리더 콜백 + private IICReaderUs m_cDeviceICReader = null; + private IPaymentExpUs m_cPntOcbSave = null; + + /// + /// 입력구분 + /// + private string m_sInPutType = ""; + /// + /// 입력데이터 + /// + private string m_sInPutData = ""; + /// + /// 마스킹데이터 + /// + private string m_sInMaskData = ""; + /// + /// 카드데이터(암호화) + /// + private string m_sInEncData = ""; + /// + /// 서비스코드 + /// + private string m_sServiceCode = ""; + /// + /// 조회 성공 여부 + /// + private bool m_bSearchSuccess = false; + /// + /// POS 초기화 필요 유무 + /// + public bool NeedInitModule { get; set; } + /// + /// 승인 수단 + /// + public string CertifyKey { get; set; } = string.Empty; + private bool icCallBack = false; + /// + /// Ic Reader CallBack Switch + /// + public bool IcCallBack + { + get { return icCallBack; } + set + { + if (value) + { + m_cDeviceICReader.RegIcCallback(delegateReader); + } + icCallBack = value; + } + } + /// + /// 마스크된 회원성명 + /// + public string MemberName { get; protected set; } = string.Empty; + /// + /// 적립 가능 유무 + /// + public bool CanReservePoint { get; protected set; } + /// + /// 회원 가용 Point + /// + public double MemberPoint { get; protected set; } = 0d; + /// + /// Point 사용시 비번 필요 유무 + /// + public bool NeedPassword { get; protected set; } + public string ApprovalNo { get; protected set; } = string.Empty; + public string ApprovalDate { get; protected set; } = string.Empty; + /// + /// 인증 처리 성공 유무 + /// + public bool ProcessOK + { + get { return m_bSearchSuccess; } + } + /// + /// Processing Timeout + /// + public bool IsTimeout + { + set + { + if (value) + { + ErrorEvent(ErrorCode.OkCashBagCertifyProcessingTimeOut); + } + } + } + #endregion + + #region [ Ctor && Dispose ] + /// + /// Ctor + /// + public posOkCashBag() + { + try + { + sManager = new SManager(); + StateObject = (StateServer)StateServer.GetInstance(); + NeedInitModule = StateObject.POS == null + || StateObject.TRAN == null + || StateObject.DEVICE == null; + if (!NeedInitModule) + { + m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 + m_cTrnStatus = (TranStatus)StateObject.TRAN; // POS 거래정보 + m_cDevStatus = (DeviceStatus)StateObject.DEVICE; + m_cDeviceICReader = (IICReaderUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_ICREADER); + m_cPntOcbSave = (IPaymentExpUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.PNT_OCB_SAVE); + delegateReader = new PosOLEDevice.DelegateIcReader(OnIcReaderCallBack); // IC리더 콜백 + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "Ctor", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// + /// + public void Dispose() + { + + try + { + InDataToZeroFill(); + + sManager = null; + StateObject = null; + m_cPosStatus = null; // POS 기본정보 + m_cTrnStatus = null; // POS 거래정보 + m_cDevStatus = null; + + m_cDeviceICReader = null; + m_cPntOcbSave = null; + delegateReader = null; // IC리더 콜백 + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "Dispose", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + #endregion + + #region [ Methods ] + /// + /// HappyPoint 회원 조회 (16 자리이면 Mobile BarCode, 그외는 전화 번호) + /// + /// + public void StartCertifyProcessing(string _inputString) + { + try + { + CommonLog.InfoLogWrite(this, "StartCertifyProcessing()", "Start"); + SendReadStart(); + if (NeedInitModule) + { + Thread.Sleep(1000); //진행창 보이기 위한 딜레이 + ErrorEvent(ErrorCode.OkCashBagCertifyNotInitailzedError); + } + else + { + var startPorcess = false; + if (_inputString.Length.Equals(16)) + { + // Mobile BarCode + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN; + m_sInMaskData = _inputString; + m_sInPutData = _inputString + "="; + startPorcess = true; + } + else + { + // 전화 번호 + if (IsCellularPhoneNumber(_inputString)) + { + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_KEYIN; + m_sInMaskData = m_sInPutData = _inputString; + startPorcess = true; + + } + else + { + SendErrLogEvent(ErrorCode.OkCashBagCertifyMobilePhoneNumberError); + } + } + //조회 전문 처리 + if (startPorcess) + { + if (EncryptedCardNo(m_sInPutData, ref m_sInMaskData, ref m_sInEncData)) + { + SearchTxtInPut(); + } + else + { + SendErrLogEvent(ErrorCode.OkCashBagCertifyEncrtipError); + } + } + } + SendReadEnd(); + CommonLog.InfoLogWrite(this, "StartCertifyProcessing()", string.Format("End : Result={0}", ProcessOK ? "OK" : "Fail")); + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "StartCertifyProcessing()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// 휴대폰 번호 형식 확인 + /// + /// + /// + private bool IsCellularPhoneNumber(string sInputData) + { + bool bRet = false; + try + { + if (sInputData.Length == 10 || sInputData.Length == 11) + { + if (sInputData.StartsWith("010") == true || sInputData.StartsWith("011") == true || sInputData.StartsWith("017") == true || + sInputData.StartsWith("016") == true || sInputData.StartsWith("018") == true || sInputData.StartsWith("019") == true) + { + bRet = true; + } + } + } + catch + { + bRet = false; + } + return bRet; + } + /// + /// OK CashBag 조회 전문 처리 + /// + private void SearchTxtInPut() + { + CommonLog.DebugLogWrite(this, "SearchTxtInPut()", "Start"); + string sRet = UserCom.RST_ERR; + try + { + + m_bSearchSuccess = false; + + + // 조회 + string[] saRecvdData = null; + sRet = m_cPntOcbSave.SearchPayment(new string[] { m_sInPutType, m_sInMaskData, m_sInEncData, "0"}, ref saRecvdData); + if (sRet != UserCom.RST_OK) + { + CertifyKey = string.Empty; + InDataToZeroFill(); + if (sRet == null || sRet.Equals(UserCom.RST_ERR)) + { + SendErrLogEvent(ErrorCode.OkCashBagUnknownError); + } + else + { + SendErrorMessageEvent(sRet); + } + } + else + { + CertifyKey = m_sInPutData; + var cEtcItem = (Column.TR_ETC.DATA)m_cPntOcbSave.GetPayment(new string[] { }); + + NeedPassword = true; + MemberPoint = cEtcItem.AMT_ENTRY_04; + + m_bSearchSuccess = true; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "SearchTxtInPut()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + CommonLog.DebugLogWrite(this, "SearchTxtInPut()", "End"); + + } + /// + /// 카드 번호 암호화 + /// + /// + /// + /// + /// + private bool EncryptedCardNo(string sInData, ref string sInMaskData, ref string sInEncData) + { + string sEncData = sInData; + bool bRet = false; + try + { + + //#20170913 현금영수증, 포인트카드 마스킹 미적용 start + // "0"인 경우 마스킹 미처리 + //기존 + //sEncData = m_cDeviceICReader.GetEncryptedCardNo(sInData).Trim(); + //변경 + sEncData = m_cDeviceICReader.GetEncryptedCardNo(sInData, "0").Trim(); + //#20170913 현금영수증, 포인트카드 마스킹 미적용 end + + if (CmUtil.MidH(sEncData, 0, 2) == "00") + { + sInEncData = CmUtil.MidH(sEncData, 2, 512).Trim(); // 암호화 데이터 + sInMaskData = CmUtil.MidH(sEncData, 514, sEncData.Length - 514).Trim(); // 마스킹 데이터 + + //#20170913 현금영수증, 포인트카드 마스킹 미적용 start + sInMaskData = CmUtil.MidH(sInMaskData, 0, 6) + "********"; + //#20170913 현금영수증, 포인트카드 마스킹 미적용 end + + bRet = true; + } + else + { + CommonLog.ErrorLogWrite(this, "EncryptedCardNo()", "Fail !!"); + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "EncryptedCardNo()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + return bRet; + } + #region DeviceEvent 관련 + + + /// + /// IC 카드 정보 입력 처리 + /// + /// + private bool GetIcCardData() + { + string sRsvStr = ""; + try + { + //IcCallBack = false; // IC리더 콜백 해지 + + ClearCardInfo(); // 카드 입력 정보 클리어 + + if (m_cDeviceICReader.GetCardInfo_ICReader(PosConst.IC_READER_TRAN_TYPE.POINT, 0, ref sRsvStr) == true) + { + if (CmUtil.MidH(sRsvStr, 0, 2) == "00") + { + m_sInEncData = CmUtil.MidH(sRsvStr, 6, 512).Trim(); + m_sInMaskData = CmUtil.MidH(sRsvStr, 1030, 37).Trim(); + m_sServiceCode = CmUtil.MidH(sRsvStr, 1067, 5).Trim(); + + m_sInPutData = m_sInMaskData; + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP; + + + + return true; + } + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetIcCardData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + // 여전법 대응//////////////////////////////////////////////////////////////////// + CmUtil.ZeroFillClear(ref sRsvStr); + ////////////////////////////////////////////////////////////////////////////////// + } + return false; + } + + /// + /// RF 카드 정보 입력 처리 + /// + /// + private bool GetRfCardData() + { + string sRsvStr = ""; + try + { + //IcCallBack = false; // IC리더 콜백 해지 + ClearCardInfo(); // 카드 입력 정보 클리어 + + //카드 정보 입력 + if (m_cDeviceICReader.GetRfCreditCardInfo("1", m_cTrnStatus.Head.NetSaleAmt.ToString(), "", "", "", ref sRsvStr) == false) + { + if (sRsvStr != "") SendErrorMessageEvent(sRsvStr); + return false; + } + + m_sInEncData = CmUtil.MidH(sRsvStr, 2, 512).Trim(); + m_sInMaskData = CmUtil.MidH(sRsvStr, 514, 40).Trim(); + m_sServiceCode = CmUtil.MidH(sRsvStr, 554, 5).Trim(); + + m_sInPutData = m_sInMaskData; + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF; + + //ReadBarCode= m_sInPutData.Length > 16 ? CmUtil.MidH(m_sInPutData, 0, 16) : m_sInPutData; + //return true; + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetRfCardData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + // 여전법 대응//////////////////////////////////////////////////////////////////// + CmUtil.ZeroFillClear(ref sRsvStr); + ////////////////////////////////////////////////////////////////////////////////// + } + return false; + } + + /// + /// POP 카드 정보 입력 처리 + /// + /// + private bool GetPopCardData() + { + string sRsvStr = ""; + try + { + //IcCallBack = false; // IC리더 콜백 해지 + + ClearCardInfo(); // 카드 입력 정보 클리어 + + if (m_cDeviceICReader.RfPrepaidCardInfo(ref sRsvStr) == false) + { + if (sRsvStr != "") SendErrorMessageEvent(sRsvStr); + return false; + } + if (sRsvStr.StartsWith("T") == true) + { + m_sInPutData = sRsvStr.Substring(7, 16).Trim(); + } + else if (sRsvStr.StartsWith("E") == true) + { + m_sInPutData = sRsvStr.Substring(1, 20).Trim(); + } + else + { + return false; + } + + bool bRet = EncryptedCardNo(m_sInPutData, ref m_sInMaskData, ref m_sInEncData); + if (bRet == true) + { + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_RF; + } + return bRet; + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetPopCardData()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + // 여전법 대응//////////////////////////////////////////////////////////////////// + CmUtil.ZeroFillClear(ref sRsvStr); + ////////////////////////////////////////////////////////////////////////////////// + } + return false; + } + #endregion + + #region 여전법 대응 + /// + /// ZeroFill 초기화 + /// + private void InDataToZeroFill() + { + try + { + + //여전법 대응! + ////////////////////////////////////////////////////////////////////////////////// + CmUtil.ZeroFillClear(ref m_sInPutData); + CmUtil.ZeroFillClear(ref m_sInEncData); + CmUtil.ZeroFillClear(ref m_sInMaskData); + ////////////////////////////////////////////////////////////////////////////////// + } + catch + { + } + + } + #endregion 여전법 대응 + + #region IC리더 콜백 + //delegate void DelegateIcReaderCallBack(int rc, StringBuilder str); + /// + /// IC리더 콜백 함수 + /// + /// + /// + public void OnIcReaderCallBack(int num, StringBuilder str) + { + try + { + SendReadStart(); + if (num == 1) + { + GetIcCardData(); + } + else + { + if (str.ToString().StartsWith("EN")) + { + ClearCardInfo(); // 카드 입력 정보 클리어 + + m_sInEncData = CmUtil.MidH(str.ToString(), 0, 512).Trim(); + m_sInMaskData = CmUtil.MidH(str.ToString(), 512, 40).Trim(); + m_sInPutData = m_sInMaskData; + m_sInPutType = PosConst.POS_VAN_MASTER.INPUT_TYPE.VAN_SWIP; + } + } + if (!string.IsNullOrEmpty(m_sInPutData)) SearchTxtInPut(); + SendReadEnd(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OnIcReaderCallBack()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + #endregion + private void SendErrorMessageEvent(string _errorMessageString) + { + try + { + CommonLog.ErrorLogWrite(this, "SendErrorMessageEvent()", _errorMessageString); + ErrorMessageEvent(_errorMessageString); + } + catch + { + } + } + private void SendErrLogEvent(ErrorCode _errorCode) + { + try + { + CommonLog.DebugLogWrite(this, "SendErrLogEvent()", _errorCode.ToString()); + ErrorEvent(_errorCode); + } + catch + { + + } + } + private void SendReadStart() + { + try + { + CommonLog.DebugLogWrite(this, "SendReadStart()"); + ReadStart(this); + } + catch + { + + } + } + private void SendReadEnd() + { + try + { + CommonLog.DebugLogWrite(this, "SendReadEnd()"); + ReadEnd(this); + } + catch + { + + } + } + private void ClearCardInfo() + { + try + { + m_sInPutType = ""; // 입력구분 + m_sInPutData = ""; // 입력데이터 + m_sInMaskData = ""; // 마스킹 + m_sInEncData = ""; // 카드데이터인카드번호 + + + m_bSearchSuccess = false; + } + catch + { + } + } + #endregion + + + + + } +} \ No newline at end of file diff --git a/Kiosk/Payments/SPC.Kiosk.Payments/posPaymentsCancel.cs b/Kiosk/Payments/SPC.Kiosk.Payments/posPaymentsCancel.cs new file mode 100644 index 0000000..23de86f --- /dev/null +++ b/Kiosk/Payments/SPC.Kiosk.Payments/posPaymentsCancel.cs @@ -0,0 +1,327 @@ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using Cosmos.BaseFrame; +using Cosmos.UserFrame; +using Cosmos.ServiceProvider; +using Cosmos.Common; +using Cosmos.CommonManager; +using System.Threading; +using System.Collections; +using SPC.Kiosk.Common; +namespace SPC.Kiosk.Payments +{ + /// + /// POS HappyPoint Approval Process + /// + public class posPaymentsCancel : IDisposable + { + #region [ Members ] + /// + /// HappyPointCertify ErrorCode + /// + public enum ErrorCode + { + posPaymentsCancelNotInitailzedError, + posPaymentsCancelProcessingTimeOut, + posPaymentsCancelPaymentSEQError, + posPaymentsCancelCanceledItemError, + posPaymentsCancelNotFoundError, + posPaymentsCancelUnknownError, + } + /// + /// ErrorMessage Event + /// + /// 반환 로그 + public delegate void ErrorMessageEventHandler(string ErrorString); + /// + /// 로그메세지 이벤트 반환용 + /// + public event ErrorMessageEventHandler ErrorMessageEvent; + /// + /// Error 반환 Event + /// + /// 반환 Error Code + public delegate void LogErrorHandler(ErrorCode errorCode); + /// + /// Error Code 이벤트 반환용 + /// + public event LogErrorHandler ErrorEvent; + /// + /// IcReadStart Event + /// + /// + public delegate void IcReadStart(object sender); + /// + /// IcReadStart Event 반환용 + /// + public event IcReadStart ReadStart; + /// + /// IcReadStart Event + /// + /// + public delegate void IcReadEnd(object sender); + /// + /// IcReadStart Event 반환용 + /// + public event IcReadEnd ReadEnd; + + private SManager sManager = null; // 이 객체를 통해 업무 Service 호출 + private StateServer StateObject = null; // StateObject : StateServer Object (객체) + private PosStatus m_cPosStatus = null; // 기본정보 참조 + private TranStatus m_cTrnStatus = null; // 거래정보 참조 + private DeviceStatus m_cDevStatus = null; // 디바이스 관리 + private IPaymentUs m_cPayCancel = null; + + + /// + /// 성공 여부 + /// + private bool m_bSearchSuccess = false; + /// + /// POS 초기화 필요 유무 + /// + public bool NeedInitModule { get; set; } + /// + /// 승인 수단 + /// + public string CertifyKey { get; set; } = string.Empty; + public long PaySEQ { get; protected set; } + /// + /// 인증 처리 성공 유무 + /// + public bool ProcessOK + { + get { return m_bSearchSuccess; } + } + /// + /// Processing TimeOut + /// + public bool IsTimeout + { + set + { + if (value) + { + ErrorEvent(ErrorCode.posPaymentsCancelProcessingTimeOut); + } + } + } + #endregion + + #region [ Ctor && Dispose ] + /// + /// Ctor + /// + public posPaymentsCancel() + { + try + { + sManager = new SManager(); + StateObject = (StateServer)StateServer.GetInstance(); + NeedInitModule = StateObject.POS == null + || StateObject.TRAN == null + || StateObject.DEVICE == null; + if (!NeedInitModule) + { + m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 + m_cTrnStatus = (TranStatus)StateObject.TRAN; // POS 거래정보 + m_cDevStatus = (DeviceStatus)StateObject.DEVICE; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "Ctor", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// + /// + public void Dispose() + { + try + { + + sManager = null; + StateObject = null; + m_cPosStatus = null; // POS 기본정보 + m_cTrnStatus = null; // POS 거래정보 + m_cDevStatus = null; + + m_cPayCancel = null; + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "Dispose", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + #endregion + + #region [ Methods ] + /// + /// HappyPoint 회원 조회 (16 자리이면 Mobile BarCode, 그외는 전화 번호) + /// + /// + public void StartProcessing(long _paySeq) + { + try + { + CommonLog.InfoLogWrite(this, "StartProcessing()", string.Format("Start [{0}]", _paySeq)); + SendReadStart(); + if (NeedInitModule) + { + Thread.Sleep(1000); //진행창 보이기 위한 딜레이 + ErrorEvent(ErrorCode.posPaymentsCancelNotInitailzedError); + } + else + { + var startPorcess = false; + var payRowNo = -1; + if (_paySeq > 0) + { + m_cTrnStatus.Head.TradeDiv = ItemConst.TRAN_DIV.NORMAL; + ArrayList alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM); + foreach (var aPayItme in alPayItem) + { + if (aPayItme is Column.TR_PAYMENT.DATA findPayItem + && findPayItem.SEQ.Equals(_paySeq)) + { + payRowNo = alPayItem.IndexOf(aPayItme); + if (!findPayItem.CANCEL_DIV.Equals(ItemConst.PAY_CANCEL_DIV.CANCEL)) + { + startPorcess = true; + } + else + { + SendErrLogEvent(ErrorCode.posPaymentsCancelCanceledItemError); + } + break; + } + } + if (!startPorcess && payRowNo < 0) + { + SendErrLogEvent(ErrorCode.posPaymentsCancelNotFoundError); + } + else + { + //승인 취소 처리 + CompleteTxtInPut(payRowNo); + if (m_bSearchSuccess) + { + alPayItem.RemoveAt(payRowNo); + } + } + } + else + { + SendErrLogEvent(ErrorCode.posPaymentsCancelPaymentSEQError); + } + + } + SendReadEnd(); + CommonLog.InfoLogWrite(this, "StartProcessing()", string.Format("End : Result={0}", ProcessOK ? "OK" : "Fail")); + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "StartProcessing()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + /// + /// 승인 취소 처리 + /// + /// + private void CompleteTxtInPut(int _rowNo) + { + CommonLog.DebugLogWrite(this, "CompleteTxtInPut()", "Start"); + string sRet = UserCom.RST_ERR; + try + { + m_bSearchSuccess = false; + m_cPayCancel = (IPaymentUs)sManager.InitServiceInstance(ServiceLists.BSV_PAYMENT.DLL, ServiceLists.BSV_PAYMENT.PAYMENTCANCEL); + var alPayItem = (ArrayList)StateObject.GetItemObject(Column.TR_PAYMENT.ITEM); + var cPayItem = (Column.TR_PAYMENT.DATA)alPayItem[_rowNo]; + + // 포인트 사용 승인 처리 + sRet = m_cPayCancel.CancelPayment(new string[] { cPayItem.PAY_WAY_CD, cPayItem.PAY_DTL_CD_01, _rowNo.ToString() }); + if (sRet != UserCom.RST_OK) + { + if (sRet == null || sRet.Equals(UserCom.RST_ERR)) + { + SendErrLogEvent(ErrorCode.posPaymentsCancelUnknownError); + } + else + { + SendErrorMessageEvent(sRet); + } + } + else + { + m_bSearchSuccess = true; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "CompleteTxtInPut()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + CommonLog.DebugLogWrite(this, "CompleteTxtInPut()", "End"); + } + + private void SendErrorMessageEvent(string _errorMessageString) + { + try + { + CommonLog.ErrorLogWrite(this, "SendErrorMessageEvent()", _errorMessageString); + ErrorMessageEvent(_errorMessageString); + } + catch + { + } + } + private void SendErrLogEvent(ErrorCode _errorCode) + { + try + { + CommonLog.DebugLogWrite(this, "SendErrLogEvent()", _errorCode.ToString()); + ErrorEvent(_errorCode); + } + catch + { + + } + } + private void SendReadStart() + { + try + { + CommonLog.DebugLogWrite(this, "SendReadStart()"); + ReadStart(this); + } + catch + { + + } + } + private void SendReadEnd() + { + try + { + CommonLog.DebugLogWrite(this, "SendReadEnd()"); + ReadEnd(this); + } + catch + { + + } + } + #endregion + + + + + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.Model/Functions.cs b/Kiosk/Popup/SPC.Kiosk.Popup.Model/Functions.cs new file mode 100644 index 0000000..1fd0bcf --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.Model/Functions.cs @@ -0,0 +1,166 @@ + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using SPC.Kiosk.Common; +namespace SPC.Kiosk.Popup.Model +{ + /// + /// Popup 사용 공통 기능 + /// + public static class Functions + { + /// + /// Name with Encript Character + /// + /// + /// + public static string GetEncriptName(this string _name) + { + string result = _name; + try + { + switch (_name.Length) + { + case 1: + result = _name; + break; + case 2: + result = _name.Substring(0, 1) + "*"; + break; + case 3: + result = _name.Substring(0, 1) + "*" + _name.Substring(2, 1); + break; + case 4: + result = _name.Substring(0, 1) + "*" + _name.Substring(2, 2); + break; + case 5: + result = _name.Substring(0, 1) + "**" + _name.Substring(3, 2); + break; + default: + var names = _name.Trim().Replace(" ", " ").Split(' '); + int i = 0; + result = string.Empty; + foreach (var aName in names) + { + if (i.Equals(1)) + { + result += string.Empty.PadRight(aName.Length, '*'); + } + else + { + result += aName; + } + i++; + } + break; + } + } + catch + { + result = _name; + } + return result; + + } + /// + /// Card Number With Encript Character + /// + /// + /// + public static string GetEncriptCardNo(this string _cardNo) + { + string result = _cardNo; + try + { + switch (_cardNo.Length) + { + case 14: + result = string.Format("{0}-{1}{2}-{3}-{4}" + , _cardNo.Substring(0, 4) + , _cardNo.Substring(4, 2) + , "**" + , "****" + , "**"); + break; + case 15: + result = string.Format("{0}-{1}{2}-{3}-{4}{5}" + , _cardNo.Substring(0, 4) + , _cardNo.Substring(4, 2) + , "**" + , "****" + , "**" + , _cardNo.Substring(14, 1)); + break; + case 16: + result = string.Format("{0}-{1}{2}-{3}-{4}{5}" + , _cardNo.Substring(0, 4) + , _cardNo.Substring(4, 2) + , "**" + , "****" + , "**" + , _cardNo.Substring(14, 2)); + break; + } + } + catch + { + result = _cardNo; + } + return result; + } + /// + /// Get Mobile Company Name by Type + /// + /// + /// + public static List GetMobileCompanyName(this MobileCompanyType _companyType) + { + List result = null; + try + { + switch (_companyType) + { + case MobileCompanyType.KT_Mobile: + result = new List + { + new M_Language + { + Type=SupportLanguageType.ko, + LanguageData = "KT" + } + }; + break; + case MobileCompanyType.SK_Telecom: + result = new List + { + new M_Language + { + Type=SupportLanguageType.ko, + LanguageData = "SK Telecom" + } + }; + break; + case MobileCompanyType.LG_Uplus: + result = new List + { + new M_Language + { + Type=SupportLanguageType.ko, + LanguageData = "LG U+" + }, + }; + break; + } + } + catch + { + result = null; + } + return result; + } + + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_HappyPointReturn.cs b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_HappyPointReturn.cs new file mode 100644 index 0000000..0e3416b --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_HappyPointReturn.cs @@ -0,0 +1,114 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using SPC.Kiosk.Common; +using SPC.Kiosk.Base; +namespace SPC.Kiosk.Popup.Model +{ + /// + /// HappyPoint 인증 및 사용 정보 + /// + public class M_HappyPointReturn + { + /// + /// 회원명 + /// + public string MemberName { get; set; } = string.Empty; + /// + /// 회원인증번호 + /// + public string MemberNumber { get; set; } = string.Empty; + /// + /// 회원인증번호 + /// + public string MemberCode { get; set; } = string.Empty; + /// + /// 앱 고객 여부 + /// + public bool IsAppMamber { get; set; } = false; + /// + /// MemberLevel + /// + public HappyPointMemberLevel MemberLevel { get; set; } = HappyPointMemberLevel.None; + /// + /// 적립된 포인트 + /// + public double MemberPoint { get; set; } = 0; + /// + /// 가용 포인트 + /// + public double UseablePoint { get; set; } = 0; + /// + /// 적립 유무 + /// + public bool ReservePoint { get; set; } = false; + /// + /// 포인트 사용유무 + /// + public bool PointUse { get; set; } = false; + /// + /// 사용 포인트 + /// + public double UsingPoints { get; set; } = 0; + /// + /// SPC 직원 유무 + /// + public bool IsCompanyMember { get; set; } + /// + /// 단골 매장 유무 + /// + public bool IsFavoriteStore { get; set; } = false; + /// + /// 포인트 카드 사용 유무 + /// + public bool IsCardNoUsed { get; set; } + /// + /// Password 사용유무 + /// + public bool NeedPassword { get; set; } + /// + /// 승인 순번 + /// + public long PaySEQ { get; set; } = -1L; + public List MyHappyCoupons { get; set; } = new List(); + public List OrderHistoryItems { get; set; } + } + /// + /// HappyPoint In Card Coupon Data + /// + public class M_HappyCoupon + { + /// + /// Coupon 번호 + /// + public string Number { get; set; } = string.Empty; + /// + /// Coupon 명 + /// + public string Name { get; set; } = string.Empty; + /// + /// 유효기간 시작 + /// + public DateTime StartDate { get; set; } = DateTime.MinValue; + /// + /// 유효 기간 종료 + /// + public DateTime EndDate { get; set; } = DateTime.MinValue; + /// + /// 사용됨 + /// + public bool IsUsed { get; set; } = false; + /// + /// Discount 금액 + /// + public double UseAmount { get; set; } = 0d; + /// + /// 승인 순번 + /// + public long PaySEQ { get; set; } = -1L; + } + + +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_MiniPopup.cs b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_MiniPopup.cs new file mode 100644 index 0000000..04657ab --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_MiniPopup.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using SPC.Kiosk.Common; + +namespace SPC.Kiosk.Popup.Model +{ + /// + /// Mini Popup Model + /// + public class M_MiniPopup + { + /// + /// Icon Type + /// + public MiniPopupIcon Icon { get; set; } = MiniPopupIcon.None; + /// + /// Display Language + /// + public SupportLanguageType DisplayLanguage { get; set; } = SupportLanguageType.ko; + /// + /// Main Message + /// + public List Message { get; set; } + /// + /// Sub Message + /// + public List SubMessage { get; set; } + /// + /// Cencal Button Text + /// + public List CencalButtonText { get; set; } + /// + /// Ok Button Text + /// + public List OkButtonText { get; set; } + /// + /// Is Show Cencal Button + /// + public bool IsCencalButton { get; set; } = true; + /// + /// Is Show Timeout Popup + /// + public bool IsTimeoutPopup { get; set; } = false; + /// + /// Timeout Seconds + /// + public double TimeoutSeconds { get; set; } = 10d; + + + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_MobileCompanyReturn.cs b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_MobileCompanyReturn.cs new file mode 100644 index 0000000..5dc83ec --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_MobileCompanyReturn.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using SPC.Kiosk.Common; +namespace SPC.Kiosk.Popup.Model +{ + /// + /// 통신사 할인 정보 + /// + public class M_MobileCompanyReturn + { + /// + /// 통신사 + /// + public MobileCompanyType Company { get; set; } + /// + /// 회원인증번호 + /// + public string MemberCode { get; set; } = string.Empty; + /// + /// 할인 대상 금액 + /// + public double ApprovalPayments { get; set; } = 0d; + /// + /// 할인 금액 + /// + public double DiscountValue { get; set; } = 0d; + /// + /// 승인 순번 + /// + public long PaySEQ { get; set; } + + + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_MobileCouponReturn.cs b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_MobileCouponReturn.cs new file mode 100644 index 0000000..7beabdd --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_MobileCouponReturn.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; + +namespace SPC.Kiosk.Popup.Model +{ + /// + /// Mobile Coupon Return Model + /// + public class M_MobileCouponReturn + { + /// + /// 쿠폰 번호 + /// + public string Number { get; set; } = string.Empty; + /// + /// 쿠폰 명 + /// + public string Name { get; set; } = string.Empty; + /// + /// 전체 쿠폰 금액 + /// + public long TotalAmount { get; set; } = 0; + /// + /// 동시 사용 제약 + /// + public bool IsOnlyAllUse { get; set; } = false; + /// + /// 전체 사용 금액 (할인 확정 금액 합계) + /// + public long TotalUseAmount { get; set; } = 0; + /// + /// 사용 쿠폰 수 + /// + public int UsingCounts { get; set; } = 0; + /// + /// 가상 쿠폰 목록 + /// + public List VirtureCoupons { get; set; } = new List(); + } + /// + /// Mobile Coupon Detail Model + /// + public class M_MobileCouponDetail:ViewModelBase + { + /// + /// 가상 쿠폰 번호 + /// + public string Number { get; set; } = string.Empty; + /// + /// 가상 쿠폰명 + /// + public string Name { get; set; } = string.Empty; + /// + /// 브렌드 코드 + /// + public string BrandCode { get; set; } = string.Empty; + /// + /// 브렌드 명 + /// + public string BrandName { get; set; } = string.Empty; + /// + /// 종류 + /// + public MobileCouponType Type { get; set; } = MobileCouponType.NormalValue; + /// + /// 옵션 + /// + public MobileCouponOptionType Option { get; set; } = MobileCouponOptionType.None; + /// + /// 권면가 + /// + public long ShowPrice { get; set; } =0L; + /// + /// 구매가 + /// + public long ByePrice { get; set; } = 0L; + /// + /// 잔액 + /// + public long RemainPrice { get; set; } = 0L; + /// + /// 가용 금액 + /// + public long CanUsingPrice { get; set; } = 0L; + /// + /// 그룹 번호 + /// + public int GroupNo { get; set; } = 0; + /// + /// 그룹 사용 횟수 + /// + public int GroupLimitUsingCount { get; set; } = 0; + /// + /// 유효 기간 시작 + /// + public DateTime StartDate { get; set; } = DateTime.MinValue; + /// + /// 유효 기간 종료 + /// + public DateTime EndDate { get; set; } = DateTime.MinValue; + /// + /// 상태 + /// + public MobileCouponStatusType Status { get; set; } = MobileCouponStatusType.CanUse; + /// + /// 상태 설명 + /// + public string StatusDetail { get; set; } = string.Empty; + /// + /// 구성 상품 순번 (상품코드) + /// + public string ItemCodeKey { get; set; } = string.Empty; + /// + /// 상품 코드 + /// + public List ItemCodes { get; set; } = new List(); + private long requestPrice = 0L; + /// + /// 사용 요청 금액 + /// + public long RequestPrice + { + get { return requestPrice; } + set { requestPrice = value; PropertyChange("RequestPrice"); } + } + private long discountPrice = 0L; + /// + /// 할인 확정 금액 + /// + public long DiscountPrice + { + get { return discountPrice; } + set { discountPrice = value; PropertyChange("DiscountPrice"); } + } + private string statusText = string.Empty; + /// + /// 상태 문자열 + /// + public string StatusText + { + get { return statusText; } + set { statusText = value; PropertyChange("StatusText"); } + + } + /// + /// 승인 순번 + /// + public long PaySEQ { get; set; } = -1L; + + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_NhsFuncInfoItem.cs b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_NhsFuncInfoItem.cs new file mode 100644 index 0000000..2de99cb --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_NhsFuncInfoItem.cs @@ -0,0 +1,206 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using SPC.Kiosk.Common; +using SPC.Kiosk.Base; +namespace SPC.Kiosk.Popup.Model +{ + /// + /// ※CommonTypes에 NhsFuncInfoType과 일치해야함※ + /// Kiosk 에서 사용가능한 결재수단 필드 : 2019-06-10 - 1997fx11 + /// + public class NhsFuncInfoItem : ViewModelBase + { + private string defaultValue = "0"; + /// + /// 아직 없는 필드에대한 값(Default 숨김) + /// + public string DefaultValue + { + get { return defaultValue; } + set { defaultValue = value; PropertyChange("DefaultValue"); } + } + + private string saveHappyPoint; + /// + /// STEP01 포인트 적립 - 해피포인트 적립 + /// + public string SaveHappyPoint + { + get { return saveHappyPoint; } + set { saveHappyPoint = value; PropertyChange("SaveHappyPoint"); } + } + + private string saveOkCashBag; + /// + /// STEP01 포인트 적립 - OK CASHBAG 적립 + /// + public string SaveOkCashBag + { + get { return saveOkCashBag; } + set { saveOkCashBag = value; PropertyChange("SaveOkCashBag"); } + } + + private string discountSKT; + /// + /// STEP01 통신사 할인 - SKT + /// + public string DiscountSKT + { + get { return discountSKT; } + set { discountSKT = value; PropertyChange("DiscountSKT"); } + } + + private string discountKT; + /// + /// STEP01 통신사 할인 - KT + /// + public string DiscountKT + { + get { return discountKT; } + set { discountKT = value; PropertyChange("DiscountKT"); } + } + + private string discountLG; + /// + /// STEP01 통신사 할인 - LGT + /// + public string DiscountLG + { + get { return discountLG; } + set { discountLG = value; PropertyChange("discountLG"); } + } + + private string usePointHappyPoint; + /// + /// STEP02 포인트 사용 - 해피포인트 사용 + /// + public string UsePointHappyPoint + { + get { return usePointHappyPoint; } + set { usePointHappyPoint = value; PropertyChange("UsePointHappyPoint"); } + } + + private string usePointOkCashBag; + /// + /// STEP02 포인트 사용 - OK CASHBAG 사용 + /// + public string UsePointOkCashBag + { + get { return usePointOkCashBag; } + set { usePointOkCashBag = value; PropertyChange("UsePointOkCashBag"); } + } + + private string useCouponHappy; + /// + /// STEP02 쿠폰 사용 - 해피쿠폰할인 + /// + public string UseCouponHappy + { + get { return useCouponHappy; } + set { useCouponHappy = value; PropertyChange("UseCouponHappy"); } + } + + private string useCouponMobile; + /// + /// STEP02 쿠폰 사용 - 모바일쿠폰 + /// + public string UseCouponMobile + { + get { return useCouponMobile; } + set { useCouponMobile = value; PropertyChange("UseCouponMobile"); } + } + + private string useCardPaymentCreditCard; + /// + /// STEP03 카드 결제 - 신용카드 + /// + public string UseCardPaymentCreditCard + { + get { return useCardPaymentCreditCard; } + set { useCardPaymentCreditCard = value; PropertyChange("UseCardPaymentCreditCard"); } + } + + private string useCardPaymentSPCEmployeeCertificate; + /// + /// STEP03 카드 결제 - SPC 사원증 + /// + public string UseCardPaymentSPCEmployeeCertificate + { + get { return useCardPaymentSPCEmployeeCertificate; } + set { useCardPaymentSPCEmployeeCertificate = value; PropertyChange("UseCardPaymentSPCEmployeeCertificate"); } + } + + private string useCardPaymentTMoney; + /// + /// STEP03 카드 결제 - T-MONEY + /// + public string UseCardPaymentTMoney + { + get { return useCardPaymentTMoney; } + set { useCardPaymentTMoney = value; PropertyChange("UseCardPaymentTMoney"); } + } + + private string useCardPaymentCashBee; + /// + /// STEP03 카드 결제 - 캐시비 + /// + public string UseCardPaymentCashBee + { + get { return useCardPaymentCashBee; } + set { useCardPaymentCashBee = value; PropertyChange("UseCardPaymentCashBee"); } + } + + private string useCardPaymentHappyGift; + /// + /// STEP03 카드 결제 - HAPPY GIFT + /// + public string UseCardPaymentHappyGift + { + get { return useCardPaymentHappyGift; } + set { useCardPaymentHappyGift = value; PropertyChange("UseCardPaymentHappyGift"); } + } + + private string useCardPaymentSamsungLGPay; + /// + /// STEP03 카드 결제 - 삼성/LG 페이 + /// + public string UseCardPaymentSamsungLGPay + { + get { return useCardPaymentSamsungLGPay; } + set { useCardPaymentSamsungLGPay = value; PropertyChange("UseCardPaymentSamsungLGPay"); } + } + + private string useCardPaymentAlipay; + /// + /// STEP03 카드 결제 - 알리페이 + /// + public string UseCardPaymentAlipay + { + get { return useCardPaymentAlipay; } + set { useCardPaymentAlipay = value; PropertyChange("UseCardPaymentAlipay"); } + } + + private string useCardPaymentSmilePay; + /// + /// STEP03 카드 결제 - 스마일페이 + /// + public string UseCardPaymentSmilePay + { + get { return useCardPaymentSmilePay; } + set { useCardPaymentSmilePay = value; PropertyChange("UseCardPaymentSmilePay"); } + } + + private string useCardPaymentZeroPay; + /// + /// STEP03 카드 결제 - 제로페이 + /// + public string UseCardPaymentZeroPay + { + get { return useCardPaymentZeroPay; } + set { useCardPaymentZeroPay = value; PropertyChange("UseCardPaymentZeroPay"); } + } + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_NumberPadImages.cs b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_NumberPadImages.cs new file mode 100644 index 0000000..cc1105c --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_NumberPadImages.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using SPC.Kiosk.Common; + +namespace SPC.Kiosk.Popup.Model +{ + /// + /// Number Pad Images Model + /// + public class M_NumberPadImages + { + /// + /// Button Type + /// + public NumberPadButton ButtonType { get; set; } + /// + /// Button Image + /// + public string ButtonImage { get; set; } + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_OkCashBagReturn.cs b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_OkCashBagReturn.cs new file mode 100644 index 0000000..69f37b8 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_OkCashBagReturn.cs @@ -0,0 +1,52 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using SPC.Kiosk.Common; + +namespace SPC.Kiosk.Popup.Model +{ + /// + /// OK 캐쉬백 인증 및 사용정보 + /// + public class M_OkCashBagReturn + { + /// + /// 회원명 + /// + public string MemberName { get; set; } = string.Empty; + /// + /// 회원인증번호 + /// + public string MemberCode { get; set; } = string.Empty; + /// + /// 적립된 포인트 + /// + public double MemberPoint { get; set; } = 0; + /// + /// 적립 유무 + /// + public bool ReservePoint { get; set; } = false; + /// + /// 포인트 사용유무 + /// + public bool PointUse { get; set; } = false; + /// + /// 사용 포인트 + /// + public double UsingPoints { get; set; } = 0; + /// + /// Password 사용유무 + /// + public bool NeedPassword { get; set; } + /// + /// 승인번호 + /// + public string ApprovalNo { get; set; } = string.Empty; + /// + /// 승인일자 + /// + public string ApprovalDate { get; set; } = string.Empty; + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_OptionReturn.cs b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_OptionReturn.cs new file mode 100644 index 0000000..ee4c8a7 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_OptionReturn.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using SPC.Kiosk.Common; +namespace SPC.Kiosk.Popup.Model +{ + /// + /// HappyPoint 인증 및 사용 정보 + /// + public class M_OptionReturn + { + /// + /// Item Count + /// + public int ItemCount { get; set; } = 0; + /// + /// 적립된 포인트 + /// + public double PriceWithOption { get; set; } = 0d; + /// + /// Select Options + /// + public List Options { get; set; } + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_PaymentEndReturn.cs b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_PaymentEndReturn.cs new file mode 100644 index 0000000..892169c --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_PaymentEndReturn.cs @@ -0,0 +1,47 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using SPC.Kiosk.Common; +namespace SPC.Kiosk.Popup.Model +{ + /// + /// Payment End Return Model + /// + public class M_PaymentEndReturn + { + /// + /// 개인 현금 연수중 발행 필요 + /// + public bool IsCashReceipt { get; set; } = false; + /// + /// 법인 혐금 영수증 발행 필요 + /// + public bool IsCompayCashReceipt { get; set; } = false; + /// + /// 현금 영수증 조회 번호 + /// + public string CashReceiptCode { get; set; } = string.Empty; + /// + /// 현금 영수증 발행 대상 금액 + /// + public int CashPayments { get; set; } = 0; + /// + /// 대기번호 + /// + public string WaitNumber { get; set; } = string.Empty; + /// + /// 진동벨 번호 + /// + public string VibrationBellNumber { get; set; } = string.Empty; + /// + /// 일림톡 대상 휴대폰 번호 + /// + public string NotifyTalkPhoneNumber { get; set; } = string.Empty; + /// + /// 승인 순번 + /// + public long PaySEQ { get; set; } = -1L; + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_PaymentReturn.cs b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_PaymentReturn.cs new file mode 100644 index 0000000..d3676fe --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_PaymentReturn.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using SPC.Kiosk.Common; +namespace SPC.Kiosk.Popup.Model +{ + /// + /// 결제 완료 정보 + /// + public class M_PaymentReturn + { + /// + /// 결제 처리 성공 유무 + /// + public bool IsProcessOK { get; set; } = false; + /// + /// 결제 금액 + /// + public double PaymentsTotal { get; set; } = 0; + /// + /// 승인 순번 + /// + public long PaySEQ { get; set; } = -1L; + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_StoreAgree.cs b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_StoreAgree.cs new file mode 100644 index 0000000..b0b8191 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.Model/M_StoreAgree.cs @@ -0,0 +1,64 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using SPC.Kiosk.Common; + +namespace SPC.Kiosk.Popup.Model +{ + /// + /// 단골 매장 컨트롤용 모델 + /// + public class M_StoreAgree + { + /// + /// 단골 매장 유무 + /// + public bool IsFavoriteStore { get; set; } = false; + /// + /// 표시언어 + /// + public SupportLanguageType DisplayLanguage { get; set; } + /// + /// 제목 + /// + public List Header { get; set; } + /// + /// 배경 이미지 + /// + public string BackgroundImage { get; set; } + /// + /// 점포 이미지 + /// + public string StoreImage { get; set; } + /// + /// 점포명 + /// + public string StoreName { get; set; } + /// + /// 등록 첫번째 안내 + /// + public List FirstInfoText { get; set; } + /// + /// 등록 두번째 안내 + /// + public List SecondInfoText { get; set; } + /// + /// 환영 안내 + /// + public List WelcomeInfoText { get; set; } + /// + /// Button Normal Brush + /// + public string ButtonNormalBrush { get; set; } + /// + /// Button SwitchOn Brush + /// + public string ButtonSwitchOnBrush { get; set; } + /// + /// Button Text + /// + public List ButtonText { get; set; } + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.Model/Properties/AssemblyInfo.cs b/Kiosk/Popup/SPC.Kiosk.Popup.Model/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..6389522 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.Model/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("SPC.Kiosk.Popup.Model")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("SPC.Kiosk.Popup.Model")] +[assembly: AssemblyCopyright("Copyright © Zin Inc. 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +//지역화 가능 응용 프로그램 빌드를 시작하려면 다음을 설정하세요. +//.csproj 파일에서 내에 CultureYouAreCodingWith를 +//설정하십시오. 예를 들어 소스 파일에서 영어(미국)를 +//사용하는 경우 를 en-US로 설정합니다. 그런 다음 아래 +//NeutralResourceLanguage 특성의 주석 처리를 제거합니다. 아래 줄의 "en-US"를 업데이트하여 +//프로젝트 파일의 UICulture 설정과 일치시킵니다. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //테마별 리소스 사전의 위치 + //(페이지 또는 응용 프로그램 리소스 사진에 + // 리소스가 없는 경우에 사용됨) + ResourceDictionaryLocation.SourceAssembly //제네릭 리소스 사전의 위치 + //(페이지 또는 응용 프로그램 리소스 사진에 + // 리소스가 없는 경우에 사용됨) +)] + + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호가 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.Model/SPC.Kiosk.Popup.Model.csproj b/Kiosk/Popup/SPC.Kiosk.Popup.Model/SPC.Kiosk.Popup.Model.csproj new file mode 100644 index 0000000..2795326 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.Model/SPC.Kiosk.Popup.Model.csproj @@ -0,0 +1,83 @@ + + + + + Debug + AnyCPU + {BE7FC15C-325B-4AD4-8EA0-A8244193E431} + Library + SPC.Kiosk.Popup.Model + SPC.Kiosk.Popup.Model + v4.0 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + x86 + true + full + false + ..\..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + 4.0 + + + + + + + + + + + + + + + + + + + + Code + + + + + + {bcc10fa2-c358-480c-8ff0-615750f3c306} + SPC.Kiosk.Base + + + {ba2d06e0-74c0-4785-b39f-d1eaac13b73d} + SPC.Kiosk.Common + + + + \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.Model/Types.cs b/Kiosk/Popup/SPC.Kiosk.Popup.Model/Types.cs new file mode 100644 index 0000000..d0bbbcb --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.Model/Types.cs @@ -0,0 +1,382 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; + +namespace SPC.Kiosk.Popup.Model +{ + /// + /// 미니팝업 아이콘 타입 + /// + public enum MiniPopupIcon + { + /// + /// 없음 + /// + None, + /// + /// 취소 + /// + Cancel, + /// + /// 삭제 + /// + Delete, + /// + /// 목록 삭제 + /// + ListCancel, + /// + /// 할인 취소 + /// + DiscountCancel, + /// + /// 상은품 취소 + /// + GiftCancel, + /// + /// 주문 취소 + /// + OrderCancel, + /// + /// 쿠폰 추가 + /// + AddCoupon, + /// + /// 결제 + /// + Payment, + } + /// + /// Number Pad Buttons + /// + public enum NumberPadButton + { + /// + /// Button0 + /// + Button0, + /// + /// Button1 + /// + Button1, + /// + /// Button2 + /// + Button2, + /// + /// Button3 + /// + Button3, + /// + /// Button4 + /// + Button4, + /// + /// Button5 + /// + Button5, + /// + /// Button6 + /// + Button6, + /// + /// Button7 + /// + Button7, + /// + /// Button8 + /// + Button8, + /// + /// Button9 + /// + Button9, + /// + /// ButtonCancel + /// + ButtonCancel, + /// + /// ButtonBack + /// + ButtonBack, + /// + /// None Button + /// + ButtonNone + } + /// + /// Mobile Coupon Window Type + /// + public enum MobileCouponWindowType + { + /// + /// 쿠폰조회 시작 + /// + CouponStart, + /// + /// 쿠폰사용 시작 + /// + CouponUsing, + /// + /// 처리중 + /// + Processing, + /// + /// 처리 실패 + /// + ProcessingError, + /// + /// 인증 처리 성공 + /// + CouponSuccess, + } + /// + /// 인증창/통신사 할인 WindowType + /// + public enum CertifyWindowType + { + /// + /// 인증 처리시작 + /// + CertifyStart, + /// + /// 인증 처리중 + /// + CertifyProcessing, + /// + /// 인증 실패 + /// + ProcessingError, + /// + /// 인증 처리 성공 + /// + CertifySuccess, + } + /// + /// Happy Point Coupon Window Type + /// + public enum HappyCouponWindowType + { + /// + /// 쿠폰 인식 + /// + CouponStart, + /// + /// 쿠폰 선택 + /// + CouponUsing, + /// + /// 처리중 + /// + Processing, + /// + /// 처리 실패 + /// + ProcessingError, + /// + /// 처리 성공 + /// + CouponSuccess, + } + /// + /// 포인트 사용 윈도우 타입 + /// + public enum PointUsingWindowType + { + /// + /// 인증 처리시작 + /// + CertifyStart, + /// + /// 포인트 사용 시작 + /// + PointUsing, + /// + /// 처리중 + /// + Processing, + /// + /// 처리 실패 + /// + ProcessingError, + /// + /// 처리 성공 + /// + CertifySuccess, + } + /// + /// 결제창 + /// + public enum PaymentWindowType + { + None, + /// + /// 결제 수단 요구 + /// + PaymentStart, + /// + /// 핀(6자리) 암호 입력창 + /// + ReadPinNumber, + /// + /// 싸인 입력창 + /// + ReadSign, + /// + /// 결제 처리중 + /// + PaymentProcessing, + /// + /// 결제 실패 + /// + ProcessingError, + /// + /// 처리 성공 + /// + PaymentSuccess + + } + /// + /// 결제 후처리창 + /// + public enum PaymentEndWindowType + { + None, + /// + /// 현금 영수증 + /// + CashReceipt, + /// + /// 결제 처리중 + /// + Processing, + /// + /// 진동벨 또는 알림톡 입력 + /// + BellOrNotifyTalk, + /// + /// 일반 처리 처리 성공 + /// + PaymentSuccess, + /// + /// 알림톡 완료 + /// + TalkSuccess, + /// + /// 진동벨/대기번호 완료 + /// + WaitNumberSuccess, + } + + /// + /// 통신사 + /// + public enum MobileCompanyType + { + /// + /// KT + /// + KT_Mobile, + /// + /// SK + /// + SK_Telecom, + /// + /// LG + /// + LG_Uplus + } + /// + /// 최종 결제 수단 + /// + public enum LastPaymentsType + { + None, + /// + /// Card 결제 + /// + IcCard, + /// + /// 삼성,LG 페이 + /// + SsLgPay, + /// + /// 캐시비 + /// + CashBee, + /// + /// 해피기프트 + /// + HappyGift, + /// + /// 티머니 + /// + Tmoney, + /// + /// 임직원결제 + /// + SpcEmployee, + /// + /// 스마일 페이 + /// + SmilePay, + /// + /// 알리페이 + /// + AliPay, + /// + /// 제로페이 + /// + ZeroPay, + } + + public enum PosOptionType + { + /// + /// 마감시간 설정 + /// + OPT800, + /// + /// 자동꺼짐 시간 + /// + OPT801, + /// + /// 진동벨 1사용, 0사용안함 + /// + OPT802, + /// + /// 알림톡 1사용, 0사용안함 + /// + OPT803, + /// + /// 대기번호 1사용, 0사용안함 + /// + OPT804, + /// + /// 자동결제 사용여부 1사용, 0사용안함 + /// + OPT810, + /// + /// 바코드계산 사용여부 1사용, 0사용안함 + /// + OPT811, + /// + /// 직원호출 사용여부 + /// + OPT812, + /// + /// 다국어 - 영문사용 + /// + OPT813, + /// + /// 다국어 - 일어사용 + /// + OPT814, + /// + /// 다국어 - 중국어사용 + /// + OPT815, + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/PopupViewModelBase.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/PopupViewModelBase.cs new file mode 100644 index 0000000..f5fa297 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/PopupViewModelBase.cs @@ -0,0 +1,194 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Input; +using System.Windows.Threading; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +namespace SPC.Kiosk.Popup.ViewModel +{ + /// + /// Popup View Model Base + /// + public class PopupViewModelBase : ViewModelBase + { + #region [ Members ] + public ICommand ToExecuteNothing { get; protected set; } = null; + private SupportLanguageType showLanguageType; + /// + /// 화면 언어 + /// + public SupportLanguageType ShowLanguageType + { + get { return showLanguageType; } + set { showLanguageType = value; PropertyChange("ShowLanguageType"); } + } + /// + /// 팝업 응답 정보 + /// + public M_PopupReturn ReturnValue { get; set; } + private bool canWindowClose = false; + /// + /// 화면 닫기 (true 이면 바로 닫음) + /// + public bool CanWindowClose + { + get { return canWindowClose; } + set { canWindowClose = value; PropertyChange("CanWindowClose"); } + } + private bool timerEnabled = false; + /// + /// 대기시간 타이머 동작 유무 + /// + public bool TimerEnabled + { + get { return timerEnabled; } + set { timerEnabled = value; PropertyChange("TimerEnabled"); } + } + private bool isTimeout = false; + /// + /// 대기시간 초과 유무 (타이머 동작 중지후 IsTimeOut = True 발생) + /// + public bool IsTimeout + { + get { return isTimeout; } + set { isTimeout = value; PropertyChange("IsTimeout"); } + } + private double timeOutSeconds = 30d; + /// + /// 대기시간 (초) + /// + public double TimeOutSeconds + { + get { return timeOutSeconds; } + set { timeOutSeconds = value; PropertyChange("TimeOutSeconds"); } + } + private bool isTimeoutPopup = false; + public bool IsTimeoutPopup + { + get { return isTimeoutPopup; } + set { isTimeoutPopup = value; PropertyChange("IsTimeoutPopup"); } + } + /// + /// 최종 엑세스 시간 PropertyChanged 가 발생 할때 마다 업데이트됨 + /// + public DateTime LastAccessTime { get; set; } = DateTime.Now; + private DispatcherTimer ShowTimer; + #endregion + + #region [ Ctor ] + /// + /// 생성자 + /// + public PopupViewModelBase() + { + ToExecuteNothing = new Command(ToExecuteNothingHandler); + this.PropertyChanged += PopupViewModelBase_PropertyChanged; + TimeOutSeconds = CommonValue.TimeOutSeconds; + ShowLanguageType = CommonValue.CommonLanguageType; + TimerEnabled = true; + } + /// + /// Dispose + /// + public void Dispose() + { + this.PropertyChanged -= PopupViewModelBase_PropertyChanged; + if (this.ShowTimer != null) + { + ShowTimer.Stop(); + ShowTimer.Tick -= ShowTimer_Tick; + ShowTimer = null; + } + } + #endregion Ctor + + #region [ Event Handlers ] + private void ToExecuteNothingHandler(object obj) + { + + } + private void ShowTimer_Tick(object sender, EventArgs e) + { + if ((DateTime.Now - LastAccessTime) > TimeSpan.FromSeconds(TimeOutSeconds)) + { + + TimerEnabled = false; + if (IsTimeoutPopup) + { +#if !TESTMODE + var popupReturn = PopupMessageBox.ShowMessageBox(ShowLanguageType + , Languages.GetMessages("LBL0067") + , Languages.GetMessages("LBL0021") + , MessageBoxButton.YesNo + , OpenCloseAnimationType.FullSizeUp + , OpenCloseAnimationType.FullSizeDown + , 0.5, 0.2, 10); + if (popupReturn.Equals(MessageBoxResult.Yes)) + { + LastAccessTime = DateTime.Now; + TimerEnabled = true; + } + else + { + IsTimeout = true; + } +#endif + } + else + { + IsTimeout = true; + } + } + } + private void PopupViewModelBase_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + LastAccessTime = DateTime.Now; + switch (e.PropertyName) + { + case "TimerEnabled": + if (TimerEnabled) + { + if (this.ShowTimer != null) + { + this.ShowTimer.Start(); + } + else + { + this.ShowTimer = new DispatcherTimer + { + Interval = TimeSpan.FromSeconds(1), + }; + ShowTimer.Tick += ShowTimer_Tick; + ShowTimer.Start(); + } + + } + else + { + if (this.ShowTimer != null) + { + this.ShowTimer.Stop(); + } + } + break; + case "CanWindowClose": + if (this.ShowTimer != null) + { + this.ShowTimer.Stop(); + this.ShowTimer.Tick -= ShowTimer_Tick; + this.ShowTimer = null; + } + break; + } + } + + + + #endregion Event Handlers + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/Properties/AssemblyInfo.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..56b5ccb --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("SPC.Kiosk.Popup.ViewModel")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("SPC.Kiosk.Popup.ViewModel")] +[assembly: AssemblyCopyright("Copyright © Zin Inc. 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +//지역화 가능 응용 프로그램 빌드를 시작하려면 다음을 설정하세요. +//.csproj 파일에서 내에 CultureYouAreCodingWith를 +//설정하십시오. 예를 들어 소스 파일에서 영어(미국)를 +//사용하는 경우 를 en-US로 설정합니다. 그런 다음 아래 +//NeutralResourceLanguage 특성의 주석 처리를 제거합니다. 아래 줄의 "en-US"를 업데이트하여 +//프로젝트 파일의 UICulture 설정과 일치시킵니다. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //테마별 리소스 사전의 위치 + //(페이지 또는 응용 프로그램 리소스 사진에 + // 리소스가 없는 경우에 사용됨) + ResourceDictionaryLocation.SourceAssembly //제네릭 리소스 사전의 위치 + //(페이지 또는 응용 프로그램 리소스 사진에 + // 리소스가 없는 경우에 사용됨) +)] + + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호가 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/SPC.Kiosk.Popup.ViewModel.csproj b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/SPC.Kiosk.Popup.ViewModel.csproj new file mode 100644 index 0000000..817a541 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/SPC.Kiosk.Popup.ViewModel.csproj @@ -0,0 +1,100 @@ + + + + + Debug + AnyCPU + {9EF1FEC9-5F0A-4A4E-8723-E93F30798FD2} + Library + SPC.Kiosk.Popup.ViewModel + SPC.Kiosk.Popup.ViewModel + v4.0 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + + + x86 + true + full + false + ..\..\..\..\BIN\ + TRACE;DEBUG;TESTMODE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + 4.0 + + + + + + + + + + + + + + + + + + + + + + + + + + Code + + + + + {bcc10fa2-c358-480c-8ff0-615750f3c306} + SPC.Kiosk.Base + + + {ba2d06e0-74c0-4785-b39f-d1eaac13b73d} + SPC.Kiosk.Common + + + {fee44681-7f0e-469a-a833-dc324eb6d01a} + SPC.Kiosk.DataHelper + + + {36fe9011-b9bc-4348-b9c1-1c063dbfa926} + SPC.Kiosk.Payments + + + {be7fc15c-325b-4ad4-8ea0-a8244193e431} + SPC.Kiosk.Popup.Model + + + + \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmCallEmployee.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmCallEmployee.cs new file mode 100644 index 0000000..cdca408 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmCallEmployee.cs @@ -0,0 +1,202 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Input; +using System.Windows.Threading; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +namespace SPC.Kiosk.Popup.ViewModel +{ + /// + /// CallEmployee.xaml 의 ViewModel + /// + public class VmCallEmployee : PopupViewModelBase + { + #region [ Members ] + private List messageText = null; + /// + /// Message Text + /// + public List MessageText + { + get { return messageText; } + set { messageText = value; PropertyChange("MessageText"); } + } + private List infomationText = null; + /// + /// Infomation Text + /// + public List InfomationText + { + get { return infomationText; } + set { infomationText = value; PropertyChange("InfomationText"); } + } + + private bool isCallEmployeeOK = false; + /// + /// Is Call Employee Process OK + /// + public bool IsCallEmployeeOK + { + get { return isCallEmployeeOK; } + set { isCallEmployeeOK = value; PropertyChange("IsCallEmployeeOK"); } + } + private List cancelButtonText; + /// + /// Cancel Button Text + /// + public List CancelButtonText + { + get { return cancelButtonText; } + set { cancelButtonText = value; PropertyChange("CancelButtonText"); } + } + private List okButtonText; + /// + /// OK Button Text + /// + public List OkButtonText + { + get { return okButtonText; } + set { okButtonText = value; PropertyChange("OkButtonText"); } + } + private double okButtonWidth=650d; + /// + /// OK Button Width + /// + public double OkButtonWidth + { + get { return okButtonWidth; } + set { okButtonWidth = value; PropertyChange("OkButtonWidth"); } + } + private double cancelButtonWidth = 650d; + /// + /// Cancel Button Visible + /// + public double CancelButtonWidth + { + get { return cancelButtonWidth; } + set { cancelButtonWidth = value; PropertyChange("CancelButtonWidth"); } + } + private string callImage; + /// + /// Call Image Enabled (On Error Enabled False) + /// + public string CallImage + { + get { return callImage; } + set { callImage = value; PropertyChange("CallImage"); } + } + private double popupWidth=1300d; + /// + /// Popup Whidth (For Calculate OK Button Width) + /// + public double PopupWidth + { + get { return popupWidth; } + set { popupWidth = value; PropertyChange("PopupWidth"); } + } + /// + /// OK Click Command + /// + public ICommand OkCommand { get; protected set; } + /// + /// Cancel Click Command + /// + public ICommand CancelCommand { get; protected set; } + + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public VmCallEmployee() + { + OkCommand = new Command(OkCommandHandler); + CancelCommand = new Command(CancelCommandHandler); + this.PropertyChanged += VmCallEmployee_PropertyChanged; + ShowLanguageType = CommonValue.CommonLanguageType; + CallImage = ResourceManager.GetNximagePathAdd("ic_alert_help.png", CommonValue.PBdesignImagesPath); + MessageText = Languages.GetMessages("LBL0102"); + InfomationText = new List(); + OkButtonText = Languages.GetMessages("BTN0005"); + CancelButtonText = Languages.GetMessages("BTN0021"); + } + ~VmCallEmployee() + { + this.PropertyChanged -= VmCallEmployee_PropertyChanged; + } + #endregion Ctor + + #region [ Event Handlers ] + private void CancelCommandHandler(object obj) + { + TimerEnabled = false; + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + + private void OkCommandHandler(object obj) + { + TimerEnabled = false; + if (IsCallEmployeeOK) + { + ReturnValue = new M_PopupReturn + { + OKAnswer = true, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + else + { + IsCallEmployeeOK = true; + } + } + + private void VmCallEmployee_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "IsTimeout": + if (IsTimeout) + { + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = true, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + break; + case "IsCallEmployeeOK": + if (IsCallEmployeeOK) + { + CallImage = ResourceManager.GetNximagePathAdd("ic_alert_check.png", CommonValue.PBdesignImagesPath); + MessageText = Languages.GetMessages("LBL0101"); + InfomationText = new List(); + OkButtonWidth =PopupWidth; + CancelButtonWidth = 0; + OkButtonText = Languages.GetMessages("BTN0039"); + } + break; + } + } + + #endregion Event Handlers + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmHappyPointCertify.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmHappyPointCertify.cs new file mode 100644 index 0000000..8600328 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmHappyPointCertify.cs @@ -0,0 +1,1300 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Threading; +using System.Windows; +using System.Windows.Input; +using System.Windows.Threading; +using System.Reflection; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Payments; +using SPC.Kiosk.DataHelper; +using System.Windows.Controls; +using System.Windows.Media; + +namespace SPC.Kiosk.Popup.ViewModel +{ + /// + /// HappyPointCertify.xaml에 대한 ViewModel + /// + public class VmHappyPointCertify : PopupViewModelBase + { + + + #region [ Members ] + private PosDataService posDataService = null; + private ObservableCollection memberHistoryItems= new ObservableCollection(); + /// + /// Member History Items + /// + public ObservableCollection MemberHistoryItems + { + get { return memberHistoryItems; } + set { memberHistoryItems = value; PropertyChange("MemberHistoryItems"); } + } + private ObservableCollection memberOrderBasket; + /// + /// Member Order Basket + /// + public ObservableCollection MemberOrderBasket + { + get { return memberOrderBasket; } + set { memberOrderBasket = value; PropertyChange("MemberOrderBasket"); } + } + + private double memberHistoryItemsGridHeight = 310d; + /// + /// Member History Items Grid Height + /// + public double MemberHistoryItemsGridHeight + { + get { return memberHistoryItemsGridHeight; } + set { memberHistoryItemsGridHeight = value; PropertyChange("MemberHistoryItemsGridHeight"); } + } + private double topGridMarginHeight = 0d; + /// + /// Top Grid Margin Height + /// + public double TopGridMarginHeight + { + get { return topGridMarginHeight; } + set { topGridMarginHeight = value; PropertyChange("TopGridMarginHeight"); } + } + + private string titileImage; + /// + /// Titile Image + /// + public string TitileImage + { + get { return titileImage; } + set { titileImage = value; PropertyChange("TitileImage"); } + } + private string imageQR; + /// + /// Image QR + /// + public string ImageQR + { + get { return imageQR; } + set { imageQR = value; PropertyChange("ImageQR"); } + } + + private string imageUserType= ResourceManager.GetNximagePathAdd("happy_member_pink.gif", CommonValue.PBdesignImagesPath); + /// + /// + /// + public string ImageUserType + { + get { return imageUserType; } + set { imageUserType = value; PropertyChange("ImageUserType"); } + } + + + private List headerText; + /// + /// Top Header Text + /// + public List HeaderText + { + get { return headerText; } + set { headerText = value; PropertyChange("HeaderText"); } + } + private List scanGuidText; + /// + /// Second Sub Header Text + /// + public List ScanGuidText + { + get { return scanGuidText; } + set { scanGuidText = value; PropertyChange("ScanGuidText"); } + } + private List processingGuide; + /// + /// Processing Guide Text + /// + public List ProcessingGuide + { + get { return processingGuide; } + set { processingGuide = value; PropertyChange("ProcessingGuide"); } + } + private List errorGuide; + /// + /// Error Guide Text + /// + public List ErrorGuide + { + get { return errorGuide; } + set { errorGuide = value; PropertyChange("ErrorGuide"); } + } + private List infoGuid1Text; + /// + /// Bootom first infomation text + /// + public List InfoGuid1Text + { + get { return infoGuid1Text; } + set { infoGuid1Text = value; PropertyChange("InfoGuid1Text"); } + } + private List infoGuid2Text; + /// + /// Bottom second infomation text + /// + public List InfoGuid2Text + { + get { return infoGuid2Text; } + set { infoGuid2Text = value; PropertyChange("InfoGuid2Text"); } + } + private string processingGIF; + /// + /// Processing GIF + /// + public string ProcessingGIF + { + get { return processingGIF; } + set { processingGIF = value; PropertyChange("ProcessingGIF"); } + } + private string errorImage; + /// + /// Read Barcode + /// + public string ErrorImage + { + get { return errorImage; } + set { errorImage = value; PropertyChange("ErrorImage"); } + } + public bool certifyStartVisible = false; + /// + /// 인증 시작 화면 Visible + /// + public bool CertifyStartVisible + { + get { return certifyStartVisible; } + set { certifyStartVisible = value; PropertyChange("CertifyStartVisible"); } + } + public bool certifyProcessingVisible = false; + /// + /// 인증 진행 화면 Visible + /// + public bool CertifyProcessingVisible + { + get { return certifyProcessingVisible; } + set { certifyProcessingVisible = value; PropertyChange("CertifyProcessingVisible"); } + } + public bool processingErrorVisible = false; + /// + /// 인증 오류 화면 Visible + /// + public bool ProcessingErrorVisible + { + get { return processingErrorVisible; } + set { processingErrorVisible = value; PropertyChange("ProcessingErrorVisible"); } + } + public bool certifySuccessVisible = false; + /// + /// 인증 완료 화면 Visible + /// + public bool CertifySuccessVisible + { + get { return certifySuccessVisible; } + set { certifySuccessVisible = value; PropertyChange("CertifySuccessVisible"); } + } + private List processingMessageText; + /// + /// Number Pad Input Guide Text + /// + public List ProcessingMessageText + { + get { return processingMessageText; } + set { processingMessageText = value; PropertyChange("ProcessingMessageText"); } + } + + private List numPadGuidText; + /// + /// Number Pad Input Guide Text + /// + public List NumPadGuidText + { + get { return numPadGuidText; } + set { numPadGuidText = value; PropertyChange("NumPadGuidText"); } + } + private List errorText; + /// + /// Process Error Text + /// + public List ErrorText + { + get { return errorText; } + set { errorText = value; PropertyChange("ErrorText"); } + } + private bool isErrorBlink = false; + /// + /// Is Error Text Blink + /// + public bool IsErrorBlink + { + get { return isErrorBlink; } + set { isErrorBlink = value; PropertyChange("IsErrorBlink"); } + } + private string formatedBarCode; + /// + /// Read Barcode Formated Text + /// + public string FormatedBarCode + { + get { return formatedBarCode; } + set { formatedBarCode = value; PropertyChange("FormatedBarCode"); } + } + private string readBarCode; + /// + /// Read Barcode + /// + public string ReadBarCode + { + get { return readBarCode; } + set { readBarCode = value; PropertyChange("ReadBarCode"); } + } + private bool showPhoneInput = false; + /// + /// Show Phone Input + /// + public bool ShowPhoneInput + { + get { return showPhoneInput; } + set { showPhoneInput = value; PropertyChange("ShowPhoneInput"); } + } + private List showPhoneButtonText; + /// + /// Number Pad Input Guide Text + /// + public List ShowPhoneButtonText + { + get { return showPhoneButtonText; } + set { showPhoneButtonText = value; PropertyChange("ShowPhoneButtonText"); } + } + + private string inputNumbers = string.Empty; + /// + /// Number Pad Input Number + /// + public string InputNumbers + { + get { return inputNumbers; } + set { inputNumbers = value; PropertyChange("InputNumbers"); } + } + + private string memberNameText = string.Empty; + /// + /// Number Pad Input Number + /// + public string MemberNameText + { + get { return memberNameText; } + set { memberNameText = value; PropertyChange("MemberNameText"); } + } + private string memberPointsText = string.Empty; + /// + /// Number Pad Input Number + /// + public string MemberPointsText + { + get { return memberPointsText; } + set { memberPointsText = value; PropertyChange("MemberPointsText"); } + } + + private double cancelButtonWidth = 650d; + /// + /// Cancel Button Width + /// + public double CancelButtonWidth + { + get { return cancelButtonWidth; } + set { cancelButtonWidth = value; PropertyChange("CancelButtonWidth"); } + } + private List cancelButtonText; + /// + /// Cancel Button Text + /// + public List CancelButtonText + { + get { return cancelButtonText; } + set { cancelButtonText = value; PropertyChange("CancelButtonText"); } + } + private List okButtonText; + /// + /// Ok Button Text + /// + public List OkButtonText + { + get { return okButtonText; } + set { okButtonText = value; PropertyChange("OkButtonText"); } + } + public bool oKButtonEnabled = false; + /// + /// OK Button enabled + /// + public bool OKButtonEnabled + { + get { return oKButtonEnabled; } + set { oKButtonEnabled = value; PropertyChange("OKButtonEnabled"); } + } + private double okButtonWidth = 650d; + /// + /// OK Button Width + /// + public double OKButtonWidth + { + get { return okButtonWidth; } + set { okButtonWidth = value; PropertyChange("OKButtonWidth"); } + } + public bool numPadInputVisible = false; + /// + /// OK Button enabled + /// + public bool NumPadInputVisible + { + get { return numPadInputVisible; } + set { numPadInputVisible = value; PropertyChange("NumPadInputVisible"); } + } + public bool numPadGuideVisible = true; + /// + /// OK Button enabled + /// + public bool NumPadGuideVisible + { + get { return numPadGuideVisible; } + set { numPadGuideVisible = value; PropertyChange("NumPadGuideVisible"); } + } + + public int numPadMaxLength; + /// + /// Number Pad Input Maxlength + /// + public int NumPadMaxLength + { + get { return numPadMaxLength; } + set { numPadMaxLength = value; PropertyChange("NumPadMaxLength"); } + } + + private List memberPointsHeaderText; + /// + /// Cancel Button Text + /// + public List MemberPointsHeaderText + { + get { return memberPointsHeaderText; } + set { memberPointsHeaderText = value; PropertyChange("MemberPointsHeaderText"); } + } + private string languageButttonImage; + /// + /// Read Barcode Formated Text + /// + public string LanguageButttonImage + { + get { return languageButttonImage; } + set { languageButttonImage = value; PropertyChange("LanguageButttonImage"); } + } + private bool languageButttonVisibel; + /// + /// Language Select Button Visible + /// + public bool LanguageButttonVisibel + { + get { return languageButttonVisibel; } + set { languageButttonVisibel = value; PropertyChange("LanguageButttonVisibel"); } + } + private CertifyWindowType certifyWindow = CertifyWindowType.CertifyStart; + /// + /// Current View Window + /// + public CertifyWindowType CertifyWindow + { + get { return certifyWindow; } + set { certifyWindow = value; PropertyChange("CertifyWindow"); } + } + private double popupWidth = 1300; + /// + /// Popup Whidth (For Calculate OK Button Width) + /// + public double PopupWidth + { + get { return popupWidth; } + set { popupWidth = value; PropertyChange("PopupWidth"); } + } + + private List bellButtonText; + /// + /// Barcode Scan Login Button Text + /// + public List BellButtonText + { + get { return bellButtonText; } + set { bellButtonText = value; PropertyChange("BellButtonText"); } + } + private List talkButtonText; + /// + /// Mobile Login Button Text + /// + public List TalkButtonText + { + get { return talkButtonText; } + set { talkButtonText = value; PropertyChange("TalkButtonText"); } + } + + /// + /// HappyPoint 인증 정보 + /// + public M_HappyPointReturn HappyPointReturn { get; set; } + + /// + /// OK Click Command + /// + public ICommand OkCommand { get; protected set; } + + /// + /// Cancel Click Command + /// + public ICommand CancelCommand { get; protected set; } + public ICommand SwitchPhoneCommand { get; protected set; } + + /// + /// Bell Button Command + /// + public ICommand BellButtonCommand { get; protected set; } + /// + /// Talk Button Command + /// + public ICommand TalkButtonCommand { get; protected set; } + + + public bool openOptionPopup = true; + /// + /// OK Button enabled + /// + public bool OpenOptionPopup + { + get { return openOptionPopup; } + set { openOptionPopup = value; PropertyChange("openOptionPopup"); } + } + /// + /// Selected Data + /// + public M_ItemData SelectedData { get; protected set; } + /// + /// Get Option Popup Return + /// + public M_PopupReturn GetOptionPopupReturn { get; set; } + private bool MemberProcessStart = false; + private posHappyPoint posHappyPoint = null; + private Task ProcessTask = null; + private string certifyKey = string.Empty; + + + private ParentPage _popupParentPage; + /// + /// Popup Parent Page + /// + public ParentPage PopupParentPage + { + get { return _popupParentPage; } + set { _popupParentPage = value; PropertyChange("PopupParentPage"); } + } + private string cashReceipButtonBackground; + /// + /// CashReceip Button Background + /// + public string CashReceipButtonBackground + { + get { return cashReceipButtonBackground; } + set { cashReceipButtonBackground = value; PropertyChange("CashReceipButtonBackground"); } + } + private string cashTypePersonButtonNormal; + /// + /// CashType Person Button Normal + /// + public string CashTypePersonButtonNormal + { + get { return cashTypePersonButtonNormal; } + set { cashTypePersonButtonNormal = value; PropertyChange("CashTypePersonButtonNormal"); } + } + private string cashTypePersonButtonDisable; + /// + /// CashType Person Button Disable + /// + public string CashTypePersonButtonDisable + { + get { return cashTypePersonButtonDisable; } + set { cashTypePersonButtonDisable = value; PropertyChange("CashTypePersonButtonDisable"); } + } + private bool cashTypePersonEnable = false; + /// + /// CashType Serson Enabled + /// + public bool CashTypePersonEnable + { + get { return cashTypePersonEnable; } + set { cashTypePersonEnable = value; PropertyChange("CashTypePersonEnable"); } + } + private string cashTypeCompanyButtonNormal; + /// + /// CashType Company Button Normal + /// + public string CashTypeCompanyButtonNormal + { + get { return cashTypeCompanyButtonNormal; } + set { cashTypeCompanyButtonNormal = value; PropertyChange("CashTypeCompanyButtonNormal"); } + } + private string cashTypeCompanyButtonDisable; + /// + /// CashType Company Button Disable + /// + public string CashTypeCompanyButtonDisable + { + get { return cashTypeCompanyButtonDisable; } + set { cashTypeCompanyButtonDisable = value; PropertyChange("CashTypeCompanyButtonDisable"); } + } + public bool cashTypeCompanyEnable = true; + /// + /// CashType Serson Enabled + /// + public bool CashTypeCompanyEnable + { + get { return cashTypeCompanyEnable; } + set { cashTypeCompanyEnable = value; PropertyChange("CashTypeCompanyEnable"); } + } + + private bool bellButtonEnable = false; + /// + /// Bell Button Enable + /// + public bool BellButtonEnable + { + get { return bellButtonEnable; } + set { bellButtonEnable = value; PropertyChange("BellButtonEnable"); } + } + private bool talkButtonEnable = true; + /// + /// Talk Button Enable + /// + public bool TalkButtonEnable + { + get { return talkButtonEnable; } + set { talkButtonEnable = value; PropertyChange("TalkButtonEnable"); } + } + #endregion + + #region [ Ctor ] + /// + /// Ctor + /// + public VmHappyPointCertify() + { + posDataService = new PosDataService(); + OkCommand = new Command(OkCommandHandler); + CancelCommand = new Command(CancelCommandHandler); + SwitchPhoneCommand = new Command(SwitchPhoneCommandHandler); + this.PropertyChanged += VmHappyPointCertify_PropertyChanged; + TitileImage = ResourceManager.GetNximagePathAdd("img_gif_barcode_happy.gif", CommonValue.PBdesignImagesPath); + ProcessingGIF = ResourceManager.GetNximagePathAdd("ic_alert_ing2.gif", CommonValue.PBdesignImagesPath); + ImageQR = ResourceManager.GetNximagePathAdd("Img_qr.png", CommonValue.PBdesignImagesPath); + ErrorImage = ResourceManager.GetNximagePathAdd("ic_alert_error.png", CommonValue.PBdesignImagesPath); + HeaderText = Languages.GetMessages("LBL0134"); + MemberPointsHeaderText = Languages.GetMessages("LBL0054"); + ProcessingMessageText = Languages.GetMessages("LBL0087"); + ProcessingGuide = Languages.GetMessages("LBL0017"); + ErrorGuide = Languages.GetMessages("LBL0017"); + ErrorText = new List(); + NumPadMaxLength = 11; + NumPadGuidText = Languages.GetMessages("LBL0091"); + ShowPhoneButtonText = new List + { + new M_Language { Type=SupportLanguageType.ko,LanguageData="전화번호로 로그인 >>" } + }; + ShowLanguageType = CommonValue.CommonLanguageType; + posHappyPoint = new posHappyPoint(); + CertifyWindow = CertifyWindowType.CertifyStart; + ShowPhoneInput = false; + + BellButtonCommand = new Command(BellButtonCommandHandler); + TalkButtonCommand = new Command(TalkButtonCommandHandler); + + + CashReceipButtonBackground = ResourceManager.GetNximagePathAdd("img_check_bg.png", CommonValue.PBdesignImagesPath); + CashTypePersonButtonNormal = ResourceManager.GetNximagePathAdd("btn_check_n.png", CommonValue.PBdesignImagesPath); + CashTypePersonButtonDisable = ResourceManager.GetNximagePathAdd("btn_check_s.png", CommonValue.PBdesignImagesPath); + CashTypeCompanyButtonNormal = ResourceManager.GetNximagePathAdd("btn_check_n.png", CommonValue.PBdesignImagesPath); + CashTypeCompanyButtonDisable = ResourceManager.GetNximagePathAdd("btn_check_s.png", CommonValue.PBdesignImagesPath); + } + /// + /// Dispose + /// + public new void Dispose() + { + this.TitileImage = null; + this.ProcessingGIF = string.Empty; + this.ErrorImage = string.Empty; + this.PropertyChanged -= VmHappyPointCertify_PropertyChanged; + if (posDataService != null) + { + posDataService.Dispose(); + posDataService = null; + } + if (ProcessTask != null) + { + ProcessTask.Dispose(); + ProcessTask = null; + } + if (posHappyPoint != null) + { + HappyPointRemoveEvents(); + posHappyPoint.Dispose(); + posHappyPoint = null; + } + base.Dispose(); + } + #endregion Ctor + + #region [ Method ] + private void AddItem2Basket(M_ItemData _itemData) + { + var option = new List(); + var itemCount = 1; + var unitPrice = _itemData.Price; + if (_itemData.IsOption) + { + SelectedData = _itemData; + GetOptionPopupReturn = null; + OpenOptionPopup = true; + try + { + if (GetOptionPopupReturn is M_PopupReturn popupReturn) + { + if (popupReturn.TimeOut) + { + IsTimeout = true; + option = null; + } + else + { + if (popupReturn.PopupArgs is M_OptionReturn getOption) + { + option = getOption.Options; + itemCount = getOption.ItemCount; + unitPrice = getOption.PriceWithOption; + } + else + { + option = null; + } + } + } + else + { + option = null; + } + } + catch + { + option = null; + } + finally + { + OpenOptionPopup = false; + } + if (option == null) return; + } + else + { + option = null; + itemCount = 1; + unitPrice = _itemData.Price; + } + var getNewOrderBasket = posDataService.AddItemToBasket(MemberOrderBasket + , itemCount + , unitPrice + , CommonValue.PBdesignImagesPath + , _itemData + , option); + if (getNewOrderBasket is ObservableCollection) MemberOrderBasket = getNewOrderBasket; + + } + + private void InitError() + { + LastAccessTime = DateTime.Now; + ErrorText = new List(); + IsErrorBlink = false; + } + private void HappyPointCreateEvents() + { + if (posHappyPoint != null) + { + posHappyPoint.ReadStart += PosHappyPoint_ReadStart; + posHappyPoint.ReadEnd += PosHappyPoint_ReadEnd; + posHappyPoint.ErrorEvent += PosHappyPoint_ErrorEvent; + posHappyPoint.ErrorMessageEvent += PosHappyPoint_ErrorMessageEvent; + } + } + private void HappyPointRemoveEvents() + { + if (posHappyPoint != null) + { + posHappyPoint.ReadStart -= PosHappyPoint_ReadStart; + posHappyPoint.ReadEnd -= PosHappyPoint_ReadEnd; + posHappyPoint.ErrorEvent -= PosHappyPoint_ErrorEvent; + posHappyPoint.ErrorMessageEvent -= PosHappyPoint_ErrorMessageEvent; + } + } + private void DoHappyPointCertify() + { + + if (posHappyPoint != null) + { + HappyPointCreateEvents(); + var processTask = new Task(() => posHappyPoint.StartCertifyProcessing(certifyKey)); + processTask.Start(); + processTask.Wait(); + HappyPointRemoveEvents(); + if (posHappyPoint.ProcessOK) + { + CertifyWindow = CertifyWindowType.CertifySuccess; + } + else + { + CertifyWindow = CertifyWindowType.ProcessingError; + } + TimerEnabled = true; + MemberProcessStart = false; + processTask = null; + } + + } + private void DoBarCodeHappyPointCertify() + { + InputNumbers = string.Empty; + FormatedBarCode = ReadBarCode.GetEncriptCardNo(); + certifyKey = ReadBarCode; + CertifyWindow = CertifyWindowType.CertifyProcessing; + } + + private void SetImageUserType() + { + if (HappyPointReturn is M_HappyPointReturn) + { + if (HappyPointReturn.IsCompanyMember) + { + ImageUserType = ResourceManager.GetNximagePathAdd("happy_member_spc.png", CommonValue.PBdesignImagesPath); + } + else + { + switch (HappyPointReturn.MemberLevel) + { + case HappyPointMemberLevel.VIP: + ImageUserType = ResourceManager.GetNximagePathAdd("happy_member_platinum.png", CommonValue.PBdesignImagesPath); + break; + case HappyPointMemberLevel.Gold: + ImageUserType = ResourceManager.GetNximagePathAdd("happy_member_gold.png", CommonValue.PBdesignImagesPath); + break; + default: //PINK && None => Pink + ImageUserType = ResourceManager.GetNximagePathAdd("happy_member_pink.png", CommonValue.PBdesignImagesPath); + break; + } + } + } + } + + private void SetOrderHistory(string _custCD) + { + if (!string.IsNullOrEmpty(_custCD)) + { + using (var dataHelper = new CommonDataHelper()) + { + string[] orderHistoryArray = dataHelper.GetCustBuyHistory(_custCD); + if (orderHistoryArray is string[] && orderHistoryArray.Length > 0) + { + List orderHistoryList = null; + if (orderHistoryArray is string[] && orderHistoryArray.Length > 0) + { + orderHistoryList = new List(); + var historyKeys = string.Format("'{0}'", string.Join("','", orderHistoryArray)); + var historyItems = dataHelper.GetItemsData(historyKeys); + //var historyItems = dataHelper.GetItemsData().GetRange(0,5); + if (historyItems is List) + { + foreach (var aItem in historyItems) + { + + aItem.BadgeHeight = 30; + aItem.BadgeOrientation = Orientation.Horizontal; + if (aItem.BadgeImages is List && aItem.BadgeImages.Count > 0) + { + var newBadgeImages = new List(); + foreach (var aBadgeImage in aItem.BadgeImages) + { + var strBadgeImage = ResourceManager.GetNximagePathAdd(aBadgeImage, CommonValue.PBdesignImagesPath); + if (!string.IsNullOrEmpty(strBadgeImage)) + { + newBadgeImages.Add(strBadgeImage); + } + } + aItem.BadgeImages = newBadgeImages; + } + if (aItem.Option is List && aItem.Option.Count > 0) + { + foreach (var aOptionGRP in aItem.Option) + { + if (aOptionGRP is M_ItemOptionGroup) + { + aOptionGRP.ImageFile = aOptionGRP.Index.Equals(0) + ? "ic_option_takein.png" + : aOptionGRP.Index.Equals(1) + ? "ic_option_shot.png" + : "ic_option_candle.png"; + } + } + } + var itemImage = ResourceManager.GetItemImage(aItem.ImageFile, CommonValue.ItemDefaultImage);//파일 없을 경우 DefaultImage로 + aItem.DataParameter = new M_AnimationButton + { + NormalBrush = itemImage, + DragCursorImage = itemImage, + DisableBrush = ResourceManager.GetNximagePathAdd("img_contents_soldout.png", CommonValue.PBdesignImagesPath), + Width = 60, + Height = 60, + Margin = new Thickness(80, 10, 95, 25), + BrushStretch = Stretch.Fill, + DragCursorHotSpot = HotSpotType.Center, + ClickAnimationType = ButtonAnimationType.None, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + Enabled = !aItem.IsSoldOut, + CircleText = string.Empty, + }; + aItem.BaseTextBlock = new M_TextBlock() + { + LanguageData = dataHelper.GetLaguageData("PROD", aItem.ItemCode), + TextSize = 20, + Width = 210, + Height = 50, + TextBrush = "Black", + TextFontFamily = "NanumSquare", + TextVerticalAlignment = VerticalAlignment.Center, + TextMargin = new Thickness(5, 0, 20, 0), + TextWeight = FontWeights.Bold, + TextWrapping = TextWrapping.Wrap + }; + aItem.AdditionTextBlock = new M_TextBlock() + { + LanguageData = new List + { + new M_Language{ Type = SupportLanguageType.ko, LanguageData = string.Format("₩{0:#,##0}", aItem.Price)}, + }, + TextSize = 26, + Width = 210, + Height = 30, + TextBrush = "#1469cc", + TextFontFamily = "NanumSquare", + TextVerticalAlignment = VerticalAlignment.Top, + TextMargin = new Thickness(5, 5, 20, 0), + TextWeight = FontWeights.Bold, + }; + orderHistoryList.Add(aItem.ItemCode); + } + } + MemberHistoryItems = new ObservableCollection(historyItems); + HappyPointReturn.OrderHistoryItems = orderHistoryList; + } + } + } + } + } + private void SetCertifyView() + { + if (ShowPhoneInput) + { + InputNumbers = string.Empty; + CancelButtonWidth = PopupWidth / 2; + OKButtonWidth = PopupWidth / 2; + OKButtonEnabled = false; + //OkButtonText = Languages.GetMessages("BTN0011"); + //CancelButtonText = Languages.GetMessages("BTN0016"); + //ShowPhoneButtonText = new List + // { + // new M_Language { Type=SupportLanguageType.ko,LanguageData="바코드 스캔 로그인 >>" } + // }; + TalkButtonEnable = false; + BellButtonEnable = true; + } + else + { + CancelButtonWidth = PopupWidth; + OKButtonWidth = 0d; + OKButtonEnabled = false; + //CancelButtonText = Languages.GetMessages("BTN0016"); + ShowPhoneButtonText = new List + { + new M_Language { Type=SupportLanguageType.ko,LanguageData="전화번호로 로그인 >>" } + }; + TalkButtonEnable = true; + BellButtonEnable = false; + + } + } + #endregion Method + + #region [ Event Handlers ] + + private void CancelCommandHandler(object obj) + { + TimerEnabled = false; + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + + private void OkCommandHandler(object obj) + { + switch (CertifyWindow) + { + case CertifyWindowType.CertifyStart: + certifyKey = InputNumbers; + CertifyWindow = CertifyWindowType.CertifyProcessing; + break; + case CertifyWindowType.ProcessingError: + CertifyWindow = CertifyWindowType.CertifyStart; + break; + case CertifyWindowType.CertifySuccess: + ReturnValue = new M_PopupReturn + { + OKAnswer = true, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = HappyPointReturn, + PopupSubArgs = MemberOrderBasket is ObservableCollection + ? MemberOrderBasket.ToList() + : null + }; + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + break; + } + + } + private void SwitchPhoneCommandHandler(object obj) + { + ShowPhoneInput = !ShowPhoneInput; + } + + private void PosHappyPoint_ErrorMessageEvent(string ErrorString) + { + ErrorText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = ErrorString.Replace("\n"," ").Replace("\r","") + }, + }; + IsErrorBlink = true; + + } + + private void PosHappyPoint_ErrorEvent(posHappyPoint.ErrorCode _errorCode) + { + //TODO: 공통에 에러 메세지 등록 핋요 + //ErrorText = Languages.GetMessages(_errorCode.ToString()); + + ErrorText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = _errorCode.ToString() + }, + }; + IsErrorBlink = true; + } + + private void PosHappyPoint_ReadStart(object sender) + { + MemberProcessStart = true; + TimerEnabled = false; + } + private void PosHappyPoint_ReadEnd(object sender) + { + if (sender is posHappyPoint getPosposHappyPoint) + { + if (getPosposHappyPoint.ProcessOK) + { + HappyPointReturn = new M_HappyPointReturn + { + MyHappyCoupons = getPosposHappyPoint.MyHappyCoupons, + IsFavoriteStore = getPosposHappyPoint.IsFavoriteStore, + IsCompanyMember = getPosposHappyPoint.IsCompanyMember, + MemberName = getPosposHappyPoint.MemberName, + MemberNumber = getPosposHappyPoint.MemberNumber, + MemberCode = getPosposHappyPoint.CertifyKey, + IsAppMamber = getPosposHappyPoint.IsAppMamber, + MemberLevel = getPosposHappyPoint.MemberLevel.StartsWith("VIP") + ? HappyPointMemberLevel.VIP + : getPosposHappyPoint.MemberLevel.StartsWith("G") + ? HappyPointMemberLevel.Gold + : HappyPointMemberLevel.Pink, + MemberPoint = getPosposHappyPoint.MemberPoint, + UseablePoint = getPosposHappyPoint.UseablePoint, + NeedPassword = getPosposHappyPoint.NeedPassword, + ReservePoint = getPosposHappyPoint.CanReservePoint, + IsCardNoUsed = getPosposHappyPoint.CertifyKey.Replace("=", "").Replace("@", "").Length.Equals(16) + }; + + // 포인트 멤버이름 : 핸드폰번호 시 [고객] + MemberNameText = HappyPointReturn.IsCardNoUsed ? HappyPointReturn.MemberName : "고객"; + MemberPointsHeaderText = HappyPointReturn.IsCardNoUsed ? Languages.GetMessages("LBL0054") : new List(); + + SetImageUserType(); + //주문이력 조회 기능 + //SetOrderHistory("1011175065"); //Test + if (HappyPointReturn.IsCardNoUsed) SetOrderHistory(HappyPointReturn.MemberNumber); //Prod + // 핸드폰 로그인 시 안보여도 포인트는 가지고 있어야 한다. + MemberPointsText = HappyPointReturn.IsCardNoUsed ? string.Format("{0}P", HappyPointReturn.MemberPoint.ToString("#,##0")) : string.Empty; + } + } + } + + private void VmHappyPointCertify_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + try + { + switch (e.PropertyName) + { + case "IsTimeout": + if (IsTimeout) + { + switch (CertifyWindow) + { + case CertifyWindowType.CertifyStart: + case CertifyWindowType.CertifySuccess: + case CertifyWindowType.ProcessingError: + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = true, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + break; + } + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + } + break; + case "ShowLanguageType": + switch (ShowLanguageType) + { + case SupportLanguageType.ko: + LanguageButttonImage = ResourceManager.GetNximagePathAdd("btn_language_kor.png", CommonValue.PBdesignImagesPath); + break; + case SupportLanguageType.en: + LanguageButttonImage = ResourceManager.GetNximagePathAdd("btn_language_eng.png", CommonValue.PBdesignImagesPath); + break; + case SupportLanguageType.ja: + LanguageButttonImage = ResourceManager.GetNximagePathAdd("btn_language_jap.png", CommonValue.PBdesignImagesPath); + break; + case SupportLanguageType.zh: + LanguageButttonImage = ResourceManager.GetNximagePathAdd("btn_language_chi.png", CommonValue.PBdesignImagesPath); + break; + } + break; + case "ShowPhoneInput": + SetCertifyView(); + break; + case "NumPadInputVisible": + NumPadGuideVisible = !NumPadInputVisible; + break; + case "InputNumbers": + NumPadInputVisible = InputNumbers.Length > 0; + if (NumPadInputVisible) + { + InitError(); + ReadBarCode = string.Empty; + } + OKButtonEnabled = InputNumbers.Length.Equals(10) || InputNumbers.Length.Equals(11); + break; + case "ReadBarCode": + if (!MemberProcessStart) + { + InitError(); + switch (ReadBarCode.Length) + { + case 17: + readBarCode = ReadBarCode.Substring(0, 16); + DoBarCodeHappyPointCertify(); + break; + case 16: + DoBarCodeHappyPointCertify(); + break; + default: + FormatedBarCode = string.Empty; + OKButtonEnabled = false; + break; + } + } + break; + case "CertifyWindow": + CertifyStartVisible = false; + CertifyProcessingVisible = false; + ProcessingErrorVisible = false; + CertifySuccessVisible = false; + switch (CertifyWindow) + { + case CertifyWindowType.CertifyStart: + CertifyStartVisible = true; + break; + case CertifyWindowType.CertifyProcessing: + CertifyProcessingVisible = true; + break; + case CertifyWindowType.ProcessingError: + ProcessingErrorVisible = true; + break; + case CertifyWindowType.CertifySuccess: + CertifySuccessVisible = true; + break; + } + break; + case "CertifyStartVisible": + case "PopupParentPage": + if (CertifyStartVisible) + { + if (PopupParentPage == ParentPage.PBPaymentsWindow) + { + HeaderText = Languages.GetMessages("LBL0135"); + ScanGuidText = Languages.GetMessages("LBL0136"); + OkButtonText = Languages.GetMessages("BTN0039"); + CancelButtonText = Languages.GetMessages("BTN0033"); + BellButtonText = new List() { new M_Language() { LanguageData = "바코드스캔", Type = SupportLanguageType.ko } }; + TalkButtonText = new List() { new M_Language() { LanguageData = "휴대폰", Type = SupportLanguageType.ko } }; + } + else + { + HeaderText = Languages.GetMessages("LBL0134"); + ScanGuidText = Languages.GetMessages("LBL0137"); + OkButtonText = Languages.GetMessages("BTN0011"); + CancelButtonText = Languages.GetMessages("BTN0016"); + BellButtonText = new List() { new M_Language() { LanguageData = "바코드스캔 로그인", Type = SupportLanguageType.ko } }; + TalkButtonText = new List() { new M_Language() { LanguageData = "휴대폰 로그인", Type = SupportLanguageType.ko } }; + } + + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + SetCertifyView(); + TimeOutSeconds = CommonValue.TimeOutSeconds; + } + break; + case "CertifyProcessingVisible": + if (CertifyProcessingVisible) + { + ScanGuidText = new List(); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + CancelButtonWidth = 0d; + OKButtonWidth = 0d; + LanguageButttonVisibel = false; + if (ProcessTask != null) ProcessTask.Wait(); + ProcessTask = new Task(DoHappyPointCertify); + ProcessTask.Start(); + } + break; + case "ProcessingErrorVisible": + if (ProcessingErrorVisible) + { + if (PopupParentPage == ParentPage.PBPaymentsWindow) + { + HeaderText = Languages.GetMessages("LBL0135"); + ScanGuidText = Languages.GetMessages("LBL0136"); + OkButtonText = Languages.GetMessages("BTN0007"); + CancelButtonText = Languages.GetMessages("BTN0033"); + BellButtonText = new List() { new M_Language() { LanguageData = "바코드스캔", Type = SupportLanguageType.ko } }; + TalkButtonText = new List() { new M_Language() { LanguageData = "휴대폰", Type = SupportLanguageType.ko } }; + } + else + { + HeaderText = Languages.GetMessages("LBL0134"); + ScanGuidText = Languages.GetMessages("LBL0137"); + OkButtonText = Languages.GetMessages("BTN0007"); + CancelButtonText = Languages.GetMessages("BTN0033"); + BellButtonText = new List() { new M_Language() { LanguageData = "바코드스캔 로그인", Type = SupportLanguageType.ko } }; + TalkButtonText = new List() { new M_Language() { LanguageData = "휴대폰 로그인", Type = SupportLanguageType.ko } }; + } + + ScanGuidText = new List(); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + CancelButtonWidth = PopupWidth / 2; + OKButtonWidth = PopupWidth / 2; + OKButtonEnabled = true; + TimeOutSeconds = 10d; + LanguageButttonVisibel = false; + } + break; + case "CertifySuccessVisible": + if (CertifySuccessVisible) + { + if (PopupParentPage == ParentPage.PBPaymentsWindow) + { + HeaderText = Languages.GetMessages("LBL0135"); + OkButtonText = Languages.GetMessages("BTN0039"); + ScanGuidText = Languages.GetMessages("LBL0141"); + } + else + { + HeaderText = Languages.GetMessages("LBL0134"); + OkButtonText = Languages.GetMessages("BTN0039"); + ScanGuidText = Languages.GetMessages("LBL0141"); + } + + CancelButtonWidth = 0d; + OKButtonWidth = PopupWidth; + OKButtonEnabled = true; + TimeOutSeconds = CommonValue.TimeOutSeconds; + LanguageButttonVisibel = false; + } + break; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "VmHappyPointCertify_PropertyChanged()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + private void BellButtonCommandHandler(object obj) + { + + //BellButtonEnable = false; + ShowPhoneInput = !ShowPhoneInput; + + } + private void TalkButtonCommandHandler(object obj) + { + //TalkButtonEnable = false; + ShowPhoneInput = !ShowPhoneInput; + } + + #endregion Event Handlers + + + } + +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmHappyPointCoupon.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmHappyPointCoupon.cs new file mode 100644 index 0000000..18e90e5 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmHappyPointCoupon.cs @@ -0,0 +1,745 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Threading; +using System.Windows; +using System.Windows.Input; +using System.Windows.Threading; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Payments; +namespace SPC.Kiosk.Popup.ViewModel +{ + /// + /// HappyPointUsing.xaml에 대한 ViewModel + /// + public class VmHappyPointCoupon : PopupViewModelBase + { + #region [ Members ] + private enum ProcessingType + { + SingleCoupon, + CouponUsing + } + private ProcessingType ProcessType { get; set; } = ProcessingType.SingleCoupon; + private List happyAppCoupons = new List(); + /// + /// Happy App Coupons + /// + public List HappyAppCoupons + { + get { return happyAppCoupons; } + set { happyAppCoupons = value; PropertyChange("HappyAppCoupons"); } + } + private string titileImage; + /// + /// Barcode Scan Image + /// + public string TitileImage + { + get { return titileImage; } + set { titileImage = value; PropertyChange("TitileImage"); } + } + + private List headerText; + /// + /// Top Header Text (first Grid) + /// + public List HeaderText + { + get { return headerText; } + set { headerText = value; PropertyChange("HeaderText"); } + } + private List scanGuidText; + /// + /// Second Header Text (first Grid) + /// + public List ScanGuidText + { + get { return scanGuidText; } + set { scanGuidText = value; PropertyChange("ScanGuidText"); } + } + private List infoGuid1Text; + /// + /// Bootom first infomation text (first Grid) + /// + public List InfoGuid1Text + { + get { return infoGuid1Text; } + set { infoGuid1Text = value; PropertyChange("InfoGuid1Text"); } + } + private List infoGuid2Text; + /// + /// Bottom second infomation text (first Grid) + /// + public List InfoGuid2Text + { + get { return infoGuid2Text; } + set { infoGuid2Text = value; PropertyChange("InfoGuid2Text"); } + } + private string processingGIF; + /// + /// Processing GIF + /// + public string ProcessingGIF + { + get { return processingGIF; } + set { processingGIF = value; PropertyChange("ProcessingGIF"); } + } + private string errorImage; + /// + /// Error Icon + /// + public string ErrorImage + { + get { return errorImage; } + set { errorImage = value; PropertyChange("ErrorImage"); } + } + private string successImage; + /// + /// Sucess Icon + /// + public string SuccessImage + { + get { return successImage; } + set { successImage = value; PropertyChange("SuccessImage"); } + } + public bool couponStartVisible = false; + /// + /// 인증 시작 화면 Visible + /// + public bool CouponStartVisible + { + get { return couponStartVisible; } + set { couponStartVisible = value; PropertyChange("CouponStartVisible"); } + } + public bool couponUsingVisible = false; + /// + /// Point Using Window Visible + /// + public bool CouponUsingVisible + { + get { return couponUsingVisible; } + set { couponUsingVisible = value; PropertyChange("CouponUsingVisible"); } + } + public bool processingVisible = false; + /// + /// 처리 진행 화면 Visible + /// + public bool ProcessingVisible + { + get { return processingVisible; } + set { processingVisible = value; PropertyChange("ProcessingVisible"); } + } + public bool processingErrorVisible = false; + /// + /// 인증 오류 화면 Visible + /// + public bool ProcessingErrorVisible + { + get { return processingErrorVisible; } + set { processingErrorVisible = value; PropertyChange("ProcessingErrorVisible"); } + } + public bool couponSuccessVisible = false; + /// + /// 인증 완료 화면 Visible + /// + public bool CouponSuccessVisible + { + get { return couponSuccessVisible; } + set { couponSuccessVisible = value; PropertyChange("CouponSuccessVisible"); } + } + private List pointPadGuidText; + /// + /// Point Pad Input Guide Text + /// + public List PointPadGuidText + { + get { return pointPadGuidText; } + set { pointPadGuidText = value; PropertyChange("PointPadGuidText"); } + } + private List totalPayHeaderText; + /// + /// Payments Total Header Text + /// + public List TotalPayHeaderText + { + get { return totalPayHeaderText; } + set { totalPayHeaderText = value; PropertyChange("TotalPayHeaderText"); } + } + private List queryPointsHeaderText; + /// + /// Member Point Header Text + /// + public List QueryPointsHeaderText + { + get { return queryPointsHeaderText; } + set { queryPointsHeaderText = value; PropertyChange("QueryPointsHeaderText"); } + } + + private List processingMessageText; + /// + /// Number Pad Input Guide Text + /// + public List ProcessingMessageText + { + get { return processingMessageText; } + set { processingMessageText = value; PropertyChange("ProcessingMessageText"); } + } + private List processingGuide; + /// + /// Processing Guide Text + /// + public List ProcessingGuide + { + get { return processingGuide; } + set { processingGuide = value; PropertyChange("ProcessingGuide"); } + } + private List errorGuide; + /// + /// Error Guide Text + /// + public List ErrorGuide + { + get { return errorGuide; } + set { errorGuide = value; PropertyChange("ErrorGuide"); } + } + private List successText; + /// + /// Sucess Guide Text + /// + public List SuccessText + { + get { return successText; } + set { successText = value; PropertyChange("SuccessText"); } + } + private double payments; + /// + /// Payments Total + /// + public double Payments + { + get { return payments; } + set { payments = value; PropertyChange("Payments"); } + } + private List errorText; + /// + /// Error Text + /// + public List ErrorText + { + get { return errorText; } + set { errorText = value; PropertyChange("ErrorText"); } + } + private bool isErrorBlink = false; + /// + /// Is Error Text Blink + /// + public bool IsErrorBlink + { + get { return isErrorBlink; } + set { isErrorBlink = value; PropertyChange("IsErrorBlink"); } + } + private string formatedBarCode; + /// + /// Read Barcoe Formated Text + /// + public string FormatedBarCode + { + get { return formatedBarCode; } + set { formatedBarCode = value; PropertyChange("FormatedBarCode"); } + } + private string readBarCode; + /// + /// Read BarCode + /// + public string ReadBarCode + { + get { return readBarCode; } + set { readBarCode = value; PropertyChange("ReadBarCode"); } + } + private List cancelButtonText; + /// + /// Cancel Button Text + /// + public List CancelButtonText + { + get { return cancelButtonText; } + set { cancelButtonText = value; PropertyChange("CancelButtonText"); } + } + private double cancelButtonWidth = 270d; + /// + /// Cancel Button Width + /// + public double CancelButtonWidth + { + get { return cancelButtonWidth; } + set { cancelButtonWidth = value; PropertyChange("CancelButtonWidth"); } + } + private double okButtonWidth = 270d; + /// + /// OK Button Width + /// + public double OKButtonWidth + { + get { return okButtonWidth; } + set { okButtonWidth = value; PropertyChange("OKButtonWidth"); } + } + private List okButtonText; + /// + /// OK Button Text + /// + public List OkButtonText + { + get { return okButtonText; } + set { okButtonText = value; PropertyChange("OkButtonText"); } + } + public bool oKButtonEnabled = false; + /// + /// OK Button Enabled + /// + public bool OKButtonEnabled + { + get { return oKButtonEnabled; } + set { oKButtonEnabled = value; PropertyChange("OKButtonEnabled"); } + } + + private HappyCouponWindowType happyCouponWindow = HappyCouponWindowType.CouponStart; + /// + /// Current View Window + /// + public HappyCouponWindowType HappyCouponWindow + { + get { return happyCouponWindow; } + set { happyCouponWindow = value; PropertyChange("HappyCouponWindow"); } + } + private double popupWidth = 1300; + /// + /// Popup Whidth (For Calculate OK Button Width) + /// + public double PopupWidth + { + get { return popupWidth; } + set { popupWidth = value; PropertyChange("PopupWidth"); } + } + private M_HappyPointReturn happyPointReturn; + /// + /// HappyPoint 인증 정보 + /// + public M_HappyPointReturn HappyPointReturn + { + get { return happyPointReturn; } + set { happyPointReturn = value; PropertyChange("HappyPointReturn"); } + } + /// + /// OK Click Command + /// + public ICommand OkCommand { get; protected set; } + /// + /// Cancel Click Command + /// + public ICommand CancelCommand { get; protected set; } + /// + /// Coupon Selectd + /// + public ICommand CouponCommand { get; protected set; } + private bool ProcessStart = false; + private posHappyPoint posHappyPoint = null; + private Task ProcessTask = null; + private string certifyKey = string.Empty; + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public VmHappyPointCoupon() + { + OkCommand = new Command(OkCommandHandler); + CancelCommand = new Command(CancelCommandHandler); + CouponCommand = new Command(CouponCommandHandler); + this.PropertyChanged += VmHappyPointCoupon_PropertyChanged; + TitileImage = ResourceManager.GetNximagePathAdd("img_gif_barcode_happy.gif", CommonValue.PBdesignImagesPath); + ProcessingGIF = ResourceManager.GetNximagePathAdd("ic_alert_ing2.gif", CommonValue.PBdesignImagesPath); + ErrorImage = ResourceManager.GetNximagePathAdd("ic_alert_error.png", CommonValue.PBdesignImagesPath); + SuccessImage = ResourceManager.GetNximagePathAdd("ic_alert_check.png", CommonValue.PBdesignImagesPath); + ErrorText = new List(); + OkButtonText = Languages.GetMessages("BTN0024"); + CancelButtonText = Languages.GetMessages("BTN0033"); + HeaderText = Languages.GetMessages("LBL0133"); + ProcessingMessageText = Languages.GetMessages("LBL0087"); + ProcessingGuide = Languages.GetMessages("LBL0028"); + ErrorGuide = Languages.GetMessages("LBL0028"); + posHappyPoint = new posHappyPoint(); + + } + + + public new void Dispose() + { + TitileImage = string.Empty; + ProcessingGIF = string.Empty; + ErrorImage = string.Empty; + this.PropertyChanged -= VmHappyPointCoupon_PropertyChanged; + if (ProcessTask != null) + { + ProcessTask.Dispose(); + ProcessTask = null; + } + if (posHappyPoint != null) + { + HappyPointRemoveEvents(); + posHappyPoint.Dispose(); + posHappyPoint = null; + } + base.Dispose(); + } + #endregion Ctor + + #region [ Methods ] + private void TestDelay() + { + Thread.Sleep(3000); + } + private void HappyPointCreateEvents() + { + if (posHappyPoint != null) + { + posHappyPoint.ReadStart += PosHappyPoint_ReadStart; + posHappyPoint.ReadEnd += PosHappyPoint_ReadEnd; + posHappyPoint.ErrorEvent += PosHappyPoint_ErrorEvent; + posHappyPoint.ErrorMessageEvent += PosHappyPoint_ErrorMessageEvent; + } + } + private void HappyPointRemoveEvents() + { + if (posHappyPoint != null) + { + posHappyPoint.ReadStart -= PosHappyPoint_ReadStart; + posHappyPoint.ReadEnd -= PosHappyPoint_ReadEnd; + posHappyPoint.ErrorEvent -= PosHappyPoint_ErrorEvent; + posHappyPoint.ErrorMessageEvent -= PosHappyPoint_ErrorMessageEvent; + } + } + private void DoSingleCouponCertify() + { + + HappyPointCreateEvents(); + var processTask = new Task(() => posHappyPoint.StartCouponProcessing(certifyKey,Payments)); + processTask.Start(); + processTask.Wait(); + HappyPointRemoveEvents(); + if (posHappyPoint.ProcessOK) + { + HappyCouponWindow = HappyCouponWindowType.CouponSuccess; + } + else + { + HappyCouponWindow = HappyCouponWindowType.ProcessingError; + } + processTask = null; + TimerEnabled = true; + ProcessStart = false; + } + + + #endregion Methods + + #region [ Event Handlers ] + private void CouponCommandHandler(object obj) + { + if (obj is M_HappyCoupon selectCoupon) + { + //var newHappyAppCoupons = HappyAppCoupons; + //var selectNumber = selectCoupon.Number; + //var selectItem = newHappyAppCoupons.Find(r => r.Number.Equals(selectNumber)); + //if (selectCoupon.IsUsed) + //{ + // certifyKey = string.Empty; + // selectItem.IsUsed = false; + //} + //else + //{ + // if (newHappyAppCoupons.Where(r => r.IsUsed).Count().Equals(0)) + // { + // certifyKey = selectItem.Number; + // selectItem.IsUsed = true; + // } + //} + //HappyAppCoupons = newHappyAppCoupons; + if (selectCoupon.IsUsed) certifyKey = selectCoupon.Number; + OKButtonEnabled = HappyAppCoupons.Where(r => r.IsUsed).Count() > 0; + } + } + + private void CancelCommandHandler(object obj) + { + TimerEnabled = false; + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = HappyPointReturn is M_HappyPointReturn && HappyPointReturn.ReservePoint + ? HappyPointReturn + : null + }; + CanWindowClose = true; + } + private void OkCommandHandler(object obj) + { + switch (HappyCouponWindow) + { + case HappyCouponWindowType.CouponUsing: + HappyCouponWindow = HappyCouponWindowType.Processing; + break; + case HappyCouponWindowType.ProcessingError: + switch (ProcessType) + { + case ProcessingType.SingleCoupon: + HappyCouponWindow = HappyCouponWindowType.CouponStart; + break; + case ProcessingType.CouponUsing: + HappyCouponWindow = HappyCouponWindowType.CouponUsing; + break; + } + break; + case HappyCouponWindowType.CouponSuccess: + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + break; + } + } + + + private void PosHappyPoint_ErrorMessageEvent(string ErrorString) + { + ErrorText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = ErrorString.Replace("\n"," ").Replace("\r","") + }, + }; + IsErrorBlink = true; + HappyCouponWindow = HappyCouponWindowType.ProcessingError; + } + + private void PosHappyPoint_ErrorEvent(posHappyPoint.ErrorCode _errorCode) + { + //TODO: 공통에 에러 메세지 등록 필요 + //ErrorText = Languages.GetMessages(_errorCode.ToString()); + + ErrorText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = _errorCode.ToString() + }, + }; + IsErrorBlink = true; + HappyCouponWindow = HappyCouponWindowType.ProcessingError; + } + + private void PosHappyPoint_ReadStart(object sender) + { + TimerEnabled = false; + ProcessStart = true; + } + + private void PosHappyPoint_ReadEnd(object sender) + { + ProcessStart = false; + try + { + if (sender is posHappyPoint getPosposHappyPoint) + { + if (getPosposHappyPoint.ProcessOK) + { + ReturnValue = new M_PopupReturn + { + OKAnswer = true, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = getPosposHappyPoint.UsedCoupon + }; + } + } + } + catch + { + throw; + } + finally + { + TimerEnabled = true; + } + + } + private void VmHappyPointCoupon_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + try + { + switch (e.PropertyName) + { + case "IsTimeout": + if (IsTimeout) + { + switch (HappyCouponWindow) + { + case HappyCouponWindowType.CouponStart: + case HappyCouponWindowType.CouponUsing: + case HappyCouponWindowType.ProcessingError: + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = true, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + break; + } + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + } + break; + case "HappyPointReturn": + if (HappyPointReturn is M_HappyPointReturn + && HappyPointReturn.MyHappyCoupons is List) + { + HappyAppCoupons = HappyPointReturn.MyHappyCoupons; + } + break; + case "HappyCouponWindow": + CouponStartVisible = false; + CouponUsingVisible = false; + ProcessingVisible = false; + ProcessingErrorVisible = false; + CouponSuccessVisible = false; + switch (HappyCouponWindow) + { + case HappyCouponWindowType.CouponStart: + CouponStartVisible = true; + break; + case HappyCouponWindowType.CouponUsing: + CouponUsingVisible = true; + break; + case HappyCouponWindowType.Processing: + ProcessingVisible = true; + break; + case HappyCouponWindowType.ProcessingError: + ProcessingErrorVisible = true; + break; + case HappyCouponWindowType.CouponSuccess: + CouponSuccessVisible = true; + break; + } + break; + case "CouponStartVisible": + if (CouponStartVisible) + { + ScanGuidText = Languages.GetMessages("LBL0051"); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + ProcessType = ProcessingType.SingleCoupon; + CancelButtonWidth = PopupWidth; + OKButtonWidth = 0d; + OKButtonEnabled = false; + CancelButtonText = Languages.GetMessages("BTN0033"); + TimeOutSeconds = CommonValue.TimeOutSeconds; + } + break; + case "CouponUsingVisible": + if (CouponUsingVisible) + { + ScanGuidText = Languages.GetMessages("LBL0062"); + InfoGuid1Text = new List(); + InfoGuid2Text = Languages.GetMessages("LBL0016"); + ProcessType = ProcessingType.CouponUsing; + CancelButtonWidth = PopupWidth / 2; + OKButtonWidth = PopupWidth / 2; + OKButtonEnabled = false; + OkButtonText = Languages.GetMessages("BTN0024"); + CancelButtonText = Languages.GetMessages("BTN0033"); + TimeOutSeconds = CommonValue.TimeOutSeconds; + } + break; + case "ProcessingVisible": + if (ProcessingVisible) + { + ScanGuidText = new List(); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + CancelButtonWidth = 0d; + OKButtonWidth = 0d; + if (ProcessTask != null) ProcessTask.Wait(); + ProcessTask = new Task(DoSingleCouponCertify); + ProcessTask.Start(); + } + break; + case "ProcessingErrorVisible": + if (ProcessingErrorVisible) + { + ScanGuidText = Languages.GetMessages("LBL0077"); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + + CancelButtonWidth = PopupWidth / 2; + OKButtonWidth = PopupWidth / 2; + OKButtonEnabled = true; + OkButtonText = Languages.GetMessages("BTN0007"); + CancelButtonText = Languages.GetMessages("BTN0033"); + TimeOutSeconds = 10d; + } + break; + case "CouponSuccessVisible": + if (CouponSuccessVisible) + { + ScanGuidText = new List(); + SuccessText = Languages.GetMessages("LBL0093"); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + CancelButtonWidth = 0d; + OkButtonText = Languages.GetMessages("BTN0039"); + OKButtonWidth = PopupWidth; + OKButtonEnabled = true; + TimeOutSeconds = 5d; + } + break; + case "ReadBarCode": + if (!ProcessStart) + { + switch (ReadBarCode.Length) + { + case 11: + case 12: + certifyKey = ReadBarCode.Substring(0, 11); + FormatedBarCode = ReadBarCode.GetEncriptCardNo(); + HappyCouponWindow = HappyCouponWindowType.Processing; + break; + + default: + FormatedBarCode = string.Empty; + OKButtonEnabled = false; + break; + } + } + break; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "VmHappyPointCoupon_PropertyChanged()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + #endregion Event Handlers + + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmHappyPointUsing.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmHappyPointUsing.cs new file mode 100644 index 0000000..be15e36 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmHappyPointUsing.cs @@ -0,0 +1,1001 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Threading; +using System.Windows; +using System.Windows.Input; +using System.Windows.Threading; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Payments; +namespace SPC.Kiosk.Popup.ViewModel +{ + /// + /// HappyPointUsing.xaml에 대한 ViewModel + /// + public class VmHappyPointUsing : PopupViewModelBase + { + #region [ Members ] + private enum ProcessingType + { + Certify, + PointUsing + } + private ProcessingType ProcessType { get; set; } = ProcessingType.Certify; + private string titileImage; + /// + /// Barcode Scan Image + /// + public string TitileImage + { + get { return titileImage; } + set { titileImage = value; PropertyChange("TitileImage"); } + } + private string wonIconImage; + /// + /// Won Icon Image + /// + public string WonIconImage + { + get { return wonIconImage; } + set { wonIconImage = value; PropertyChange("WonIconImage"); } + } + private string pointImage; + /// + /// Point Using Title Image + /// + public string PointImage + { + get { return pointImage; } + set { pointImage = value; PropertyChange("PointImage"); } + } + private string allUseNoramlBrush; + /// + /// All Use Button Normal Brush + /// + public string AllUseNoramlBrush + { + get { return allUseNoramlBrush; } + set { allUseNoramlBrush = value; PropertyChange("AllUseNoramlBrush"); } + } + private string allUseSwitchOnBrush; + /// + /// All Use Button Switch On Brush + /// + public string AllUseSwitchOnBrush + { + get { return allUseSwitchOnBrush; } + set { allUseSwitchOnBrush = value; PropertyChange("AllUseSwitchOnBrush"); } + } + public bool allUseSwitch = false; + /// + /// All Use Button Switch + /// + public bool AllUseSwitch + { + get { return allUseSwitch; } + set { allUseSwitch = value; PropertyChange("AllUseSwitch"); } + } + private List headerText; + /// + /// Top Header Text (first Grid) + /// + public List HeaderText + { + get { return headerText; } + set { headerText = value; PropertyChange("HeaderText"); } + } + private List scanGuidText; + /// + /// Second Header Text (first Grid) + /// + public List ScanGuidText + { + get { return scanGuidText; } + set { scanGuidText = value; PropertyChange("ScanGuidText"); } + } + private List infoGuid1Text; + /// + /// Bootom first infomation text (first Grid) + /// + public List InfoGuid1Text + { + get { return infoGuid1Text; } + set { infoGuid1Text = value; PropertyChange("InfoGuid1Text"); } + } + private List infoGuid2Text; + /// + /// Bottom second infomation text (first Grid) + /// + public List InfoGuid2Text + { + get { return infoGuid2Text; } + set { infoGuid2Text = value; PropertyChange("InfoGuid2Text"); } + } + private string processingGIF; + /// + /// Processing GIF + /// + public string ProcessingGIF + { + get { return processingGIF; } + set { processingGIF = value; PropertyChange("ProcessingGIF"); } + } + private string errorImage; + /// + /// Error Icon + /// + public string ErrorImage + { + get { return errorImage; } + set { errorImage = value; PropertyChange("ErrorImage"); } + } + private string successImage; + /// + /// Sucess Icon + /// + public string SuccessImage + { + get { return successImage; } + set { successImage = value; PropertyChange("SuccessImage"); } + } + public bool certifyStartVisible = false; + /// + /// 인증 시작 화면 Visible + /// + public bool CertifyStartVisible + { + get { return certifyStartVisible; } + set { certifyStartVisible = value; PropertyChange("CertifyStartVisible"); } + } + public bool pointUsingVisible = false; + /// + /// Point Using Window Visible + /// + public bool PointUsingVisible + { + get { return pointUsingVisible; } + set { pointUsingVisible = value; PropertyChange("PointUsingVisible"); } + } + public bool processingVisible = false; + /// + /// 처리 진행 화면 Visible + /// + public bool ProcessingVisible + { + get { return processingVisible; } + set { processingVisible = value; PropertyChange("ProcessingVisible"); } + } + public bool processingErrorVisible = false; + /// + /// 인증 오류 화면 Visible + /// + public bool ProcessingErrorVisible + { + get { return processingErrorVisible; } + set { processingErrorVisible = value; PropertyChange("ProcessingErrorVisible"); } + } + public bool certifySuccessVisible = false; + /// + /// 인증 완료 화면 Visible + /// + public bool CertifySuccessVisible + { + get { return certifySuccessVisible; } + set { certifySuccessVisible = value; PropertyChange("CertifySuccessVisible"); } + } + private List pointPadGuidText; + /// + /// Point Pad Input Guide Text + /// + public List PointPadGuidText + { + get { return pointPadGuidText; } + set { pointPadGuidText = value; PropertyChange("PointPadGuidText"); } + } + private List totalPayHeaderText; + /// + /// Payments Total Header Text + /// + public List TotalPayHeaderText + { + get { return totalPayHeaderText; } + set { totalPayHeaderText = value; PropertyChange("TotalPayHeaderText"); } + } + private List queryPointsHeaderText; + /// + /// Member Point Header Text + /// + public List QueryPointsHeaderText + { + get { return queryPointsHeaderText; } + set { queryPointsHeaderText = value; PropertyChange("QueryPointsHeaderText"); } + } + + private List processingMessageText; + /// + /// Number Pad Input Guide Text + /// + public List ProcessingMessageText + { + get { return processingMessageText; } + set { processingMessageText = value; PropertyChange("ProcessingMessageText"); } + } + private List processingGuide; + /// + /// Processing Guide Text + /// + public List ProcessingGuide + { + get { return processingGuide; } + set { processingGuide = value; PropertyChange("ProcessingGuide"); } + } + private List errorGuide; + /// + /// Error Guide Text + /// + public List ErrorGuide + { + get { return errorGuide; } + set { errorGuide = value; PropertyChange("ErrorGuide"); } + } + private List successText; + /// + /// Sucess Guide Text + /// + public List SuccessText + { + get { return successText; } + set { successText = value; PropertyChange("SuccessText"); } + } + private double queryPoints; + /// + /// Member Points + /// + public double QueryPoints + { + get { return queryPoints; } + set { queryPoints = value; PropertyChange("QueryPoints"); } + } + private double usingPoints; + /// + /// Using Points + /// + public double UsingPoints + { + get { return usingPoints; } + set { usingPoints = value; PropertyChange("UsingPoints"); } + } + private double payments; + /// + /// Payments Total + /// + public double Payments + { + get { return payments; } + set { payments = value; PropertyChange("Payments"); } + } + private List errorText; + /// + /// Error Text + /// + public List ErrorText + { + get { return errorText; } + set { errorText = value; PropertyChange("ErrorText"); } + } + private bool isErrorBlink = false; + /// + /// Is Error Text Blink + /// + public bool IsErrorBlink + { + get { return isErrorBlink; } + set { isErrorBlink = value; PropertyChange("IsErrorBlink"); } + } + private string formatedBarCode; + /// + /// Read Barcoe Formated Text + /// + public string FormatedBarCode + { + get { return formatedBarCode; } + set { formatedBarCode = value; PropertyChange("FormatedBarCode"); } + } + private string readBarCode; + /// + /// Read BarCode + /// + public string ReadBarCode + { + get { return readBarCode; } + set { readBarCode = value; PropertyChange("ReadBarCode"); } + } + private string inputPoints = string.Empty; + /// + /// Input Using Point Text + /// + public string InputPoints + { + get { return inputPoints; } + set { inputPoints = value; PropertyChange("InputPoints"); } + } + public bool numPadInputVisible = false; + /// + /// Number Pad Points Visible + /// + public bool NumPadInputVisible + { + get { return numPadInputVisible; } + set { numPadInputVisible = value; PropertyChange("NumPadInputVisible"); } + } + public bool numPadGuideVisible = true; + /// + /// Nummber Pad Guid Visible + /// + public bool NumPadGuideVisible + { + get { return numPadGuideVisible; } + set { numPadGuideVisible = value; PropertyChange("NumPadGuideVisible"); } + } + private List allUseButtonText; + /// + /// All Point Using Button text + /// + public List AllUseButtonText + { + get { return allUseButtonText; } + set { allUseButtonText = value; PropertyChange("AllUseButtonText"); } + } + private List cancelButtonText; + /// + /// Cancel Button Text + /// + public List CancelButtonText + { + get { return cancelButtonText; } + set { cancelButtonText = value; PropertyChange("CancelButtonText"); } + } + private double cancelButtonWidth = 270d; + /// + /// Cancel Button Width + /// + public double CancelButtonWidth + { + get { return cancelButtonWidth; } + set { cancelButtonWidth = value; PropertyChange("CancelButtonWidth"); } + } + private double okButtonWidth = 270d; + /// + /// OK Button Width + /// + public double OKButtonWidth + { + get { return okButtonWidth; } + set { okButtonWidth = value; PropertyChange("OKButtonWidth"); } + } + private List okButtonText; + /// + /// OK Button Text + /// + public List OkButtonText + { + get { return okButtonText; } + set { okButtonText = value; PropertyChange("OkButtonText"); } + } + public bool oKButtonEnabled = false; + /// + /// OK Button Enabled + /// + public bool OKButtonEnabled + { + get { return oKButtonEnabled; } + set { oKButtonEnabled = value; PropertyChange("OKButtonEnabled"); } + } + private int pointPadMaxLength; + /// + /// Point Pad Input Max Length + /// + public int PointPadMaxLength + { + get { return pointPadMaxLength; } + set { pointPadMaxLength = value; PropertyChange("PointPadMaxLength"); } + } + private string certifyPassword = string.Empty; + public string CertifyPassword + { + get { return certifyPassword; } + set { certifyPassword = value; PropertyChange("CertifyPassword"); } + } + public bool isOpenPasswordWindow = false; + /// + /// Password Window Open + /// + public bool IsOpenPasswordWindow + { + get { return isOpenPasswordWindow; } + set { isOpenPasswordWindow = value; PropertyChange("IsOpenPasswordWindow"); } + } + + private PointUsingWindowType pointUsingWindow = PointUsingWindowType.CertifyStart; + /// + /// Current View Window + /// + public PointUsingWindowType PointUsingWindow + { + get { return pointUsingWindow; } + set { pointUsingWindow = value; PropertyChange("PointUsingWindow"); } + } + private double popupWidth = 1300; + /// + /// Popup Whidth (For Calculate OK Button Width) + /// + public double PopupWidth + { + get { return popupWidth; } + set { popupWidth = value; PropertyChange("PopupWidth"); } + } + private M_HappyPointReturn happyPointReturn; + /// + /// HappyPoint 인증 정보 + /// + public M_HappyPointReturn HappyPointReturn + { + get { return happyPointReturn; } + set { happyPointReturn = value; PropertyChange("HappyPointReturn"); } + } + /// + /// OK Click Command + /// + public ICommand OkCommand { get; protected set; } + /// + /// Cancel Click Command + /// + public ICommand CancelCommand { get; protected set; } + /// + /// All Points Using Click Command + /// + public ICommand AllUseCommand { get; protected set; } + public bool ImmediatelyClose { get; protected set; } = false; + private bool ProcessStart = false; + private posHappyPoint posHappyPoint = null; + private Task ProcessTask = null; + private string certifyKey = string.Empty; + private double queryUsingPoints = 0d; + private double canUseAllPoints = 0d; + private int passCheckLength = 4; + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public VmHappyPointUsing() + { + OkCommand = new Command(OkCommandHandler); + CancelCommand = new Command(CancelCommandHandler); + AllUseCommand = new Command(AllUseCommandHandler); + this.PropertyChanged += VmHappyPointUsing_PropertyChanged; + TitileImage = ResourceManager.GetNximagePathAdd("img_gif_barcode_happy.gif", CommonValue.PBdesignImagesPath); + WonIconImage = ResourceManager.GetNximagePathAdd("ic_won.png", CommonValue.PBdesignImagesPath); + PointImage = ResourceManager.GetNximagePathAdd("img_point.png", CommonValue.PBdesignImagesPath); + ProcessingGIF = ResourceManager.GetNximagePathAdd("ic_alert_ing2.gif", CommonValue.PBdesignImagesPath); + ErrorImage = ResourceManager.GetNximagePathAdd("ic_alert_error.png", CommonValue.PBdesignImagesPath); + SuccessImage = ResourceManager.GetNximagePathAdd("ic_alert_check.png", CommonValue.PBdesignImagesPath); + AllUseNoramlBrush = ResourceManager.GetNximagePathAdd("btn_number_all_n.png", CommonValue.PBdesignImagesPath); + AllUseSwitchOnBrush = ResourceManager.GetNximagePathAdd("btn_number_all_p.png", CommonValue.PBdesignImagesPath); + ErrorText = new List(); + OkButtonText = Languages.GetMessages("BTN0024"); + CancelButtonText = Languages.GetMessages("BTN0033"); + AllUseButtonText = Languages.GetMessages("LBL0045"); + HeaderText = Languages.GetMessages("LBL0135"); + ProcessingMessageText = Languages.GetMessages("LBL0087"); + ProcessingGuide = Languages.GetMessages("LBL0028"); + ErrorGuide = Languages.GetMessages("LBL0028"); + PointPadMaxLength = 9; + PointPadGuidText = Languages.GetMessages("LBL0059"); + TotalPayHeaderText = Languages.GetMessages("LBL0112"); + posHappyPoint = new posHappyPoint(); + + } + /// + /// Dispose + /// + public new void Dispose() + { + TitileImage = string.Empty; + PointImage = string.Empty; + ProcessingGIF = string.Empty; + ErrorImage = string.Empty; + AllUseNoramlBrush = string.Empty; + AllUseSwitchOnBrush = string.Empty; + this.PropertyChanged -= VmHappyPointUsing_PropertyChanged; + if (ProcessTask != null) + { + ProcessTask.Dispose(); + ProcessTask = null; + } + if (posHappyPoint != null) + { + HappyPointRemoveEvents(); + posHappyPoint.Dispose(); + posHappyPoint = null; + } + base.Dispose(); + } + #endregion Ctor + + #region [ Methods ] + private void TestDelay() + { + Thread.Sleep(3000); + } + private void HappyPointCreateEvents() + { + if (posHappyPoint != null) + { + posHappyPoint.ReadStart += PosHappyPoint_ReadStart; + posHappyPoint.ReadEnd += PosHappyPoint_ReadEnd; + posHappyPoint.ErrorEvent += PosHappyPoint_ErrorEvent; + posHappyPoint.ErrorMessageEvent += PosHappyPoint_ErrorMessageEvent; + } + } + private void HappyPointRemoveEvents() + { + if (posHappyPoint != null) + { + posHappyPoint.ReadStart -= PosHappyPoint_ReadStart; + posHappyPoint.ReadEnd -= PosHappyPoint_ReadEnd; + posHappyPoint.ErrorEvent -= PosHappyPoint_ErrorEvent; + posHappyPoint.ErrorMessageEvent -= PosHappyPoint_ErrorMessageEvent; + } + } + private void DoHappyPointCertify() + { + + HappyPointCreateEvents(); + var processTask = new Task(() => posHappyPoint.StartCertifyProcessing(certifyKey)); + processTask.Start(); + processTask.Wait(); + HappyPointRemoveEvents(); + processTask = null; + + + } + private void DoHappyPointUsing() + { + + if (posHappyPoint != null) + { + HappyPointCreateEvents(); + var processTask = new Task(() => posHappyPoint.StartPaymentProcessing(HappyPointReturn.MemberCode + ,double.Parse(InputPoints) + ,CertifyPassword)); + processTask.Start(); + processTask.Wait(); + HappyPointRemoveEvents(); + processTask = null; + } + + } + private bool PointValueCheck() + { + bool result = false; + try + { + if (!Payments.Equals(0) && QueryPoints >= 100) + { + var checkValue = double.Parse(InputPoints); + if (checkValue >= 100) + { + result = (checkValue % 10).Equals(0) + && checkValue <= QueryPoints + && checkValue <= Payments; + } + + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "PointValueCheck()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = false; + } + return result; + } + + #endregion Methods + + #region [ Event Handlers ] + private void AllUseCommandHandler(object obj) + { + TimerEnabled = false; + if (QueryPoints > 100) + { + canUseAllPoints = QueryPoints - QueryPoints % 10; + if (!Payments.Equals(0)) + { + if (Payments < canUseAllPoints) + { + InputPoints = Payments.ToString(); + } + else + { + InputPoints = canUseAllPoints.ToString(); + } + + } + } + TimerEnabled = true; + } + + private void CancelCommandHandler(object obj) + { + TimerEnabled = false; + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = HappyPointReturn is M_HappyPointReturn && HappyPointReturn.ReservePoint + ? HappyPointReturn + : null + }; + CanWindowClose = true; + } + private void OkCommandHandler(object obj) + { + switch (PointUsingWindow) + { + case PointUsingWindowType.PointUsing: + queryUsingPoints = double.Parse(InputPoints); + if (HappyPointReturn is M_HappyPointReturn && HappyPointReturn.NeedPassword) + { + IsOpenPasswordWindow = true; + } + else + { + PointUsingWindow = PointUsingWindowType.Processing; + } + break; + case PointUsingWindowType.ProcessingError: + switch (ProcessType) + { + case ProcessingType.Certify: + PointUsingWindow = PointUsingWindowType.CertifyStart; + break; + case ProcessingType.PointUsing: + InputPoints = string.Empty; + PointUsingWindow = PointUsingWindowType.PointUsing; + break; + } + break; + case PointUsingWindowType.CertifySuccess: + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + break; + } + } + + + private void PosHappyPoint_ErrorMessageEvent(string ErrorString) + { + ErrorText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = ErrorString.Replace("\n"," ").Replace("\r","") + }, + }; + IsErrorBlink = true; + PointUsingWindow = PointUsingWindowType.ProcessingError; + } + + private void PosHappyPoint_ErrorEvent(posHappyPoint.ErrorCode _errorCode) + { + //TODO: 공통에 에러 메세지 등록 필요 + //ErrorText = Languages.GetMessages(_errorCode.ToString()); + + ErrorText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = _errorCode.ToString() + }, + }; + IsErrorBlink = true; + PointUsingWindow = PointUsingWindowType.ProcessingError; + } + + private void PosHappyPoint_ReadStart(object sender) + { + TimerEnabled = false; + ProcessStart = true; + } + + private void PosHappyPoint_ReadEnd(object sender) + { + ProcessStart = false; + try + { + if (sender is posHappyPoint getPosposHappyPoint) + { + if (getPosposHappyPoint.ProcessOK) + { + switch (ProcessType) + { + case ProcessingType.Certify: + HappyPointReturn = new M_HappyPointReturn + { + IsCompanyMember = getPosposHappyPoint.IsCompanyMember, + MemberName = getPosposHappyPoint.MemberName, + MemberNumber = getPosposHappyPoint.MemberNumber, + MemberCode = getPosposHappyPoint.CertifyKey, + IsAppMamber = getPosposHappyPoint.IsAppMamber, + MemberLevel = getPosposHappyPoint.MemberLevel.StartsWith("VIP") + ? HappyPointMemberLevel.VIP + : getPosposHappyPoint.MemberLevel.StartsWith("G") + ? HappyPointMemberLevel.Gold + : HappyPointMemberLevel.Pink, + MemberPoint = getPosposHappyPoint.MemberPoint, + UseablePoint = getPosposHappyPoint.UseablePoint, + NeedPassword = getPosposHappyPoint.NeedPassword, + ReservePoint = HappyPointReturn is M_HappyPointReturn + ? HappyPointReturn.ReservePoint + : false, + }; + QueryPoints = HappyPointReturn.MemberPoint; + PointUsingWindow = PointUsingWindowType.PointUsing; + break; + case ProcessingType.PointUsing: + if (HappyPointReturn is M_HappyPointReturn) + { + HappyPointReturn.PointUse = true; + HappyPointReturn.UsingPoints = getPosposHappyPoint.ApprovalPoint; + HappyPointReturn.PaySEQ = getPosposHappyPoint.PaySEQ; + } + ReturnValue = new M_PopupReturn + { + OKAnswer = true, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = HappyPointReturn + }; + UsingPoints = HappyPointReturn.UsingPoints; + PointUsingWindow = PointUsingWindowType.CertifySuccess; + break; + } + } + } + } + catch + { + + throw; + } + finally + { + TimerEnabled = true; + } + + } + private void VmHappyPointUsing_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + try + { + switch (e.PropertyName) + { + case "IsTimeout": + if (IsTimeout) + { + switch (PointUsingWindow) + { + case PointUsingWindowType.CertifyStart: + case PointUsingWindowType.PointUsing: + case PointUsingWindowType.ProcessingError: + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = true, + ReturnLanguage = ShowLanguageType, + PopupArgs = HappyPointReturn + }; + break; + } + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + } + break; + case "PointUsingWindow": + CertifyStartVisible = false; + PointUsingVisible = false; + ProcessingVisible = false; + ProcessingErrorVisible = false; + CertifySuccessVisible = false; + switch (PointUsingWindow) + { + case PointUsingWindowType.CertifyStart: + CertifyStartVisible = true; + break; + case PointUsingWindowType.PointUsing: + PointUsingVisible = true; + break; + case PointUsingWindowType.Processing: + ProcessingVisible = true; + break; + case PointUsingWindowType.ProcessingError: + ProcessingErrorVisible = true; + break; + case PointUsingWindowType.CertifySuccess: + CertifySuccessVisible = true; + break; + } + break; + case "CertifyStartVisible": + if (CertifyStartVisible) + { + ScanGuidText = Languages.GetMessages("LBL0129"); + InfoGuid1Text = new List(); + InfoGuid2Text = Languages.GetMessages("LBL0003"); + ProcessType = ProcessingType.Certify; + CancelButtonWidth = PopupWidth; + OKButtonWidth = 0d; + OKButtonEnabled = false; + CancelButtonText = Languages.GetMessages("BTN0033"); + TimeOutSeconds = CommonValue.TimeOutSeconds; + } + break; + case "PointUsingVisible": + if (PointUsingVisible) + { + ScanGuidText = Languages.GetMessages("LBL0063"); + InfoGuid1Text = new List(); + InfoGuid2Text = Languages.GetMessages("LBL0001"); + ProcessType = ProcessingType.PointUsing; + CancelButtonWidth = PopupWidth / 2; + OKButtonWidth = PopupWidth / 2; + OKButtonEnabled = false; + OkButtonText = Languages.GetMessages("BTN0024"); + CancelButtonText = Languages.GetMessages("BTN0033"); + TimeOutSeconds = CommonValue.TimeOutSeconds; + } + break; + case "ProcessingVisible": + if (ProcessingVisible) + { + ScanGuidText = new List(); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + CancelButtonWidth = 0d; + OKButtonWidth = 0d; + if (ProcessTask != null) ProcessTask.Wait(); + switch (ProcessType) + { + case ProcessingType.Certify: + ProcessTask = new Task(DoHappyPointCertify); + break; + case ProcessingType.PointUsing: + ProcessTask = new Task(DoHappyPointUsing); + break; + } + ProcessTask.Start(); + } + break; + case "ProcessingErrorVisible": + if (ProcessingErrorVisible) + { + switch (ProcessType) + { + case ProcessingType.Certify: + ScanGuidText = Languages.GetMessages("LBL0077"); + break; + case ProcessingType.PointUsing: + ScanGuidText = Languages.GetMessages("LBL0077"); + break; + } + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + + CancelButtonWidth = PopupWidth / 2; + OKButtonWidth = PopupWidth / 2; + OKButtonEnabled = true; + OkButtonText = Languages.GetMessages("BTN0007"); + CancelButtonText = Languages.GetMessages("BTN0033"); + TimeOutSeconds = 10d; + } + break; + case "CertifySuccessVisible": + if (CertifySuccessVisible) + { + if (HappyPointReturn is M_HappyPointReturn + && HappyPointReturn.PointUse + && HappyPointReturn.UsingPoints.Equals(Payments)) + { + ScanGuidText = new List(); + SuccessText = Languages.GetMessages("LBL0093"); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + ImmediatelyClose = true; + TimeOutSeconds = 0d; + } + else + { + ScanGuidText = new List(); + SuccessText = Languages.GetMessages("LBL0093"); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + CancelButtonWidth = 0d; + OkButtonText = Languages.GetMessages("BTN0039"); + OKButtonWidth = PopupWidth; + OKButtonEnabled = true; + TimeOutSeconds = 5d; + } + } + break; + case "HappyPointReturn": + if (HappyPointReturn != null) + { + QueryPoints = HappyPointReturn.MemberPoint; + } + break; + case "NumPadInputVisible": + NumPadGuideVisible = !NumPadInputVisible; + break; + case "InputPoints": + if (canUseAllPoints > 0d) + { + AllUseSwitch = canUseAllPoints.ToString().Equals(InputPoints); + } + else + { + AllUseSwitch = false; + } + NumPadInputVisible = InputPoints.Length > 0; + OKButtonEnabled = PointValueCheck(); + break; + case "ReadBarCode": + if (!ProcessStart) + { + switch (ReadBarCode.Length) + { + case 16: + case 17: + certifyKey = ReadBarCode.Substring(0, 16); + InputPoints = string.Empty; + FormatedBarCode = ReadBarCode.GetEncriptCardNo(); + PointUsingWindow = PointUsingWindowType.Processing; + break; + + default: + FormatedBarCode = string.Empty; + OKButtonEnabled = false; + break; + } + } + break; + case "CertifyPassword": + if (HappyPointReturn is M_HappyPointReturn && HappyPointReturn.NeedPassword + && CertifyPassword.Length.Equals(passCheckLength)) + { + PointUsingWindow = PointUsingWindowType.Processing; + } + break; + } + } + catch (Exception ex) + { + + CommonLog.ErrorLogWrite(this, "VmHappyPointUsing_PropertyChanged()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + #endregion Event Handlers + + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmLanguageSelector.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmLanguageSelector.cs new file mode 100644 index 0000000..2792e2a --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmLanguageSelector.cs @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Input; +using System.Windows.Threading; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.DataHelper; +using SPC.Kiosk.Popup.Model; + +namespace SPC.Kiosk.Popup.ViewModel +{ + public class VmLanguageSelector : PopupViewModelBase + { + #region [ Members ] + private List okButtonText; + /// + /// OK Button Text + /// + public List OkButtonText + { + get { return okButtonText; } + set { okButtonText = value; PropertyChange("OkButtonText"); } + } + /// + /// OK Click Command + /// + public ICommand OkCommand { get; protected set; } + + private string optionValue813; + /// + /// 다국어 - 영문사용 + /// + public string OptionValue813 + { + get { return optionValue813; } + set { optionValue813 = value; PropertyChange("OptionValue813"); } + } + + private string optionValue814; + /// + /// 다국어 - 일어사용 + /// + public string OptionValue814 + { + get { return optionValue814; } + set { optionValue814 = value; PropertyChange("OptionValue814"); } + } + + private string optionValue815; + /// + /// 다국어 - 중국어사용 + /// + public string OptionValue815 + { + get { return optionValue815; } + set { optionValue815 = value; PropertyChange("OptionValue815"); } + } + + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public VmLanguageSelector() + { + OkCommand = new Command(OkCommandHandler); + this.PropertyChanged += VmLanguageSelector_PropertyChanged; + OkButtonText = Languages.GetMessages("BTN0024"); + ShowLanguageType = CommonValue.CommonLanguageType; + + this.GetPosOption(); + } + + private void GetPosOption() + { + //PosOption 값 획득 + using (var backDataService = new BackDataService()) + { + this.OptionValue813 = backDataService.GetPosOption(nameof(PosOptionType.OPT813)); + this.OptionValue814 = backDataService.GetPosOption(nameof(PosOptionType.OPT814)); + this.OptionValue815 = backDataService.GetPosOption(nameof(PosOptionType.OPT815)); + } + } + + ~VmLanguageSelector() + { + this.PropertyChanged -= VmLanguageSelector_PropertyChanged; + } + #endregion Ctor + + #region [ Event Handlers ] + private void OkCommandHandler(object obj) + { + TimerEnabled = false; + ReturnValue = new M_PopupReturn + { + OKAnswer = true, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + + private void VmLanguageSelector_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "IsTimeout": + if (IsTimeout) + { + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = true, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + break; + } + } + + #endregion Event Handlers + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmMiniPopup.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmMiniPopup.cs new file mode 100644 index 0000000..799a882 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmMiniPopup.cs @@ -0,0 +1,235 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Input; +using System.Windows.Threading; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +namespace SPC.Kiosk.Popup.ViewModel +{ + /// + /// CallEmployee.xaml 의 ViewModel + /// + public class VmMiniPopup : PopupViewModelBase + { + #region [ Members ] + private M_MiniPopup miniPopup; + /// + /// Parameters + /// + public M_MiniPopup MiniPopup + { + get { return miniPopup; } + set { miniPopup = value; PropertyChange("MiniPopup"); } + } + + private string iconNoramlBrush = string.Empty; + /// + /// Message Text + /// + public string IconNoramlBrush + { + get { return iconNoramlBrush; } + set { iconNoramlBrush = value; PropertyChange("IconNoramlBrush"); } + } + private List messageText = null; + /// + /// Message Text + /// + public List MessageText + { + get { return messageText; } + set { messageText = value; PropertyChange("MessageText"); } + } + private List subMessageText = null; + /// + /// SubMessage Text + /// + public List SubMessageText + { + get { return subMessageText; } + set { subMessageText = value; PropertyChange("SubMessageText"); } + } + + private List cancelButtonText; + /// + /// Cancel Button Text + /// + public List CancelButtonText + { + get { return cancelButtonText; } + set { cancelButtonText = value; PropertyChange("CancelButtonText"); } + } + private List okButtonText; + /// + /// OK Button Text + /// + public List OkButtonText + { + get { return okButtonText; } + set { okButtonText = value; PropertyChange("OkButtonText"); } + } + private double okButtonWidth = 400d; + /// + /// OK Button Width + /// + public double OkButtonWidth + { + get { return okButtonWidth; } + set { okButtonWidth = value; PropertyChange("OkButtonWidth"); } + } + private double cancelButtonWidth = 400d; + /// + /// OK Button Width + /// + public double CancelButtonWidth + { + get { return cancelButtonWidth; } + set { cancelButtonWidth = value; PropertyChange("CancelButtonWidth"); } + } + /// + /// OK Click Command + /// + public ICommand OkCommand { get; protected set; } + /// + /// Cancel Click Command + /// + public ICommand CancelCommand { get; protected set; } + + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public VmMiniPopup() + { + OkCommand = new Command(OkCommandHandler); + CancelCommand = new Command(CancelCommandHandler); + this.PropertyChanged += VmMiniPopup_PropertyChanged; + } + ~VmMiniPopup() + { + this.PropertyChanged -= VmMiniPopup_PropertyChanged; + } + #endregion Ctor + + #region [ Methods ] + private void SetMiniPopup() + { + if (MiniPopup is M_MiniPopup) + { + ShowLanguageType = MiniPopup.DisplayLanguage; + MessageText = MiniPopup.Message; + SubMessageText = MiniPopup.SubMessage; + OkButtonText = MiniPopup.OkButtonText; + CancelButtonText = MiniPopup.CencalButtonText; + TimeOutSeconds = MiniPopup.TimeoutSeconds; + IsTimeoutPopup = MiniPopup.IsTimeoutPopup; + var iconBrush = "Transparent"; + switch (MiniPopup.Icon) + { + case MiniPopupIcon.Cancel: + iconBrush = ResourceManager.GetNximagePathAdd("ic_alert_cancel.png", CommonValue.PBdesignImagesPath); + break; + case MiniPopupIcon.Delete: + iconBrush = ResourceManager.GetNximagePathAdd("ic_alert_delete.png", CommonValue.PBdesignImagesPath); + break; + case MiniPopupIcon.ListCancel: + iconBrush = ResourceManager.GetNximagePathAdd("ic_alert_listcancel.png", CommonValue.PBdesignImagesPath); + break; + case MiniPopupIcon.DiscountCancel: + iconBrush = ResourceManager.GetNximagePathAdd("ic_alert_discountcancel.png", CommonValue.PBdesignImagesPath); + break; + case MiniPopupIcon.GiftCancel: + iconBrush = ResourceManager.GetNximagePathAdd("ic_alert_giftcancel.png", CommonValue.PBdesignImagesPath); + break; + case MiniPopupIcon.OrderCancel: + iconBrush = ResourceManager.GetNximagePathAdd("ic_alert_ordercancel.png", CommonValue.PBdesignImagesPath); + break; + case MiniPopupIcon.AddCoupon: + iconBrush = ResourceManager.GetNximagePathAdd("ic_alert_coupon.png", CommonValue.PBdesignImagesPath); + break; + case MiniPopupIcon.Payment: + iconBrush = ResourceManager.GetNximagePathAdd("ic_alert_payment.png", CommonValue.PBdesignImagesPath); + break; + default: + iconBrush = "Transparent"; + break; + } + IconNoramlBrush = iconBrush; + if (!MiniPopup.IsCencalButton) + { + OkButtonWidth = 800d; + CancelButtonWidth = 0d; + } + else + { + OkButtonWidth = 400d; + CancelButtonWidth = 400d; + } + } + } + #endregion Methods + + #region [ Event Handlers ] + private void CancelCommandHandler(object obj) + { + TimerEnabled = false; + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + + private void OkCommandHandler(object obj) + { + TimerEnabled = false; + + ReturnValue = new M_PopupReturn + { + OKAnswer = true, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + + } + + private void VmMiniPopup_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "IsTimeout": + if (IsTimeout) + { + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = true, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + break; + + case "MiniPopup": + SetMiniPopup(); + break; + } + } + + + #endregion Event Handlers + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmMobileCompanyMemberCertify.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmMobileCompanyMemberCertify.cs new file mode 100644 index 0000000..cca7ab5 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmMobileCompanyMemberCertify.cs @@ -0,0 +1,661 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Input; +using System.Windows.Threading; +using System.Reflection; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Payments; +using System.Windows; +using System.Threading.Tasks; +using System.Threading; +namespace SPC.Kiosk.Popup.ViewModel +{ + /// + /// MobileCompanyMemberCertify.xaml 의 ViewModel + /// + public class VmMobileCompanyMemberCertify : PopupViewModelBase + { + #region [ Members ] + private MobileCompanyType mobileCompany; + /// + /// Mobile Company Type + /// + public MobileCompanyType MobileCompany + { + get { return mobileCompany; } + set { mobileCompany = value; PropertyChange("MobileCompany"); } + } + private List mobileCompanyName; + /// + /// Mobile Company Name + /// + public List MobileCompanyName + { + get { return mobileCompanyName; } + set { mobileCompanyName = value; PropertyChange("MobileCompanyName"); } + } + private double payments; + /// + /// Total Payments + /// + public double Payments + { + get { return payments; } + set { payments = value; PropertyChange("Payments"); } + } + private List headerSubText; + /// + /// Top Sub Header Text + /// + public List HeaderSubText + { + get { return headerSubText; } + set { headerSubText = value; PropertyChange("HeaderSubText"); } + } + private List scanGuidText; + /// + /// Second Sub Header Text + /// + public List ScanGuidText + { + get { return scanGuidText; } + set { scanGuidText = value; PropertyChange("ScanGuidText"); } + } + private List processingGuide; + /// + /// Processing Guide Text + /// + public List ProcessingGuide + { + get { return processingGuide; } + set { processingGuide = value; PropertyChange("ProcessingGuide"); } + } + private List errorGuide; + /// + /// Error Guide Text + /// + public List ErrorGuide + { + get { return errorGuide; } + set { errorGuide = value; PropertyChange("ErrorGuide"); } + } + + private List infoGuid1Text; + /// + /// Bootom first infomation text + /// + public List InfoGuid1Text + { + get { return infoGuid1Text; } + set { infoGuid1Text = value; PropertyChange("InfoGuid1Text"); } + } + private List infoGuid2Text; + /// + /// Bottom second infomation text + /// + public List InfoGuid2Text + { + get { return infoGuid2Text; } + set { infoGuid2Text = value; PropertyChange("InfoGuid2Text"); } + } + public bool certifyStartVisible = false; + /// + /// 인증 시작 화면 Visible + /// + public bool CertifyStartVisible + { + get { return certifyStartVisible; } + set { certifyStartVisible = value; PropertyChange("CertifyStartVisible"); } + } + public bool certifyProcessingVisible = false; + /// + /// 인증 진행 화면 Visible + /// + public bool CertifyProcessingVisible + { + get { return certifyProcessingVisible; } + set { certifyProcessingVisible = value; PropertyChange("CertifyProcessingVisible"); } + } + public bool processingErrorVisible = false; + /// + /// 인증 오류 화면 Visible + /// + public bool ProcessingErrorVisible + { + get { return processingErrorVisible; } + set { processingErrorVisible = value; PropertyChange("ProcessingErrorVisible"); } + } + public bool certifySuccessVisible = false; + /// + /// 인증 완료 화면 Visible + /// + public bool CertifySuccessVisible + { + get { return certifySuccessVisible; } + set { certifySuccessVisible = value; PropertyChange("CertifySuccessVisible"); } + } + private List processingMessageText; + /// + /// Number Pad Input Guide Text + /// + public List ProcessingMessageText + { + get { return processingMessageText; } + set { processingMessageText = value; PropertyChange("ProcessingMessageText"); } + } + private string titileImage; + /// + /// Read Barcode Formated Text + /// + public string TitileImage + { + get { return titileImage; } + set { titileImage = value; PropertyChange("TitileImage"); } + } + private string processingGIF; + /// + /// Processing GIF + /// + public string ProcessingGIF + { + get { return processingGIF; } + set { processingGIF = value; PropertyChange("ProcessingGIF"); } + } + private string errorImage; + /// + /// Error Icon + /// + public string ErrorImage + { + get { return errorImage; } + set { errorImage = value; PropertyChange("ErrorImage"); } + } + private string successImage; + /// + /// Sucess Icon + /// + public string SuccessImage + { + get { return successImage; } + set { successImage = value; PropertyChange("SuccessImage"); } + } + private List errorText; + /// + /// Process Error Text + /// + public List ErrorText + { + get { return errorText; } + set { errorText = value; PropertyChange("ErrorText"); } + } + private bool isErrorBlink = false; + /// + /// Is Error Text Blink + /// + public bool IsErrorBlink + { + get { return isErrorBlink; } + set { isErrorBlink = value; PropertyChange("IsErrorBlink"); } + } + private string formatedBarCode; + /// + /// Read Barcode Formated Text + /// + public string FormatedBarCode + { + get { return formatedBarCode; } + set { formatedBarCode = value; PropertyChange("FormatedBarCode"); } + } + private string readBarCode; + /// + /// Read Barcode + /// + public string ReadBarCode + { + get { return readBarCode; } + set { readBarCode = value; PropertyChange("ReadBarCode"); } + } + private double discountValue = 0d; + /// + /// Number Pad Input Number + /// + public double DiscountValue + { + get { return discountValue; } + set { discountValue = value; PropertyChange("DiscountValue"); } + } + private double cancelButtonWidth = 650d; + /// + /// Cancel Button Width + /// + public double CancelButtonWidth + { + get { return cancelButtonWidth; } + set { cancelButtonWidth = value; PropertyChange("CancelButtonWidth"); } + } + private List cancelButtonText; + /// + /// Cancel Button Text + /// + public List CancelButtonText + { + get { return cancelButtonText; } + set { cancelButtonText = value; PropertyChange("CancelButtonText"); } + } + private List okButtonText; + /// + /// Ok Button Text + /// + public List OkButtonText + { + get { return okButtonText; } + set { okButtonText = value; PropertyChange("OkButtonText"); } + } + public bool oKButtonEnabled = false; + /// + /// OK Button enabled + /// + public bool OKButtonEnabled + { + get { return oKButtonEnabled; } + set { oKButtonEnabled = value; PropertyChange("OKButtonEnabled"); } + } + private double okButtonWidth = 150d; + /// + /// OK Button Width + /// + public double OKButtonWidth + { + get { return okButtonWidth; } + set { okButtonWidth = value; PropertyChange("OKButtonWidth"); } + } + + private List successText; + /// + /// Cancel Button Text + /// + public List SuccessText + { + get { return successText; } + set { successText = value; PropertyChange("SuccessText"); } + } + + private CertifyWindowType certifyWindow = CertifyWindowType.CertifyStart; + /// + /// Current View Window + /// + public CertifyWindowType CertifyWindow + { + get { return certifyWindow; } + set { certifyWindow = value; PropertyChange("CertifyWindow"); } + } + private double popupWidth = 1300; + /// + /// Popup Whidth (For Calculate OK Button Width) + /// + public double PopupWidth + { + get { return popupWidth; } + set { popupWidth = value; PropertyChange("PopupWidth"); } + } + /// + /// 통신사 할인 정보 + /// + public M_MobileCompanyReturn MobileCompanyReturnVlaue { get; set; } + /// + /// OK Click Command + /// + public ICommand OkCommand { get; protected set; } + /// + /// Cancel Click Command + /// + public ICommand CancelCommand { get; protected set; } + private bool DiscountProcessStart = false; + private posMobileCompanyDiscount posTelecomDiscount = null; + private Task ProcessTask = null; + private string certifyKey = string.Empty; + #endregion + + #region [ Ctor ] + /// + /// Ctor + /// + public VmMobileCompanyMemberCertify() + { + OkCommand = new Command(OkCommandHandler); + CancelCommand = new Command(CancelCommandHandler); + this.PropertyChanged += VmMobileCompanyMemberCertify_PropertyChanged; + TitileImage = ResourceManager.GetNximagePathAdd("img_gif_barcode.gif", CommonValue.PBdesignImagesPath); + ProcessingGIF = ResourceManager.GetNximagePathAdd("ic_alert_ing2.gif", CommonValue.PBdesignImagesPath); + ErrorImage = ResourceManager.GetNximagePathAdd("ic_alert_error.png", CommonValue.PBdesignImagesPath); + SuccessImage = ResourceManager.GetNximagePathAdd("ic_alert_check.png", CommonValue.PBdesignImagesPath); + HeaderSubText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "할인" + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "Discount" + }, + }; + ProcessingMessageText = Languages.GetMessages("LBL0087"); + ProcessingGuide = Languages.GetMessages("LBL0017"); + ErrorGuide = Languages.GetMessages("LBL0028"); + ErrorText = new List(); + OkButtonText = Languages.GetMessages("BTN0024"); + CancelButtonText = Languages.GetMessages("BTN0033"); + posTelecomDiscount = new posMobileCompanyDiscount(); + posTelecomDiscount.ReadStart += posTelecomDiscount_ReadStart; + posTelecomDiscount.ReadEnd += posTelecomDiscount_ReadEnd; + posTelecomDiscount.ErrorEvent += posTelecomDiscount_ErrorEvent; + posTelecomDiscount.ErrorMessageEvent += posTelecomDiscount_ErrorMessageEvent; + CertifyWindow = CertifyWindowType.CertifyStart; + } + ~VmMobileCompanyMemberCertify() + { + this.PropertyChanged -= VmMobileCompanyMemberCertify_PropertyChanged; + if (ProcessTask != null) + { + ProcessTask.Dispose(); + ProcessTask = null; + } + if (posTelecomDiscount != null) + { + posTelecomDiscount.ReadStart -= posTelecomDiscount_ReadStart; + posTelecomDiscount.ReadEnd -= posTelecomDiscount_ReadEnd; + posTelecomDiscount.ErrorEvent -= posTelecomDiscount_ErrorEvent; + posTelecomDiscount.ErrorMessageEvent -= posTelecomDiscount_ErrorMessageEvent; + posTelecomDiscount.Dispose(); + posTelecomDiscount = null; + } + } + + #endregion Ctor + + #region [ Methods ] + private void InitError() + { + LastAccessTime = DateTime.Now; + ErrorText = new List(); + IsErrorBlink = false; + } + private void TelecomCreateEvents() + { + if (posTelecomDiscount != null) + { + posTelecomDiscount.ReadStart += posTelecomDiscount_ReadStart; + posTelecomDiscount.ReadEnd += posTelecomDiscount_ReadEnd; + posTelecomDiscount.ErrorEvent += posTelecomDiscount_ErrorEvent; + posTelecomDiscount.ErrorMessageEvent += posTelecomDiscount_ErrorMessageEvent; + } + } + private void TelecomRemoveEvents() + { + if (posTelecomDiscount != null) + { + posTelecomDiscount.ReadStart -= posTelecomDiscount_ReadStart; + posTelecomDiscount.ReadEnd -= posTelecomDiscount_ReadEnd; + posTelecomDiscount.ErrorEvent -= posTelecomDiscount_ErrorEvent; + posTelecomDiscount.ErrorMessageEvent -= posTelecomDiscount_ErrorMessageEvent; + } + } + private void DoMobileCompanyMemberCertify() + { + if (posTelecomDiscount != null) + { + TelecomCreateEvents(); + var processTask = new Task(() => posTelecomDiscount.StartCertifyProcessing(certifyKey,MobileCompany,Payments)); + processTask.Start(); + processTask.Wait(); + TelecomRemoveEvents(); + processTask = null; + } + } + private void DoBarCodeMobileCompanyMemberCertify() + { + FormatedBarCode = ReadBarCode.GetEncriptCardNo(); + certifyKey = ReadBarCode; + CertifyWindow = CertifyWindowType.CertifyProcessing; + } + #endregion Methods + + #region [ Event Handlers ] + private void posTelecomDiscount_ErrorMessageEvent(string _errorString) + { + ErrorText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = _errorString.Replace("\n"," ").Replace("\r","") + }, + }; + IsErrorBlink = true; + CertifyWindow = CertifyWindowType.ProcessingError; + } + + private void posTelecomDiscount_ErrorEvent(posMobileCompanyDiscount.ErrorCode _errorCode) + { + //TODO: 공통에 에러 메세지 등록 필요 + //ErrorText = Languages.GetMessages(_errorCode.ToString()); + + ErrorText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = _errorCode.ToString() + }, + }; + IsErrorBlink = true; + CertifyWindow = CertifyWindowType.ProcessingError; + } + + private void posTelecomDiscount_ReadStart(object sender) + { + DiscountProcessStart = true; + TimerEnabled = false; + } + + private void posTelecomDiscount_ReadEnd(object sender) + { + if (sender is posMobileCompanyDiscount getTelecomDiscount) + { + if (getTelecomDiscount.ProcessOK) + { + MobileCompanyReturnVlaue = new M_MobileCompanyReturn + { + Company = getTelecomDiscount.MobileCompany, + MemberCode = getTelecomDiscount.CertifyKey, + ApprovalPayments = getTelecomDiscount.Payment, + DiscountValue = getTelecomDiscount.DiscountValue, + PaySEQ = getTelecomDiscount.PaySEQ, + }; + ReturnValue = new M_PopupReturn + { + OKAnswer = true, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = MobileCompanyReturnVlaue + }; + DiscountValue = MobileCompanyReturnVlaue.DiscountValue; + CertifyWindow = CertifyWindowType.CertifySuccess; + } + } + TimerEnabled = true; + DiscountProcessStart = false; + + } + private void CancelCommandHandler(object obj) + { + TimerEnabled = false; + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + + private void OkCommandHandler(object obj) + { + switch (CertifyWindow) + { + case CertifyWindowType.ProcessingError: + CertifyWindow = CertifyWindowType.CertifyStart; + break; + case CertifyWindowType.CertifySuccess: + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + break; + } + } + private void VmMobileCompanyMemberCertify_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + try + { + switch (e.PropertyName) + { + case "IsTimeout": + if (IsTimeout) + { + switch (CertifyWindow) + { + case CertifyWindowType.CertifyStart: + case CertifyWindowType.ProcessingError: + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = true, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + break; + } + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + } + break; + case "ReadBarCode": + if (!DiscountProcessStart) + { + switch (ReadBarCode.Length) + { + case 17: + readBarCode = ReadBarCode.Substring(0, 16); + FormatedBarCode = ReadBarCode.GetEncriptCardNo(); + DoBarCodeMobileCompanyMemberCertify(); + break; + case 16: + FormatedBarCode = ReadBarCode.GetEncriptCardNo(); + DoBarCodeMobileCompanyMemberCertify(); + break; + default: + FormatedBarCode = string.Empty; + OKButtonEnabled = false; + break; + } + } + break; + case "CertifyWindow": + CertifyStartVisible = false; + CertifyProcessingVisible = false; + ProcessingErrorVisible = false; + CertifySuccessVisible = false; + switch (CertifyWindow) + { + case CertifyWindowType.CertifyStart: + CertifyStartVisible = true; + break; + case CertifyWindowType.CertifyProcessing: + CertifyProcessingVisible = true; + break; + case CertifyWindowType.ProcessingError: + ProcessingErrorVisible = true; + break; + case CertifyWindowType.CertifySuccess: + CertifySuccessVisible = true; + break; + } + break; + case "MobileCompany": + MobileCompanyName = MobileCompany.GetMobileCompanyName(); + break; + case "CertifyStartVisible": + if (CertifyStartVisible) + { + ScanGuidText = Languages.GetMessages("LBL0082"); + InfoGuid1Text = new List(); + InfoGuid2Text = Languages.GetMessages("LBL0003"); + CancelButtonWidth = PopupWidth; + OKButtonWidth = 0d; + OKButtonEnabled = false; + CancelButtonText = Languages.GetMessages("BTN0033"); + TimeOutSeconds = CommonValue.TimeOutSeconds; + } + break; + case "CertifyProcessingVisible": + if (CertifyProcessingVisible) + { + ScanGuidText = new List(); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + CancelButtonWidth = 0d; + OKButtonWidth = 0d; + + if (ProcessTask != null) ProcessTask.Wait(); + ProcessTask = new Task(DoMobileCompanyMemberCertify); + ProcessTask.Start(); + } + break; + case "ProcessingErrorVisible": + if (ProcessingErrorVisible) + { + ScanGuidText = Languages.GetMessages("LBL0077"); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + CancelButtonWidth = PopupWidth / 2; + OKButtonWidth = PopupWidth / 2; + OKButtonEnabled = true; + OkButtonText = Languages.GetMessages("BTN0007"); + CancelButtonText = Languages.GetMessages("BTN0033"); + TimeOutSeconds = 10d; + } + break; + case "CertifySuccessVisible": + if (CertifySuccessVisible) + { + ScanGuidText = new List(); + SuccessText = Languages.GetMessages("LBL0093"); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + CancelButtonWidth = 0d; + OkButtonText = Languages.GetMessages("BTN0039"); + OKButtonWidth = PopupWidth; + OKButtonEnabled = true; + TimeOutSeconds = 5d; + } + break; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "VmMobileCompanyMemberCertify_PropertyChanged()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + #endregion Event Handlers + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmMobileHappyCoupon.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmMobileHappyCoupon.cs new file mode 100644 index 0000000..6c31fef --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmMobileHappyCoupon.cs @@ -0,0 +1,779 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Input; +using System.Windows.Threading; +using System.Reflection; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Payments; +using System.Windows; +using System.Threading.Tasks; +using System.Threading; +using SPC.Kiosk.DataHelper; + +namespace SPC.Kiosk.Popup.ViewModel +{ + /// + /// MobileCompanyMemberCertify.xaml 의 ViewModel + /// + public class VmMobileHappyCoupon : PopupViewModelBase + { + #region [ Members ] + private enum ProcessingType + { + Search, + Using + } + private M_MobileCouponReturn mobileCouponReturn = new M_MobileCouponReturn(); + + public M_MobileCouponReturn MobileCouponReturn + { + get { return mobileCouponReturn; } + set { mobileCouponReturn = value; PropertyChange("MobileCouponReturn"); } + } + + private List basketData; + /// + /// 장바구니 상품정보 + /// + public List BasketData + { + get { return basketData; } + set { basketData = value; PropertyChange("BasketData"); } + } + private double payments; + /// + /// Total Payments + /// + public double Payments + { + get { return payments; } + set { payments = value; PropertyChange("Payments"); } + } + private double totalCouponAmount; + /// + /// Total Payments + /// + public double TotalCouponAmount + { + get { return totalCouponAmount; } + set { totalCouponAmount = value; PropertyChange("TotalCouponAmount"); } + } + private List headerText; + /// + /// Top Header Text + /// + public List HeaderText + { + get { return headerText; } + set { headerText = value; PropertyChange("HeaderText"); } + } + private List scanGuidText; + /// + /// Second Sub Header Text + /// + public List ScanGuidText + { + get { return scanGuidText; } + set { scanGuidText = value; PropertyChange("ScanGuidText"); } + } + private List processingGuide; + /// + /// Processing Guide Text + /// + public List ProcessingGuide + { + get { return processingGuide; } + set { processingGuide = value; PropertyChange("ProcessingGuide"); } + } + private List errorGuide; + /// + /// Error Guide Text + /// + public List ErrorGuide + { + get { return errorGuide; } + set { errorGuide = value; PropertyChange("ErrorGuide"); } + } + + private List infoGuid1Text; + /// + /// Bootom first infomation text + /// + public List InfoGuid1Text + { + get { return infoGuid1Text; } + set { infoGuid1Text = value; PropertyChange("InfoGuid1Text"); } + } + private List infoGuid2Text; + /// + /// Bottom second infomation text + /// + public List InfoGuid2Text + { + get { return infoGuid2Text; } + set { infoGuid2Text = value; PropertyChange("InfoGuid2Text"); } + } + public bool couponStartVisible = false; + /// + /// 시작 화면 Visible + /// + public bool CouponStartVisible + { + get { return couponStartVisible; } + set { couponStartVisible = value; PropertyChange("CouponStartVisible"); } + } + public bool processingVisible = false; + /// + /// 진행 화면 Visible + /// + public bool ProcessingVisible + { + get { return processingVisible; } + set { processingVisible = value; PropertyChange("ProcessingVisible"); } + } + public bool processingErrorVisible = false; + /// + /// 오류 화면 Visible + /// + public bool ProcessingErrorVisible + { + get { return processingErrorVisible; } + set { processingErrorVisible = value; PropertyChange("ProcessingErrorVisible"); } + } + public bool couponUsingVisible = false; + /// + /// 쿠폰 목록 화면 Visible + /// + public bool CouponUsingVisible + { + get { return couponUsingVisible; } + set { couponUsingVisible = value; PropertyChange("CouponUsingVisible"); } + } + public bool couponSuccessVisible = false; + /// + /// 쿠폰 처리 성공 Visible + /// + public bool CouponSuccessVisible + { + get { return couponSuccessVisible; } + set { couponSuccessVisible = value; PropertyChange("CouponSuccessVisible"); } + } + private List processingMessageText; + /// + /// Processing Message Text + /// + public List ProcessingMessageText + { + get { return processingMessageText; } + set { processingMessageText = value; PropertyChange("ProcessingMessageText"); } + } + private string titileImage; + /// + /// Titile Image + /// + public string TitileImage + { + get { return titileImage; } + set { titileImage = value; PropertyChange("TitileImage"); } + } + private string processingGIF; + /// + /// Processing GIF + /// + public string ProcessingGIF + { + get { return processingGIF; } + set { processingGIF = value; PropertyChange("ProcessingGIF"); } + } + private string errorImage; + /// + /// Error Icon + /// + public string ErrorImage + { + get { return errorImage; } + set { errorImage = value; PropertyChange("ErrorImage"); } + } + private string successImage; + /// + /// Sucess Icon + /// + public string SuccessImage + { + get { return successImage; } + set { successImage = value; PropertyChange("SuccessImage"); } + } + private string wonIconImage; + /// + /// WonIconImage + /// + public string WonIconImage + { + get { return wonIconImage; } + set { wonIconImage = value; PropertyChange("WonIconImage"); } + } + private List errorText; + /// + /// Process Error Text + /// + public List ErrorText + { + get { return errorText; } + set { errorText = value; PropertyChange("ErrorText"); } + } + private bool isErrorBlink = false; + /// + /// Is Error Text Blink + /// + public bool IsErrorBlink + { + get { return isErrorBlink; } + set { isErrorBlink = value; PropertyChange("IsErrorBlink"); } + } + private string formatedBarCode; + /// + /// Read Barcode Formated Text + /// + public string FormatedBarCode + { + get { return formatedBarCode; } + set { formatedBarCode = value; PropertyChange("FormatedBarCode"); } + } + private string readBarCode; + /// + /// Read Barcode + /// + public string ReadBarCode + { + get { return readBarCode; } + set { readBarCode = value; PropertyChange("ReadBarCode"); } + } + private double discountValue = 0d; + /// + /// Number Pad Input Number + /// + public double DiscountValue + { + get { return discountValue; } + set { discountValue = value; PropertyChange("DiscountValue"); } + } + private double cancelButtonWidth = 650d; + /// + /// Cancel Button Width + /// + public double CancelButtonWidth + { + get { return cancelButtonWidth; } + set { cancelButtonWidth = value; PropertyChange("CancelButtonWidth"); } + } + private List cancelButtonText; + /// + /// Cancel Button Text + /// + public List CancelButtonText + { + get { return cancelButtonText; } + set { cancelButtonText = value; PropertyChange("CancelButtonText"); } + } + private List okButtonText; + /// + /// Ok Button Text + /// + public List OkButtonText + { + get { return okButtonText; } + set { okButtonText = value; PropertyChange("OkButtonText"); } + } + public bool oKButtonEnabled = false; + /// + /// OK Button enabled + /// + public bool OKButtonEnabled + { + get { return oKButtonEnabled; } + set { oKButtonEnabled = value; PropertyChange("OKButtonEnabled"); } + } + private double okButtonWidth = 650d; + /// + /// OK Button Width + /// + public double OKButtonWidth + { + get { return okButtonWidth; } + set { okButtonWidth = value; PropertyChange("OKButtonWidth"); } + } + + private List successText; + /// + /// Cancel Button Text + /// + public List SuccessText + { + get { return successText; } + set { successText = value; PropertyChange("SuccessText"); } + } + + private MobileCouponWindowType couponWindow = MobileCouponWindowType.CouponStart; + /// + /// Current View Window + /// + public MobileCouponWindowType CouponWindow + { + get { return couponWindow; } + set { couponWindow = value; PropertyChange("CouponWindow"); } + } + private double popupWidth = 1300; + /// + /// Popup Whidth (For Calculate OK Button Width) + /// + public double PopupWidth + { + get { return popupWidth; } + set { popupWidth = value; PropertyChange("PopupWidth"); } + } + /// + /// OK Click Command + /// + public ICommand OkCommand { get; protected set; } + /// + /// Cancel Click Command + /// + public ICommand CancelCommand { get; protected set; } + + private bool ProcessStart = false; + private posMobileHappyCoupon posMobileCoupon = null; + private Task ProcessTask = null; + private string certifyKey = string.Empty; + private ProcessingType processingType = ProcessingType.Search; + #endregion + + #region [ Ctor ] + /// + /// Ctor + /// + public VmMobileHappyCoupon() + { + OkCommand = new Command(OkCommandHandler); + CancelCommand = new Command(CancelCommandHandler); + this.PropertyChanged += VmMobileHappyCoupon_PropertyChanged; + TitileImage = ResourceManager.GetNximagePathAdd("img_gif_barcode.gif", CommonValue.PBdesignImagesPath); + ProcessingGIF = ResourceManager.GetNximagePathAdd("ic_alert_ing2.gif", CommonValue.PBdesignImagesPath); + ErrorImage = ResourceManager.GetNximagePathAdd("ic_alert_error.png", CommonValue.PBdesignImagesPath); + SuccessImage = ResourceManager.GetNximagePathAdd("ic_alert_check.png", CommonValue.PBdesignImagesPath); + WonIconImage = ResourceManager.GetNximagePathAdd("ic_won.png", CommonValue.PBdesignImagesPath); + HeaderText = Languages.GetMessages("LBL0047"); + ScanGuidText = Languages.GetMessages("LBL0051"); + ProcessingMessageText = Languages.GetMessages("LBL0087"); + ProcessingGuide = Languages.GetMessages("LBL0017"); + ErrorGuide = Languages.GetMessages("LBL0028"); + ErrorText = new List(); + OkButtonText = Languages.GetMessages("BTN0024"); + CancelButtonText = Languages.GetMessages("BTN0033"); + posMobileCoupon = new posMobileHappyCoupon(); + posMobileCoupon.ReadStart += posMobileCoupon_ReadStart; + posMobileCoupon.ReadEnd += posMobileCoupon_ReadEnd; + posMobileCoupon.ErrorEvent += posMobileCoupon_ErrorEvent; + posMobileCoupon.ErrorMessageEvent += posMobileCoupon_ErrorMessageEvent; + CouponWindow = MobileCouponWindowType.CouponStart; + } + + + ~VmMobileHappyCoupon() + { + this.PropertyChanged -= VmMobileHappyCoupon_PropertyChanged; + if (ProcessTask != null) + { + ProcessTask.Wait(); + ProcessTask = null; + } + if (posMobileCoupon != null) + { + posMobileCoupon.ReadStart -= posMobileCoupon_ReadStart; + posMobileCoupon.ReadEnd -= posMobileCoupon_ReadEnd; + posMobileCoupon.ErrorEvent -= posMobileCoupon_ErrorEvent; + posMobileCoupon.ErrorMessageEvent -= posMobileCoupon_ErrorMessageEvent; + posMobileCoupon.Dispose(); + posMobileCoupon = null; + } + } + + #endregion Ctor + + #region [ Methods ] + private void InitError() + { + LastAccessTime = DateTime.Now; + ErrorText = new List(); + IsErrorBlink = false; + } + private void MobileCouponCreateEvents() + { + if (posMobileCoupon != null) + { + posMobileCoupon.ReadStart += posMobileCoupon_ReadStart; + posMobileCoupon.ReadEnd += posMobileCoupon_ReadEnd; + posMobileCoupon.ErrorEvent += posMobileCoupon_ErrorEvent; + posMobileCoupon.ErrorMessageEvent += posMobileCoupon_ErrorMessageEvent; + } + } + private void MobileCouponRemoveEvents() + { + if (posMobileCoupon != null) + { + posMobileCoupon.ReadStart -= posMobileCoupon_ReadStart; + posMobileCoupon.ReadEnd -= posMobileCoupon_ReadEnd; + posMobileCoupon.ErrorEvent -= posMobileCoupon_ErrorEvent; + posMobileCoupon.ErrorMessageEvent -= posMobileCoupon_ErrorMessageEvent; + } + } + private void DoCouponSearch() + { + if (posMobileCoupon != null) + { + MobileCouponCreateEvents(); + var processTask = new Task(() => posMobileCoupon.StartCertifyProcessing(certifyKey, Payments)); + processTask.Start(); + processTask.Wait(); + MobileCouponRemoveEvents(); + if (posMobileCoupon.ProcessOK) + { + CouponWindow = MobileCouponWindowType.CouponUsing; + } + else + { + CouponWindow = MobileCouponWindowType.ProcessingError; + } + processTask = null; + } + TimerEnabled = true; + ProcessStart = false; + + } + private void DoCouponUsing() + { + if (posMobileCoupon != null) + { + MobileCouponCreateEvents(); + var processTask = new Task(() => posMobileCoupon.StartPaymentProcessing(MobileCouponReturn,Payments)); + processTask.Start(); + processTask.Wait(); + MobileCouponRemoveEvents(); + if (posMobileCoupon.ProcessOK) + { + CouponWindow = MobileCouponWindowType.CouponSuccess; + } + else + { + CouponWindow = MobileCouponWindowType.ProcessingError; + } + processTask = null; + } + TimerEnabled = true; + ProcessStart = false; + } + private void DoBarCodeCouponStart() + { + certifyKey = ReadBarCode; + processingType = ProcessingType.Search; + CouponWindow = MobileCouponWindowType.Processing; + } + private void SetTatalUsingAmount() + { + if (MobileCouponReturn is M_MobileCouponReturn + && MobileCouponReturn.VirtureCoupons.Count > 0) + { + TotalCouponAmount = double.Parse(MobileCouponReturn.VirtureCoupons.Sum(r => r.DiscountPrice).ToString()); + } + else + { + TotalCouponAmount = 0; + } + + } + + + #endregion Methods + + #region [ Event Handlers ] + + private void posMobileCoupon_ErrorMessageEvent(string _errorString) + { + ErrorText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = _errorString.Replace("\n"," ").Replace("\r","") + }, + }; + IsErrorBlink = true; + } + + private void posMobileCoupon_ErrorEvent(posMobileHappyCoupon.ErrorCode _errorCode) + { + //TODO: 공통에 에러 메세지 등록 필요 + //ErrorText = Languages.GetMessages(_errorCode.ToString()); + + ErrorText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = _errorCode.ToString() + }, + }; + IsErrorBlink = true; + } + + private void posMobileCoupon_ReadStart(object sender) + { + ProcessStart = true; + TimerEnabled = false; + } + + private void posMobileCoupon_ReadEnd(object sender) + { + if (sender is posMobileHappyCoupon getMobileHappyCoupon) + { + if (getMobileHappyCoupon.ProcessOK) + { + if (processingType.Equals(ProcessingType.Search)) + { + MobileCouponReturn = getMobileHappyCoupon.CouponData; + } + else if (processingType.Equals(ProcessingType.Using)) + { + ReturnValue = new M_PopupReturn + { + OKAnswer = true, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = MobileCouponReturn + }; + } + } + } + + } + private void CancelCommandHandler(object obj) + { + TimerEnabled = false; + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + + private void OkCommandHandler(object obj) + { + switch (CouponWindow) + { + case MobileCouponWindowType.ProcessingError: + switch (processingType) + { + case ProcessingType.Search: + CouponWindow = MobileCouponWindowType.CouponStart; + break; + case ProcessingType.Using: + CouponWindow = MobileCouponWindowType.CouponUsing; + break; + } + break; + case MobileCouponWindowType.CouponUsing: + processingType = ProcessingType.Using; + CouponWindow = MobileCouponWindowType.Processing; + break; + case MobileCouponWindowType.CouponSuccess: + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + break; + } + } + private void VmMobileHappyCoupon_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + try + { + switch (e.PropertyName) + { + case "IsTimeout": + if (IsTimeout) + { + switch (CouponWindow) + { + case MobileCouponWindowType.CouponStart: + case MobileCouponWindowType.CouponUsing: + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = true, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + break; + } + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + } + break; + case "MobileCouponReturn": + SetTatalUsingAmount(); + if (MobileCouponReturn is M_MobileCouponReturn + && MobileCouponReturn.VirtureCoupons.Count > 0) + { + foreach (var aCouponData in MobileCouponReturn.VirtureCoupons) + { + aCouponData.PropertyChanged += ACouponData_PropertyChanged; + } + } + break; + case "TotalCouponAmount": + OKButtonEnabled = TotalCouponAmount > 0; + break; + case "ReadBarCode": + if (!ProcessStart) + { + if (ReadBarCode.Length >= 12 && ReadBarCode.Length <= 20) + { + readBarCode = ReadBarCode; + FormatedBarCode = readBarCode; + DoBarCodeCouponStart(); + } + else + { + FormatedBarCode = string.Empty; + OKButtonEnabled = false; + } + } + break; + case "CouponWindow": + CouponStartVisible = false; + ProcessingVisible = false; + ProcessingErrorVisible = false; + CouponUsingVisible = false; + CouponSuccessVisible = false; + switch (CouponWindow) + { + case MobileCouponWindowType.CouponStart: + CouponStartVisible = true; + break; + case MobileCouponWindowType.Processing: + ProcessingVisible = true; + break; + case MobileCouponWindowType.ProcessingError: + ProcessingErrorVisible = true; + break; + case MobileCouponWindowType.CouponUsing: + CouponUsingVisible = true; + break; + case MobileCouponWindowType.CouponSuccess: + CouponSuccessVisible = true; + break; + } + break; + case "CouponStartVisible": + if (CouponStartVisible) + { + ScanGuidText = Languages.GetMessages("LBL0051"); + InfoGuid1Text = new List(); + InfoGuid2Text = Languages.GetMessages("LBL0015"); + CancelButtonWidth = PopupWidth; + OKButtonWidth = 0d; + OKButtonEnabled = false; + CancelButtonText = Languages.GetMessages("BTN0033"); + TimeOutSeconds = CommonValue.TimeOutSeconds; + } + break; + case "ProcessingVisible": + if (ProcessingVisible) + { + ScanGuidText = new List(); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + CancelButtonWidth = 0d; + OKButtonWidth = 0d; + + if (ProcessTask != null) ProcessTask.Wait(); + + switch (processingType) + { + case ProcessingType.Search: + ProcessTask = new Task(DoCouponSearch); + break; + case ProcessingType.Using: + ProcessTask = new Task(DoCouponUsing); + break; + } + ProcessTask.Start(); + } + break; + case "ProcessingErrorVisible": + if (ProcessingErrorVisible) + { + ScanGuidText = Languages.GetMessages("LBL0077"); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + CancelButtonWidth = PopupWidth / 2; + OKButtonWidth = PopupWidth / 2; + OKButtonEnabled = true; + OkButtonText = Languages.GetMessages("BTN0007"); + CancelButtonText = Languages.GetMessages("BTN0033"); + TimeOutSeconds = 10d; + } + break; + case "CouponUsingVisible": + if (CouponUsingVisible) + { + ScanGuidText = new List(); + SuccessText = Languages.GetMessages("LBL0113"); + InfoGuid1Text = new List(); + InfoGuid2Text = Languages.GetMessages("LBL0004"); + CancelButtonWidth = PopupWidth / 2; + OKButtonWidth = PopupWidth / 2; + OKButtonEnabled = false; + OkButtonText = Languages.GetMessages("BTN0039"); + CancelButtonText = Languages.GetMessages("BTN0033"); + TimeOutSeconds = CommonValue.TimeOutSeconds; + } + break; + case "CouponSuccessVisible": + if (CouponSuccessVisible) + { + ScanGuidText = new List(); + SuccessText = Languages.GetMessages("LBL0093"); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + CancelButtonWidth = 0d; + OkButtonText = Languages.GetMessages("BTN0039"); + OKButtonWidth = PopupWidth; + OKButtonEnabled = true; + TimeOutSeconds = 5d; + } + break; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "VmMobileHappyCoupon_PropertyChanged()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + + private void ACouponData_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + LastAccessTime = DateTime.Now; + SetTatalUsingAmount(); + } + + #endregion Event Handlers + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmNumPadPopup.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmNumPadPopup.cs new file mode 100644 index 0000000..44819e2 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmNumPadPopup.cs @@ -0,0 +1,303 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Threading; +using System.Windows; +using System.Windows.Input; +using System.Windows.Threading; +using System.Reflection; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Payments; + +namespace SPC.Kiosk.Popup.ViewModel +{ + /// + /// HappyPointCertify.xaml에 대한 ViewModel + /// + public class VmNumPadPopup : PopupViewModelBase + { + + + #region [ Members ] + private List numPadGuidText; + /// + /// Number Pad Input Guide Text + /// + public List NumPadGuidText + { + get { return numPadGuidText; } + set { numPadGuidText = value; PropertyChange("NumPadGuidText"); } + } + private bool formated = false; + /// + /// Input Text Formated + /// + public bool Formated + { + get { return formated; } + set { formated = value; PropertyChange("Formated"); } + } + private bool isPassword = false; + /// + /// Input Text Formated + /// + public bool IsPassword + { + get { return isPassword; } + set { isPassword = value; PropertyChange("IsPassword"); } + } + + private string inputNumbers = string.Empty; + /// + /// Number Pad Input Number + /// + public string InputNumbers + { + get { return inputNumbers; } + set { inputNumbers = value; PropertyChange("InputNumbers"); } + } + + private double cancelButtonWidth = 270d; + /// + /// Cancel Button Width + /// + public double CancelButtonWidth + { + get { return cancelButtonWidth; } + set { cancelButtonWidth = value; PropertyChange("CancelButtonWidth"); } + } + private List cancelButtonText; + /// + /// Cancel Button Text + /// + public List CancelButtonText + { + get { return cancelButtonText; } + set { cancelButtonText = value; PropertyChange("CancelButtonText"); } + } + private List okButtonText; + /// + /// Ok Button Text + /// + public List OkButtonText + { + get { return okButtonText; } + set { okButtonText = value; PropertyChange("OkButtonText"); } + } + public bool oKButtonEnabled = false; + /// + /// OK Button enabled + /// + public bool OKButtonEnabled + { + get { return oKButtonEnabled; } + set { oKButtonEnabled = value; PropertyChange("OKButtonEnabled"); } + } + private double okButtonWidth = 270d; + /// + /// OK Button Width + /// + public double OKButtonWidth + { + get { return okButtonWidth; } + set { okButtonWidth = value; PropertyChange("OKButtonWidth"); } + } + public bool numPadInputVisible = false; + /// + /// OK Button enabled + /// + public bool NumPadInputVisible + { + get { return numPadInputVisible; } + set { numPadInputVisible = value; PropertyChange("NumPadInputVisible"); } + } + public bool numPadGuideVisible = true; + /// + /// OK Button enabled + /// + public bool NumPadGuideVisible + { + get { return numPadGuideVisible; } + set { numPadGuideVisible = value; PropertyChange("NumPadGuideVisible"); } + } + + public int numPadMaxLength; + /// + /// Number Pad Input Maxlength + /// + public int NumPadMaxLength + { + get { return numPadMaxLength; } + set { numPadMaxLength = value; PropertyChange("NumPadMaxLength"); } + } + public int checkLength; + /// + /// Number Pad Input Maxlength + /// + public int CheckLength + { + get { return checkLength; } + set { checkLength = value; PropertyChange("CheckLength"); } + } + + private List memberPointsHeaderText; + /// + /// Cancel Button Text + /// + public List MemberPointsHeaderText + { + get { return memberPointsHeaderText; } + set { memberPointsHeaderText = value; PropertyChange("MemberPointsHeaderText"); } + } + private string languageButttonImage; + /// + /// Read Barcode Formated Text + /// + public string LanguageButttonImage + { + get { return languageButttonImage; } + set { languageButttonImage = value; PropertyChange("LanguageButttonImage"); } + } + private bool languageButttonVisibel; + /// + /// Language Select Button Visible + /// + public bool LanguageButttonVisibel + { + get { return languageButttonVisibel; } + set { languageButttonVisibel = value; PropertyChange("LanguageButttonVisibel"); } + } + private CertifyWindowType certifyWindow = CertifyWindowType.CertifyStart; + /// + /// Current View Window + /// + public CertifyWindowType CertifyWindow + { + get { return certifyWindow; } + set { certifyWindow = value; PropertyChange("CertifyWindow"); } + } + private double popupWidth = 1300; + /// + /// Popup Whidth (For Calculate OK Button Width) + /// + public double PopupWidth + { + get { return popupWidth; } + set { popupWidth = value; PropertyChange("PopupWidth"); } + } + /// + /// HappyPoint 인증 정보 + /// + public M_HappyPointReturn HappyPointReturn { get; set; } + /// + /// OK Click Command + /// + public ICommand OkCommand { get; protected set; } + /// + /// Cancel Click Command + /// + public ICommand CancelCommand { get; protected set; } + #endregion + + #region [ Ctor ] + /// + /// Ctor + /// + public VmNumPadPopup() + { + OkCommand = new Command(OkCommandHandler); + CancelCommand = new Command(CancelCommandHandler); + this.PropertyChanged += VmHappyPointCertify_PropertyChanged; + OkButtonText = Languages.GetMessages("BTN0024"); + CancelButtonText = Languages.GetMessages("BTN0033"); + } + /// + /// Dispose + /// + public new void Dispose() + { + this.PropertyChanged -= VmHappyPointCertify_PropertyChanged; + base.Dispose(); + } + #endregion Ctor + + #region [ Method ] + + + #endregion Method + + #region [ Event Handlers ] + + private void CancelCommandHandler(object obj) + { + TimerEnabled = false; + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + + private void OkCommandHandler(object obj) + { + + TimerEnabled = false; + ReturnValue = new M_PopupReturn + { + OKAnswer = true, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = InputNumbers + }; + CanWindowClose = true; + } + + private void VmHappyPointCertify_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "IsTimeout": + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = true, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + break; + case "NumPadInputVisible": + NumPadGuideVisible = !NumPadInputVisible; + break; + case "InputNumbers": + NumPadInputVisible = InputNumbers.Length > 0; + if (CheckLength > 0 && CheckLength <= NumPadMaxLength) + { + OKButtonEnabled = CheckLength.Equals(InputNumbers.Length); + } + else + { + OKButtonEnabled = InputNumbers.Length > 0; + } + break; + case "PopupWidth": + OKButtonWidth = PopupWidth / 2; + CancelButtonWidth = PopupWidth / 2; + break; + } + } + #endregion Event Handlers + + + } + +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmOkCashBagCertify.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmOkCashBagCertify.cs new file mode 100644 index 0000000..3ceae5e --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmOkCashBagCertify.cs @@ -0,0 +1,793 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Input; +using System.Windows.Threading; +using System.Reflection; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Payments; +using System.Windows; +using System.Threading.Tasks; +using System.Threading; + +namespace SPC.Kiosk.Popup.ViewModel +{ + /// + /// OkCashBagCertify.xaml에 대한 ViewModel + /// + public class VmOkCashBagCertify : PopupViewModelBase + { + + + #region [ Members ] + + private List headerText; + /// + /// Top Header Text + /// + public List HeaderText + { + get { return headerText; } + set { headerText = value; PropertyChange("HeaderText"); } + } + private List scanGuidText; + /// + /// Second Sub Header Text + /// + public List ScanGuidText + { + get { return scanGuidText; } + set { scanGuidText = value; PropertyChange("ScanGuidText"); } + } + private string processingGIF; + /// + /// Processing GIF + /// + public string ProcessingGIF + { + get { return processingGIF; } + set { processingGIF = value; PropertyChange("ProcessingGIF"); } + } + private List infoGuid1Text; + /// + /// Bootom first infomation text + /// + public List InfoGuid1Text + { + get { return infoGuid1Text; } + set { infoGuid1Text = value; PropertyChange("InfoGuid1Text"); } + } + private List infoGuid2Text; + /// + /// Bottom second infomation text + /// + public List InfoGuid2Text + { + get { return infoGuid2Text; } + set { infoGuid2Text = value; PropertyChange("InfoGuid2Text"); } + } + public bool certifyStartVisible = false; + /// + /// 인증 시작 화면 Visible + /// + public bool CertifyStartVisible + { + get { return certifyStartVisible; } + set { certifyStartVisible = value; PropertyChange("CertifyStartVisible"); } + } + public bool certifyProcessingVisible = false; + /// + /// 인증 진행 화면 Visible + /// + public bool CertifyProcessingVisible + { + get { return certifyProcessingVisible; } + set { certifyProcessingVisible = value; PropertyChange("CertifyProcessingVisible"); } + } + public bool processingErrorVisible = false; + /// + /// 인증 오류 화면 Visible + /// + public bool ProcessingErrorVisible + { + get { return processingErrorVisible; } + set { processingErrorVisible = value; PropertyChange("ProcessingErrorVisible"); } + } + public bool certifySuccessVisible = false; + /// + /// 인증 완료 화면 Visible + /// + public bool CertifySuccessVisible + { + get { return certifySuccessVisible; } + set { certifySuccessVisible = value; PropertyChange("CertifySuccessVisible"); } + } + + private bool showPhoneInput = false; + /// + /// Show Phone Input + /// + public bool ShowPhoneInput + { + get { return showPhoneInput; } + set { showPhoneInput = value; PropertyChange("ShowPhoneInput"); } + } + private List processingMessageText; + /// + /// Number Pad Input Guide Text + /// + public List ProcessingMessageText + { + get { return processingMessageText; } + set { processingMessageText = value; PropertyChange("ProcessingMessageText"); } + } + private List processingGuide; + /// + /// Processing Guide Text + /// + public List ProcessingGuide + { + get { return processingGuide; } + set { processingGuide = value; PropertyChange("ProcessingGuide"); } + } + private string errorImage; + /// + /// Error Icon + /// + public string ErrorImage + { + get { return errorImage; } + set { errorImage = value; PropertyChange("ErrorImage"); } + } + private List errorGuide; + /// + /// Error Guide Text + /// + public List ErrorGuide + { + get { return errorGuide; } + set { errorGuide = value; PropertyChange("ErrorGuide"); } + } + + private List numPadGuidText; + /// + /// Number Pad Input Guide Text + /// + public List NumPadGuidText + { + get { return numPadGuidText; } + set { numPadGuidText = value; PropertyChange("NumPadGuidText"); } + } + private List numPadCancelText; + /// + /// Number Pad Cancel Button Text + /// + public List NumPadCancelText + { + get { return numPadCancelText; } + set { numPadCancelText = value; PropertyChange("NumPadCancelText"); } + } + private List errorText; + /// + /// Process Error Text + /// + public List ErrorText + { + get { return errorText; } + set { errorText = value; PropertyChange("ErrorText"); } + } + private bool isErrorBlink = false; + /// + /// Is Error Text Blink + /// + public bool IsErrorBlink + { + get { return isErrorBlink; } + set { isErrorBlink = value; PropertyChange("IsErrorBlink"); } + } + private string formatedBarCode; + /// + /// Read Barcode Formated Text + /// + public string FormatedBarCode + { + get { return formatedBarCode; } + set { formatedBarCode = value; PropertyChange("FormatedBarCode"); } + } + private string readBarCode; + /// + /// Read Barcode + /// + public string ReadBarCode + { + get { return readBarCode; } + set { readBarCode = value; PropertyChange("ReadBarCode"); } + } + private string inputNumbers = string.Empty; + /// + /// Number Pad Input Number + /// + public string InputNumbers + { + get { return inputNumbers; } + set { inputNumbers = value; PropertyChange("InputNumbers"); } + } + private string memberPointsText = string.Empty; + /// + /// Number Pad Input Number + /// + public string MemberPointsText + { + get { return memberPointsText; } + set { memberPointsText = value; PropertyChange("MemberPointsText"); } + } + + private double cancelButtonWidth = 650d; + /// + /// Cancel Button Width + /// + public double CancelButtonWidth + { + get { return cancelButtonWidth; } + set { cancelButtonWidth = value; PropertyChange("CancelButtonWidth"); } + } + private List cancelButtonText; + /// + /// Cancel Button Text + /// + public List CancelButtonText + { + get { return cancelButtonText; } + set { cancelButtonText = value; PropertyChange("CancelButtonText"); } + } + private List okButtonText; + /// + /// Ok Button Text + /// + public List OkButtonText + { + get { return okButtonText; } + set { okButtonText = value; PropertyChange("OkButtonText"); } + } + public bool oKButtonEnabled = false; + /// + /// OK Button enabled + /// + public bool OKButtonEnabled + { + get { return oKButtonEnabled; } + set { oKButtonEnabled = value; PropertyChange("OKButtonEnabled"); } + } + private double okButtonWidth = 650d; + /// + /// OK Button Width + /// + public double OKButtonWidth + { + get { return okButtonWidth; } + set { okButtonWidth = value; PropertyChange("OKButtonWidth"); } + } + public int numPadMaxLength; + /// + /// Number Pad Input Maxlength + /// + public int NumPadMaxLength + { + get { return numPadMaxLength; } + set { numPadMaxLength = value; PropertyChange("NumPadMaxLength"); } + } + + private List memberPointsHeaderText; + /// + /// Cancel Button Text + /// + public List MemberPointsHeaderText + { + get { return memberPointsHeaderText; } + set { memberPointsHeaderText = value; PropertyChange("MemberPointsHeaderText"); } + } + + private CertifyWindowType certifyWindow = CertifyWindowType.CertifyStart; + /// + /// Current View Window + /// + public CertifyWindowType CertifyWindow + { + get { return certifyWindow; } + set { certifyWindow = value; PropertyChange("CertifyWindow"); } + } + private double popupWidth = 1300; + /// + /// Popup Whidth (For Calculate OK Button Width) + /// + public double PopupWidth + { + get { return popupWidth; } + set { popupWidth = value; PropertyChange("PopupWidth"); } + } + /// + /// OK CashBag 인증 정보 + /// + public M_OkCashBagReturn OkCashBagReturn { get; set; } + /// + /// OK Click Command + /// + public ICommand OkCommand { get; protected set; } + /// + /// Cancel Click Command + /// + public ICommand CancelCommand { get; protected set; } + private bool MemberProcessStart = false; + private posOkCashBag posOkCashBag = null; + private Task ProcessTask = null; + private CancellationTokenSource TokenSource; + private string certifyKey = string.Empty; + + /// + /// 바코드스캔 Image + /// + public string BarcodeScanImage { get; set; } = ResourceManager.GetNximagePathAdd("img_gif_barcode.gif", CommonValue.PBdesignImagesPath); + + #endregion + + #region [ Ctor ] + /// + /// Ctor + /// + public VmOkCashBagCertify() + { + OkCommand = new Command(OkCommandHandler); + CancelCommand = new Command(CancelCommandHandler); + this.PropertyChanged += VmHappyPointCertify_PropertyChanged; + HeaderText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "OK 캐시백 회원인증" + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "enOK 캐시백 회원인증" + }, + }; + ProcessingMessageText = Languages.GetMessages("LBL0087"); + ProcessingGuide = Languages.GetMessages("LBL0140"); + ErrorImage = ResourceManager.GetNximagePathAdd("ic_alert_error.png", CommonValue.PBdesignImagesPath); + ErrorGuide = Languages.GetMessages("LBL0140"); + ErrorText = new List(); + NumPadMaxLength = 11; + NumPadGuidText = Languages.GetMessages("MobileNumberMessage"); + NumPadCancelText = Languages.GetMessages("CommonClear"); + ProcessingGIF = ResourceManager.GetNximagePathAdd("ic_alert_ing2.gif", CommonValue.PBdesignImagesPath); + ShowLanguageType = CommonValue.CommonLanguageType; + posOkCashBag = new posOkCashBag(); + CertifyWindow = CertifyWindowType.CertifyStart; + } + + + ~VmOkCashBagCertify() + { + this.PropertyChanged -= VmHappyPointCertify_PropertyChanged; + if (ProcessTask != null) + { + ProcessTask.Dispose(); + ProcessTask = null; + } + if (posOkCashBag != null) + { + CashBagRemoveEvents(); + posOkCashBag.Dispose(); + posOkCashBag = null; + } + } + #endregion Ctor + + #region [ Method ] + + + private void InitError() + { + LastAccessTime = DateTime.Now; + ErrorText = new List(); + IsErrorBlink = false; + } + private void CashBagCreateEvents() + { + if (posOkCashBag != null) + { + posOkCashBag.ReadStart += PosOkCashBag_ReadStart; + posOkCashBag.ReadEnd += PosOkCashBag_ReadEnd; + posOkCashBag.ErrorEvent += PosOkCashBag_ErrorEvent; + posOkCashBag.ErrorMessageEvent += PosOkCashBag_ErrorMessageEvent; + } + } + private void CashBagRemoveEvents() + { + if (posOkCashBag != null) + { + posOkCashBag.ReadStart -= PosOkCashBag_ReadStart; + posOkCashBag.ReadEnd -= PosOkCashBag_ReadEnd; + posOkCashBag.ErrorEvent -= PosOkCashBag_ErrorEvent; + posOkCashBag.ErrorMessageEvent -= PosOkCashBag_ErrorMessageEvent; + } + } + private void DoOkCashBagCertify() + { + if (posOkCashBag != null) + { + this.CashBagCreateEvents(); + var processTask = new Task(() => posOkCashBag.StartCertifyProcessing(certifyKey)); + TokenSource = new CancellationTokenSource(); + processTask.Start(); + processTask.Wait(); + if (posOkCashBag.ProcessOK) + { + CertifyWindow = CertifyWindowType.CertifySuccess; + } + else + { + CertifyWindow = CertifyWindowType.ProcessingError; + } + CashBagRemoveEvents(); + TokenSource.Dispose(); + processTask = null; + TokenSource = null; + } + + } + private void DoBarCodeOkCashBagCertify() + { + InputNumbers = string.Empty; + FormatedBarCode = ReadBarCode.GetEncriptCardNo(); + certifyKey = ReadBarCode; + CertifyWindow = CertifyWindowType.CertifyProcessing; + } + #endregion Method + + #region [ Event Handlers ] + private void PosOkCashBag_ErrorMessageEvent(string ErrorString) + { + ErrorText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = ErrorString.Replace("\n"," ").Replace("\r","") + }, + }; + IsErrorBlink = true; + CertifyWindow = CertifyWindowType.ProcessingError; + } + + private void PosOkCashBag_ErrorEvent(posOkCashBag.ErrorCode _errorCode) + { + //TODO: 공통에 에러 메세지 등록 필요 + //ErrorText = Languages.GetMessages(_errorCode.ToString()); + + ErrorText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = _errorCode.ToString() + }, + }; + IsErrorBlink = true; + CertifyWindow = CertifyWindowType.ProcessingError; + } + + private void PosOkCashBag_ReadStart(object sender) + { + MemberProcessStart = true; + TimerEnabled = false; + } + + private void PosOkCashBag_ReadEnd(object sender) + { + if (sender is posHappyPoint getPosposHappyPoint) + { + if (getPosposHappyPoint.ProcessOK) + { + OkCashBagReturn = new M_OkCashBagReturn + { + MemberName = getPosposHappyPoint.MemberName, + MemberCode = getPosposHappyPoint.CertifyKey, + MemberPoint = getPosposHappyPoint.MemberPoint, + NeedPassword = getPosposHappyPoint.NeedPassword, + ReservePoint = getPosposHappyPoint.CanReservePoint, + }; + ReturnValue = new M_PopupReturn + { + OKAnswer = true, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = OkCashBagReturn + }; + MemberPointsText = string.Format("{0} Points", OkCashBagReturn.MemberPoint.ToString("#,##0")); + CertifyWindow = CertifyWindowType.CertifySuccess; + } + } + TimerEnabled = true; + MemberProcessStart = false; + + } + private void CancelCommandHandler(object obj) + { + TimerEnabled = false; + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + + private void OkCommandHandler(object obj) + { + switch (CertifyWindow) + { + case CertifyWindowType.CertifyStart: + certifyKey = InputNumbers; + CertifyWindow = CertifyWindowType.CertifyProcessing; + break; + case CertifyWindowType.ProcessingError: + CertifyWindow = CertifyWindowType.CertifyStart; + break; + case CertifyWindowType.CertifySuccess: + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + break; + } + + } + + private void VmHappyPointCertify_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "IsTimeout": + if (IsTimeout) + { + switch (CertifyWindow) + { + case CertifyWindowType.CertifyStart: + case CertifyWindowType.ProcessingError: + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = true, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + break; + } + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + } + break; + case "InputNumbers": + if (InputNumbers.Length > 0) + { + InitError(); + ReadBarCode = string.Empty; + } + OKButtonEnabled = InputNumbers.Length.Equals(10) || InputNumbers.Length.Equals(11); + break; + case "ReadBarCode": + if (!MemberProcessStart) + { + InitError(); + switch (ReadBarCode.Length) + { + case 17: + readBarCode = ReadBarCode.Substring(0, 16); + DoBarCodeOkCashBagCertify(); + break; + case 16: + DoBarCodeOkCashBagCertify(); + break; + default: + FormatedBarCode = string.Empty; + OKButtonEnabled = false; + break; + } + } + break; + case "CertifyWindow": + CertifyStartVisible = false; + CertifyProcessingVisible = false; + ProcessingErrorVisible = false; + CertifySuccessVisible = false; + switch (CertifyWindow) + { + case CertifyWindowType.CertifyStart: + CertifyStartVisible = true; + break; + case CertifyWindowType.CertifyProcessing: + CertifyProcessingVisible = true; + break; + case CertifyWindowType.ProcessingError: + ProcessingErrorVisible = true; + break; + case CertifyWindowType.CertifySuccess: + CertifySuccessVisible = true; + break; + } + break; + case "CertifyStartVisible": + if (CertifyStartVisible) + { + ScanGuidText = Languages.GetMessages("LBL0082"); + InfoGuid1Text = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "* 인증시 OK 캐시백 포인트가 적립됩니다." + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "en* 인증시OK 캐시백 포인트가 적립됩니다." + }, + }; + InfoGuid2Text = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "* 수집된 개인정보는 활용 후 자동 폐기 됩니다." + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "en* 수집된 개인정보는 활용 후 자동 폐기 됩니다." + }, + }; + + CancelButtonWidth = PopupWidth; + OKButtonWidth = 0d; + OKButtonEnabled = false; + //OkButtonText = Languages.GetMessages("CommonYes"); + //CancelButtonText = Languages.GetMessages("CommonNo"); + OkButtonText = Languages.GetMessages("CommonOK"); + CancelButtonText = Languages.GetMessages("CommonCancel"); + TimeOutSeconds = CommonValue.TimeOutSeconds; + } + break; + case "CertifyProcessingVisible": + if (CertifyProcessingVisible) + { + ScanGuidText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "인증 처리 진행 중입니다." + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "en인증 처리 진행 중입니다." + }, + }; + //InfoGuid1Text = new List + // { + // new M_Language + // { + // Type = SupportLanguageType.ko, + // LanguageData = "* 화면 상태가 지속되면 직원을 호출 하세요." + // }, + // new M_Language + // { + // Type = SupportLanguageType.en, + // LanguageData = "en* 화면 상태가 지속되면 직원을 호출 하세요." + // }, + // }; + InfoGuid2Text = new List(); + if (ProcessTask != null) ProcessTask.Wait(); + ProcessTask = new Task(DoOkCashBagCertify); + ProcessTask.Start(); + + //if (ProcessTask != null) + //{ + // ProcessTask.Dispose(); + // ProcessTask = null; + //} + //ProcessTask = new Task(DoOkCashBagCertify); + //ProcessTask.Start(); + } + break; + case "ProcessingErrorVisible": + if (ProcessingErrorVisible) + { + ScanGuidText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "인증 처리중 오류가 발생 했습니다." + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "en인증 처리중 오류가 발생 했습니다." + }, + }; + InfoGuid1Text = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "* 10초간 입력이 없으면 취소 처리됩니다." + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "en* 10초간 입력이 없으면 취소 처리됩니다." + }, + }; + + InfoGuid2Text = new List(); + CancelButtonWidth = PopupWidth / 2; + OKButtonWidth = PopupWidth / 2; + OKButtonEnabled = true; + OkButtonText = Languages.GetMessages("CommonRetry"); + CancelButtonText = Languages.GetMessages("CommonCancel"); + TimeOutSeconds = 10d; + } + break; + case "CertifySuccessVisible": + if (CertifySuccessVisible) + { + ScanGuidText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "인증 처리가 완료 되었습니다." + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "en인증 처리가 완료 되었습니다." + }, + }; + InfoGuid1Text = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "* 사용 가능 포인트를 확인하세요." + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "en* 사용 가능 포인트를 확인하세요." + }, + }; + InfoGuid2Text = new List(); + CancelButtonWidth = 0d; + OkButtonText = Languages.GetMessages("CommonOK"); + OKButtonWidth = PopupWidth; + OKButtonEnabled = true; + TimeOutSeconds = 5d; + } + break; + } + } + #endregion Event Handlers + + + } + +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmOkCashBagUsing.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmOkCashBagUsing.cs new file mode 100644 index 0000000..22dc5a4 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmOkCashBagUsing.cs @@ -0,0 +1,781 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; +using System.Windows.Threading; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +namespace SPC.Kiosk.Popup.ViewModel +{ + /// + /// PkCashBagCertify.xaml에 대한 ViewModel + /// + public class VmOkCashBagUsing : PopupViewModelBase + { + #region [ Members ] + private List headerText; + /// + /// Top Header Text (Memebr login) + /// + public List HeaderText + { + get { return headerText; } + set { headerText = value; PropertyChange("HeaderText"); } + } + private List afterHeaderText; + /// + /// Top Header Text (Using Points) + /// + public List AfterHeaderText + { + get { return afterHeaderText; } + set { afterHeaderText = value; PropertyChange("AfterHeaderText"); } + } + private List scanGuidText; + /// + /// Second Header Text (Memebr login) + /// + public List ScanGuidText + { + get { return scanGuidText; } + set { scanGuidText = value; PropertyChange("ScanGuidText"); } + } + private List infoGuid1Text; + /// + /// Bottom first Infomation Text (Memebr login) + /// + public List InfoGuid1Text + { + get { return infoGuid1Text; } + set { infoGuid1Text = value; PropertyChange("InfoGuid1Text"); } + } + private List infoGuid2Text; + /// + /// Bottom second Infomation Text (Memebr login) + /// + public List InfoGuid2Text + { + get { return infoGuid2Text; } + set { infoGuid2Text = value; PropertyChange("InfoGuid2Text"); } + } + private List infoGuid3Text; + /// + /// Bottom first Infomation Text (Using Points) + /// + public List InfoGuid3Text + { + get { return infoGuid3Text; } + set { infoGuid3Text = value; PropertyChange("InfoGuid3Text"); } + } + private List infoGuid4Text; + /// + /// Bottom second Infomation Text (Using Points) + /// + public List InfoGuid4Text + { + get { return infoGuid4Text; } + set { infoGuid4Text = value; PropertyChange("InfoGuid4Text"); } + } + public int numPadMaxLength; + /// + /// Number Pad Max Length + /// + public int NumPadMaxLength + { + get { return numPadMaxLength; } + set { numPadMaxLength = value; PropertyChange("NumPadMaxLength"); } + } + private List numPadGuidText; + /// + /// Number Pad Input Guide Text + /// + public List NumPadGuidText + { + get { return numPadGuidText; } + set { numPadGuidText = value; PropertyChange("NumPadGuidText"); } + } + private List numPadCancelText; + /// + /// Number Pad Cancel Button Text + /// + public List NumPadCancelText + { + get { return numPadCancelText; } + set { numPadCancelText = value; PropertyChange("NumPadCancelText"); } + } + private bool pointPadVisible; + /// + /// Point Pad Visible + /// + public bool PointPadVisible + { + get { return pointPadVisible; } + set { pointPadVisible = value; PropertyChange("PointPadVisible"); } + } + private int pointPadMaxLength; + /// + /// Point Pad Max Length + /// + public int PointPadMaxLength + { + get { return pointPadMaxLength; } + set { pointPadMaxLength = value; PropertyChange("PointPadMaxLength"); } + } + private List pointPadGuidText; + /// + /// Point Pad Input Guide Text + /// + public List PointPadGuidText + { + get { return pointPadGuidText; } + set { pointPadGuidText = value; PropertyChange("PointPadGuidText"); } + } + private List pointPadCancelText; + /// + /// Point Pad Cancel Button Text + /// + public List PointPadCancelText + { + get { return pointPadCancelText; } + set { pointPadCancelText = value; PropertyChange("PointPadCancelText"); } + } + private List cancelButtonText; + /// + /// Cancel Button Text (Member Login) + /// + public List CancelButtonText + { + get { return cancelButtonText; } + set { cancelButtonText = value; PropertyChange("CancelButtonText"); } + } + private List okButtonText; + /// + /// OK Button Text (Member Login) + /// + public List OkButtonText + { + get { return okButtonText; } + set { okButtonText = value; PropertyChange("OkButtonText"); } + } + public bool oKButtonEnabled = false; + /// + /// OK Button Enabled (Member Login) + /// + public bool OKButtonEnabled + { + get { return oKButtonEnabled; } + set { oKButtonEnabled = value; PropertyChange("OKButtonEnabled"); } + } + private List cancelButton2Text; + /// + /// Cancel Button Text (Point Using) + /// + public List CancelButton2Text + { + get { return cancelButton2Text; } + set { cancelButton2Text = value; PropertyChange("CancelButton2Text"); } + } + private List okButton2Text; + /// + /// OK Button Text (Point Using) + /// + public List OkButton2Text + { + get { return okButton2Text; } + set { okButton2Text = value; PropertyChange("OkButton2Text"); } + } + public bool oKButton2Enabled = false; + /// + /// OK Button Enabled (Point using) + /// + public bool OKButton2Enabled + { + get { return oKButton2Enabled; } + set { oKButton2Enabled = value; PropertyChange("OKButton2Enabled"); } + } + private List switchAnswer1Text; + /// + /// Point Reserve Check Button Text + /// + public List SwitchAnswer1Text + { + get { return switchAnswer1Text; } + set { switchAnswer1Text = value; PropertyChange("SwitchAnswer1Text"); } + } + public bool switchAnswer1Switch = false; + /// + /// Point Reserve Check Button Switch + /// + public bool SwitchAnswer1Switch + { + get { return switchAnswer1Switch; } + set { switchAnswer1Switch = value; PropertyChange("SwitchAnswer1Switch"); } + } + private List switchAnswer2Text; + /// + /// Point using Check Button Text + /// + public List SwitchAnswer2Text + { + get { return switchAnswer2Text; } + set { switchAnswer2Text = value; PropertyChange("SwitchAnswer2Text"); } + } + public bool switchAnswer2Switch = false; + /// + /// Point Using Button Switch + /// + public bool SwitchAnswer2Switch + { + get { return switchAnswer2Switch; } + set { switchAnswer2Switch = value; PropertyChange("SwitchAnswer2Switch"); } + } + private List allUseButtonText; + /// + /// All using Points Button Text + /// + public List AllUseButtonText + { + get { return allUseButtonText; } + set { allUseButtonText = value; PropertyChange("AllUseButtonText"); } + } + private List totalPayHeaderText; + /// + /// Payments Total Header Text + /// + public List TotalPayHeaderText + { + get { return totalPayHeaderText; } + set { totalPayHeaderText = value; PropertyChange("TotalPayHeaderText"); } + } + private string formatedBarCode; + /// + /// Formated Read Barcode + /// + public string FormatedBarCode + { + get { return formatedBarCode; } + set { formatedBarCode = value; PropertyChange("FormatedBarCode"); } + } + private string readBarCode; + /// + /// Read Barcode + /// + public string ReadBarCode + { + get { return readBarCode; } + set { readBarCode = value; PropertyChange("ReadBarCode"); } + } + /// + /// Point Reserve Check Flag + /// + private bool reservepoint; + public bool ReservePoint + { + get { return reservepoint; } + set { reservepoint = value; PropertyChange("ReservePoint"); } + } + private double payments; + /// + /// Total Payments + /// + public double Payments + { + get { return payments; } + set { payments = value; PropertyChange("Payments"); } + } + private string showPayment; + /// + /// Total Payments Show Text + /// + public string ShowPayment + { + get { return showPayment; } + set { showPayment = value; PropertyChange("ShowPayment"); } + } + private string memberName; + /// + /// Login Memeber Name + /// + public string MemberName + { + get { return memberName; } + set { memberName = value; PropertyChange("MemberName"); } + } + private double queryPoints; + /// + /// Member Useable All Points + /// + public double QueryPoints + { + get { return queryPoints; } + set { queryPoints = value; PropertyChange("QueryPoints"); } + } + private List errorText; + /// + /// Error Text (Member login) + /// + public List ErrorText + { + get { return errorText; } + set { errorText = value; PropertyChange("ErrorText"); } + } + private bool isErrorBlink = false; + /// + /// Is Error Text Blink (Member login) + /// + public bool IsErrorBlink + { + get { return isErrorBlink; } + set { isErrorBlink = value; PropertyChange("IsErrorBlink"); } + } + private List errorText2; + /// + /// Error Text (Point Using) + /// + public List ErrorText2 + { + get { return errorText2; } + set { errorText2 = value; PropertyChange("ErrorText2"); } + } + private bool isErrorBlink2 = false; + /// + /// Is Error Text Blink (Point using) + /// + public bool IsErrorBlink2 + { + get { return isErrorBlink2; } + set { isErrorBlink2 = value; PropertyChange("IsErrorBlink2"); } + } + private bool toAfterBase = false; + /// + /// Change Grid to Point Using Grid Flag (true => to to Point Using) + /// + public bool ToAfterBase + { + get { return toAfterBase; } + set { toAfterBase = value; PropertyChange("ToAfterBase"); } + } + private List memberInfo; + /// + /// Login Memner Info + /// + public List MemberInfo + { + get { return memberInfo; } + set { memberInfo = value; PropertyChange("MemberInfo"); } + } + private string inputNumbers = string.Empty; + /// + /// Number pad input Numbers + /// + public string InputNumbers + { + get { return inputNumbers; } + set { inputNumbers = value; PropertyChange("InputNumbers"); } + } + private string inputPoints = string.Empty; + /// + /// Point pad Input Points + /// + public string InputPoints + { + get { return inputPoints; } + set { inputPoints = value; PropertyChange("InputPoints"); } + } + private M_OkCashBagReturn okCashBagReturn; + /// + /// Ok Chash bag Return Value + /// + public M_OkCashBagReturn OkCashBagReturn + { + get { return okCashBagReturn; } + set { okCashBagReturn = value; PropertyChange("OkCashBagReturn"); } + } + /// + /// OK Click Command (Member Login) + /// + public ICommand OkCommand { get; protected set; } + /// + /// Cancel Click Command (Member Login & Point Using) + /// + public ICommand CancelCommand { get; protected set; } + /// + /// Ok Click Command (Point Using) + /// + public ICommand Ok2Command { get; protected set; } + /// + /// Point Reserve Click Command + /// + public ICommand SwitchAnswer1Command { get; protected set; } + /// + /// Point Using Click Command + /// + public ICommand SwitchAnswer2Command { get; protected set; } + /// + /// All Using Points Click Command + /// + public ICommand AllUseCommand { get; protected set; } + + private List PointUsingGuid3 = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "* 해피포인트 적립시 OK캐쉬백은 적립할 수 없습니다." + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "en* 해피포인트 적립시 OK캐쉬백은 적립할 수 없습니다." + }, + }; + private List PointUsingGuid4 = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "* 1000P 이상 10P 단위 사용가능." + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "en* * 1000P 이상 10P 단위 사용가능." + }, + }; + private List ReservePoint3 = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "* 최종 결제후 자동 적립됩니다." + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "en* 최종 결제후 자동 적립됩니다." + }, + }; + private List ReservePoint4 = new List(); + private bool MemberProcessStart = false; + private Task ProcessTask = null; + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public VmOkCashBagUsing() + { + OkCommand = new Command(OkCommandHandler); + CancelCommand = new Command(CancelCommandHandler); + Ok2Command = new Command(Ok2CommandHandler); + SwitchAnswer1Command = new Command(SwitchAnswer1CommandHandler); + SwitchAnswer2Command = new Command(SwitchAnswer2CommandHandler); + AllUseCommand = new Command(AllUseCommandHandler); + this.PropertyChanged += VmOkCashBagCertify_PropertyChanged; + HeaderText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "OK 캐쉬백 회원인증" + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "OK CASHBAG Member Certify" + }, + }; + AfterHeaderText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "OK 캐쉬백" + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "OK CASHBAG" + }, + }; + ScanGuidText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "바코드 스켄 또는 전화 번호를 입력하세요." + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "en바코드 스켄 또는 전화 번호를 입력하세요." + }, + }; + InfoGuid1Text = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "* 해피포인트 적립시 OK캐쉬백은 적립할 수 없습니다." + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "en* 해피포인트 적립시 OK캐쉬백은 적립할 수 없습니다." + }, + }; + InfoGuid2Text = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "* 수집된 개인정보는 활용 후 자동 폐기 됩니다." + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "en* 수집된 개인정보는 활용 후 자동 폐기 됩니다." + }, + }; + NumPadMaxLength = 11; + NumPadGuidText = Languages.GetMessages("MobileNumberMessage"); + NumPadCancelText = Languages.GetMessages("CommonClear"); + PointPadMaxLength = 9; + PointPadGuidText = Languages.GetMessages("InputUsingPoints"); + PointPadCancelText = Languages.GetMessages("CommonClear"); + CancelButtonText = Languages.GetMessages("CommonCancel"); + OkButtonText = Languages.GetMessages("CommonOK"); + CancelButton2Text = Languages.GetMessages("CommonCancel"); + OkButton2Text = Languages.GetMessages("CommonOK"); + SwitchAnswer1Text = Languages.GetMessages("CommonReserve"); + SwitchAnswer2Text = Languages.GetMessages("CommonUsing"); + AllUseButtonText = Languages.GetMessages("CommonUsingAll"); + TotalPayHeaderText = Languages.GetMessages("PriceForPayment"); + if (!ReservePoint) PointPadVisible = true; + } + + ~VmOkCashBagUsing() + { + this.PropertyChanged -= VmOkCashBagCertify_PropertyChanged; + } + #endregion Ctor + + #region [ Methods ] + private bool PointValueCheck() + { + bool result = false; + try + { + if (!Payments.Equals(0) && QueryPoints >= 1000) + { + var checkValue = int.Parse(InputPoints); + if (checkValue >= 1000) + { + result = (checkValue % 10).Equals(0) + && checkValue <= QueryPoints + && checkValue <= Payments; + } + } + + } + catch + { + result = false; + } + return result; + } + private void DoOkCashBagCertify() + { + TimerEnabled = false; + MemberProcessStart = true; + //TODO : OK CASHBAG Point 조회 + OkCashBagReturn = new M_OkCashBagReturn + { + MemberName = "홍길동", + MemberPoint = 120501, + MemberCode = ReadBarCode.Equals(string.Empty) ? InputNumbers : ReadBarCode, + }; + MemberName = OkCashBagReturn.MemberName; + QueryPoints = OkCashBagReturn.MemberPoint; + ToAfterBase = true; + TimerEnabled = true; + } + #endregion Methods + + #region [ Event Handlers ] + private void AllUseCommandHandler(object obj) + { + if (QueryPoints > 1000) + { + var canUseAllPoints = QueryPoints - QueryPoints % 10; + if (!Payments.Equals(0)) + { + if (Payments < canUseAllPoints) + { + InputPoints = Payments.ToString(); + } + else + { + InputPoints = canUseAllPoints.ToString(); + } + } + } + } + + private void CancelCommandHandler(object obj) + { + TimerEnabled = false; + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + + private void OkCommandHandler(object obj) + { + DoOkCashBagCertify(); + } + + private void Ok2CommandHandler(object obj) + { + TimerEnabled = false; + OkCashBagReturn.ReservePoint = SwitchAnswer1Switch; + OkCashBagReturn.PointUse = SwitchAnswer2Switch; + OkCashBagReturn.UsingPoints = string.IsNullOrEmpty(InputPoints) + ? 0 : int.Parse(InputPoints); + ReturnValue = new M_PopupReturn + { + OKAnswer = true, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = OkCashBagReturn + }; + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + } + + private void SwitchAnswer1CommandHandler(object obj) + { + if (SwitchAnswer2Switch) + { + OKButton2Enabled = PointValueCheck(); + + } + else + { + OKButton2Enabled = ReservePoint ? SwitchAnswer1Switch : false; + } + } + + private void SwitchAnswer2CommandHandler(object obj) + { + if (!ReservePoint) SwitchAnswer2Switch = true; + if (SwitchAnswer2Switch) + { + InfoGuid3Text = PointUsingGuid3; + InfoGuid4Text = PointUsingGuid4; + if (!Payments.Equals(0)) + { + PointPadVisible = true; + OKButton2Enabled = PointValueCheck(); + } + else + { + SwitchAnswer2Switch = false; + } + + } + else + { + InfoGuid3Text = ReservePoint3; + InfoGuid4Text = ReservePoint4; + InputPoints = string.Empty; + PointPadVisible = false; + OKButton2Enabled = ReservePoint ? SwitchAnswer1Switch : false; + } + } + + private void VmOkCashBagCertify_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "IsTimeout": + if (IsTimeout) + { + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = true, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + } + break; + case "ReservePoint": + if (ReservePoint) + { + InfoGuid3Text = ReservePoint3; + InfoGuid4Text = ReservePoint4; + PointPadVisible = false; + } + else + { + SwitchAnswer2Switch = true; + OKButton2Enabled = false; + InfoGuid3Text = PointUsingGuid3; + InfoGuid4Text = PointUsingGuid4; + } + break; + case "InputNumbers": + if (InputNumbers.Length > 0) ReadBarCode = string.Empty; + OKButtonEnabled = NumPadMaxLength.Equals(InputNumbers.Length); + break; + case "InputPoints": + OKButton2Enabled = PointValueCheck(); + break; + case "Payments": + ShowPayment = string.Format(@"\{0}", Payments.ToString("#,##0")); + break; + case "MemberName": + case "QueryPoints": + var memberInfo = string.Format("{0}({1}P)" + , MemberName.GetEncriptName(), QueryPoints.ToString("#,###0")); + MemberInfo = new List + { + new M_Language { Type=SupportLanguageType.ko, LanguageData = memberInfo } + }; + break; + case "ReadBarCode": + if (!MemberProcessStart) + { + switch (ReadBarCode.Length) + { + case 16: + InputNumbers = string.Empty; + FormatedBarCode = ReadBarCode.GetEncriptCardNo(); + DoOkCashBagCertify(); + break; + default: + FormatedBarCode = string.Empty; + OKButtonEnabled = false; + break; + } + } + break; + } + } + #endregion Event Handlers + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmOptionSelect.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmOptionSelect.cs new file mode 100644 index 0000000..3cece47 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmOptionSelect.cs @@ -0,0 +1,329 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Threading; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +namespace SPC.Kiosk.Popup.ViewModel +{ + /// + /// OptionSelect.xaml 의 ViewModel + /// + public class VmOptionSelect : PopupViewModelBase + { + #region [ Members ] + /// + /// Return Data + /// + public M_OptionReturn OptionReturn { get; set; } + + private double itemPrice; + public double ItemPrice + { + get { return itemPrice; } + set { itemPrice = value; PropertyChange("ItemPrice"); } + } + private List options; + /// + /// Option Data + /// + public List Options + { + get { return options; } + set { options = value; PropertyChange("Options"); } + } + + private List headerText; + /// + /// Top Header Text + /// + public List HeaderText + { + get { return headerText; } + set { headerText = value; PropertyChange("HeaderText"); } + } + private List scanGuidText; + /// + /// Second Sub Header Text + /// + public List ScanGuidText + { + get { return scanGuidText; } + set { scanGuidText = value; PropertyChange("ScanGuidText"); } + } + + private string itemImageBrush; + /// + /// Item Image + /// + public string ItemImageBrush + { + get { return itemImageBrush; } + set { itemImageBrush = value; PropertyChange("ItemImageBrush"); } + } + private M_AnimationButton leftButtonData= null; + /// Combo Right Left Data + public M_AnimationButton LeftButtonData + { + get { return leftButtonData; } + set { leftButtonData = value; PropertyChange("LeftButtonData"); } + } + private M_AnimationButton rightButtonData = null; + /// + /// Combo Right Button Data + /// + public M_AnimationButton RightButtonData + { + get { return rightButtonData; } + set { rightButtonData = value; PropertyChange("RightButtonData"); } + } + + + private List itemName; + /// + /// Second Sub Header Text + /// + public List ItemName + { + get { return itemName; } + set { itemName = value; PropertyChange("ItemName"); } + } + private int itemCount = 1; + /// + /// Item Count + /// + public int ItemCount + { + get { return itemCount; } + set { itemCount = value; PropertyChange("ItemCount"); } + } + private double unitPrice; + public double UnitPrice + { + get { return unitPrice; } + set { unitPrice = value; PropertyChange("UnitPrice"); } + } + private List totalPriceLabel; + /// + /// Second Sub Header Text + /// + public List TotalPriceLabel + { + get { return totalPriceLabel; } + set { totalPriceLabel = value; PropertyChange("TotalPriceLabel"); } + } + + private double totalPrice; + public double TotalPrice + { + get { return totalPrice; } + set { totalPrice = value; PropertyChange("TotalPrice"); } + } + private List cancelButtonText; + /// + /// Cancel Button Text + /// + public List CancelButtonText + { + get { return cancelButtonText; } + set { cancelButtonText = value; PropertyChange("CancelButtonText"); } + } + private List okButtonText; + /// + /// OK Button Text + /// + public List OkButtonText + { + get { return okButtonText; } + set { okButtonText = value; PropertyChange("OkButtonText"); } + } + /// + /// OK Click Command + /// + public ICommand OkCommand { get; protected set; } + /// + /// Cancel Click Command + /// + public ICommand CancelCommand { get; protected set; } + /// + /// Option Changed Command + /// + public ICommand OptionCommand { get; protected set; } + private bool editMode = false; + /// + /// Edit Mode + /// + public bool EditMode + { + get { return editMode; } + set { editMode = value; PropertyChange("EditMode"); } + } + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public VmOptionSelect() + { + OkCommand = new Command(OkCommandHandler); + CancelCommand = new Command(CancelCommandHandler); + OptionCommand = new Command(OptionCommandHandler); + LeftButtonData = new M_AnimationButton + { + NormalBrush = ResourceManager.GetNximagePathAdd("btn_count_minus_n.png", CommonValue.PBdesignImagesPath), + DownBrush = ResourceManager.GetNximagePathAdd("btn_count_minus_p.png", CommonValue.PBdesignImagesPath), + BrushStretch = Stretch.Fill, + DragEnable = false, + Width = 36, + Height = 36, + Switch = false, + AutoToggle = false, + TextVisible = Visibility.Collapsed, + ClickAnimationType = ButtonAnimationType.None, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty, + }; + RightButtonData = new M_AnimationButton + { + NormalBrush = ResourceManager.GetNximagePathAdd("btn_count_plus_n.png", CommonValue.PBdesignImagesPath), + DownBrush = ResourceManager.GetNximagePathAdd("btn_count_plus_p.png", CommonValue.PBdesignImagesPath), + BrushStretch = Stretch.Fill, + DragEnable = false, + Width = 36, + Height = 36, + Switch = false, + AutoToggle = false, + TextVisible = Visibility.Collapsed, + ClickAnimationType = ButtonAnimationType.None, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty, + }; + this.PropertyChanged += VmOptionSelect_PropertyChanged; + HeaderText = Languages.GetMessages("LBL0115"); + TotalPriceLabel = Languages.GetMessages("LBL0132"); + ScanGuidText = Languages.GetMessages("LBL0068"); + ShowLanguageType = CommonValue.CommonLanguageType; + CancelButtonText = Languages.GetMessages("BTN0033"); + OkButtonText = Languages.GetMessages("BTN0024"); + } + + + ~VmOptionSelect() + { + this.PropertyChanged -= VmOptionSelect_PropertyChanged; + } + #endregion Ctor + + #region [ Methods ] + private void CalcUnitPrice(object _param) + { + if (_param is List changedOption) + { + + var optionPrice = ItemPrice; + foreach (var aGroup in changedOption) + { + foreach (var aOption in aGroup.Options) + { + if ((aOption.Kind.Equals(OptionKind.Discount) + || aOption.Kind.Equals(OptionKind.UpCharge)) + && aOption.IsSelected) + { + optionPrice += aOption.SelectValue; + } + } + } + UnitPrice = optionPrice; + } + } + #endregion Methods + + #region [ Event Handlers ] + private void OptionCommandHandler(object _param) + { + CalcUnitPrice(_param); + } + private void CancelCommandHandler(object obj) + { + TimerEnabled = false; + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + + private void OkCommandHandler(object obj) + { + TimerEnabled = false; + var newOptionReturn = new M_OptionReturn + { + ItemCount = ItemCount, + PriceWithOption = UnitPrice, + Options = Options + }; + ReturnValue = new M_PopupReturn + { + OKAnswer = true, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = newOptionReturn + }; + CanWindowClose = true; + } + + private void VmOptionSelect_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + try + { + switch (e.PropertyName) + { + case "IsTimeout": + if (IsTimeout) + { + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = true, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + break; + case "ItemPrice": + CalcUnitPrice(Options); + break; + case "ItemCount": + case "UnitPrice": + if (ItemCount > 0 && UnitPrice > 0) + { + TotalPrice = ItemCount * UnitPrice; + } + break; + } + } + catch (Exception ex) + { + + CommonLog.ErrorLogWrite(this, "VmOptionSelect_PropertyChanged()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + + #endregion Event Handlers + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmPaymentProcess.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmPaymentProcess.cs new file mode 100644 index 0000000..6dd4afd --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmPaymentProcess.cs @@ -0,0 +1,896 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Input; +using System.Windows.Threading; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Payments; + +namespace SPC.Kiosk.Popup.ViewModel +{ + /// + /// HappyPointCertify.xaml에 대한 ViewModel + /// + public class VmPaymentProcess : PopupViewModelBase + { + #region [ Members ] + private string titileImage; + /// + /// Read Barcode Formated Text + /// + public string TitileImage + { + get { return titileImage; } + set { titileImage = value; PropertyChange("TitileImage"); } + } + private string processingGIF; + /// + /// Processing GIF + /// + public string ProcessingGIF + { + get { return processingGIF; } + set { processingGIF = value; PropertyChange("ProcessingGIF"); } + } + private string errorImage; + /// + /// Error Icon + /// + public string ErrorImage + { + get { return errorImage; } + set { errorImage = value; PropertyChange("ErrorImage"); } + } + private string successImage; + /// + /// Sucess Icon + /// + public string SuccessImage + { + get { return successImage; } + set { successImage = value; PropertyChange("SuccessImage"); } + } + private List headerText; + /// + /// Top Header Text + /// + public List HeaderText + { + get { return headerText; } + set { headerText = value; PropertyChange("HeaderText"); } + } + private List scanGuidText; + /// + /// Second Sub Header Text + /// + public List ScanGuidText + { + get { return scanGuidText; } + set { scanGuidText = value; PropertyChange("ScanGuidText"); } + } + private List processingMessageText; + /// + /// Number Pad Input Guide Text + /// + public List ProcessingMessageText + { + get { return processingMessageText; } + set { processingMessageText = value; PropertyChange("ProcessingMessageText"); } + } + private List processingGuide; + /// + /// Processing Guide Text + /// + public List ProcessingGuide + { + get { return processingGuide; } + set { processingGuide = value; PropertyChange("ProcessingGuide"); } + } + private List errorGuide; + /// + /// Error Guide Text + /// + public List ErrorGuide + { + get { return errorGuide; } + set { errorGuide = value; PropertyChange("ErrorGuide"); } + } + + private List infoGuid1Text; + /// + /// Bootom first infomation text + /// + public List InfoGuid1Text + { + get { return infoGuid1Text; } + set { infoGuid1Text = value; PropertyChange("InfoGuid1Text"); } + } + private TextAlignment infoGuid1TextAlignment = TextAlignment.Left; + public TextAlignment InfoGuid1TextAlignment + { + get { return infoGuid1TextAlignment; } + set { infoGuid1TextAlignment = value; PropertyChange("InfoGuid1TextAlignment"); } + } + private List infoGuid2Text; + /// + /// Bootom Second infomation text + /// + public List InfoGuid2Text + { + get { return infoGuid2Text; } + set { infoGuid2Text = value; PropertyChange("InfoGuid2Text"); } + } + private List leftInfomationText; + /// + /// Bootom Second infomation text + /// + public List LeftInfomationText + { + get { return leftInfomationText; } + set { leftInfomationText = value; PropertyChange("LeftInfomationText"); } + } + private bool paymentStartVisible = false; + /// + /// ReadCardOrBarCode Window Is Visible + /// + public bool PaymentStartVisible + { + get { return paymentStartVisible; } + set { paymentStartVisible = value; PropertyChange("PaymentStartVisible"); } + } + private bool readSignVisible = false; + /// + /// PaymentProcessing Window Is Visible + /// + public bool ReadSignVisible + { + get { return readSignVisible; } + set { readSignVisible = value; PropertyChange("ReadSignVisible"); } + } + private bool paymentProcessingVisible = false; + /// + /// PaymentProcessing Window Is Visible + /// + public bool PaymentProcessingVisible + { + get { return paymentProcessingVisible; } + set { paymentProcessingVisible = value; PropertyChange("PaymentProcessingVisible"); } + } + private bool processingErrorVisible = false; + /// + /// ProcessingError Window Is Visible + /// + public bool ProcessingErrorVisible + { + get { return processingErrorVisible; } + set { processingErrorVisible = value; PropertyChange("ProcessingErrorVisible"); } + } + + private bool paymentSuccessVisible = false; + /// + /// Payment Success Window Is Visible + /// + public bool PaymentSuccessVisible + { + get { return paymentSuccessVisible; } + set { paymentSuccessVisible = value; PropertyChange("PaymentSuccessVisible"); } + } + private List errorText; + /// + /// Process Error Text + /// + public List ErrorText + { + get { return errorText; } + set { errorText = value; PropertyChange("ErrorText"); } + } + private bool isErrorBlink = false; + /// + /// Is Error Text Blink + /// + public bool IsErrorBlink + { + get { return isErrorBlink; } + set { isErrorBlink = value; PropertyChange("IsErrorBlink"); } + } + private string formatedBarCode; + /// + /// Read Barcode Formated Text + /// + public string FormatedBarCode + { + get { return formatedBarCode; } + set { formatedBarCode = value; PropertyChange("FormatedBarCode"); } + } + private string readBarCode; + /// + /// Read Barcode + /// + public string ReadBarCode + { + get { return readBarCode; } + set { readBarCode = value; PropertyChange("ReadBarCode"); } + } + private double payments; + /// + /// Total Payments + /// + public double Payments + { + get { return payments; } + set { payments = value; PropertyChange("Payments"); } + } + private string showPayment; + /// + /// Total Payments + /// + public string ShowPayment + { + get { return showPayment; } + set { showPayment = value; PropertyChange("ShowPayment"); } + } + private double popupWidth = 1300d; + /// + /// Popup Whidth (For Calculate OK Button Width) + /// + public double PopupWidth + { + get { return popupWidth; } + set { popupWidth = value; PropertyChange("PopupWidth"); } + } + private List cancelButtonText; + /// + /// Cancel Button Text + /// + public List CancelButtonText + { + get { return cancelButtonText; } + set { cancelButtonText = value; PropertyChange("CancelButtonText"); } + } + + private double cancelButtonWidth = 650d; + /// + /// Cancel Button Width + /// + public double CancelButtonWidth + { + get { return cancelButtonWidth; } + set { cancelButtonWidth = value; PropertyChange("CancelButtonWidth"); } + } + + private List okButtonText; + /// + /// OK Button Text + /// + public List OkButtonText + { + get { return okButtonText; } + set { okButtonText = value; PropertyChange("OkButtonText"); } + } + private bool oKButtonEnabled = false; + /// + /// OK Button Enabled + /// + public bool OKButtonEnabled + { + get { return oKButtonEnabled; } + set { oKButtonEnabled = value; PropertyChange("OKButtonEnabled"); } + } + + private double okButtonWidth = 650d; + /// + /// OK Button Width + /// + public double OKButtonWidth + { + get { return okButtonWidth; } + set { okButtonWidth = value; PropertyChange("OKButtonWidth"); } + } + private string signData; + /// + /// SignData + /// + public string SignData + { + get { return signData; } + set { signData = value; PropertyChange("SignData"); } + } + private string signFile; + /// + /// SignFile + /// + public string SignFile + { + get { return signFile; } + set { signFile = value; PropertyChange("SignFile"); } + } + private bool useableSign; + /// + /// Useable Sign + /// + public bool UseableSign + { + get { return useableSign; } + set { useableSign = value; PropertyChange("UseableSign"); } + } + private bool signEnd; + /// + /// Sign End + /// + public bool SignEnd + { + get { return signEnd; } + set { signEnd = value; PropertyChange("SignEnd"); } + } + private bool signReset; + /// + /// Sign Reset + /// + public bool SignReset + { + get { return signReset; } + set { signReset = value; PropertyChange("SignReset"); } + } + /// + /// 결제 처리 정보 + /// + public M_PaymentReturn PaymentReturn { get; set; } + /// + /// OK Click Command + /// + public ICommand OkCommand { get; protected set; } + + /// + /// Cancel Click Command + /// + public ICommand CancelCommand { get; protected set; } + private LastPaymentsType paymentType = LastPaymentsType.None; + public LastPaymentsType PaymentType + { + get { return paymentType; } + set { paymentType = value; PropertyChange("PaymentType"); } + } + private PaymentWindowType paymentWindow = PaymentWindowType.None; + /// + /// Current View Window + /// + public PaymentWindowType PaymentWindow + { + get { return paymentWindow; } + set { paymentWindow = value; PropertyChange("PaymentWindow"); } + } + public bool ImmediatelyClose { get; protected set; } = false; + + private bool ProcessStart = false; + private posLastPayments PosLastPayments = null; + + private Task ProcessTask = null; + private Task ProcessTask2 = null; + private CancellationTokenSource TokenSource; + private string certifyKey = string.Empty; + + #endregion + + #region [ Ctor ] + /// + /// Ctor + /// + public VmPaymentProcess() + { + OkCommand = new Command(OkCommandHandler); + CancelCommand = new Command(CancelCommandHandler); + this.PropertyChanged += VmHappyPointCertify_PropertyChanged; + + ProcessingGIF = ResourceManager.GetNximagePathAdd("ic_alert_ing2.gif", CommonValue.PBdesignImagesPath); + SuccessImage = ResourceManager.GetNximagePathAdd("ic_alert_check.png", CommonValue.PBdesignImagesPath); + ErrorImage = ResourceManager.GetNximagePathAdd("ic_alert_error.png", CommonValue.PBdesignImagesPath); + HeaderText = Languages.GetMessages("LBL0026"); + + ProcessingMessageText = Languages.GetMessages("LBL0031"); + ProcessingGuide = Languages.GetMessages("LBL0140"); + ErrorGuide = Languages.GetMessages("LBL0028"); + ErrorText = new List(); + ShowLanguageType = CommonValue.CommonLanguageType; + PaymentWindow = PaymentWindowType.PaymentStart; + PosLastPayments = new posLastPayments(); + } + /// + /// Dispose() + /// + public new void Dispose() + { + this.TitileImage = string.Empty; + this.ProcessingGIF = string.Empty; + this.ErrorImage = string.Empty; + this.PropertyChanged -= VmHappyPointCertify_PropertyChanged; + if (TokenSource != null) + { + TokenSource.Cancel(); + } + if (PosLastPayments != null) + { + PaymentProcessRemoveEvents(); + PosLastPayments.Dispose(); + PosLastPayments = null; + } + if (ProcessTask != null) + { + //ProcessTask.Dispose(); + ProcessTask = null; + } + base.Dispose(); + } + #endregion Ctor + + #region [ Methods ] + private void PaymentProcessCreateEvents() + { + if (PosLastPayments != null) + { + PosLastPayments.ReadStart += posLastPayments_ReadStart; + PosLastPayments.ReadEnd += posLastPayments_ReadEnd; + PosLastPayments.SignStartEvent += posLastPayments_SignStartEvent; + PosLastPayments.SignEndEvent += PosLastPayments_SignEndEvent; + PosLastPayments.ErrorEvent += posLastPayments_ErrorEvent; + PosLastPayments.ErrorMessageEvent += posLastPayments_ErrorMessageEvent; + } + } + + private void posLastPayments_SignStartEvent(object sender) + { + PaymentWindow = PaymentWindowType.ReadSign; + } + + private void PosLastPayments_SignEndEvent(object sender) + { + PaymentWindow = PaymentWindowType.PaymentProcessing; + } + + private void PaymentProcessRemoveEvents() + { + if (PosLastPayments != null) + { + PosLastPayments.ReadStart -= posLastPayments_ReadStart; + PosLastPayments.ReadEnd -= posLastPayments_ReadEnd; + PosLastPayments.SignStartEvent -= posLastPayments_SignStartEvent; + PosLastPayments.SignEndEvent -= PosLastPayments_SignEndEvent; + PosLastPayments.ErrorEvent -= posLastPayments_ErrorEvent; + PosLastPayments.ErrorMessageEvent -= posLastPayments_ErrorMessageEvent; + } + } + + private void DoPaymentProcess() + { + + + try + { + #region 결제 처리 Task 처리 + PosLastPayments.NoSignLimitAmount = CommonValue.NoSignAmountMaxLimit; + if (PosLastPayments != null) + { + TimerEnabled = false; + SignReset = false; + SignEnd = false; + PaymentProcessCreateEvents(); + ProcessTask2 = new Task(() => PosLastPayments.StartCertifyProcessing(PaymentType, certifyKey, Payments)); + TokenSource = new CancellationTokenSource(); + ProcessTask2.Start(); + ProcessTask2.Wait(); + PaymentProcessRemoveEvents(); + PaymentWindow = PosLastPayments.ProcessOK ? PaymentWindowType.PaymentSuccess : PaymentWindowType.ProcessingError; + TokenSource.Dispose(); + ProcessTask2.Dispose(); + ProcessTask2 = null; + TokenSource = null; + } + #endregion + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "DoPaymentProcess()", "Fail !!", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + TimerEnabled = true; + } + } + #endregion Methods + + #region [ Event Handlers ] + + private void CancelCommandHandler(object obj) + { + switch (PaymentWindow) + { + case PaymentWindowType.ProcessingError: + case PaymentWindowType.PaymentStart: + TimerEnabled = false; + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + break; + case PaymentWindowType.ReadSign: + SignReset = true; + break; + } + + } + private void OkCommandHandler(object obj) + { + switch (PaymentWindow) + { + case PaymentWindowType.ProcessingError: + PaymentWindow = PaymentWindowType.PaymentStart; + break; + case PaymentWindowType.PaymentSuccess: + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + break; + case PaymentWindowType.ReadSign: + SignEnd = true; + break; + } + } + private void posLastPayments_ErrorMessageEvent(string ErrorString) + { + ErrorText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = ErrorString.Replace("\n"," ").Replace("\r","") + }, + }; + IsErrorBlink = true; + } + + private void posLastPayments_ErrorEvent(posLastPayments.ErrorCode _errorCode) + { + //TODO: 공통에 에러 메세지 등록 필요 + //ErrorText = Languages.GetMessages(_errorCode.ToString()); + var errTxt = string.Empty; + + switch (_errorCode) + { + case posLastPayments.ErrorCode.LastPaymentsCardNumberError: + errTxt = "카드를 리딩에 실패했습니다. \n다시 결제 버튼을 눌러 다시 시도하세요."; + break; + case posLastPayments.ErrorCode.LastPaymentsCardReadingError: + errTxt = "카드를 리딩에 실패했습니다. \n다시 결제 버튼을 눌러 다시 시도하세요."; + break; + case posLastPayments.ErrorCode.LastPaymentsEncrtipError: + errTxt = "암호화 에러가 발생했습니다."; + break; + case posLastPayments.ErrorCode.LastPaymentsNotInitailzedError: + errTxt = "초기화 에러가 발생했습니다."; + break; + case posLastPayments.ErrorCode.LastPaymentsProcessingTimeOut: + errTxt = "처리시간이 초과되었습니다. \n재결제 버튼을 눌러 다시 시도하세요."; + break; + case posLastPayments.ErrorCode.LastPaymentsUnknownError: + errTxt = "에러가 발생했습니다."; + break; + default: + break; + + + } + + ErrorText = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + //LanguageData = _errorCode.ToString() + LanguageData = errTxt + }, + }; + IsErrorBlink = true; + } + + private void posLastPayments_ReadStart(object sender) + { + TimerEnabled = false; + ProcessStart = true; + switch (PaymentType) + { + case LastPaymentsType.IcCard: + case LastPaymentsType.SsLgPay: + case LastPaymentsType.CashBee: + case LastPaymentsType.HappyGift: + case LastPaymentsType.Tmoney: + case LastPaymentsType.SpcEmployee: + case LastPaymentsType.SmilePay: + PaymentWindow = PaymentWindowType.PaymentProcessing; + break; + } + } + + private void posLastPayments_ReadEnd(object sender) + { + ProcessStart = false; + try + { + if (sender is posLastPayments getposLastPayments) + { + if (getposLastPayments.ProcessOK) + { + PaymentReturn = new M_PaymentReturn + { + IsProcessOK = true, + PaymentsTotal = getposLastPayments.PaymentsValue, + PaySEQ = getposLastPayments.PaySEQ, + + }; + ReturnValue = new M_PopupReturn + { + OKAnswer = true, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = PaymentReturn + + }; + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "posLastPayments_ReadEnd()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + + } + private void VmHappyPointCertify_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + try + { + switch (e.PropertyName) + { + case "IsTimeout": + if (IsTimeout) + { + #region 입력시간 초과시 + switch (PaymentWindow) + { + case PaymentWindowType.PaymentStart: + case PaymentWindowType.ProcessingError: + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = true, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + break; + } + if (!ProcessStart) CanWindowClose = true; + #endregion + } + break; + case "PaymentWindow": + #region 창 모두 안보이게 하기 + PaymentStartVisible = false; + ReadSignVisible = false; + PaymentProcessingVisible = false; + ProcessingErrorVisible = false; + PaymentSuccessVisible = false; + #endregion + + #region 선택창 보이기 + switch (PaymentWindow) + { + case PaymentWindowType.PaymentStart: + PaymentStartVisible = true; + break; + case PaymentWindowType.ReadSign: + ReadSignVisible = true; + break; + case PaymentWindowType.PaymentProcessing: + PaymentProcessingVisible = true; + break; + case PaymentWindowType.ProcessingError: + ProcessingErrorVisible = true; + break; + case PaymentWindowType.PaymentSuccess: + PaymentSuccessVisible = true; + break; + } + #endregion + break; + case "PaymentType": + switch (PaymentType) + { + case LastPaymentsType.IcCard: + TitileImage = ResourceManager.GetNximagePathAdd("img_gif_card.gif", CommonValue.PBdesignImagesPath); + ScanGuidText = Languages.GetMessages("LBL0084"); + break; + case LastPaymentsType.SsLgPay: + TitileImage = ResourceManager.GetNximagePathAdd("img_gif_pay.gif", CommonValue.PBdesignImagesPath); + ScanGuidText = Languages.GetMessages("LBL0083"); + break; + case LastPaymentsType.SmilePay: + TitileImage = ResourceManager.GetNximagePathAdd("img_gif_barcode.gif", CommonValue.PBdesignImagesPath); + ScanGuidText = Languages.GetMessages("LBL0082"); + break; + } + break; + case "PaymentStartVisible": + if (PaymentStartVisible) + { + #region 카드 또는 신용카드 리딩 처리 + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + InfoGuid1TextAlignment = TextAlignment.Left; + CancelButtonText = Languages.GetMessages("BTN0033"); + CancelButtonWidth = PopupWidth; + OKButtonWidth = 0; + TimeOutSeconds = CommonValue.TimeOutSeconds; + switch (PaymentType) + { + case LastPaymentsType.IcCard: + case LastPaymentsType.SsLgPay: + case LastPaymentsType.CashBee: + case LastPaymentsType.HappyGift: + case LastPaymentsType.Tmoney: + case LastPaymentsType.SpcEmployee: + if (ProcessTask != null) ProcessTask.Wait(); + ProcessTask = new Task(DoPaymentProcess); + ProcessTask.Start(); + break; + } + #endregion + } + break; + case "ReadSignVisible": + if (ReadSignVisible) + { + ScanGuidText = Languages.GetMessages("LBL0072"); + InfoGuid1Text = Languages.GetMessages("LBL0066"); + InfoGuid2Text = new List + { + new M_Language + { + Type = SupportLanguageType.ko, + LanguageData = "* 싸인이 너무 짧거나 길면 확인 버튼이 활성화 되지 않습니다." + }, + new M_Language + { + Type = SupportLanguageType.en, + LanguageData = "en* * * 싸인이 너무 짧거나 길면 확인 버튼이 활성화 되지 않습니다." + }, + }; + CancelButtonText = Languages.GetMessages("BTN0007"); + CancelButtonWidth = PopupWidth / 2; + OkButtonText = Languages.GetMessages("BTN0024"); + OKButtonWidth = PopupWidth / 2; + OKButtonEnabled = false; + } + break; + case "PaymentProcessingVisible": + if (PaymentProcessingVisible) + { + if (PaymentType == LastPaymentsType.SmilePay) + { + //ScanGuidText = Languages.GetMessages("LBL0087"); + ProcessingMessageText = Languages.GetMessages("LBL0087"); + } + else + { + ScanGuidText = Languages.GetMessages("LBL0032"); + } + + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + OKButtonWidth = 0d; + CancelButtonWidth = 0d; + + if (!SignEnd) + { + switch (PaymentType) + { + case LastPaymentsType.SmilePay: + case LastPaymentsType.AliPay: + case LastPaymentsType.ZeroPay: + if (ProcessTask != null) ProcessTask.Wait(); + ProcessTask = new Task(DoPaymentProcess); + ProcessTask.Start(); + break; + } + } + } + break; + case "ProcessingErrorVisible": + if (ProcessingErrorVisible) + { + #region 처리 실패 오류 창 + ScanGuidText = new List(); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + InfoGuid1TextAlignment = TextAlignment.Left; + CancelButtonText = Languages.GetMessages("BTN0003"); + CancelButtonWidth = PopupWidth / 2; + OkButtonText = Languages.GetMessages("BTN0006"); + OKButtonWidth = PopupWidth / 2; + OKButtonEnabled = true; + TimeOutSeconds = 10d; + #endregion + } + break; + case "PaymentSuccessVisible": + if (PaymentSuccessVisible) + { + if (PaymentType == LastPaymentsType.SmilePay) + { + ScanGuidText = Languages.GetMessages("LBL0087"); + } + else + { + ScanGuidText = Languages.GetMessages("LBL0029"); + } + + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + OKButtonWidth = 0d; + CancelButtonWidth = 0d; + ImmediatelyClose = true; + TimeOutSeconds = 0d; + } + break; + case "ReadBarCode": + if (!ProcessStart) + { + switch (PaymentType) + { + case LastPaymentsType.SmilePay: + case LastPaymentsType.AliPay: + case LastPaymentsType.ZeroPay: + switch (ReadBarCode.Length) + { + case 16: + case 17: + certifyKey = ReadBarCode.Substring(0, 16); + FormatedBarCode = ReadBarCode.GetEncriptCardNo(); + PaymentWindow = PaymentWindowType.PaymentProcessing; + break; + default: + FormatedBarCode = string.Empty; + break; + } + break; + } + } + break; + case "UseableSign": + OKButtonEnabled = UseableSign; + break; + case "SignData": + if (PosLastPayments != null && !string.IsNullOrEmpty(SignData)) + { + PosLastPayments.SignData = SignData; + PosLastPayments.SignEndStatus = true; + } + break; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "VmHappyPointCertify_PropertyChanged()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + #endregion Event Handlers + } + +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmPaymentsEnd.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmPaymentsEnd.cs new file mode 100644 index 0000000..a88cbee --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmPaymentsEnd.cs @@ -0,0 +1,1397 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Threading; +using System.Windows; +using System.Windows.Input; +using System.Windows.Threading; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Payments; +using SPC.Kiosk.DataHelper; + +namespace SPC.Kiosk.Popup.ViewModel +{ + /// + /// PaymentsEnd.xaml에 대한 ViewModel + /// + public class VmPaymentsEnd : PopupViewModelBase + { + #region [ Members ] + private PosDataService posDataService = null; + public WaitWindow WaitWindowFrom { get; set; } + private List basketData; + public List BasketData + { + get { return basketData; } + set { basketData = value; PropertyChange("BasketData"); } + } + private string titileImage; + /// + /// Cash Image + /// + public string TitileImage + { + get { return titileImage; } + set { titileImage = value; PropertyChange("TitileImage"); } + } + private List headerText; + /// + /// Top Header Text (first Grid) + /// + public List HeaderText + { + get { return headerText; } + set { headerText = value; PropertyChange("HeaderText"); } + } + private List scanGuidText; + /// + /// Second Header Text (first Grid) + /// + public List ScanGuidText + { + get { return scanGuidText; } + set { scanGuidText = value; PropertyChange("ScanGuidText"); } + } + private List infoGuid1Text; + /// + /// Bootom first infomation text (first Grid) + /// + public List InfoGuid1Text + { + get { return infoGuid1Text; } + set { infoGuid1Text = value; PropertyChange("InfoGuid1Text"); } + } + private List infoGuid2Text; + /// + /// Bottom second infomation text (first Grid) + /// + public List InfoGuid2Text + { + get { return infoGuid2Text; } + set { infoGuid2Text = value; PropertyChange("InfoGuid2Text"); } + } + + private List totalPayHeaderText; + /// + /// Payments Total Header Text + /// + public List TotalPayHeaderText + { + get { return totalPayHeaderText; } + set { totalPayHeaderText = value; PropertyChange("TotalPayHeaderText"); } + } + private List queryPointsHeaderText; + /// + /// Member Point Header Text + /// + public List QueryPointsHeaderText + { + get { return queryPointsHeaderText; } + set { queryPointsHeaderText = value; PropertyChange("QueryPointsHeaderText"); } + } + private double cashPayments; + /// + /// Payments Total + /// + public double CashPayments + { + get { return cashPayments; } + set { cashPayments = value; PropertyChange("CashPayments"); } + } + private double cashTax; + /// + /// Payments Total + /// + public double CashTax + { + get { return cashTax; } + set { cashTax = value; PropertyChange("CashTax"); } + } + + + private List cancelButtonText; + /// + /// Cancel Button Text + /// + public List CancelButtonText + { + get { return cancelButtonText; } + set { cancelButtonText = value; PropertyChange("CancelButtonText"); } + } + private double cancelButtonWidth = 650d; + /// + /// Cancel Button Width + /// + public double CancelButtonWidth + { + get { return cancelButtonWidth; } + set { cancelButtonWidth = value; PropertyChange("CancelButtonWidth"); } + } + private double okButtonWidth = 650d; + /// + /// OK Button Width + /// + public double OKButtonWidth + { + get { return okButtonWidth; } + set { okButtonWidth = value; PropertyChange("OKButtonWidth"); } + } + private List okButtonText; + /// + /// OK Button Text + /// + public List OkButtonText + { + get { return okButtonText; } + set { okButtonText = value; PropertyChange("OkButtonText"); } + } + private bool oKButtonEnabled = false; + /// + /// OK Button Enabled + /// + public bool OKButtonEnabled + { + get { return oKButtonEnabled; } + set { oKButtonEnabled = value; PropertyChange("OKButtonEnabled"); } + } + private bool talkGetButtonEnabled = false; + /// + /// OK Button Enabled + /// + public bool TalkGetButtonEnabled + { + get { return talkGetButtonEnabled; } + set { talkGetButtonEnabled = value; PropertyChange("TalkGetButtonEnabled"); } + } + private bool storeAgreeView; + public bool StoreAgreeView + { + get { return storeAgreeView; } + set { storeAgreeView = value; PropertyChange("StoreAgreeView"); } + } + + private M_StoreAgree storeAgreeData; + /// + /// Sotre Agree Data + /// + public M_StoreAgree StoreAgreeData + { + get { return storeAgreeData; } + set { storeAgreeData = value; PropertyChange("StoreAgreeData"); } + } + + #region CashReceipt + + private bool cashReceiptVisible = false; + /// + /// 인증 시작 화면 Visible + /// + public bool CashReceiptVisible + { + get { return cashReceiptVisible; } + set { cashReceiptVisible = value; PropertyChange("CashReceiptVisible"); } + } + private string cashReceipTitileImage; + /// + /// CashReceip Titile Image + /// + public string CashReceipTitileImage + { + get { return cashReceipTitileImage; } + set { cashReceipTitileImage = value; PropertyChange("CashReceipTitileImage"); } + } + private string cashReceipButtonBackground; + /// + /// CashReceip Button Background + /// + public string CashReceipButtonBackground + { + get { return cashReceipButtonBackground; } + set { cashReceipButtonBackground = value; PropertyChange("CashReceipButtonBackground"); } + } + private string cashTypePersonButtonNormal; + /// + /// CashType Person Button Normal + /// + public string CashTypePersonButtonNormal + { + get { return cashTypePersonButtonNormal; } + set { cashTypePersonButtonNormal = value; PropertyChange("CashTypePersonButtonNormal"); } + } + private string cashTypePersonButtonDisable; + /// + /// CashType Person Button Disable + /// + public string CashTypePersonButtonDisable + { + get { return cashTypePersonButtonDisable; } + set { cashTypePersonButtonDisable = value; PropertyChange("CashTypePersonButtonDisable"); } + } + private bool cashTypePersonEnable = false; + /// + /// CashType Serson Enabled + /// + public bool CashTypePersonEnable + { + get { return cashTypePersonEnable; } + set { cashTypePersonEnable = value; PropertyChange("CashTypePersonEnable"); } + } + private List cashTypePersonText; + /// + /// CashType Serson Button text + /// + public List CashTypePersonText + { + get { return cashTypePersonText; } + set { cashTypePersonText = value; PropertyChange("CashTypePersonText"); } + } + private string cashTypeCompanyButtonNormal; + /// + /// CashType Company Button Normal + /// + public string CashTypeCompanyButtonNormal + { + get { return cashTypeCompanyButtonNormal; } + set { cashTypeCompanyButtonNormal = value; PropertyChange("CashTypeCompanyButtonNormal"); } + } + private string cashTypeCompanyButtonDisable; + /// + /// CashType Company Button Disable + /// + public string CashTypeCompanyButtonDisable + { + get { return cashTypeCompanyButtonDisable; } + set { cashTypeCompanyButtonDisable = value; PropertyChange("CashTypeCompanyButtonDisable"); } + } + public bool cashTypeCompanyEnable = true; + /// + /// CashType Serson Enabled + /// + public bool CashTypeCompanyEnable + { + get { return cashTypeCompanyEnable; } + set { cashTypeCompanyEnable = value; PropertyChange("CashTypeCompanyEnable"); } + } + private List cashTypeCompanyText; + /// + /// All Point Using Button text + /// + public List CashTypeCompanyText + { + get { return cashTypeCompanyText; } + set { cashTypeCompanyText = value; PropertyChange("CashTypeCompanyText"); } + } + private string inputNumber = string.Empty; + /// + /// Input Numner Point Text + /// + public string InputNumber + { + get { return inputNumber; } + set { inputNumber = value; PropertyChange("InputNumber"); } + } + private List numPadGuidText; + /// + /// Number Pad Input Guide Text + /// + public List NumPadGuidText + { + get { return numPadGuidText; } + set { numPadGuidText = value; PropertyChange("NumPadGuidText"); } + } + + private int numPadMaxLength; + /// + /// Point Pad Input Max Length + /// + public int NumPadMaxLength + { + get { return numPadMaxLength; } + set { numPadMaxLength = value; PropertyChange("NumPadMaxLength"); } + } + private bool numPadFormated = false; + /// + /// NumPad Formated + /// + public bool NumPadFormated + { + get { return numPadFormated; } + set { numPadFormated = value; PropertyChange("NumPadFormated"); } + } + private bool numPadInputVisible = false; + /// + /// Number Pad Points Visible + /// + public bool NumPadInputVisible + { + get { return numPadInputVisible; } + set { numPadInputVisible = value; PropertyChange("NumPadInputVisible"); } + } + private bool numPadGuideVisible = true; + /// + /// Nummber Pad Guid Visible + /// + public bool NumPadGuideVisible + { + get { return numPadGuideVisible; } + set { numPadGuideVisible = value; PropertyChange("NumPadGuideVisible"); } + } + + #endregion + + #region Processing + private bool processingVisible = false; + /// + /// 처리 진행 화면 Visible + /// + public bool ProcessingVisible + { + get { return processingVisible; } + set { processingVisible = value; PropertyChange("ProcessingVisible"); } + } + + private string processingGIF; + /// + /// Processing GIF + /// + public string ProcessingGIF + { + get { return processingGIF; } + set { processingGIF = value; PropertyChange("ProcessingGIF"); } + } + private List processingMessageText; + /// + /// Processing Message Text + /// + public List ProcessingMessageText + { + get { return processingMessageText; } + set { processingMessageText = value; PropertyChange("ProcessingMessageText"); } + } + private List processingGuide; + /// + /// Processing Guide Text + /// + public List ProcessingGuide + { + get { return processingGuide; } + set { processingGuide = value; PropertyChange("ProcessingGuide"); } + } + #endregion + + #region BellOrNotifyTalk + private bool bellOrNotifyTalkVisible = false; + /// + /// 처리 진행 화면 Visible + /// + public bool BellOrNotifyTalkVisible + { + get { return bellOrNotifyTalkVisible; } + set { bellOrNotifyTalkVisible = value; PropertyChange("BellOrNotifyTalkVisible"); } + } + private string bellOrNotifyTalkTitileImage; + /// + /// BellOrNotifyTalk Titile Image + /// + public string BellOrNotifyTalkTitileImage + { + get { return bellOrNotifyTalkTitileImage; } + set { bellOrNotifyTalkTitileImage = value; PropertyChange("BellOrNotifyTalkTitileImage"); } + } + private List bellOrNotifyTalkText; + /// + /// Bell Button Text + /// + public List BellOrNotifyTalkText + { + get { return bellOrNotifyTalkText; } + set { bellOrNotifyTalkText = value; PropertyChange("BellOrNotifyTalkText"); } + } + private bool bellButtonEnable = false; + /// + /// Bell Button Enable + /// + public bool BellButtonEnable + { + get { return bellButtonEnable; } + set { bellButtonEnable = value; PropertyChange("BellButtonEnable"); } + } + private List bellButtonText; + /// + /// Bell Button Text + /// + public List BellButtonText + { + get { return bellButtonText; } + set { bellButtonText = value; PropertyChange("BellButtonText"); } + } + private bool talkButtonEnable = true; + /// + /// Talk Button Enable + /// + public bool TalkButtonEnable + { + get { return talkButtonEnable; } + set { talkButtonEnable = value; PropertyChange("TalkButtonEnable"); } + } + private List talkButtonText; + /// + /// Talk Button Text + /// + public List TalkButtonText + { + get { return talkButtonText; } + set { talkButtonText = value; PropertyChange("TalkButtonText"); } + } + private string talkNumPadNumber = string.Empty; + /// + /// TalkNumPad Number + /// + public string TalkNumPadNumber + { + get { return talkNumPadNumber; } + set { talkNumPadNumber = value; PropertyChange("TalkNumPadNumber"); } + } + private List talkNumPadGuidText; + /// + /// Number Pad Input Guide Text + /// + public List TalkNumPadGuidText + { + get { return talkNumPadGuidText; } + set { talkNumPadGuidText = value; PropertyChange("TalkNumPadGuidText"); } + } + + private int talkNumPadMaxLength; + /// + /// Point Pad Input Max Length + /// + public int TalkNumPadMaxLength + { + get { return talkNumPadMaxLength; } + set { talkNumPadMaxLength = value; PropertyChange("TalkNumPadMaxLength"); } + } + private bool talkNumPadFormated = true; + /// + /// TalkNumPad Guide Visible + /// + public bool TalkNumPadFormated + { + get { return talkNumPadFormated; } + set { talkNumPadFormated = value; PropertyChange("TalkNumPadFormated"); } + } + private bool talkNumPadInputVisible = false; + /// + /// TalkNumPad InputNumber Visible + /// + public bool TalkNumPadInputVisible + { + get { return talkNumPadInputVisible; } + set { talkNumPadInputVisible = value; PropertyChange("TalkNumPadInputVisible"); } + } + private bool talkNumPadGuideVisible = true; + /// + /// TalkNumPad Guide Visible + /// + public bool TalkNumPadGuideVisible + { + get { return talkNumPadGuideVisible; } + set { talkNumPadGuideVisible = value; PropertyChange("TalkNumPadGuideVisible"); } + } + + #endregion + + #region PaymentSuccess + private bool paymentSuccessVisible = false; + + /// + /// 처리 완료 화면 Visible + /// + public bool PaymentSuccessVisible + { + get { return paymentSuccessVisible; } + set { paymentSuccessVisible = value; PropertyChange("PaymentSuccessVisible"); } + } + private string successImage; + /// + /// Sucess Icon + /// + public string SuccessImage + { + get { return successImage; } + set { successImage = value; PropertyChange("SuccessImage"); } + } + private List successText; + /// + /// Sucess Guide Text + /// + public List SuccessText + { + get { return successText; } + set { successText = value; PropertyChange("SuccessText"); } + } + + #endregion + + #region TalkSuccess + private bool talkSuccessVisible = false; + + /// + /// 처리 완료 화면 Visible + /// + public bool TalkSuccessVisible + { + get { return talkSuccessVisible; } + set { talkSuccessVisible = value; PropertyChange("TalkSuccessVisible"); } + } + private string talkSuccessImage; + /// + /// Sucess Icon + /// + public string TalkSuccessImage + { + get { return talkSuccessImage; } + set { talkSuccessImage = value; PropertyChange("TalkSuccessImage"); } + } + private List talkSuccessText; + /// + /// Sucess Guide Text + /// + public List TalkSuccessText + { + get { return talkSuccessText; } + set { talkSuccessText = value; PropertyChange("TalkSuccessText"); } + } + private List talkSuccessInfoText; + /// + /// Sucess Guide Text + /// + public List TalkSuccessInfoText + { + get { return talkSuccessInfoText; } + set { talkSuccessInfoText = value; PropertyChange("TalkSuccessInfoText"); } + } + #endregion + + #region WaitNumberSuccess + private bool waitNumberSuccessVisible = false; + + /// + /// 처리 완료 화면 Visible + /// + public bool WaitNumberSuccessVisible + { + get { return waitNumberSuccessVisible; } + set { waitNumberSuccessVisible = value; PropertyChange("WaitNumberSuccessVisible"); } + } + private List waitNumberHeaderText; + /// + /// Sucess Guide Text + /// + public List WaitNumberHeaderText + { + get { return waitNumberHeaderText; } + set { waitNumberHeaderText = value; PropertyChange("WaitNumberHeaderText"); } + } + private string waitNumberText; + /// + /// Sucess Guide Text + /// + public string WaitNumberText + { + get { return waitNumberText; } + set { waitNumberText = value; PropertyChange("WaitNumberText"); } + } + private List successInfoText; + /// + /// Sucess Guide Text + /// + public List SuccessInfoText + { + get { return successInfoText; } + set { successInfoText = value; PropertyChange("SuccessInfoText"); } + } + + /// + /// Point Saving Button OK + /// + private bool pointSavingButtonOk = false; + + public bool PointSavingButtonOk + { + get { return pointSavingButtonOk; } + set { pointSavingButtonOk = value; PropertyChange("PointSavingButtonOk"); } + } + + /// + /// Point Saving Button Background + /// + private string pointSavingButtonBackground; + + public string PointSavingButtonBackground + { + get { return pointSavingButtonBackground; } + set { pointSavingButtonBackground = value; PropertyChange("PointSavingButtonBackground"); } + } + + /// + /// Point Image + /// + private string waitNumberSuccessPointImage; + + public string WaitNumberSuccessPointImage + { + get { return waitNumberSuccessPointImage; } + set { waitNumberSuccessPointImage = value; PropertyChange("WaitNumberSuccessPointImage"); } + } + + #endregion + + private PaymentEndWindowEndType endWindow = PaymentEndWindowEndType.None; + public PaymentEndWindowEndType EndWindow + { + get { return endWindow; } + set { endWindow = value; PropertyChange("EndWindow"); } + } + private PaymentEndWindowType paymentEndWindow = PaymentEndWindowType.None; + /// + /// Current View Window + /// + public PaymentEndWindowType PaymentEndWindow + { + get { return paymentEndWindow; } + set { paymentEndWindow = value; PropertyChange("PaymentEndWindow"); } + } + private bool bellAnsTalkToggleVisible = true; + public bool BellAnsTalkToggleVisible + { + get { return bellAnsTalkToggleVisible; } + set { bellAnsTalkToggleVisible = value; PropertyChange("BellAnsTalkToggleVisible"); } + } + + + private double popupWidth = 1300; + /// + /// Popup Whidth (For Calculate OK Button Width) + /// + public double PopupWidth + { + get { return popupWidth; } + set { popupWidth = value; PropertyChange("PopupWidth"); } + } + private M_PaymentEndReturn paymentEndReturn; + /// + /// HappyPoint 인증 정보 + /// + public M_PaymentEndReturn PaymentEndReturn + { + get { return paymentEndReturn; } + set { paymentEndReturn = value; PropertyChange("PaymentEndReturn"); } + } + /// + /// OK Click Command + /// + public ICommand OkCommand { get; protected set; } + /// + /// Cancel Click Command + /// + public ICommand CancelCommand { get; protected set; } + /// + /// Cash Type Person Command + /// + public ICommand CashTypePersonCommand { get; protected set; } + /// + /// Cash Type Company Command + /// + public ICommand CashTypeCompanyCommand { get; protected set; } + /// + /// Bell Button Command + /// + public ICommand BellButtonCommand { get; protected set; } + /// + /// Talk Button Command + /// + public ICommand TalkButtonCommand { get; protected set; } + /// + /// Store Agree Command + /// + public ICommand StoreAgreeCommand { get; protected set; } + /// + /// Point Saving Button Command + /// + public ICommand PointSavingButtonCommand { get; protected set; } + /// + /// Talk Get Button Command + /// + public ICommand TalkGetButtonCommand { get; protected set; } + /// + /// All Points Using Click Command + /// + public bool ImmediatelyClose { get; protected set; } = false; + /// + /// Happy Point Reserve + /// + public bool HappyPointReserve { get; set; } + /// + /// OkCashBag Reserve + /// + public bool OkCashBagReserve { get; set; } + private M_HappyPointReturn happyPointReturn; + /// + /// Happy Point Return + /// + public M_HappyPointReturn HappyPointReturn + { + get { return happyPointReturn; } + set { happyPointReturn = value; PropertyChange("HappyPointReturn"); } + } + + private bool ProcessStart = false; + private posLastPayments LastPayments = null; + private Task ProcessTask = null; + private string certifyKey = string.Empty; + private string divType = "0"; // "0"=개인(소득공제) ,"1"=사업자(증빙제출) + + #endregion Members + + + #region [ Ctor ] + /// + /// Ctor + /// + public VmPaymentsEnd() + { + posDataService = new PosDataService(); + WaitWindowFrom = WaitWindow.GetInstance; + WaitWindowFrom.CloseWaitWindow(); + OkCommand = new Command(OkCommandHandler); + CancelCommand = new Command(CancelCommandHandler); + CashTypePersonCommand = new Command(CashTypePersonCommandHandler); + CashTypeCompanyCommand = new Command(CashTypeCompanyCommandHandler); + BellButtonCommand = new Command(BellButtonCommandHandler); + TalkButtonCommand = new Command(TalkButtonCommandHandler); + StoreAgreeCommand = new Command(StoreAgreeCommandHandler); + PointSavingButtonCommand = new Command(PointSavingCommandHandler); + TalkGetButtonCommand = new Command(TalkGetCommandHandler); + this.PropertyChanged += VmPaymentsEnd_PropertyChanged; + //TitileImage = ResourceManager.GetNximagePathAdd("img_gif_barcode_happy.gif", CommonValue.PBdesignImagesPath); + CashReceipTitileImage = ResourceManager.GetNximagePathAdd("img_cashreceipt.png", CommonValue.PBdesignImagesPath); + CashReceipButtonBackground = ResourceManager.GetNximagePathAdd("img_check_bg.png", CommonValue.PBdesignImagesPath); + CashTypePersonButtonNormal = ResourceManager.GetNximagePathAdd("btn_check_n.png", CommonValue.PBdesignImagesPath); + CashTypePersonButtonDisable = ResourceManager.GetNximagePathAdd("btn_check_s.png", CommonValue.PBdesignImagesPath); + CashTypeCompanyButtonNormal = ResourceManager.GetNximagePathAdd("btn_check_n.png", CommonValue.PBdesignImagesPath); + CashTypeCompanyButtonDisable = ResourceManager.GetNximagePathAdd("btn_check_s.png", CommonValue.PBdesignImagesPath); + ProcessingGIF = ResourceManager.GetNximagePathAdd("ic_alert_ing2.gif", CommonValue.PBdesignImagesPath); + SuccessImage = ResourceManager.GetNximagePathAdd("img_receipt.png", CommonValue.PBdesignImagesPath); + TalkSuccessImage = ResourceManager.GetNximagePathAdd("ic_talk.png", CommonValue.PBdesignImagesPath); + + OkButtonText = Languages.GetMessages("BTN0033"); + CancelButtonText = Languages.GetMessages("BTN0024"); + CashTypePersonText = Languages.GetMessages("BTN0002"); + CashTypeCompanyText = Languages.GetMessages("BTN0017"); + SuccessText = Languages.GetMessages("LBL0030"); + SuccessInfoText = Languages.GetMessages("LBL0076"); + TalkSuccessText = Languages.GetMessages("LBL0075"); + TalkSuccessInfoText = Languages.GetMessages("LBL0076"); + ProcessingMessageText = Languages.GetMessages("LBL0087"); + ProcessingGuide = Languages.GetMessages("LBL0028"); + NumPadFormated = true; + NumPadMaxLength = 11; + NumPadGuidText = Languages.GetMessages("LBL0091"); + + BellOrNotifyTalkTitileImage = ResourceManager.GetNximagePathAdd("img_bell.png", CommonValue.PBdesignImagesPath); + BellOrNotifyTalkText = Languages.GetMessages("LBL0078"); + TalkNumPadFormated = false; + TalkNumPadMaxLength = 3; + TalkNumPadGuidText = Languages.GetMessages("LBL0104"); + TotalPayHeaderText = Languages.GetMessages("PriceForPayment"); + LastPayments = new posLastPayments(); + + WaitNumberSuccessPointImage = ResourceManager.GetNximagePathAdd("ic_point.png", CommonValue.PBdesignImagesPath); + PointSavingButtonBackground = ResourceManager.GetNximagePathAdd("btn_store.png", CommonValue.PBdesignImagesPath); + } + + /// + /// Dispose + /// + public new void Dispose() + { + TitileImage = string.Empty; + ProcessingGIF = string.Empty; + this.PropertyChanged -= VmPaymentsEnd_PropertyChanged; + if (posDataService != null) + { + posDataService.LastBarcodeDelete(); + posDataService.Dispose(); + posDataService = null; + } + if (ProcessTask != null) + { + ProcessTask.Dispose(); + ProcessTask = null; + } + if (LastPayments != null) + { + CashReceiptRemoveEvents(); + LastPayments.Dispose(); + LastPayments = null; + } + base.Dispose(); + } + #endregion Ctor + + + #region [ Methods ] + private void SetStoreAgreeData() + { + var isFavoriteStore = HappyPointReturn is M_HappyPointReturn + ? HappyPointReturn.IsFavoriteStore + : false; + StoreAgreeData = new M_StoreAgree + { + IsFavoriteStore = isFavoriteStore, + DisplayLanguage = ShowLanguageType, + Header = isFavoriteStore + ? new List + { + new M_Language { Type=SupportLanguageType.ko, LanguageData="단골매장"} + } + : Languages.GetMessages("LBL0039"), + BackgroundImage = ResourceManager.GetNximagePathAdd("store_bg.png", CommonValue.PBdesignImagesPath), + StoreImage = ResourceManager.GetNximagePathAdd("ic_store.png", CommonValue.PBdesignImagesPath), + StoreName = posDataService != null ? posDataService.StoreName() : string.Empty, + FirstInfoText = Languages.GetMessages("LBL0040"), + SecondInfoText = Languages.GetMessages("LBL0019"), + WelcomeInfoText = new List + { + new M_Language { Type=SupportLanguageType.ko, LanguageData="고객님 저희 매장을 방문해 주셔서 감사합니다."} + }, + ButtonNormalBrush = ResourceManager.GetNximagePathAdd("btn_store_agree_n2.png", CommonValue.PBdesignImagesPath), + ButtonSwitchOnBrush = "Transparent", + ButtonText = Languages.GetMessages("BTN0010"), + }; + } + private void TestDelay() + { + Thread.Sleep(1000); + } + + + private void CashReceiptCreateEvents() + { + if (LastPayments != null) + { + LastPayments.ReadStart += LastPayments_ReadStart; + LastPayments.ReadEnd += LastPayments_ReadEnd; + } + } + + + private void CashReceiptRemoveEvents() + { + if (LastPayments != null) + { + LastPayments.ReadStart -= LastPayments_ReadStart; + LastPayments.ReadEnd -= LastPayments_ReadEnd; + } + } + + + private void DoCashReceiptProcessing() + { + + ProcessStart = true; + TimerEnabled = false; + CashReceiptCreateEvents(); + var processTask = new Task(() => LastPayments.StartCashBill(InputNumber,divType,CashPayments,CashTax)); + processTask.Start(); + processTask.Wait(); + DoBeforeReceiptPrint(); + CashReceiptRemoveEvents(); + processTask = null; + ProcessStart = false; + TimerEnabled = true; + } + private void DoNewMemberRequest() + { + ProcessStart = true; + TimerEnabled = false; + WaitWindowFrom.ShowWaitWindow(); + + var korItemName = BasketData.FirstOrDefault().ItemName.GetLanguageData(SupportLanguageType.ko); + var itemCount = BasketData.Sum(r => r.Count).ToString(); + //TODO:비회원 입력 전화 번호 처리 (InputNumber) + using (var commonDataHelper = new DataHelper.CommonDataHelper()) + { + commonDataHelper.Send_NoticeTalk(InputNumber, korItemName, itemCount); + } + + // test + //DoReceiptPrint(); + + //TestDelay(); + WaitWindowFrom.CloseWaitWindow(); + ProcessStart = false; + CanWindowClose = true; + + } + private void DoRegFavoriteStore()//DoRegFavoriteStore + { + ProcessStart = true; + TimerEnabled = false; + WaitWindowFrom.ShowWaitWindow(); + using (var PosHappyPoint = new posHappyPoint()) + { + PosHappyPoint.StartFavoriteStoreProcess(happyPointReturn.MemberCode, true); + } + WaitWindowFrom.CloseWaitWindow(); + ProcessStart = false; + CanWindowClose = true; + } + + private void DoBeforeReceiptPrint() + { + switch (EndWindow) + { + case PaymentEndWindowEndType.Talk: + TalkButtonEnable = false; + PaymentEndWindow = PaymentEndWindowType.BellOrNotifyTalk; + break; + case PaymentEndWindowEndType.Bell: + BellButtonEnable = false; + PaymentEndWindow = PaymentEndWindowType.BellOrNotifyTalk; + break; + default: + DoReceiptPrint(); + break; + } + } + + + private void DoAfterReceiptPrint() + { + switch (EndWindow) + { + case PaymentEndWindowEndType.None: + PaymentEndWindow = PaymentEndWindowType.PaymentSuccess; + break; + case PaymentEndWindowEndType.Bell: + PaymentEndWindow = PaymentEndWindowType.WaitNumberSuccess; + break; + case PaymentEndWindowEndType.Talk: + if (string.IsNullOrEmpty(TalkNumPadNumber)) + { + PaymentEndWindow = PaymentEndWindowType.WaitNumberSuccess; + } + else + { + PaymentEndWindow = PaymentEndWindowType.TalkSuccess; + } + break; + case PaymentEndWindowEndType.WaitNumber: + PaymentEndWindow = PaymentEndWindowType.WaitNumberSuccess; + break; + default: + PaymentEndWindow = PaymentEndWindowType.PaymentSuccess; + break; + } + } + + + private void DoReceiptPrint() + { + var waitNumber = string.Empty; + var bellNo = EndWindow.Equals(PaymentEndWindowEndType.Bell) + ? TalkNumPadNumber + : string.Empty; + var isTalk = EndWindow.Equals(PaymentEndWindowEndType.Talk); + using (var ps = new PosDataService()) waitNumber=ps.PrintReceipt(bellNo, isTalk, HappyPointReserve,OkCashBagReserve); + if (!string.IsNullOrEmpty(waitNumber)) WaitNumberText = waitNumber; + DoAfterReceiptPrint(); + + } + + + #endregion Methods + + + #region [ Event Handlers ] + private void CashTypePersonCommandHandler(object obj) + { + CashTypePersonEnable = false; + } + private void CashTypeCompanyCommandHandler(object obj) + { + CashTypeCompanyEnable = false; + } + private void BellButtonCommandHandler(object obj) + { + + BellButtonEnable = false; + + } + private void TalkButtonCommandHandler(object obj) + { + TalkButtonEnable = false; + } + + private void PointSavingCommandHandler(object obj) + { + PointSavingButtonOk = true; + } + + private void TalkGetCommandHandler(object obj) + { + //Console.WriteLine("알림톡 받기"); + DoNewMemberRequest(); + CanWindowClose = true; + } + + private void CancelCommandHandler(object obj) + { + switch (PaymentEndWindow) + { + case PaymentEndWindowType.CashReceipt: + certifyKey = InputNumber; + divType = CashTypeCompanyEnable ? "0" : "1"; + PaymentEndWindow = PaymentEndWindowType.Processing; + break; + case PaymentEndWindowType.PaymentSuccess: + case PaymentEndWindowType.WaitNumberSuccess: + case PaymentEndWindowType.TalkSuccess: + CanWindowClose = true; + break; + } + } + private void OkCommandHandler(object obj) + { + switch (PaymentEndWindow) + { + case PaymentEndWindowType.CashReceipt: + PaymentEndWindow = PaymentEndWindowType.Processing; + break; + case PaymentEndWindowType.BellOrNotifyTalk: + DoReceiptPrint(); + break; + case PaymentEndWindowType.PaymentSuccess: + case PaymentEndWindowType.WaitNumberSuccess: + case PaymentEndWindowType.TalkSuccess: + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + + break; + } + } + + + private void StoreAgreeCommandHandler(object obj) + { + if (ProcessTask != null) ProcessTask.Wait(); + if (HappyPointReturn is M_HappyPointReturn) + { + DoRegFavoriteStore(); + } + else + { + CanWindowClose = true; + } + } + + private void LastPayments_ReadStart(object sender) + { + TimerEnabled = false; + ProcessStart = true; + } + private void LastPayments_ReadEnd(object sender) + { + ProcessStart = false; + } + private void VmPaymentsEnd_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + try + { + switch (e.PropertyName) + { + + case "IsTimeout": + if (IsTimeout) + { + switch (PaymentEndWindow) + { + case PaymentEndWindowType.CashReceipt: + InputNumber = string.Empty; + PaymentEndWindow = PaymentEndWindowType.Processing; + break; + case PaymentEndWindowType.BellOrNotifyTalk: + TalkNumPadNumber = string.Empty; + DoReceiptPrint(); + break; + case PaymentEndWindowType.PaymentSuccess: + case PaymentEndWindowType.WaitNumberSuccess: + case PaymentEndWindowType.TalkSuccess: + if (ProcessTask != null) ProcessTask.Wait(); + CanWindowClose = true; + break; + } + } + break; + case "HappyPointReturn": + StoreAgreeView = HappyPointReturn is M_HappyPointReturn; + SetStoreAgreeData(); + break; + case "EndWindow": + switch (EndWindow) + { + case PaymentEndWindowEndType.Bell: + BellAnsTalkToggleVisible = !CommonValue.DisableEndType.Equals(PaymentEndWindowEndType.Talk); + break; + case PaymentEndWindowEndType.Talk: + BellAnsTalkToggleVisible = !CommonValue.DisableEndType.Equals(PaymentEndWindowEndType.Bell); + break; + } + break; + case "PaymentEndWindow": + CashReceiptVisible = false; + ProcessingVisible = false; + BellOrNotifyTalkVisible = false; + PaymentSuccessVisible = false; + WaitNumberSuccessVisible = false; + TalkSuccessVisible = false; + switch (PaymentEndWindow) + { + case PaymentEndWindowType.CashReceipt: + CashReceiptVisible = true; + break; + case PaymentEndWindowType.Processing: + ProcessingVisible = true; + break; + case PaymentEndWindowType.BellOrNotifyTalk: + BellOrNotifyTalkVisible = true; + break; + case PaymentEndWindowType.PaymentSuccess: + PaymentSuccessVisible = true; + break; + case PaymentEndWindowType.WaitNumberSuccess: + WaitNumberSuccessVisible = true; + break; + case PaymentEndWindowType.TalkSuccess: + TalkSuccessVisible = true; + break; + } + break; + case "CashReceiptVisible": + if (CashReceiptVisible) + { + using (var ps = new PosDataService()) ps.GetCashBill(ref cashPayments, ref cashTax); + if (CashPayments.Equals(0)) + { + DoBeforeReceiptPrint(); + } + else + { + HeaderText = Languages.GetMessages("LBL0139"); + ScanGuidText = Languages.GetMessages("LBL0053"); + InfoGuid1Text = Languages.GetMessages("LBL0009"); + InfoGuid2Text = Languages.GetMessages("LBL0010"); + CancelButtonWidth = PopupWidth / 2; + OKButtonWidth = PopupWidth / 2; + OKButtonEnabled = false; + CancelButtonText = Languages.GetMessages("BTN0033"); + OkButtonText = Languages.GetMessages("BTN0024"); + TimeOutSeconds = CommonValue.TimeOutSeconds; + } + } + break; + + case "ProcessingVisible": + if (ProcessingVisible) + { + HeaderText = Languages.GetMessages("LBL0139"); + ScanGuidText = new List(); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + CancelButtonWidth = 0d; + OKButtonWidth = 0d; + if (ProcessTask != null) + { + ProcessTask.Dispose(); + ProcessTask = null; + } + ProcessTask = new Task(DoCashReceiptProcessing); + ProcessTask.Start(); + } + break; + case "BellOrNotifyTalkVisible": + if (BellOrNotifyTalkVisible) + { + HeaderText = Languages.GetMessages("LBL0029"); + ScanGuidText = Languages.GetMessages("LBL0074"); + InfoGuid1Text = Languages.GetMessages("LBL0011"); + InfoGuid2Text = Languages.GetMessages("LBL0005"); + CancelButtonWidth = 0d; + OKButtonWidth = PopupWidth; + OKButtonEnabled = false; + OkButtonText = Languages.GetMessages("BTN0024"); + TimeOutSeconds = CommonValue.TimeOutSeconds; + } + break; + case "PaymentSuccessVisible": + if (PaymentSuccessVisible) + { + InputNumber = string.Empty; + HeaderText = Languages.GetMessages("LBL0029"); + ScanGuidText = new List(); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + CancelButtonWidth = 0d; + OKButtonWidth = PopupWidth; + OKButtonEnabled = true; + OkButtonText = Languages.GetMessages("BTN0039"); + TimeOutSeconds = CommonValue.TimeOutSeconds; + } + break; + case "WaitNumberSuccessVisible": + if (WaitNumberSuccessVisible) + { + InputNumber = string.Empty; + HeaderText = Languages.GetMessages("LBL0029"); + ScanGuidText = Languages.GetMessages("LBL0093"); + WaitNumberHeaderText = Languages.GetMessages("LBL0041"); + if (EndWindow.Equals(PaymentEndWindowEndType.Bell) + && !string.IsNullOrEmpty(TalkNumPadNumber)) + { + WaitNumberHeaderText = Languages.GetMessages("LBL0103"); + + WaitNumberText = TalkNumPadNumber; + } + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + CancelButtonWidth = 0d; + OKButtonWidth = PopupWidth; + OKButtonEnabled = true; + OkButtonText = Languages.GetMessages("BTN0039"); + TimeOutSeconds = CommonValue.TimeOutSeconds; + + } + break; + case "TalkSuccessVisible": + if (TalkSuccessVisible) + { + InputNumber = string.Empty; + HeaderText = Languages.GetMessages("LBL0029"); + ScanGuidText = Languages.GetMessages("LBL0093"); + InfoGuid1Text = new List(); + InfoGuid2Text = new List(); + CancelButtonWidth = 0d; + OKButtonWidth = PopupWidth; + OKButtonEnabled = true; + OkButtonText = Languages.GetMessages("BTN0039"); + TimeOutSeconds = CommonValue.TimeOutSeconds; + } + break; + + case "NumPadInputVisible": + NumPadGuideVisible = !NumPadInputVisible; + break; + case "InputNumber": + NumPadInputVisible = InputNumber.Length > 0; + switch (PaymentEndWindow) + { + case PaymentEndWindowType.CashReceipt: + if (!CashTypePersonEnable) + { + OKButtonEnabled = InputNumber.Length.Equals(10) || InputNumber.Length.Equals(11); + } + if (!CashTypeCompanyEnable) + { + OKButtonEnabled = InputNumber.Length.Equals(10); + } + break; + case PaymentEndWindowType.PaymentSuccess: + case PaymentEndWindowType.WaitNumberSuccess: + case PaymentEndWindowType.TalkSuccess: + TalkGetButtonEnabled = InputNumber.Length.Equals(10) || InputNumber.Length.Equals(11); + break; + default: + OKButtonEnabled = InputNumber.Length.Equals(10) || InputNumber.Length.Equals(11); + break; + } + break; + case "TalkNumPadInputVisible": + TalkNumPadGuideVisible = !TalkNumPadInputVisible; + break; + case "TalkNumPadNumber": + TalkNumPadInputVisible = TalkNumPadNumber.Length > 0; + if (!BellButtonEnable) + { + OKButtonEnabled = TalkNumPadNumber.Length > 0; + } + if (!TalkButtonEnable) + { + OKButtonEnabled = TalkNumPadNumber.Length.Equals(10) || TalkNumPadNumber.Length.Equals(11); + } + break; + case "CashTypePersonEnable": + if (!CashTypePersonEnable) + { + NumPadFormated = true; + NumPadMaxLength = 11; + NumPadGuidText = Languages.GetMessages("LBL0091"); + InputNumber = string.Empty; + CashTypeCompanyEnable = true; + } + break; + case "CashTypeCompanyEnable": + if (!CashTypeCompanyEnable) + { + NumPadFormated = false; + NumPadMaxLength = 10; + NumPadGuidText = Languages.GetMessages("LBL0056"); + InputNumber = string.Empty; + CashTypePersonEnable = true; + } + break; + case "BellButtonEnable": + if (!BellButtonEnable) + { + EndWindow = PaymentEndWindowEndType.Bell; + TalkNumPadFormated = true; + TalkNumPadMaxLength = 3; + TalkNumPadGuidText = Languages.GetMessages("LBL0104"); + BellOrNotifyTalkTitileImage = ResourceManager.GetNximagePathAdd("img_bell.png", CommonValue.PBdesignImagesPath); + BellOrNotifyTalkText = Languages.GetMessages("LBL0078"); + TalkNumPadNumber = string.Empty; + TalkButtonEnable = true; + } + break; + case "TalkButtonEnable": + if (!TalkButtonEnable) + { + EndWindow = PaymentEndWindowEndType.Talk; + TalkNumPadFormated = true; + TalkNumPadMaxLength = 11; + TalkNumPadGuidText = Languages.GetMessages("LBL0091"); + BellOrNotifyTalkTitileImage = ResourceManager.GetNximagePathAdd("img_talk.png", CommonValue.PBdesignImagesPath); + BellOrNotifyTalkText = Languages.GetMessages("LBL0036"); + TalkNumPadNumber = string.Empty; + BellButtonEnable = true; + } + break; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "VmPaymentsEnd_PropertyChanged()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + + #endregion Event Handlers + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmStepInfoPopup.cs b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmStepInfoPopup.cs new file mode 100644 index 0000000..2196e35 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup.ViewModel/VmStepInfoPopup.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.IO; +using System.Linq; +using System.Text; +using System.Windows.Input; +using System.Windows.Threading; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +namespace SPC.Kiosk.Popup.ViewModel +{ + /// + /// CallEmployee.xaml 의 ViewModel + /// + public class VmStepInfoPopup : PopupViewModelBase + { + #region [ Members ] + + public string StepIamge { get; set; } = ResourceManager.GetNximagePathAdd("step.gif", CommonValue.PBdesignImagesPath); + + private List okButtonText; + /// + /// OK Button Text + /// + public List OkButtonText + { + get { return okButtonText; } + set { okButtonText = value; PropertyChange("OkButtonText"); } + } + private double okButtonWidth = 800d; + /// + /// OK Button Width + /// + public double OkButtonWidth + { + get { return okButtonWidth; } + set { okButtonWidth = value; PropertyChange("OkButtonWidth"); } + } + /// + /// OK Click Command + /// + public ICommand OkCommand { get; protected set; } + + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public VmStepInfoPopup() + { + OkCommand = new Command(OkCommandHandler); + this.PropertyChanged += VmStepInfoPopup_PropertyChanged; + OkButtonText = Languages.GetMessages("BTN0039"); + TimeOutSeconds = 10d; + } + ~VmStepInfoPopup() + { + this.PropertyChanged -= VmStepInfoPopup_PropertyChanged; + } + #endregion Ctor + + #region [ Methods ] + #endregion Methods + + #region [ Event Handlers ] + + private void OkCommandHandler(object obj) + { + TimerEnabled = false; + + ReturnValue = new M_PopupReturn + { + OKAnswer = true, + TimeOut = false, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + + } + + private void VmStepInfoPopup_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "IsTimeout": + if (IsTimeout) + { + ReturnValue = new M_PopupReturn + { + OKAnswer = false, + TimeOut = true, + ReturnLanguage = ShowLanguageType, + PopupArgs = null + }; + CanWindowClose = true; + } + break; + } + } + + + #endregion Event Handlers + } +} \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/CallEmployee.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/CallEmployee.xaml new file mode 100644 index 0000000..15af5b9 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/CallEmployee.xaml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/CallEmployee.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/CallEmployee.xaml.cs new file mode 100644 index 0000000..f6b938c --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/CallEmployee.xaml.cs @@ -0,0 +1,130 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Forms; +using System.Drawing; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using System.Windows.Threading; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; + +namespace SPC.Kiosk.Popup +{ + /// + /// CallEmployee.xaml에 대한 상호 작용 논리 + /// + public partial class CallEmployee : Window + { + #region [ Members ] + private int ScreenNo { get; set; } = 0; + private VmCallEmployee ViewModel { get; set; } + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public CallEmployee() + { + InitializeComponent(); + this.ContentRendered += CallEmployee_ContentRendered; + this.Loaded += CallEmployee_Loaded; + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + + } + + #endregion Ctor + + #region [ Methods ] + private void OpenWindow() + { + var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeUp + , this.FrameBase.Height + , 0.5 + , 0.2); + if (OpenAnimations != null) + { + OpenAnimations.Begin(); + } + } + private void CloseWindow() + { + var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeDown + , this.FrameBase.Height + , 0.5 + , 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + #endregion Methods + + #region [ Event Handlers ] + private void CloseAnimation_Completed(object sender, EventArgs e) + { + this.ContentRendered -= CallEmployee_ContentRendered; + this.Loaded -= CallEmployee_Loaded; + this.Close(); + } + + private void CallEmployee_ContentRendered(object sender, EventArgs e) + { + this.FrameBase.Width = 1300; + this.FrameBase.Height = 1010; + OpenWindow(); + } + + private void CallEmployee_Loaded(object sender, RoutedEventArgs e) + { + if (this.DataContext is VmCallEmployee viewModel) + { + ViewModel = viewModel; + ViewModel.PropertyChanged += ViewModel_PropertyChanged; + ViewModel.IsTimeoutPopup = false; + } + this.FrameBase.Width = 0; + this.FrameBase.Height = 0; + } + + private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "CanWindowClose": + if (this.ViewModel.CanWindowClose) + { + CloseWindow(); + } + break; + } + } + + + + + + + #endregion Event Handlers + } + + +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/HappyAppCoupon.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/HappyAppCoupon.xaml new file mode 100644 index 0000000..799e638 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/HappyAppCoupon.xaml @@ -0,0 +1,48 @@ + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/HappyAppCoupon.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/HappyAppCoupon.xaml.cs new file mode 100644 index 0000000..e8ca724 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/HappyAppCoupon.xaml.cs @@ -0,0 +1,141 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +namespace SPC.Kiosk.Popup +{ + /// + /// DiscountAndValue.xaml에 대한 상호 작용 논리 + /// + public partial class HappyAppCoupon : UserControl + { + #region [ Members ] + /// + /// ItemData + /// + public static readonly DependencyProperty ItemDataProperty = + DependencyProperty.Register(nameof(ItemData), typeof(M_HappyCoupon), typeof(HappyAppCoupon), new PropertyMetadata(new M_HappyCoupon(), new PropertyChangedCallback(OnItemDataPropertyChanged))); + + private static void OnItemDataPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as HappyAppCoupon; + } + + /// + /// Display Language + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(HappyAppCoupon), new PropertyMetadata(SupportLanguageType.ko)); + /// + /// Button Switch + /// + public static readonly DependencyProperty SwitchPropery = + DependencyProperty.Register(nameof(Switch), typeof(bool), typeof(HappyAppCoupon), new PropertyMetadata(false, new PropertyChangedCallback(OnSwitchProperyChanged))); + /// + /// Button Switch + /// + public bool Switch + { + get { return (bool)GetValue(SwitchPropery); } + set { SetValue(SwitchPropery, value);} + + } + /// + /// ItemData + /// + public M_HappyCoupon ItemData + { + get { return (M_HappyCoupon)GetValue(ItemDataProperty); } + set { SetValue(ItemDataProperty, value); } + } + /// + /// Display Language + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + /// + /// Button NormalBrush + /// + public string ButtonNormalBrush { get; set; } + public string ButtonDownBrush { get; set; } + public string ButtonSwitchOnBrush { get; set; } + public string ButtonDisableBrush { get; set; } + + #region [ RoutedEvent 'MouseClicked' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent MouseClickedEvent = EventManager.RegisterRoutedEvent(nameof(MouseClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(HappyAppCoupon)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler MouseClicked + { + add { AddHandler(MouseClickedEvent, value); } + remove { RemoveHandler(MouseClickedEvent, value); } + } + #endregion RoutedEvent 'MouseClicked' + + #endregion Members + + #region [ Ctor & Etc ] + /// + /// Ctor + /// + public HappyAppCoupon() + { + ButtonNormalBrush = ResourceManager.GetNximagePathAdd("btn_coupon_n.png", CommonValue.PBdesignImagesPath); + ButtonDownBrush = ResourceManager.GetNximagePathAdd("btn_coupon_p.png", CommonValue.PBdesignImagesPath); + ButtonSwitchOnBrush = ResourceManager.GetNximagePathAdd("btn_coupon_s.png", CommonValue.PBdesignImagesPath); + ButtonDisableBrush = ResourceManager.GetNximagePathAdd("btn_coupon_d.png", CommonValue.PBdesignImagesPath); + InitializeComponent(); + } + + #endregion Ctor & Etc + + #region [ Methods ] + /// + /// Raise MouseClicked Event + /// + private void RaiseMouseClickedEvent(object _sender) + { + RoutedEventArgs newEventArgs = new RoutedEventArgs(HappyAppCoupon.MouseClickedEvent, _sender); + RaiseEvent(newEventArgs); + } + #endregion Methods + + #region [ Event Handlers ] + private static void OnSwitchProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as HappyAppCoupon; + target.OptionButton.Switch = (bool)e.NewValue; + } + + private void OptionButton_MouseClicked(object sender, RoutedEventArgs e) + { + RaiseMouseClickedEvent(this.ItemData); + + } + #endregion Event Handlers + + } +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/HappyAppCoupons.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/HappyAppCoupons.xaml new file mode 100644 index 0000000..6e1a621 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/HappyAppCoupons.xaml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/HappyAppCoupons.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/HappyAppCoupons.xaml.cs new file mode 100644 index 0000000..fd1a1cf --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/HappyAppCoupons.xaml.cs @@ -0,0 +1,314 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +namespace SPC.Kiosk.Popup +{ + /// + /// MiniBasketItem.xaml에 대한 상호 작용 논리 + /// + public partial class HappyAppCoupons : UserControl + { + #region [ Members ] + /// + /// ItemData + /// + public static readonly DependencyProperty CouponDataProperty = + DependencyProperty.Register(nameof(CouponData), typeof(List), typeof(HappyAppCoupons), new PropertyMetadata(null, new PropertyChangedCallback(OnCouponDataPropertyChanged))); + + + /// + /// Display Language + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(HappyAppCoupons), new PropertyMetadata(SupportLanguageType.ko, new PropertyChangedCallback(OnDisplayLanguageProperyChanged))); + /// + /// Vertical Scroll Offset + /// + public static readonly DependencyProperty VerticalOffsetProperty = + DependencyProperty.Register(nameof(VerticalOffset), typeof(double), typeof(HappyAppCoupons), new PropertyMetadata(0d, new PropertyChangedCallback(OnVerticalOffsetPropertyChanged))); + + /// + /// Command + /// + public static readonly DependencyProperty CommandProperty = + DependencyProperty.Register(nameof(Command), typeof(ICommand), typeof(HappyAppCoupons), new UIPropertyMetadata(null)); + + /// + /// Command + /// + public ICommand Command + { + get { return (ICommand)GetValue(CommandProperty); } + set { SetValue(CommandProperty, value); } + } + /// + /// Vertical Scroll Offset + /// + public double VerticalOffset + { + get { return (double)GetValue(VerticalOffsetProperty); } + set { SetValue(VerticalOffsetProperty, value); } + } + + /// + /// ItemData + /// + public List CouponData + { + get { return (List)GetValue(CouponDataProperty); } + set { SetValue(CouponDataProperty, value); } + } + /// + /// Display Language + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + #region [ RoutedEvent 'CouponSelect' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent CouponSelectEvent = EventManager.RegisterRoutedEvent(nameof(CouponSelect), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(HappyAppCoupons)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler CouponSelect + { + add { AddHandler(CouponSelectEvent, value); } + remove { RemoveHandler(CouponSelectEvent, value); } + } + #endregion RoutedEvent 'SelectChange' + private double mouseDownYposition = -1; + private bool MoseDown = false; + + #endregion Members + + #region [ Ctor & Etc ] + /// + /// Ctor + /// + public HappyAppCoupons() + { + InitializeComponent(); + CouponGrid.PreviewMouseDown += CouponGrid_PreviewMouseDown; + CouponGrid.PreviewMouseUp += CouponGrid_PreviewMouseUp; + CouponGrid.PreviewMouseMove += CouponGrid_PreviewMouseMove; + CouponGrid.MouseLeave += CouponGrid_MouseLeave; + + } + + #endregion Ctor & Etc + + #region [ Methods ] + /// + /// Raise MouseClicked Event + /// + private void RaiseCouponSelectEvent(object _sender) + { + if (Command != null && Command.CanExecute(_sender)) + { + Command.Execute(_sender); + } + RoutedEventArgs newEventArgs = new RoutedEventArgs(HappyAppCoupons.CouponSelectEvent, _sender); + RaiseEvent(newEventArgs); + } + private void SetCouponStack(List newValue) + { + foreach (var aGrid in CouponStack.Children) + { + if (aGrid is Grid aCoupons) + { + foreach (var aStack in aCoupons.Children) + { + if (aStack is StackPanel aItems) + { + foreach (var aItem in aItems.Children) + { + if (aItem is HappyAppCoupon aCoupon) + { + aCoupon.MouseClicked -= ACoupon_MouseClicked; + } + } + aItems.Children.Clear(); + } + } + aCoupons.Children.Clear(); + } + } + CouponStack.Children.Clear(); + if (newValue.Count.Equals(0)) return; + var index = 0; + Grid lineGrid = null; + StackPanel lineStack = null; + foreach (var aCouponDetail in newValue) + { + var newCoupon = new HappyAppCoupon + { + ItemData = aCouponDetail, + DisplayLanguage = this.DisplayLanguage + }; + if ((index % 3).Equals(0)) + { + lineGrid = new Grid + { + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left, + Width = newCoupon.Width * 3, + Height = newCoupon.Height, + }; + lineStack = new StackPanel + { + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left, + Orientation = Orientation.Horizontal, + }; + + } + newCoupon.MouseClicked += ACoupon_MouseClicked; + newCoupon.Name = string.Format("HappyAppCoupon{0}", index); + this.ReregisterName(newCoupon.Name, newCoupon); + lineStack.Children.Add(newCoupon); + index++; + if ((index % 3).Equals(0)) + { + lineGrid.Children.Add(lineStack); + CouponStack.Children.Add(lineGrid); + } + } + if (!(index % 3).Equals(0)) + { + lineGrid.Children.Add(lineStack); + CouponStack.Children.Add(lineGrid); + } + } + #endregion Methods + + #region [ Event Handlers ] + private void ACoupon_MouseClicked(object sender, RoutedEventArgs e) + { + if (sender is HappyAppCoupon selectCoupon) + { + foreach (var aGrid in CouponStack.Children) + { + if (aGrid is Grid aCoupons) + { + foreach (var aStack in aCoupons.Children) + { + if (aStack is StackPanel aItems) + { + foreach (var aItem in aItems.Children) + { + if (aItem is HappyAppCoupon aCoupon) + { + if (aCoupon.Name.Equals(selectCoupon.Name)) + { + aCoupon.ItemData.IsUsed = !aCoupon.ItemData.IsUsed; + selectCoupon.Switch = aCoupon.ItemData.IsUsed; + } + else + { + aCoupon.Switch = false; + aCoupon.ItemData.IsUsed = false; + } + } + } + } + } + } + } + } + RaiseCouponSelectEvent(e.OriginalSource); + } + private static void OnVerticalOffsetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != e.OldValue) + { + var target = d as HappyAppCoupons; + target.MainScroll.ScrollToVerticalOffset((double)e.NewValue); + } + } + + private static void OnCouponDataPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue is List newValue) + { + var target = d as HappyAppCoupons; + target.SetCouponStack(newValue); + } + } + + + private static void OnDisplayLanguageProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue is SupportLanguageType newValue) + { + var target = d as HappyAppCoupons; + foreach (var aGrid in target.CouponStack.Children) + { + if (aGrid is Grid aCoupons) + { + foreach (var aStack in aCoupons.Children) + { + if (aStack is StackPanel aItems) + { + foreach (var aItem in aItems.Children) + { + if (aItem is HappyAppCoupon aCoupon) + { + aCoupon.DisplayLanguage = newValue; + } + } + } + } + } + } + } + } + private void CouponGrid_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + var requstGrid = sender as Grid; + mouseDownYposition = e.GetPosition(sender as Grid).Y; + MoseDown = true; + } + + private void CouponGrid_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + MoseDown = false; + } + + private void CouponGrid_PreviewMouseMove(object sender, MouseEventArgs e) + { + if (!MoseDown) return; + var requstGrid = sender as Grid; + var curMouseYposition = e.GetPosition(requstGrid).Y; + VerticalOffset = VerticalOffset + (mouseDownYposition - curMouseYposition) * 2; + mouseDownYposition = curMouseYposition; + } + + private void CouponGrid_MouseLeave(object sender, MouseEventArgs e) + { + MoseDown = false; + } + #endregion Event Handlers + + } +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointCertify.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointCertify.xaml new file mode 100644 index 0000000..4bde7b7 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointCertify.xaml @@ -0,0 +1,612 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointCertify.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointCertify.xaml.cs new file mode 100644 index 0000000..21977bf --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointCertify.xaml.cs @@ -0,0 +1,306 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Forms; +using System.Drawing; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using System.Windows.Threading; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; +using System.Windows.Media.Animation; + +namespace SPC.Kiosk.Popup +{ + /// + /// HappyPointCertify.xaml에 대한 상호 작용 논리 + /// + public partial class HappyPointCertify : Window + { + #region [ Members ] + private int ScreenNo { get; set; } = 0; + private VmHappyPointCertify ViewModel { get; set; } + private bool ShowLanguageButton { get; set; } + private bool ShowMemberHistoryItems { get; set; } + private ParentPage PopupParentPage { get; set; } = ParentPage.EmptyPage; + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public HappyPointCertify(bool _showLanguageButton = true, bool _showMemberHistoryItems = true, ParentPage _popupParentPage = ParentPage.EmptyPage) + { + ShowLanguageButton = _showLanguageButton; + ShowMemberHistoryItems = _showMemberHistoryItems; + PopupParentPage = _popupParentPage; + InitializeComponent(); + this.ContentRendered += HappyPointCertify_ContentRendered; + this.Loaded += HappyPointCertify_Loaded; + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + + } + + + + #endregion Ctor + + #region [ Methods ] + private void OpenWindow() + { + var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeUp + , this.FrameBase.Height + , 0.5 + , 0.5); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Begin(); + } + } + private void CloseWindow() + { + var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeDown + , this.FrameBase.Width + , 0.5 + , 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + private void ChangeWindow() + { + //this.Dispatcher.Invoke((Action)(() => + //{ + try + { + var _target = this.FrameData; + var targetAnimation = new Storyboard(); + var centerX = _target.ActualWidth / 2; + var centerY = _target.ActualHeight / 2; + _target.RenderTransform = new ScaleTransform(1, 1, centerX, centerY); + var flipXAni = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.2))); + Storyboard.SetTarget(flipXAni, _target); + Storyboard.SetTargetProperty(flipXAni, new PropertyPath("RenderTransform.ScaleX")); + targetAnimation.Children.Add(flipXAni); + targetAnimation.Completed += TargetAnimation_Completed; + targetAnimation.Begin(); + } + catch + { + } + //})); + } + + private void TargetAnimation_Completed(object sender, EventArgs e) + { + if (this.ViewModel.CertifyWindow.Equals(CertifyWindowType.CertifyStart) + && !this.ViewModel.ShowPhoneInput) + { + this.BarCode.IsEnabled = true; + this.BarCode.Focus(); + } + else + { + this.BarCode.IsEnabled = false; + } + } + private void OpenOptionPopup() + { + this.ViewModel.TimerEnabled = false; + try + { + var newOptions = new List(); + foreach (var aOptionGroup in this.ViewModel.SelectedData.Option) + { + newOptions.Add(aOptionGroup.Clone()); + } + var newOpenOptionSelect = new OptionSelect(this.ViewModel.SelectedData.BaseTextBlock.LanguageData + , newOptions + , this.ViewModel.SelectedData.DataParameter.NormalBrush + , 1 + , this.ViewModel.SelectedData.Price + , false); + newOpenOptionSelect.ShowDialog(); + if (newOpenOptionSelect.DataContext is VmOptionSelect optionViewModel) + { + this.ViewModel.GetOptionPopupReturn = optionViewModel.ReturnValue; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenOptionPopup", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + this.ViewModel.TimerEnabled = false; + } + } + + #endregion Methods + + #region [ Event Handlers ] + private void OpenAnimations_Completed(object sender, EventArgs e) + { + if (this.ViewModel.CertifyWindow.Equals(CertifyWindowType.CertifyStart) + && !this.ViewModel.ShowPhoneInput) + { + this.BarCode.IsEnabled = true; + this.BarCode.Focus(); + } + else + { + this.BarCode.IsEnabled = false; + } + } + private void CloseAnimation_Completed(object sender, EventArgs e) + { + this.ContentRendered -= HappyPointCertify_ContentRendered; + this.Loaded -= HappyPointCertify_Loaded; + this.LostFocus -= HappyPointCertify_LostFocus; + this.BarCode.PreviewKeyDown -= BarCode_PreviewKeyDown; + this.BarCode.LostFocus -= BarCode_LostFocus; + this.ChangeLanguage.MouseClicked -= ChangeLanguage_MouseClicked; + this.ViewModel.Dispose(); + + this.Close(); + + } + private void HappyPointCertify_ContentRendered(object sender, EventArgs e) + { + this.FrameBase.Width = 1300; + this.FrameBase.Height = 1010; + OpenWindow(); + } + + private void HappyPointCertify_Loaded(object sender, RoutedEventArgs e) + { + if (this.DataContext is VmHappyPointCertify viewModel) + { + this.ViewModel = viewModel; + this.ViewModel.PropertyChanged += ViewModel_PropertyChanged; + this.ViewModel.LanguageButttonVisibel = ShowLanguageButton; + this.ViewModel.MemberHistoryItemsGridHeight = ShowMemberHistoryItems ? 310d : 0d; + this.ViewModel.TopGridMarginHeight = ShowMemberHistoryItems ? 0d : 120d; + this.ViewModel.PopupWidth = this.FrameBase.Width; + this.ViewModel.IsTimeoutPopup = false; + this.ViewModel.PopupParentPage = PopupParentPage; + } + this.LostFocus += HappyPointCertify_LostFocus; + this.BarCode.PreviewKeyDown += BarCode_PreviewKeyDown; + this.BarCode.LostFocus += BarCode_LostFocus; + this.ChangeLanguage.MouseClicked += ChangeLanguage_MouseClicked; + this.FrameBase.Width = 0; + this.FrameBase.Height = 0; + } + + private void HappyPointCertify_LostFocus(object sender, RoutedEventArgs e) + { + this.Focus(); + } + + private void ChangeLanguage_MouseClicked(object sender, RoutedEventArgs e) + { + this.ViewModel.TimerEnabled = false; + try + { + M_PopupReturn result = null; + var newLanguageSelector = new LanguageSelector(this.ViewModel.ShowLanguageType); + newLanguageSelector.ShowDialog(); + if (newLanguageSelector.DataContext is VmLanguageSelector viewModel) + { + result = viewModel.ReturnValue; + } + newLanguageSelector = null; + if (result is M_PopupReturn) + { + if (result.TimeOut) + { + this.ViewModel.ReturnValue = result; + CloseWindow(); + } + else + { + this.ViewModel.ShowLanguageType = result.ReturnLanguage; + this.ViewModel.TimerEnabled = true; + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ChangeLanguage_MouseClicked", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + private void BarCode_LostFocus(object sender, RoutedEventArgs e) + { + this.BarCode.Focus(); + } + + private void BarCode_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) + { + if (sender is System.Windows.Controls.TextBox textBox + && (e.Key.Equals(Key.Enter) || e.Key.Equals(Key.Return)) + && !string.IsNullOrEmpty(textBox.Text)) + { + this.ViewModel.ReadBarCode = textBox.Text.Trim(); + textBox.Text = string.Empty; + } + } + private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "CanWindowClose": + if (this.ViewModel.CanWindowClose) + { + CloseWindow(); + } + break; + case "OpenOptionPopup": + if (this.ViewModel.OpenOptionPopup) + { + OpenOptionPopup(); + } + break; + case "ShowPhoneInput": + ChangeWindow(); + break; + case "CertifyWindow": + ChangeWindow(); + break; + + + } + } + + + + #endregion Event Handlers + + private void OrderHistory_MouseClicked(object sender, RoutedEventArgs e) + { + + } + } + + +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointCoupon.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointCoupon.xaml new file mode 100644 index 0000000..6daebb9 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointCoupon.xaml @@ -0,0 +1,300 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointCoupon.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointCoupon.xaml.cs new file mode 100644 index 0000000..f01b84f --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointCoupon.xaml.cs @@ -0,0 +1,213 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Forms; +using System.Drawing; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using System.Windows.Threading; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; +using System.Windows.Media.Animation; + +namespace SPC.Kiosk.Popup +{ + /// + /// HappyPointCoupon.xaml에 대한 상호 작용 논리 + /// + public partial class HappyPointCoupon : Window + { + #region [ Members ] + private int ScreenNo { get; set; } = 0; + private VmHappyPointCoupon ViewModel { get; set; } + /// + /// HappyPoint 인증 및 사용 정보 + /// + private M_HappyPointReturn GetHappyPointReturn { get; set; } + private double GetPayments { get; set; } + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + /// + /// + public HappyPointCoupon(M_HappyPointReturn _happyPointReturn, double _totalPayment = 0) + { + GetPayments = _totalPayment; + GetHappyPointReturn = _happyPointReturn; + InitializeComponent(); + this.ContentRendered += HappyPointCoupon_ContentRendered; + this.Loaded += HappyPointCoupon_Loaded; + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + } + + #endregion Ctor + + #region [ Methods ] + private void OpenWindow() + { + var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeUp + , this.FrameBase.Height + , 0.5 + , 0.2); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Begin(); + } + } + private void CloseWindow() + { + var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeDown + , this.FrameBase.Height + , 0.5 + , 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + private void ChangeWindow() + { + try + { + var _target = this.FrameData; + var targetAnimation = new Storyboard(); + var centerX = _target.ActualWidth / 2; + var centerY = _target.ActualHeight / 2; + _target.RenderTransform = new ScaleTransform(1, 1, centerX, centerY); + var flipXAni = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.2))); + Storyboard.SetTarget(flipXAni, _target); + Storyboard.SetTargetProperty(flipXAni, new PropertyPath("RenderTransform.ScaleX")); + targetAnimation.Children.Add(flipXAni); + targetAnimation.Completed += TargetAnimation_Completed; + targetAnimation.Begin(); + + } + catch + { + } + } + private void TargetAnimation_Completed(object sender, EventArgs e) + { + if (this.ViewModel.HappyCouponWindow.Equals(HappyCouponWindowType.CouponStart)) + { + this.BarCode.IsEnabled = true; + this.BarCode.Focus(); + } + else + { + this.BarCode.IsEnabled = false; + } + } + + #endregion Methods + + #region [ Event Handlers ] + private void OpenAnimations_Completed(object sender, EventArgs e) + { + if (this.ViewModel.HappyCouponWindow.Equals(HappyCouponWindowType.CouponStart)) + { + this.BarCode.IsEnabled = true; + this.BarCode.Focus(); + } + else + { + this.BarCode.IsEnabled = false; + } + } + private void CloseAnimation_Completed(object sender, EventArgs e) + { + this.ContentRendered -= HappyPointCoupon_ContentRendered; + this.Loaded -= HappyPointCoupon_Loaded; + this.BarCode.PreviewKeyDown -= BarCode_PreviewKeyDown; + this.BarCode.LostFocus -= BarCode_LostFocus; + this.ViewModel.Dispose(); + this.Close(); + } + private void HappyPointCoupon_ContentRendered(object sender, EventArgs e) + { + this.FrameBase.Width = 1300; + this.FrameBase.Height = 1010; + OpenWindow(); + + } + private void HappyPointCoupon_Loaded(object sender, RoutedEventArgs e) + { + if (this.DataContext is VmHappyPointCoupon viewModel) + { + this.ViewModel = viewModel; + this.ViewModel.PropertyChanged += ViewModel_PropertyChanged; + this.ViewModel.Payments = GetPayments; + this.ViewModel.HappyPointReturn = GetHappyPointReturn; + this.ViewModel.PopupWidth = this.FrameBase.Width; + if (GetHappyPointReturn is M_HappyPointReturn + && GetHappyPointReturn.MyHappyCoupons.Count > 0 + && GetHappyPointReturn.MemberCode.Length > 15) + { + this.ViewModel.HappyCouponWindow = HappyCouponWindowType.CouponUsing; + } + else + { + this.ViewModel.HappyCouponWindow = HappyCouponWindowType.CouponStart; + + } + this.ViewModel.IsTimeoutPopup = false; + } + this.BarCode.PreviewKeyDown += BarCode_PreviewKeyDown; + this.BarCode.LostFocus += BarCode_LostFocus; + this.FrameBase.Width = 0; + this.FrameBase.Height = 0; + } + + private void BarCode_LostFocus(object sender, RoutedEventArgs e) + { + this.BarCode.Focus(); + } + + private void BarCode_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) + { + if (sender is System.Windows.Controls.TextBox textBox + && (e.Key.Equals(Key.Enter) || e.Key.Equals(Key.Return)) + && !string.IsNullOrEmpty(textBox.Text)) + { + this.ViewModel.ReadBarCode = textBox.Text.Trim(); + textBox.Text = string.Empty; + } + } + private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "CanWindowClose": + CloseWindow(); + break; + case "HappyCouponWindow": + ChangeWindow(); + break; + } + } + + #endregion Event Handlers + } + +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointUsing.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointUsing.xaml new file mode 100644 index 0000000..ff555a7 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointUsing.xaml @@ -0,0 +1,444 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointUsing.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointUsing.xaml.cs new file mode 100644 index 0000000..e01b81b --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/HappyPointUsing.xaml.cs @@ -0,0 +1,259 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Forms; +using System.Drawing; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using System.Windows.Threading; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; +using System.Windows.Media.Animation; + +namespace SPC.Kiosk.Popup +{ + /// + /// HappyPointUsing.xaml에 대한 상호 작용 논리 + /// + public partial class HappyPointUsing : Window + { + #region [ Members ] + private int ScreenNo { get; set; } = 0; + private VmHappyPointUsing ViewModel { get; set; } + /// + /// HappyPoint 인증 및 사용 정보 + /// + private M_HappyPointReturn GetHappyPointReturn { get; set; } + private double GetPayments { get; set; } + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + /// + /// + public HappyPointUsing(M_HappyPointReturn _happyPointReturn, double _totalPayment = 0) + { + GetPayments = _totalPayment; + GetHappyPointReturn = _happyPointReturn; + InitializeComponent(); + this.ContentRendered += HappyPointUsing_ContentRendered; + this.Loaded += HappyPointUsing_Loaded; + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + } + + #endregion Ctor + + #region [ Methods ] + private void OpenWindow() + { + var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeUp + , this.FrameBase.Height + , 0.5 + , 0.2); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Begin(); + } + } + private void CloseWindow() + { + var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeDown + , this.FrameBase.Height + , 0.5 + , 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + private void ChangeWindow() + { + try + { + var _target = this.FrameData; + var targetAnimation = new Storyboard(); + var centerX = _target.ActualWidth / 2; + var centerY = _target.ActualHeight / 2; + _target.RenderTransform = new ScaleTransform(1, 1, centerX, centerY); + var flipXAni = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.2))); + Storyboard.SetTarget(flipXAni, _target); + Storyboard.SetTargetProperty(flipXAni, new PropertyPath("RenderTransform.ScaleX")); + targetAnimation.Children.Add(flipXAni); + targetAnimation.Completed += TargetAnimation_Completed; + targetAnimation.Begin(); + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ChangeWindow()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + private void TargetAnimation_Completed(object sender, EventArgs e) + { + if (this.ViewModel.PointUsingWindow.Equals(PointUsingWindowType.CertifyStart)) + { + this.BarCode.IsEnabled = true; + this.BarCode.Focus(); + } + else + { + this.BarCode.IsEnabled = false; + } + } + private void OpenPassWindow() + { + this.ViewModel.TimerEnabled = false; + try + { + M_PopupReturn result = null; + var newPasswordPopup = new NumPadPopup(this.ViewModel.ShowLanguageType + , Languages.GetMessages("LBL0055")); + newPasswordPopup.ShowDialog(); + if (newPasswordPopup.DataContext is VmNumPadPopup viewModel) + { + result = viewModel.ReturnValue; + } + newPasswordPopup.DataContext = null; + newPasswordPopup = null; + if (result is M_PopupReturn) + { + if (result.OKAnswer) + { + this.ViewModel.CertifyPassword = (string)result.PopupArgs; + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenPassWindow()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + this.ViewModel.IsOpenPasswordWindow = false; + this.ViewModel.TimerEnabled = true; + } + + } + + #endregion Methods + + #region [ Event Handlers ] + private void OpenAnimations_Completed(object sender, EventArgs e) + { + if (this.ViewModel.PointUsingWindow.Equals(PointUsingWindowType.CertifyStart)) + { + this.BarCode.IsEnabled = true; + this.BarCode.Focus(); + } + else + { + this.BarCode.IsEnabled = false; + } + } + private void CloseAnimation_Completed(object sender, EventArgs e) + { + this.ContentRendered -= HappyPointUsing_ContentRendered; + this.Loaded -= HappyPointUsing_Loaded; + this.BarCode.PreviewKeyDown -= BarCode_PreviewKeyDown; + this.BarCode.LostFocus -= BarCode_LostFocus; + this.ViewModel.Dispose(); + this.Close(); + } + private void HappyPointUsing_ContentRendered(object sender, EventArgs e) + { + this.FrameBase.Width = 1300; + this.FrameBase.Height = 1010; + OpenWindow(); + + } + private void HappyPointUsing_Loaded(object sender, RoutedEventArgs e) + { + if (this.DataContext is VmHappyPointUsing viewModel) + { + this.ViewModel = viewModel; + this.ViewModel.PropertyChanged += ViewModel_PropertyChanged; + this.ViewModel.Payments = GetPayments; + this.ViewModel.HappyPointReturn = GetHappyPointReturn; + this.ViewModel.PopupWidth = this.FrameBase.Width; + if (GetHappyPointReturn is M_HappyPointReturn && GetHappyPointReturn.MemberCode.Length >= 16) + { + this.ViewModel.PointUsingWindow = PointUsingWindowType.PointUsing; + } + else + { + this.ViewModel.PointUsingWindow = PointUsingWindowType.CertifyStart; + + } + this.ViewModel.IsTimeoutPopup = false; + } + this.BarCode.PreviewKeyDown += BarCode_PreviewKeyDown; + this.BarCode.LostFocus += BarCode_LostFocus; + this.FrameBase.Width = 0; + this.FrameBase.Height = 0; + } + + private void BarCode_LostFocus(object sender, RoutedEventArgs e) + { + this.BarCode.Focus(); + } + + private void BarCode_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) + { + if (sender is System.Windows.Controls.TextBox textBox + && (e.Key.Equals(Key.Enter) || e.Key.Equals(Key.Return)) + && !string.IsNullOrEmpty(textBox.Text)) + { + this.ViewModel.ReadBarCode = textBox.Text.Trim(); + textBox.Text = string.Empty; + } + } + private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "CanWindowClose": + if (this.ViewModel.CanWindowClose) + { + if (this.ViewModel.ImmediatelyClose) + { + CloseAnimation_Completed(null, null); + } + else + { + CloseWindow(); + } + } + break; + case "PointUsingWindow": + ChangeWindow(); + break; + case "IsOpenPasswordWindow": + if (this.ViewModel.IsOpenPasswordWindow) OpenPassWindow(); + break; + } + } + + #endregion Event Handlers + } + +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/LanguageSelector.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/LanguageSelector.xaml new file mode 100644 index 0000000..5a52642 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/LanguageSelector.xaml @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/LanguageSelector.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/LanguageSelector.xaml.cs new file mode 100644 index 0000000..ed305fc --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/LanguageSelector.xaml.cs @@ -0,0 +1,228 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Forms; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Threading; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; +namespace SPC.Kiosk.Popup +{ + /// + /// LanguageSelector.xaml에 대한 상호 작용 논리 + /// + public partial class LanguageSelector : Window + { + #region [ Members ] + private int ScreenNo { get; set; } = 0; + private VmLanguageSelector ViewModel { get; set; } + private SupportLanguageType GetLanguageType { get; set; } + #endregion Members + + #region [ Ctor / Etc ] + /// + /// Ctor + /// + public LanguageSelector(SupportLanguageType _supportLanguageType) + { + GetLanguageType = _supportLanguageType; + InitializeComponent(); + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + this.Loaded += LanguageSelector_Loaded; + this.ContentRendered += LanguageSelector_ContentRendered; + } + + #endregion Ctor / Etc + + #region [ Methods ] + private void ChangeSwitch() + { + foreach (var aObj in this.LanguageButtonStack.Children) + { + if (aObj is AnimationButton aButton) + { + if (aButton.Tag is SupportLanguageType languageType) + { + aButton.Switch = this.ViewModel.ShowLanguageType.Equals(languageType); + aButton.Text = languageType.GetLanguageNativeName(); + } + } + } + } + private void CreateLanguageButtons() + { + foreach (var aLanguage in Enum.GetValues(typeof(SupportLanguageType)).Cast()) + { + var visible = Visibility.Visible; + switch (aLanguage) + { + case SupportLanguageType.en: + if (this.ViewModel.OptionValue813 == "0") visible = Visibility.Collapsed; + break; + case SupportLanguageType.ja: + if (this.ViewModel.OptionValue814 == "0") visible = Visibility.Collapsed; + break; + case SupportLanguageType.zh: + if (this.ViewModel.OptionValue815 == "0") visible = Visibility.Collapsed; + break; + default: + break; + } + + var ButtonData = new M_AnimationButton + { + Width = 180, + Height = 180, + BrushStretch = Stretch.Fill, + ClickAnimationType = ButtonAnimationType.SizeDown, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty, + Switch = this.ViewModel.ShowLanguageType.Equals(aLanguage), + TextVisible = Visibility.Collapsed, + Margin = new Thickness(33,0,33,0), + }; + switch (aLanguage) + { + case SupportLanguageType.ko: + ButtonData.NormalBrush = ResourceManager.GetNximagePathAdd("btn_pop_kor_n.png", CommonValue.PBdesignImagesPath); + ButtonData.SwitchOnBrush = ResourceManager.GetNximagePathAdd("btn_pop_kor_s.png", CommonValue.PBdesignImagesPath); + break; + case SupportLanguageType.en: + ButtonData.NormalBrush = ResourceManager.GetNximagePathAdd("btn_pop_eng_n.png", CommonValue.PBdesignImagesPath); + ButtonData.SwitchOnBrush = ResourceManager.GetNximagePathAdd("btn_pop_eng_s.png", CommonValue.PBdesignImagesPath); + break; + case SupportLanguageType.zh: + ButtonData.NormalBrush = ResourceManager.GetNximagePathAdd("btn_pop_chi_n.png", CommonValue.PBdesignImagesPath); + ButtonData.SwitchOnBrush = ResourceManager.GetNximagePathAdd("btn_pop_chi_s.png", CommonValue.PBdesignImagesPath); + break; + case SupportLanguageType.ja: + ButtonData.NormalBrush = ResourceManager.GetNximagePathAdd("btn_pop_jap_n.png", CommonValue.PBdesignImagesPath); + ButtonData.SwitchOnBrush = ResourceManager.GetNximagePathAdd("btn_pop_jap_s.png", CommonValue.PBdesignImagesPath); + break; + } + var newLanauageButton = new AnimationButton + { + Name = string.Format("Button_{0}", aLanguage), + DataParameter = ButtonData, + Tag = aLanguage, + Visibility = visible + }; + + newLanauageButton.MouseClicked += NewLanauageButton_MouseClicked; + this.LanguageButtonStack.Children.Add(newLanauageButton); + this.ReregisterName(string.Format("Button_{0}", aLanguage), newLanauageButton); + } + } + + private void CloseWindow() + { + var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeDown + , this.FrameBase.Height + , 0.5 + , 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + + private void OpenWindow() + { + var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeUp + , this.FrameBase.Height + , 0.5 + , 0.2); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Begin(); + } + } + #endregion Methods + + #region [ Event Handlers ] + + + private void CloseAnimation_Completed(object sender, EventArgs e) + { + this.Loaded -= LanguageSelector_Loaded; + this.ContentRendered -= LanguageSelector_ContentRendered; + this.ViewModel.Dispose(); + this.Close(); + } + private void OpenAnimations_Completed(object sender, EventArgs e) + { + } + + private void NewLanauageButton_MouseClicked(object sender, RoutedEventArgs e) + { + if (sender is AnimationButton clickedButton) + { + if (clickedButton.Tag is SupportLanguageType changeLanguage) + { + if (!this.ViewModel.ShowLanguageType.Equals(changeLanguage)) + { + this.ViewModel.ShowLanguageType = changeLanguage; + ChangeSwitch(); + } + } + } + } + private void LanguageSelector_ContentRendered(object sender, EventArgs e) + { + this.FrameBase.Width = 1300; + this.FrameBase.Height = 1010; + OpenWindow(); + } + + private void LanguageSelector_Loaded(object sender, RoutedEventArgs e) + { + if (this.DataContext is VmLanguageSelector viewModel) + { + this.ViewModel = viewModel; + this.ViewModel.PropertyChanged += ViewModel_PropertyChanged; + this.ViewModel.ShowLanguageType = GetLanguageType; + this.ViewModel.IsTimeoutPopup = false; + } + CreateLanguageButtons(); + this.UpdateLayout(); + this.FrameBase.Width = 0; + this.FrameBase.Height = 0; + } + + private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "CanWindowClose": + if (this.ViewModel.CanWindowClose) + { + CloseWindow(); + } + break; + + } + } + #endregion Event Handlers + + } +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/MiniPopup.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/MiniPopup.xaml new file mode 100644 index 0000000..1698ba2 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/MiniPopup.xaml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/MiniPopup.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/MiniPopup.xaml.cs new file mode 100644 index 0000000..08938b5 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/MiniPopup.xaml.cs @@ -0,0 +1,147 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Forms; +using System.Drawing; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using System.Windows.Threading; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; + +namespace SPC.Kiosk.Popup +{ + /// + /// CallEmployee.xaml에 대한 상호 작용 논리 + /// + public partial class MiniPopup : Window + { + #region [ Members ] + private int ScreenNo { get; set; } = 0; + private VmMiniPopup ViewModel { get; set; } + + private M_MiniPopup GetMiniPopup { get; set; } + + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public MiniPopup(M_MiniPopup _getMiniPopup) + { + GetMiniPopup = _getMiniPopup; + InitializeComponent(); + this.ContentRendered += MiniPopup_ContentRendered; + this.Loaded += MiniPopup_Loaded; + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + + } + + #endregion Ctor + + #region [ Methods ] + private void OpenWindow() + { + var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeUp + , this.FrameBase.Height + , 0.5 + , 0.2); + if (OpenAnimations != null) + { + OpenAnimations.Begin(); + } + } + private void CloseWindow() + { + var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeDown + , this.FrameBase.Height + , 0.5 + , 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + #endregion Methods + + #region [ Event Handlers ] + private void CloseAnimation_Completed(object sender, EventArgs e) + { + + this.ContentRendered -= MiniPopup_ContentRendered; + this.Loaded -= MiniPopup_Loaded; + this.ViewModel.Dispose(); + this.Close(); + } + + private void MiniPopup_ContentRendered(object sender, EventArgs e) + { + this.FrameBase.Width = 800; + this.FrameBase.Height = 540; + OpenWindow(); + } + + private void MiniPopup_Loaded(object sender, RoutedEventArgs e) + { + if (this.DataContext is VmMiniPopup viewModel) + { + ViewModel = viewModel; + ViewModel.PropertyChanged += ViewModel_PropertyChanged; + ViewModel.MiniPopup = GetMiniPopup; + ViewModel.IsTimeoutPopup = false; + } + this.FrameBase.Width = 0; + this.FrameBase.Height = 0; + } + + private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "CanWindowClose": + if (this.ViewModel.CanWindowClose) + { + CloseWindow(); + } + break; + case "SubMessageText": + if (string.IsNullOrEmpty(ViewModel.SubMessageText.GetLanguageData(ViewModel.ShowLanguageType))) + { + Message2.Visibility = Visibility.Collapsed; + } + else + { + Message2.Visibility = Visibility.Visible; + } + break; + } + } + + + + + + + #endregion Event Handlers + } + + +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/MobileCompanyMemberCertify.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/MobileCompanyMemberCertify.xaml new file mode 100644 index 0000000..fce9c8e --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/MobileCompanyMemberCertify.xaml @@ -0,0 +1,303 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/MobileCompanyMemberCertify.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/MobileCompanyMemberCertify.xaml.cs new file mode 100644 index 0000000..ceb8da3 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/MobileCompanyMemberCertify.xaml.cs @@ -0,0 +1,212 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Forms; +using System.Drawing; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using System.Windows.Threading; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; +using System.Windows.Media.Animation; +namespace SPC.Kiosk.Popup +{ + /// + /// MobileCompanyMemberCertify.xaml에 대한 상호 작용 논리 + /// + public partial class MobileCompanyMemberCertify : Window + { + #region [ Members ] + private int ScreenNo { get; set; } = 0; + private VmMobileCompanyMemberCertify ViewModel { get; set; } + private MobileCompanyType GetMobileCompany { get; set; } + private double GetPayments { get; set; } + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + /// + /// + public MobileCompanyMemberCertify(MobileCompanyType _mobileCompany, double _totalPayment = 0) + { + GetPayments = _totalPayment; + GetMobileCompany = _mobileCompany; + InitializeComponent(); + this.ContentRendered += MobileCompanyMemberCertify_ContentRendered; + this.Loaded += MobileCompanyMemberCertify_Loaded; + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + + } + + #endregion Ctor + + #region [ Methods ] + private void OpenWindow() + { + var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeUp + , this.FrameBase.Height + , 0.5 + , 0.2); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Begin(); + } + } + private void CloseWindow() + { + var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeDown + , this.FrameBase.Height + , 0.5 + , 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + private void ChangeWindow() + { + //this.Dispatcher.Invoke((Action)(() => + //{ + try + { + var _target = this.FrameData; + var targetAnimation = new Storyboard(); + var centerX = _target.ActualWidth / 2; + var centerY = _target.ActualHeight / 2; + _target.RenderTransform = new ScaleTransform(1, 1, centerX, centerY); + var flipXAni = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.2))); + Storyboard.SetTarget(flipXAni, _target); + Storyboard.SetTargetProperty(flipXAni, new PropertyPath("RenderTransform.ScaleX")); + targetAnimation.Children.Add(flipXAni); + targetAnimation.Completed += TargetAnimation_Completed; + targetAnimation.Begin(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ChangeWindow()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + //})); + } + + private void TargetAnimation_Completed(object sender, EventArgs e) + { + if (this.ViewModel.CertifyWindow.Equals(CertifyWindowType.CertifyStart)) + { + this.BarCode.IsEnabled = true; + this.BarCode.Focus(); + } + else + { + this.BarCode.IsEnabled = false; + } + } + + #endregion Methods + + #region [ Event Handlers ] + private void OpenAnimations_Completed(object sender, EventArgs e) + { + if (this.ViewModel.CertifyWindow.Equals(CertifyWindowType.CertifyStart)) + { + this.BarCode.IsEnabled = true; + this.BarCode.Focus(); + } + else + { + this.BarCode.IsEnabled = false; + } + } + private void CloseAnimation_Completed(object sender, EventArgs e) + { + this.ContentRendered -= MobileCompanyMemberCertify_ContentRendered; + this.Loaded += MobileCompanyMemberCertify_Loaded; + this.BarCode.PreviewKeyDown -= BarCode_PreviewKeyDown; + this.BarCode.LostFocus -= BarCode_LostFocus; + this.ViewModel.Dispose(); + this.Close(); + } + + private void MobileCompanyMemberCertify_ContentRendered(object sender, EventArgs e) + { + this.FrameBase.Width = 1300; + this.FrameBase.Height = 1010; + OpenWindow(); + } + + private void MobileCompanyMemberCertify_Loaded(object sender, RoutedEventArgs e) + { + if (this.DataContext is VmMobileCompanyMemberCertify viewModel) + { + this.ViewModel = viewModel; + this.ViewModel.PropertyChanged += ViewModel_PropertyChanged; + this.ViewModel.MobileCompany = GetMobileCompany; + this.ViewModel.Payments = GetPayments; + this.ViewModel.IsTimeoutPopup = false; + } + this.LostFocus += MobileCompanyMemberCertify_LostFocus; + this.BarCode.PreviewKeyDown += BarCode_PreviewKeyDown; + this.BarCode.LostFocus += BarCode_LostFocus; + this.FrameBase.Width = 0; + this.FrameBase.Height = 0; + + } + private void MobileCompanyMemberCertify_LostFocus(object sender, RoutedEventArgs e) + { + this.Focus(); + } + private void BarCode_LostFocus(object sender, RoutedEventArgs e) + { + this.BarCode.Focus(); + } + + private void BarCode_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) + { + if (sender is System.Windows.Controls.TextBox textBox + && (e.Key.Equals(Key.Enter) || e.Key.Equals(Key.Return)) + && !string.IsNullOrEmpty(textBox.Text)) + { + this.ViewModel.ReadBarCode = textBox.Text.Trim(); + textBox.Text = string.Empty; + } + } + + + private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "CanWindowClose": + if (this.ViewModel.CanWindowClose) + { + CloseWindow(); + } + break; + case "CertifyWindow": + ChangeWindow(); + break; + } + } + #endregion Event Handlers + } + +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/MobileHappyCoupon.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/MobileHappyCoupon.xaml new file mode 100644 index 0000000..621773d --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/MobileHappyCoupon.xaml @@ -0,0 +1,374 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/MobileHappyCoupon.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/MobileHappyCoupon.xaml.cs new file mode 100644 index 0000000..d2df8cf --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/MobileHappyCoupon.xaml.cs @@ -0,0 +1,363 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Media.Animation; +using System.Windows.Forms; +using System.Drawing; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using System.Windows.Threading; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; +using SPC.Kiosk.DataHelper; +namespace SPC.Kiosk.Popup +{ + /// + /// MobileHappyCoupon.xaml에 대한 상호 작용 논리 + /// + public partial class MobileHappyCoupon : Window + { + #region [ Members ] + private int ScreenNo { get; set; } = 0; + private VmMobileHappyCoupon ViewModel { get; set; } + private double GetPayments { get; set; } + private List GetBasketItems { get; set; } + + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + /// + /// + public MobileHappyCoupon(List _getBasketItems, double _getPayments) + { + GetPayments = _getPayments; + GetBasketItems = _getBasketItems; + InitializeComponent(); + this.ContentRendered += MobileHappyCoupon_ContentRendered; + this.Loaded += MobileHappyCoupon_Loaded; + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + + } + + #endregion Ctor + + #region [ Methods ] + private void OpenWindow() + { + var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeUp + , this.FrameBase.Height + , 0.5 + , 0.2); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Begin(); + } + } + private void CloseWindow() + { + var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeDown + , this.FrameBase.Height + , 0.5 + , 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + private void ChangeWindow() + { + //this.Dispatcher.Invoke((Action)(() => + //{ + try + { + var _target = this.FrameData; + var targetAnimation = new Storyboard(); + var centerX = _target.ActualWidth / 2; + var centerY = _target.ActualHeight / 2; + _target.RenderTransform = new ScaleTransform(1, 1, centerX, centerY); + var flipXAni = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.2))); + Storyboard.SetTarget(flipXAni, _target); + Storyboard.SetTargetProperty(flipXAni, new PropertyPath("RenderTransform.ScaleX")); + targetAnimation.Children.Add(flipXAni); + targetAnimation.Completed += TargetAnimation_Completed; + targetAnimation.Begin(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ChangeWindow()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + //})); + } + + private void TargetAnimation_Completed(object sender, EventArgs e) + { + if (this.ViewModel.CouponWindow.Equals(MobileCouponWindowType.CouponStart)) + { + this.BarCode.IsEnabled = true; + this.BarCode.Focus(); + } + else + { + this.BarCode.IsEnabled = false; + } + } + + #endregion Methods + + #region [ Event Handlers ] + private void OpenAnimations_Completed(object sender, EventArgs e) + { + if (this.ViewModel.CouponWindow.Equals(MobileCouponWindowType.CouponStart)) + { + this.BarCode.IsEnabled = true; + this.BarCode.Focus(); + } + else + { + this.BarCode.IsEnabled = false; + } + } + private void CloseAnimation_Completed(object sender, EventArgs e) + { + this.ContentRendered -= MobileHappyCoupon_ContentRendered; + this.Loaded += MobileHappyCoupon_Loaded; + this.BarCode.PreviewKeyDown -= BarCode_PreviewKeyDown; + this.BarCode.LostFocus -= BarCode_LostFocus; + this.ViewModel.Dispose(); + this.Close(); + } + + private void MobileHappyCoupon_ContentRendered(object sender, EventArgs e) + { + this.FrameBase.Width = 1300; + this.FrameBase.Height = 1010; + OpenWindow(); + } + + private void MobileHappyCoupon_Loaded(object sender, RoutedEventArgs e) + { + if (this.DataContext is VmMobileHappyCoupon viewModel) + { + this.ViewModel = viewModel; + this.ViewModel.PropertyChanged += ViewModel_PropertyChanged; + this.ViewModel.Payments += GetPayments; + this.ViewModel.BasketData = GetBasketItems; + this.ViewModel.IsTimeoutPopup = false; + } + this.LostFocus += MobileHappyCoupon_LostFocus; + this.BarCode.PreviewKeyDown += BarCode_PreviewKeyDown; + this.BarCode.LostFocus += BarCode_LostFocus; + this.FrameBase.Width = 0; + this.FrameBase.Height = 0; + + } + private void MobileHappyCoupon_LostFocus(object sender, RoutedEventArgs e) + { + this.Focus(); + } + private void BarCode_LostFocus(object sender, RoutedEventArgs e) + { + this.BarCode.Focus(); + } + + private void BarCode_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) + { + if (sender is System.Windows.Controls.TextBox textBox + && (e.Key.Equals(Key.Enter) || e.Key.Equals(Key.Return)) + && !string.IsNullOrEmpty(textBox.Text)) + { + this.ViewModel.ReadBarCode = textBox.Text.Trim(); + textBox.Text = string.Empty; + } + } + + + private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "CanWindowClose": + if (this.ViewModel.CanWindowClose) + { + CloseWindow(); + } + break; + case "CouponWindow": + ChangeWindow(); + break; + } + } + #endregion Event Handlers + private void OpenErrorPopup(List _errorMessage) + { + this.ViewModel.TimerEnabled = false; + try + { + var miniPopup = new M_MiniPopup + { + Icon = MiniPopupIcon.AddCoupon, + DisplayLanguage = this.ViewModel.ShowLanguageType, + Message = _errorMessage, + OkButtonText = Languages.GetMessages("BTN0039"), + IsCencalButton = false, + TimeoutSeconds = 10, + }; + var MiniPopupWin = new MiniPopup(miniPopup); + MiniPopupWin.ShowDialog(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenErrorPopup()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + finally + { + this.ViewModel.TimerEnabled = true; + } + } + private long GetUsingValue() + { + long result = 0L; + try + { + M_PopupReturn getInput = null; + var newPasswordPopup = new NumPadPopup(this.ViewModel.ShowLanguageType + , Languages.GetMessages("LBL0122") + ,false + ,false + ,6 + ,0); + newPasswordPopup.ShowDialog(); + if (newPasswordPopup.DataContext is VmNumPadPopup viewModel) + { + getInput = viewModel.ReturnValue; + } + newPasswordPopup.DataContext = null; + newPasswordPopup = null; + if (getInput is M_PopupReturn) + { + if (getInput.OKAnswer) + { + result = long.Parse("0"+(string)getInput.PopupArgs); + } + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetUsingValue()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = 0L; + } + return result; + + } + private void CoupnDatas_CouponSelect(object sender, RoutedEventArgs e) + { + if (e.OriginalSource is M_MobileCouponDetail mobileCouponDetail) + { + //if (mobileCouponDetail.BrandCode.StartsWith()) + if (mobileCouponDetail.RequestPrice.Equals(0)) + { + var canUsingPrice = mobileCouponDetail.CanUsingPrice; + var maxUsingPrice = long.Parse((this.ViewModel.Payments - this.ViewModel.TotalCouponAmount).ToString()); + var maxCanInputPrice = maxUsingPrice <= canUsingPrice + ? maxUsingPrice + : canUsingPrice; + if (maxUsingPrice > 0) + { + switch (mobileCouponDetail.Type) + { + case MobileCouponType.NormalValue: + case MobileCouponType.ValueLimit: + var inputValue = GetUsingValue(); + if (inputValue > 0) + { + if (inputValue > maxCanInputPrice) + { + OpenErrorPopup(Languages.GetMessages("LBL0033")); + } + else if (inputValue % 10 > 0) + { + OpenErrorPopup(Languages.GetMessages("LBL0020")); + } + else + { + mobileCouponDetail.RequestPrice = inputValue; + mobileCouponDetail.DiscountPrice = inputValue; + } + } + break; + case MobileCouponType.ValueFixed: + if (canUsingPrice > maxUsingPrice) + { + OpenErrorPopup(Languages.GetMessages("LBL0033")); + } + else + { + mobileCouponDetail.RequestPrice = canUsingPrice; + mobileCouponDetail.DiscountPrice = canUsingPrice; + } + break; + default: + if (canUsingPrice > maxUsingPrice) + { + OpenErrorPopup(Languages.GetMessages("LBL0033")); + } + else + { + if (mobileCouponDetail.Option.Equals(MobileCouponOptionType.ItemFixed)) + { + var exitItem = false; + using (var newPosDataService = new PosDataService()) + { + exitItem = newPosDataService.IsExistITEM_PLU_CD(mobileCouponDetail.ItemCodeKey); + } + if (exitItem) + { + mobileCouponDetail.RequestPrice = canUsingPrice; + mobileCouponDetail.DiscountPrice = canUsingPrice; + } + else + { + OpenErrorPopup(Languages.GetMessages("LBL0064")); + } + } + else + { + mobileCouponDetail.RequestPrice = canUsingPrice; + mobileCouponDetail.DiscountPrice = canUsingPrice; + } + } + break; + } + } + } + else + { + mobileCouponDetail.RequestPrice = 0; + mobileCouponDetail.DiscountPrice = 0; + } + } + } + } + +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/NumPadPopup.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/NumPadPopup.xaml new file mode 100644 index 0000000..76118bb --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/NumPadPopup.xaml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/NumPadPopup.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/NumPadPopup.xaml.cs new file mode 100644 index 0000000..a70b86e --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/NumPadPopup.xaml.cs @@ -0,0 +1,163 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Forms; +using System.Drawing; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using System.Windows.Threading; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; +using System.Windows.Media.Animation; + +namespace SPC.Kiosk.Popup +{ + /// + /// HappyPointCertify.xaml에 대한 상호 작용 논리 + /// + public partial class NumPadPopup : Window + { + #region [ Members ] + private int ScreenNo { get; set; } = 0; + private VmNumPadPopup ViewModel { get; set; } + private SupportLanguageType GetLanguageType { get; set; } + private List GetGuideText { get; set; } + private bool Formated { get; set; } + private bool IsPassword { get; set; } + private int MaxLength { get; set; } + private int CheckLength { get; set; } + + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public NumPadPopup(SupportLanguageType _languageType + , List _guideText + , bool _formated = false + , bool _isPassword = true + , int _maxLength = 4 + , int _checkLength = 4) + { + GetLanguageType = _languageType; + GetGuideText = _guideText; + Formated = _formated; + IsPassword = _isPassword; + MaxLength = _maxLength; + CheckLength = _checkLength; + InitializeComponent(); + this.ContentRendered += NumPadPopup_ContentRendered; + this.Loaded += NumPadPopup_Loaded; + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + + } + + + #endregion Ctor + + #region [ Methods ] + private void OpenWindow() + { + var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeUp + , this.FrameBase.Height + , 0.5 + , 0.5); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Begin(); + } + } + private void CloseWindow() + { + var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeDown + , this.FrameBase.Width + , 0.5 + , 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + + + + #endregion Methods + + #region [ Event Handlers ] + private void OpenAnimations_Completed(object sender, EventArgs e) + { + } + private void CloseAnimation_Completed(object sender, EventArgs e) + { + this.Loaded -= NumPadPopup_Loaded; + this.ViewModel.Dispose(); + + this.Close(); + + } + private void NumPadPopup_ContentRendered(object sender, EventArgs e) + { + this.FrameBase.Width = 540; + this.FrameBase.Height = 800; + OpenWindow(); + } + + private void NumPadPopup_Loaded(object sender, RoutedEventArgs e) + { + + if (this.DataContext is VmNumPadPopup viewModel) + { + this.ViewModel = viewModel; + this.ViewModel.PropertyChanged += ViewModel_PropertyChanged; + this.ViewModel.ShowLanguageType = GetLanguageType; + this.ViewModel.NumPadGuidText = GetGuideText; + this.ViewModel.Formated = Formated; + this.ViewModel.IsPassword = IsPassword; + this.ViewModel.NumPadMaxLength = MaxLength; + this.ViewModel.CheckLength = CheckLength; + this.ViewModel.PopupWidth = this.FrameBase.Width; + this.ViewModel.IsTimeoutPopup = false; + } + this.FrameBase.Width = 0; + this.FrameBase.Height = 0; + } + + + private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "CanWindowClose": + if (this.ViewModel.CanWindowClose) + { + CloseWindow(); + } + break; + + } + } + + #endregion Event Handlers + } + + +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/OkCashBagCertify.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/OkCashBagCertify.xaml new file mode 100644 index 0000000..7426b46 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/OkCashBagCertify.xaml @@ -0,0 +1,298 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/OkCashBagCertify.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/OkCashBagCertify.xaml.cs new file mode 100644 index 0000000..cf1f60a --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/OkCashBagCertify.xaml.cs @@ -0,0 +1,210 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Forms; +using System.Drawing; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using System.Windows.Threading; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; +using System.Windows.Media.Animation; + +namespace SPC.Kiosk.Popup +{ + /// + /// OkCashBagCertify.xaml에 대한 상호 작용 논리 + /// + public partial class OkCashBagCertify : Window + { + #region [ Members ] + private int ScreenNo { get; set; } = 0; + private VmOkCashBagCertify ViewModel { get; set; } + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public OkCashBagCertify() + { + InitializeComponent(); + this.ContentRendered += OkCashBagCertify_ContentRendered; + this.Loaded += OkCashBagCertify_Loaded; + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + + } + + #endregion Ctor + + #region [ Methods ] + private void OpenWindow() + { + var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeUp + , this.FrameBase.Height + , 0.5 + , 0.2); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Begin(); + } + } + private void CloseWindow() + { + var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeDown + , this.FrameBase.Height + , 0.5 + , 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + private void ChangeWindow() + { + //this.Dispatcher.Invoke((Action)(() => + //{ + try + { + var _target = this.FrameData; + var targetAnimation = new Storyboard(); + var centerX = _target.ActualWidth / 2; + var centerY = _target.ActualHeight / 2; + _target.RenderTransform = new ScaleTransform(1, 1, centerX, centerY); + var flipXAni = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.2))); + Storyboard.SetTarget(flipXAni, _target); + Storyboard.SetTargetProperty(flipXAni, new PropertyPath("RenderTransform.ScaleX")); + targetAnimation.Children.Add(flipXAni); + targetAnimation.Completed += TargetAnimation_Completed; + targetAnimation.Begin(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ChangeWindow()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + //})); + } + + private void TargetAnimation_Completed(object sender, EventArgs e) + { + if (this.ViewModel.CertifyWindow.Equals(CertifyWindowType.CertifyStart)) + { + this.BarCode.IsEnabled = true; + this.BarCode.Focus(); + } + else + { + this.BarCode.IsEnabled = false; + } + } + + #endregion Methods + + #region [ Event Handlers ] + private void OpenAnimations_Completed(object sender, EventArgs e) + { + if (this.ViewModel.CertifyWindow.Equals(CertifyWindowType.CertifyStart)) + { + this.BarCode.IsEnabled = true; + this.BarCode.Focus(); + } + else + { + this.BarCode.IsEnabled = false; + } + } + private void CloseAnimation_Completed(object sender, EventArgs e) + { + this.ContentRendered -= OkCashBagCertify_ContentRendered; + this.Loaded -= OkCashBagCertify_Loaded; + this.LostFocus -= OkCashBagCertify_LostFocus; + this.BarCode.PreviewKeyDown -= BarCode_PreviewKeyDown; + this.BarCode.LostFocus -= BarCode_LostFocus; + this.ViewModel.Dispose(); + this.Close(); + } + private void OkCashBagCertify_ContentRendered(object sender, EventArgs e) + { + this.FrameBase.Width = 1300; + this.FrameBase.Height = 1010; + OpenWindow(); + } + + private void OkCashBagCertify_Loaded(object sender, RoutedEventArgs e) + { + + if (this.DataContext is VmOkCashBagCertify viewModel) + { + this.ViewModel = viewModel; + this.ViewModel.PropertyChanged += ViewModel_PropertyChanged; + this.ViewModel.IsTimeoutPopup = false; + } + this.LostFocus += OkCashBagCertify_LostFocus; + this.BarCode.PreviewKeyDown += BarCode_PreviewKeyDown; + this.BarCode.LostFocus += BarCode_LostFocus; + this.FrameBase.Width = 0; + this.FrameBase.Height = 0; + + } + + private void OkCashBagCertify_LostFocus(object sender, RoutedEventArgs e) + { + this.Focus(); + } + + private void BarCode_LostFocus(object sender, RoutedEventArgs e) + { + this.BarCode.Focus(); + } + + private void BarCode_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) + { + if (sender is System.Windows.Controls.TextBox textBox + && (e.Key.Equals(Key.Enter) || e.Key.Equals(Key.Return)) + && !string.IsNullOrEmpty(textBox.Text)) + { + this.ViewModel.ReadBarCode = textBox.Text.Trim(); + textBox.Text = string.Empty; + } + } + private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "CanWindowClose": + if (this.ViewModel.CanWindowClose) + { + CloseWindow(); + } + break; + case "CertifyWindow": + ChangeWindow(); + break; + + + } + } + + #endregion Event Handlers + } + + +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/OkCashBagUsing.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/OkCashBagUsing.xaml new file mode 100644 index 0000000..08726cf --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/OkCashBagUsing.xaml @@ -0,0 +1,493 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/OkCashBagUsing.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/OkCashBagUsing.xaml.cs new file mode 100644 index 0000000..24e00d5 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/OkCashBagUsing.xaml.cs @@ -0,0 +1,178 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Forms; +using System.Drawing; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using System.Windows.Threading; +using System.Text.RegularExpressions; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; +namespace SPC.Kiosk.Popup +{ + /// + /// PkCashBagCertify.xaml에 대한 상호 작용 논리 + /// + public partial class OkCashBagUsing : Window + { + #region [ Members ] + private int ScreenNo { get; set; } = 0; + private VmOkCashBagUsing ViewModel { get; set; } + private double GetPayments { get; set; } + private bool GetReserveEnabled { get; set; } + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + /// + /// + public OkCashBagUsing(double _totalPayment = 0, bool _reserveEnabled = true) + { + + GetPayments = _totalPayment; + GetReserveEnabled = _reserveEnabled; + InitializeComponent(); + this.ContentRendered += OkCashBagUsing_ContentRendered; + this.Loaded += OkCashBagCertify_Loaded; + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + + } + + #endregion Ctor + + #region [ Methods ] + private void OpenWindow() + { + this.AfterBase.Visibility = Visibility.Hidden; + var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeUp + , this.FrameBase.Height + , 0.5 + , 0.2); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Begin(); + } + } + private void CloseWindow() + { + var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeDown + , this.FrameBase.Height + , 0.5 + , 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + + #endregion Methods + + #region [ Event Handlers ] + private void OpenAnimations_Completed(object sender, EventArgs e) + { + this.BarCode.Focus(); + } + private void CloseAnimation_Completed(object sender, EventArgs e) + { + this.ContentRendered -= OkCashBagUsing_ContentRendered; + this.Loaded -= OkCashBagCertify_Loaded; + this.BarCode.PreviewKeyDown -= BarCode_PreviewKeyDown; + this.BarCode.LostFocus -= BarCode_LostFocus; + this.Close(); + } + private void OkCashBagUsing_ContentRendered(object sender, EventArgs e) + { + this.FrameBase.Width = 1300; + this.FrameBase.Height = 1010; + OpenWindow(); + } + + private void OkCashBagCertify_Loaded(object sender, RoutedEventArgs e) + { + + + + if (this.DataContext is VmOkCashBagUsing viewModel) + { + this.ViewModel = viewModel; + this.ViewModel.PropertyChanged += ViewModel_PropertyChanged; + this.ViewModel.Payments = GetPayments; + this.ViewModel.ReservePoint = GetReserveEnabled; + this.ViewModel.IsTimeoutPopup = false; + } + this.BarCode.PreviewKeyDown += BarCode_PreviewKeyDown; + this.BarCode.LostFocus += BarCode_LostFocus; + this.AfterBase.IsEnabled = false; + this.FrameBase.Width = 0; + this.FrameBase.Height = 0; + } + private void BarCode_LostFocus(object sender, RoutedEventArgs e) + { + this.BarCode.Focus(); + } + private void BarCode_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) + { + if (sender is System.Windows.Controls.TextBox textBox + && (e.Key.Equals(Key.Enter) || e.Key.Equals(Key.Return)) + && !string.IsNullOrEmpty(textBox.Text)) + { + this.ViewModel.ReadBarCode = textBox.Text.Trim(); + textBox.Text = string.Empty; + } + } + private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "CanWindowClose": + if (this.ViewModel.CanWindowClose) + { + CloseWindow(); + } + break; + case "ToAfterBase": + if (this.ViewModel.ToAfterBase) + { + this.FrameBase.IsEnabled = false; + var AfterBaseOpenAnimations = Animations.GetOpenAndCloseAnimation(this.FrameBase + , this.AfterBase + , OpenCloseAnimationType.GotoRight + , this.FrameBase.Width, 0, 0.3); + if (AfterBaseOpenAnimations != null) + { + AfterBaseOpenAnimations.Completed += AfterBaseOpenAnimations_Completed; + AfterBaseOpenAnimations.Begin(); + } + } + break; + } + } + private void AfterBaseOpenAnimations_Completed(object sender, EventArgs e) + { + this.AfterBase.IsEnabled = true; + } + #endregion Event Handlers + } + +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/OptionGroup.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/OptionGroup.xaml new file mode 100644 index 0000000..26ae388 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/OptionGroup.xaml @@ -0,0 +1,52 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/OptionGroup.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/OptionGroup.xaml.cs new file mode 100644 index 0000000..173acc6 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/OptionGroup.xaml.cs @@ -0,0 +1,291 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; + +namespace SPC.Kiosk.Popup +{ + /// + /// DiscountAndValue.xaml에 대한 상호 작용 논리 + /// + public partial class OptionGroup : UserControl + { + #region [ Members ] + private string optionGroupDefault = ResourceManager.GetNximagePathAdd("btn_count_plus_p.png", CommonValue.PBdesignImagesPath); + /// + /// ItemData + /// + public static readonly DependencyProperty GroupDataProperty = + DependencyProperty.Register(nameof(GroupData), typeof(M_ItemOptionGroup), typeof(OptionGroup), new PropertyMetadata(null, new PropertyChangedCallback(OnGroupDataPropertyChanged))); + + + /// + /// Display Language + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(OptionGroup), new PropertyMetadata(SupportLanguageType.ko, new PropertyChangedCallback(OnDisplayLanguageProperyChanged))); + + /// + /// Horizontal Scroll Offset + /// + public static readonly DependencyProperty HorizontalOffsetProperty = + DependencyProperty.Register(nameof(HorizontalOffset), typeof(double), typeof(OptionGroup), new PropertyMetadata(0d, new PropertyChangedCallback(OnHorizontalOffsetPropertyChanged))); + /// + /// EditMode + /// + public static readonly DependencyProperty EditModeProperty = + DependencyProperty.Register(nameof(EditMode), typeof(bool), typeof(OptionGroup), new PropertyMetadata(false)); + + /// + /// Horizontal Scroll Offset + /// + public double HorizontalOffset + { + get { return (double)GetValue(HorizontalOffsetProperty); } + set { SetValue(HorizontalOffsetProperty, value); } + } + /// + /// ItemData + /// + public M_ItemOptionGroup GroupData + { + get { return (M_ItemOptionGroup)GetValue(GroupDataProperty); } + set { SetValue(GroupDataProperty, value); } + } + /// + /// Display Language + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + /// + /// Edit Mode + /// + public bool EditMode + { + get { return (bool)GetValue(EditModeProperty); } + set { SetValue(EditModeProperty, value); } + } + #region [ RoutedEvent 'SelectChange' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent SelectChangeEvent = EventManager.RegisterRoutedEvent(nameof(SelectChange), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(OptionGroup)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler SelectChange + { + add { AddHandler(SelectChangeEvent, value); } + remove { RemoveHandler(SelectChangeEvent, value); } + } + #endregion RoutedEvent 'SelectChange' + private double mouseDownXposition = -1; + private bool MoseDown = false; + #endregion Members + + #region [ Ctor & Etc ] + /// + /// Ctor + /// + public OptionGroup() + { + InitializeComponent(); + OptionGrid.PreviewMouseDown += OptionGrid_PreviewMouseDown; + OptionGrid.PreviewMouseUp += OptionGrid_PreviewMouseUp; + OptionGrid.PreviewMouseMove += OptionGrid_PreviewMouseMove; + OptionGrid.MouseLeave += OptionGrid_MouseLeave; + } + + + #endregion Ctor & Etc + + #region [ Methods ] + /// + /// Raise MouseClicked Event + /// + private void RaiseSelectChangeEvent(object _sender) + { + RoutedEventArgs newEventArgs = new RoutedEventArgs(OptionGroup.SelectChangeEvent, _sender); + RaiseEvent(newEventArgs); + } + private void SetOptionStack(M_ItemOptionGroup newValue) + { + this.OptionGroupName.MultiLanguage = newValue.Name; + this.OptionGroupIcon.NormalBrush = ResourceManager.GetOptionImage(newValue.ImageFile, CommonValue.OptionDefaultImage); + foreach (var aItem in OptionStack.Children) + { + if (aItem is OptionItem aOptionItem) + { + aOptionItem.MouseClicked -= OptionItem_MouseClicked; + } + } + OptionStack.Children.Clear(); + var Index = 0; + + foreach (var aOption in newValue.Options) + { + if (!EditMode) + { + if (newValue.IsMustSelect && Index.Equals(0)) + { + switch (aOption.Kind) + { + case OptionKind.Button: + aOption.IsSelected = true; + break; + case OptionKind.Discount: + case OptionKind.UpCharge: + aOption.IsSelected = true; + aOption.SelectValue = aOption.Amount; + break; + case OptionKind.Count: + aOption.IsSelected = true; + aOption.SelectValue = aOption.AmountMin.Equals(0) ? aOption.Amount : aOption.AmountMin; + break; + } + } + else + { + aOption.IsSelected = false; + } + } + var newOptionItem = new OptionItem + { + DisplayLanguage = this.DisplayLanguage, + OptionMode = newValue.SelectMode, + ItemData = aOption, + }; + newOptionItem.MouseClicked += OptionItem_MouseClicked; + newOptionItem.Name = string.Format("OptionItem{0}", aOption.Index); + this.ReregisterName(newOptionItem.Name, newOptionItem); + this.OptionStack.Children.Add(newOptionItem); + Index++; + } + } + + + + private string GetGroupImage(string _ImageFile) + { + string result = optionGroupDefault; + try + { + if (string.IsNullOrEmpty(_ImageFile)) + { + result = ResourceManager.GetNximagePathAdd(_ImageFile, CommonValue.PBdesignImagesPath); ; + if (string.IsNullOrEmpty(result)) result = optionGroupDefault; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "GetGroupImage()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + return result; + } + #endregion Methods + + #region [ Event Handlers ] + private void OptionItem_MouseClicked(object sender, RoutedEventArgs e) + { + if (sender is OptionItem getOption) + { + switch (GroupData.SelectMode) + { + case OptionSelectMode.Single: + foreach (var aItem in OptionStack.Children) + { + if (aItem is OptionItem otherOption && !otherOption.Equals(getOption)) + { + otherOption.Switch = false; + otherOption.ItemData.SelectValue = 0d; + } + }; + break; + case OptionSelectMode.Multi: + break; + } + RaiseSelectChangeEvent(GroupData); + } + } + private static void OnHorizontalOffsetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != e.OldValue) + { + var target = d as OptionGroup; + target.MainScroll.ScrollToVerticalOffset((double)e.NewValue); + } + } + + private static void OnGroupDataPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue is M_ItemOptionGroup newValue) + { + var target = d as OptionGroup; + target.SetOptionStack(newValue); + } + } + + + private static void OnDisplayLanguageProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue is SupportLanguageType newValue) + { + var target = d as OptionGroup; + target.OptionGroupName.DisplayLanguage = newValue; + foreach (var aOptoin in target.OptionStack.Children) + { + if (aOptoin is OptionItem optionItem) + { + optionItem.DisplayLanguage = newValue; + } + } + } + } + private void OptionGrid_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + var requstGrid = sender as Grid; + mouseDownXposition = e.GetPosition(sender as Grid).X; + MoseDown = true; + } + + private void OptionGrid_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + MoseDown = false; + } + + private void OptionGrid_PreviewMouseMove(object sender, MouseEventArgs e) + { + if (!MoseDown) return; + var requstGrid = sender as Grid; + var curMouseXposition = e.GetPosition(requstGrid).X; + HorizontalOffset = HorizontalOffset + (mouseDownXposition - curMouseXposition) * 2; + mouseDownXposition = curMouseXposition; + } + + private void OptionGrid_MouseLeave(object sender, MouseEventArgs e) + { + MoseDown = false; + } + + #endregion Event Handlers + + } +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/OptionItem.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/OptionItem.xaml new file mode 100644 index 0000000..1a32570 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/OptionItem.xaml @@ -0,0 +1,64 @@ + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/OptionItem.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/OptionItem.xaml.cs new file mode 100644 index 0000000..caf0515 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/OptionItem.xaml.cs @@ -0,0 +1,285 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; + +namespace SPC.Kiosk.Popup +{ + /// + /// DiscountAndValue.xaml에 대한 상호 작용 논리 + /// + public partial class OptionItem : UserControl + { + #region [ Members ] + /// + /// ItemData + /// + public static readonly DependencyProperty ItemDataProperty = + DependencyProperty.Register(nameof(ItemData), typeof(M_ItemOption), typeof(OptionItem), new PropertyMetadata(null, new PropertyChangedCallback(OnItemDataPropertyChanged))); + /// + /// Display Language + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(OptionItem), new PropertyMetadata(SupportLanguageType.ko, new PropertyChangedCallback(OnDisplayLanguageProperyChanged))); + /// + /// Option Select Mode + /// + public static readonly DependencyProperty OptionModePropery = + DependencyProperty.Register(nameof(OptionMode), typeof(OptionSelectMode), typeof(OptionItem), new PropertyMetadata(OptionSelectMode.None)); + /// + /// Button Switch + /// + public static readonly DependencyProperty SwitchPropery = + DependencyProperty.Register(nameof(Switch), typeof(bool), typeof(OptionItem), new PropertyMetadata(false)); + /// + /// Option Select Mode + /// + public OptionSelectMode OptionMode + { + get { return (OptionSelectMode)GetValue(OptionModePropery); } + set { SetValue(OptionModePropery, value); } + } + /// + /// Button Switch + /// + public bool Switch + { + get { return (bool)GetValue(SwitchPropery); } + set { SetValue(SwitchPropery, value); SelectedChange(value);} + + } + /// + /// ItemData + /// + public M_ItemOption ItemData + { + get { return (M_ItemOption)GetValue(ItemDataProperty); } + set { SetValue(ItemDataProperty, value); } + } + /// + /// Display Language + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + /// + /// Delete Button NormalBrush + /// + #region [ RoutedEvent 'MouseClicked' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent MouseClickedEvent = EventManager.RegisterRoutedEvent(nameof(MouseClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(OptionItem)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler MouseClicked + { + add { AddHandler(MouseClickedEvent, value); } + remove { RemoveHandler(MouseClickedEvent, value); } + } + #endregion RoutedEvent 'MouseClicked' + + #endregion Members + + #region [ Ctor & Etc ] + /// + /// Ctor + /// + public OptionItem() + { + InitializeComponent(); + OptionValueCombo.LeftButtonData = new M_AnimationButton + { + NormalBrush = ResourceManager.GetNximagePathAdd("btn_count_minus_n.png", CommonValue.PBdesignImagesPath), + DownBrush = ResourceManager.GetNximagePathAdd("btn_count_minus_p.png", CommonValue.PBdesignImagesPath), + BrushStretch = Stretch.Fill, + DragEnable = false, + Width = 36, + Height = 36, + Switch = false, + AutoToggle = false, + TextVisible = Visibility.Collapsed, + ClickAnimationType = ButtonAnimationType.None, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty, + }; + OptionValueCombo.RightButtonData = new M_AnimationButton + { + NormalBrush = ResourceManager.GetNximagePathAdd("btn_count_plus_n.png", CommonValue.PBdesignImagesPath), + DownBrush = ResourceManager.GetNximagePathAdd("btn_count_plus_p.png", CommonValue.PBdesignImagesPath), + BrushStretch = Stretch.Fill, + DragEnable = false, + Width = 36, + Height = 36, + Switch = false, + AutoToggle = false, + TextVisible = Visibility.Collapsed, + ClickAnimationType = ButtonAnimationType.None, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty, + }; + OptionValueCombo.SelectChange += OptionValueCombo_SelectChange; + + } + + #endregion Ctor & Etc + + #region [ Methods ] + /// + /// Raise MouseClicked Event + /// + private void RaiseMouseClickedEvent(object _sender) + { + RoutedEventArgs newEventArgs = new RoutedEventArgs(OptionItem.MouseClickedEvent, _sender); + RaiseEvent(newEventArgs); + } + #endregion Methods + + #region [ Event Handlers ] + private void OptionValueCombo_SelectChange(object sender, RoutedEventArgs e) + { + if (sender is NumericCombo numericCombo) + { + ItemData.SelectValue = double.Parse(numericCombo.SelectedValue.ToString()); + if (!ItemData.SelectValue.Equals(0) && ItemData.SelectValue >= ItemData.AmountMin && !ItemData.IsSelected) + { + SelectedChange(true, true); + } + else if (ItemData.SelectValue.Equals(0)) + { + SelectedChange(false, true); + } + } + } + private static void OnItemDataPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue is M_ItemOption newValue) + { + var target = d as OptionItem; + target.OptionButton.NormalBrush = ResourceManager.GetNximagePathAdd("btn_option_n.png", CommonValue.PBdesignImagesPath); + target.OptionButton.SwitchOnBrush = ResourceManager.GetNximagePathAdd("btn_option_s.png", CommonValue.PBdesignImagesPath); + target.OptionButton.DisableBrush = ResourceManager.GetNximagePathAdd("btn_option_s.png", CommonValue.PBdesignImagesPath); + + switch (newValue.Kind) + { + case OptionKind.Button: + target.OptionValueCombo.Visibility = Visibility.Collapsed; + target.OptionAmount.Visibility = Visibility.Collapsed; + break; + case OptionKind.Count: + target.OptionValueCombo.Visibility = Visibility.Visible; + target.OptionAmount.Visibility = Visibility.Collapsed; + target.OptionValueCombo.MinValue = newValue.AmountMin; + target.OptionValueCombo.MaxValue = newValue.AmountMax; + target.OptionValueCombo.ValueStep = int.Parse(newValue.Amount.ToString()); + if (newValue.IsSelected) + { + target.OptionValueCombo.SelectedValue = int.Parse(newValue.SelectValue.ToString()); + } + else + { + target.OptionValueCombo.SelectedValue = newValue.AmountMin; + } + break; + case OptionKind.Discount: + target.OptionValueCombo.Visibility = Visibility.Collapsed; + target.OptionAmount.Visibility = Visibility.Visible; + target.OptionAmount.Text = newValue.Amount.ToString("#,##0"); + break; + case OptionKind.UpCharge: + target.OptionValueCombo.Visibility = Visibility.Collapsed; + target.OptionAmount.Visibility = Visibility.Visible; + target.OptionAmount.Text = newValue.Amount.ToString("#,##0"); + break; + } + target.SelectedChange(newValue.IsSelected); + target.OptionButton.LanguageText = newValue.Name; + } + } + + private static void OnDisplayLanguageProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue is SupportLanguageType newValue) + { + var target = d as OptionItem; + target.OptionButton.DisplayLanguage = newValue; + } + } + private void OptionButton_MouseClicked(object sender, RoutedEventArgs e) + { + if (ItemData is M_ItemOption) + { + switch (ItemData.Kind) + { + case OptionKind.Button: + case OptionKind.Discount: + case OptionKind.UpCharge: + if (ItemData.IsSelected) + { + this.ItemData.SelectValue = 0d; + SelectedChange(false,true); + } + else + { + this.ItemData.SelectValue = ItemData.Amount; + SelectedChange(true,true); + } + break; + case OptionKind.Count: + if (ItemData.IsSelected) + { + this.ItemData.SelectValue = 0d; + OptionValueCombo.SelectedValue = ItemData.AmountMin; + SelectedChange(false,true); + } + else + { + if (OptionValueCombo.SelectedValue > 0) + { + this.ItemData.SelectValue = double.Parse(OptionValueCombo.SelectedValue.ToString()); + SelectedChange(true,true); + } + } + break; + } + } + } + private void SelectedChange(bool _switch, bool _sendEvent = false) + { + switch (OptionMode) + { + case OptionSelectMode.Single: + ItemData.IsSelected = _switch; + this.OptionButton.Enabled = !_switch; + break; + case OptionSelectMode.Multi: + ItemData.IsSelected = _switch; + this.OptionButton.Switch = _switch; + break; + } + if (_sendEvent) RaiseMouseClickedEvent(this); + } + #endregion Event Handlers + + } +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/OptionSelect.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/OptionSelect.xaml new file mode 100644 index 0000000..b913069 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/OptionSelect.xaml @@ -0,0 +1,225 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/OptionSelect.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/OptionSelect.xaml.cs new file mode 100644 index 0000000..e435365 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/OptionSelect.xaml.cs @@ -0,0 +1,162 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Forms; +using System.Drawing; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using System.Windows.Threading; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; + +namespace SPC.Kiosk.Popup +{ + /// + /// OptionSelect.xaml에 대한 상호 작용 논리 + /// + public partial class OptionSelect : Window + { + #region [ Members ] + private int ScreenNo { get; set; } = 0; + private VmOptionSelect ViewModel { get; set; } + + private List GetItemName { get; set; } + private List GetOptions { get; set; } + private string GetItemImage { get; set; } + private int GetItemCount { get; set; } + private double GetItemPrice { get; set; } + private bool GetEditMode { get; set; } + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public OptionSelect(List _getItemName + , List _getOptions + , string _getItemImage + , int _getItemCount + , double _getItemPrice + , bool _editMode) + { + GetItemName = _getItemName; + GetOptions = _getOptions; + GetItemImage = _getItemImage; + GetItemCount = _getItemCount; + GetItemPrice = _getItemPrice; + GetEditMode = _editMode; + InitializeComponent(); + this.ContentRendered += OptionSelect_ContentRendered; + this.Loaded += OptionSelect_Loaded; + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + + } + + #endregion Ctor + + #region [ Methods ] + private void OpenWindow() + { + var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase + , OpenCloseAnimationType.GotoLeft + , this.FrameBase.Width + , 0.5 + , 0.2); + if (OpenAnimations != null) + { + OpenAnimations.Begin(); + } + } + private void CloseWindow() + { + var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase + , OpenCloseAnimationType.GotoRight + , this.FrameBase.Width + , 0.5 + , 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + #endregion Methods + + #region [ Event Handlers ] + private void CloseAnimation_Completed(object sender, EventArgs e) + { + this.ContentRendered -= OptionSelect_ContentRendered; + this.Loaded -= OptionSelect_Loaded; + this.ViewModel.Dispose(); + this.Close(); + } + + private void OptionSelect_ContentRendered(object sender, EventArgs e) + { + this.FrameBase.Width = 1300; + this.FrameBase.Height = 1010; + OpenWindow(); + } + + private void OptionSelect_Loaded(object sender, RoutedEventArgs e) + { + try + { + if (this.DataContext is VmOptionSelect viewModel) + { + ViewModel = viewModel; + ViewModel.PropertyChanged += ViewModel_PropertyChanged; + ViewModel.EditMode = GetEditMode; + ViewModel.ItemName = GetItemName; + ViewModel.Options = GetOptions; + ViewModel.ItemImageBrush = GetItemImage; + ViewModel.ItemCount = GetItemCount; + ViewModel.ItemPrice = GetItemPrice; + ViewModel.IsTimeoutPopup = false; + } + this.FrameBase.Width = 0; + this.FrameBase.Height = 0; + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OptionSelect_Loaded()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + + private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "CanWindowClose": + if (this.ViewModel.CanWindowClose) + { + CloseWindow(); + } + break; + } + } + + + + + + + #endregion Event Handlers + } + + +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/OptionSelector.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/OptionSelector.xaml new file mode 100644 index 0000000..a1e3e52 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/OptionSelector.xaml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/OptionSelector.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/OptionSelector.xaml.cs new file mode 100644 index 0000000..7c99b91 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/OptionSelector.xaml.cs @@ -0,0 +1,241 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; + +namespace SPC.Kiosk.Popup +{ + /// + /// MiniBasketItem.xaml에 대한 상호 작용 논리 + /// + public partial class OptionSelector : UserControl + { + #region [ Members ] + /// + /// ItemData + /// + public static readonly DependencyProperty OptionDataProperty = + DependencyProperty.Register(nameof(OptionData), typeof(List), typeof(OptionSelector), new PropertyMetadata(null, new PropertyChangedCallback(OnOptionDataPropertyChanged))); + + + /// + /// Display Language + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(OptionSelector), new PropertyMetadata(SupportLanguageType.ko, new PropertyChangedCallback(OnDisplayLanguageProperyChanged))); + /// + /// Vertical Scroll Offset + /// + public static readonly DependencyProperty VerticalOffsetProperty = + DependencyProperty.Register(nameof(VerticalOffset), typeof(double), typeof(OptionSelector), new PropertyMetadata(0d, new PropertyChangedCallback(OnVerticalOffsetPropertyChanged))); + /// + /// EditMode + /// + public static readonly DependencyProperty EditModeProperty = + DependencyProperty.Register(nameof(EditMode), typeof(bool), typeof(OptionSelector), new PropertyMetadata(false)); + + + + /// + /// Command + /// + public static readonly DependencyProperty CommandProperty = + DependencyProperty.Register(nameof(Command), typeof(ICommand), typeof(OptionSelector), new UIPropertyMetadata(null)); + + /// + /// Command + /// + public ICommand Command + { + get { return (ICommand)GetValue(CommandProperty); } + set { SetValue(CommandProperty, value); } + } + /// + /// Vertical Scroll Offset + /// + public double VerticalOffset + { + get { return (double)GetValue(VerticalOffsetProperty); } + set { SetValue(VerticalOffsetProperty, value); } + } + + /// + /// ItemData + /// + public List OptionData + { + get { return (List)GetValue(OptionDataProperty); } + set { SetValue(OptionDataProperty, value); } + } + /// + /// Display Language + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + /// + /// Edit Mode + /// + public bool EditMode + { + get { return (bool)GetValue(EditModeProperty); } + set { SetValue(EditModeProperty, value); } + } + #region [ RoutedEvent 'SelectChange' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent SelectChangeEvent = EventManager.RegisterRoutedEvent(nameof(SelectChange), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(OptionSelector)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler SelectChange + { + add { AddHandler(SelectChangeEvent, value); } + remove { RemoveHandler(SelectChangeEvent, value); } + } + #endregion RoutedEvent 'SelectChange' + private double mouseDownYposition = -1; + private bool MoseDown = false; + + #endregion Members + + #region [ Ctor & Etc ] + /// + /// Ctor + /// + public OptionSelector() + { + InitializeComponent(); + OptionGrid.PreviewMouseDown += OptionGrid_PreviewMouseDown; + OptionGrid.PreviewMouseUp += OptionGrid_PreviewMouseUp; + OptionGrid.PreviewMouseMove += OptionGrid_PreviewMouseMove; + OptionGrid.MouseLeave += OptionGrid_MouseLeave; + + } + + #endregion Ctor & Etc + + #region [ Methods ] + /// + /// Raise MouseClicked Event + /// + private void RaiseSelectChangeEvent(object _sender) + { + if (Command != null && Command.CanExecute(_sender)) + { + Command.Execute(_sender); + } + RoutedEventArgs newEventArgs = new RoutedEventArgs(OptionSelector.SelectChangeEvent, _sender); + RaiseEvent(newEventArgs); + } + private void SetOptionStack(List newValue) + { + foreach (var aItem in OptionStack.Children) + { + if (aItem is OptionGroup aOptionGroup) + { + aOptionGroup.SelectChange -= OptionGroup_SelectChange; + } + } + OptionStack.Children.Clear(); + foreach (var aOptionGroup in newValue) + { + var newOptionGroup = new OptionGroup + { + EditMode = this.EditMode, + GroupData = aOptionGroup, + DisplayLanguage = this.DisplayLanguage + }; + newOptionGroup.SelectChange += OptionGroup_SelectChange; + newOptionGroup.Name = string.Format("OptionGroup{0}", aOptionGroup.Index); + this.ReregisterName(newOptionGroup.Name, newOptionGroup); + this.OptionStack.Children.Add(newOptionGroup); + } + } + #endregion Methods + + #region [ Event Handlers ] + private void OptionGroup_SelectChange(object sender, RoutedEventArgs e) + { + RaiseSelectChangeEvent(OptionData); + } + private static void OnVerticalOffsetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != e.OldValue) + { + var target = d as OptionSelector; + target.MainScroll.ScrollToVerticalOffset((double)e.NewValue); + } + } + + private static void OnOptionDataPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue is List newValue) + { + var target = d as OptionSelector; + target.SetOptionStack(newValue); + } + } + + + private static void OnDisplayLanguageProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue is SupportLanguageType newValue) + { + var target = d as OptionSelector; + foreach (var aGroup in target.OptionStack.Children) + { + if (aGroup is OptionGroup optionGroup) + { + optionGroup.DisplayLanguage = newValue; + } + } + } + } + private void OptionGrid_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + var requstGrid = sender as Grid; + mouseDownYposition = e.GetPosition(sender as Grid).Y; + MoseDown = true; + } + + private void OptionGrid_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + MoseDown = false; + } + + private void OptionGrid_PreviewMouseMove(object sender, MouseEventArgs e) + { + if (!MoseDown) return; + var requstGrid = sender as Grid; + var curMouseYposition = e.GetPosition(requstGrid).Y; + VerticalOffset = VerticalOffset + (mouseDownYposition - curMouseYposition) * 2; + mouseDownYposition = curMouseYposition; + } + + private void OptionGrid_MouseLeave(object sender, MouseEventArgs e) + { + MoseDown = false; + } + #endregion Event Handlers + + } +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/PBNumericPad.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/PBNumericPad.xaml new file mode 100644 index 0000000..9d14951 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/PBNumericPad.xaml @@ -0,0 +1,99 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/PBNumericPad.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/PBNumericPad.xaml.cs new file mode 100644 index 0000000..4dda3f5 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/PBNumericPad.xaml.cs @@ -0,0 +1,602 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +namespace SPC.Kiosk.Popup +{ + /// + /// NumericPad.xaml에 대한 상호 작용 논리 + /// + public partial class PBNumericPad : UserControl + { + #region [ Members ] + /// + /// Button Images + /// + public static readonly DependencyProperty ButtonImagesProperty = + DependencyProperty.Register(nameof(ButtonImages), typeof(List), typeof(PBNumericPad), new PropertyMetadata(null, new PropertyChangedCallback(OnButtonImagesPropertyChanged))); + /// + /// Input Text + /// + public static readonly DependencyProperty InputTextProperty = + DependencyProperty.Register(nameof(InputText), typeof(string), typeof(PBNumericPad), new PropertyMetadata(string.Empty, new PropertyChangedCallback(OnInputTextPropertyChanged))); + /// + /// Show Text With Mask + /// + public static readonly DependencyProperty ShowTextProperty = + DependencyProperty.Register(nameof(ShowText), typeof(string), typeof(PBNumericPad), new PropertyMetadata(string.Empty)); + /// + /// Text Area Visible + /// + public static readonly DependencyProperty TextVisibleProperty = + DependencyProperty.Register(nameof(TextVisibility), typeof(Visibility), typeof(PBNumericPad), new PropertyMetadata(Visibility.Visible)); + /// + /// Guid Text (Mutil Language) + /// + public static readonly DependencyProperty GuidTextProperty = + DependencyProperty.Register(nameof(GuidText), typeof(List), typeof(PBNumericPad), new PropertyMetadata(default(List), new PropertyChangedCallback(OnGuidTextPropertyChanged))); + /// + /// Max input Length + /// + public static readonly DependencyProperty MaxLengthPropery = + DependencyProperty.Register(nameof(MaxLength), typeof(int), typeof(PBNumericPad), new PropertyMetadata(0)); + /// + /// Is Formated Show Text + /// + public static readonly DependencyProperty FormatedPropery = + DependencyProperty.Register(nameof(Formated), typeof(bool), typeof(PBNumericPad), new PropertyMetadata(false)); + /// + /// CurrencyFormat Text + /// + public static readonly DependencyProperty CurrencyFormatPropery = + DependencyProperty.Register(nameof(CurrencyFormat), typeof(string), typeof(PBNumericPad), new PropertyMetadata("#,##0")); + /// + /// Display Language Type + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(PBNumericPad), new PropertyMetadata(SupportLanguageType.ko, new PropertyChangedCallback(OnDisplayLanguageProperyChanged))); + /// + /// Is PassWord + /// + public static readonly DependencyProperty IsPassWordPropery = + DependencyProperty.Register(nameof(IsPassWord), typeof(bool), typeof(PBNumericPad), new PropertyMetadata(false)); + + /// + /// CurrencyFormat Text + /// + public string CurrencyFormat + { + get { return (string)GetValue(CurrencyFormatPropery); } + set { SetValue(CurrencyFormatPropery, value); } + } + /// + /// Is PassWord + /// + public bool IsPassWord + { + get { return (bool)GetValue(IsPassWordPropery); } + set { SetValue(IsPassWordPropery, value); } + } + /// + /// Is Formated Show Text + /// + public List ButtonImages + { + get { return (List)GetValue(ButtonImagesProperty); } + set { SetValue(ButtonImagesProperty, value); } + } + /// + /// Is Formated Show Text + /// + public bool Formated + { + get { return (bool)GetValue(FormatedPropery); } + set { SetValue(FormatedPropery, value); } + } + /// + /// Max input Length + /// + public int MaxLength + { + get { return (int)GetValue(MaxLengthPropery); } + set { SetValue(MaxLengthPropery, value); } + } + + /// + /// Text Area Visibility + /// + public Visibility TextVisibility + { + get { return (Visibility)GetValue(TextVisibleProperty); } + set { SetValue(TextVisibleProperty, value); } + } + /// + /// Input Text (Real Data) + /// + public string InputText + { + get { return (string)GetValue(InputTextProperty); } + set { SetValue(InputTextProperty, value); } + } + /// + /// Show Text With Mask + /// + public string ShowText + { + get { return (string)GetValue(ShowTextProperty); } + set { SetValue(ShowTextProperty, value); } + } + /// + /// Guid Text (Multi Language) + /// + public List GuidText + { + get { return (List)GetValue(GuidTextProperty); } + set { SetValue(GuidTextProperty, value); } + } + /// + /// Display Language Type + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + #endregion Members + + #region [ Ctor/Etc ] + /// + /// Ctor + /// + public PBNumericPad() + { + try + { + InitializeComponent(); + + foreach (var aElement in this.BaseGrid.Children) + { + if (aElement is AnimationButton aNumberButton) + { + aNumberButton.MouseClicked += NumberButton_MouseClicked; + } + } + SetImage(); + } + catch + { + } + } + + #endregion Ctor + + #region [ Methods ] + + private void SetShowText(string _showText) + { + string displayText = _showText; + if (!string.IsNullOrEmpty(displayText)) + { + if (displayText.Length < 10) + { + + } + else if (displayText.Length.Equals(10) && Formated) + { + var displayChars = displayText.ToCharArray(); + displayText = string.Empty; + for (int i = 0; i < displayChars.Length; i++) + { + if (i > 2 && i < 6) + { + displayText += '*'; + } + else + { + displayText += displayChars[i]; + } + } + } + else if (displayText.Length.Equals(11) && Formated) + { + var displayChars = displayText.ToCharArray(); + displayText = string.Empty; + for (int i = 0; i < displayChars.Length; i++) + { + if (i > 2 && i < 7) + { + displayText += '*'; + } + else + { + displayText += displayChars[i]; + } + } + } + else if (displayText.Length < 17 && Formated) + { + var displayChars = displayText.ToCharArray(); + displayText = string.Empty; + for (int i = 0; i < displayChars.Length; i++) + { + if (i > 5 && i < 14) + { + displayText += '*'; + } + else + { + displayText += displayChars[i]; + } + } + + } + else if (Formated) + { + var displayChars = displayText.ToCharArray(); + displayText = string.Empty; + for (int i = 0; i < displayChars.Length; i++) + { + if (i > 3 && i < 16) + { + displayText += '*'; + } + else + { + displayText += displayChars[i]; + } + } + } + string formatedString = string.Empty; + if (IsPassWord) + { + formatedString = string.Empty.PadRight(displayText.Length, '*'); + } + else + { + if (Formated) + { + if (displayText.Length.Equals(10)) + { + formatedString = string.Format("{0}-{1}-{2}" + , displayText.Substring(0, 3) + , displayText.Substring(3, 3) + , displayText.Substring(6, 4)); + } + else if (displayText.Length.Equals(11)) + { + formatedString = string.Format("{0}-{1}-{2}" + , displayText.Substring(0, 3) + , displayText.Substring(3, 4) + , displayText.Substring(7, 4)); + } + else if (displayText.Length.Equals(16)) + { + formatedString = string.Format("{0}-{1}-{2}-{3}" + , displayText.Substring(0, 4) + , displayText.Substring(4, 4) + , displayText.Substring(8, 4) + , displayText.Substring(12, 4)); + } + else if (displayText.Length.Equals(20)) + { + formatedString = string.Format("{0}-{1}-{2}-{3}-{4}" + , displayText.Substring(0, 4) + , displayText.Substring(4, 4) + , displayText.Substring(8, 4) + , displayText.Substring(12, 4) + , displayText.Substring(16, 4)); + } + } + else + { + if (string.IsNullOrEmpty(CurrencyFormat)) + { + formatedString = displayText; + } + else + { + formatedString = (double.Parse(displayText)).ToString(CurrencyFormat); + } + } + } + if (!string.IsNullOrEmpty(formatedString)) displayText = formatedString; + this.ShowText = displayText; + } + else + { + this.ShowText = this.GuidText.GetLanguageData(this.DisplayLanguage); + } + } + private double SetEtcTextFontSize(AnimationButton _target, string _text) + { + double result = 20d; + try + { + var textLength = string.IsNullOrEmpty(_text.Trim()) ? 1 : _text.Trim().Length; + var fontSize = 0d; + switch (textLength) + { + case 1: + case 2: + case 3: + case 4: + fontSize = 0.35; + break; + default: + fontSize = 0.3; + break; + } + result = _target.ActualHeight > 0 ? _target.ActualHeight * fontSize : 20d; + + } + catch + { + result = 20d; + } + return result; + } + + private void SetImage(object _buttonImages = null) + { + var getButtonImages = new List(); + if (_buttonImages is List) + { + getButtonImages = _buttonImages as List; + } + else + { + getButtonImages.Add + ( + new M_NumberPadImages + { + ButtonType = NumberPadButton.Button0, + ButtonImage = ResourceManager.GetNximagePathAdd("btn_number_0.png", CommonValue.PBdesignImagesPath) + } + ); + getButtonImages.Add + ( + new M_NumberPadImages + { + ButtonType = NumberPadButton.Button1, + ButtonImage = ResourceManager.GetNximagePathAdd("btn_number_1.png", CommonValue.PBdesignImagesPath) + } + ); + getButtonImages.Add + ( + new M_NumberPadImages + { + ButtonType = NumberPadButton.Button2, + ButtonImage = ResourceManager.GetNximagePathAdd("btn_number_2.png", CommonValue.PBdesignImagesPath) + } + ); + getButtonImages.Add + ( + new M_NumberPadImages + { + ButtonType = NumberPadButton.Button3, + ButtonImage = ResourceManager.GetNximagePathAdd("btn_number_3.png", CommonValue.PBdesignImagesPath) + } + ); + getButtonImages.Add + ( + new M_NumberPadImages + { + ButtonType = NumberPadButton.Button4, + ButtonImage = ResourceManager.GetNximagePathAdd("btn_number_4.png", CommonValue.PBdesignImagesPath) + } + ); + getButtonImages.Add + ( + new M_NumberPadImages + { + ButtonType = NumberPadButton.Button5, + ButtonImage = ResourceManager.GetNximagePathAdd("btn_number_5.png", CommonValue.PBdesignImagesPath) + } + ); + getButtonImages.Add + ( + new M_NumberPadImages + { + ButtonType = NumberPadButton.Button6, + ButtonImage = ResourceManager.GetNximagePathAdd("btn_number_6.png", CommonValue.PBdesignImagesPath) + } + ); + getButtonImages.Add + ( + new M_NumberPadImages + { + ButtonType = NumberPadButton.Button7, + ButtonImage = ResourceManager.GetNximagePathAdd("btn_number_7.png", CommonValue.PBdesignImagesPath) + } + ); + getButtonImages.Add + ( + new M_NumberPadImages + { + ButtonType = NumberPadButton.Button8, + ButtonImage = ResourceManager.GetNximagePathAdd("btn_number_8.png", CommonValue.PBdesignImagesPath) + } + ); + getButtonImages.Add + ( + new M_NumberPadImages + { + ButtonType = NumberPadButton.Button9, + ButtonImage = ResourceManager.GetNximagePathAdd("btn_number_9.png", CommonValue.PBdesignImagesPath) + } + ); + getButtonImages.Add + ( + new M_NumberPadImages + { + ButtonType = NumberPadButton.ButtonCancel, + ButtonImage = ResourceManager.GetNximagePathAdd("btn_number_c.png", CommonValue.PBdesignImagesPath) + } + ); + getButtonImages.Add + ( + new M_NumberPadImages + { + ButtonType = NumberPadButton.ButtonBack, + ButtonImage = ResourceManager.GetNximagePathAdd("btn_number_d.png", CommonValue.PBdesignImagesPath) + } + ); + } + foreach (var aElement in this.BaseGrid.Children) + { + if (aElement is AnimationButton aNumberButton) + { + var getType = NumberPadButton.ButtonNone; + var ButtonTag = string.Empty; + switch (aNumberButton.Name) + { + case nameof(Button0): + getType = NumberPadButton.Button0; + ButtonTag = "0"; + break; + case nameof(Button1): + getType = NumberPadButton.Button1; + ButtonTag = "1"; + break; + case nameof(Button2): + getType = NumberPadButton.Button2; + ButtonTag = "2"; + break; + case nameof(Button3): + getType = NumberPadButton.Button3; + ButtonTag = "3"; + break; + case nameof(Button4): + getType = NumberPadButton.Button4; + ButtonTag = "4"; + break; + case nameof(Button5): + getType = NumberPadButton.Button5; + ButtonTag = "5"; + break; + case nameof(Button6): + getType = NumberPadButton.Button6; + ButtonTag = "6"; + break; + case nameof(Button7): + getType = NumberPadButton.Button7; + ButtonTag = "7"; + break; + case nameof(Button8): + getType = NumberPadButton.Button8; + ButtonTag = "8"; + break; + case nameof(Button9): + getType = NumberPadButton.Button9; + ButtonTag = "9"; + break; + case nameof(ButtonCancel): + getType = NumberPadButton.ButtonCancel; + break; + case nameof(ButtonBack): + getType = NumberPadButton.ButtonBack; + break; + } + aNumberButton.Tag = ButtonTag; + var findButtonImage = getButtonImages.Find(r => r.ButtonType.Equals(getType)); + aNumberButton.Width = this.Width / 3; + aNumberButton.Height = this.Height / 4; + if (findButtonImage is M_NumberPadImages) + { + aNumberButton.NormalBrush = findButtonImage.ButtonImage; + } + + } + } + this.UpdateLayout(); + } + #endregion Methods + + #region [ Event Handlers ] + private static void OnButtonImagesPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null) + { + var target = d as PBNumericPad; + target.SetImage(e.NewValue); + } + } + + private static void OnGuidTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null) + { + var target = d as PBNumericPad; + target.SetShowText(target.InputText); + } + } + + private static void OnDisplayLanguageProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != null ) + { + var target = d as PBNumericPad; + target.SetShowText(target.InputText); + } + } + private static void OnInputTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as PBNumericPad; + var inputText = (string)e.NewValue; + target.SetShowText(inputText); + } + private void NumberButton_MouseClicked(object sender, RoutedEventArgs e) + { + if (sender is AnimationButton aNumberButton) + { + switch (aNumberButton.Name) + { + case nameof(ButtonCancel): + this.InputText = string.Empty; + break; + case nameof(ButtonBack): + if (this.InputText != null && this.InputText.Length > 0) + { + this.InputText = this.InputText.Remove(this.InputText.Length - 1, 1); + } + break; + default: + if (!this.MaxLength.Equals(0) ) + { + if (this.InputText.Length < this.MaxLength) + { + this.InputText = this.InputText + (string)aNumberButton.Tag; + } + } + else + { + if (!(this.InputText.Length.Equals(0) && aNumberButton.Tag.Equals("0"))) + { + this.InputText = this.InputText + (string)aNumberButton.Tag; + } + + } + break; + } + } + } + + #endregion Event Handlers + } + +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/PBStoreAgree.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/PBStoreAgree.xaml new file mode 100644 index 0000000..72820e2 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/PBStoreAgree.xaml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/PBStoreAgree.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/PBStoreAgree.xaml.cs new file mode 100644 index 0000000..496b532 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/PBStoreAgree.xaml.cs @@ -0,0 +1,120 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Globalization; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; + + +namespace SPC.Kiosk.Popup +{ + /// + /// PBStoreAgree.xaml에 대한 상호 작용 논리 + /// + public partial class PBStoreAgree : UserControl + { + public static readonly DependencyProperty StoreDataProperty = + DependencyProperty.Register(nameof(StoreData), typeof(M_StoreAgree), typeof(PBStoreAgree), new PropertyMetadata(null, new PropertyChangedCallback(OnStoreDataPropertyChanged))); + + + public static readonly DependencyProperty SelectedProperty = + DependencyProperty.Register(nameof(Selected), typeof(bool), typeof(PBStoreAgree), new PropertyMetadata(false)); + /// + /// Command + /// + public static readonly DependencyProperty CommandProperty = + DependencyProperty.Register(nameof(Command), typeof(ICommand), typeof(PBStoreAgree), new UIPropertyMetadata(null)); + public bool Selected + { + get { return (bool)GetValue(SelectedProperty); } + set { SetValue(SelectedProperty, value); } + } + + + /// + /// Command + /// + public ICommand Command + { + get { return (ICommand)GetValue(CommandProperty); } + set { SetValue(CommandProperty, value); } + } + /// + /// Store Data + /// + public M_StoreAgree StoreData + { + get { return (M_StoreAgree)GetValue(StoreDataProperty); } + set { SetValue(StoreDataProperty, value); } + } + #region [ Make RoutedEvent 'MouseClicked'] + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent MouseClickedEvent = EventManager.RegisterRoutedEvent(nameof(MouseClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(PBStoreAgree)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler MouseClicked + { + add { AddHandler(MouseClickedEvent, value); } + remove { RemoveHandler(MouseClickedEvent, value); } + } + /// + /// Raise MouseClicked Event + /// + private void RaiseMouseClickedEvent(object _sender) + { + if (Command != null && Command.CanExecute(_sender)) + { + Command.Execute(_sender); + } + RoutedEventArgs newEventArgs = new RoutedEventArgs(PBStoreAgree.MouseClickedEvent, _sender); + RaiseEvent(newEventArgs); + } + #endregion Make RoutedEvent 'MouseClicked' + public PBStoreAgree() + { + InitializeComponent(); + } + private void ResetVisible() + { + this.WelcomInfo.Visibility = this.StoreData.IsFavoriteStore ? Visibility.Visible : Visibility.Collapsed; + this.StoreInfo1.Visibility = this.StoreData.IsFavoriteStore ? Visibility.Collapsed : Visibility.Visible; + this.StoreInfo2.Visibility = this.StoreData.IsFavoriteStore ? Visibility.Collapsed : Visibility.Visible; + this.StoreAgree.Visibility = this.StoreData.IsFavoriteStore ? Visibility.Collapsed : Visibility.Visible; + } + + private static void OnStoreDataPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as PBStoreAgree; + if (e.NewValue is M_StoreAgree storeAgree) + { + target.ResetVisible(); + } + } + + private static void DisplayLanguageProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + } + + private void StoreAgree_MouseClicked(object sender, RoutedEventArgs e) + { + RaiseMouseClickedEvent(this.StoreData); + } + } +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/PaymentProcess.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/PaymentProcess.xaml new file mode 100644 index 0000000..b252d7d --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/PaymentProcess.xaml @@ -0,0 +1,325 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/PaymentProcess.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/PaymentProcess.xaml.cs new file mode 100644 index 0000000..2a8930b --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/PaymentProcess.xaml.cs @@ -0,0 +1,221 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Forms; +using System.Drawing; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using System.Windows.Threading; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; +using System.Windows.Media.Animation; +using System.Threading.Tasks; + +namespace SPC.Kiosk.Popup +{ + /// + /// CallEmployee.xaml에 대한 상호 작용 논리 + /// + public partial class PaymentProcess : Window + { + #region [ Members ] + private int ScreenNo { get; set; } = 0; + private VmPaymentProcess ViewModel { get; set; } + private double GetPayments { get; set; } + private LastPaymentsType GetPaymentType { get; set; } + private bool FirstLoaded = true; + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public PaymentProcess(LastPaymentsType _getPaymentType, double _totalPayment ) + { + GetPaymentType = _getPaymentType; + GetPayments = _totalPayment; + InitializeComponent(); + this.ContentRendered += PaymentProcess_ContentRendered; + this.Loaded += PaymentProcess_Loaded; + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + + } + + #endregion Ctor + + #region [ Methods ] + private void OpenWindow() + { + var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeUp + , this.FrameBase.Height + , 0.5 + , 0.2); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Begin(); + } + } + private void ChangeWindow() + { + this.Dispatcher.Invoke((Action)(() => + { + try + { + var _target = this.FrameData; + var targetAnimation = new Storyboard(); + var centerX = _target.ActualWidth / 2; + var centerY = _target.ActualHeight / 2; + _target.RenderTransform = new ScaleTransform(1, 1, centerX, centerY); + var flipXAni = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.2))); + Storyboard.SetTarget(flipXAni, _target); + Storyboard.SetTargetProperty(flipXAni, new PropertyPath("RenderTransform.ScaleX")); + targetAnimation.Children.Add(flipXAni); + targetAnimation.Completed += TargetAnimation_Completed; + targetAnimation.Begin(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ChangeWindow()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + })); + } + private void TargetAnimation_Completed(object sender, EventArgs e) + { + if (this.ViewModel.PaymentWindow.Equals(PaymentWindowType.PaymentStart)) + { + this.BarCode.IsEnabled = true; + this.BarCode.Focus(); + } + else + { + this.BarCode.IsEnabled = false; + } + } + private void CloseWindow() + { + var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeDown + , this.FrameBase.Height + , 0.5 + , 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + #endregion Methods + + #region [ Event Handlers ] + private void OpenAnimations_Completed(object sender, EventArgs e) + { + this.ViewModel.PaymentWindow = PaymentWindowType.PaymentStart; + this.BarCode.IsEnabled = true; + this.BarCode.Focus(); + + + } + private void CloseAnimation_Completed(object sender, EventArgs e) + { + this.ContentRendered -= PaymentProcess_ContentRendered; + this.Loaded -= PaymentProcess_Loaded; + this.BarCode.PreviewKeyDown -= BarCode_PreviewKeyDown; + this.BarCode.LostFocus -= BarCode_LostFocus; + this.ViewModel.Dispose(); + this.Close(); + } + private void PaymentProcess_ContentRendered(object sender, EventArgs e) + { + this.FrameBase.Width = 1300; + this.FrameBase.Height = 1010; + OpenWindow(); + } + + private void PaymentProcess_Loaded(object sender, RoutedEventArgs e) + { + if (this.DataContext is VmPaymentProcess viewModel) + { + this.ViewModel = viewModel; + this.ViewModel.PropertyChanged += ViewModel_PropertyChanged; + this.ViewModel.PaymentType = GetPaymentType; + this.ViewModel.Payments = GetPayments; + this.ViewModel.IsTimeoutPopup = false; + } + this.BarCode.PreviewKeyDown += BarCode_PreviewKeyDown; + this.BarCode.LostFocus += BarCode_LostFocus; + this.FrameBase.Width = 0; + this.FrameBase.Height = 0; + + } + private void BarCode_LostFocus(object sender, RoutedEventArgs e) + { + this.BarCode.Focus(); + } + + private void BarCode_PreviewKeyDown(object sender, System.Windows.Input.KeyEventArgs e) + { + if (sender is System.Windows.Controls.TextBox textBox + && (e.Key.Equals(Key.Enter) || e.Key.Equals(Key.Return)) + && !string.IsNullOrEmpty(textBox.Text)) + { + this.ViewModel.ReadBarCode = textBox.Text.Trim(); + textBox.Text = string.Empty; + } + } + private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "CanWindowClose": + if (this.ViewModel.CanWindowClose) + { + if (this.ViewModel.ImmediatelyClose) + { + CloseAnimation_Completed(null, null); + } + else + { + CloseWindow(); + } + } + break; + case "PaymentWindow": + if (!FirstLoaded) + { + ChangeWindow(); + } + else + { + FirstLoaded = false; + } + break; + } + } + + + + + + + + #endregion Event Handlers + } + + +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/PaymentsEnd.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/PaymentsEnd.xaml new file mode 100644 index 0000000..e989952 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/PaymentsEnd.xaml @@ -0,0 +1,1155 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/PaymentsEnd.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/PaymentsEnd.xaml.cs new file mode 100644 index 0000000..ce4596a --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/PaymentsEnd.xaml.cs @@ -0,0 +1,192 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Forms; +using System.Drawing; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using System.Windows.Threading; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; +using System.Windows.Media.Animation; + +namespace SPC.Kiosk.Popup +{ + /// + /// PaymentsEnd.xaml에 대한 상호 작용 논리 + /// + public partial class PaymentsEnd : Window + { + #region [ Members ] + private int ScreenNo { get; set; } = 0; + private VmPaymentsEnd ViewModel { get; set; } + /// + /// HappyPoint 인증 및 사용 정보 + /// + private PaymentEndWindowEndType GetPaymentEndWindow { get; set; } + private List GetBasketItems { get; set; } + private bool GetHappyPointReseve { get; set; } + private bool GetOkCashBagReseve { get; set; } + private M_HappyPointReturn GetHappyPointReturn { get; set; } + + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + /// + /// + public PaymentsEnd(PaymentEndWindowEndType _paymentEndWindow + , List _getBasketItems + , bool _happyPointReserve + , bool _okCashBagReserve + , M_HappyPointReturn _getHappyPointReturn = null) + { + GetPaymentEndWindow = _paymentEndWindow; + GetBasketItems = _getBasketItems; + GetHappyPointReseve = _happyPointReserve; + GetOkCashBagReseve = _okCashBagReserve; + GetHappyPointReturn = _getHappyPointReturn; + InitializeComponent(); + this.ContentRendered += PaymentsEnd_ContentRendered; + this.Loaded += PaymentsEnd_Loaded; + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + } + + #endregion Ctor + + #region [ Methods ] + private void OpenWindow() + { + var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeUp + , this.FrameBase.Height + , 0.5 + , 0.2); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Begin(); + } + } + private void CloseWindow() + { + var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeDown + , this.FrameBase.Height + , 0.5 + , 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + private void ChangeWindow() + { + try + { + var _target = this.FrameData; + var targetAnimation = new Storyboard(); + var centerX = _target.ActualWidth / 2; + var centerY = _target.ActualHeight / 2; + _target.RenderTransform = new ScaleTransform(1, 1, centerX, centerY); + var flipXAni = new DoubleAnimation(0, 1, new Duration(TimeSpan.FromSeconds(0.2))); + Storyboard.SetTarget(flipXAni, _target); + Storyboard.SetTargetProperty(flipXAni, new PropertyPath("RenderTransform.ScaleX")); + targetAnimation.Children.Add(flipXAni); + targetAnimation.Completed += TargetAnimation_Completed; + targetAnimation.Begin(); + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "ChangeWindow()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + private void TargetAnimation_Completed(object sender, EventArgs e) + { + } + #endregion Methods + + #region [ Event Handlers ] + private void OpenAnimations_Completed(object sender, EventArgs e) + { + } + private void CloseAnimation_Completed(object sender, EventArgs e) + { + this.ContentRendered -= PaymentsEnd_ContentRendered; + this.Loaded -= PaymentsEnd_Loaded; + this.ViewModel.Dispose(); + this.Close(); + } + private void PaymentsEnd_ContentRendered(object sender, EventArgs e) + { + this.FrameBase.Width = 1300; + this.FrameBase.Height = 1010; + OpenWindow(); + + } + private void PaymentsEnd_Loaded(object sender, RoutedEventArgs e) + { + if (this.DataContext is VmPaymentsEnd viewModel) + { + this.ViewModel = viewModel; + this.ViewModel.PropertyChanged += ViewModel_PropertyChanged; + this.ViewModel.EndWindow = GetPaymentEndWindow; + this.ViewModel.BasketData = GetBasketItems; + this.ViewModel.HappyPointReturn = GetHappyPointReturn; + this.ViewModel.HappyPointReserve = GetHappyPointReseve; + this.ViewModel.OkCashBagReserve = GetOkCashBagReseve; + this.ViewModel.PopupWidth = this.FrameBase.Width; + this.ViewModel.PaymentEndWindow = PaymentEndWindowType.CashReceipt; + this.ViewModel.IsTimeoutPopup = false; + } + this.FrameBase.Width = 0; + this.FrameBase.Height = 0; + } + + + private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "CanWindowClose": + if (this.ViewModel.CanWindowClose) + { + if (this.ViewModel.ImmediatelyClose) + { + CloseAnimation_Completed(null, null); + } + else + { + CloseWindow(); + } + } + break; + case "PointUsingWindow": + ChangeWindow(); + break; + + } + } + + #endregion Event Handlers + } + +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/PopupManager.cs b/Kiosk/Popup/SPC.Kiosk.Popup/PopupManager.cs new file mode 100644 index 0000000..53bfcbf --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/PopupManager.cs @@ -0,0 +1,429 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Input; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; +namespace SPC.Kiosk.Popup +{ + /// + /// Popup Manager + /// + public sealed class PopupManager + { + private static PopupManager instance = null; + private static readonly object padlock = new object(); + /// + /// This Class Instance + /// + public static PopupManager GetInstance + { + get + { + lock (padlock) + { + if (instance == null) + { + instance = new PopupManager(); + } + return instance; + } + } + } + public void OpenPaymentsEnd(PaymentEndWindowEndType _paymentEndWindow + , List _getBasketItems + , bool _happyPointReserve + , bool _okCashBagReserve + , M_HappyPointReturn _happyPointReturn=null) + { + try + { + var PaymentsEndWin = new PaymentsEnd(_paymentEndWindow + , _getBasketItems + , _happyPointReserve + , _okCashBagReserve + , _happyPointReturn); + PaymentsEndWin.ShowDialog(); + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenPaymentsEnd", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + } + } + /// + /// 번호 입력창 + /// + /// + /// + /// + /// + /// + /// + /// + public M_PopupReturn OpenNumPadPopup(SupportLanguageType _languageType + , List _guideText + , bool _formated = false + , bool _isPassword = true + , int _maxLength = 4 + , int _checkLength = 4) + { + M_PopupReturn result = null; + try + { + var NumPadPopupWin = new NumPadPopup(_languageType + , _guideText + , _formated + , _isPassword + , _maxLength + , _checkLength); + NumPadPopupWin.ShowDialog(); + if (NumPadPopupWin.DataContext is VmNumPadPopup viewModel) + { + result = viewModel.ReturnValue; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenNumPadPopup", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + + } + return result; + } + public M_PopupReturn OpenStepInfoPopup() + { + M_PopupReturn result = null; + try + { + var StepInfoPopupWin = new StepInfoPopup(); + StepInfoPopupWin.ShowDialog(); + if (StepInfoPopupWin.DataContext is VmStepInfoPopup viewModel) + { + result = viewModel.ReturnValue; + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenStepInfoPopup", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + + } + return result; + } + /// + /// Open MiniPopup + /// + /// + /// + public M_PopupReturn OpenMiniPopup(M_MiniPopup _miniPopup) + { + M_PopupReturn result = null; + try + { + if (_miniPopup is M_MiniPopup) + { + var MiniPopupWin = new MiniPopup(_miniPopup); + MiniPopupWin.ShowDialog(); + if (MiniPopupWin.DataContext is VmMiniPopup viewModel) + { + result = viewModel.ReturnValue; + } + //MiniPopupWin.DataContext = null; + //MiniPopupWin.Content = null; + //MiniPopupWin = null; + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenMiniPopup", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + + } + return result; + } + /// + /// Option Select + /// + /// + /// + /// + /// + public M_PopupReturn OpenOptionSelect(List _getItemName + , List _getOptions + , string _getItemImage + , int _getItemCount + , double _getItemPrice + , bool _editMode = false) + { + M_PopupReturn result = null; + try + { + var OptionSelectWin = new OptionSelect(_getItemName + , _getOptions + , _getItemImage + , _getItemCount + , _getItemPrice + , _editMode); + OptionSelectWin.ShowDialog(); + if (OptionSelectWin.DataContext is VmOptionSelect viewModel) + { + result = viewModel.ReturnValue; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenOptionSelect", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + /// + /// Last Payment + /// + /// + public M_PopupReturn OpenPaymentProcess(LastPaymentsType _paymentType, double _totalPayment ) + { + M_PopupReturn result = null; + try + { + var PaymentProcessWin = new PaymentProcess(_paymentType, _totalPayment); + PaymentProcessWin.ShowDialog(); + if (PaymentProcessWin.DataContext is VmPaymentProcess viewModel) + { + result = viewModel.ReturnValue; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenPaymentProcess", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + /// + /// Language Select + /// + /// + public M_PopupReturn OpenLanguageSelector(SupportLanguageType _supportLanguageType) + { + M_PopupReturn result = null; + try + { + var LanguageSelectorWin = new LanguageSelector(_supportLanguageType); + LanguageSelectorWin.ShowDialog(); + if (LanguageSelectorWin.DataContext is VmLanguageSelector viewModel) + { + result = viewModel.ReturnValue; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenLanguageSelector()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + + } + return result; + } + /// + /// Call Employee + /// + /// + public M_PopupReturn OpenCallEmployee() + { + M_PopupReturn result = null; + try + { + var CallEmployeeWin = new CallEmployee(); + CallEmployeeWin.ShowDialog(); + if (CallEmployeeWin.DataContext is VmCallEmployee viewModel) + { + result = viewModel.ReturnValue; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenCallEmployee", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + /// + /// HappyPoint Certify + /// + /// + public M_PopupReturn OpenHappyPointCertify(bool _showLanguageButton=true, bool _showMemberHistoryItems = true, ParentPage _popupParentPage = ParentPage.EmptyPage) + { + M_PopupReturn result = null; + try + { + var HappyPointCertifyWin = new HappyPointCertify(_showLanguageButton, _showMemberHistoryItems, _popupParentPage); + HappyPointCertifyWin.ShowDialog(); + if (HappyPointCertifyWin.DataContext is VmHappyPointCertify viewModel) + { + result = new M_PopupReturn + { + OKAnswer = viewModel.ReturnValue.OKAnswer, + TimeOut = viewModel.ReturnValue.TimeOut, + ReturnLanguage = viewModel.ReturnValue.ReturnLanguage, + PopupArgs = viewModel.ReturnValue.PopupArgs + }; + } + + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenHappyPointCertify", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + /// + /// HappyPoint Using + /// + /// 이전 인증 결과 + /// 결제 대상 금액 + /// + public M_PopupReturn OpenHappyPointUsing(M_HappyPointReturn _happyPointReturn, double _totalPayment = 0) + { + M_PopupReturn result = null; + try + { + var HappyPointUsingWin = new HappyPointUsing(_happyPointReturn, _totalPayment); + HappyPointUsingWin.ShowDialog(); + if (HappyPointUsingWin.DataContext is VmHappyPointUsing viewModel) + { + result = viewModel.ReturnValue; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenHappyPointUsing", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + + public M_PopupReturn OpenHappyAppCoupon(M_HappyPointReturn _happyPointReturn, double _totalPayment = 0) + { + M_PopupReturn result = null; + try + { + var HappyAppCouponWin = new HappyPointCoupon(_happyPointReturn, _totalPayment); + HappyAppCouponWin.ShowDialog(); + if (HappyAppCouponWin.DataContext is VmHappyPointCoupon viewModel) + { + result = viewModel.ReturnValue; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenHappyAppCoupon", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + + public M_PopupReturn OpenMobileHappyCoupon(List _getBasketItems , double _totalPayment = 0) + { + M_PopupReturn result = null; + try + { + var MobileHappyCouponWin = new MobileHappyCoupon(_getBasketItems, _totalPayment); + MobileHappyCouponWin.ShowDialog(); + if (MobileHappyCouponWin.DataContext is VmMobileHappyCoupon viewModel) + { + result = viewModel.ReturnValue; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenMobileHappyCoupon()", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + /// + /// OK CashBag Certify + /// + /// 결제 대상 금액 + /// 적립 가능 유무 + /// + public M_PopupReturn OpenOkCashBagCertify() + { + M_PopupReturn result = null; + try + { + var OkCashBagCertifyWin = new OkCashBagCertify(); + OkCashBagCertifyWin.ShowDialog(); + if (OkCashBagCertifyWin.DataContext is VmOkCashBagCertify viewModel) + { + result = viewModel.ReturnValue; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenOkCashBagCertify", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + + /// + /// OK CashBag Using + /// + /// 결제 대상 금액 + /// 적립 가능 유무 + /// + public M_PopupReturn OpenOkCashBagUsing(double _totalPayment=0, bool _reserveEnabled = true) + { + M_PopupReturn result = null; + try + { + var OkCashBagUsingWin = new OkCashBagUsing(_totalPayment, _reserveEnabled); + OkCashBagUsingWin.ShowDialog(); + if (OkCashBagUsingWin.DataContext is VmOkCashBagUsing viewModel) + { + result = viewModel.ReturnValue; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenOkCashBagUsing", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + /// + /// MobileCompany Certify && Discount + /// + /// 대상 통신사 + /// 경제 대상 금액 + /// + public M_PopupReturn OpenMobileCompanyCertify(MobileCompanyType _mobileCompany, double _totalPayment = 0) + { + M_PopupReturn result = null; + try + { + var MobileCompanyMemberCertifyWin = new MobileCompanyMemberCertify(_mobileCompany, _totalPayment); + MobileCompanyMemberCertifyWin.ShowDialog(); + if (MobileCompanyMemberCertifyWin.DataContext is VmMobileCompanyMemberCertify viewModel) + { + result = viewModel.ReturnValue; + } + } + catch (Exception ex) + { + CommonLog.ErrorLogWrite(this, "OpenMobileCompanyCertify", "Fail", string.Format("{0}\n{1}", ex.Message, ex.StackTrace)); + result = null; + } + return result; + } + + } +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/Properties/AssemblyInfo.cs b/Kiosk/Popup/SPC.Kiosk.Popup/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..81c5e24 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("SPC.Kiosk.Popup")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Zin Inc.")] +[assembly: AssemblyProduct("SPC.Kiosk.Popup")] +[assembly: AssemblyCopyright("Copyright © Zin Inc. 2019")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("7c64409c-24e1-4d9e-a686-b13061f1c61b")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 +// 기본값으로 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/SPC.Kiosk.Popup.csproj b/Kiosk/Popup/SPC.Kiosk.Popup/SPC.Kiosk.Popup.csproj new file mode 100644 index 0000000..782d9ac --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/SPC.Kiosk.Popup.csproj @@ -0,0 +1,249 @@ + + + + + Debug + AnyCPU + {7C64409C-24E1-4D9E-A686-B13061F1C61B} + Library + Properties + SPC.Kiosk.Popup + SPC.Kiosk.Popup + v4.0 + 512 + true + + + true + full + false + ..\..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + + + + HappyPointCoupon.xaml + + + StepInfoPopup.xaml + + + MobileHappyCoupon.xaml + + + NumPadPopup.xaml + + + MiniPopup.xaml + + + HappyAppCoupon.xaml + + + HappyAppCoupons.xaml + + + VirtureMobileHappyCoupons.xaml + + + VirtureMobileHappyCoupon.xaml + + + PaymentsEnd.xaml + + + PBNumericPad.xaml + + + OptionSelector.xaml + + + OptionGroup.xaml + + + OptionItem.xaml + + + OptionSelect.xaml + + + OkCashBagCertify.xaml + + + PaymentProcess.xaml + + + CallEmployee.xaml + + + HappyPointUsing.xaml + + + LanguageSelector.xaml + + + MobileCompanyMemberCertify.xaml + + + OkCashBagUsing.xaml + + + HappyPointCertify.xaml + + + PBStoreAgree.xaml + + + + + + + {bcc10fa2-c358-480c-8ff0-615750f3c306} + SPC.Kiosk.Base + + + {ba2d06e0-74c0-4785-b39f-d1eaac13b73d} + SPC.Kiosk.Common + + + {fee44681-7f0e-469a-a833-dc324eb6d01a} + SPC.Kiosk.DataHelper + + + {be7fc15c-325b-4ad4-8ea0-a8244193e431} + SPC.Kiosk.Popup.Model + + + {9ef1fec9-5f0a-4a4e-8723-e93f30798fd2} + SPC.Kiosk.Popup.ViewModel + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + XamlIntelliSenseFileGenerator + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + + + \ No newline at end of file diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/StepInfoPopup.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/StepInfoPopup.xaml new file mode 100644 index 0000000..56340c0 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/StepInfoPopup.xaml @@ -0,0 +1,135 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/StepInfoPopup.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/StepInfoPopup.xaml.cs new file mode 100644 index 0000000..1b9f19f --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/StepInfoPopup.xaml.cs @@ -0,0 +1,134 @@ +using System; +using System.ComponentModel; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Forms; +using System.Drawing; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using System.Windows.Threading; +using SPC.Kiosk.Popup.Model; +using SPC.Kiosk.Popup.ViewModel; + +namespace SPC.Kiosk.Popup +{ + /// + /// StepInfoPopup.xaml에 대한 상호 작용 논리 + /// + public partial class StepInfoPopup : Window + { + #region [ Members ] + private int ScreenNo { get; set; } = 0; + private VmStepInfoPopup ViewModel { get; set; } + + + #endregion Members + + #region [ Ctor ] + /// + /// Ctor + /// + public StepInfoPopup() + { + InitializeComponent(); + this.ContentRendered += StepInfoPopup_ContentRendered; + this.Loaded += StepInfoPopup_Loaded; + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = Screen.AllScreens[ScreenNo].Bounds.Width; + this.Height = Screen.AllScreens[ScreenNo].Bounds.Height; + + } + + #endregion Ctor + + #region [ Methods ] + private void OpenWindow() + { + var OpenAnimations = Animations.GetOpenAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeUp + , this.FrameBase.Height + , 0.5 + , 0.2); + if (OpenAnimations != null) + { + OpenAnimations.Begin(); + } + } + private void CloseWindow() + { + var CloseAnimation = Animations.GetCloseAnimation(this.FrameBase + , OpenCloseAnimationType.FullSizeDown + , this.FrameBase.Height + , 0.5 + , 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + #endregion Methods + + #region [ Event Handlers ] + private void CloseAnimation_Completed(object sender, EventArgs e) + { + + this.ContentRendered -= StepInfoPopup_ContentRendered; + this.Loaded -= StepInfoPopup_Loaded; + this.ViewModel.Dispose(); + this.Close(); + } + + private void StepInfoPopup_ContentRendered(object sender, EventArgs e) + { + this.FrameBase.Width = 800; + this.FrameBase.Height = 540; + OpenWindow(); + } + + private void StepInfoPopup_Loaded(object sender, RoutedEventArgs e) + { + if (this.DataContext is VmStepInfoPopup viewModel) + { + ViewModel = viewModel; + ViewModel.PropertyChanged += ViewModel_PropertyChanged; + ViewModel.IsTimeoutPopup = false; + } + this.FrameBase.Width = 0; + this.FrameBase.Height = 0; + } + + private void ViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "CanWindowClose": + if (this.ViewModel.CanWindowClose) + { + CloseWindow(); + } + break; + } + } + + + + + + + #endregion Event Handlers + } + + +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/VirtureMobileHappyCoupon.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/VirtureMobileHappyCoupon.xaml new file mode 100644 index 0000000..bd73acd --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/VirtureMobileHappyCoupon.xaml @@ -0,0 +1,68 @@ + + + + + + + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/VirtureMobileHappyCoupon.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/VirtureMobileHappyCoupon.xaml.cs new file mode 100644 index 0000000..061a820 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/VirtureMobileHappyCoupon.xaml.cs @@ -0,0 +1,211 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +namespace SPC.Kiosk.Popup +{ + /// + /// DiscountAndValue.xaml에 대한 상호 작용 논리 + /// + public partial class VirtureMobileHappyCoupon : UserControl + { + #region [ Members ] + /// + /// ItemData + /// + public static readonly DependencyProperty ItemDataProperty = + DependencyProperty.Register(nameof(ItemData), typeof(M_MobileCouponDetail), typeof(VirtureMobileHappyCoupon), new PropertyMetadata(new M_MobileCouponDetail(), new PropertyChangedCallback(OnItemDataPropertyChanged))); + /// + /// Display Language + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(VirtureMobileHappyCoupon), new PropertyMetadata(SupportLanguageType.ko)); + /// + /// Button Switch + /// + public static readonly DependencyProperty SwitchPropery = + DependencyProperty.Register(nameof(Switch), typeof(bool), typeof(VirtureMobileHappyCoupon), new PropertyMetadata(false, new PropertyChangedCallback(OnSwitchProperyChanged))); + public static readonly DependencyProperty EnabledPropery = + DependencyProperty.Register(nameof(Enabled), typeof(bool), typeof(VirtureMobileHappyCoupon), new PropertyMetadata(true, new PropertyChangedCallback(OnEnabledProperyChanged))); + + + + /// + /// Button Switch + /// + public bool Switch + { + get { return (bool)GetValue(SwitchPropery); } + set { SetValue(SwitchPropery, value);} + + } + /// + /// Button Enabled + /// + public bool Enabled + { + get { return (bool)GetValue(EnabledPropery); } + set { SetValue(EnabledPropery, value); } + + } + /// + /// ItemData + /// + public M_MobileCouponDetail ItemData + { + get { return (M_MobileCouponDetail)GetValue(ItemDataProperty); } + set { SetValue(ItemDataProperty, value); } + } + /// + /// Display Language + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + /// + /// Button NormalBrush + /// + public string ButtonNormalBrush { get; set; } + public string ButtonDownBrush { get; set; } + public string ButtonSwitchOnBrush { get; set; } + public string ButtonDisableBrush { get; set; } + + #region [ RoutedEvent 'MouseClicked' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent MouseClickedEvent = EventManager.RegisterRoutedEvent(nameof(MouseClicked), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(VirtureMobileHappyCoupon)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler MouseClicked + { + add { AddHandler(MouseClickedEvent, value); } + remove { RemoveHandler(MouseClickedEvent, value); } + } + #endregion RoutedEvent 'MouseClicked' + + #endregion Members + + #region [ Ctor & Etc ] + /// + /// Ctor + /// + public VirtureMobileHappyCoupon() + { + ButtonNormalBrush = ResourceManager.GetNximagePathAdd("btn_coupon_n.png", CommonValue.PBdesignImagesPath); + ButtonDownBrush = ResourceManager.GetNximagePathAdd("btn_coupon_p.png", CommonValue.PBdesignImagesPath); + ButtonSwitchOnBrush = ResourceManager.GetNximagePathAdd("btn_coupon_s.png", CommonValue.PBdesignImagesPath); + ButtonDisableBrush = ResourceManager.GetNximagePathAdd("btn_coupon_d.png", CommonValue.PBdesignImagesPath); + InitializeComponent(); + } + + #endregion Ctor & Etc + + #region [ Methods ] + /// + /// Raise MouseClicked Event + /// + private void RaiseMouseClickedEvent(object _sender) + { + RoutedEventArgs newEventArgs = new RoutedEventArgs(VirtureMobileHappyCoupon.MouseClickedEvent, _sender); + RaiseEvent(newEventArgs); + } + #endregion Methods + + #region [ Event Handlers ] + private static void OnSwitchProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as VirtureMobileHappyCoupon; + target.OptionButton.Switch = (bool)e.NewValue; + } + private static void OnEnabledProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as VirtureMobileHappyCoupon; + target.OptionButton.Enabled = (bool)e.NewValue; + } + + private static void OnItemDataPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + var target = d as VirtureMobileHappyCoupon; + if (e.OldValue is M_MobileCouponDetail oldValue) + { + oldValue.PropertyChanged -= target.ItemData_PropertyChanged; + } + if (e.NewValue is M_MobileCouponDetail newValue) + { + newValue.PropertyChanged += target.ItemData_PropertyChanged; + if (newValue.Status.Equals(MobileCouponStatusType.CanUse)) + { + switch (newValue.Type) + { + case MobileCouponType.NormalValue: + target.RemainAmount.Text = string.Format("잔액:{0}", newValue.CanUsingPrice.ToString("#,##0")); + break; + case MobileCouponType.ValueFixed: + target.RemainAmount.Text = string.Format("1회:{0}", newValue.CanUsingPrice.ToString("#,##0")); + break; + case MobileCouponType.ValueLimit: + target.RemainAmount.Text = string.Format("최대:{0}", newValue.CanUsingPrice.ToString("#,##0")); + break; + } + target.Enabled = true; + target.UsingValue.Visibility = newValue.DiscountPrice.Equals(0) + ? Visibility.Collapsed + : Visibility.Visible; + + } + else + { + target.Enabled = false; + target.UsingValue.Visibility = Visibility.Collapsed; + } + } + } + + private void ItemData_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "DiscountPrice": + if (this.ItemData.Status.Equals(MobileCouponStatusType.CanUse)) + { + this.UsingValue.Visibility = this.ItemData.DiscountPrice.Equals(0) + ? Visibility.Collapsed + : Visibility.Visible; + this.Switch = this.ItemData.DiscountPrice > 0; + } + else + { + this.UsingValue.Visibility = Visibility.Collapsed; + } + break; + } + } + + private void OptionButton_MouseClicked(object sender, RoutedEventArgs e) + { + RaiseMouseClickedEvent(this.ItemData); + } + #endregion Event Handlers + + } +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/VirtureMobileHappyCoupons.xaml b/Kiosk/Popup/SPC.Kiosk.Popup/VirtureMobileHappyCoupons.xaml new file mode 100644 index 0000000..9ea3468 --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/VirtureMobileHappyCoupons.xaml @@ -0,0 +1,18 @@ + + + + + + + + diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/VirtureMobileHappyCoupons.xaml.cs b/Kiosk/Popup/SPC.Kiosk.Popup/VirtureMobileHappyCoupons.xaml.cs new file mode 100644 index 0000000..fe2d35a --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/VirtureMobileHappyCoupons.xaml.cs @@ -0,0 +1,284 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.ComponentModel; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using SPC.Kiosk.Base; +using SPC.Kiosk.Common; +using SPC.Kiosk.Popup.Model; +namespace SPC.Kiosk.Popup +{ + /// + /// MiniBasketItem.xaml에 대한 상호 작용 논리 + /// + public partial class VirtureMobileHappyCoupons : UserControl + { + #region [ Members ] + /// + /// ItemData + /// + public static readonly DependencyProperty CouponDataProperty = + DependencyProperty.Register(nameof(CouponData), typeof(M_MobileCouponReturn), typeof(VirtureMobileHappyCoupons), new PropertyMetadata(null, new PropertyChangedCallback(OnCouponDataPropertyChanged))); + + + /// + /// Display Language + /// + public static readonly DependencyProperty DisplayLanguagePropery = + DependencyProperty.Register(nameof(DisplayLanguage), typeof(SupportLanguageType), typeof(VirtureMobileHappyCoupons), new PropertyMetadata(SupportLanguageType.ko, new PropertyChangedCallback(OnDisplayLanguageProperyChanged))); + /// + /// Vertical Scroll Offset + /// + public static readonly DependencyProperty VerticalOffsetProperty = + DependencyProperty.Register(nameof(VerticalOffset), typeof(double), typeof(VirtureMobileHappyCoupons), new PropertyMetadata(0d, new PropertyChangedCallback(OnVerticalOffsetPropertyChanged))); + + /// + /// Command + /// + public static readonly DependencyProperty CommandProperty = + DependencyProperty.Register(nameof(Command), typeof(ICommand), typeof(VirtureMobileHappyCoupons), new UIPropertyMetadata(null)); + + /// + /// Command + /// + public ICommand Command + { + get { return (ICommand)GetValue(CommandProperty); } + set { SetValue(CommandProperty, value); } + } + /// + /// Vertical Scroll Offset + /// + public double VerticalOffset + { + get { return (double)GetValue(VerticalOffsetProperty); } + set { SetValue(VerticalOffsetProperty, value); } + } + + /// + /// ItemData + /// + public M_MobileCouponReturn CouponData + { + get { return (M_MobileCouponReturn)GetValue(CouponDataProperty); } + set { SetValue(CouponDataProperty, value); } + } + /// + /// Display Language + /// + public SupportLanguageType DisplayLanguage + { + get { return (SupportLanguageType)GetValue(DisplayLanguagePropery); } + set { SetValue(DisplayLanguagePropery, value); } + } + #region [ RoutedEvent 'CouponSelect' ] + + /// + /// MouseClicked Event + /// + public static readonly RoutedEvent CouponSelectEvent = EventManager.RegisterRoutedEvent(nameof(CouponSelect), RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(VirtureMobileHappyCoupons)); + /// + /// MouseClicked Routed Event Handler + /// + public event RoutedEventHandler CouponSelect + { + add { AddHandler(CouponSelectEvent, value); } + remove { RemoveHandler(CouponSelectEvent, value); } + } + #endregion RoutedEvent 'SelectChange' + private double mouseDownYposition = -1; + private bool MoseDown = false; + + #endregion Members + + #region [ Ctor & Etc ] + /// + /// Ctor + /// + public VirtureMobileHappyCoupons() + { + InitializeComponent(); + CouponGrid.PreviewMouseDown += CouponGrid_PreviewMouseDown; + CouponGrid.PreviewMouseUp += CouponGrid_PreviewMouseUp; + CouponGrid.PreviewMouseMove += CouponGrid_PreviewMouseMove; + CouponGrid.MouseLeave += CouponGrid_MouseLeave; + + } + + #endregion Ctor & Etc + + #region [ Methods ] + /// + /// Raise MouseClicked Event + /// + private void RaiseCouponSelectEvent(object _sender) + { + if (Command != null && Command.CanExecute(_sender)) + { + Command.Execute(_sender); + } + RoutedEventArgs newEventArgs = new RoutedEventArgs(VirtureMobileHappyCoupons.CouponSelectEvent, _sender); + RaiseEvent(newEventArgs); + } + private void SetCouponStack(M_MobileCouponReturn newValue) + { + foreach (var aGrid in CouponStack.Children) + { + if (aGrid is Grid aCoupons) + { + foreach (var aStack in aCoupons.Children) + { + if (aStack is StackPanel aItems) + { + foreach (var aItem in aItems.Children) + { + if (aItem is VirtureMobileHappyCoupon aCoupon) + { + aCoupon.MouseClicked -= ACoupon_MouseClicked; + } + } + aItems.Children.Clear(); + } + } + aCoupons.Children.Clear(); + } + } + CouponStack.Children.Clear(); + if (newValue.VirtureCoupons.Count.Equals(0)) return; + var index = 0; + Grid lineGrid = null; + StackPanel lineStack = null; + foreach (var aCouponDetail in newValue.VirtureCoupons) + { + var newCoupon = new VirtureMobileHappyCoupon + { + ItemData = aCouponDetail, + Enabled = aCouponDetail.Status.Equals(MobileCouponStatusType.CanUse), + DisplayLanguage = this.DisplayLanguage + }; + if ((index % 3).Equals(0)) + { + lineGrid = new Grid + { + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left, + Width = newCoupon.Width * 3, + Height = newCoupon.Height, + }; + lineStack = new StackPanel + { + VerticalAlignment = VerticalAlignment.Top, + HorizontalAlignment = HorizontalAlignment.Left, + Orientation = Orientation.Horizontal, + }; + + } + newCoupon.MouseClicked += ACoupon_MouseClicked; + newCoupon.Name = string.Format("MobileCoupon{0}", index); + this.ReregisterName(newCoupon.Name, newCoupon); + lineStack.Children.Add(newCoupon); + index++; + if ((index % 3).Equals(0)) + { + lineGrid.Children.Add(lineStack); + CouponStack.Children.Add(lineGrid); + } + } + if (!(index % 3).Equals(0)) + { + lineGrid.Children.Add(lineStack); + CouponStack.Children.Add(lineGrid); + } + } + #endregion Methods + + #region [ Event Handlers ] + private void ACoupon_MouseClicked(object sender, RoutedEventArgs e) + { + RaiseCouponSelectEvent(e.OriginalSource); + } + private static void OnVerticalOffsetPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue != e.OldValue) + { + var target = d as VirtureMobileHappyCoupons; + target.MainScroll.ScrollToVerticalOffset((double)e.NewValue); + } + } + + private static void OnCouponDataPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue is M_MobileCouponReturn newValue) + { + var target = d as VirtureMobileHappyCoupons; + target.SetCouponStack(newValue); + } + } + + + private static void OnDisplayLanguageProperyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (e.NewValue is SupportLanguageType newValue) + { + var target = d as VirtureMobileHappyCoupons; + foreach (var aGrid in target.CouponStack.Children) + { + if (aGrid is Grid aCoupons) + { + foreach (var aStack in aCoupons.Children) + { + if (aStack is StackPanel aItems) + { + foreach (var aItem in aItems.Children) + { + if (aItem is VirtureMobileHappyCoupon aCoupon) + { + aCoupon.DisplayLanguage = newValue; + } + } + } + } + } + } + } + } + private void CouponGrid_PreviewMouseDown(object sender, MouseButtonEventArgs e) + { + var requstGrid = sender as Grid; + mouseDownYposition = e.GetPosition(sender as Grid).Y; + MoseDown = true; + } + + private void CouponGrid_PreviewMouseUp(object sender, MouseButtonEventArgs e) + { + MoseDown = false; + } + + private void CouponGrid_PreviewMouseMove(object sender, MouseEventArgs e) + { + if (!MoseDown) return; + var requstGrid = sender as Grid; + var curMouseYposition = e.GetPosition(requstGrid).Y; + VerticalOffset = VerticalOffset + (mouseDownYposition - curMouseYposition) * 2; + mouseDownYposition = curMouseYposition; + } + + private void CouponGrid_MouseLeave(object sender, MouseEventArgs e) + { + MoseDown = false; + } + #endregion Event Handlers + + } +} diff --git a/Kiosk/Popup/SPC.Kiosk.Popup/packages.config b/Kiosk/Popup/SPC.Kiosk.Popup/packages.config new file mode 100644 index 0000000..d7bbafa --- /dev/null +++ b/Kiosk/Popup/SPC.Kiosk.Popup/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Kiosk/Start/SPC.Kiosk.Start.Model/Properties/AssemblyInfo.cs b/Kiosk/Start/SPC.Kiosk.Start.Model/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..2fa629d --- /dev/null +++ b/Kiosk/Start/SPC.Kiosk.Start.Model/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("SPC.Kiosk.Start.Model")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("SPC.Kiosk.Start.Model")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("37f15b06-9bcb-4f3c-8eb5-050d6be1c344")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 +// 기본값으로 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Kiosk/Start/SPC.Kiosk.Start.Model/SPC.Kiosk.Start.Model.csproj b/Kiosk/Start/SPC.Kiosk.Start.Model/SPC.Kiosk.Start.Model.csproj new file mode 100644 index 0000000..66ef52d --- /dev/null +++ b/Kiosk/Start/SPC.Kiosk.Start.Model/SPC.Kiosk.Start.Model.csproj @@ -0,0 +1,57 @@ + + + + + Debug + AnyCPU + {37F15B06-9BCB-4F3C-8EB5-050D6BE1C344} + Library + Properties + SPC.Kiosk.Start.Model + SPC.Kiosk.Start.Model + v4.0 + 512 + true + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + + {ba2d06e0-74c0-4785-b39f-d1eaac13b73d} + SPC.Kiosk.Common + + + + \ No newline at end of file diff --git a/Kiosk/Start/SPC.Kiosk.Start.Model/m_InitImage.cs b/Kiosk/Start/SPC.Kiosk.Start.Model/m_InitImage.cs new file mode 100644 index 0000000..0ef87cb --- /dev/null +++ b/Kiosk/Start/SPC.Kiosk.Start.Model/m_InitImage.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using SPC.Kiosk.Common; +namespace SPC.Kiosk.Start.Model +{ + public class M_UriImage + { + public int Index { get; set; } + public UriTypes LinkType { get; set; } + public string LinkUri { get; set; } + public string Image { get; set; } + } + +} diff --git a/Kiosk/Start/SPC.Kiosk.Start.ViewModel/Properties/AssemblyInfo.cs b/Kiosk/Start/SPC.Kiosk.Start.ViewModel/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8c07e43 --- /dev/null +++ b/Kiosk/Start/SPC.Kiosk.Start.ViewModel/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("SPC.Kiosk.Start.ViewModel")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("KioskStart")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +// 이 프로젝트가 COM에 노출되는 경우 다음 GUID는 typelib의 ID를 나타냅니다. +[assembly: Guid("beacf939-6802-4d28-8445-e02692e741a4")] + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호를 +// 기본값으로 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Kiosk/Start/SPC.Kiosk.Start.ViewModel/SPC.Kiosk.Start.ViewModel.csproj b/Kiosk/Start/SPC.Kiosk.Start.ViewModel/SPC.Kiosk.Start.ViewModel.csproj new file mode 100644 index 0000000..ec1db72 --- /dev/null +++ b/Kiosk/Start/SPC.Kiosk.Start.ViewModel/SPC.Kiosk.Start.ViewModel.csproj @@ -0,0 +1,76 @@ + + + + + Debug + AnyCPU + {BEACF939-6802-4D28-8445-E02692E741A4} + Library + Properties + SPC.Kiosk.Start.ViewModel + SPC.Kiosk.Start.ViewModel + v4.0 + 512 + true + Svn + Svn + Svn + SubversionScc + + + true + full + false + ..\..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\BIN\Cosmos.BaseFrame.dll + + + ..\..\BIN\Cosmos.Common.dll + + + + + + + + + + + + + + + + + + + + {bcc10fa2-c358-480c-8ff0-615750f3c306} + SPC.Kiosk.Base + + + {BA2D06E0-74C0-4785-B39F-D1EAAC13B73D} + SPC.Kiosk.Common + + + {37f15b06-9bcb-4f3c-8eb5-050d6be1c344} + SPC.Kiosk.Start.Model + + + + \ No newline at end of file diff --git a/Kiosk/Start/SPC.Kiosk.Start.ViewModel/StartViewModel.cs b/Kiosk/Start/SPC.Kiosk.Start.ViewModel/StartViewModel.cs new file mode 100644 index 0000000..4608a14 --- /dev/null +++ b/Kiosk/Start/SPC.Kiosk.Start.ViewModel/StartViewModel.cs @@ -0,0 +1,535 @@ +using Cosmos.BaseFrame; +using Cosmos.Common; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.IO; +using System.ComponentModel; +using System.Windows.Input; +using SPC.Kiosk.Common; +using SPC.Kiosk.Base; +using System.Windows.Media.Animation; +using System.Windows; +using System.Collections.ObjectModel; +using System.Windows.Forms; +using SPC.Kiosk.Start.Model; +using System.Text.RegularExpressions; + +namespace SPC.Kiosk.Start.ViewModel +{ + /// + /// Test View Model + /// + public class VmStartViewModel : ViewModelBase + { + #region [ Members ] + + public SupportLanguageType ShowLanguageType + { + get { return CommonValue.CommonLanguageType; } + set { CommonValue.CommonLanguageType = value; PropertyChange("ShowLanguageType"); } + } + public string TitIeImage { get; set; } = ResourceManager.GetCDPimagePath("intro_bimg.png"); + + public string CloseImage { get; set; } = ResourceManager.GetNximagePath("btn_close.png"); + + public string IntroTop { get; set; } = ResourceManager.GetCDPimagePath("블루투스인형1.jpg"); + + public string IntroBottom { get; set; } = ResourceManager.GetCDPimagePath("블루투스인형2.jpg"); + + public ObservableCollection MediaRollItems { get; set; } + + public int ScreenNo { get; set; } + public Size ScreenSize { get; set; } + public string FirstMedia { get; set; } + + public ICommand BaseToTradeCommad { get; protected set; } = null; + public ICommand RollMediaCommand { get; protected set; } = null; + public ICommand ItemDropedCommand { get; protected set; } = null; + public ICommand ListItemDropCommand { get; protected set; } = null; + public ICommand ListCircleClickCommand { get; protected set; } = null; + public ICommand OpenPopupCommand { get; protected set; } = null; + public ICommand WaitPopupCommand { get; protected set; } = null; + + public ICommand NumericPadOkCommand { get; protected set; } = null; + + private bool toggleSwitch = false; + public bool ToggleSwitch + { + get { return toggleSwitch; } + set { toggleSwitch = value; PropertyChange("ToggleSwitch"); } + } + private int testItemPageNo; + public int TestItemPageNo + { + get + { + return testItemPageNo; + } + set + { + testItemPageNo = value; + PropertyChange("TestItemPageNo"); + } + } + private ObservableCollection testItems; + public ObservableCollection TestItems + { + get + { + return testItems; + } + set + { + testItems = value; + PropertyChange("TestItems"); + } + } + private int defaultSelectedItem; + public int DefaultSelectedItem + { + get + { + return defaultSelectedItem; + } + set + { + defaultSelectedItem = value; + PropertyChange("DefaultSelectedItem"); + } + } + private int defaultSelectedPageNo; + public int DefaultSelectedPageNo + { + get + { + return defaultSelectedPageNo; + } + set + { + defaultSelectedPageNo = value; + PropertyChange("DefaultSelectedPageNo"); + } + } + public int SelectedColumnCount { get; set; } + public int SelectedRowCount { get; set; } + + + private ObservableCollection selectedItems; + public ObservableCollection SelectedItems + { + get + { + return selectedItems; + } + set + { + selectedItems = value; + PropertyChange("SelectedItems"); + } + } + + public List PreviousText { get; set; } + public List NextText { get; set; } + public List PopupText { get; set; } + public List ExistText { get; set; } + public List ToggleText { get; set; } + public List TradeHeaderText { get; set; } + + public List OkText { get; set; } + public List CancelText { get; set; } + public List InputMobileNumberMessage { get; set; } + + private string inputNumbers; + public string InputNumbers + { + get + { + return inputNumbers; + } + set + { + inputNumbers = value; + PropertyChange("InputNumbers"); + } + } + + #endregion Members + + #region [ Ctor ] + public VmStartViewModel() + { + ScreenNo = 0; + ScreenSize = new Size(0,0); + InitViewModel(); + } + public VmStartViewModel(int _screenNo,Size _screensize) + { + ScreenNo = _screenNo; + ScreenSize = _screensize; + InitViewModel(); + } + + #endregion Ctor + + #region [ Methods ] + + private void InitViewModel() + { + var waitWindow = new WaitWindow(); + waitWindow.ShowWaitWindow(); + try + { + SelectedColumnCount = 6; + SelectedRowCount = 1; + + BaseToTradeCommad = new Command(BaseToTradeCommandHandler); + RollMediaCommand = new Command(RollMediaCommandHandler); + ItemDropedCommand = new Command(ItemDropedCommandHandler); + ListItemDropCommand = new Command(ListItemDropCommandHandler); + ListCircleClickCommand = new Command(ListCircleClickCommandHandler); + OpenPopupCommand = new Command(OpenPopupCommandHandler); + WaitPopupCommand = new Command(WaitPopupCommandHandler); + NumericPadOkCommand = new Command(NumericPadOkCommandHandler); + TitIeImage = ResourceManager.GetCDPimagePath("intro_bimg.png"); + CloseImage = ResourceManager.GetNximagePath("btn_close.png"); + FirstMedia = ResourceManager.GetCDPmediaPath("CF1.wmv"); + + MediaRollItems = new ObservableCollection + { + new M_MediaRollItem() { Type = MediaType.Image, MediaPath = ResourceManager.GetCDPimagePath("블루투스인형2.jpg"), RunnigSeconds = 10 }, + new M_MediaRollItem() { Type = MediaType.VOD, MediaPath = ResourceManager.GetCDPmediaPath("CF1.wmv"), RunnigSeconds = 48 }, + new M_MediaRollItem() { Type = MediaType.VOD, MediaPath = ResourceManager.GetCDPmediaPath("CF2.wmv"), RunnigSeconds = 39 }, + }; + + PreviousText = Languages.GetMessages("CommonPrevious"); + NextText = Languages.GetMessages("CommonNext"); + PopupText = Languages.GetMessages("CommonPopup"); + ExistText = Languages.GetMessages("CommonExist"); + ToggleText = Languages.GetMessages("CommonToggle"); + TradeHeaderText = Languages.GetMessages("TradeHeader"); + InputMobileNumberMessage = Languages.GetMessages("MobileNumberMessage"); + OkText = Languages.GetMessages("CommonOK"); + CancelText = Languages.GetMessages("CommonCancel"); + + this.PropertyChanged += VmStartViewModel_PropertyChanged; + + + } + catch + { + throw; + } + finally + { + waitWindow.CloseWaitWindow(); + } + } + + + private void VmStartViewModel_PropertyChanged(object sender, PropertyChangedEventArgs e) + { + switch (e.PropertyName) + { + case "ToggleSwitch": + ShowLanguageType = ToggleSwitch ? SupportLanguageType.en : SupportLanguageType.ko; + break; + default: + break; + } + } + + + + private List GetEmptyItems(int _emptyCount) + { + List result = null; + + try + { + result = new List(); + for (int i = 0; i < _emptyCount; i++) result.Add(GetAnEmptyItem(i)); + return result; + } + catch + { + result = null; + } + return result; + + } + private M_ItemData GetSelectData(int _index, M_ItemData _sourceData) + { + M_ItemData result = null; + try + { + result = new M_ItemData + { + Index = _index, + ItemCode = _sourceData.ItemCode, + Category1 = "Select", + DataParameter = _sourceData.DataParameter + }; + result.DataParameter.Width = 100; + result.DataParameter.Height = 100; + result.DataParameter.DragEnable = false; + result.DataParameter.DragCursorImage = string.Empty; + result.DataParameter.ClickAnimationType = ButtonAnimationType.None; + result.DataParameter.CircleSize = 30; + result.DataParameter.CircleBackBrush = "Black"; + result.DataParameter.CircleTextBruch = "White"; + result.DataParameter.CircleText = "X"; + } + catch + { + + result = null; + } + return result; + } + private M_ItemData GetAnEmptyItem(int _index) + { + M_ItemData result = null; + try + { + result= new M_ItemData + { + Index = _index, + ItemCode = "EmptyItem", + Category1 = "Empty", + DataParameter = new M_AnimationButton + { + NormalBrush = "Gray", + DownBrush = "Gray", + DragEnable = false, + Width = 100, + Height = 100, + Switch = false, + AutoToggle = false, + ClickAnimationType = ButtonAnimationType.None, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty, + } + }; + } + catch + { + + result = null; + } + return result; + } + private List GetItemImages(List m_ItemDatas) + { + List result = m_ItemDatas; + + try + { + var itemFiles = ResourceManager.GetItemImages("*.png"); + if (result ==null) result= new List(); + result.Clear(); + int index = 0; + foreach (var aItemFles in itemFiles) + { + var aFile = new FileInfo(aItemFles); + if (Regex.IsMatch(aFile.Name.Replace(aFile.Extension, ""), "^[0-9]")) + { + result.Add(new M_ItemData() + { + Index = index, + ItemCode = aFile.Name.Replace(aFile.Extension, ""), + Category1 = "All", + DataParameter = new M_AnimationButton + { + NormalBrush = aItemFles, + DownBrush = aItemFles, + DragCursorImage = aItemFles, + Width = 100, + Height = 100, + BrushStretch = Stretch.Fill, + Switch = false, + AutoToggle = false, + DragEnable = true, + DragCursorHotSpot = HotSpotType.Center, + ClickAnimationType = ButtonAnimationType.SizeUp, + CircleBackBrush = "Transparent", + CircleTextBruch = "Transparent", + CircleText = string.Empty + }, + BaseTextBlock = new M_TextBlock() + { + LanguageData = new List { + new M_Language{ Type = SupportLanguageType.en, LanguageData = aFile.Name.Replace(aFile.Extension, "")}, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = aFile.Name.Replace(aFile.Extension, "")} + }, + TextSize = 14, + TextBrush = "White", + TextWeight = FontWeights.Bold + }, + AdditionTextBlock = new M_TextBlock() + { + LanguageData = new List { + new M_Language{ Type = SupportLanguageType.en, LanguageData = string.Format("₩{0:#,##0}", 3001)}, + new M_Language{ Type = SupportLanguageType.ko, LanguageData = string.Format("₩{0:#,##0}", 3000)} + }, + TextSize = 16, + TextBrush = "LightPink", + TextWeight = FontWeights.Bold, + }, + + }); + index++; + } + } + return result; + } + catch + { + result = null; + } + return result; + } + + private void DataModelInit() + { + var waitWindow = new WaitWindow(); + waitWindow.ShowWaitWindow(); + try + { + ToggleSwitch = false; + TestItems = new ObservableCollection(GetItemImages(null)); + TestItemPageNo = 0; + SelectedItems = new ObservableCollection(GetEmptyItems(1)); + DefaultSelectedItem = 0; + DefaultSelectedPageNo = 0; + + } + catch + { + throw; + } + finally + { + waitWindow.CloseWaitWindow(); + } + + } + + #endregion Methods + + #region Event Handlers + private void NumericPadOkCommandHandler(object _param) + { + if (!string.IsNullOrEmpty(InputNumbers)) + { + if (InputNumbers.Length < 11) + { + KioskMessageBox.TimeMessageBox(ScreenNo + , ScreenSize + , null + , null + , Languages.GetMessages("TimePopupMessage") + , OpenCloseAnimationType.GotoUp + , OpenCloseAnimationType.GotoDown, 0.5, 0.2, 2); + } + else if (InputNumbers.Length.Equals(11)) + { + InputNumbers = string.Empty; + } + } + } + + private void ListItemDropCommandHandler(object _param) + { + if (_param != null) + { + var dropedItem = _param as M_ItemDropEventArgs; + var sourceButton = dropedItem.SourceObject as AnimationButton; + var targetButton = dropedItem.TargetObject as AnimationButton; + var targetData = targetButton.DataParameter as M_ItemData; + var sourceData = sourceButton.DataParameter as M_ItemData; + var selectSourceData = TestItems.Where(r => r.Equals(sourceData)).FirstOrDefault(); + var targetIndex = SelectedItems.IndexOf(targetData); + if (targetIndex > -1) + { + var newSelectItem = GetSelectData(targetData.Index, sourceData); + SelectedItems[targetIndex] = newSelectItem; + targetButton.DataParameter = newSelectItem; + var defaultItem = SelectedItems.Where(r => r.ItemCode.Equals("EmptyItem")).FirstOrDefault(); + if (defaultItem == null) + { + SelectedItems.Add(GetAnEmptyItem(SelectedItems.Count)); + SelectedItems = new ObservableCollection(SelectedItems.ToList()); + } + DefaultSelectedItem = SelectedItems.IndexOf(SelectedItems.Where(r => r.ItemCode.Equals("EmptyItem")).FirstOrDefault()); + DefaultSelectedPageNo = DefaultSelectedItem / (SelectedColumnCount * SelectedRowCount); + } + + } + } + private void ListCircleClickCommandHandler(object _param) + { + var targetButton = _param as AnimationButton; + var targetData = targetButton.DataParameter as M_ItemData; + var targetIndex = SelectedItems.IndexOf(targetData); + if (targetIndex > -1) + { + var newDeletedItem = GetAnEmptyItem(targetIndex); + SelectedItems[targetIndex] = newDeletedItem; + targetButton.DataParameter = newDeletedItem; + DefaultSelectedItem = SelectedItems.IndexOf(SelectedItems.Where(r => r.ItemCode.Equals("EmptyItem")).FirstOrDefault()); + } + } + + private void OpenPopupCommandHandler(object obj) + { + var dialogResult = MessageBoxResult.None; + while (dialogResult.Equals(MessageBoxResult.None)) + { + dialogResult = KioskMessageBox.ShowMessageBox(ScreenNo + , ScreenSize + , Languages.GetMessages("PopupHeader") + , null + , Languages.GetMessages("PopupMessage") + , MessageBoxButton.YesNo + , OpenCloseAnimationType.GotoUp + , OpenCloseAnimationType.GotoDown, 0.5, 0.2); + } + + } + private void WaitPopupCommandHandler(object obj) + { + KioskMessageBox.TimeMessageBox(ScreenNo + , ScreenSize + , null + , null + , Languages.GetMessages("TimePopupMessage") + , OpenCloseAnimationType.GotoLeft + , OpenCloseAnimationType.GotoRight, 0.5, 0.2, 3); + } + + private void BaseToTradeCommandHandler(object _param) + { + DataModelInit(); + } + private void RollMediaCommandHandler(object _param) + { + DataModelInit(); + } + private void ItemDropedCommandHandler(object _param) + { + if (_param is M_ItemDropEventArgs dropedItem) + { + var targetButton = dropedItem.TargetObject as AnimationButton; + targetButton.CircleText = (int.Parse(targetButton.CircleText) + 1).ToString() ; + } + } + + #endregion Event Handlers + } + +} diff --git a/Kiosk/Start/SPC.Kiosk.Start/Properties/AssemblyInfo.cs b/Kiosk/Start/SPC.Kiosk.Start/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..b92fa90 --- /dev/null +++ b/Kiosk/Start/SPC.Kiosk.Start/Properties/AssemblyInfo.cs @@ -0,0 +1,55 @@ +using System.Reflection; +using System.Resources; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; +using System.Windows; + +// 어셈블리에 대한 일반 정보는 다음 특성 집합을 통해 +// 제어됩니다. 어셈블리와 관련된 정보를 수정하려면 +// 이러한 특성 값을 변경하세요. +[assembly: AssemblyTitle("SPC.Kiosk.Start")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("KioskMain")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2018")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// ComVisible을 false로 설정하면 이 어셈블리의 형식이 COM 구성 요소에 +// 표시되지 않습니다. COM에서 이 어셈블리의 형식에 액세스하려면 +// 해당 형식에 대해 ComVisible 특성을 true로 설정하세요. +[assembly: ComVisible(false)] + +//지역화 가능 응용 프로그램 빌드를 시작하려면 다음을 설정하세요. +//.csproj 파일에서 내에 CultureYouAreCodingWith를 +//설정하십시오. 예를 들어 소스 파일에서 영어(미국)를 +//사용하는 경우 를 en-US로 설정합니다. 그런 다음 아래 +//NeutralResourceLanguage 특성의 주석 처리를 제거합니다. 아래 줄의 "en-US"를 업데이트하여 +//프로젝트 파일의 UICulture 설정과 일치시킵니다. + +//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)] + + +[assembly: ThemeInfo( + ResourceDictionaryLocation.None, //테마별 리소스 사전의 위치 + //(페이지 또는 응용 프로그램 리소스 사진에 + // 리소스가 없는 경우에 사용됨) + ResourceDictionaryLocation.SourceAssembly //제네릭 리소스 사전의 위치 + //(페이지 또는 응용 프로그램 리소스 사진에 + // 리소스가 없는 경우에 사용됨) +)] + + +// 어셈블리의 버전 정보는 다음 네 가지 값으로 구성됩니다. +// +// 주 버전 +// 부 버전 +// 빌드 번호 +// 수정 버전 +// +// 모든 값을 지정하거나 아래와 같이 '*'를 사용하여 빌드 번호 및 수정 번호가 자동으로 +// 지정되도록 할 수 있습니다. +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Kiosk/Start/SPC.Kiosk.Start/SPC.Kiosk.Start.csproj b/Kiosk/Start/SPC.Kiosk.Start/SPC.Kiosk.Start.csproj new file mode 100644 index 0000000..93679bf --- /dev/null +++ b/Kiosk/Start/SPC.Kiosk.Start/SPC.Kiosk.Start.csproj @@ -0,0 +1,96 @@ + + + + + Debug + AnyCPU + {252882FC-0458-4FF7-9B3F-1440189A733B} + Library + SPC.Kiosk.Start + SPC.Kiosk.Start + v4.0 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + Svn + Svn + Svn + SubversionScc + + + x86 + true + full + false + ..\..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + + + + + + + + 4.0 + + + + + + + ..\..\..\packages\WpfAnimatedGif.1.4.17\lib\net\WpfAnimatedGif.dll + + + + + MSBuild:Compile + Designer + + + StartWindow.xaml + Code + + + + + Code + + + + + {bcc10fa2-c358-480c-8ff0-615750f3c306} + SPC.Kiosk.Base + + + {ba2d06e0-74c0-4785-b39f-d1eaac13b73d} + SPC.Kiosk.Common + + + {beacf939-6802-4d28-8445-e02692e741a4} + SPC.Kiosk.Start.ViewModel + + + + + + + \ No newline at end of file diff --git a/Kiosk/Start/SPC.Kiosk.Start/StartWindow.xaml b/Kiosk/Start/SPC.Kiosk.Start/StartWindow.xaml new file mode 100644 index 0000000..16fdbc1 --- /dev/null +++ b/Kiosk/Start/SPC.Kiosk.Start/StartWindow.xaml @@ -0,0 +1,318 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Kiosk/Start/SPC.Kiosk.Start/StartWindow.xaml.cs b/Kiosk/Start/SPC.Kiosk.Start/StartWindow.xaml.cs new file mode 100644 index 0000000..4e8989d --- /dev/null +++ b/Kiosk/Start/SPC.Kiosk.Start/StartWindow.xaml.cs @@ -0,0 +1,202 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Windows; +using System.Runtime.InteropServices; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Forms; +using System.Windows.Input; +using System.Windows.Media.Animation; +using SPC.Kiosk.Common; +using System.Threading.Tasks; +namespace SPC.Kiosk.Start +{ + /// + /// MainWindow.xaml에 대한 상호 작용 논리 + /// + public partial class StartWindow : Window + { + public int ScreenNo { get; set; } = 0; + public Size WindowSize { get; set; } = new Size(0, 0); + public StartWindow() + { + StartInitialize(); + } + public StartWindow(Size _size) + { + WindowSize = _size; + StartInitialize(); + } + public StartWindow(int _screenNo) + { + ScreenNo = _screenNo; + StartInitialize(); + } + + public StartWindow(int _screenNo,Size _size) + { + ScreenNo = _screenNo; + WindowSize = _size; + StartInitialize(); + } + private void StartInitialize() + { + InitializeComponent(); + this.Left = Screen.AllScreens[ScreenNo].WorkingArea.Left; + this.Top = Screen.AllScreens[ScreenNo].WorkingArea.Top; + this.Width = WindowSize.Width.Equals(0) ? Screen.AllScreens[ScreenNo].Bounds.Width : WindowSize.Width; + this.Height = WindowSize.Height.Equals(0) ? Screen.AllScreens[ScreenNo].Bounds.Height : WindowSize.Height; + this.Closed += StartWindow_Closed; + } + + private void StartWindow_Closed(object sender, EventArgs e) + { + this.Loaded -= StartWindow_Loaded; + this.DataContext = null; + BindingOperations.ClearAllBindings(this); + GC.SuppressFinalize(this); + } + + ~StartWindow() { } + private void StartWindow_Loaded(object sender, RoutedEventArgs e) + { + OpenBase(); + + } + private void BaseToTrade() + { + + ItemList.DefaultPageNo = 0; + var OpenAnimations = Animations.GetOpenAndCloseAnimation(this.BaseGrid, this.TradeGrid, OpenCloseAnimationType.GotoLeft, this.Width, 0.3); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Name = "TradeOpen"; + OpenAnimations.Begin(); + } + } + private void TradeToBase() + { + + var OpenAnimations = Animations.GetOpenAndCloseAnimation(this.TradeGrid,this.BaseGrid, OpenCloseAnimationType.GotoRight, this.Width, 0.3); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Name = "BaseOpen"; + OpenAnimations.Begin(); + } + + } + private void TradeToBasket() + { + + var OpenAnimations = Animations.GetOpenAndCloseAnimation(this.TradeGrid,this.BasketGrid, OpenCloseAnimationType.GotoLeft, this.Width,0.3); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Name = "BasketOpen"; + OpenAnimations.Begin(); + } + + } + private void BasketToTrade() + { + + var OpenAnimations = Animations.GetOpenAndCloseAnimation(this.BasketGrid,this.TradeGrid, OpenCloseAnimationType.GotoRight, this.Width, 0.3); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Name = "TradeOpen"; + OpenAnimations.Begin(); + } + + } + + private void OpenBase() + { + this.TradeGrid.IsEnabled = false; + this.BasketGrid.IsEnabled = false; + this.TradeGrid.Visibility = Visibility.Hidden; + this.BasketGrid.Visibility = Visibility.Hidden; + var OpenAnimations = Animations.GetOpenAnimation(this.BaseGrid, OpenCloseAnimationType.GotoLeft, this.Width, 0.5); + if (OpenAnimations != null) + { + OpenAnimations.Completed += OpenAnimations_Completed; + OpenAnimations.Name = "BaseOpen"; + OpenAnimations.Begin(); + } + } + private void CloseBase() + { + var CloseAnimation = Animations.GetCloseAnimation(this.BasketGrid, OpenCloseAnimationType.GotoLeft, this.Width, 0.2); + if (CloseAnimation != null) + { + CloseAnimation.Completed += CloseAnimation_Completed; + CloseAnimation.Begin(); + } + } + private void OpenAnimations_Completed(object sender, EventArgs e) + { + var senderStoryboard = (sender as ClockGroup).Timeline as Storyboard; + var getName = senderStoryboard.Name; + switch (senderStoryboard.Name) + { + case "BaseOpen": + this.BaseGrid.IsEnabled = true; + break; + case "TradeOpen": + this.TradeGrid.IsEnabled = true; + break; + case "BasketOpen": + this.BasketGrid.IsEnabled = true; + break; + + } + + } + private void CloseAnimation_Completed(object sender, EventArgs e) + { + this.Close(); + } + private void CloseImage_Click(object sender, RoutedEventArgs e) + { + CloseBase(); + } + private void TradeToBase_MouseClicked(object sender, RoutedEventArgs e) + { + TradeToBase(); + } + private void TradeToBasket_MouseClicked(object sender, RoutedEventArgs e) + { + TradeToBasket(); + } + private void BasketToTrade_MouseClicked(object sender, RoutedEventArgs e) + { + BasketToTrade(); + } + private void BaseToTrade_MouseClicked(object sender, RoutedEventArgs e) + { + BaseToTrade(); + } + private void ToggleButton_MouseClicked(object sender, RoutedEventArgs e) + { + Console.WriteLine("ToggleButton Clicked"); + } + + private void ItemList_MouseClicked(object sender, RoutedEventArgs e) + { + var itemButton = e.OriginalSource as AnimationButton; + Console.WriteLine("ClickItem:{0}",itemButton.NormalBrush); + } + private void TitleMedia3_MouseClicked(object sender, RoutedEventArgs e) + { + var target = sender as MediaPlayer; + target.Restart(); + + } + + } +} diff --git a/Kiosk/Start/SPC.Kiosk.Start/packages.config b/Kiosk/Start/SPC.Kiosk.Start/packages.config new file mode 100644 index 0000000..d7bbafa --- /dev/null +++ b/Kiosk/Start/SPC.Kiosk.Start/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Kiosk/Test/KioskTest/App.xaml b/Kiosk/Test/KioskTest/App.xaml new file mode 100644 index 0000000..d5a8267 --- /dev/null +++ b/Kiosk/Test/KioskTest/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/Kiosk/Test/KioskTest/App.xaml.cs b/Kiosk/Test/KioskTest/App.xaml.cs new file mode 100644 index 0000000..70a8dca --- /dev/null +++ b/Kiosk/Test/KioskTest/App.xaml.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Windows; + +namespace TestProject +{ + /// + /// App.xaml에 대한 상호 작용 논리 + /// + public partial class App : Application + { + } +} diff --git a/Kiosk/Test/KioskTest/KioskTest.csproj b/Kiosk/Test/KioskTest/KioskTest.csproj new file mode 100644 index 0000000..a1d9f11 --- /dev/null +++ b/Kiosk/Test/KioskTest/KioskTest.csproj @@ -0,0 +1,132 @@ + + + + + Debug + AnyCPU + {E2928D3E-C5D3-42E7-952D-19491B079A16} + WinExe + KioskTest + KioskTest + v4.0 + 512 + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + 4 + true + Svn + Svn + Svn + SubversionScc + + + x86 + true + full + false + ..\..\..\..\BIN\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + window_icon_spc_icon.ico + + + + + + + + + + 4.0 + + + + + + + + MSBuild:Compile + Designer + + + MSBuild:Compile + Designer + + + App.xaml + Code + + + MainWindow.xaml + Code + + + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + ResXFileCodeGenerator + Resources.Designer.cs + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + {bcc10fa2-c358-480c-8ff0-615750f3c306} + SPC.Kiosk.Base + + + {ba2d06e0-74c0-4785-b39f-d1eaac13b73d} + SPC.Kiosk.Common + + + {bca39ae9-b2eb-495e-be62-ab95b0325cff} + SPC.Kiosk.PB.ViewModel + + + {38393190-821d-496d-a996-11833c20e476} + SPC.Kiosk.PB + + + {37f15b06-9bcb-4f3c-8eb5-050d6be1c344} + SPC.Kiosk.Start.Model + + + {beacf939-6802-4d28-8445-e02692e741a4} + SPC.Kiosk.Start.ViewModel + + + {252882fc-0458-4ff7-9b3f-1440189a733b} + SPC.Kiosk.Start + + + + + + + \ No newline at end of file diff --git a/Kiosk/Test/KioskTest/MainWindow.xaml b/Kiosk/Test/KioskTest/MainWindow.xaml new file mode 100644 index 0000000..ac892fc --- /dev/null +++ b/Kiosk/Test/KioskTest/MainWindow.xaml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + +