示例#1
0
        private void UpdaterProc()
        {
            string remote = string.Empty;

            Constants.AvailableUpdate status = IsUpdateAvailable(ref remote);
            UpdateMessageDlg          updmsgdlg;

            Constants.UpdateResponse dlgupdresp;
            if (status == Constants.AvailableUpdate.NoUpdate)
            {
                if (type == Constants.UpdateType.Manual)
                {
                    updmsgdlg = new UpdateMessageDlg("Your version of Group Gator is latest! No new updates available", Constants.UpdateMessageType.Info);
                    updmsgdlg.Display();
                    updmsgdlg.Dispose();
                }
                checking = false;
                return;
            }
            else if (status == Constants.AvailableUpdate.NonCritical)
            {
                updmsgdlg  = new UpdateMessageDlg("A new version of GroupGator is available. Do you want to download this update?", Constants.UpdateMessageType.Question);
                dlgupdresp = updmsgdlg.Display();
                updmsgdlg.Dispose();
                if (dlgupdresp == Constants.UpdateResponse.Yes)
                {
                    GGDisk disk = new GGDisk();
                    try
                    {
                        if (File.Exists(disk.fileupd))
                        {
                            File.Delete(disk.fileupd);
                        }

                        DownloadUpdate(remote, disk.fileupd);

                        updmsgdlg  = new UpdateMessageDlg("Update downloaded! Would you like to exit GroupGator now and install this new update?", Constants.UpdateMessageType.Question);
                        dlgupdresp = updmsgdlg.Display();
                        updmsgdlg.Dispose();
                        if (dlgupdresp == Constants.UpdateResponse.Yes)
                        {
                            System.Diagnostics.Process.Start(disk.fileupd);
                            //todo freeversion update
                            Environment.Exit(0);
                        }
                    }
                    catch (Exception ex)
                    {
                        ;// log.Show(ex.Message.ToString(), 0, true);
                    }
                    finally
                    {
                        checking = false;
                    }
                }
            }
            else if (status == Constants.AvailableUpdate.Critical)
            {
                GGDisk disk = new GGDisk();
                try
                {
                    if (File.Exists(disk.fileupd))
                    {
                        File.Delete(disk.fileupd);
                    }

                    DownloadUpdate(remote, disk.fileupd);
                    updmsgdlg = new UpdateMessageDlg("CRITICAL UPDATE: GroupGATOR will now exit and apply the update.", Constants.UpdateMessageType.Info);
                    updmsgdlg.Display();
                    updmsgdlg.Dispose();

                    System.Diagnostics.Process.Start(disk.fileupd);
                    //todo freeversion update
                    Environment.Exit(0);
                }
                catch (Exception ex)
                {
                    ;
                }
                finally
                {
                    checking = false;
                }
            }

            checking = false;
        }
示例#2
0
        public Constants.AvailableUpdate IsUpdateAvailable(ref string loc)
        {
            string updfile = string.Empty;

            MyUtils.MyUtils util  = new MyUtils.MyUtils();
            MyWeb.MyWeb     myweb = new MyWeb.MyWeb();
            WebService      wserv = new WebService();

            while (updfile == string.Empty)
            {
                updfile = myweb.GetWebPage(wserv.urlupdchk, 0, 0);
                System.Threading.Thread.Sleep(3000);
            }
            lcv  = util.GetStrBetween(updfile, "<TYPEC>", "</TYPEC>");
            lcf  = util.GetStrBetween(updfile, "<CFILE>", "</CFILE>");
            lncv = util.GetStrBetween(updfile, "<TYPENC>", "</TYPENC>");
            lncf = util.GetStrBetween(updfile, "<NCFILE>", "</NCFILE>");
            cv   = cv.Replace(".", string.Empty);
            lncv = lncv.Replace(".", string.Empty);
            lcv  = lcv.Replace(".", string.Empty);

            int icv   = 0;
            int ilncv = 0;
            int ilcv  = 0;

            try
            {
                icv   = Convert.ToInt32(cv);
                ilncv = Convert.ToInt32(lncv);
                ilcv  = Convert.ToInt32(lcv);
            }
            catch (Exception ex)
            {
                icv   = 0;
                ilncv = 0;
                ilcv  = 0;
            }

            Constants.AvailableUpdate ret = Constants.AvailableUpdate.NoUpdate;

            if (icv > ilcv)
            {
                ret = Constants.AvailableUpdate.NoUpdate;
                if (ilncv > icv)
                {
                    ret = Constants.AvailableUpdate.NonCritical;
                    loc = lncf;
                }
            }
            else if (icv == ilcv)
            {
                if (ilncv > icv)
                {
                    loc = lncf;
                    ret = Constants.AvailableUpdate.NonCritical;
                }
            }
            else if (icv < ilcv)
            {
                ret = Constants.AvailableUpdate.Critical;
                if (ilncv >= ilcv)
                {
                    loc = lncf;
                }
                else
                {
                    loc = lcf;
                }
            }

            return(ret);
        }