From 1d9f82659dbfdfd6ac0ddbb33f1fd5af1164d939 Mon Sep 17 00:00:00 2001
From: yangle <admin@YINMOU>
Date: 星期五, 29 十一月 2024 16:52:14 +0800
Subject: [PATCH] 浸渍 铁芯检测 无尘 单品过站 不能开工不能过站控制

---
 WFormSynchronizeData_SMR/WFormReadData_SMR/DBHelper.cs |   46 +++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 45 insertions(+), 1 deletions(-)

diff --git a/WFormSynchronizeData_SMR/WFormReadData_SMR/DBHelper.cs b/WFormSynchronizeData_SMR/WFormReadData_SMR/DBHelper.cs
index fe2fd8a..21fbdca 100644
--- a/WFormSynchronizeData_SMR/WFormReadData_SMR/DBHelper.cs
+++ b/WFormSynchronizeData_SMR/WFormReadData_SMR/DBHelper.cs
@@ -1,11 +1,14 @@
-锘縰sing System;
+锘縰sing Newtonsoft.Json;
+using System;
 using System.Collections.Generic;
 using System.Configuration;
 using System.Data;
 using System.Data.SqlClient;
+using System.IO;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
+using System.Windows;
 
 namespace WFormReadData_SMR
 {
@@ -333,6 +336,47 @@
                 return -2;
             }
         }
+        private static readonly object lockObj = new object();
+        //鍐欐棩蹇�
+        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)
+            {
+            }
+        }
 
         //寰楀埌鏈�澶у崟鎹彿
         public string CreateBillCode(string BillCode, ref string sReturn, bool Add)

--
Gitblit v1.9.1