write logs for inference and loader to file

This commit is contained in:
Alex Bezdieniezhnykh
2025-06-14 16:08:32 +03:00
parent 8aa2f563a4
commit 6f297c4ebf
30 changed files with 218 additions and 140 deletions
+27 -13
View File
@@ -3,23 +3,27 @@ using System.IO;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace Azaion.LoaderUI;
public partial class Login
{
private readonly IAzaionApi _azaionApi;
private readonly DirectoriesConfig _dirConfig;
private readonly ILogger<Login> _logger;
private readonly DirectoriesConfig? _dirConfig;
public Login(IAzaionApi azaionApi, IOptions<DirectoriesConfig> directoriesConfig)
public Login(IAzaionApi azaionApi, IOptions<DirectoriesConfig> directoriesConfig, ILogger<Login> logger)
{
_azaionApi = azaionApi;
_logger = logger;
_dirConfig = directoriesConfig.Value;
InitializeComponent();
}
private void LoginClick(object sender, RoutedEventArgs e)
private async void LoginClick(object sender, RoutedEventArgs e)
{
var creds = new ApiCredentials(TbEmail.Text, TbPassword.Password);
if (!creds.IsValid())
@@ -30,33 +34,43 @@ public partial class Login
_azaionApi.Login(creds);
if (GetInstallerVer() > GetLocalVer())
DownloadAndRunInstaller();
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}");
Close();
}
private void DownloadAndRunInstaller()
private async Task DownloadAndRunInstaller()
{
var (installerName, stream) = _azaionApi.DownloadInstaller(_dirConfig.SuiteInstallerDirectory);
var (installerName, stream) = await _azaionApi.DownloadInstaller(_dirConfig?.SuiteInstallerDirectory ?? "");
var localFileStream = new FileStream(installerName, FileMode.Create, FileAccess.Write);
stream.CopyTo(localFileStream);
await stream.CopyToAsync(localFileStream);
localFileStream.Close();
stream.Close();
var processInfo = new ProcessStartInfo(installerName)
{
UseShellExecute = true,
Verb = "runas"
Arguments = "/VERYSILENT"
};
Process.Start(processInfo);
var process = Process.Start(processInfo);
await process!.WaitForExitAsync();
}
private Version GetInstallerVer()
private async Task<Version> GetInstallerVer()
{
var installerName = _azaionApi.GetLastInstallerName(_dirConfig.SuiteInstallerDirectory);
TbStatus.Text = "Checking for the newer version...";
var installerName = await _azaionApi.GetLastInstallerName(_dirConfig?.SuiteInstallerDirectory ?? Constants.SUITE_FOLDER);
var version = installerName
.Replace("AzaionSuite.Iterative.", "")
.Replace(".exe", "");