change - 激活码激活Hsl模块

dev
wenjy 8 months ago
parent 0164b9529d
commit 068a66e70a

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

Loading…
Cancel
Save