From 0fb0f17319ecf71d66b96a6acfd07f754be9443e Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期四, 24 十月 2024 13:44:38 +0800
Subject: [PATCH] WCS添加穿梭车信息表,修改任务信息表
---
项目代码/WMS/WIDESEA_WMSServer/WIDESEA_Core/LogHelper/LogLock.cs | 92 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 92 insertions(+), 0 deletions(-)
diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/LogHelper/LogLock.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/LogHelper/LogLock.cs"
new file mode 100644
index 0000000..50da663
--- /dev/null
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WIDESEA_WMSServer/WIDESEA_Core/LogHelper/LogLock.cs"
@@ -0,0 +1,92 @@
+锘�
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_Core.Helper;
+
+namespace WIDESEA_Core.LogHelper
+{
+ public class LogLock
+ {
+ static ReaderWriterLockSlim LogWriteLock = new ReaderWriterLockSlim();
+ static int WritedCount = 0;
+ static int FailedCount = 0;
+ static string _contentRoot = string.Empty;
+
+ public LogLock(string contentPath)
+ {
+ _contentRoot = contentPath;
+ }
+
+ public static void OutLogAOP(string prefix, string[] dataParas, bool IsHeader = true)
+ {
+ OutSql2LogToFile(prefix, dataParas, IsHeader);
+ }
+
+ public static void OutSql2LogToFile(string prefix, string[] dataParas, bool IsHeader = true, bool isWrt = false)
+ {
+ try
+ {
+ //璁剧疆璇诲啓閿佷负鍐欏叆妯″紡鐙崰璧勬簮锛屽叾浠栧啓鍏ヨ姹傞渶瑕佺瓑寰呮湰娆″啓鍏ョ粨鏉熶箣鍚庢墠鑳界户缁啓鍏�
+ //娉ㄦ剰锛氶暱鏃堕棿鎸佹湁璇荤嚎绋嬮攣鎴栧啓绾跨▼閿佷細浣垮叾浠栫嚎绋嬪彂鐢熼ゥ楗� (starve)銆� 涓轰簡寰楀埌鏈�濂界殑鎬ц兘锛岄渶瑕佽�冭檻閲嶆柊鏋勯�犲簲鐢ㄧ▼搴忎互灏嗗啓璁块棶鐨勬寔缁椂闂村噺灏戝埌鏈�灏忋��
+ // 浠庢�ц兘鏂归潰鑰冭檻锛岃姹傝繘鍏ュ啓鍏ユā寮忓簲璇ョ揣璺熸枃浠舵搷浣滀箣鍓嶏紝鍦ㄦ澶勮繘鍏ュ啓鍏ユā寮忎粎鏄负浜嗛檷浣庝唬鐮佸鏉傚害
+ // 鍥犺繘鍏ヤ笌閫�鍑哄啓鍏ユā寮忓簲鍦ㄥ悓涓�涓猼ry finally璇彞鍧楀唴锛屾墍浠ュ湪璇锋眰杩涘叆鍐欏叆妯″紡涔嬪墠涓嶈兘瑙﹀彂寮傚父锛屽惁鍒欓噴鏀炬鏁板ぇ浜庤姹傛鏁板皢浼氳Е鍙戝紓甯�
+ LogWriteLock.EnterWriteLock();
+
+ var folderPath = Path.Combine(_contentRoot, "Log");
+ if (!Directory.Exists(folderPath))
+ {
+ Directory.CreateDirectory(folderPath);
+ }
+ //string logFilePath = Path.Combine(path, $@"{filename}.log");
+ var logFilePath = FileHelper.GetAvailableFileWithPrefixOrderSize(folderPath, prefix);
+
+ var now = DateTime.Now;
+ string logContent = String.Join("\r\n", dataParas);
+ if (IsHeader)
+ {
+ logContent = (
+ "--------------------------------\r\n" +
+ DateTime.Now + "|\r\n" +
+ String.Join("\r\n", dataParas) + "\r\n"
+ );
+ }
+ else
+ {
+ logContent = (
+ dataParas[1] + ",\r\n"
+ );
+ }
+
+ //if (logContent.IsNotEmptyOrNull() && logContent.Length > 500)
+ //{
+ // logContent = logContent.Substring(0, 500) + "\r\n";
+ //}
+ if (isWrt)
+ {
+ System.IO.File.WriteAllText(logFilePath, logContent);
+ }
+ else
+ {
+ System.IO.File.AppendAllText(logFilePath, logContent);
+ }
+ WritedCount++;
+ }
+ catch (Exception e)
+ {
+ //Console.Write(e.Message);
+ FailedCount++;
+ }
+ finally
+ {
+ //閫�鍑哄啓鍏ユā寮忥紝閲婃斁璧勬簮鍗犵敤
+ //娉ㄦ剰锛氫竴娆¤姹傚搴斾竴娆¢噴鏀�
+ // 鑻ラ噴鏀炬鏁板ぇ浜庤姹傛鏁板皢浼氳Е鍙戝紓甯竅鍐欏叆閿佸畾鏈粡淇濇寔鍗宠閲婃斁]
+ // 鑻ヨ姹傚鐞嗗畬鎴愬悗鏈噴鏀惧皢浼氳Е鍙戝紓甯竅姝ゆā寮忎笉涓嬪厑璁镐互閫掑綊鏂瑰紡鑾峰彇鍐欏叆閿佸畾]
+ LogWriteLock.ExitWriteLock();
+ }
+ }
+ }
+}
--
Gitblit v1.9.3