123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145 |
- using System;
- using System.Collections.Generic;
- using System.Windows.Forms;
- using System.Threading;
- using Common.Logging;
- using ILog = Common.Logging.ILog;
- using Tofly.Core.Exceptions;
- using Tofly.Core.Context;
- using Tofly.Core.Context.Support;
- using Tofly.CoreUI.Message;
- using Tofly.CoreUI.Control;
- using Tofly.CoreUI.Plot.Win.Config;
- using Tofly.GISUI.Plugin;
- namespace Main.Win.Config
- {
- static class Program
- {
-
-
-
- [STAThread]
- static void Main()
- {
- try
- {
- Application.ThreadException += Application_ThreadException;
- Application.EnableVisualStyles();
- AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
- Application.SetCompatibleTextRenderingDefault(false);
- try
- {
- IApplicationContext pContext = ContextRegistry.GetContext();
- IInitGISLicense license = pContext.GetObject("IInitGISLicense") as IInitGISLicense;
- license.InitializeLicense();
- }
- catch (Exception e)
- {
- if (e is Tofly.Core.SysRegist.SysRegistException)
- {
-
-
-
- Application.Exit();
- }
- try
- {
- ILog adviceLogger = LogManager.GetLogger(AppDomain.CurrentDomain.Id.ToString());
- adviceLogger.Error(e.Message, e);
- }
- catch { }
- }
- FormConfigureClass form = new FormConfigureClass();
- Application.Run(form);
- }
- catch (Exception e)
- {
- if (e is Tofly.Core.SysRegist.SysRegistException)
- {
-
-
- Application.Exit();
- }
- try
- {
- ILog adviceLogger = LogManager.GetLogger(AppDomain.CurrentDomain.Id.ToString());
- adviceLogger.Error(e.Message, e);
- MessageManager.Show(MessageType.Error, e.Message);
- }
- catch { }
- }
- }
-
-
-
-
-
- static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
- {
- UnhandleException(e.ExceptionObject as Exception);
- }
-
-
-
-
-
- private static void Application_ThreadException(object sender, ThreadExceptionEventArgs e)
- {
- UnhandleException(e.Exception);
- }
- private static void UnhandleException(Exception e)
- {
-
- IException innerException = e as IException;
- ILog adviceLogger = LogManager.GetLogger(AppDomain.CurrentDomain.Id.ToString());
- try
- {
- if (innerException != null)
- {
- if (innerException is Tofly.Core.SysRegist.SysRegistException)
- {
-
-
-
- Application.Exit();
- }
- else
- {
- if (!innerException.IsLog)
- {
- adviceLogger.Error(e.Message, e);
- innerException.IsLog = true;
- }
- if (!innerException.IsShow)
- {
- innerException.IsShow = true;
- MessageManager.Show(Tofly.CoreUI.Message.MessageType.Error, e.Message);
- }
- }
- }
- else
- {
- adviceLogger.Error(e.Message, e);
- MessageManager.Show(Tofly.CoreUI.Message.MessageType.Error, e.Message);
- }
- }
- catch (Exception ex)
- {
- adviceLogger.Error(ex.Message, ex);
- }
- }
- }
- }
|