diff options
| author | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
|---|---|---|
| committer | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
| commit | 00a491d93733d4625ad329b2ba8237f445364b3f (patch) | |
| tree | 4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/PPC/Tango.PPC.Common/UWF | |
| parent | 124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff) | |
| download | Tango-00a491d9.tar.gz Tango-00a491d9.zip | |
merge
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/UWF')
3 files changed, 19 insertions, 67 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/AlternativeUnifiedWriteFilterManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/AlternativeUnifiedWriteFilterManager.cs index ea57ca0d8..5fb74b2fe 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/AlternativeUnifiedWriteFilterManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/AlternativeUnifiedWriteFilterManager.cs @@ -4,16 +4,20 @@ using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; -using Tango.Core; using Tango.Core.Components; namespace Tango.PPC.Common.UWF { - public class AlternativeUnifiedWriteFilterManager : ExtendedObject, IUnifiedWriteFilterManager + public class AlternativeUnifiedWriteFilterManager : IUnifiedWriteFilterManager { private const string UWF_PATH = "C:\\Windows\\Sysnative\\uwfmgr.exe"; /// <summary> + /// Gets a value indicating whether UWF if currently enabled on the system. + /// </summary> + public bool IsEnabled { get; private set; } + + /// <summary> /// Installs and configures the service (requires restart). /// </summary> /// <returns></returns> @@ -43,15 +47,14 @@ namespace Tango.PPC.Common.UWF command.OutputEncoding = CmdCommand.OutEncoding.Unicode; await command.Run(); - //We don't use page file anymore since upgrade to 4GB RAM. But keep this just in case. - //command = new CmdCommand("wmic", $"computersystem where name=\"%computername%\" set AutomaticManagedPagefile=False"); - //await command.Run(); + command = new CmdCommand("wmic", $"computersystem where name=\"%computername%\" set AutomaticManagedPagefile=False"); + await command.Run(); - //command = new CmdCommand("wmic", $"pagefileset create name=\"p:\\pagefile.sys\""); - //await command.Run(); + command = new CmdCommand("wmic", $"pagefileset create name=\"p:\\pagefile.sys\""); + await command.Run(); - //command = new CmdCommand("wmic", $"pagefileset where name=\"p:\\\\pagefile.sys\" set InitialSize=16,MaximumSize=3870"); - //await command.Run(); + command = new CmdCommand("wmic", $"pagefileset where name=\"p:\\\\pagefile.sys\" set InitialSize=16,MaximumSize=3870"); + await command.Run(); } /// <summary> @@ -64,32 +67,5 @@ namespace Tango.PPC.Common.UWF command.OutputEncoding = CmdCommand.OutEncoding.Unicode; await command.Run(); } - - /// <summary> - /// Gets a value indicating whether UWF if currently enabled on the system. - /// </summary> - /// <returns></returns> - public async Task<bool> IsEnabled() - { - String pattern = @"Next Session Settings[\n\r]+FILTER SETTINGS[\n\r]+\s+Filter state:\s+(OFF|ON)"; - - LogManager.Log($"Getting UWF status using pattern '{pattern}'..."); - CmdCommand command = new CmdCommand(UWF_PATH, $"get-config"); - command.ExitStrategy = CmdCommand.ExitStrategies.StandardOutput; - command.OutputEncoding = CmdCommand.OutEncoding.Unicode; - var result = await command.Run(); - - Match match = Regex.Match(result.StandardOutput, pattern); - if (match != null && match.Success && match.Groups.Count > 1) - { - var value = match.Groups[1].Value; - - LogManager.Log($"UWF pattern parsing result: '{value}'."); - - return value.ToStringOrEmpty().Trim() == "ON"; - } - - return false; - } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/DefaultUnifiedWriteFilterManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/DefaultUnifiedWriteFilterManager.cs index 5684f6926..65cb3f466 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/DefaultUnifiedWriteFilterManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/DefaultUnifiedWriteFilterManager.cs @@ -2,9 +2,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; -using System.Text.RegularExpressions; using System.Threading.Tasks; -using Tango.Core; using Tango.Core.Components; namespace Tango.PPC.Common.UWF @@ -13,7 +11,7 @@ namespace Tango.PPC.Common.UWF /// Represents the default unified writer filter manager. /// </summary> /// <seealso cref="Tango.PPC.Common.UWF.IUnifiedWriteFilterManager" /> - public class DefaultUnifiedWriteFilterManager : ExtendedObject, IUnifiedWriteFilterManager + public class DefaultUnifiedWriteFilterManager : IUnifiedWriteFilterManager { private const int UWF_CAPACITY_MB = 5000; private const string UWF_PATH = "C:\\Windows\\Sysnative\\uwfmgr.exe"; @@ -26,6 +24,11 @@ namespace Tango.PPC.Common.UWF }; /// <summary> + /// Gets a value indicating whether UWF if currently enabled on the system. + /// </summary> + public bool IsEnabled { get; } + + /// <summary> /// Installs and configures the service (requires restart). /// </summary> public async Task Setup() @@ -92,31 +95,5 @@ namespace Tango.PPC.Common.UWF command.OutputEncoding = CmdCommand.OutEncoding.Unicode; await command.Run(); } - - /// <summary> - /// Gets a value indicating whether UWF if currently enabled on the system. - /// </summary> - /// <returns></returns> - public async Task<bool> IsEnabled() - { - String pattern = @"Next Session Settings[\n\r]+FILTER SETTINGS[\n\r]+\s+Filter state:\s+(OFF|ON)"; - - LogManager.Log($"Getting UWF status using pattern '{pattern}'..."); - CmdCommand command = new CmdCommand(UWF_PATH, $"get-config"); - command.OutputEncoding = CmdCommand.OutEncoding.Unicode; - var result = await command.Run(); - - Match match = Regex.Match(result.StandardOutput, pattern); - if (match != null && match.Success && match.Groups.Count > 1) - { - var value = match.Groups[1].Value; - - LogManager.Log($"UWF pattern parsing result: '{value}'."); - - return value.ToStringOrEmpty().Trim() == "ON"; - } - - return false; - } } } diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/IUnifiedWriteFilterManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/IUnifiedWriteFilterManager.cs index b6a661ab5..05fa1876a 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/IUnifiedWriteFilterManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/IUnifiedWriteFilterManager.cs @@ -14,8 +14,7 @@ namespace Tango.PPC.Common.UWF /// <summary> /// Gets a value indicating whether UWF if currently enabled on the system. /// </summary> - /// <returns></returns> - Task<bool> IsEnabled(); + bool IsEnabled { get; } /// <summary> /// Installs and configures the service (requires restart). |
