Adjust logging and add debugger option
All checks were successful
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 1m12s
All checks were successful
Deploy to Gitea Releases / deploy-to-gitea-releases (push) Successful in 1m12s
This commit is contained in:
@@ -30,18 +30,26 @@ internal class WindowSource : IWindowSource, IDisposable
|
||||
{
|
||||
using var taskService = new TaskService();
|
||||
|
||||
Log.Information("Checking for task name: {name}", HardwareMonitorService.ScheduledTaskName);
|
||||
|
||||
var existingTask = taskService.FindTask(HardwareMonitorService.ScheduledTaskName);
|
||||
|
||||
Log.Information("Task: {existingTask}", existingTask);
|
||||
|
||||
if (existingTask == null)
|
||||
{
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
|
||||
var path = Path.GetDirectoryName(assembly.Location);
|
||||
|
||||
Log.Information("Service path: {path}", path);
|
||||
|
||||
if (path != null)
|
||||
{
|
||||
var fileName = Path.Combine(path, "HardwareMonitorService.exe");
|
||||
|
||||
Log.Information("Full service path: {fileName}", fileName);
|
||||
|
||||
var startInfo = new ProcessStartInfo
|
||||
{
|
||||
FileName = fileName,
|
||||
@@ -50,13 +58,16 @@ internal class WindowSource : IWindowSource, IDisposable
|
||||
Verb = "runas"
|
||||
};
|
||||
|
||||
Log.Information("Starting process");
|
||||
|
||||
Process.Start(startInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception exception)
|
||||
{
|
||||
// Ignored
|
||||
Log.Error(exception, "");
|
||||
}
|
||||
|
||||
_floatingStatusWindow = new FloatingStatusWindow(this);
|
||||
@@ -73,36 +84,42 @@ internal class WindowSource : IWindowSource, IDisposable
|
||||
{
|
||||
try
|
||||
{
|
||||
Log.Information("IsInstalled: {isInstalled}", UpdateCheck.IsInstalled);
|
||||
|
||||
if (!UpdateCheck.IsInstalled)
|
||||
return false;
|
||||
|
||||
Log.Information("CheckVersionAtStartup: {checkVersionAtStartup}", Settings.Default.CheckVersionAtStartup);
|
||||
|
||||
if (!Settings.Default.CheckVersionAtStartup)
|
||||
return false;
|
||||
|
||||
Log.Logger.Information("Checking for update");
|
||||
|
||||
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(Resources.CheckingForUpdate));
|
||||
|
||||
Log.Information("Checking for updates");
|
||||
|
||||
var newVersion = await UpdateCheck.UpdateManager.CheckForUpdatesAsync();
|
||||
|
||||
Log.Information("New version: {version}", newVersion);
|
||||
|
||||
if (newVersion == null)
|
||||
return false;
|
||||
|
||||
Log.Logger.Information("Downloading update");
|
||||
|
||||
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(Resources.DownloadingUpdate));
|
||||
|
||||
Log.Information("Downloading update");
|
||||
|
||||
await UpdateCheck.UpdateManager.DownloadUpdatesAsync(newVersion);
|
||||
|
||||
Log.Logger.Information("Installing update");
|
||||
|
||||
await _dispatcher.InvokeAsync(() => _floatingStatusWindow.SetText(Resources.InstallingUpdate));
|
||||
|
||||
Log.Information("Installing update");
|
||||
|
||||
UpdateCheck.UpdateManager.ApplyUpdatesAndRestart(newVersion);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Log.Logger.Error(e, nameof(UpdateApp));
|
||||
Log.Error(e, nameof(UpdateApp));
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -110,16 +127,16 @@ internal class WindowSource : IWindowSource, IDisposable
|
||||
|
||||
private async Task Start(bool hasUpdate)
|
||||
{
|
||||
Log.Logger.Information("Start: hasUpdate={hasUpdate}", hasUpdate);
|
||||
Log.Information("Start: hasUpdate={hasUpdate}", hasUpdate);
|
||||
|
||||
if (hasUpdate)
|
||||
return;
|
||||
|
||||
Log.Logger.Information("Load");
|
||||
Log.Information("Load");
|
||||
|
||||
await Load();
|
||||
|
||||
Log.Logger.Information("Starting timer");
|
||||
Log.Information("Starting timer");
|
||||
|
||||
_timer.Elapsed += HandleTimerElapsed;
|
||||
_timer.AutoReset = false;
|
||||
|
||||
Reference in New Issue
Block a user