change - 激活码激活Hsl模块

pull/6/head
wenjy 8 months ago
parent 0164b9529d
commit 068a66e70a

@ -48,34 +48,47 @@ namespace SlnMesnac.Extensions
try try
{ {
if (appConfig.plcConfig != null) do
{ {
foreach (var item in appConfig.plcConfig) if (!HslCommunication.Authorization.SetAuthorizationCode("1839541f-8fb4-42c4-a13f-733b027fe5af"))
{ {
if (item.isFlage) Log.Information("HslCommunication激活失败可用时长为24小时");
{ break;
PlcAbsractFactory _plc = InitPlc(x, item.plcType); }
else
{
Log.Information("HslCommunication激活成功");
}
var connectResult = _plc.Connect(item.plcIp, item.plcPort); if (appConfig.plcConfig != null)
if (connectResult) {
foreach (var item in appConfig.plcConfig)
{
if (item.isFlage)
{ {
Log.Information($"PLC{item.plcIp}:{item.plcPort};连接成功,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}"); PlcAbsractFactory _plc = InitPlc(x, item.plcType);
_plc.ConfigKey = item.plcKey;
if(absractFactories.Contains(_plc)) var connectResult = _plc.Connect(item.plcIp, item.plcPort);
if (connectResult)
{ {
absractFactories.Remove(_plc); Log.Information($"PLC{item.plcIp}:{item.plcPort};连接成功,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
} _plc.ConfigKey = item.plcKey;
absractFactories.Add(_plc); if (absractFactories.Contains(_plc))
} {
else absractFactories.Remove(_plc);
{ }
Log.Information($"PLC{item.plcIp}:{item.plcPort};连接失败,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
absractFactories.Add(_plc);
}
else
{
Log.Information($"PLC{item.plcIp}:{item.plcPort};连接失败,时间:{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}");
}
} }
} }
} }
} }while(false);
} }
catch (Exception e) catch (Exception e)
{ {

Loading…
Cancel
Save