using System; using System.IO; using UAS_MES_NEW.Entity; namespace UAS_MES_NEW.PublicMethod { class LogManager { public static string LogAddress = SystemInf.LogFolder; /// /// 记录操作 /// /// public static void DoLog(string Message) { try { StreamWriter sw = File.AppendText(LogAddress + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"); sw.WriteLine("\n【时间】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\n"); sw.WriteLine("【消息】" + Message + "\n"); sw.WriteLine("---------------------------------------------------------------------------------------------------------------"); sw.Close(); } catch (Exception) { } } /// /// 记录操作和SQL /// /// /// public static void DoLog(string Message, string SQL) { try { StreamWriter sw = File.AppendText(LogAddress + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"); sw.WriteLine("\n【时间】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\n"); sw.WriteLine("【消息】" + Message + "\n"); sw.WriteLine("【SQL】" + SQL + "\n"); sw.WriteLine("---------------------------------------------------------------------------------------------------------------"); sw.Close(); } catch (Exception) { } } /// /// 记录SQL /// /// public static void DoSQLLog(string SQL) { try { StreamWriter sw = File.AppendText(LogAddress + DateTime.Now.ToString("yyyy-MM-dd") + ".txt"); sw.WriteLine("\n【时间】" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\n"); sw.WriteLine("【SQL】" + SQL + "\n"); sw.WriteLine("---------------------------------------------------------------------------------------------------------------"); sw.Close(); } catch (Exception) { } } } }