Esempio n. 1
0
        static void Application_ThreadException(Object seder, System.Threading.ThreadExceptionEventArgs e)
        {
            DialogResult result = DialogResult.Cancel;

            OperationalLogManager.AppendMessage(e.Exception.Message);
            OperationalLogManager.AppendMessage(e.Exception.ToString());

            string errorMsg = "程序出现错误需要关闭,请联系数慧客服,解决此问题! ";

            try
            {
                result = MessageBox.Show(errorMsg, COMMONCONST.MESSAGEBOX_ERROR, MessageBoxButtons.OK,
                                         MessageBoxIcon.Stop);
                // Exits the program when the user clicks Abort.
                if (result == DialogResult.OK)
                {
                    //关闭当前程序
                    System.Environment.Exit(System.Environment.ExitCode);
                }
                //Application.ExitThread();
                //Application.Exit();
            }
            catch
            {
            }
        }
Esempio n. 2
0
        static void CurrentDomain_UnhandledException(Object seder, System.UnhandledExceptionEventArgs e)
        {
            Exception ex = e.ExceptionObject as Exception;

            OperationalLogManager.AppendMessage(ex.Message);
            OperationalLogManager.AppendMessage(ex.ToString());
        }
Esempio n. 3
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            SplashScreen.ShowSplashScreen();

            //1、检查只允许一个实例运行
            Process[] ps = Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName);
            if (ps.Length > 1)
            {
                XtraMessageBox.Show("质检Demo程序已经启动!", COMMONCONST.MESSAGEBOX_WARING, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                SplashScreen.CloseForm();
                return;
            }


            //2、检查公司的lic权限

            //3、检查arcgis license权限
            LicenseInitializer m_AOLicenseInitializer = new LicenseInitializer();

            if (!m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB },
                                                              new esriLicenseExtensionCode[] { esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst }))
            {
                SplashScreen.CloseForm();
                XtraMessageBox.Show("Arcgis许可验证失败", COMMONCONST.MESSAGEBOX_WARING, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            //应用dev的主题
            DevExpress.UserSkins.OfficeSkins.Register();
            DevExpress.UserSkins.BonusSkins.Register();
            if (!DevExpress.Skins.SkinManager.AllowFormSkins ||
                !NativeVista.IsVista)
            {
                DevExpress.Skins.SkinManager.EnableFormSkins();
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ApplicationExit += new EventHandler(Application_ApplicationExit);
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            //开启日志记录
            OperationalLogManager.SetAutoFlush(true);

            OperationalLogManager.AppendSeparator();
            OperationalLogManager.AppendSeparator();

            //读取环境变量
            ConfigManager.GetEnvironVariable();

            //运行主程序
            Application.Run(new RibbonFrmMain());
        }
Esempio n. 4
0
        /// <summary>
        /// Get_s the sysdb connection.
        /// </summary>
        /// <returns></returns>
        public static IDbConnection GetSysDbConnection()
        {
            try
            {
                if (m_syscon != null && m_syscon.State != ConnectionState.Closed)
                {
                    return(m_syscon);
                }

                string strConn;
                if (string.IsNullOrEmpty(m_SysDbPath))
                {
                    OperationalLogManager.AppendMessage("找不到系统库!请正确设置系统库路径");
                    return(null);
                }

                AccessMDBEncrypt AccessMDB = new AccessMDBEncrypt();
                AccessMDB.FileToUntie(m_SysDbPath);
                strConn = @"PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" + m_SysDbPath + ";Persist Security Info=False";

                m_syscon = m_Dbfactory.CreateConnection();
                m_syscon.ConnectionString = strConn;

                while (m_syscon.State.Equals(ConnectionState.Closed))
                {
                    try
                    {
                        m_syscon.Open();
                    }
                    catch (Exception exp)
                    {
                        OperationalLogManager.AppendMessage(exp.ToString());
                        return(null);
                    }
                }
                AccessMDB.FileToEncrypt(m_SysDbPath);
                return(m_syscon);
            }
            catch (Exception exp)
            {
                OperationalLogManager.AppendMessage(exp.ToString());
                m_syscon = null;
            }
            return(null);
        }