offline 모드에서 ip/mac 조회하도록 함. ip가 없으면 reel generate 가 동작하지 않음

This commit is contained in:
ChiKyun Kim
2025-09-28 14:43:00 +09:00
parent 16da4a5ffa
commit 1ebbb83866
5 changed files with 69 additions and 48 deletions

View File

@@ -12,7 +12,7 @@ namespace Project.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] [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 { internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));

View File

@@ -16,7 +16,7 @@
</Setting> </Setting>
<Setting Name="CS" Type="(Connection string)" Scope="Application"> <Setting Name="CS" Type="(Connection string)" Scope="Application">
<DesignTimeValue Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt; <DesignTimeValue Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;SerializableConnectionString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
&lt;ConnectionString&gt;Data Source=10.201.11.21,50150;Initial Catalog=WMS;Persist Security Info=True;User ID=wmsadm;Password=78#4AmWnh1!!;Encrypt=False;TrustServerCertificate=True&lt;/ConnectionString&gt; &lt;ConnectionString&gt;Data Source=10.201.11.21,50150;Initial Catalog=WMS;Persist Security Info=True;User ID=wmsadm;Password=78#4AmWnh1!!;Encrypt=False;TrustServerCertificate=True&lt;/ConnectionString&gt;
&lt;ProviderName&gt;System.Data.SqlClient&lt;/ProviderName&gt; &lt;ProviderName&gt;System.Data.SqlClient&lt;/ProviderName&gt;
&lt;/SerializableConnectionString&gt;</DesignTimeValue> &lt;/SerializableConnectionString&gt;</DesignTimeValue>
@@ -24,7 +24,7 @@
</Setting> </Setting>
<Setting Name="WMS_DEV" Type="(Connection string)" Scope="Application"> <Setting Name="WMS_DEV" Type="(Connection string)" Scope="Application">
<DesignTimeValue Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt; <DesignTimeValue Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;SerializableConnectionString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
&lt;ConnectionString&gt;Data Source=10.201.11.21,50150;Initial Catalog=WMS;Persist Security Info=True;User ID=wmsadm;Password=78#4AmWnh1!!;Encrypt=False;TrustServerCertificate=True&lt;/ConnectionString&gt; &lt;ConnectionString&gt;Data Source=10.201.11.21,50150;Initial Catalog=WMS;Persist Security Info=True;User ID=wmsadm;Password=78#4AmWnh1!!;Encrypt=False;TrustServerCertificate=True&lt;/ConnectionString&gt;
&lt;ProviderName&gt;System.Data.SqlClient&lt;/ProviderName&gt; &lt;ProviderName&gt;System.Data.SqlClient&lt;/ProviderName&gt;
&lt;/SerializableConnectionString&gt;</DesignTimeValue> &lt;/SerializableConnectionString&gt;</DesignTimeValue>
@@ -32,7 +32,7 @@
</Setting> </Setting>
<Setting Name="WMS_PRD" Type="(Connection string)" Scope="Application"> <Setting Name="WMS_PRD" Type="(Connection string)" Scope="Application">
<DesignTimeValue Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt; <DesignTimeValue Profile="(Default)">&lt;?xml version="1.0" encoding="utf-16"?&gt;
&lt;SerializableConnectionString xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; &lt;SerializableConnectionString xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
&lt;ConnectionString&gt;Data Source=V1SPCSQL,51122;Initial Catalog=WMS;Persist Security Info=True;User ID=wmsadm;Password="2!x2$yY8R;}$";Encrypt=False;TrustServerCertificate=True&lt;/ConnectionString&gt; &lt;ConnectionString&gt;Data Source=V1SPCSQL,51122;Initial Catalog=WMS;Persist Security Info=True;User ID=wmsadm;Password="2!x2$yY8R;}$";Encrypt=False;TrustServerCertificate=True&lt;/ConnectionString&gt;
&lt;ProviderName&gt;System.Data.SqlClient&lt;/ProviderName&gt; &lt;ProviderName&gt;System.Data.SqlClient&lt;/ProviderName&gt;
&lt;/SerializableConnectionString&gt;</DesignTimeValue> &lt;/SerializableConnectionString&gt;</DesignTimeValue>

View File

