From 85170f9ab975d8e2dccbbf97f8f4dc7bbf4fafaa Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期五, 24 五月 2024 15:50:34 +0800
Subject: [PATCH] 2.自动组托界面:  (已完成)初始化页面时,若当前托条码存在组托记录,则取第一个子条码中的物料获取组托数量。  同时记录条码中的源单主ID、子ID  (已完成)扫描子条码时,判断当前子条码是否是第一个,如果是的话,根据条码中的物料获取组托数量。   同时记录条码中的源单主ID、子ID  (已完成)自动组托时,组托完成后,将组托数量清空。         同时清空记录的源单主ID、子ID

---
 WebAPI/LogService.cs |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 42 insertions(+), 0 deletions(-)

diff --git a/WebAPI/LogService.cs b/WebAPI/LogService.cs
index 7762f83..113cc0d 100644
--- a/WebAPI/LogService.cs
+++ b/WebAPI/LogService.cs
@@ -69,5 +69,47 @@
             }
         }
         #endregion
+
+        #region 鑷畾涔夋枃浠跺悕
+        public static void CustomWriteLog(object obj, string FileName, string filePath = "Vlog" , bool isAppend = true)
+        {
+            try
+            {
+                lock (lockObj)
+                {
+                    filePath = $@"{filePath}\{FileName}.txt";
+
+                    filePath = AppDomain.CurrentDomain.BaseDirectory + filePath;
+
+                    if (!System.IO.Directory.Exists(Path.GetDirectoryName(filePath)))
+                    {
+                        System.IO.Directory.CreateDirectory(Path.GetDirectoryName(filePath));
+                    }
+
+                    bool fileExists = System.IO.File.Exists(filePath);
+                    //涓嶅瓨鍦� 鍒欏垱寤鸿鏂囦欢
+                    if (!fileExists)
+                    {
+                        System.IO.File.Create(filePath).Close();
+                    }
+
+                    using (StreamWriter writer = new StreamWriter(filePath, isAppend))
+                    {
+                        //瀛樺湪鐨勬椂鍊欐墠鍐欎竴琛�
+                        if (fileExists && isAppend)
+                        {
+                            writer.WriteLine();
+                        }
+
+                        var content = obj is string ? obj : JsonConvert.SerializeObject(obj);
+                        writer.WriteLine($"{DateTime.Now} {content}");
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+            }
+        }
+        #endregion
     }
 }

--
Gitblit v1.9.1