|
@@ -2,8 +2,6 @@
|
|
|
using ServiceCenter.Extensions;
|
|
|
using ServiceCenter.Redis;
|
|
|
using System.Collections.Concurrent;
|
|
|
-using System.IO;
|
|
|
-using WCS.Core;
|
|
|
|
|
|
namespace ServiceCenter.Logs
|
|
|
{
|
|
@@ -15,19 +13,33 @@ namespace ServiceCenter.Logs
|
|
|
public static ConcurrentQueue<KeyLog> Logs = new ConcurrentQueue<KeyLog>();
|
|
|
|
|
|
/// <summary>
|
|
|
- /// 发布一条日志记录
|
|
|
+ /// 发布一条世界交互日志
|
|
|
/// </summary>
|
|
|
- /// <param name="path">路径</param>
|
|
|
- /// <param name="title">文件名</param>
|
|
|
- /// <param name="con">内容</param>
|
|
|
- public static void Publish(string path, string title, string con)
|
|
|
+ /// <param name="logs"></param>
|
|
|
+ public static void WorldPublish(ConcurrentQueue<KeyLog> logs)
|
|
|
{
|
|
|
- RedisHub.Default.RPush("LogHub", JsonConvert.SerializeObject(new LogModel
|
|
|
+ if (logs.Count > 0)
|
|
|
{
|
|
|
- path = path,
|
|
|
- Title = title,
|
|
|
- Con = con
|
|
|
- }));
|
|
|
+ foreach (var log in Logs)
|
|
|
+ {
|
|
|
+ var dir = $"D:\\WCSLogs\\{DateTime.Now.yyyyMMdd()}\\{log.Channel.World}\\{log.Channel.System}\\{log.Channel.Item}\\";
|
|
|
+ var msg = $"{log.Time.yyyyMMddhhmmssf()}--[{Thread.CurrentThread.ManagedThreadId}]--{log}\n";
|
|
|
+ RedisHub.Default.RPush("LogHub", JsonConvert.SerializeObject(new LogModel
|
|
|
+ {
|
|
|
+ path = dir,
|
|
|
+ Title = $"{log.Log.Message.Split(":")[0]}.txt",
|
|
|
+ Con = msg
|
|
|
+ }));
|
|
|
+ }
|
|
|
+ List<BusinessAlarm> businesses = logs.Select(v => new BusinessAlarm()
|
|
|
+ {
|
|
|
+ BusinessName = v.Channel.System,
|
|
|
+ DevNo = v.Channel.Item,
|
|
|
+ Con = v.ToString(),
|
|
|
+ Time = DateTime.Now
|
|
|
+ }).ToList();
|
|
|
+ RedisHub.Default.Set($"{nameof(BusinessAlarm)}", JsonConvert.SerializeObject(businesses));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
@@ -81,4 +93,30 @@ namespace ServiceCenter.Logs
|
|
|
|
|
|
public string Con { get; set; }
|
|
|
}
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 业务报警
|
|
|
+ /// </summary>
|
|
|
+ public class BusinessAlarm
|
|
|
+ {
|
|
|
+ /// <summary>
|
|
|
+ /// 业务名称
|
|
|
+ /// </summary>
|
|
|
+ public string BusinessName { get; set; }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 设备号
|
|
|
+ /// </summary>
|
|
|
+ public string DevNo { get; set; }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 内容
|
|
|
+ /// </summary>
|
|
|
+ public string Con { get; set; }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 时间
|
|
|
+ /// </summary>
|
|
|
+ public DateTime Time { get; set; }
|
|
|
+ }
|
|
|
}
|