@@ -1,6 +1,7 @@
using AR; using AR;
using Emgu.CV.BgSegm; using Emgu.CV.BgSegm;
using System; using System;
using System.CodeDom;
using System.Collections.Generic; using System.Collections.Generic;
using System.Data; using System.Data;
using System.Data.SqlClient; using System.Data.SqlClient;
@@ -1097,7 +1098,7 @@ namespace Project
public static void initCore() 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(); system_mot.Load();
//setting //setting
@@ -1122,7 +1123,7 @@ namespace Project
//zpl파일 만든다. //zpl파일 만든다.
var fn = Path.Combine(UTIL.CurrentPath, "Data", "zpl.txt"); 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) static void popup_WindowOpen(object sender, EventArgs e)
@@ -1239,6 +1240,54 @@ namespace Project
public static string IP { get; set; } public static string IP { get; set; }
public static string MAC { 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;
}
/// <summary> /// <summary>
/// 프로그램 사용기록 추가 /// 프로그램 사용기록 추가
@@ -1251,46 +1300,17 @@ namespace Project
if (prgmName.Length > 50) prgmName = prgmName.Substring(0, 50); //길이제한 if (prgmName.Length > 50) prgmName = prgmName.Substring(0, 50); //길이제한
var task = Task.Factory.StartNew(() => var task = Task.Factory.StartNew(() =>
{ {
GetIPMac();
try try
{ {
string ip = "";
string mac = ""; if (IP == "" || 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 == "")
{ {
return; 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(); conn.Open();
string ProcName = "AddPrgmUser3"; string ProcName = "AddPrgmUser3";
SqlCommand cmd = new SqlCommand(ProcName, conn) SqlCommand cmd = new SqlCommand(ProcName, conn)
@@ -1299,10 +1319,10 @@ namespace Project
}; };
SqlParameter param = cmd.Parameters.Add("@mac", SqlDbType.NVarChar, 50); SqlParameter param = cmd.Parameters.Add("@mac", SqlDbType.NVarChar, 50);
param.Value = mac; param.Value = MAC;
param = cmd.Parameters.Add("@ip", SqlDbType.NVarChar, 50); param = cmd.Parameters.Add("@ip", SqlDbType.NVarChar, 50);
param.Value = ip; param.Value = IP;
param = cmd.Parameters.Add("@pgrm", SqlDbType.NVarChar, 50); param = cmd.Parameters.Add("@pgrm", SqlDbType.NVarChar, 50);
param.Value = prgmName; param.Value = prgmName;
@@ -1320,13 +1340,12 @@ namespace Project
param.Value = System.Environment.UserName; param.Value = System.Environment.UserName;
param = cmd.Parameters.Add("@hostname", SqlDbType.NVarChar, 100); param = cmd.Parameters.Add("@hostname", SqlDbType.NVarChar, 100);
param.Value = fullname; param.Value = HOSTNAME;
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
conn.Close(); conn.Close();
IP = ip;
MAC = mac;
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -1644,11 +1663,12 @@ namespace Project
string NewID = string.Empty; string NewID = string.Empty;
string Message = 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, var retval = ta.X_SP_GET_UNIT_ID_LABEL(SETTING.Data.WMS_PROGRAM_ID,
SETTING.Data.WMS_CENTER_CD, sid, SETTING.Data.WMS_CENTER_CD, sid,
SETTING.Data.WMS_REG_USERID, SETTING.Data.WMS_REG_USERID,
PUB.IP, ip,
ref NewID, ref NewID,
ref Message); ref Message);
@@ -1795,7 +1815,7 @@ namespace Project
case eECode.VISCONF: case eECode.VISCONF:
description = "Vision configuration error\nPlease check vision system settings"; description = "Vision configuration error\nPlease check vision system settings";
break; break;
case eECode.PRINTER: case eECode.PRINTER:
description = "Printer error\nPlease check the printer connection and status\n{0}"; description = "Printer error\nPlease check the printer connection and status\n{0}";
break; break;
@@ -1808,7 +1828,7 @@ namespace Project
case eECode.MOTX_SAFETY: case eECode.MOTX_SAFETY:
description = "Motion X-axis safety error\nSafety condition violated for X-axis movement"; description = "Motion X-axis safety error\nSafety condition violated for X-axis movement";
break; break;
default: default:
description = $"Unknown error code: {err}\n{{0}}"; description = $"Unknown error code: {err}\n{{0}}";
break; break;

View File

@@ -95,7 +95,7 @@ namespace Project
// //
if (SETTING.User.LastModelV != "") PUB.SelectModelV(SETTING.User.LastModelV, false); if (SETTING.User.LastModelV != "") PUB.SelectModelV(SETTING.User.LastModelV, false);
var motionmodel = SETTING.User.LastModelM; 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"); if (motionmodel.ToUpper().StartsWith("CONV")) PUB.flag.set(eVarBool.Use_Conveyor, true, "load");
else PUB.flag.set(eVarBool.Use_Conveyor, false, "load"); else PUB.flag.set(eVarBool.Use_Conveyor, false, "load");
PUB.SelectModelM(motionmodel, false); PUB.SelectModelM(motionmodel, false);

View File

@@ -451,6 +451,7 @@ namespace Project
PUB.log.Add("Program Start"); PUB.log.Add("Program Start");
if (SETTING.Data.OnlineMode) if (SETTING.Data.OnlineMode)
PUB.CheckNRegister3(Application.ProductName, "chi", Application.ProductVersion); PUB.CheckNRegister3(Application.ProductName, "chi", Application.ProductVersion);
else PUB.GetIPMac();
if (SETTING.Data.EnableDebugMode) if (SETTING.Data.EnableDebugMode)
{ {