Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
Develop (#16)
Browse files Browse the repository at this point in the history
* groundwork for unit tests

* fixing red border to datepicker

* Adding Windows Remediation Service and making service list configurable

* Adding lock check to Hosts file
  • Loading branch information
WereDev committed Nov 17, 2019
1 parent 5236b60 commit a791743
Show file tree
Hide file tree
Showing 40 changed files with 943 additions and 404 deletions.
50 changes: 25 additions & 25 deletions Wu10Man.sln
@@ -1,25 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27004.2009
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wu10Man", "Wu10Man\Wu10Man.csproj", "{5162DE0E-A9CE-480D-A550-E4F8833E5D26}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5162DE0E-A9CE-480D-A550-E4F8833E5D26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5162DE0E-A9CE-480D-A550-E4F8833E5D26}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5162DE0E-A9CE-480D-A550-E4F8833E5D26}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5162DE0E-A9CE-480D-A550-E4F8833E5D26}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5FF65910-90B3-413F-B7D3-A1F3D40FC5C1}
EndGlobalSection
EndGlobal

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29025.244
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wu10Man", "Wu10Man\Wu10Man.csproj", "{5162DE0E-A9CE-480D-A550-E4F8833E5D26}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5162DE0E-A9CE-480D-A550-E4F8833E5D26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5162DE0E-A9CE-480D-A550-E4F8833E5D26}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5162DE0E-A9CE-480D-A550-E4F8833E5D26}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5162DE0E-A9CE-480D-A550-E4F8833E5D26}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {5FF65910-90B3-413F-B7D3-A1F3D40FC5C1}
EndGlobalSection
EndGlobal
14 changes: 14 additions & 0 deletions Wu10Man/App.config
Expand Up @@ -2,8 +2,22 @@
<configuration>
<appSettings>
<add key="WindowsUpdateUrls" value="stats.microsoft.com,download.microsoft.com,update.microsoft.com,windowsupdate.microsoft.com,windowsupdate.com,download.windowsupdate.com,ntservicepack.microsoft.com,wustat.windows.com" />
<add key="WindowsServiceNames" value="wuauserv,TrustedInstaller,WaaSMedicSvc,sedsvc" />
<add key="ClientSettingsProvider.ServiceUri" value="" />
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<system.web>
<membership defaultProvider="ClientAuthenticationMembershipProvider">
<providers>
<add name="ClientAuthenticationMembershipProvider" type="System.Web.ClientServices.Providers.ClientFormsAuthenticationMembershipProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" />
</providers>
</membership>
<roleManager defaultProvider="ClientRoleProvider" enabled="true">
<providers>
<add name="ClientRoleProvider" type="System.Web.ClientServices.Providers.ClientRoleProvider, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" serviceUri="" cacheTimeout="86400" />
</providers>
</roleManager>
</system.web>
</configuration>
36 changes: 34 additions & 2 deletions Wu10Man/App.xaml.cs
@@ -1,7 +1,13 @@
using System;
using Autofac;
using System;
using System.Windows;
using WereDev.Utils.Wu10Man.Editors;
using WereDev.Utils.Wu10Man.Interfaces;
using WereDev.Utils.Wu10Man.Helpers;
using WereDev.Utils.Wu10Man.UserWindows;
using WereDev.Utils.Wu10Man.Utilites;
using System.Linq;
using WereDev.Utils.Wu10Man.Utilites.Models;

