diff --git a/ATXCommon/SystemChecks.cs b/ATXCommon/SystemChecks.cs index 73e63a44301223b2bae39ba228b583e4b8c2f65a..29abc6177b2a6aca3409c3057f870760b07cebbe 100644 --- a/ATXCommon/SystemChecks.cs +++ b/ATXCommon/SystemChecks.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; using System.Linq; using System.Management; @@ -74,7 +75,7 @@ namespace ATXCommon public static string CheckFreeDiskSpace(List<Serializables.DriveToCheck> drives) { var msg = ""; foreach (var driveToCheck in drives) { - var freeSpace = SystemChecks.GetFreeDriveSpace(driveToCheck.DriveName); + var freeSpace = GetFreeDriveSpace(driveToCheck.DriveName); if (freeSpace >= driveToCheck.SpaceThreshold) continue; @@ -85,6 +86,26 @@ namespace ATXCommon return msg; } + /// <summary> + /// Compares all processes against the ProcessNames in the BlacklistedProcesses list. + /// </summary> + /// <returns>Returns the name of the first matching process, an empty string otherwise.</returns> + public static string CheckForBlacklistedProcesses(List<string> processNames) { + foreach (var running in Process.GetProcesses()) { + try { + foreach (var blacklisted in processNames) { + if (running.ProcessName.ToLower().Equals(blacklisted)) { + return blacklisted; + } + } + } + catch (Exception ex) { + Log.Warn("Error in checkProcesses(): {0}", ex.Message); + } + } + return ""; + } + /// <summary> /// Check if a user is currently logged into Windows. /// diff --git a/AutoTx/ATXProject.csproj b/AutoTx/ATXProject.csproj index 96121158c733b68259b54028f5f19ae51c41a8ba..aa53c590e76de1b7ce51a8a289890b3c4d4ae538 100644 --- a/AutoTx/ATXProject.csproj +++ b/AutoTx/ATXProject.csproj @@ -103,9 +103,6 @@ <Compile Include="RoboCommand.cs"> <SubType>Component</SubType> </Compile> - <Compile Include="SystemChecks.cs"> - <SubType>Component</SubType> - </Compile> </ItemGroup> <ItemGroup> <None Include="App.config" /> diff --git a/AutoTx/AutoTx.cs b/AutoTx/AutoTx.cs index 374b38ca3752f101af75ef93af583ba778f0a10a..f5b722b875529bd99f3c73f609371d3ff62f2597 100644 --- a/AutoTx/AutoTx.cs +++ b/AutoTx/AutoTx.cs @@ -446,7 +446,8 @@ namespace AutoTx else if (SystemChecks.GetFreeMemory() < _config.MinAvailableMemory) limitReason = "RAM usage"; else { - var blacklistedProcess = CheckForBlacklistedProcesses(); + var blacklistedProcess = SystemChecks.CheckForBlacklistedProcesses( + _config.BlacklistedProcesses); if (blacklistedProcess != "") { limitReason = "blacklisted process '" + blacklistedProcess + "'"; } diff --git a/AutoTx/SystemChecks.cs b/AutoTx/SystemChecks.cs deleted file mode 100644 index 64e744656058ce9beb3065e722aa97be7a169a0b..0000000000000000000000000000000000000000 --- a/AutoTx/SystemChecks.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using System.Diagnostics; -using ATXCommon; - -namespace AutoTx -{ - public partial class AutoTx - { - /// <summary> - /// Compares all processes against the ProcessNames in the BlacklistedProcesses list. - /// </summary> - /// <returns>Returns the name of the first matching process, an empty string otherwise.</returns> - public string CheckForBlacklistedProcesses() { - foreach (var running in Process.GetProcesses()) { - try { - foreach (var blacklisted in _config.BlacklistedProcesses) { - if (running.ProcessName.ToLower().Equals(blacklisted)) { - return blacklisted; - } - } - } - catch (Exception ex) { - Log.Warn("Error in checkProcesses(): {0}", ex.Message); - } - } - return ""; - } - } -} \ No newline at end of file