Example #1
0
        private void AttachEvents()
        {
            if (!DesignMode)
            {
                this.Shown           += new EventHandler(OnShown);
                this.HandleDestroyed += new EventHandler(OnHandleDestroyed);
            }

            _updateHelper = new ApplicationUpdateHelper();
        }
Example #2
0
        private void bgWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (File.Exists((Path.GetTempPath() + update.Version + @".zip")))
            {
                eventLog.WriteEntry("Get directory to update" + DateTime.Now.ToString());

                string currentDirectory = Path.GetDirectoryName(this.applicationInfo.ApplicationAssembly.Location);

                eventLog.WriteEntry("Begin update" + DateTime.Now.ToString());

                // "Install" it
                ApplicationUpdateHelper.Update(currentDirectory, update, clientZipLocation);
            }
        }
Example #3
0
        private void continueLoading()
        {
            SharedLocator.setStaticInfo(new StaticInfo());
            SharedLocator.setExercisesManager(new exercises.ExerciseManager());

            loadState();
            if (_preloaderScreen != null)
            {
                _preloaderScreen.Close();
                _preloaderScreen.Dispose();
            }
            showTasksWindow();
            ApplicationUpdateHelper.checkForTheNewVersion();
        }
 private bool notifyAboutNewVersion()
 {
     Debug.Assert(StaticUpdateChecker.NewVersionInformation != null);
     if (isTrackingTime())
     {
         _applicationUpdateReminderPostponedTillTimerStop     = false;
         _applicationUpdateNotificationPostponedTillTimerStop = true;
         Trace.TraceInformation("[MainForm] New version appeared during time tracking");
     }
     else if (ApplicationUpdateHelper.ShowCheckForUpdatesDialog())
     {
         doCloseOnUpgrade();
         return(true);
     }
     return(false);
 }
        private void upgradeApplicationByUserRequest()
        {
            if (StaticUpdateChecker.NewVersionInformation == null)
            {
                Debug.Assert(false); // Should not UI control be disabled now?..
                return;
            }

            Trace.TraceInformation("[MainForm] User clicked at new version label in UI");
            if (ApplicationUpdateHelper.InstallUpdate(StaticUpdateChecker.NewVersionInformation.InstallerFilePath))
            {
                doCloseOnUpgrade();
            }
            else
            {
                Trace.TraceInformation("[MainForm] User discarded to install a new version");
            }
        }
Example #6
0
        private void bgWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            // Download file
            try
            {
                eventLog.WriteEntry("Entering background worker" + DateTime.Now.ToString());
                //int counter = 0;
                //foreach (ApplicationUpdateXml.UpdateApplication application in update.Applications)
                //{
                //    foreach (var file in application.Files)
                //    {
                //        var webClient = webClients[counter];
                //        file.tempFile = Path.GetTempFileName();
                //        webClient.DownloadFileAsync(new Uri(update.Uri + @"/" + file.Name), file.tempFile);
                //        counter++;
                //    }
                //}

                if (File.Exists(Path.GetTempPath() + update.Version + @".zip"))
                {
                    File.Delete(Path.GetTempPath() + update.Version + @".zip");
                }

                //var remoteFileSize = webClient.OpenRead(new Uri(UpdateZipLocation + @"/" + update.Version + @".zip")).Length;
                //eventLog.WriteEntry(remoteFileSize.ToString());

                eventLog.WriteEntry("downloading file" + DateTime.Now.ToString());

                webClient.DownloadFile(new Uri(UpdateZipLocation + @"/" + update.Version + @".zip"), Path.GetTempPath() + update.Version + @".zip");

                eventLog.WriteEntry("File downloaded" + DateTime.Now.ToString());

                if (!ApplicationUpdateHelper.DoesFilesMatch(Path.GetTempPath() + update.Version + @".zip", update.Md5))
                {
                    eventLog.WriteEntry(string.Format("{0} does not match MD5 : {1}", Path.GetTempPath() + update.Version + @".zip", update.Md5));
                    throw new Exception(String.Format("{0} failed to download", update.Version));
                }
            }
            catch (Exception ex)
            {
                eventLog.WriteEntry(string.Format("Exception : {0}", ex.ToString()));
                throw ex;
            }
        }
 private bool remindAboutNewVersion()
 {
     Trace.TraceInformation("[MainForm] Reminder timer triggered (or re-triggered after timer stop)");
     if (StaticUpdateChecker.NewVersionInformation != null && Program.Settings.RemindAboutAvailableNewVersion)
     {
         if (isTrackingTime())
         {
             _applicationUpdateReminderPostponedTillTimerStop     = true;
             _applicationUpdateNotificationPostponedTillTimerStop = false;
             Trace.TraceInformation("[MainForm] Reminder triggered during time tracking");
         }
         else if (ApplicationUpdateHelper.RemindAboutAvailableVersion())
         {
             doCloseOnUpgrade();
             return(true);
         }
     }
     return(false);
 }