namespace WereDev.Utils.Wu10Man
{
Expand All @@ -15,6 +21,7 @@ public App() : base()
Wu10Logger.LogInfo("Application starting");
try
{
RegisterDependencies();
WriteStartupLogs();
this.Dispatcher.UnhandledException += OnDispatcherUnhandledException;
this.MainWindow = new MainWindow();
Expand All @@ -26,10 +33,26 @@ public App() : base()
{
Wu10Logger.LogError(ex);
MessageBox.Show("An error occured attempting to initialize the application. Check the log file for more details.", "Error!", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
this.Shutdown();
base.Shutdown();
}
}

private void RegisterDependencies()
{
var builder = new ContainerBuilder();
builder.Register<IWindowsServices>((context, parameters) => { return GetWindowsServices(); });
builder.RegisterType<FilesHelper>().As<IFilesHelper>();
builder.RegisterType<HostsFileEditor>().As<IHostsFileEditor>();
builder.RegisterType<RegistryEditor>().As<IRegistryEditor>();
builder.RegisterType<ServiceCredentialsEditor>().As<IServiceCredentialsEditor>();
builder.RegisterType<TokenEditor>().As<ITokenEditor>();
builder.RegisterType<WindowsServiceManager>().As<IWindowsServiceManager>();
builder.RegisterType<WindowsServiceProviderFactory>().As<IWindowsServiceProviderFactory>();


DependencyManager.Container = builder.Build();
}

protected override void OnExit(ExitEventArgs e)
{
Wu10Logger.LogInfo("Application ended");
Expand All @@ -51,5 +74,14 @@ void WriteStartupLogs()
Wu10Logger.LogInfo(EnvironmentVersionHelper.GetWindowsVersion());
Wu10Logger.LogInfo($".Net Framework: {EnvironmentVersionHelper.GetDotNetFrameworkBuild()}");
}

WindowsServiceNames GetWindowsServices()
{
var serviceNames = System.Configuration.ConfigurationManager.AppSettings["WindowsServiceNames"];
var split = serviceNames.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
var names = new WindowsServiceNames();
names.AddRange(split.Distinct());
return names;
}
}
}
13 changes: 13 additions & 0 deletions Wu10Man/Constants.cs
@@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WereDev.Utils.Wu10Man
{
public static class Constants
{
public const string USERNAME_LOCAL_SYSTEM = @".\LocalSystem";
}
}
16 changes: 16 additions & 0 deletions Wu10Man/DependencyManager.cs
@@ -0,0 +1,16 @@
using Autofac;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WereDev.Utils.Wu10Man
{
public static class DependencyManager
{
public static IContainer Container { get; set; }

public static T Resolve<T>() => Container.Resolve<T>();
}
}
152 changes: 0 additions & 152 deletions Wu10Man/Editors/ServiceCredentialsEditor.cs

This file was deleted.

17 changes: 11 additions & 6 deletions Wu10Man/Helpers/EnvironmentVersionHelper.cs
@@ -1,12 +1,17 @@
namespace WereDev.Utils.Wu10Man.Helpers
using WereDev.Utils.Wu10Man.Interfaces;

namespace WereDev.Utils.Wu10Man.Helpers
{
public static class EnvironmentVersionHelper
{
private const string WindowsVersionRegistryKey = @"SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion";
private const string DotNetVersionRegistryKey = @"SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full";
private static IRegistryEditor RegistryEditor => DependencyManager.Resolve<IRegistryEditor>();


public static string GetDotNetFrameworkBuild()
{
var release = Editors.RegistryEditor.ReadLocalMachineRegistryValue(DotNetVersionRegistryKey, "Release");
var release = RegistryEditor.ReadLocalMachineRegistryValue(DotNetVersionRegistryKey, "Release");
int.TryParse(release, out var releaseInt);

if (releaseInt >= 528040)
Expand Down Expand Up @@ -37,10 +42,10 @@ public static string GetDotNetFrameworkBuild()

public static string GetWindowsVersion()
{
var windowsProduct = Editors.RegistryEditor.ReadLocalMachineRegistryValue(WindowsVersionRegistryKey, "ProductName");
var windowsRelease = Editors.RegistryEditor.ReadLocalMachineRegistryValue(WindowsVersionRegistryKey, "ReleaseId");
var windowsBuild = Editors.RegistryEditor.ReadLocalMachineRegistryValue(WindowsVersionRegistryKey, "CurrentBuild");
var windowsBuildRevision = Editors.RegistryEditor.ReadLocalMachineRegistryValue(WindowsVersionRegistryKey, "BaseBuildRevisionNumber");
var windowsProduct = RegistryEditor.ReadLocalMachineRegistryValue(WindowsVersionRegistryKey, "ProductName");
var windowsRelease = RegistryEditor.ReadLocalMachineRegistryValue(WindowsVersionRegistryKey, "ReleaseId");
var windowsBuild = RegistryEditor.ReadLocalMachineRegistryValue(WindowsVersionRegistryKey, "CurrentBuild");
var windowsBuildRevision = RegistryEditor.ReadLocalMachineRegistryValue(WindowsVersionRegistryKey, "BaseBuildRevisionNumber");
return $"{windowsProduct} Version {windowsRelease} Build {windowsBuild}.{windowsBuildRevision}";
}
}
Expand Down

0 comments on commit a791743

Please sign in to comment.