|
|
|
@ -69,16 +69,20 @@ public static class ClientMgr
|
|
|
|
|
{
|
|
|
|
|
EquipInfoRepository equipInfoRepository = AppInfo.Container.Resolve<EquipInfoRepository>();
|
|
|
|
|
EquipNetInfoRepository netInfoRepository = AppInfo.Container.Resolve<EquipNetInfoRepository>();
|
|
|
|
|
BinInfoRepository binInfoRepository = AppInfo.Container.Resolve<BinInfoRepository>();
|
|
|
|
|
List<EquipInfo> equipInfos = equipInfoRepository.QueryListByClause(it => it.TypeCode == (int)EquipmentType.Charger);
|
|
|
|
|
if (equipInfos.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
Dictionary<string, EquipInfo> set = equipInfos.ToDictionary(it => it.Code, it => it);
|
|
|
|
|
List<EquipNetInfo> equipNetInfos = netInfoRepository.QueryListByClause(it => set.Keys.Contains(it.Code));
|
|
|
|
|
Dictionary<string,BinInfo> binInfoMap = binInfoRepository.QueryListByClause(it => set.Keys.Contains(it.ChargerNo))
|
|
|
|
|
.ToDictionary(it => it.ChargerNo, it => it);
|
|
|
|
|
foreach (EquipNetInfo netInfo in equipNetInfos)
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
ConnClient(netInfo);
|
|
|
|
|
binInfoMap.TryGetValue(netInfo.Code, out var binInfo);
|
|
|
|
|
ConnClient(netInfo, binInfo);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -247,14 +251,22 @@ public static class ClientMgr
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void ConnClient(EquipNetInfo netInfo)
|
|
|
|
|
private static void ConnClient(EquipNetInfo netInfo, BinInfo? binInfo)
|
|
|
|
|
{
|
|
|
|
|
Log.Info($"begin to connect {netInfo.Code} {netInfo.NetAddr}:{netInfo.NetPort}");
|
|
|
|
|
ChargerClient client = AppInfo.Container.Resolve<ChargerClient>();
|
|
|
|
|
client.BinNo = binInfo.No;
|
|
|
|
|
client.BatteryNo = binInfo.BatteryNo;
|
|
|
|
|
client.InitBootstrap(netInfo.NetAddr, int.Parse(netInfo.NetPort));
|
|
|
|
|
client.Connect();
|
|
|
|
|
client.SessionAttr(netInfo.Code, netInfo.DestAddr);
|
|
|
|
|
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
client.Connect();
|
|
|
|
|
client.SessionAttr(netInfo.Code, netInfo.DestAddr);
|
|
|
|
|
Log.Info($"succeed to connect {netInfo.Code} {netInfo.NetAddr}:{netInfo.NetPort}");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
AddBySn(netInfo.Code, client);
|
|
|
|
|
Log.Info($"connected {netInfo.Code} {netInfo.NetAddr}:{netInfo.NetPort}");
|
|
|
|
|
Log.Info($"begin to connect {netInfo.Code} {netInfo.NetAddr}:{netInfo.NetPort}");
|
|
|
|
|
}
|
|
|
|
|
}
|