Implemented diagnose command

master v0.1.4
Inga 🏳‍🌈 4 years ago
parent bcd39606e4
commit 9680c5d65e
  1. 27
      RadeonResetBugFixService/MainHandler.cs
  2. 11
      RadeonResetBugFixService/Program.cs
  3. 1
      RadeonResetBugFixService/RadeonResetBugFixService.csproj
  4. 19
      RadeonResetBugFixService/Tasks/ListDevicesTask.cs

@ -97,5 +97,32 @@
} }
} }
} }
public void HandleDiagnose(string reason)
{
using (var fileLogger = new FileLogger(this.LogFilename))
{
using (ILogger logger = new TaskLoggerWrapper(fileLogger, "Diagnose"))
{
logger.Log($"Reason: {reason}");
try
{
lock (this.Mutex)
{
TasksProcessor.ProcessTasks(
logger,
new ITask[]
{
new ListDevicesTask(),
});
}
}
catch (Exception e)
{
logger.LogError(e.ToString());
}
}
}
}
} }
} }

@ -72,6 +72,10 @@
{ {
DoShutdown(); DoShutdown();
} }
else if (command.Equals("diagnose", StringComparison.OrdinalIgnoreCase))
{
DoDiagnose();
}
else else
{ {
ShowHelp(); ShowHelp();
@ -92,6 +96,8 @@
Console.WriteLine("\t\tPerforms startup sequence (development command, does not affect services)"); Console.WriteLine("\t\tPerforms startup sequence (development command, does not affect services)");
Console.WriteLine($"\t{exeName} shutdown"); Console.WriteLine($"\t{exeName} shutdown");
Console.WriteLine("\t\tPerforms shutdown sequence (development command, does not affect services)"); Console.WriteLine("\t\tPerforms shutdown sequence (development command, does not affect services)");
Console.WriteLine($"\t{exeName} diagnose");
Console.WriteLine("\t\tPerforms diagnose (see result file in logs folder)");
} }
private static void DoInstall() private static void DoInstall()
@ -136,5 +142,10 @@
{ {
new MainHandler().HandleShutdown("Program.DoShutdown"); new MainHandler().HandleShutdown("Program.DoShutdown");
} }
private static void DoDiagnose()
{
new MainHandler().HandleDiagnose("Program.DoDiagnose");
}
} }
} }

@ -89,6 +89,7 @@
<Compile Include="Tasks\EnableBasicDisplayStartupTask.cs" /> <Compile Include="Tasks\EnableBasicDisplayStartupTask.cs" />
<Compile Include="Tasks\FixMonitorTask.cs" /> <Compile Include="Tasks\FixMonitorTask.cs" />
<Compile Include="Tasks\LastResortDevicesRestoreTask.cs" /> <Compile Include="Tasks\LastResortDevicesRestoreTask.cs" />
<Compile Include="Tasks\ListDevicesTask.cs" />
<Compile Include="Tasks\SleepTask.cs" /> <Compile Include="Tasks\SleepTask.cs" />
<Compile Include="ThirdParty\MonitorChanger.cs" /> <Compile Include="ThirdParty\MonitorChanger.cs" />
<Compile Include="ThirdParty\ServiceHelpers.cs" /> <Compile Include="ThirdParty\ServiceHelpers.cs" />

@ -0,0 +1,19 @@
namespace RadeonResetBugFixService.Tasks
{
using System.Linq;
using Contracts;
using Devices;
class ListDevicesTask : ITask
{
string ITask.TaskName => "Listing devices";
void ITask.Run(ILogger logger)
{
foreach (var device in DeviceHelper.GetDevices().ToArray())
{
logger.Log($"Found device {device.Description}: manufacturer='{device.Manufacturer}', service='{device.Service}', class='{device.ClassName}'");
}
}
}
}
Loading…
Cancel
Save