Example #8
0
        private void CheckForUpdate()
        {
            try
            {
                eventLog.WriteEntry("Enter checking update" + DateTime.Now.ToString());
                // Update the service state to Start Pending.
                ServiceStatus serviceStatus = new ServiceStatus();
                serviceStatus.dwCurrentState = ServiceState.SERVICE_RUNNING;
                serviceStatus.dwWaitHint     = 100000;
                SetServiceStatus(this.ServiceHandle, ref serviceStatus);

                eventLog.WriteEntry("Checking for update xml" + DateTime.Now.ToString());

                ApplicationUpdateXml updateXML = ApplicationUpdateHelper.HasUpdate(this);

                eventLog.WriteEntry("Found update xml" + DateTime.Now.ToString() + updateXML.ToString());

                if (updateXML != null)
                {
                    update = updateXML;
                    eventLog.WriteEntry(String.Format("App Version {0}", this.applicationInfo.ApplicationAssembly.GetName().Version.ToString()));
                    eventLog.WriteEntry(String.Format("update version {0}", update.Version));
                    eventLog.WriteEntry("Is newer" + DateTime.Now.ToString() + update.IsNewerThan(this.applicationInfo.ApplicationAssembly.GetName().Version).ToString());

                    // Check if the update is not null and is a newer version than the current application
                    if (update != null && update.IsNewerThan(this.applicationInfo.ApplicationAssembly.GetName().Version))
                    {
                        eventLog.WriteEntry("download update" + DateTime.Now.ToString());
                        this.DownloadUpdate(update); // Do the update
                        eventLog.WriteEntry("updated downloaded" + DateTime.Now.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
                eventLog.WriteEntry("CheckForUpdate Excption " + DateTime.Now.ToString() + ex.ToString());
                timer.Stop();
            }
        }
Example #9
0
        private static void onLaunchMainInstance(LaunchOptions options)
        {
            cleanUpOldFiles();
            if (ApplicationUpdateHelper.ShowCheckForUpdatesDialog())
            {
                Trace.TraceInformation("Application is exiting to install a new version");
                return;
            }

            bool runningAsUwp = new DesktopBridge.Helpers().IsRunningAsUwp();

            Trace.TraceInformation(String.Format("Running as UWP = {0}", runningAsUwp ? "Yes" : "No"));
            if (runningAsUwp)
            {
                revertOldInstallations();
            }

            string path = runningAsUwp ? Constants.UWP_Launcher_Name : Process.GetCurrentProcess().MainModule.FileName;

            if (!prepareGitEnvironment() || !integrateInDiffTool(path))
            {
                return;
            }

            bool    integratedInGitExtensions = integrateInGitExtensions();
            bool    integratedInSourceTree    = integrateInSourceTree();
            Version osVersion = Environment.OSVersion.Version;

            Trace.TraceInformation(String.Format("OS version is {0}", osVersion.ToString()));
            Version clrVersion = Environment.Version;

            Trace.TraceInformation(String.Format("CLR version is {0}", clrVersion.ToString()));
            Trace.TraceInformation(String.Format(".NET Framework version is {0}", typeof(string).Assembly.ImageRuntimeVersion));

            LaunchOptions.NormalModeOptions normalOptions = options.SpecialOptions as LaunchOptions.NormalModeOptions;
            Application.Run(new MainForm(normalOptions.StartMinimized, runningAsUwp, normalOptions.StartUrl,
                                         integratedInGitExtensions, integratedInSourceTree));
        }