林豪 左 преди 2 години
родител
ревизия
9034a44c65

+ 31 - 1
ServiceCenter/ServiceCenter.cs

@@ -24,11 +24,32 @@ namespace ServiceCenter
         /// </summary>
         private static string _WarehouseName { get; set; } = null!;
 
+        /// <summary>
+        ///  Http请求超时时间
+        /// </summary>
+        private static int _HttpTimeout { get; set; }
+
+        /// <summary>
+        ///  Http请求超时时间
+        /// </summary>
+        public static int HttpTimeout
+        {
+            get
+            {
+                return _HttpTimeout;
+            }
+        }
+
         /// <summary>
         /// 仓库名称
         /// </summary>
         public static string WarehouseName
-        { get { return _WarehouseName; } }
+        {
+            get
+            {
+                return _WarehouseName;
+            }
+        }
 
         /// <summary>
         /// 设置仓库名称
@@ -39,6 +60,15 @@ namespace ServiceCenter
             _WarehouseName = warehouseName;
         }
 
+        /// <summary>
+        ///  设置Http请求超时时间
+        /// </summary>
+        /// <param name="timeout"></param>
+        public static void SetHttpTimeout(int timeout)
+        {
+            _HttpTimeout = timeout;
+        }
+
         #endregion 配置中心
 
         #region 系统运行模式

+ 1 - 1
ServiceCenter/ServiceCenter.csproj

@@ -10,7 +10,7 @@
   <ItemGroup>
     <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.5" />
     <PackageReference Include="PlcSiemens" Version="1.0.0.2" />
-    <PackageReference Include="WCS.Core" Version="1.0.0.5" />
+    <PackageReference Include="WCS.Core" Version="1.0.0.6" />
     <PackageReference Include="WCS.Entity" Version="1.0.0.12" />
   </ItemGroup>
 

+ 4 - 5
ServiceCenter/WebApi/APICaller.cs

@@ -3,7 +3,6 @@ using System.Collections.Concurrent;
 using System.Diagnostics;
 using System.Net;
 using System.Text;
-using WCS.Core;
 
 namespace ServiceCenter.WebApi
 {
@@ -32,11 +31,11 @@ namespace ServiceCenter.WebApi
             if (Results.ContainsKey(key))
             {
                 var res = Results[key];
-                if (res == null) throw new KnownException("接口调用中", LogLevel.Low);
+                if (res == null) throw new Exception("接口调用中");
 
                 try
                 {
-                    if (!res.Succsess) throw new KnownException(res.Exception, LogLevel.Mid);
+                    if (!res.Succsess) throw new Exception(res.Exception);
 
                     return (T)res.Data;
                 }
@@ -73,7 +72,7 @@ namespace ServiceCenter.WebApi
                 }
                 else
                 {
-                    throw new KnownException("接口调用中", LogLevel.Low);
+                    throw new Exception("接口调用中");
                 }
             }
         }
@@ -97,7 +96,7 @@ namespace ServiceCenter.WebApi
             {
                 var res = reader.ReadToEnd();
                 sw.Stop();
-                if (sw.ElapsedMilliseconds > 500) Ltc.Log($"接口{url}调用耗时{sw.ElapsedMilliseconds}---------{JsonConvert.SerializeObject(res)}", LogLevel.Low, ErrorType.Kown);
+                //if (sw.ElapsedMilliseconds > 500) Ltc.Log($"接口{url}调用耗时{sw.ElapsedMilliseconds}---------{JsonConvert.SerializeObject(res)}", LogLevel.Low, ErrorType.Kown);
 
                 return res;
             }

+ 1 - 18
WCS.Service/Worker.cs

@@ -183,23 +183,6 @@ namespace WCS.Service
 
             var a = typeof(IStation520);
 
-            //日志发布事件s
-            Configs.PublishEvent += () =>
-            {
-                //WMS.UploadDevInfo();
-                //ProtocolProxy.Do();
-            };
-            //异常上抛
-            Configs.UploadException = (d, s) =>
-            {
-                //if (s == "接口调用中") return;
-                //if (ProtocolProxy.AllDatas.ContainsKey(d))
-                //{
-                //    ProtocolProxy.AllDatas[d].Info = s;
-                //    //ProtocolProxy.AllDatas[d].Frame = LogicHandler.Frame;
-                //}
-                //WMS.TaskException(d, s);
-            };
             //创建PLC访问器
             Configs.PLCAccessorCreater = new PLCAccessors.PLCAccessorsCreater();
             try
@@ -229,7 +212,7 @@ namespace WCS.Service
 
                 while (true)
                 {
-                    Ltc.GetSystem<DataCollectionSysyem>().Invoke(true);
+                    World.GetSystemInstance<DataCollectionSysyem>().Invoke(true);
                 }
 
                 #endregion 启用数据采集器

+ 1 - 1
WCS.WorkEngineering/WCS.WorkEngineering.csproj

@@ -8,7 +8,7 @@
 
   <ItemGroup>
     <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.5" />
-    <PackageReference Include="ServiceCenter" Version="1.0.0.24" />
+    <PackageReference Include="ServiceCenter" Version="1.0.0.25" />
   </ItemGroup>
 
   <ItemGroup>

+ 23 - 0
WCS.WorkEngineering/worlds/MainWorld.cs

@@ -104,5 +104,28 @@ namespace WCS.WorkEngineering.Worlds
             var log = (LogInfo)logObj;
             Logs.Enqueue(new KeyLog { Channel = channel, Log = log, Time = DateTime.Now });
         }
+
+        /// <summary>
+        ///  日志处理,重写改方法后请自行添加执行内容
+        /// </summary>
+        /// <param name="channel"></param>
+        /// <param name="msg"></param>
+        /// <exception cref="NotImplementedException"></exception>
+        protected override void OnInternalLog(Channel channel, string msg)
+        {
+            var log = new LogInfo { Level = LogLevelEnum.Low, Message = msg };
+            Logs.Enqueue(new KeyLog { Channel = channel, Log = log, Time = DateTime.Now });
+        }
+
+        /// <summary>
+        ///  获取日志,重写改方法后请自行添加执行内容
+        /// </summary>
+        /// <param name="channel"></param>
+        /// <returns></returns>
+        /// <exception cref="NotImplementedException"></exception>
+        protected override IEnumerable<string> GetChannelMsg(Channel channel)
+        {
+            return Logs.Where(v => v.Channel.ToString() == channel.ToString()).Select(v => v.Log.ToString());
+        }
     }
 }