Пример #1
0
 static void ShowErrorBox(Exception exception, string message, bool mustTerminate)
 {
     try
     {
         using (ExceptionBox box = new ExceptionBox(exception, message, mustTerminate))
         {
             if (FanHai.Gui.Framework.Gui.WorkbenchSingleton.InvokeRequired)
             {
                 box.ShowDialog();
             }
             else
             {
                 box.ShowDialog(FanHai.Gui.Framework.Gui.WorkbenchSingleton.MainForm);
             }
         }
     }
     catch (Exception ex)
     {
         LoggingService.Warn("Error showing ExceptionBox", ex);
         MessageBox.Show(exception.ToString(), message, MessageBoxButtons.OK,
                         MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
     }
 }
Пример #2
0
        public void InitMESCore(SolarViewerHost.CallbackHelper callback, StartupSettings properties)
        {
            //初始化ILoggingService接口
            FanHai.Gui.Core.Services.ServiceManager.LoggingService = new log4netLoggingService();
            //初始化IMessageService接口
            FanHai.Gui.Core.Services.ServiceManager.MessageService = WinFormsMessageService.Instance;
            //记录字符串信息
            LoggingService.Info("Init FanHai Framework Core...");
            this.callback = callback;

            CoreStartup startup = new CoreStartup(properties.ApplicationName);

            if (properties.UseSolarViewerFrameworkErrorHandler)
            {
                this.useSolarViewerFrameworkErrorHandler = true;
                ExceptionBox.RegisterExceptionBoxForUnhandledExceptions();
            }
            //设定启动路径
            startup.ConfigDirectory = properties.ConfigDirectory;
            //设定数据路径
            startup.DataDirectory = properties.DataDirectory;
            if (properties.PropertiesName != null)
            {
                //把StarupSettings类中PropertiesName属性传递给CoreStartup
                startup.PropertiesName = properties.PropertiesName;
            }
            //ParserService.DomPersistencePath = properties.DomPersistencePath;
            // disable RTL: translations for the RTL languages are inactive
            RightToLeftConverter.RightToLeftLanguages = new string[0];
            //设定App启动路径
            if (properties.ApplicationRootPath != null)
            {
                FileUtility.ApplicationRootPath = properties.ApplicationRootPath;
            }
            startup.StartCoreServices();

            Assembly exe = Assembly.Load(properties.ResourceAssemblyName);

            ResourceService.RegisterNeutralStrings(new ResourceManager("FanHai.Gui.Framework.StartUp.Resources.StringResources", exe));
            ResourceService.RegisterNeutralImages(new ResourceManager("FanHai.Gui.Framework.StartUp.Resources.BitmapResources", exe));

            LoggingService.Info("Looking for AddIns...");
            foreach (string file in properties.addInFiles)
            {
                startup.AddAddInFile(file);
            }
            foreach (string dir in properties.addInDirectories)
            {
                startup.AddAddInsFromDirectory(dir);
            }

            if (properties.AllowAddInConfigurationAndExternalAddIns)
            {
                startup.ConfigureExternalAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddIns.xml"));
            }
            if (properties.AllowUserAddIns)
            {
                startup.ConfigureUserAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddInInstallTemp"),
                                            Path.Combine(PropertyService.ConfigDirectory, "AddIns"));
            }

            LoggingService.Info("Loading AddInTree...");
            startup.RunInitialization();

            LoggingService.Info("Init FanHai Framework Core finished");
        }