示例#1
0
        private async Task <IReadOnlyList <Release> > GetAllAvailableReleases()
        {
            try
            {
                if (!await ConnectivityHelper.IsConnected())
                {
                    logger.Info("Could not establish a connection to the internet.");

                    _messageBoxService.ShowError(_localizationHelper.GetLocalization("UpdateNoConnectionMessage"),
                                                 _localizationHelper.GetLocalization("Error"));

                    return(null);
                }

                var releases = await ApiClient.Repository.Release.GetAll(GITHUB_USERNAME, GITHUB_PROJECTNAME).ConfigureAwait(false);

                if (releases == null || releases.Count < 1)
                {
                    return(null);
                }

                return(releases);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error getting info about preset updates.");
                return(null);
            }
        }
示例#2
0
        private async Task <IReadOnlyList <Release> > GetAllAvailableReleases()
        {
            try
            {
                if (!await ConnectivityHelper.IsConnected())
                {
                    logger.Info("Could not establish a connection to the internet.");

                    string language = Localization.Localization.GetLanguageCodeFromName(Settings.Default.SelectedLanguage);
                    MessageBox.Show(Localization.Localization.Translations[language]["UpdateNoConnectionMessage"],
                                    Localization.Localization.Translations[language]["Error"],
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Warning);

                    return(null);
                }

                var releases = await ApiClient.Repository.Release.GetAll(GITHUB_USERNAME, GITHUB_PROJECTNAME).ConfigureAwait(false);

                if (releases == null || releases.Count < 1)
                {
                    return(null);
                }

                return(releases);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error getting info about preset updates.");
                return(null);
            }
        }
示例#3
0
        public async Task <bool> IsNewPresetFileAvailableAsync(Version currentPresetVersion)
        {
            try
            {
                var result = false;

                if (!await ConnectivityHelper.IsConnected())
                {
                    Trace.WriteLine("Could not establish a connection to the internet.");

                    string language = Localization.Localization.GetLanguageCodeFromName(Settings.Default.SelectedLanguage);
                    MessageBox.Show(Localization.Localization.Translations[language]["UpdateNoConnectionMessage"],
                                    Localization.Localization.Translations[language]["Error"],
                                    MessageBoxButton.OK,
                                    MessageBoxImage.Warning);

                    return(result);
                }

                var releases = await ApiClient.Repository.Release.GetAll(GITHUB_USERNAME, GITHUB_PROJECTNAME).ConfigureAwait(false);

                if (releases == null || releases.Count < 1)
                {
                    AllReleases = null;
                    return(result);
                }

                AllReleases = releases;

                var latestPresetRelease = releases.FirstOrDefault(x => !x.Draft && !x.Prerelease && x.TagName.StartsWith(RELEASE_PRESET_TAG, StringComparison.OrdinalIgnoreCase));
                //for testing - latest preset and icons release
                //var latestPresetRelease = releases.FirstOrDefault(x => !x.Draft && !x.Prerelease && x.TagName.StartsWith("Presetsv3.0.0", StringComparison.OrdinalIgnoreCase));
                if (latestPresetRelease == null)
                {
                    LatestPresetRelease = null;
                    return(result);
                }

                LatestPresetRelease = latestPresetRelease;

                var latestPresetVersionString = latestPresetRelease.TagName.Replace(RELEASE_PRESET_TAG, string.Empty).Trim();
                if (string.IsNullOrWhiteSpace(latestPresetVersionString))
                {
                    Trace.WriteLine($"Could not get version of latest preset release. {nameof(latestPresetRelease.TagName)}: {latestPresetRelease.TagName}");
                    return(result);
                }

                var latestPresetVersion = new Version(latestPresetVersionString);
                if (latestPresetVersion > currentPresetVersion)
                {
                    result = true;
                }

                return(result);
            }
            catch (Exception ex)
            {
                Trace.WriteLine($"Error getting info about preset updates.{Environment.NewLine}{ex}");
                return(false);
            }
        }