mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 11:06:30 +00:00
fix loader version check
This commit is contained in:
@@ -10,7 +10,4 @@ public class ApiCredentials
|
|||||||
|
|
||||||
[Key(nameof(Password))]
|
[Key(nameof(Password))]
|
||||||
public string Password { get; set; } = null!;
|
public string Password { get; set; } = null!;
|
||||||
|
|
||||||
public bool IsValid() =>
|
|
||||||
!string.IsNullOrWhiteSpace(Email) && !string.IsNullOrWhiteSpace(Password);
|
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
@@ -44,14 +45,35 @@ public partial class Login
|
|||||||
Email = TbEmail.Text,
|
Email = TbEmail.Text,
|
||||||
Password = TbPassword.Password
|
Password = TbPassword.Password
|
||||||
};
|
};
|
||||||
if (!creds.IsValid())
|
if (string.IsNullOrWhiteSpace(creds.Email) || string.IsNullOrWhiteSpace(creds.Password))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SetControlsStatus(isLoading: true);
|
|
||||||
_azaionApi.Login(creds);
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
SetControlsStatus(isLoading: true);
|
||||||
|
_azaionApi.Login(creds);
|
||||||
Validate(creds);
|
Validate(creds);
|
||||||
|
|
||||||
|
TbStatus.Foreground = Brushes.Black;
|
||||||
|
var installerVersion = await GetInstallerVer();
|
||||||
|
var localVersion = GetLocalVer();
|
||||||
|
|
||||||
|
if (installerVersion > localVersion)
|
||||||
|
{
|
||||||
|
TbStatus.Text = $"Updating from {localVersion} to {installerVersion}...";
|
||||||
|
await DownloadAndRunInstaller();
|
||||||
|
TbStatus.Text = $"Installed {installerVersion}!";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
TbStatus.Text = "Your version is up to date!";
|
||||||
|
|
||||||
|
Process.Start(Constants.AZAION_SUITE_EXE, $"-e {creds.Email} -p {creds.Password}");
|
||||||
|
await Task.Delay(800);
|
||||||
|
TbStatus.Text = "Loading...";
|
||||||
|
while (!Process.GetProcessesByName(Constants.INFERENCE_EXE).Any())
|
||||||
|
await Task.Delay(500);
|
||||||
|
await Task.Delay(1500);
|
||||||
|
Close();
|
||||||
}
|
}
|
||||||
catch (Exception exception)
|
catch (Exception exception)
|
||||||
{
|
{
|
||||||
@@ -59,28 +81,7 @@ public partial class Login
|
|||||||
TbStatus.Foreground = Brushes.Red;
|
TbStatus.Foreground = Brushes.Red;
|
||||||
TbStatus.Text = exception.Message;
|
TbStatus.Text = exception.Message;
|
||||||
SetControlsStatus(isLoading: false);
|
SetControlsStatus(isLoading: false);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
TbStatus.Foreground = Brushes.Black;
|
|
||||||
var installerVersion = await GetInstallerVer();
|
|
||||||
var localVersion = GetLocalVer();
|
|
||||||
|
|
||||||
if (installerVersion > localVersion)
|
|
||||||
{
|
|
||||||
TbStatus.Text = $"Updating from {localVersion} to {installerVersion}...";
|
|
||||||
await DownloadAndRunInstaller();
|
|
||||||
TbStatus.Text = $"Installed {installerVersion}!";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
TbStatus.Text = "Your version is up to date!";
|
|
||||||
|
|
||||||
Process.Start(Constants.AZAION_SUITE_EXE, $"-e {creds.Email} -p {creds.Password}");
|
|
||||||
await Task.Delay(800);
|
|
||||||
TbStatus.Text = "Loading...";
|
|
||||||
while (!Process.GetProcessesByName(Constants.INFERENCE_EXE).Any())
|
|
||||||
await Task.Delay(500);
|
|
||||||
await Task.Delay(1500);
|
|
||||||
Close();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Validate(ApiCredentials creds)
|
private void Validate(ApiCredentials creds)
|
||||||
@@ -172,10 +173,10 @@ public partial class Login
|
|||||||
? Constants.SUITE_FOLDER
|
? Constants.SUITE_FOLDER
|
||||||
: _dirConfig.SuiteInstallerDirectory;
|
: _dirConfig.SuiteInstallerDirectory;
|
||||||
var installerName = await _azaionApi.GetLastInstallerName(installerDir);
|
var installerName = await _azaionApi.GetLastInstallerName(installerDir);
|
||||||
var version = installerName
|
var match = Regex.Match(installerName, @"\d+(\.\d+)+");
|
||||||
.Replace("AzaionSuite.Iterative.", "")
|
if (!match.Success)
|
||||||
.Replace(".exe", "");
|
throw new Exception($"Can't find version in {installerName}");
|
||||||
return new Version(version);
|
return new Version(match.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Version GetLocalVer()
|
private Version GetLocalVer()
|
||||||
|
|||||||
Reference in New Issue
Block a user