From 9ca96199d92168fe221dda9aba56f55520a561d8 Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期二, 29 十月 2024 17:30:59 +0800 Subject: [PATCH] 1 --- WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzExtensions/QuartzJobHostedService.cs | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-) diff --git a/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzExtensions/QuartzJobHostedService.cs b/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzExtensions/QuartzJobHostedService.cs index b554eeb..31ef5bb 100644 --- a/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzExtensions/QuartzJobHostedService.cs +++ b/WIDESEAWCS_Server/WIDESEAWCS_QuartzJob/QuartzExtensions/QuartzJobHostedService.cs @@ -68,10 +68,10 @@ { #region 杩炴帴PLC Assembly assembly = Assembly.Load($"WIDESEAWCS_Communicator"); - Type type = assembly.GetType($"WIDESEAWCS_Communicator.{x.DevicePlcType}"); - object obj = Activator.CreateInstance(type, new object[] { x.DeviceIp, x.DevicePort, x.DeviceName }); - bool connectResult = (bool)type.InvokeMember("Connect", BindingFlags.Default | BindingFlags.InvokeMethod, null, obj, new object[] { }); - if (connectResult) ConsoleHelper.WriteSuccessLine(x.DeviceCode + "杩炴帴鎴愬姛"); else ConsoleHelper.WriteErrorLine(x.DeviceCode + "杩炴帴澶辫触"); + Type? type = assembly.GetType($"WIDESEAWCS_Communicator.{x.DevicePlcType}"); + object? obj = Activator.CreateInstance(type, new object[] { x.DeviceIp, x.DevicePort, x.DeviceName }); + bool? connectResult = (bool)type.InvokeMember("Connect", BindingFlags.Default | BindingFlags.InvokeMethod, null, obj, new object[] { }); + if (connectResult ?? false) ConsoleHelper.WriteSuccessLine(x.DeviceCode + "杩炴帴鎴愬姛"); else ConsoleHelper.WriteErrorLine(x.DeviceCode + "杩炴帴澶辫触"); #endregion @@ -89,6 +89,7 @@ DeviceProParamDes = d.DeviceProParamDes, DeviceProParamName = d.DeviceProParamName, DeviceProParamType = d.DeviceProParamType, + DevicePlcType = x.DevicePlcType }).ToList(); List<DeviceProtocolDetailDTO> deviceProtocolDetails = _deviceProtocolDetailService.GetDeviceProtocolDetailsByDeviceType(x.DeviceType); -- Gitblit v1.9.3