Exemplo n.º 1
0
        private async Task CheckForUpdate()
        {
            try
            {
                CurrentState = State.Checking;
                using (var manager = await UpdateManager.GitHubUpdateManager("https://github.com/wolkesson/SampleCrunch", null, null, null, Properties.Settings.Default.PreRelease))
                {
                    var updates = await manager.CheckForUpdate();

                    this.lastVersion = updates?.ReleasesToApply?.OrderBy(x => x.Version).LastOrDefault();

                    if (this.lastVersion == null)
                    {
                        CurrentState = State.NoUpdateAvailable;
                    }
                    else
                    {
                        CurrentState = State.UpdateAvailable;
                        RaisePropertyChanged <string>(nameof(AvailableVersion));
                    }
                }
            }
            catch (Exception e)
            {
                AppTelemetry.ReportError("Update", e);
                CurrentState = State.Failed;
            }
        }
Exemplo n.º 2
0
        private async void Execute_UpdateCommand()
        {
            if (this.updating)
            {
                return;
            }

            Updating     = true;
            CurrentState = State.Checking;

            try
            {
                Stopwatch watch = Stopwatch.StartNew();
                using (var manager = await UpdateManager.GitHubUpdateManager("https://github.com/wolkesson/SampleCrunch", null, null, null, Properties.Settings.Default.PreRelease))
                {
                    var updates = await manager.CheckForUpdate();

                    var lastVersion = updates?.ReleasesToApply?.OrderBy(x => x.Version).LastOrDefault();
                    CurrentState = State.Downloading;
                    await manager.DownloadReleases(new[] { lastVersion });

#if DEBUG
                    System.Windows.Forms.MessageBox.Show("DEBUG: Don't actually perform the update in debug mode");
#else
                    CurrentState = State.Installing;

                    //manager.CreateShortcutForThisExe();

                    MainViewModel main = SimpleIoc.Default.GetInstance <MainViewModel>();

                    // Send Telemetry
                    System.Collections.Specialized.NameValueCollection data = new System.Collections.Specialized.NameValueCollection
                    {
                        { "from", main.Version },
                        { "to", this.lastVersion.Version.ToString() },
                        { "elapse", watch.ElapsedMilliseconds.ToString() }
                    };
                    AppTelemetry.ReportEvent("Updating", data);

                    //System.Windows.Forms.MessageBox.Show("The application has been updated - please restart the app.");
                    await manager.ApplyReleases(updates);

                    await manager.UpdateApp();

                    BackupSettings();

                    CurrentState = State.Installed;
#endif
                }
            }
            catch (Exception e)
            {
                AppTelemetry.ReportError("Update", e);
                CurrentState = State.Failed;
            }
            finally
            {
                if (CurrentState == State.Installed)
                {
                    UpdateManager.RestartApp();
                }
                Updating = false;
            }
        }
Exemplo n.º 3
0
 public void SendErrorReport()
 {
     AppTelemetry.OverrideUID = "test";
     AppTelemetry.ReportError("FakeError", new Exception("This is an alternative exeption"));
     // Use REST API to test if write was succesful
 }