fix loader version check

This commit is contained in:
Alex Bezdieniezhnykh
2025-07-03 19:36:48 +03:00
parent f6f0b0b266
commit 75d3a2412f
2 changed files with 30 additions and 32 deletions
-3
View File
@@ -10,7 +10,4 @@ public class ApiCredentials
[Key(nameof(Password))]
public string Password { get; set; } = null!;
public bool IsValid() =>
!string.IsNullOrWhiteSpace(Email) && !string.IsNullOrWhiteSpace(Password);
}
+17 -16
View File
@@ -1,6 +1,7 @@
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
@@ -44,23 +45,15 @@ public partial class Login
Email = TbEmail.Text,
Password = TbPassword.Password
};
if (!creds.IsValid())
if (string.IsNullOrWhiteSpace(creds.Email) || string.IsNullOrWhiteSpace(creds.Password))
return;
SetControlsStatus(isLoading: true);
_azaionApi.Login(creds);
try
{
SetControlsStatus(isLoading: true);
_azaionApi.Login(creds);
Validate(creds);
}
catch (Exception exception)
{
_logger.LogError(exception, exception.Message);
TbStatus.Foreground = Brushes.Red;
TbStatus.Text = exception.Message;
SetControlsStatus(isLoading: false);
return;
}
TbStatus.Foreground = Brushes.Black;
var installerVersion = await GetInstallerVer();
var localVersion = GetLocalVer();
@@ -82,6 +75,14 @@ public partial class Login
await Task.Delay(1500);
Close();
}
catch (Exception exception)
{
_logger.LogError(exception, exception.Message);
TbStatus.Foreground = Brushes.Red;
TbStatus.Text = exception.Message;
SetControlsStatus(isLoading: false);
}
}
private void Validate(ApiCredentials creds)
{
@@ -172,10 +173,10 @@ public partial class Login
? Constants.SUITE_FOLDER
: _dirConfig.SuiteInstallerDirectory;
var installerName = await _azaionApi.GetLastInstallerName(installerDir);
var version = installerName
.Replace("AzaionSuite.Iterative.", "")
.Replace(".exe", "");
return new Version(version);
var match = Regex.Match(installerName, @"\d+(\.\d+)+");
if (!match.Success)
throw new Exception($"Can't find version in {installerName}");
return new Version(match.Value);
}
private Version GetLocalVer()