From 41698df242496be7da6f224e5ea292680ae7f158 Mon Sep 17 00:00:00 2001 From: Schwirg László Date: Tue, 30 Nov 2021 15:17:12 +0100 Subject: [PATCH] v1.10.0.0 - Külső exe indítás paraméterezhetőségeése --- Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs | 37 ++++++++++++++++++++++++++++++++----- Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs | 4 ++-- 2 files changed, 34 insertions(+), 7 deletions(-) diff --git a/Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs b/Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs index 4dfce6f..2d6d81b 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs +++ b/Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs @@ -16,7 +16,7 @@ using Vrh.Log4Pro.MaintenanceConsole.MenuNS; using Vrh.Log4Pro.MaintenanceConsole.ColorConsoleNS; using Vrh.Log4Pro.MaintenanceConsole.CommandLineParserNS; using Vrh.Log4Pro.MaintenanceConsole.ToolsNS; - +using VRH.Common; using Vrh.XmlProcessing; using System.Xml.Linq; @@ -54,7 +54,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS #endregion Execute #region First level Executors with UI - private static object ExternalUtilityStarter(object parameter, object o) + private static object ExternalUtilityStarter(object parameter, object o) { var config = (parameter as Menu.ExecutorParameter).GetConfig2(); using (System.Diagnostics.Process pProcess = new System.Diagnostics.Process()) @@ -62,6 +62,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS Process ExternalProcess = new Process(); ExternalProcess.StartInfo.FileName = config.Exe; ExternalProcess.StartInfo.WindowStyle = config.ProcessWindowsStyle; + + ExternalProcess.StartInfo.Arguments = config.Arguments; ExternalProcess.Start(); int waitingtime = config.WaitForExit ? -1 : 0; ExternalProcess.WaitForExit(waitingtime); @@ -380,19 +382,42 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS { public ExternalUtilityConfig(XElement x) { - Key = GetValue(nameof(XmlStructure.ExternalUtility.Attributes.Key), x, ""); - Exe= GetValue(nameof(XmlStructure.ExternalUtility.Attributes.Exe), x, ""); - Description = GetValue(nameof(XmlStructure.ExternalUtility.Attributes.Description), x, Exe); + ArgumentParametersDictionary = GetValue(nameof(XmlStructure.ExternalUtility.Attributes.ArgumentParameters), x, XmlStructure.ExternalUtility.Attributes.ArgumentParameters.Values.DEFAULT).Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries) + .Select(kvp => CreateKVP(kvp)) + .Where(kvp => kvp.Key != null) + .ToDictionary(kvp => kvp.Key, kvp => kvp.Value); + + Key = VRH.Common.StringConstructor.ResolveConstructorR(ArgumentParametersDictionary, GetValue(nameof(XmlStructure.ExternalUtility.Attributes.Key), x, ""), "{}@@"); + Description = VRH.Common.StringConstructor.ResolveConstructorR(ArgumentParametersDictionary, GetValue(nameof(XmlStructure.ExternalUtility.Attributes.Description), x, Exe), "{}@@"); + Arguments = VRH.Common.StringConstructor.ResolveConstructorR(ArgumentParametersDictionary, GetValue(nameof(XmlStructure.ExternalUtility.Attributes.Arguments), x, XmlStructure.ExternalUtility.Attributes.Arguments.Values.DEFAULT), "{}@@"); + + Exe = GetValue(nameof(XmlStructure.ExternalUtility.Attributes.Exe), x, ""); ProcessWindowsStyle = GetValue(nameof(XmlStructure.ExternalUtility.Attributes.WindowStyle), x, XmlStructure.ExternalUtility.Attributes.WindowStyle.Values.DEFAULT); WaitForExit= GetValue(nameof(XmlStructure.ExternalUtility.Attributes.WaitForExit), x, XmlStructure.ExternalUtility.Attributes.WaitForExit.Values.DEFAULT); Valid = !string.IsNullOrWhiteSpace(Key) && !string.IsNullOrWhiteSpace(Exe) && !string.IsNullOrWhiteSpace(Description); } public string Key = XmlStructure.ExternalUtility.Attributes.Key.Values.DEFAULT; public string Description = XmlStructure.ExternalUtility.Attributes.Description.Values.DEFAULT; + public string Arguments = XmlStructure.ExternalUtility.Attributes.Arguments.Values.DEFAULT; + public Dictionary ArgumentParametersDictionary = null; public string Exe = XmlStructure.ExternalUtility.Attributes.Exe.Values.DEFAULT; public ProcessWindowStyle ProcessWindowsStyle = XmlStructure.ExternalUtility.Attributes.WindowStyle.Values.DEFAULT; public bool WaitForExit=XmlStructure.ExternalUtility.Attributes.WaitForExit.Values.DEFAULT; public bool Valid; + + private static KeyValuePair CreateKVP(string kvpstring) + { + string kvpk = null; + string kvpv = null; + try + { + kvpk = kvpstring.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries)[0]; if (string.IsNullOrWhiteSpace(kvpk)) { kvpk = null; } + kvpv = kvpstring.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries)[1]; + KeyValuePair r = new KeyValuePair(kvpk, kvpv); + return r; + } + catch { return new KeyValuePair(kvpk, null); } + } } public XElement RegexpTesterConfig; public XElement PingerConfigXml; @@ -446,6 +471,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS public static class Key { public static class Values { public static string DEFAULT = ""; } } public static class Description { public static class Values { public static string DEFAULT = ""; } } public static class Exe { public static class Values { public static string DEFAULT = ""; } } + public static class Arguments{ public static class Values { public static string DEFAULT = ""; } } + public static class ArgumentParameters { public static class Values { public static string DEFAULT = ""; } } public static class WindowStyle { public static class Values { public static ProcessWindowStyle DEFAULT = ProcessWindowStyle.Normal; } } public static class WaitForExit { public static class Values { public static bool DEFAULT = true; } } } diff --git a/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs b/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs index 04cf058..4803fc5 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs +++ b/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.9.3.0")] -[assembly: AssemblyFileVersion("1.9.3.0")] +[assembly: AssemblyVersion("1.10.0.0")] +[assembly: AssemblyFileVersion("1.10.0.0")] -- libgit2 0.21.2