Example #1
0
 public MainForm()
 {
     InitializeComponent();
     _logManager = CustomLogManager.GetInstance();
     ((CustomLogManager)_logManager).LogChangedEvent += MainForm_LogChangedEvent;
     StartCollectService();
 }
Example #2
0
 private void StartCollectService()
 {
     if (_process != null)
     {
         MessageBox.Show("服务已启动");
     }
     else
     {
         _process = new ActiveProccess(CustomLogManager.GetInstance());
         _process.Run(Address, Port);
     }
 }
Example #3
0
 private static void Main()
 {
     CustomLogManager.GetInstance().WriteLogToFile(string.Empty.PadRight(6) + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " : " + "开始运行程序" + "\r\n");
     try
     {
         Application.EnableVisualStyles();
         Application.SetCompatibleTextRenderingDefault(false);
         //处理未捕获的异常
         Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
         //处理UI线程异常
         Application.ThreadException += Application_ThreadException;
         //处理非UI线程异常
         AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
         //运行主程序
         Application.Run(new MainForm());
     }
     catch (Exception e)
     {
         CustomLogManager.GetInstance().WriteLogToFile(string.Empty.PadRight(6) + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " : " + e.Message + "\r\n");
     }
 }
Example #4
0
 public static CustomLogManager GetInstance()
 {
     return(_instance ?? (_instance = new CustomLogManager()));
 }
Example #5
0
 private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
 {
     CustomLogManager.GetInstance().WriteLogToFile(string.Empty.PadRight(6) + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " : " + e.Exception + "\r\n");
 }
Example #6
0
 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
 {
     CustomLogManager.GetInstance().WriteLogToFile(string.Empty.PadRight(6) + DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss") + " : " + e.ExceptionObject + "\r\n");
 }