From 9ee2abf3f34b3e6c0d35df6cdde0c4d4e1a5d246 Mon Sep 17 00:00:00 2001
From: 王 垚 <1402714037@qq.com>
Date: 星期五, 31 十二月 2021 20:16:08 +0800
Subject: [PATCH] 问题处理

---
 WebSRM/App_Data/ReportData.cs |   88 ++++++++++++++++++++++++++++++++++++-------
 1 files changed, 73 insertions(+), 15 deletions(-)

diff --git a/WebSRM/App_Data/ReportData.cs b/WebSRM/App_Data/ReportData.cs
index 90d9ec9..48d9bfc 100644
--- a/WebSRM/App_Data/ReportData.cs
+++ b/WebSRM/App_Data/ReportData.cs
@@ -2,15 +2,11 @@
 //using System.Collections;
 using System.Text;
 using System.Data;
-using System.Configuration;
 using System.IO;
 using System.IO.Compression;
 using System.Web;
-using System.Web.Security;
-using System.Web.UI;
-using System.Web.UI.WebControls;
-using System.Web.UI.WebControls.WebParts;
-using System.Web.UI.HtmlControls;
+using System.Threading.Tasks;
+
 
 /////////////////////////////////////////////////////////////////////////////////////////////////////////
 //浠ヤ笅鏋氫妇鎸囧畾鎶ヨ〃鏁版嵁鐨勬牸寮忕被鍨�
@@ -165,7 +161,7 @@
         {
             //"recordset":[
             sbJSONText.Append('"');
-            sbJSONText.Append(dt.TableName); 
+            sbJSONText.Append(dt.TableName);
             sbJSONText.Append("\":[\n");
             foreach (DataRow dr in dt.Rows)
             {
@@ -203,7 +199,7 @@
     public static void PrepareValueText(ref string ValueText)
     {
         bool HasSpecialChar = false;
-        foreach(char ch in ValueText)
+        foreach (char ch in ValueText)
         {
             if (ch == '"' || ch == '\\' || ch == '\r' || ch == '\n' || ch == '\t')
             {
@@ -218,22 +214,84 @@
             {
                 if (ch == '"' || ch == '\\' || ch == '\r' || ch == '\n' || ch == '\t')
                 {
-                    NewValueText.Append( '\\');
+                    NewValueText.Append('\\');
                     if (ch == '"' || ch == '\\')
-                        NewValueText.Append( ch  );
+                        NewValueText.Append(ch);
                     else if (ch == '\r')
-                        NewValueText.Append( 'r' );
+                        NewValueText.Append('r');
                     else if (ch == '\n')
-                        NewValueText.Append( 'n' );
+                        NewValueText.Append('n');
                     else if (ch == '\t')
-                        NewValueText.Append( 't' );
+                        NewValueText.Append('t');
                 }
                 else
                 {
-                    NewValueText.Append( ch  );
+                    NewValueText.Append(ch);
                 }
             }
             ValueText = NewValueText.ToString();
         }
     }
-}
\ No newline at end of file
+}
+//public class LogService
+//{
+//    private static readonly object lockObj = new object();
+
+//    public static void WriteAsync(object obj, string filePath = "Vlog", bool isAppend = true)
+//    {
+//        Task.Run(() =>
+//        {
+//            Write(obj, filePath, isAppend);
+//        });
+//    }
+
+//    public static void WriteAsync<T>(object obj, string filePath = "Vlog", bool isAppend = true)
+//    {
+//        Task.Run(() =>
+//        {
+//            Write(obj, $@"{filePath}\{typeof(T).Name}", isAppend);
+//        });
+//    }
+
+//    #region 鏃ュ織
+//    public static void Write(object obj, string filePath = "Vlog", bool isAppend = true)
+//    {
+//        try
+//        {
+//            lock (lockObj)
+//            {
+//                filePath = $@"{filePath}\webapi{DateTime.Now.ToString("yyyyMMdd")}.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 : obj;
+//                    writer.WriteLine($"{DateTime.Now} {content}");
+//                }
+//            }
+//        }
+//        catch (Exception ex)
+//        {
+//        }
+//    }
+//    #endregion
+//}
\ No newline at end of file

--
Gitblit v1.9.1