diff --git a/ZXBSInstaller.Log/ServiceLayer.cs b/ZXBSInstaller.Log/ServiceLayer.cs index c7ad982..a01c93c 100644 --- a/ZXBSInstaller.Log/ServiceLayer.cs +++ b/ZXBSInstaller.Log/ServiceLayer.cs @@ -214,75 +214,81 @@ public static void OpenUrlInBrowser(string url) /// if no external tools are configured or can download the config file. public static ExternalTool[] GetExternalTools() { - UpdateStatus?.Invoke("Retrieving external tools information...", 5); - - using var httpClient = new HttpClient(); - string json = httpClient.GetStringAsync(GeneralConfig.ToolsListURL).GetAwaiter().GetResult(); - var tools = JsonSerializer.Deserialize(json); - - int max = tools.Length; - int prg = 10; - for (int n = 0; n < max; n++) + try { - var tool = tools[n]; - prg = (n * 90) / max; - UpdateStatus?.Invoke($"Retrieving versions for {tool.Name}...", prg + 10); + UpdateStatus?.Invoke("Retrieving external tools information...", 5); - tool.Versions = GetAvailableToolVersion(tool); - if (tool.Versions == null) - { - tool.Versions = new ExternalTools_Version[0]; - } - tool.InstalledVersion = GetToolVersion(tool.Id); + using var httpClient = new HttpClient(); + string json = httpClient.GetStringAsync(GeneralConfig.ToolsListURL).GetAwaiter().GetResult(); + var tools = JsonSerializer.Deserialize(json); - // Set latest version - if (GeneralConfig.OnlyStableVersions) + int max = tools.Length; + int prg = 10; + for (int n = 0; n < max; n++) { - tool.LatestVersion = tool.Versions. - Where(d => d.OperatingSystem == CurrentOperatingSystem && - d.BetaNumber == 0). - OrderByDescending(d => d.VersionNumber). - FirstOrDefault(); - } - if (tool.LatestVersion == null || !GeneralConfig.OnlyStableVersions) - { - tool.LatestVersion = tool.Versions. - Where(d => d.OperatingSystem == CurrentOperatingSystem). - OrderByDescending(d => d.VersionNumber). - FirstOrDefault(); - } + var tool = tools[n]; + prg = (n * 90) / max; + UpdateStatus?.Invoke($"Retrieving versions for {tool.Name}...", prg + 10); - // Path for first versions of ZXBSInstalller - if (tool.Id == "zxbsinstaller" && tool.LatestVersion == null) - { - tool.LatestVersion = tool.InstalledVersion; - } + tool.Versions = GetAvailableToolVersion(tool); + if (tool.Versions == null) + { + tool.Versions = new ExternalTools_Version[0]; + } + tool.InstalledVersion = GetToolVersion(tool.Id); - // Determine whether you need to update - if (tool.InstalledVersion == null) - { - tool.UpdateNeeded = true; - } - else - { - if (tool.LatestVersion != null) + // Set latest version + if (GeneralConfig.OnlyStableVersions) + { + tool.LatestVersion = tool.Versions. + Where(d => d.OperatingSystem == CurrentOperatingSystem && + d.BetaNumber == 0). + OrderByDescending(d => d.VersionNumber). + FirstOrDefault(); + } + if (tool.LatestVersion == null || !GeneralConfig.OnlyStableVersions) + { + tool.LatestVersion = tool.Versions. + Where(d => d.OperatingSystem == CurrentOperatingSystem). + OrderByDescending(d => d.VersionNumber). + FirstOrDefault(); + } + + // Path for first versions of ZXBSInstalller + if (tool.Id == "zxbsinstaller" && tool.LatestVersion == null) + { + tool.LatestVersion = tool.InstalledVersion; + } + + // Determine whether you need to update + if (tool.InstalledVersion == null) { - if (tool.LatestVersion.VersionNumber > tool.InstalledVersion.VersionNumber) + tool.UpdateNeeded = true; + } + else + { + if (tool.LatestVersion != null) { - tool.UpdateNeeded = true; + if (tool.LatestVersion.VersionNumber > tool.InstalledVersion.VersionNumber) + { + tool.UpdateNeeded = true; + } } } - } - - tool.LocalPath = Path.Combine(GeneralConfig.BasePath, tool.Id); - } - //GetPaths(ref tools); + tool.LocalPath = Path.Combine(GeneralConfig.BasePath, tool.Id); + } - ExternalTools = tools.OrderBy(d => d.Order).ToArray(); + //GetPaths(ref tools); - return ExternalTools; + ExternalTools = tools.OrderBy(d => d.Order).ToArray(); + return ExternalTools; + } + catch (Exception ex) + { + return null; + } #if GENERATE_JSON var lst = new List(); // Compiler diff --git a/ZXBSInstaller/Controls/MainControl.axaml.cs b/ZXBSInstaller/Controls/MainControl.axaml.cs index 405c564..6628d8e 100644 --- a/ZXBSInstaller/Controls/MainControl.axaml.cs +++ b/ZXBSInstaller/Controls/MainControl.axaml.cs @@ -97,12 +97,13 @@ private void GetExternalTools() { ButtonDefinitions = ButtonEnum.Ok, ContentTitle = "ERROR", - ContentMessage = "Error retrieving the list of tools. Please check your internet connection.", + ContentMessage = "Error retrieving the list of tools, please check your Internet connection.\r\nIt may be a temporary server error, report the error to duefectucorp@gmail.com and try again later.", Icon = MsBox.Avalonia.Enums.Icon.Error, WindowIcon = ((Window)this.VisualRoot).Icon, WindowStartupLocation = WindowStartupLocation.CenterOwner }); box.ShowAsPopupAsync(this); + } else {