Ejemplo n.º 1
0
        public void Loaded()
        {
            try
            {
                Preferences currentPrefs = _preferencesService.CurrentPreferences.Clone();

                bool updateAvailable = false;

                if (currentPrefs.AppCheckForUpdates)
                {
                    UpdateInfo updateInfo = _updateService.CheckForUpdate();

                    if (updateInfo != null)
                    {
                        updateAvailable = true;
                        _navigationService.ShowUpdateInfo(updateInfo);
                    }
                }

                bool searchOnStartup = false;

                if (!updateAvailable && currentPrefs.SearchOnStartup)
                {
                    currentPrefs.Validate();

                    if (!currentPrefs.HasErrors)
                    {
                        searchOnStartup = true;

                        SearchParameters searchParams = new SearchParameters(SearchType.Channel)
                        {
                            Channel         = currentPrefs.SearchChannelName,
                            VideoType       = currentPrefs.SearchVideoType,
                            LoadLimitType   = currentPrefs.SearchLoadLimitType,
                            LoadFrom        = DateTime.Now.Date.AddDays(-currentPrefs.SearchLoadLastDays),
                            LoadFromDefault = DateTime.Now.Date.AddDays(-currentPrefs.SearchLoadLastDays),
                            LoadTo          = DateTime.Now.Date,
                            LoadToDefault   = DateTime.Now.Date,
                            LoadLastVods    = currentPrefs.SearchLoadLastVods
                        };

                        _searchService.PerformSearch(searchParams);
                    }
                }

                if (!updateAvailable && !searchOnStartup)
                {
                    _navigationService.ShowWelcome();
                }

                _twitchService.Authorize(_runtimeDataService.RuntimeData.AccessToken);
            }
            catch (Exception ex)
            {
                _dialogService.ShowAndLogException(ex);
            }
        }
Ejemplo n.º 2
0
 private async Task CheckForUpdate()
 {
     if (Helpers.SystemHelper.IsNetworkConnected)
     {
         await updateService.CheckForUpdate();
     }
     else
     {
         await notificationService.ShowToastAsync(i18NService.GetXmlStringByKey("ToastNetworkOffline"), new TimeSpan(0, 0, 3), Controls.ToastType.Error);
     }
 }
Ejemplo n.º 3
0
        public ToolStripMenuItem GetItem()
        {
            var result = new ToolStripMenuItem {
                Text = "Check for Update"
            };

            result.Click += (sender, args) =>
            {
                UpdateService.CheckForUpdate();
            };
            return(result);
        }
Ejemplo n.º 4
0
        private void ShowUpdateDialog()
        {
            Preferences currentPrefs = _preferencesService.CurrentPreferences.Clone();

            if (currentPrefs.AppCheckForUpdates)
            {
                Task.Run(() => _updateService.CheckForUpdate()).ContinueWith(t =>
                {
                    if (!t.IsFaulted && t.Result != null)
                    {
                        _dialogService.ShowUpdateInfoDialog(t.Result);
                    }
                }, TaskScheduler.FromCurrentSynchronizationContext());
            }
        }
Ejemplo n.º 5
0
        public override async Task RunJobAsync()
        {
            try
            {
                await LogInformation("Contacting Github now to see if new version is available.");

                var update = _updateService.CheckForUpdate(Settings);
                await LogProgress(20);

                if (update.IsUpdateAvailable && Settings.AutoUpdate)
                {
                    await LogInformation($"New version found: v{update.AvailableVersion}");
                    await LogInformation($"Auto update is enabled so going to update the server now!");

                    await _settingsService.SetUpdateInProgressSettingAsync(true);

                    await HubHelper.BroadcastUpdateState(true);

                    Task.WaitAll(_updateService.DownloadZipAsync(update));
                    await LogProgress(50);

                    await _updateService.UpdateServerAsync();

                    await _settingsService.SetUpdateInProgressSettingAsync(false);

                    await HubHelper.BroadcastUpdateFinished(true);
                }
                else if (update.IsUpdateAvailable)
                {
                    await LogInformation($"New version found: v{update.AvailableVersion}");
                    await LogInformation("Auto updater is disabled, so going to end the job now.");
                }
                else
                {
                    await LogInformation("No new version available");
                }
            }
            catch (Exception)
            {
                await _settingsService.SetUpdateInProgressSettingAsync(false);

                await HubHelper.BroadcastUpdateState(false);

                await HubHelper.BroadcastUpdateFinished(false);

                throw;
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 显示"关于"
        /// </summary>
        private void ShowAbout()
        {
            Version version = Assembly.GetExecutingAssembly().GetName().Version;

            Version osVersion = Environment.OSVersion.Version;

            string caption     = i18NService.GetXmlStringByKey("AboutCaption");
            string versionInfo = string.Format(i18NService.GetXmlStringByKey("AboutVersionFormatter"), osVersion, version);

            if (TaskDialog.OSSupportsTaskDialogs)
            {
                using TaskDialog dialog = new TaskDialog
                      {
                          AllowDialogCancellation = true,
                          ExpandedByDefault       = true,
                          EnableHyperlinks        = true,
                          WindowTitle             = caption,
                          MainInstruction         = i18NService.GetXmlStringByKey("AboutInstruction"),
                          Content             = i18NService.GetXmlStringByKey("AboutContent"),
                          ExpandedInformation = versionInfo,
                          Footer     = i18NService.GetXmlStringByKey("AboutFooter"),
                          FooterIcon = TaskDialogIcon.Information
                      };

                var checkUpdateButton = new TaskDialogButton(i18NService.GetXmlStringByKey("CheckUpdate"));
                dialog.Buttons.Add(checkUpdateButton);
                dialog.Buttons.Add(new TaskDialogButton(ButtonType.Ok)
                {
                    Default = true
                });
                dialog.HyperlinkClicked += (s, e) => Helpers.ProcessHelper.OpenHyperlink(e.Href);
                var result = dialog.ShowDialog(this);

                if (result == checkUpdateButton)
                {
                    updateService.CheckForUpdate();
                }
            }
            else
            {
                dialogService.ShowMessageBox(
                    versionInfo, caption,
                    MessageBoxButton.OK, MessageBoxImage.Information, MessageBoxResult.OK, this);
            }
        }
Ejemplo n.º 7
0
        private async Task UpdateCheck(string user, string repo)
        {
            try
            {
                var latest = await Updater.CheckForUpdate(user, repo, Version);

                if (latest.HasUpdate)
                {
                    Logger.Info($"Plugin Update available ({latest.Version})");
                    Notify("Plugin Update Available",
                           $"{Name} v{latest.Version}",
                           IcoMoon.Download3, latest.DownloadUrl);
                }
            }
            catch (Exception e)
            {
                Logger.Error($"Github update failed: {e.Message}");
            }
        }
Ejemplo n.º 8
0
        public ActionResult CheckForUpdate()
        {
            var result = _updateService.CheckForUpdate();

            return(Ok(_mapper.Map <UpdateResultViewModel>(result)));
        }