Exemplo n.º 1
0
 void Step4CheckVersion(string updatedFileName)
 {
     if (CancelUpdate)
     {
         return;
     }
     if (CheckVersionCheckBox.Checked)
     {
         var processFi      = System.Diagnostics.FileVersionInfo.GetVersionInfo(processFileName);
         var updatedFi      = System.Diagnostics.FileVersionInfo.GetVersionInfo(updatedFileName);
         var processVersion = new Version(processFi.FileVersion);
         var updatedVersion = new Version(updatedFi.FileVersion);
         LogPanel.Add("Current version: {0}", processVersion);
         LogPanel.Add("Updated version: {0}", updatedVersion);
         if (processVersion == updatedVersion)
         {
             LogPanel.Add("Versions are the same. Skip Update");
             return;
         }
         if (processVersion > updatedVersion)
         {
             LogPanel.Add("Remote version is older. Skip Update.");
             return;
         }
     }
     Step5ReplaceFiles(updatedFileName);
 }
Exemplo n.º 2
0
        void Step5ReplaceFiles(string updateFileName)
        {
            if (CancelUpdate)
            {
                return;
            }
            // Change the currently running executable so it can be overwritten.
            string bak = processFileName + ".bak";

            CurrentLogItem = LogPanel.Add("Renaming running process...");
            try
            {
                if (System.IO.File.Exists(bak))
                {
                    System.IO.File.Delete(bak);
                }
            }
            catch (Exception ex)
            {
                CurrentLogItem.Message += " Failed: " + ex.Message;
                return;
            }
            System.IO.File.Move(processFileName, bak);
            System.IO.File.Copy(updateFileName, processFileName);
            CurrentLogItem.Message += " Done";
            Step6Restart(processFileName);
        }
Exemplo n.º 3
0
        void Step6Restart(string fileName)
        {
            var process = System.Diagnostics.Process.GetCurrentProcess();

            CurrentLogItem = LogPanel.Add("Restarting...");
            Application.Restart();
        }
Exemplo n.º 4
0
        void Step6Restart()
        {
            if (CancelUpdate)
            {
                return;
            }
            var process = System.Diagnostics.Process.GetCurrentProcess();

            CurrentLogItem = LogPanel.Add("Restarting...");
            System.Windows.Forms.Application.Restart();
        }
Exemplo n.º 5
0
        public void Step2ProcessUpdateResults(CloudMessage results)
        {
            var url = results.Values.GetValue <string>(CloudKey.UpdateUrl);

            if (string.IsNullOrEmpty(url))
            {
                CurrentLogItem.Message += " No new updates.";
                return;
            }
            CurrentLogItem.Message += " Update URL retrieved.";
            LogPanel.Add("{0}", url);
            CurrentLogItem        = LogPanel.Add("Download...");
            _downloader           = new Downloader();
            _downloader.Progress += _downloader_Progress;
            _downloader.LoadAsync(url);
        }
Exemplo n.º 6
0
        void Step1ChekOnline()
        {
            CurrentLogItem = LogPanel.Add("Check Online...");
            var message = new CloudMessage(Engine.CloudAction.CheckUpdates);

            message.Values.Add(CloudKey.ClientVersion, Application.ProductVersion);
            var item = new CloudItem()
            {
                Date    = DateTime.Now,
                Message = message,
                State   = CloudState.None,
                Retries = 4,
            };

            CheckUpateItem = item;
            MainForm.Current.CloudPanel.Add(item);
        }
Exemplo n.º 7
0
 void Step3CheckSignature(string updateFileName)
 {
     if (CheckDigitalSignatureCheckBox.Checked)
     {
         CurrentLogItem = LogPanel.Add("Check Digital Signature...");
         X509Certificate2 certificate;
         Exception        error;
         if (!CertificateHelper.IsSignedAndTrusted(updateFileName, out certificate, out error))
         {
             var errMessage = error == null
                 ? " Failed" : string.Format(" Failed: {0}", error.Message);
             CurrentLogItem.Message += errMessage;
             return;
         }
     }
     Step4CheckVersion(updateFileName);
 }
Exemplo n.º 8
0
        void Step1ChekOnline()
        {
            CurrentLogItem = LogPanel.Add("Check Online...");
            var message = new CloudMessage(Engine.CloudAction.CheckUpdates);
            var ai      = new JocysCom.ClassLibrary.Configuration.AssemblyInfo();

            message.Values.Add(CloudKey.ClientVersion, ai.Version);
            var item = new CloudItem()
            {
                Date    = DateTime.Now,
                Message = message,
                State   = CloudState.None,
                Retries = 4,
            };

            CheckUpateItem = item;
            Global.CloudClient.TasksTimer.DoActionNow(item);
        }