From 980b78709fef23248956382fe72571e431c4d289 Mon Sep 17 00:00:00 2001
From: zrg <z1873@LAPTOP-EAVL132E>
Date: 星期二, 06 一月 2026 10:46:05 +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