Exemple #1
0
 public ProxyForm(LoginForm lf)
 {
     InitializeComponent();
     this.lf = lf;
 }
Exemple #2
0
 public ProxyForm(LoginForm lf)
 {
     InitializeComponent();
     this.lf = lf;
 }
Exemple #3
0
        static void Main()
        {
            try
            {
                //处理未捕获的异常   
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                //处理UI线程异常   
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                //处理非UI线程异常   
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);


                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                //删除老版本文件
                string[] oldFiles = { "Common.dll", "GlassButton.dll", "TicketHelper.exe" };
                foreach (string str in oldFiles)
                {
                    if (File.Exists(str))
                        File.Delete(str);
                }
                string checkUpdateUrl = "http://waner8.sinaapp.com/Update.txt";
                HttpClient client = new HttpClient();
                FileVersionInfo myFileVersion = FileVersionInfo.GetVersionInfo(System.Windows.Forms.Application.ExecutablePath);
                client.TimeOut = 5000;
                string json = client.Get(checkUpdateUrl);
                bool exit = false;
                if (json != "")
                {
                    if (json != "timeout")
                    {
                        UpdateInfo ui = JsonHelper.FromJson<UpdateInfo>(json);
                        if (ui.NewVersion != myFileVersion.FileVersion)
                        {
                            exit = true;
                        }
                    }
                }
                if (exit)
                {
                    json = json.Replace("\"", "'");
                    Process.Start("AutoUpdater.exe", json);
                    Application.Exit();
                }
                else
                {
                    LoadingForm lf = new LoadingForm();
                    if (lf.ShowDialog() == DialogResult.OK)
                    {
                        LoginForm l = new LoginForm();
                        if (l.ShowDialog() == DialogResult.OK)
                        {
                            Application.Run(new MainForm());
                        }
                        else
                        {
                            Application.Exit();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string str = "";
                string strDateInfo = "出现应用程序未处理的异常:" + DateTime.Now.ToString() + "\r\n";
                if (ex != null)
                {
                    str = string.Format(strDateInfo + "异常类型:{0}\r\n异常消息:{1}\r\n异常信息:{2}\r\n",
                         ex.GetType().Name, ex.Message, ex.StackTrace);
                }
                else
                {
                    str = string.Format("应用程序线程错误:{0}", ex);
                }

                writeLog(str);
            }
        }
Exemple #4
0
        static void Main()
        {
            try
            {
                //处理未捕获的异常
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                //处理UI线程异常
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                //处理非UI线程异常
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);


                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                //删除老版本文件
                string[] oldFiles = { "Common.dll", "GlassButton.dll", "TicketHelper.exe" };
                foreach (string str in oldFiles)
                {
                    if (File.Exists(str))
                    {
                        File.Delete(str);
                    }
                }
                string          checkUpdateUrl = "http://waner8.sinaapp.com/Update.txt";
                HttpClient      client         = new HttpClient();
                FileVersionInfo myFileVersion  = FileVersionInfo.GetVersionInfo(System.Windows.Forms.Application.ExecutablePath);
                client.TimeOut = 5000;
                string json = client.Get(checkUpdateUrl);
                bool   exit = false;
                if (json != "")
                {
                    if (json != "timeout")
                    {
                        UpdateInfo ui = JsonHelper.FromJson <UpdateInfo>(json);
                        if (ui.NewVersion != myFileVersion.FileVersion)
                        {
                            exit = true;
                        }
                    }
                }
                if (exit)
                {
                    json = json.Replace("\"", "'");
                    Process.Start("AutoUpdater.exe", json);
                    Application.Exit();
                }
                else
                {
                    LoadingForm lf = new LoadingForm();
                    if (lf.ShowDialog() == DialogResult.OK)
                    {
                        LoginForm l = new LoginForm();
                        if (l.ShowDialog() == DialogResult.OK)
                        {
                            Application.Run(new MainForm());
                        }
                        else
                        {
                            Application.Exit();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                string str         = "";
                string strDateInfo = "出现应用程序未处理的异常:" + DateTime.Now.ToString() + "\r\n";
                if (ex != null)
                {
                    str = string.Format(strDateInfo + "异常类型:{0}\r\n异常消息:{1}\r\n异常信息:{2}\r\n",
                                        ex.GetType().Name, ex.Message, ex.StackTrace);
                }
                else
                {
                    str = string.Format("应用程序线程错误:{0}", ex);
                }

                writeLog(str);
            }
        }