using System; using System.Collections; using System.IO; using System.Data; using Cosmos.Common; using Cosmos.UserFrame; using Cosmos.CommonManager; using Cosmos.ServiceProvider; using Cosmos.BaseFrame; using System.Diagnostics; using System.Linq; using System.Text; //#20180322 포스스팩에 REAL IP, ISP 추가 start using Newtonsoft.Json; using Newtonsoft.Json.Linq; //#20180322 포스스팩에 REAL IP, ISP 추가 end //#20180710 LOCAL IP 가져오기 start using System.Net; using System.Net.NetworkInformation; //#20180710 LOCAL IP 가져오기 end namespace Cosmos.Service { public class PosSpec : IServiceUs { private SManager sManager = new SManager(); // 이 객체를 통해 업무 Service 호출 private PosStatus m_cPosStatus = new PosStatus(); //기본정보 참조 private StateServer StateObject = (StateServer)StateServer.GetInstance(); // StateObject : StateServer Object (객체) protected IDataCommonUs m_cDataCommon = null; // 판매공통 모듈 private IICReaderUs m_cICReader = null; // IC리더기 private ISignPadUs m_cSignPad = null; // 사인패드 private readonly string m_FIELD_DIV = "|"; private readonly string m_LINE_DIV = "#~"; private string m_sWmiClass = ""; private string m_sWin32Product = ""; public PosSpec() { m_cPosStatus = (PosStatus)StateObject.POS; // POS 기본정보 m_cDataCommon = (IDataCommonUs)sManager.InitServiceInstance(ServiceLists.ASV_DATA_PROCESS.DLL, ServiceLists.ASV_DATA_PROCESS.DATA_COMMON); m_cICReader = (IICReaderUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_ICREADER); m_cSignPad = (ISignPadUs)sManager.InitServiceInstance(ServiceLists.AGENT_OLEDEVICE.DLL, ServiceLists.AGENT_OLEDEVICE.DEVICE_SIGNPAD); } public string Execute(string[] aParam) { string sRet = UserCom.RST_ERR; string sSendData = ""; try { sSendData += GetBios(); //BIOS sSendData += GetBoard(); //BOARD sSendData += GetCpu(); //CPU sSendData += GetPosPgm(); //POS PROGRAM VERSION sSendData += GetDB(); //DB sSendData += GetDisk(); //DISK sSendData += GetMemory(); //MEMORY sSendData += GetNetWork(); //NETWORK sSendData += GetVideo(); //VIDEO sSendData += GetOS(); //OS //#20180710 Real OS 가져오기 start sSendData += GetRealOS(); //RealOS //#20180710 Real OS 가져오기 end sSendData += GetSignPad(); //SIGNPAD sSendData += GetProduct(); //PRODUCT sSendData += GetReader(); //CARDREADER sSendData += GetDeviceStatus(); // 주변장치 상태 정보 가져오기 sSendData += GetLastLogData(); // 로그, 매출 최초 일자 sSendData += GetPosSystem(); // 인증 버전 sSendData += GetCpiMstData(); // 캠페인코드(2017.06.21) //#20180322 포스스팩에 REAL IP, ISP 추가 start //ISP -> 인터넷 서비스 제공자 sSendData += Get_IP_ISP(); //#20180322 포스스팩에 REAL IP, ISP 추가 end //#20180710 LOCAL IP 가져오기 start sSendData += GetLocalIP(); //LOCAL IP //#20180710 LOCAL IP 가져오기 end //sSendData += GetFiles(); //FILE //앞 구분자 자르기 sSendData = sSendData.Substring(2); UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "▶ POS SPEC SEND DATA :" + sSendData); //전문 보내기 sRet = ExecuteIrtPosSpec(sSendData); } 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; } #region POS SPEC 전문 송신 /// /// POS SPEC 전문 송신 /// /// /// /// private string ExecuteIrtPosSpec(string sSystemData) { string sRet = UserCom.RST_ERR; int iRecvTimeOut = 10000; Hashtable htRecvData = new Hashtable(); Hashtable htSendData = new Hashtable(); try { // 조회 htSendData.Add(Column.IQ_POS_SPEC.DATA.INQ_TYPE, ItemConst.IRT_INQ_TYPE.POS_SPEC_INQ); htSendData.Add(Column.IQ_POS_SPEC.DATA.STOR_CD, m_cPosStatus.Base.StoreNo); htSendData.Add(Column.IQ_POS_SPEC.DATA.SALE_DT, DateTime.Now.ToString("yyyyMMdd")); htSendData.Add(Column.IQ_POS_SPEC.DATA.POS_NO, m_cPosStatus.Base.PosNo); htSendData.Add(Column.IQ_POS_SPEC.DATA.SYSTEM_DATA, sSystemData); htSendData.Add(Column.IQ_POS_SPEC.DATA.RES_CD, ""); sRet = m_cDataCommon.ExecutePosIrt(ItemConst.COMM_MSG_TYPE.POSIRT, m_cPosStatus.Base.CommSvrIp, (int)m_cPosStatus.Base.SysInfoPort, iRecvTimeOut, htSendData, ref htRecvData); if (sRet != UserCom.RST_OK) { UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "SPEC SEND FAIL : " + sRet); sRet = UserCom.RST_ERR; return sRet; } if (htRecvData[Column.IQ_POS_SPEC.DATA.RES_CD].ToString() == "00") { UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "POS SPEC SEND SUCCESS"); } else { UserLog.WriteLogFile(UserCom.LOG_ERROR, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "SPEC SEND FAIL RSN_CD : " + htRecvData[Column.IQ_POS_SPEC.DATA.RES_CD].ToString()); } 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 System API 데이터 조회 /// /// Return a hardware identifier /// /// /// /// /// private string identifier(string wmiClass, string wmiProperty, string wmiMustBeTrue) { string result = ""; bool bCheck = false; System.Management.ManagementClass mc = new System.Management.ManagementClass(wmiClass); System.Management.ManagementObjectCollection moc = mc.GetInstances(); foreach (System.Management.ManagementObject mo in moc) { if (wmiMustBeTrue != "") { bCheck = mo[wmiMustBeTrue].ToString() == "True" ? true : false; } else { bCheck = true; } if (bCheck == true) { //Only get the first one if (result == "") { try { result = mo[wmiProperty].ToString(); break; } catch { } } } } return result; } /// /// Return a hardware identifier /// /// /// /// private string identifier(string wmiClass, string wmiProperty) { return identifier(wmiClass, wmiProperty, ""); } #endregion #region 조회 데이터 포멧팅 /// /// 조회 데이터 치환 /// /// /// private string DataReplace(string sInData) { string sData = ""; try { sData = sInData.Replace(m_FIELD_DIV, "").Replace(m_LINE_DIV, "").Replace("\n", ""); } 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.ToString()); } return sData; } /// /// 전송 데이터 포멧팅 /// /// /// /// /// private string DataFormat(string sWmiClass, string sWmiInstance, string sInstanceValue) { return DataFormat(sWmiClass, sWmiInstance, sInstanceValue, ""); } /// /// 전송 데이터 포멧팅 /// /// /// /// /// /// private string DataFormat(string sWmiClass, string sWmiInstance, string sInstanceValue, string AddValues) { string sRetData = string.Empty; try { if (AddValues == "") { sRetData = string.Format("{4}{1}{0}{2}{0}{3}", m_FIELD_DIV, sWmiClass, sWmiInstance, DataReplace(sInstanceValue), m_LINE_DIV); } else { sRetData += string.Format("{4}{1}{0}{2}{0}{3} {5}", m_FIELD_DIV, sWmiClass, sWmiInstance, DataReplace(sInstanceValue), m_LINE_DIV, AddValues); } } 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.ToString()); } return sRetData; } /// /// 사이즈 가져오기 /// /// /// private string GetFileSize(double byteCount) { string size = "0 Bytes"; try { if (byteCount >= 1099511627776.0) size = String.Format("{0:##.##}", byteCount / 1099511627776.0) + " TB"; else if (byteCount >= 1073741824.0) size = String.Format("{0:##.##}", byteCount / 1073741824.0) + " GB"; else if (byteCount >= 1048576.0) size = String.Format("{0:##.##}", byteCount / 1048576.0) + " MB"; else if (byteCount >= 1024.0) size = String.Format("{0:##.##}", byteCount / 1024.0) + " KB"; else if (byteCount > 0 && byteCount < 1024.0) size = byteCount.ToString() + " Bytes"; } 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.ToString()); } return size; } #endregion #region CPU 정보 가져오기 /// /// CPU 정보 가져오기 /// /// private string GetCpu() { string sRetData = string.Empty; try { m_sWmiClass = "CPU"; m_sWin32Product = "Win32_Processor"; string retVal = identifier(m_sWin32Product, "Name"); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "Name", retVal); } } 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.ToString()); } return sRetData; } #endregion #region Bios 정보 가져오기 /// /// Bios 정보 가져오기 /// /// private string GetBios() { string sRetData = string.Empty; string retVal = string.Empty; try { m_sWmiClass = "BIOS"; m_sWin32Product = "Win32_BIOS"; retVal = identifier(m_sWin32Product, "Name"); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "Name", retVal); retVal = ""; } retVal = identifier(m_sWin32Product, "SerialNumber"); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "SerialNumber", retVal); retVal = ""; } retVal = identifier(m_sWin32Product, "SMBIOSBIOSVersion"); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "SMBIOSBIOSVersion", retVal); retVal = ""; } } 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.ToString()); } return sRetData; } #endregion #region Disk 정보 가져오기 /// /// Disk 정보 가져오기 /// /// private string GetDisk() { string sRetData = string.Empty; string retVal = string.Empty; try { m_sWmiClass = "DISK"; m_sWin32Product = "Win32_DiskDrive"; retVal = identifier(m_sWin32Product, "Model"); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "Model", retVal); retVal = ""; } retVal = identifier(m_sWin32Product, "InterfaceType"); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "InterfaceType", retVal); retVal = ""; } retVal = identifier(m_sWin32Product, "Size"); if (retVal != "") { //int iMaxMem = (int)(CmUtil.DoubleParse(retVal) / 1000000000); //sRetData += DataFormat(m_sWmiClass, "Size", iMaxMem.ToString(), "GB"); sRetData += DataFormat(m_sWmiClass, "Size", GetFileSize(CmUtil.DoubleParse(retVal))); retVal = ""; } } 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.ToString()); } return sRetData; } #endregion #region Board 정보 가져오기 /// /// Board 정보 가져오기 /// /// private string GetBoard() { string sRetData = string.Empty; string retVal = string.Empty; try { m_sWmiClass = "BOARD"; m_sWin32Product = "Win32_BaseBoard"; retVal = identifier(m_sWin32Product, "Product"); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "Product", retVal); retVal = ""; } retVal = identifier(m_sWin32Product, "SerialNumber"); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "SerialNumber", retVal); retVal = ""; } retVal = identifier(m_sWin32Product, "Manufacturer"); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "Manufacturer", retVal); retVal = ""; } } 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.ToString()); } return sRetData; } #endregion #region Video 정보 가져오기 /// /// Video 정보 가져오기 /// /// private string GetVideo() { string sRetData = string.Empty; string retVal = string.Empty; try { m_sWmiClass = "VIDEO"; m_sWin32Product = "Win32_VideoController"; retVal = identifier(m_sWin32Product, "Name"); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "Name", retVal); retVal = ""; } retVal = identifier(m_sWin32Product, "VideoModeDescription"); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "VideoModeDescription", retVal); retVal = ""; } retVal = identifier(m_sWin32Product, "CurrentHorizontalResolution") + " X " + identifier("Win32_VideoController", "CurrentVerticalResolution"); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "Resolution", retVal); retVal = ""; } } 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.ToString()); } return sRetData; } #endregion #region NetWork 정보 가져오기 /// /// NetWork 정보 가져오기 /// /// private string GetNetWork() { string sRetData = string.Empty; string retVal = string.Empty; try { m_sWmiClass = "NETWORK"; m_sWin32Product = "Win32_NetworkAdapterConfiguration"; retVal = identifier(m_sWin32Product, "MACAddress", "IPEnabled"); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "MACAddress", retVal); retVal = ""; } } 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.ToString()); } return sRetData; } #endregion #region Memory 정보 가져오기 /// /// Memory 정보 가져오기 /// /// private string GetMemory() { string sRetData = string.Empty; string retVal = string.Empty; try { m_sWmiClass = "MEMORY"; m_sWin32Product = "Win32_ComputerSystem"; retVal = identifier(m_sWin32Product, "TotalPhysicalMemory"); if (retVal != "") { //int iMaxMem = (int)(CmUtil.DoubleParse(retVal) / 1024); //sRetData += DataFormat(m_sWmiClass, "TotalVisibleMemorySize", iMaxMem.ToString(), "MB"); sRetData += DataFormat(m_sWmiClass, "TotalPhysicalMemory", GetFileSize(CmUtil.DoubleParse(retVal))); retVal = ""; } } 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.ToString()); } return sRetData; } #endregion #region OS 정보 가져오기 /// /// OS 정보 가져오기 /// /// private string GetOS() { string sRetData = string.Empty; string retVal = string.Empty; try { m_sWmiClass = "OS"; m_sWin32Product = "Win32_OperatingSystem"; retVal = identifier(m_sWin32Product, "Caption"); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "Caption", retVal); retVal = ""; } retVal = identifier(m_sWin32Product, "SerialNumber"); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "SerialNumber", retVal); retVal = ""; } retVal = identifier(m_sWin32Product, "CSDVersion"); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "CSDVersion", retVal); retVal = ""; } } 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.ToString()); } return sRetData; } #endregion #region Files 정보 가져오기 /// /// Files 정보 가져오기 /// /// private string GetFiles() { string sRetData = string.Empty; string retVal = string.Empty; try { m_sWmiClass = "FILE"; if (System.IO.Directory.Exists(BaseCom.NxBinPath)) { System.IO.DirectoryInfo di = new System.IO.DirectoryInfo(BaseCom.NxBinPath); foreach (var item in di.GetFiles()) { //if (item.Extension.ToUpper() == ".EXE" || item.Extension.ToUpper() == ".DLL" || item.Extension.ToUpper() == ".OCX" || item.Extension.ToUpper() == ".COM") //{ FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(item.FullName); retVal = myFileVersionInfo.FileVersion; if (retVal == "" || retVal == null) { retVal = item.CreationTime.ToString("yyyy-MM-dd HH:mm:ss"); } sRetData += DataFormat(m_sWmiClass, item.Name, retVal); //sRetData += string.Format("{4}{1}{0}{2}{0}{3}", m_FIELD_DIV, "FILE", item.Name, DataReplace(retVal), m_LINE_DIV); //} } } } 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.ToString()); } return sRetData; } #endregion #region SignPad 정보 가져오기 /// /// SignPad 정보 가져오기 /// /// private string GetSignPad() { string sRetData = string.Empty; string retVal = string.Empty; try { m_sWmiClass = "SIGNPAD"; //응답메시지 (모델명(10) + 펌웨어버젼(20) + App버젼(30) + RF버젼(30) + 시리얼번호(30) + POS연동타입(1) if (m_cSignPad.GetSignPadInfo(ref retVal) == true) { sRetData += DataFormat(m_sWmiClass, "ModelName", CmUtil.MidH(retVal, 0, 9).Trim()); sRetData += DataFormat(m_sWmiClass, "FirmwareVersion", CmUtil.MidH(retVal, 10, 20).Trim()); sRetData += DataFormat(m_sWmiClass, "AppVersion", CmUtil.MidH(retVal, 30, 30).Trim()); sRetData += DataFormat(m_sWmiClass, "RFVersion", CmUtil.MidH(retVal, 60, 30).Trim()); sRetData += DataFormat(m_sWmiClass, "SerialNumber", CmUtil.MidH(retVal, 90, 30).Trim()); sRetData += DataFormat(m_sWmiClass, "PosConnectedType", CmUtil.MidH(retVal, 120, 1).Trim()); } } 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.ToString()); } return sRetData; } #endregion #region DB 정보 가져오기 /// /// DB 정보 가져오기 /// /// private string GetDB() { string sRetData = string.Empty; string retVal = string.Empty; try { m_sWmiClass = "DB"; sRetData += DataFormat(m_sWmiClass, "Version", m_cPosStatus.Base.MstDownDate); } 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.ToString()); } return sRetData; } #endregion #region 프로그램 정보 가져오기 /// /// 프로그램 정보 가져오기 /// /// private string GetPosPgm() { string sRetData = string.Empty; string retVal = string.Empty; string sProgramVer = ""; try { CmMessage cmPosConfig = CmMessage.MakeMessageFromFile(BaseCom.NxIniPath + PosConst.INI_FILE_NAME.PosConfig); m_sWmiClass = "POS_PGM"; for (int iLoop = 10; iLoop <= 19; iLoop++) { sProgramVer = CmUtil.StringNullEmpty(cmPosConfig.GetMessage("PGMVER").GetMessageValue("ProgramVer" + iLoop)); sRetData += DataFormat(m_sWmiClass, "ProgramVer" + iLoop, string.Format("{0}", sProgramVer == "" ? "2016011000001" : sProgramVer)); } } 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.ToString()); } return sRetData; } #endregion #region Product 정보 가져오기 /// /// Product 정보 가져오기 /// /// private string GetProduct() { string sRetData = string.Empty; string retVal = string.Empty; try { m_sWmiClass = "PRODUCT"; m_sWin32Product = ""; } 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.ToString()); } return sRetData; } #endregion #region CARDREADER 정보 가져오기 /// /// CARDREADER 정보 가져오기 /// /// private string GetReader() { string sRetData = string.Empty; string retVal = string.Empty; try { m_sWmiClass = "CARDREADER"; m_sWin32Product = ""; DeviceStatus m_cDevStatus = (DeviceStatus)StateObject.DEVICE; if (m_cDevStatus.ICReader.UseYn == false) { sRetData += DataFormat(m_sWmiClass, "CardRederType", "MSR"); } else { sRetData += DataFormat(m_sWmiClass, "CardRederType", "IC"); if (m_cICReader != null) { string[] arRet = m_cICReader.GetStatus_ICReader(PosConst.POS_CARD_READER_DEVICE_TYPE.IC_READER); if (arRet != null && arRet.Length > 6) { sRetData += DataFormat(m_sWmiClass, "HwStatus", arRet[0].Trim()); sRetData += DataFormat(m_sWmiClass, "IntegrityStatus", arRet[1].Trim()); sRetData += DataFormat(m_sWmiClass, "CardInStatus", arRet[2].Trim()); sRetData += DataFormat(m_sWmiClass, "ReaderName", arRet[3].Trim()); sRetData += DataFormat(m_sWmiClass, "ReaderVersion", arRet[4].Trim()); sRetData += DataFormat(m_sWmiClass, "ModuleId", arRet[5].Trim()); } } } } 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.ToString()); } return sRetData; } #endregion #region 주변장치 상태 정보 가져오기 /// /// 주변장치 상태 정보 가져오기 /// /// private string GetDeviceStatus() { string sRetData = string.Empty; string retVal = string.Empty; try { m_sWmiClass = "DEVICE_STATUS"; //프린터 sRetData += DataFormat(m_sWmiClass, "POS_PRINTER", ConvertSetDeviceStatus(m_cPosStatus.Base.OlePosPrinterStatus)); //IC리더기 sRetData += DataFormat(m_sWmiClass, "POS_ICREADER", ConvertSetDeviceStatus(m_cPosStatus.Base.OlePosICReaderStatus)); //CAT 단말기 sRetData += DataFormat(m_sWmiClass, "POS_CAT", ConvertSetDeviceStatus(m_cPosStatus.Base.OlePosCATStatus)); //돈통 //sRetData += DataFormat(m_sWmiClass, "POS_CASHDRAWER", ConvertSetDeviceStatus(m_cPosStatus.Base.OlePosCashDrawerStatus)); //저울 sRetData += DataFormat(m_sWmiClass, "POS_SCALE", ConvertSetDeviceStatus(m_cPosStatus.Base.OlePosScaleStatus)); //사인패드 sRetData += DataFormat(m_sWmiClass, "POS_SIGNPAD", ConvertSetDeviceStatus(m_cPosStatus.Base.OlePosSignPadStatus)); //라벨프린터 sRetData += DataFormat(m_sWmiClass, "POS_LABELPRINT", ConvertSetDeviceStatus(m_cPosStatus.Base.OlePosLabelPrinterStatus)); //MSR //sRetData += DataFormat(m_sWmiClass, "POS_MSR", ConvertSetDeviceStatus(m_cPosStatus.Base.OlePosMsrStatus)); //폴디스플레이 sRetData += DataFormat(m_sWmiClass, "POS_SCALEPOLEDISP", ConvertSetDeviceStatus(m_cPosStatus.Base.OlePosScalePoleDispStatus)); } 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.ToString()); } return sRetData; } #endregion #region 로그, 매출 최초 일자 /// /// 로그, 매출 최초 일자 /// /// private string GetLastLogData() { string sRetData = string.Empty; string retVal = string.Empty; string sQuery = string.Empty; try { m_sWmiClass = "LAST_LOG_DATE"; IMasterUs m_cMstService = (IMasterUs)sManager.InitServiceInstance(ServiceLists.ASV_MASTER.DLL, ServiceLists.ASV_MASTER.POS_MASTER); if (m_cMstService != null) { sQuery = " SELECT MIN(SALE_DT) AS SALE_DT "; sQuery += " FROM POSLOG..TR_SALE_HEADER"; sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'"; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'"; sQuery += " AND POS_NO = '" + m_cPosStatus.Base.PosNo + "'"; System.Data.DataTable dt = m_cMstService.Select(new string[] { sQuery }); if (!(dt == null || dt.Rows.Count == 0)) { System.Data.DataRow dr = dt.Rows[0]; //매출 헤더 최초 일자 sRetData += DataFormat(m_sWmiClass, "TR_FRIST_SALE", dr["SALE_DT"].ToString()); } } // 로그 최초 일자 if (Directory.Exists(BaseCom.NxLogPath)) { DirectoryInfo di = new DirectoryInfo(BaseCom.NxLogPath); foreach (var item in di.GetFiles().OrderByDescending(f => f.LastWriteTime)) { //로그 최초 일자 sRetData += DataFormat(m_sWmiClass, "FRIST_TEXT_LOG", item.LastWriteTime.ToString("yyyyMMdd")); 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.ToString()); } return sRetData; } #endregion #region 상태값 문자 변환 /// /// 상태값 문자 변환 /// /// /// private string ConvertSetDeviceStatus(string sData) { string sRetData = string.Empty; try { if (sData == "" || sData == UserCom.RST_IGNORE) //사용 안함 { sRetData = "NO"; } else if (sData == UserCom.RST_OK) //정상 { sRetData = "OK"; } else //그외 에러 { sRetData = "NG"; } } 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.ToString()); } return sRetData; } #endregion #region POS SYSTEM INFO /// /// POS SYSTEM INFO /// /// private string GetPosSystem() { string sRetData = string.Empty; string retVal = string.Empty; StringBuilder sbVer = null; try { if (m_cICReader != null) { m_sWmiClass = "POS_SYSTEM_INFO"; //여전법 인증 번호 sRetData += DataFormat(m_sWmiClass, "AUTH_SOFTWARE_VER", CmUtil.MidH(m_cPosStatus.Base.Auth_POS_SW_Ver.ToString(), 0, 16)); //IC리더기 sbVer = m_cICReader.SetAuthInfoString(PosConst.POS_CARD_READER_DEVICE_TYPE.IC_READER); if (sbVer.ToString() != "") sRetData += DataFormat(m_sWmiClass, "AUTH_ICREADER_VER", CmUtil.MidH(sbVer.ToString(), 0, 16)); //사인패드 sbVer = m_cICReader.SetAuthInfoString(PosConst.POS_CARD_READER_DEVICE_TYPE.SAIGNPAD); if (sbVer.ToString() != "") sRetData += DataFormat(m_sWmiClass, "AUTH_SIGNPAD_VER", CmUtil.MidH(sbVer.ToString(), 0, 16)); } } 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.ToString()); } return sRetData; } #endregion #region 캠페인마스터 정보(2017.06.21) /// /// 캠페인마스터 정보 /// /// private string GetCpiMstData() { string sRetData = string.Empty; string sQuery = string.Empty; try { m_sWmiClass = "MST_CPI"; IMasterUs m_cMstService = (IMasterUs)sManager.InitServiceInstance(ServiceLists.ASV_MASTER.DLL, ServiceLists.ASV_MASTER.POS_MASTER); if (m_cMstService == null) return ""; // 캠페인 마스터 sQuery = " SELECT * FROM POSMST..MST_CPI WITH(NOLOCK) "; sQuery += " WHERE CMP_CD = '" + m_cPosStatus.Base.CmpCd + "'"; sQuery += " AND STOR_CD = '" + m_cPosStatus.Base.StoreNo + "'"; sQuery += " AND '" + DateTime.Now.ToString("yyyyMMdd") + "' BETWEEN STARTDAY AND FNSHDAY "; sQuery += " AND PRGRS_STATUS = 'C'"; sQuery += " AND USE_YN = '" + PosConst.MST_USE_YN.YES + "'"; //sQuery += " ORDER BY CPI_CD "; DataTable dtMstCpi = m_cMstService.Select(new string[] { sQuery }); if (dtMstCpi == null || dtMstCpi.Rows.Count <= 0) return ""; foreach (DataRow dr in dtMstCpi.Rows) { // 캠페인 코드 설정 sRetData += DataFormat(m_sWmiClass, CmUtil.GetDataRowStr(dr, PosMst.MST_CPI.DATA.CPI_CD), ""); } } 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.ToString()); } return sRetData; } #endregion //#20180322 포스스팩에 REAL IP, ISP 추가 start #region REAL IP, ISP /// /// REAL IP, ISP 정보 /// /// private string Get_IP_ISP() { string sRetData = string.Empty; string sQuery = string.Empty; try { string url = "http://ipinfo.io/json"; System.Net.WebRequest req = System.Net.WebRequest.Create(url); System.Net.WebResponse resp = req.GetResponse(); System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream()); string response = sr.ReadToEnd().Trim(); JObject jo = JObject.Parse(response); string sRealIP = jo["ip"].ToString(); string sISP = jo["org"].ToString(); m_sWmiClass = "NETWORK"; sRetData += DataFormat(m_sWmiClass, "REALIP", sRealIP); sRetData += DataFormat(m_sWmiClass, "ISP", sISP); } 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.ToString()); } return sRetData; } #endregion //#20180322 포스스팩에 REAL IP, ISP 추가 end //#20180710 Real OS 가져오기 start #region Real OS 가져오기 private string GetRealOS() { string sRetData = string.Empty; string retVal = string.Empty; try { #region 또다른방법 /* OperatingSystem OS = Environment.OSVersion; string sWinName = string.Empty; switch (OS.Platform) { case PlatformID.Win32Windows: if (OS.Version.Major == 4) { switch (OS.Version.Minor) { case 0: sWinName = "Windows 95"; break; case 10: sWinName = "Windows 98"; break; case 90: sWinName = "Window Me"; break; } } break; case PlatformID.Win32NT: if (OS.Version.Major == 4) { switch (OS.Version.Minor) { case 0: sWinName = "Windows NT 4.0"; break; } } else if (OS.Version.Major == 5) { switch (OS.Version.Minor) { case 0: sWinName = "Windows 2000"; break; case 1: sWinName = "Windows XP"; break; case 2: sWinName = "Window Server 2003"; break; } } else if (OS.Version.Major == 6) { switch (OS.Version.Minor) { case 0: sWinName = "Windows Vista"; break; } } break; } */ #endregion #region 구포스방법 m_sWmiClass = "OS"; string strTempXPEmbedded = "SYSTEM\\WPA\\EMBEDDED"; string strTempEBStandard2009 = "SYSTEM\\WPA\\WES"; string strTempEMPOSReady2009 = "SYSTEM\\WPA\\POSREADY"; string strTempWEPOS = "SYSTEM\\WPA\\WEPOS"; OperatingSystem OS = Environment.OSVersion; UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "▶ Platform :" + OS.Platform.ToString() + ", Version Major :" + OS.Version.Major + ", OS ServicePack :" + OS.ServicePack + ", OS Version :" + OS.Version + ", OS VersionString :" + OS.VersionString); // xp 계열 if (OS.Platform == PlatformID.Win32NT && OS.Version.Major == 5) { //1. Windows XP Embedded Microsoft.Win32.RegistryKey rgTempXPEmbedded = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(strTempXPEmbedded, Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree); // if (rgTempXPEmbedded != null) { retVal = "Windows XP Embedded " + OS.ServicePack; } //2. Windows Embedded Standard 2009 Microsoft.Win32.RegistryKey rgTempEBStandard2009 = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(strTempEBStandard2009, Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree); //Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree if (rgTempEBStandard2009 != null) { retVal = "Windows Embedded Standard 2009 " + OS.ServicePack; } //3. Windows Embedded POSReady 2009 Microsoft.Win32.RegistryKey rgTempEMPOSReady2009 = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(strTempEMPOSReady2009, Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree); //Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree if (rgTempEMPOSReady2009 != null) { retVal = "Windows Embedded POSReady 2009 " + OS.ServicePack; } //4. Windows Embedded for Point of Service(WEPOS) Microsoft.Win32.RegistryKey rgTempWEPOS = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(strTempWEPOS, Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree); //Microsoft.Win32.RegistryKeyPermissionCheck.ReadWriteSubTree if (rgTempWEPOS != null) { retVal = "Windows Embedded for Point of Service " + OS.ServicePack; } UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "▶ XP - GetRealOS :" + retVal); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "Real_OS", retVal); retVal = ""; } } else { m_sWmiClass = "OS"; m_sWin32Product = "Win32_OperatingSystem"; string sCaption = ""; string sCSDVersion = ""; sCaption = identifier(m_sWin32Product, "Caption"); sCSDVersion = identifier(m_sWin32Product, "CSDVersion"); retVal = sCaption + sCSDVersion; UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "▶ 7 - GetRealOS :" + retVal); if (retVal != "") { sRetData += DataFormat(m_sWmiClass, "Real_OS", retVal); retVal = ""; } } #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 + "()", ex.ToString()); } return sRetData; } #endregion Real OS 가져오기 //#20180710 Real OS 가져오기 end //#20180710 LOCAL IP 가져오기 start #region Local IP private string GetLocalIP() { string myIP = ""; string strHostName = ""; string sRetData = string.Empty; try { m_sWmiClass = "NETWORK"; strHostName = System.Net.Dns.GetHostName(); IPHostEntry ipEntry = System.Net.Dns.GetHostEntry(strHostName); foreach (IPAddress ipAddress in ipEntry.AddressList) { if (ipAddress.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork) { myIP = ipAddress.ToString(); } } sRetData += DataFormat(m_sWmiClass, "LOCAL_IP", myIP); UserLog.WriteLogFile(UserCom.LOG_IOS, System.Reflection.Assembly.GetExecutingAssembly().ManifestModule.Name, System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name + "." + System.Reflection.MethodBase.GetCurrentMethod().Name + "()", "▶ LOCAL_IP :" + myIP); } 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.ToString()); } return sRetData; } #endregion //#20180710 LOCAL IP 가져오기 end } }