static void Main() { try { bool bCreate; System.Threading.Mutex mutex = new System.Threading.Mutex(false, "SINGILE_INSTANCE_MUTEX", out bCreate); if (!bCreate) { MessageBox.Show("程序已经启动!只能运行一个实例", "提示", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); Application.Exit(); return; } //Xpo连接数据库 ConnectionHelper.Connect(AutoCreateOption.DatabaseAndSchema); //设置应用程序处理异常方式:ThreadException处理 Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); //处理UI线程异常 Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException); //处理非UI线程异常 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); #region 应用程序的主入口点 Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); BonusSkins.Register(); SkinManager.EnableFormSkins(); //UserLookAndFeel.Default.SetSkinStyle("DevExpress Style"); ///// 连接数据库 ////// SqlAssist.ConnectDb(); ///// 检查版本 /////// //string curNewestVersion = Tools.getNewVersion(); //if (string.Compare(curNewestVersion, AppInfo.AppVersion) > 0) //{ // MessageBox.Show("服务器发现更新的版本!系统需要升级", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); // Tools.DownloadNew(curNewestVersion); // SqlAssist.DisConnect(); // //启动升级拷贝 ////// // try // { // Process.Start("Upgrade.exe", curNewestVersion); // } // catch (Exception e) // { // Console.WriteLine(e.Message); // } // Application.Exit(); // return; //} // 检查 工作站是否进行登记 Envior.WORKSTATIONID = ConfigurationManager.OpenExeConfiguration(Application.ExecutablePath).AppSettings.Settings["workstationID"].Value.ToString(); string hostname = string.Empty; string ipaddress = string.Empty; Tools.GetIpAddress(out hostname, out ipaddress); if (!string.IsNullOrEmpty(Envior.WORKSTATIONID)) { switch (MiscAction.WorkStationIsRegistered(Envior.WORKSTATIONID, hostname, ipaddress)) { case 0: //未登记 XtraMessageBox.Show("此工作站尚未登记!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); return; case 2: //主机名不符 XtraMessageBox.Show("此工作站【计算机名称】与登记不符!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); return; case 3: //ip地址不符 XtraMessageBox.Show("此工作站【IP地址】与登记不符!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); Application.Exit(); return; default: break; } } else { XtraMessageBox.Show("未设置工作站ID!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Stop); Application.Exit(); return; } Application.Run(new Frm_main()); #endregion } catch (Exception ex) { string str = GetExceptionMsg(ex, string.Empty); LogUtils.Error(str); XtraMessageBox.Show(str, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } }