diff --git a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - ColorConsole.cs b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - ColorConsole.cs
index ae07a5c..1e20b4c 100644
--- a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - ColorConsole.cs
+++ b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - ColorConsole.cs
@@ -102,8 +102,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ColorConsoleNS
///
///
///
+ ///
///
- public static string ReadLine(string text = null, ConsoleColor? f = null, ConsoleColor? b = null, string bracket = null, string prefix = "",string suffix = "",List validitylist=null,string exitvalue="EX",string defaultvalue=null)
+ public static string ReadLine(string text = null, ConsoleColor? f = null, ConsoleColor? b = null, string bracket = null, string prefix = "", string suffix = "", List validitylist = null, string exitvalue = "EX", string defaultvalue = null, bool required = false)
{
string input;
while (true)
@@ -128,8 +129,10 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ColorConsoleNS
Write(prompt, f, b, bracket, prefix, suffix);
input = Console.ReadLine();
if (defaultvalue!=null && (input == null || input == "")) { input = defaultvalue; }
- if (exitvalue != null && input!=null && input.ToLower() == exitvalue || validitylist ==null || !validitylist.Any() || validitylist.Contains(input)) { break; }
- WriteLine($"Erroneous value!",ConsoleColor.Red);
+ if (required && string.IsNullOrWhiteSpace(input)) { WriteLine($"Erroneous value!", ConsoleColor.Red); continue; }
+ if (exitvalue != null && input != null && input.ToLower() == exitvalue) { break; }
+ if (validitylist == null || !validitylist.Any() || string.IsNullOrWhiteSpace(input) || validitylist.Contains(input)) { break; }
+ WriteLine($"Erroneous value!", ConsoleColor.Red);
}
}
return input;
diff --git a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - CommandLineParser.cs b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - CommandLineParser.cs
index b90a340..48f1bd6 100644
--- a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - CommandLineParser.cs
+++ b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - CommandLineParser.cs
@@ -289,6 +289,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.CommandLineParserNS
public const string KEY = "INM";
public static class Functions
{
+ public static class EnableWindowsFeature { public const string KEY = "ENA"; }
public static class EnvironmentInstall { public const string KEY = "ENV"; }
public static class RestartServer { public const string KEY = "RST"; }
public static class ConfigureIIS { public const string KEY = "IIS"; }
diff --git a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools.cs b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools.cs
index 965dcd2..d883724 100644
--- a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools.cs
+++ b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools.cs
@@ -215,7 +215,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS
try
{
RegistryKey rk = Registry.LocalMachine.OpenSubKey(path);
- if (rk == null) return "";
+ if (rk == null) { return ""; }
return (string)rk.GetValue(key);
}
catch { return ""; }
diff --git a/Vrh.Log4Pro.MaintenanceConsole/Manager - InstallManager.cs b/Vrh.Log4Pro.MaintenanceConsole/Manager - InstallManager.cs
index 45da424..1a5b2b7 100644
--- a/Vrh.Log4Pro.MaintenanceConsole/Manager - InstallManager.cs
+++ b/Vrh.Log4Pro.MaintenanceConsole/Manager - InstallManager.cs
@@ -43,6 +43,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.InstallManagerNS
var menufunctions = new Menu("Install Manager", "Select function!")
.AddMenuItem(new Menu.Item(CLP.Module.InstallManager.Functions.EnvironmentInstall.KEY, "Environment install", EnvironmentInstall, new Menu.ExecutorParameter(cfg: config, null)))
.AddMenuItem(new Menu.Item(CLP.Module.WebApplicationManager.Function.ConfigureIIS.KEY, "Configure IIS Default App Pool", WebApplicationManager.ConfigIIS, epWA))
+ .AddMenuItem(new Menu.Item(CLP.Module.InstallManager.Functions.EnableWindowsFeature.KEY, "Enable Windows feature (option: set install source)", EnableWindowsFeature, new Menu.ExecutorParameter(cfg: config, null)))
.AddMenuItem(new Menu.ItemSeparator())
.AddMenuItem(new Menu.Item(CLP.Module.InstallManager.Functions.RestartServer.KEY, "Restart server", RestartServer, new Menu.ExecutorParameter(cfg: config, null)))
.SetSelectionMode(Menu.SelectionMode.Single);
@@ -52,49 +53,53 @@ namespace Vrh.Log4Pro.MaintenanceConsole.InstallManagerNS
#endregion Execute
#region First level Executors with UI
+ #region EnableWindowsFeature
+ private static object EnableWindowsFeature(object parameter, object o)
+ {
+ var config = (parameter as Menu.ExecutorParameter).GetConfig();
+ var selectedos = GetOsCode();if (selectedos == null) { return o; }
+
+ string featurename = ColorConsole.ReadLine($"Enter Windows feature name!", ConsoleColor.Green,required:true);
+ if (featurename.ToLower() == "ex") { return o; }
+
+ foreach (var wfg in config.WindowsFeatureGroups.Where(x => selectedos == null || x.OS == selectedos))
+ {
+ EnableWindowsFeatures(wfg.Group, wfg.OS, featurename, config);
+ };
+ return o;
+ }
+ #endregion EnableWindowsFeature
#region EnvironmentInstall
private static object EnvironmentInstall(object parameter, object o)
{
var config = (parameter as Menu.ExecutorParameter).GetConfig();
- InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.Group.Values grp;
- InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values os;
-
- string osfrn = Tools.OSFriendlyName();
- var defaultvalue =
- osfrn.StartsWith("Microsoft Windows 10") ? InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values.WS2016.ToString()
- : osfrn.StartsWith("Microsoft Windows Server 2016") ? InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values.WS2016.ToString()
- : osfrn.StartsWith("Microsoft Windows Server 2012") ? InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values.WS2016.ToString()
- : null;
- var oslist = Enum.GetNames(typeof(InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values)).ToList();
- string answer = ColorConsole.ReadLine($"Enter os code (friendly name is: '{osfrn}')!", ConsoleColor.Green, validitylist: oslist, defaultvalue: defaultvalue.ToString());
+ var selectedos = GetOsCode(); if (selectedos == null) { return o; }
- InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values? selectedos = null;
- selectedos = (InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values)Enum
- .Parse(typeof(InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values), answer);
foreach (var wfg in config.WindowsFeatureGroups.Where(x=>selectedos==null || x.OS== selectedos))
{
- grp = wfg.Group;
- os = wfg.OS;
- answer = ColorConsole.ReadLine($"Do You want to configure feature group '{grp}' for os '{os}'?(Y/N)", ConsoleColor.Green);
- if (answer.ToUpper() == "Y") { EnableWindowsFeatures(grp, os, config); }
+ string answer = ColorConsole.ReadLine($"Do You want to configure feature group '{wfg.Group}' for os '{wfg.OS}'?(Y/N)", ConsoleColor.Green);
+ if (answer.ToUpper() == "Y") { EnableWindowsFeatures(wfg.Group, wfg.OS, null, config); }
};
return o;
}
- private static void EnableWindowsFeatures(InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.Group.Values grp
- , InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values os, InstallManagerXmlParser environmentinstallconfig)
+ private static void EnableWindowsFeatures(
+ InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.Group.Values grp
+ , InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values os
+ , string featurename
+ , InstallManagerXmlParser environmentinstallconfig)
{
- ColorConsole.WriteLine($"Enableing {grp} features for os {os}...",ConsoleColor.Green);
+ if (featurename == null) { ColorConsole.WriteLine($"Enableing {grp} features for os {os}...", ConsoleColor.Green); }
foreach (var fn in environmentinstallconfig.GetFeatureList(os,grp))
{
+ if (featurename!=null && fn != featurename) { continue; }
if (string.IsNullOrWhiteSpace(fn) || fn.StartsWith("#")) { continue; }
ColorConsole.WriteLine($"Enableing {grp} features for os {os}. Feature name: {fn}.",ConsoleColor.Yellow);
string response;
switch (os)
{
case InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values.WS2016:
-
//var cmd = "Powershell -Command {Import-Module ServerManager ; Install-WindowsFeature XXXX}";
- response = Tools.ExecuteAndGetStdIo("Powershell", $"-Command {{Import - Module ServerManager ; Install-WindowsFeature -Name {fn} -IncludeAllSubFeature -IncludeManagementTools}}");
+ response = Tools.ExecuteAndGetStdIo("Powershell", $"-Command {{Import-Module ServerManager; Install-WindowsFeature -Name {fn} -IncludeAllSubFeature -IncludeManagementTools}}");
//response = Tools.ExecuteAndGetStdIo("Install-WindowsFeature", $"-Name {fn} -IncludeAllSubFeature -IncludeManagementTools");
break;
case InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values.W7:
@@ -104,6 +109,22 @@ namespace Vrh.Log4Pro.MaintenanceConsole.InstallManagerNS
}
}
}
+ public static InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values? GetOsCode()
+ {
+ string osfrn = Tools.OSFriendlyName();
+ var defaultvalue =
+ osfrn.StartsWith("Microsoft Windows 10") ? InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values.WS2016.ToString()
+ : osfrn.StartsWith("Microsoft Windows Server 2016") ? InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values.WS2016.ToString()
+ : osfrn.StartsWith("Microsoft Windows Server 2012") ? InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values.WS2016.ToString()
+ : null;
+ var oslist = Enum.GetNames(typeof(InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values)).ToList();
+ string answer = ColorConsole.ReadLine($"Enter os code (friendly name is: '{osfrn}')!", ConsoleColor.Green, validitylist: oslist, defaultvalue: defaultvalue.ToString(), required: true);
+ if (answer.ToLower() == "ex") { return null; }
+ InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values? selectedos = null;
+ selectedos = (InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values)Enum
+ .Parse(typeof(InstallManagerXmlParser.XmlStructure.EnvironmentInstall.WindowsFeatureList.Attributes.OS.Values), answer);
+ return selectedos;
+ }
#endregion EnvironmentInstall
#region Restart server
private static object RestartServer(object parameter, object o)
diff --git a/Vrh.Log4Pro.MaintenanceConsole/Program.cs b/Vrh.Log4Pro.MaintenanceConsole/Program.cs
index 1a78914..659f0c8 100644
--- a/Vrh.Log4Pro.MaintenanceConsole/Program.cs
+++ b/Vrh.Log4Pro.MaintenanceConsole/Program.cs
@@ -80,7 +80,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole
static void DisplayComputerInfo()
{
const string XMLCONNECTIONSTRING = "config=MAINTENANCECONSOLE;";
- const string XMLCONNECTIONSTRING_DEFAULT = "file=Config.Xml;";
+ //const string XMLCONNECTIONSTRING_DEFAULT = "file=Config.Xml;";
var config = new MaintenanceConsoleXmlProcessor(XMLCONNECTIONSTRING, "", "hu-HU");
ColorConsole.WriteLine(config.Xml_Header,ConsoleColor.Yellow,bracket:"[]");
--
libgit2 0.21.2