From 1ebbb83866459bcf7b71fe55b905d97f5cc09b6c Mon Sep 17 00:00:00 2001 From: ChiKyun Kim Date: Sun, 28 Sep 2025 14:43:00 +0900 Subject: [PATCH] =?UTF-8?q?offline=20=EB=AA=A8=EB=93=9C=EC=97=90=EC=84=9C?= =?UTF-8?q?=20ip/mac=20=EC=A1=B0=ED=9A=8C=ED=95=98=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=ED=95=A8.=20ip=EA=B0=80=20=EC=97=86=EC=9C=BC=EB=A9=B4=20reel?= =?UTF-8?q?=20generate=20=EA=B0=80=20=EB=8F=99=EC=9E=91=ED=95=98=EC=A7=80?= =?UTF-8?q?=20=EC=95=8A=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Project/Properties/Settings.Designer.cs | 2 +- Handler/Project/Properties/Settings.settings | 6 +- Handler/Project/Pub.cs | 106 +++++++++++------- Handler/Project/RunCode/Step/_STEP_INIT.cs | 2 +- Handler/Project/fMain.cs | 1 + 5 files changed, 69 insertions(+), 48 deletions(-) diff --git a/Handler/Project/Properties/Settings.Designer.cs b/Handler/Project/Properties/Settings.Designer.cs index 11194ae..55037b1 100644 --- a/Handler/Project/Properties/Settings.Designer.cs +++ b/Handler/Project/Properties/Settings.Designer.cs @@ -12,7 +12,7 @@ namespace Project.Properties { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")] internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); diff --git a/Handler/Project/Properties/Settings.settings b/Handler/Project/Properties/Settings.settings index f3b2dc5..739b7c7 100644 --- a/Handler/Project/Properties/Settings.settings +++ b/Handler/Project/Properties/Settings.settings @@ -16,7 +16,7 @@ <?xml version="1.0" encoding="utf-16"?> -<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +<SerializableConnectionString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ConnectionString>Data Source=10.201.11.21,50150;Initial Catalog=WMS;Persist Security Info=True;User ID=wmsadm;Password=78#4AmWnh1!!;Encrypt=False;TrustServerCertificate=True</ConnectionString> <ProviderName>System.Data.SqlClient</ProviderName> </SerializableConnectionString> @@ -24,7 +24,7 @@ <?xml version="1.0" encoding="utf-16"?> -<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +<SerializableConnectionString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ConnectionString>Data Source=10.201.11.21,50150;Initial Catalog=WMS;Persist Security Info=True;User ID=wmsadm;Password=78#4AmWnh1!!;Encrypt=False;TrustServerCertificate=True</ConnectionString> <ProviderName>System.Data.SqlClient</ProviderName> </SerializableConnectionString> @@ -32,7 +32,7 @@ <?xml version="1.0" encoding="utf-16"?> -<SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> +<SerializableConnectionString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ConnectionString>Data Source=V1SPCSQL,51122;Initial Catalog=WMS;Persist Security Info=True;User ID=wmsadm;Password="2!x2$yY8R;}$";Encrypt=False;TrustServerCertificate=True</ConnectionString> <ProviderName>System.Data.SqlClient</ProviderName> </SerializableConnectionString> diff --git a/Handler/Project/Pub.cs b/Handler/Project/Pub.cs index 74ef380..2893086 100644 --- a/Handler/Project/Pub.cs +++ b/Handler/Project/Pub.cs @@ -1,6 +1,7 @@ using AR; using Emgu.CV.BgSegm; using System; +using System.CodeDom; using System.Collections.Generic; using System.Data; using System.Data.SqlClient; @@ -1097,7 +1098,7 @@ namespace Project public static void initCore() { - system_mot = new System_MotParameter(UTIL.MakePath("Data","System_mot.xml")); + system_mot = new System_MotParameter(UTIL.MakePath("Data", "System_mot.xml")); system_mot.Load(); //setting @@ -1122,7 +1123,7 @@ namespace Project //zpl파일 만든다. var fn = Path.Combine(UTIL.CurrentPath, "Data", "zpl.txt"); - // i// File.WriteAllText(fn, Properties.Settings.Default.ZPL7, Encoding.Default); + // i// File.WriteAllText(fn, Properties.Settings.Default.ZPL7, Encoding.Default); } static void popup_WindowOpen(object sender, EventArgs e) @@ -1239,6 +1240,54 @@ namespace Project public static string IP { get; set; } public static string MAC { get; set; } + public static string HOSTNAME { get; set; } + + public static void GetIPMac() + { + string ip = ""; + string mac = ""; + try + { + var nif = NetworkInterface.GetAllNetworkInterfaces(); + var host = Dns.GetHostEntry(Dns.GetHostName()); + HOSTNAME = System.Net.Dns.GetHostEntry("").HostName; + foreach (IPAddress r in host.AddressList) + { + string str = r.ToString(); + + if (str != "" && str.Substring(0, 3) == "10.") + { + ip = str; + break; + } + } + + string rtn = string.Empty; + ObjectQuery oq = new System.Management.ObjectQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled='TRUE'"); + ManagementObjectSearcher query1 = new ManagementObjectSearcher(oq); + foreach (ManagementObject mo in query1.Get()) + { + string[] address = (string[])mo["IPAddress"]; + if (address[0] == ip && mo["MACAddress"] != null) + { + mac = mo["MACAddress"].ToString(); + break; + } + } + + } + catch (Exception ex) + { + ip = ""; + mac = ""; + } + + IP = ip; + MAC = mac; + + + + } /// /// 프로그램 사용기록 추가 @@ -1251,46 +1300,17 @@ namespace Project if (prgmName.Length > 50) prgmName = prgmName.Substring(0, 50); //길이제한 var task = Task.Factory.StartNew(() => { + GetIPMac(); try { - string ip = ""; - string mac = ""; - // string prgmName = Application.ProductName; - - var nif = NetworkInterface.GetAllNetworkInterfaces(); - var host = Dns.GetHostEntry(Dns.GetHostName()); - string fullname = System.Net.Dns.GetHostEntry("").HostName; - foreach (IPAddress r in host.AddressList) - { - string str = r.ToString(); - - if (str != "" && str.Substring(0, 3) == "10.") - { - ip = str; - break; - } - } - - string rtn = string.Empty; - ObjectQuery oq = new System.Management.ObjectQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled='TRUE'"); - ManagementObjectSearcher query1 = new ManagementObjectSearcher(oq); - foreach (ManagementObject mo in query1.Get()) - { - string[] address = (string[])mo["IPAddress"]; - if (address[0] == ip && mo["MACAddress"] != null) - { - mac = mo["MACAddress"].ToString(); - break; - } - } - - if (ip == "" || mac == "") + + if (IP == "" || MAC == "") { return; } - SqlConnection conn = new SqlConnection("Data Source=10.131.15.18;Initial Catalog=EE;Persist Security Info=True;User ID=eeuser;Password=Amkor123!"); + SqlConnection conn = new SqlConnection("Data Source=K4FASQL.kr.ds.amkor.com,50150;Initial Catalog=EE;Persist Security Info=True;User ID=eeadm;Password=uJnU8a8q&DJ+ug-D"); conn.Open(); string ProcName = "AddPrgmUser3"; SqlCommand cmd = new SqlCommand(ProcName, conn) @@ -1299,10 +1319,10 @@ namespace Project }; SqlParameter param = cmd.Parameters.Add("@mac", SqlDbType.NVarChar, 50); - param.Value = mac; + param.Value = MAC; param = cmd.Parameters.Add("@ip", SqlDbType.NVarChar, 50); - param.Value = ip; + param.Value = IP; param = cmd.Parameters.Add("@pgrm", SqlDbType.NVarChar, 50); param.Value = prgmName; @@ -1320,13 +1340,12 @@ namespace Project param.Value = System.Environment.UserName; param = cmd.Parameters.Add("@hostname", SqlDbType.NVarChar, 100); - param.Value = fullname; + param.Value = HOSTNAME; cmd.ExecuteNonQuery(); conn.Close(); - IP = ip; - MAC = mac; + } catch (Exception ex) { @@ -1644,11 +1663,12 @@ namespace Project string NewID = string.Empty; string Message = string.Empty; + var ip = PUB.IP ?? "127.0.0.1"; var retval = ta.X_SP_GET_UNIT_ID_LABEL(SETTING.Data.WMS_PROGRAM_ID, SETTING.Data.WMS_CENTER_CD, sid, SETTING.Data.WMS_REG_USERID, - PUB.IP, + ip, ref NewID, ref Message); @@ -1795,7 +1815,7 @@ namespace Project case eECode.VISCONF: description = "Vision configuration error\nPlease check vision system settings"; break; - + case eECode.PRINTER: description = "Printer error\nPlease check the printer connection and status\n{0}"; break; @@ -1808,7 +1828,7 @@ namespace Project case eECode.MOTX_SAFETY: description = "Motion X-axis safety error\nSafety condition violated for X-axis movement"; break; - + default: description = $"Unknown error code: {err}\n{{0}}"; break; diff --git a/Handler/Project/RunCode/Step/_STEP_INIT.cs b/Handler/Project/RunCode/Step/_STEP_INIT.cs index 02e45b0..ae18dea 100644 --- a/Handler/Project/RunCode/Step/_STEP_INIT.cs +++ b/Handler/Project/RunCode/Step/_STEP_INIT.cs @@ -95,7 +95,7 @@ namespace Project // if (SETTING.User.LastModelV != "") PUB.SelectModelV(SETTING.User.LastModelV, false); var motionmodel = SETTING.User.LastModelM; - if (motionmodel.isEmpty()) motionmodel = PUB.Result.vModel.Motion; + if (motionmodel.isEmpty()) motionmodel = PUB.Result.vModel.Motion ?? string.Empty; if (motionmodel.ToUpper().StartsWith("CONV")) PUB.flag.set(eVarBool.Use_Conveyor, true, "load"); else PUB.flag.set(eVarBool.Use_Conveyor, false, "load"); PUB.SelectModelM(motionmodel, false); diff --git a/Handler/Project/fMain.cs b/Handler/Project/fMain.cs index 15f39ae..51c4150 100644 --- a/Handler/Project/fMain.cs +++ b/Handler/Project/fMain.cs @@ -451,6 +451,7 @@ namespace Project PUB.log.Add("Program Start"); if (SETTING.Data.OnlineMode) PUB.CheckNRegister3(Application.ProductName, "chi", Application.ProductVersion); + else PUB.GetIPMac(); if (SETTING.Data.EnableDebugMode) {