Selaa lähdekoodia

2024年5月29日09:48:30

lijun 5 kuukautta sitten
vanhempi
commit
870d5b96ab

+ 4 - 4
Pas.ScadaService/Core/GopTimeCalc.cs

@@ -15,7 +15,7 @@ namespace Pas.ScadaService.Core
         /// <summary>
         /// 点位关联
         /// </summary>
-        private static readonly ConcurrentDictionary<string, List<ConditionDto>> _changeDic = new ConcurrentDictionary<string, List<ConditionDto>>();
+        private static readonly ConcurrentDictionary<string, List<ConditionDto>> ChangeDic = new ConcurrentDictionary<string, List<ConditionDto>>();
         /// <summary>
         /// 所有时间
         /// </summary>
@@ -31,13 +31,13 @@ namespace Pas.ScadaService.Core
             var conditionDtoList = inputObject.ToJsonEntity<List<ConditionDto>>();
             foreach (var item in conditionDtoList)
             {
-                if (_changeDic.TryGetValue(HandleParam(item.Change.Replace("@(", "").Replace(")", "")), out var value))
+                if (ChangeDic.TryGetValue(HandleParam(item.Change.Replace("@(", "").Replace(")", "")), out var value))
                 {
                     value.Add(item);
                 }
                 else
                 {
-                    _changeDic.TryAdd(HandleParam(item.Change.Replace("@(", "").Replace(")", "")), new List<ConditionDto> { item });
+                    ChangeDic.TryAdd(HandleParam(item.Change.Replace("@(", "").Replace(")", "")), new List<ConditionDto> { item });
                 }
             }
             //初始化数据库
@@ -91,7 +91,7 @@ namespace Pas.ScadaService.Core
                     data => GetValue(data.Value.Value.ToString(), data.Value.DataType));
             foreach (var data in obj)
             {
-                if (!_changeDic.TryGetValue(HandleParam(data.ItemId), out var conditionDtoList)) continue;
+                if (!ChangeDic.TryGetValue(HandleParam(data.ItemId), out var conditionDtoList)) continue;
                 foreach (var conditionDto in conditionDtoList)
                 {
                     var conditionValue = conditionDto.Value;

+ 17 - 2
Pas.ScadaService/Program.cs

@@ -3,6 +3,7 @@ using System.Collections.Generic;
 using System.Configuration;
 using System.Linq;
 using System.Text;
+using System.Threading;
 using System.Threading.Tasks;
 using System.Windows.Forms;
 
@@ -12,10 +13,24 @@ namespace Pas.ScadaService
     {
         static void Main(string[] args)
         {
-            StartUp.Start();
-            Console.WriteLine("启动成功");
+            Start();
             Application.Run();
         }
+
+        private static void Start()
+        {
+            try
+            {
+                StartUp.Start();
+                Console.WriteLine("启动成功");
+            }
+            catch (Exception e)
+            {
+                Console.WriteLine("出现异常3秒后自动重启,异常信息:"+e);
+                Thread.Sleep(3000);
+                Start();
+            }
+        }
        
     }
 }

+ 2 - 16
Pas.ScadaService/StartUp.cs

@@ -39,26 +39,12 @@ namespace Pas.ScadaService
                             Value = c.Value.value
                         })
                         .ToList();
-                try
-                {
-                    GopTimeCalc.ChangeData(dataList);
-                }
-                catch (Exception e)
-                {
-                    XTrace.Log.Error(e.ToString());
-                }
+                GopTimeCalc.ChangeData(dataList);
 
             };
             _scada.Start();
             Thread.Sleep(3000);
-            try
-            {
-                GopTimeCalc.Load(config, sqlConn, GetAllData());
-            }
-            catch (Exception e)
-            {
-                XTrace.Log.Error(e.ToString());
-            }
+            GopTimeCalc.Load(config, sqlConn, GetAllData());
             _isStart = true;
         }
         private static List<Model.Data> GetAllData()

BIN
Pas.ScadaService/obj/Release/Pas.ScadaService.csproj.AssemblyReference.cache