1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using System;
- using System.Collections.Generic;
- using System.IO;
- using System.Linq;
- using System.Text;
- namespace UAS_AutoUpdate
- {
- class LogManager
- {
- public static string LogAddress = @"C:\UAS_MES";
- /// <summary>
- /// 记录操作
- /// </summary>
- /// <param name="Message"></param>
- 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) { }
- }
- /// <summary>
- /// 记录操作和SQL
- /// </summary>
- /// <param name="Message"></param>
- /// <param name="SQL"></param>
- 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) { }
- }
- /// <summary>
- /// 记录SQL
- /// </summary>
- /// <param name="SQL"></param>
- 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) { }
- }
- }
- }
|