From 8b320dd2af9ea1d637f1d046279bd33379283891 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Sun, 3 Mar 2019 16:23:06 +0200 Subject: PPC v1.0.4 --- .gitignore | 5 +- Software/DB/PPC/Tango.mdf | Bin 75497472 -> 75497472 bytes Software/DB/PPC/Tango_log.ldf | Bin 53673984 -> 53673984 bytes .../Advanced Installer Projects/PPC Installer.aip | 104 ++------------------- .../Build/Shortcuts/Machine Studio.lnk | Bin 1516 -> 1532 bytes .../DefaultAuthenticationProvider.cs | 10 +- .../OS/DefaultOperationSystemManager.cs | 15 +++ .../PPC/Tango.PPC.Common/Tango.PPC.Common.csproj | 3 +- .../UWF/AlternativeUnifiedWriteFilterManager.cs | 71 ++++++++++++++ Software/Visual_Studio/PPC/Tango.PPC.UI/App.config | 81 +--------------- .../Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml | 2 +- .../PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs | 2 +- .../PPC/Tango.PPC.UI/ViewModelLocator.cs | 2 +- .../Visual_Studio/PPC/Tango.PPC.UI/app.manifest | 2 +- .../PPC/Tango.PPC.WatchDog/MainWindowVM.cs | 28 +++++- .../Utilities/Tango.UITests/MainWindow.xaml.cs | 38 +++++--- 16 files changed, 165 insertions(+), 198 deletions(-) create mode 100644 Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/AlternativeUnifiedWriteFilterManager.cs diff --git a/.gitignore b/.gitignore index 328672b46..8b1c529db 100644 --- a/.gitignore +++ b/.gitignore @@ -300,7 +300,8 @@ __pycache__/ /.jxbrowser-data /.metadata /RemoteSystemsTempFiles + +#Advanced Installer /Software/Visual_Studio/Advanced Installer Projects/Machine Studio Installer-cache +/Software/Visual_Studio/Advanced Installer Projects/PPC Installer-cache /Software/Visual_Studio/Build -/Software/Visual_Studio/Advanced Installer Projects/PPC-cache -/Software/Visual_Studio/Advanced Installer Projects/PPC-cache diff --git a/Software/DB/PPC/Tango.mdf b/Software/DB/PPC/Tango.mdf index d68ce42c5..f6776e165 100644 Binary files a/Software/DB/PPC/Tango.mdf and b/Software/DB/PPC/Tango.mdf differ diff --git a/Software/DB/PPC/Tango_log.ldf b/Software/DB/PPC/Tango_log.ldf index 406196edf..1299b7711 100644 Binary files a/Software/DB/PPC/Tango_log.ldf and b/Software/DB/PPC/Tango_log.ldf differ diff --git a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip index 1d309f495..dc1aa23ac 100644 --- a/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip +++ b/Software/Visual_Studio/Advanced Installer Projects/PPC Installer.aip @@ -18,10 +18,10 @@ - + - + @@ -57,6 +57,7 @@ + @@ -72,17 +73,9 @@ - - - - - - - - @@ -109,7 +102,6 @@ - @@ -129,46 +121,20 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -205,19 +171,15 @@ - - - - + - - + @@ -229,6 +191,7 @@ + @@ -245,27 +208,18 @@ - + - - - - - - - - - @@ -309,14 +263,12 @@ - - @@ -336,23 +288,12 @@ - - - - - - - - - - - @@ -366,30 +307,15 @@ - - - - - - - - - - - - - - - - + @@ -484,20 +410,9 @@ - - - - - - - - - - - @@ -509,7 +424,7 @@ - + @@ -577,6 +492,7 @@ + diff --git a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk index cc5de8350..90ca11fc7 100644 Binary files a/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk and b/Software/Visual_Studio/Build/Shortcuts/Machine Studio.lnk differ diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs index d6fb50a8c..7aa9ae890 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Authentication/DefaultAuthenticationProvider.cs @@ -84,7 +84,15 @@ namespace Tango.MachineStudio.UI.Authentication ObservablesContext.OverrideSettingsDataSource(response.DataSource); } - ObservablesStaticCollections.Instance.Initialize(); + try + { + ObservablesStaticCollections.Instance.Initialize(); + } + catch (System.Data.Entity.Core.MetadataException) + { + ObservablesContext.ClearModelStore(); + ObservablesStaticCollections.Instance.Initialize(); + } using (ObservablesContext db = ObservablesContext.CreateDefault()) { diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs index 9e44a5028..1dbb57a8b 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/OS/DefaultOperationSystemManager.cs @@ -131,6 +131,21 @@ namespace Tango.PPC.Common.OS { CmdCommand cmd = new CmdCommand("tzutil", $"/s \"{timeZone.Id}\""); await cmd.Run(); + + try + { + cmd = new CmdCommand("sc.exe", "config W32Time start=auto"); + cmd.Timeout = TimeSpan.FromSeconds(10); + await cmd.Run(); + + cmd = new CmdCommand("net", "start W32Time"); + cmd.Timeout = TimeSpan.FromSeconds(10); + await cmd.Run(); + + cmd = new CmdCommand("w32tm", $"/resync"); + await cmd.Run(); + } + catch { } } /// diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj index 07ea6c5d1..62874d9cb 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/Tango.PPC.Common.csproj @@ -147,6 +147,7 @@ + @@ -371,7 +372,7 @@ - + \ No newline at end of file diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/AlternativeUnifiedWriteFilterManager.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/AlternativeUnifiedWriteFilterManager.cs new file mode 100644 index 000000000..5fb74b2fe --- /dev/null +++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/UWF/AlternativeUnifiedWriteFilterManager.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using Tango.Core.Components; + +namespace Tango.PPC.Common.UWF +{ + public class AlternativeUnifiedWriteFilterManager : IUnifiedWriteFilterManager + { + private const string UWF_PATH = "C:\\Windows\\Sysnative\\uwfmgr.exe"; + + /// + /// Gets a value indicating whether UWF if currently enabled on the system. + /// + public bool IsEnabled { get; private set; } + + /// + /// Installs and configures the service (requires restart). + /// + /// + public Task Setup() + { + return Enable(); + } + + /// + /// Enables the UWF service (requires restart). + /// + /// + public async Task Enable() + { + CmdCommand command = null; + try + { + + command = new CmdCommand(UWF_PATH, $"filter disable"); + command.OutputEncoding = CmdCommand.OutEncoding.Unicode; + await command.Run(); + + } + catch { } + + command = new CmdCommand(UWF_PATH, $"filter enable"); + command.OutputEncoding = CmdCommand.OutEncoding.Unicode; + 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 where name=\"p:\\\\pagefile.sys\" set InitialSize=16,MaximumSize=3870"); + await command.Run(); + } + + /// + /// Disables the UWF service (requires restart). + /// + /// + public async Task Disable() + { + CmdCommand command = new CmdCommand(UWF_PATH, $"filter disable"); + command.OutputEncoding = CmdCommand.OutEncoding.Unicode; + await command.Run(); + } + } +} diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config index 15a7107bd..9a0087c43 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/App.config @@ -11,86 +11,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml index 5c358610f..9907a7c2c 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/MainWindow.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:Tango.PPC.UI" xmlns:views="clr-namespace:Tango.PPC.UI.Views" mc:Ignorable="d" - Title="MainWindow" Height="1000" Stylus.IsTapFeedbackEnabled="False" Stylus.IsPressAndHoldEnabled="False" Stylus.IsTouchFeedbackEnabled="False" Width="800" WindowStyle="SingleBorderWindow" ResizeMode="CanResize" WindowStartupLocation="CenterScreen" + Title="Tango - PPC" Height="1000" Stylus.IsTapFeedbackEnabled="False" Stylus.IsPressAndHoldEnabled="False" Stylus.IsTouchFeedbackEnabled="False" Width="800" WindowStyle="SingleBorderWindow" ResizeMode="CanResize" WindowStartupLocation="CenterScreen" FontFamily="{StaticResource TangoFlexoFontFamily}" FontSize="{StaticResource TangoDefaultFontSize}" Foreground="{StaticResource TangoDarkForegroundBrush}" diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs index b7c1f4eff..9b8f8f4ae 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/Properties/AssemblyInfo.cs @@ -8,4 +8,4 @@ using System.Windows; // set of attributes. Change these attribute values to modify the information // associated with an assembly. [assembly: AssemblyTitle("Tango PPC Application")] -[assembly: AssemblyVersion("1.0.3.0")] +[assembly: AssemblyVersion("1.0.4.0")] diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs index 018c9b223..3517abbb2 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/ViewModelLocator.cs @@ -91,7 +91,7 @@ namespace Tango.PPC.UI TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); - TangoIOC.Default.Register(); + TangoIOC.Default.Register(); TangoIOC.Default.Register(); //TangoIOC.Default.Register(new TeamFoundationServiceExtendedClient("https://twinetfs.visualstudio.com", String.Empty, "szzfokrceo4rhd4eqi5qpmxn3pa5iwl3q7tlqd36l2m7smz2ynoa")); diff --git a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest index efc5f8179..d72e75011 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest +++ b/Software/Visual_Studio/PPC/Tango.PPC.UI/app.manifest @@ -16,7 +16,7 @@ Remove this element if your application requires this virtualization for backwards compatibility. --> - + diff --git a/Software/Visual_Studio/PPC/Tango.PPC.WatchDog/MainWindowVM.cs b/Software/Visual_Studio/PPC/Tango.PPC.WatchDog/MainWindowVM.cs index 0693b0931..f12678054 100644 --- a/Software/Visual_Studio/PPC/Tango.PPC.WatchDog/MainWindowVM.cs +++ b/Software/Visual_Studio/PPC/Tango.PPC.WatchDog/MainWindowVM.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; +using System.Runtime.InteropServices; using System.Text; using System.Threading; using System.Threading.Tasks; @@ -16,6 +17,9 @@ namespace Tango.PPC.WatchDog { public class MainWindowVM : ViewModel { + [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)] + static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName); + private const String tango_process_name = "Tango.PPC.UI"; private WatchDogClient _watchdog; public TextController Log { get; set; } @@ -109,16 +113,16 @@ namespace Tango.PPC.WatchDog { var process = Process.Start(Path.Combine(AssemblyHelper.GetCurrentAssemblyFolder(), tango_process_name + ".exe")); LogManager.Log("PPC application started."); - LogManager.Log("Waiting for the application to enter an idle state...."); - if (process.WaitForInputIdle((int)TimeSpan.FromMinutes(1).TotalMilliseconds)) + LogManager.Log("Waiting for the application main window...."); + if (WaitForPPCWindow(TimeSpan.FromSeconds(5), TimeSpan.FromMinutes(1))) { - LogManager.Log("Application is in idle state. waiting another 10 seconds..."); + LogManager.Log("Application main window opened. waiting another 10 seconds..."); Thread.Sleep(TimeSpan.FromSeconds(10)); _watchdog.Start(); } else { - LogManager.Log("The PPC application did not enter to an idle state within 1 minute. The Watchdog will not start again!"); + LogManager.Log("The PPC application main window has failed to open within 1 minute. The Watchdog will not start again!"); } } catch (Exception ex) @@ -126,5 +130,21 @@ namespace Tango.PPC.WatchDog LogManager.Log(ex, "Error starting PPC application."); } } + + private bool WaitForPPCWindow(TimeSpan interval, TimeSpan timeout) + { + for (TimeSpan time = TimeSpan.Zero; time < timeout; time = time.Add(interval)) + { + IntPtr windowPtr = FindWindowByCaption(IntPtr.Zero, "Tango - PPC"); + if (windowPtr != IntPtr.Zero) + { + return true; + } + + Thread.Sleep(interval); + } + + return false; + } } } diff --git a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs index ca676e277..2fad8b46b 100644 --- a/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs +++ b/Software/Visual_Studio/Utilities/Tango.UITests/MainWindow.xaml.cs @@ -37,6 +37,8 @@ using TableDependency.SqlClient.Base; using TableDependency.SqlClient; using TableDependency.SqlClient.Base.EventArgs; using TableDependency.SqlClient.Base.Abstracts; +using Tango.Core.Components; +using System.Text.RegularExpressions; namespace Tango.UITests { @@ -51,21 +53,33 @@ namespace Tango.UITests public MainWindow() { - _dataSource = new DataSource() - { - Address = "twine.database.windows.net", - Catalog = "Tango_DEV", - Type = DataSourceType.SQLServer, - UserName = "Roy", - Password = "Aa123456", - IntegratedSecurity = false, - }; + //_dataSource = new DataSource() + //{ + // Address = "twine.database.windows.net", + // Catalog = "Tango_DEV", + // Type = DataSourceType.SQLServer, + // UserName = "Roy", + // Password = "Aa123456", + // IntegratedSecurity = false, + //}; + + //InitializeComponent(); + //EntityFrameworkCache.Initialize(new MyMemoryCache() { Expiration = TimeSpan.FromMinutes(1) }); + + + //this.Closing += MainWindow_Closing; + + CmdCommand command = new CmdCommand("wmic", "pagefile list /format:list"); + var result = command.Run().Result; + + Regex regEx = new Regex("Name=(.+)"); + var pageFiles = regEx.Matches(result.StandardOutput).OfType().Select(x => x.Groups.OfType().LastOrDefault()).ToList().Select(x => x.Value.Replace("\n", "").Replace("\r", "")).ToList(); + + - InitializeComponent(); - EntityFrameworkCache.Initialize(new MyMemoryCache() { Expiration = TimeSpan.FromMinutes(1) }); + //var matches = matches.OfType().Select(x => x.Groups.OfType().Last().Value.Replace("\n","").Replace("\r","")).ToList(); - this.Closing += MainWindow_Closing; } private void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e) -- cgit v1.3.1