Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 61 additions & 55 deletions ZXBSInstaller.Log/ServiceLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -214,75 +214,81 @@ public static void OpenUrlInBrowser(string url)
/// if no external tools are configured or can download the config file.</returns>
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<ExternalTool[]>(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<ExternalTool[]>(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<ExternalTool>();
// Compiler
Expand Down
3 changes: 2 additions & 1 deletion ZXBSInstaller/Controls/MainControl.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down