Commit 86dd8431 张东亮

设置数据异常System.OutOfMemoryException

1 个父辈 3aa1afc3
正在显示 168 个修改的文件 包含 40 行增加35 行删除
...@@ -159,6 +159,9 @@ namespace AGVDispatch ...@@ -159,6 +159,9 @@ namespace AGVDispatch
catch (Exception ex) catch (Exception ex)
{ {
LogUtil.Error($"timer1_Tick error", ex); LogUtil.Error($"timer1_Tick error", ex);
}finally
{
Monitor.Exit(locObj);
} }
} }
} }
......
[2023-02-27 14:56:37,464][1]INFO AGVServer 【12000】服务启动 [2023-03-29 11:54:25,236][1]INFO AGVServer 【12000】服务启动
[2023-02-27 14:56:37,465][1]INFO Server start listen : 12000 [2023-03-29 11:54:25,239][1]INFO Server start listen : 12000
[2023-02-27 14:56:37,476][1]INFO 本机IP:[ 192.168.101.21 192.168.64.1 192.168.153.1 172.21.64.1] [2023-03-29 11:54:25,260][1]INFO 本机IP:[ 192.168.105.11 192.168.101.19 192.168.64.1 192.168.153.1 172.30.32.1]
[2023-02-27 14:57:22,426][1]INFO AGVServer 【12000】服务启动
[2023-02-27 14:57:22,428][1]INFO Server start listen : 12000
[2023-02-27 14:59:11,145][1]INFO 本机IP:[ 192.168.101.21 192.168.64.1 192.168.153.1 172.21.64.1]
[2023-02-27 15:18:42,627][15]INFO [12000]有新的客户端连接上:[127.0.0.1:60811]
[2023-02-27 15:18:42,715][20]INFO 客户端127.0.0.1离线,节点状态重置
[2023-02-27 15:18:44,173][20]INFO 客户端【127.0.0.1:60811】已断开
[2023-02-27 15:29:08,054][1]INFO AGVServer 【12000】服务启动
[2023-02-27 15:29:08,056][1]INFO Server start listen : 12000
[2023-02-27 15:29:10,971][1]INFO 本机IP:[ 192.168.101.21 192.168.64.1 192.168.153.1 172.21.64.1]
[2023-02-27 15:54:34,269][1]INFO AGVServer 【12000】服务启动
[2023-02-27 15:54:34,270][1]INFO Server start listen : 12000
[2023-02-27 15:54:36,653][1]INFO 本机IP:[ 192.168.101.21 192.168.64.1 192.168.153.1 172.21.64.1]
[2023-02-27 15:59:18,484][1]INFO AGVServer 【12000】服务启动
[2023-02-27 15:59:18,486][1]INFO Server start listen : 12000
[2023-02-27 15:59:21,638][1]INFO 本机IP:[ 192.168.101.21 192.168.64.1 192.168.153.1 172.21.64.1]
...@@ -4,6 +4,6 @@ ...@@ -4,6 +4,6 @@
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup> </startup>
<appSettings> <appSettings>
<add key="ProName" value="AGVDispatch-点位上报" /> <add key="ProName" value="AGVDispatch-2号车总出现设置状态异常修复" />
</appSettings> </appSettings>
</configuration> </configuration>
\ No newline at end of file \ No newline at end of file
using DeviceLib.Model.AGV; using Common;
using DeviceLib.Model.AGV;
using DeviceLib.Model.AGV.MiR; using DeviceLib.Model.AGV.MiR;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Threading;
namespace DeviceLib.DB.Config namespace DeviceLib.DB.Config
{ {
public class ConfigOperation public class ConfigOperation
...@@ -52,27 +56,40 @@ namespace DeviceLib.DB.Config ...@@ -52,27 +56,40 @@ namespace DeviceLib.DB.Config
{ {
if (robot != null) if (robot != null)
{ {
using (ConfigContext context = new ConfigContext()) if (Monitor.TryEnter(robot, 3000))
{ {
var find = context.Robots.FirstOrDefault(x => x.id == robot.id); try
if (find != null)
{
find.auto = robot.auto;
find.use_fleet = robot.use_fleet;
find.is_debug = robot.is_debug;
}
foreach (var item in robot.load_infos)
{ {
var loadInfo = context.LoadInfos.FirstOrDefault(s => s.id == item.id); using (ConfigContext context = new ConfigContext())
if (loadInfo != null)
{ {
loadInfo.shelf_type = item.shelf_type; var find = context.Robots.FirstOrDefault(x => x.id == robot.id);
loadInfo.shelf_id = item.shelf_id; if (find != null)
{
find.auto = robot.auto;
find.use_fleet = robot.use_fleet;
find.is_debug = robot.is_debug;
}
foreach (var item in robot.load_infos)
{
var loadInfo = context.LoadInfos.FirstOrDefault(s => s.id == item.id);
if (loadInfo != null)
{
loadInfo.shelf_type = item.shelf_type;
loadInfo.shelf_id = item.shelf_id;
}
}
context.SaveChangesAsync();
return true;
} }
} }
context.SaveChangesAsync(); catch (Exception ex)
return true; {
LogUtil.Error($"SetRobot {robot?.name}",ex);
}
finally { Monitor.Exit(robot); }
} }
} }
return false; return false;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!