diff --git a/shangjian/.vs/BL/v17/.suo b/shangjian/.vs/BL/v17/.suo index 3ad06e2..6e364c0 100644 Binary files a/shangjian/.vs/BL/v17/.suo and b/shangjian/.vs/BL/v17/.suo differ diff --git a/shangjian/CentralControl/bin/Debug/CentralControl.exe b/shangjian/CentralControl/bin/Debug/CentralControl.exe index 9aa4d82..c6ce999 100644 Binary files a/shangjian/CentralControl/bin/Debug/CentralControl.exe and b/shangjian/CentralControl/bin/Debug/CentralControl.exe differ diff --git a/shangjian/CentralControl/bin/Debug/CentralControl.pdb b/shangjian/CentralControl/bin/Debug/CentralControl.pdb index afb30a2..cba0962 100644 Binary files a/shangjian/CentralControl/bin/Debug/CentralControl.pdb and b/shangjian/CentralControl/bin/Debug/CentralControl.pdb differ diff --git a/shangjian/CentralControl/bin/Debug/XGL.Data.dll b/shangjian/CentralControl/bin/Debug/XGL.Data.dll index a01740a..0c69d61 100644 Binary files a/shangjian/CentralControl/bin/Debug/XGL.Data.dll and b/shangjian/CentralControl/bin/Debug/XGL.Data.dll differ diff --git a/shangjian/CentralControl/bin/Debug/XGL.Data.pdb b/shangjian/CentralControl/bin/Debug/XGL.Data.pdb index f0809a6..45ec895 100644 Binary files a/shangjian/CentralControl/bin/Debug/XGL.Data.pdb and b/shangjian/CentralControl/bin/Debug/XGL.Data.pdb differ diff --git a/shangjian/CentralControl/obj/Debug/CentralControl.csproj.AssemblyReference.cache b/shangjian/CentralControl/obj/Debug/CentralControl.csproj.AssemblyReference.cache index ed78be8..748a3ee 100644 Binary files a/shangjian/CentralControl/obj/Debug/CentralControl.csproj.AssemblyReference.cache and b/shangjian/CentralControl/obj/Debug/CentralControl.csproj.AssemblyReference.cache differ diff --git a/shangjian/CentralControl/obj/Debug/CentralControl.exe b/shangjian/CentralControl/obj/Debug/CentralControl.exe index 9aa4d82..c6ce999 100644 Binary files a/shangjian/CentralControl/obj/Debug/CentralControl.exe and b/shangjian/CentralControl/obj/Debug/CentralControl.exe differ diff --git a/shangjian/CentralControl/obj/Debug/CentralControl.pdb b/shangjian/CentralControl/obj/Debug/CentralControl.pdb index afb30a2..cba0962 100644 Binary files a/shangjian/CentralControl/obj/Debug/CentralControl.pdb and b/shangjian/CentralControl/obj/Debug/CentralControl.pdb differ diff --git a/shangjian/XGL.Data/DBService/FormingMachineService.cs b/shangjian/XGL.Data/DBService/FormingMachineService.cs index 36d24e4..bc08dd1 100644 --- a/shangjian/XGL.Data/DBService/FormingMachineService.cs +++ b/shangjian/XGL.Data/DBService/FormingMachineService.cs @@ -142,7 +142,7 @@ namespace XGL.Data.DBService public DataTable GetFormingMachineState(string devicecode) { - string sql = $@"select status from base_equipment where equipment_code = '{devicecode}'; "; + string sql = $@"select status,plc_ip from base_equipment where equipment_code = '{devicecode}'; "; DataSet dtset = Utils.netClientDBHelper.getDataSet(sql); if (dtset != null && dtset.Tables.Count > 0 && dtset.Tables[0].Rows.Count > 0) @@ -537,11 +537,13 @@ VALUES return sqlList;//> 0 ? true : false; } - public void ChangeShiftsInfo() + public bool ChangeShiftsInfo() { // string sql = $@"INSERT INTO [dbo].[mes_changeshift_info] ([id], [shift_code], [change_time], [create_time], [create_by], [last_update], [update_by], [work_date]) - VALUES ('1', NULL, NULL, NULL, NULL, NULL, NULL, NULL);"; + VALUES ('{Common.GetUUID()}', '{LoginUser.ShiftCode}', GetDate(), GetDate(), '{LoginUser.UserName}', GetDate(), '{LoginUser.UserName}', '{LoginUser.WorkDate}');"; + int ret = Utils.netClientDBHelper.executeUpdate(sql); + return ret > 0 ? true : false; } diff --git a/shangjian/XGL/App.config b/shangjian/XGL/App.config index 872a6c6..0f4164b 100644 --- a/shangjian/XGL/App.config +++ b/shangjian/XGL/App.config @@ -12,7 +12,7 @@ - + diff --git a/shangjian/XGL/FormItem/Main.xaml.cs b/shangjian/XGL/FormItem/Main.xaml.cs index 5e2badc..a2a8f99 100644 --- a/shangjian/XGL/FormItem/Main.xaml.cs +++ b/shangjian/XGL/FormItem/Main.xaml.cs @@ -81,7 +81,7 @@ namespace XGL.FormItem this.myTb.SetBinding(TextBlock.TextProperty, textBinding); InitPage(); - GetServiceDelay(Utils.GetServerIP()); + GetServiceDelay(Utils.GetServerIP()); } private void InitPage() @@ -177,6 +177,9 @@ namespace XGL.FormItem timerDeciveState.Elapsed += TimerDeciveState_Elapsed; timerDeciveState.Start(); this.lbVersion.Content = LoginUser.Version; + FormingMachineService formingMachineService = new FormingMachineService(); + DataTable dtDeviceIP = formingMachineService.GetFormingMachineState(deviceCode); + GetDevicePingResult(dtDeviceIP.Rows[0][1].ToString()); } @@ -243,6 +246,59 @@ namespace XGL.FormItem }, 1, 0, 2000); } + public void GetDevicePingResult(string serviceIp) + { + Time = new System.Threading.Timer((s) => + { + try + { + PingTest(serviceIp); + } + catch (Exception) + { + + } + }, 1, 0, 2000); + } + + + static void PingTest(string ip) + { + string ipAddress = ip;//"192.168.1.1"; // 你要 ping 的 IP 地址 + + Ping pingSender = new Ping(); + PingOptions options = new PingOptions(); + + options.DontFragment = true; + + string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + byte[] buffer = System.Text.Encoding.ASCII.GetBytes(data); + int timeout = 120; + + while (true) + { + PingReply reply = pingSender.Send(ipAddress, timeout, buffer, options); + if (reply.Status != IPStatus.Success) + { + // 记录日志 + string logMessage = $"Ping failed to {ipAddress} at {DateTime.Now}. Reason: {reply.Status}"; + //WriteToLogFile(logMessage); + LogHelper.instance.log.Error(logMessage); + + // 这里你可以添加其他处理逻辑,或者退出循环 + // break; + } + else + { + Console.WriteLine($"Ping successful to {ipAddress}. Reply time: {reply.RoundtripTime}ms"); + } + + // 可以设定一个间隔时间,然后再次 ping + //System.Threading.Thread.Sleep(5000); // 5 秒 + } + } + + SerialHelper serialHelper = new SerialHelper(); int time = 0; private void TimerDeciveState_Elapsed(object sender, ElapsedEventArgs e)