/// <summary>
 /// 加载自动更新程序。
 /// </summary>
 /// <param name="initService"></param>
 protected void LoadAutoUpdateProgram(InitialService initService)
 {
     if (initService != null)
     {
         CredentialsCollection cred = CredentialsFactory.DeSerialize(FolderStructure.CredentialsFile);
         if (cred != null && cred.Count > 0)
         {
             this.CoreService.Add("credentials", cred[0]);
             try
             {
                 string url = cred[0].ServiceURL;
                 if (!string.IsNullOrEmpty(url))
                 {
                     initService.RaiseChanged("检测自动更新...");
                     string[] urls = url.Split('/');
                     url = url.Replace(urls[urls.Length - 1], "AutoUpdate.ashx");
                     Process.Start("Yaesoft.SFIT.Client.AutoUpdate.exe", url);
                 }
             }
             catch (Exception x)
             {
                 initService.RaiseChanged("自动更新异常:" + x.Message);
             }
         }
     }
 }
 /// <summary>
 /// 加载监控界面颜色配置文件。
 /// </summary>
 /// <param name="initService"></param>
 protected void LoadMonitorUIColorSettingsCfg(InitialService initService)
 {
     if (initService != null)
     {
         initService.RaiseChanged("开始加载监控界面颜色配置数据...");
         MonitorUIColorSettings settings = MonitorUIColorSettings.DeSerializer();
         if (settings != null)
         {
             initService.Add("monitoruicolorsettings", settings);
             initService.RaiseChanged("加载监控界面颜色配置数据完成...");
         }
         else
         {
             initService.RaiseChanged("加载监控界面颜色配置数据失败");
         }
     }
 }
 /// <summary>
 /// 加载端口设置文件。
 /// </summary>
 protected void LoadNetPortSettingsCfg(InitialService initService)
 {
     if (initService != null)
     {
         initService.RaiseChanged("开始加载端口设置数据...");
         PortSettings ps = NetPortSettingsMgr.DeSerializer();
         if (ps != null)
         {
             initService.Add("portsettings", ps);
             initService.RaiseChanged("加载端口设置数据完成...");
         }
         else
         {
             initService.RaiseChanged("加载端口设置数据失败");
         }
     }
 }
示例#4
0
        static void Main()
        {
            bool isRun;
            Mutex run = new Mutex(true, "run_only_one", out isRun);
            if (isRun)
            {
                try
                {
                    #region 主运行区。
                    //处理未捕获的异常。
                    Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                    //处理UI线程异常。
                    Application.ThreadException += new ThreadExceptionEventHandler(delegate(object sender, ThreadExceptionEventArgs e)
                    {
                        GlobalExceptionHandler(e == null ? null : e.Exception);
                    });
                    //处理非UI线程异常。
                    AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(delegate(object sender, UnhandledExceptionEventArgs e)
                    {
                        GlobalExceptionHandler(e.ExceptionObject as Exception);
                    });

                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    //设置线程池。
                    ThreadPool.SetMaxThreads(300, 200);
                    ThreadPool.SetMinThreads(100, 50);
                    //
                    using (InitialService service = new InitialService())
                    {
                        service.AddForm(new InitializeWindow(service));
                        service.Run();
                    }
                    #endregion
                }
                catch (Exception e)
                {
                    GlobalExceptionHandler(e);
                }
                finally
                {
                    run.ReleaseMutex();
                    Environment.Exit(0);
                }
            }
            else
            {
                MessageBox.Show("已有一个实例在运行!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }