Esempio n. 1
0
        public async void DownloadUpdateClick()
        {
            await Task.Run(() => {
                CLog.Here().Information($"AppUpdaterService - DownloadUpdate : [ Download for Update... ]");
                AvailableUpdate?.ClosePopUp();

                // this is async so that it can grab the download file name from the server
                SparkleInst.DownloadStarted -= CBStartedDownloading;
                SparkleInst.DownloadStarted += CBStartedDownloading;

                SparkleInst.DownloadFinished -= CBFinishedDownloading;
                SparkleInst.DownloadFinished += CBFinishedDownloading;

                SparkleInst.DownloadHadError -= CBDownloadError;
                SparkleInst.DownloadHadError += CBDownloadError;

                SparkleInst.DownloadMadeProgress -= CBDownloadMadeProgress;
                SparkleInst.DownloadMadeProgress += CBDownloadMadeProgress;

                SparkleInst.DownloadCanceled -= CBDownloadCanceled;
                SparkleInst.DownloadCanceled += CBDownloadCanceled;
            });

            await SparkleInst.InitAndBeginDownload(UpdateInfo.Updates.First());

            // ok, the file is downloading now
        }
Esempio n. 2
0
 public async void SkipUpdateClick(AppCastItem CurrentItem)
 {
     await Task.Run(() => {
         CLog.Here().Information($"AppUpdaterService - SkipUpdate : [ {CurrentItem.AppName} {CurrentItem.Version} ]");
         SparkleInst.Configuration.SetVersionToSkip(CurrentItem.Version);
     });
 }
Esempio n. 3
0
 public async void InstallUpdateClick()
 {
     await Task.Run(() => {
         CLog.Here().Information($"AppUpdaterService - InstallUpdate : [ Install for Update [{DownloadPath}] ]");
         SparkleInst.CloseApplication += CBCloseApplication;
         SparkleInst.InstallUpdate(UpdateInfo.Updates.First(), DownloadPath);
     });
 }
Esempio n. 4
0
 public async void CBCloseApplication()
 {
     // System.Windows.Application.Current.Shutdown();
     await Task.Run(() => {
         int nProcessId = Process.GetCurrentProcess().Id;
         CLog.Here().Information($"Self Process Exit to Relaunch after Install and Upgrade: self process is kill (PID:{nProcessId})");
         Process localById = Process.GetProcessById(nProcessId);
         localById.Kill();
     });
 }
Esempio n. 5
0
 public async void CBDownloadError(AppCastItem item, string path, Exception exception)
 {
     // Display in progress when error occured -> DownloadInfo.Text = "We had an error during the download process :( -- " + exception.Message;
     await Task.Run(() => {
         string DownloadLog = string.Format($"{item.AppName} {item.Version}, We had an error during the download process :( -- {exception.Message}");
         CLog.Here().Error(DownloadLog);
         DownloadUpdate?.ClosePopUp();
         File.Delete(path);
         IsCancelRequested = false;
         IsCanceled        = false;
     });
 }
Esempio n. 6
0
        public async void CBFullUpdateCloseApplication()
        {
            //System.Windows.Application.Current.Shutdown();
            await Task.Delay(2000);

            await Task.Run(() => {
                // RunFullUpdateUpdateStatusLabel.Text = "Closing application...";
                int nProcessId = Process.GetCurrentProcess().Id;
                CLog.Here().Information($"Self Process Exit to Relaunch after Install and Upgrade: self process is kill (PID:{nProcessId})");
                Process localById = Process.GetProcessById(nProcessId);
                localById.Kill();
            });
        }
Esempio n. 7
0
        public async void CBDownloadCanceled(AppCastItem item, string path)
        {
            await Task.Run(() => {
                CLog.Here().Information($"AppUpdaterService - CBDownloadCanceled : [ {item.AppName} {item.Version} Cancel downloading! : [{path}] ]");

                if (IsCanceled == false)
                {
                    IsCancelRequested = false;
                    IsCanceled        = true;
                    DownloadUpdate?.ClosePopUp();
                }
            });
        }
Esempio n. 8
0
        /* To Function Features */
        public async void CheckUpdatesClick(SGCheckUpdate sgCheckUpdate                 = null,
                                            SGAvailableUpdate sgAvailableUpdate         = null,
                                            SGDownloadUpdate sgDownloadUpdate           = null,
                                            SGFinishedDownload sgFinishedDownload       = null,
                                            SGMessageNotification sgMessageNotification = null)
        {
            CheckUpdate         = sgCheckUpdate;
            AvailableUpdate     = sgAvailableUpdate;
            DownloadUpdate      = sgDownloadUpdate;
            FinishedDownload    = sgFinishedDownload;
            MessageNotification = sgMessageNotification;

            CLog.Here().Information($"AppUpdaterService - CheckUpdates : [ Checking for updates... ]");
            CheckUpdate?.OpenPopUp();
            UpdateInfo = await SparkleInst.CheckForUpdatesQuietly();

            await Task.Delay(1000);

            await Task.Run(() => {
                CheckUpdate?.ClosePopUp();
                // use _sparkle.CheckForUpdatesQuietly() if you don't want the user to know you are checking for updates!
                // if you use CheckForUpdatesAtUserRequest() and are using a UI, then handling things yourself is rather silly
                // as it will show a UI for things
                if (UpdateInfo != null)
                {
                    switch (UpdateInfo.Status)
                    {
                    case UpdateStatus.UpdateAvailable:
                        CLog.Here().Information($"AppUpdaterService - CheckUpdates : [ There's an update available! ]");
                        AvailableUpdate?.OpenPopUp(SparkleInst, UpdateInfo.Updates);
                        break;

                    case UpdateStatus.UpdateNotAvailable:
                        CLog.Here().Information($"AppUpdaterService - CheckUpdates : [ There's no update available :( ]");
                        MessageNotification?.OpenPopUp("There's no update available :(");
                        break;

                    case UpdateStatus.UserSkipped:
                        CLog.Here().Information($"AppUpdaterService - CheckUpdates : [ The user skipped this update! ]");
                        MessageNotification?.OpenPopUp("The user skipped this update!<br>You have elected to skip this version.");
                        break;

                    case UpdateStatus.CouldNotDetermine:
                        CLog.Here().Information($"AppUpdaterService - CheckUpdates : [ We couldn't tell if there was an update... ]");
                        MessageNotification?.OpenPopUp("We couldn't tell if there was an update...");
                        break;
                    }
                }
            });
        }
Esempio n. 9
0
        public async void UpdateAutomaticallyClick()
        {
            await Task.Run(() => {
                // RunFullUpdateUpdateStatusLabel.Text = "Checking for update...";
                CLog.Here().Information($"AppUpdaterService - UpdateAutomatically : [ Checking for updates... ]");

                SparkleInst.UserInteractionMode = UserInteractionMode.DownloadAndInstall;
                SparkleInst.UpdateDetected     += CBFullUpdateUpdateDetected;
                SparkleInst.DownloadStarted    += CBFullUpdateStartedDownloading;
                SparkleInst.DownloadFinished   += CBFullUpdateDownloadFileIsReady;
                SparkleInst.CloseApplication   += CBFullUpdateCloseApplication;
            });

            await SparkleInst.CheckForUpdatesQuietly();
        }