| | |
| | | //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; |
| | | |
| | | |
| | | ///////////////////////////////////////////////////////////////////////////////////////////////////////// |
| | | //以下枚举指定报表数据的格式类型 |
| | |
| | | { |
| | | //"recordset":[ |
| | | sbJSONText.Append('"'); |
| | | sbJSONText.Append(dt.TableName); |
| | | sbJSONText.Append(dt.TableName); |
| | | sbJSONText.Append("\":[\n"); |
| | | foreach (DataRow dr in dt.Rows) |
| | | { |
| | |
| | | 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') |
| | | { |
| | |
| | | { |
| | | 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(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | //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 |
| | | //} |