예제 #1
0
        static void Main()
        {
            System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN");
            DevExpress.UserSkins.BonusSkins.Register();
            DevExpress.Skins.SkinManager.EnableFormSkins();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            string  serverIP   = "";
            Int32   serverPort = 0;
            Boolean _isUpdate  = false;

            if (FileUtil.IsExistFile(@"AutoUpdater\AutoUpdater.exe.config"))
            {
                AppConfig appConfig = new AppConfig(@"AutoUpdater\AutoUpdater.exe.config");
                serverIP   = appConfig.AppConfigGet("ServerIP");
                serverPort = Convert.ToInt32(appConfig.AppConfigGet("ServerPort"));
                _isUpdate  = Convert.ToBoolean(appConfig.AppConfigGet("isUpdate"));

                // 检查更新服务器端口是否可用
                if (_isUpdate && (NetworkUtil.CheckIPPortEnabled(serverIP, serverPort) < 0 || NetworkUtil.CheckIPPortEnabled(serverIP, serverPort + 2) < 0))
                {
                    _isUpdate = false;
                    MessageDxUtil.ShowTips("更新服务器端不可用,服务器更新取消!");
                }
            }

            // 自动升级工具
            if (_isUpdate && VersionHelper.HasNewVersion(serverIP, serverPort) && (MessageDxUtil.ShowYesNoAndTips("服务器有新的版本是否更新") == DialogResult.Yes))
            {
                string updateExePath = AppDomain.CurrentDomain.BaseDirectory + "AutoUpdater\\AutoUpdater.exe";
                System.Diagnostics.Process myProcess = System.Diagnostics.Process.Start(updateExePath);
            }
            else
            {
                WaitDialogForm WaitBeforeLogin = null;
                new Thread((ThreadStart) delegate
                {
                    WaitBeforeLogin = new DevExpress.Utils.WaitDialogForm("请稍候...", "正在加载应用系统");
                    //Application.Run(new TestCommons.Form1(WaitBeforeLogin));
                }).Start();
            }
            //Application.Run(new JCodes.Framework.Test.Form1());
            // Application.Run(new JCodes.Framework.TestWinForm.Form2());

            // 分页控件
            //Application.Run(new TestDictionary.Form1());

            // 测试公共类
            //Application.Run(new TestCommons.Form1());

            //Application.Run(new TestControlUtil.Form1());

            // 附件测试
            //Application.Run(new TestAttachmentDx.Form1());

            // 权限管理系统
            //Application.Run(new TestSecurityMix_WCF_WIN.Form1());
            //Application.Run(new JCodes.Framework.SmallTools.Test.FrmWinRarZip());

            //Application.Run(new JCodes.Framework.Test.IPOdepthDealfrm());
            //Application.Run(new JCodes.Framework.AddIn.SmallTools.xlsDataDeal());

            //Application.Run(new JCodes.Framework.TestWinForm.BizControlForm());


            // Application.Run(new ZheshangKaoshi());

            //Application.Run(new JCodes.Framework.AddIn.Test.MainForm());
            //Application.Run(new JCodes.Framework.TestWinForm.Basic.FrmTestBizControl());
            //Application.Run(new JCodes.Framework.TestWinForm.ZSJob.TouHangDiGaoFrm());
            //Application.Run(new JCodes.Framework.TestWinForm.PdfDemo.PdfTestFrm());
            //Application.Run(new JCodes.Framework.TestWinForm.ZsDaixiao.FrmDealConsignment());

            //Application.Run(new JCodes.Framework.Test.AMSDownloadForm());
            //Application.Run(new JCodes.Framework.Test.DakaDateSetFrm());
            Application.Run(new JCodes.Framework.TestWinForm.Basic.InitDataFrm());
            //Application.Run(new JCodes.Framework.Wind.FrmWindDemo());
        }
예제 #2
0
        static void Main(string[] args)
        {
            // lst 保存进程参数,后续判断参数只用使用lst.Contains 即可
            List <string> lst = new List <string>();

            foreach (string arg in args)
            {
                lst.Add(arg);
            }

            // 20150918 wujm09397 捕捉系统框架的异常
            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

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

            DevExpress.Skins.SkinManager.EnableFormSkins();
            DevExpress.UserSkins.BonusSkins.Register();
            UserLookAndFeel.Default.SetSkinStyle("DevExpress Style");

            Portal.gc._waitBeforeLogin = new WaitDialogForm(Const.StartAppText, Const.SystemTipInfo);

            AppConfig appConfig  = new AppConfig(@"AutoUpdater\\AutoUpdater.exe.config");
            string    serverIP   = appConfig.AppConfigGet("ServerIP");
            Int32     serverPort = Convert.ToInt32(appConfig.AppConfigGet("ServerPort"));
            Boolean   _isUpdate  = Convert.ToBoolean(appConfig.AppConfigGet("isUpdate"));

            // 检查更新服务器端口是否可用
            if (_isUpdate && (NetworkUtil.CheckIPPortEnabled(serverIP, serverPort) < 0 || NetworkUtil.CheckIPPortEnabled(serverIP, serverPort + 2) < 0))
            {
                _isUpdate = false;
                MessageDxUtil.ShowTips("更新服务器端不可用,服务器更新取消!");
            }

            // 自动升级工具
            if (_isUpdate && VersionHelper.HasNewVersion(serverIP, serverPort) && (MessageDxUtil.ShowYesNoAndTips("服务器有新的版本是否更新") == DialogResult.Yes))
            {
                string updateExePath = AppDomain.CurrentDomain.BaseDirectory + "AutoUpdater\\AutoUpdater.exe";
                System.Diagnostics.Process myProcess = System.Diagnostics.Process.Start(updateExePath);
            }
            else
            {
                // 重启之后需要停止一段时间确保进程已经死了
                if (lst.Contains(Const.Restart))
                {
                    Thread.Sleep(Const.SLEEP_TIME * 2);
                }

                Process[] processes = System.Diagnostics.Process.GetProcessesByName(Process.GetCurrentProcess().ProcessName);

                try
                {
                    if (processes.Length > 1)
                    {
                        MessageDxUtil.ShowTips(Const.StartAppText);
                        Thread.Sleep(Const.SLEEP_TIME);
                        System.Environment.Exit(1);
                    }
                    else
                    {
                        LoginNormal(args);
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.WriteLog(LogLevel.LOG_LEVEL_EMERG, ex, typeof(Program));
                    MessageDxUtil.ShowError(ex.Message);
                }
            }
        }