From 4515e773689b8e8dbebca5bf2a26fa4cb1ab1238 Mon Sep 17 00:00:00 2001 From: Schwirg László Date: Wed, 30 Jun 2021 18:44:36 +0200 Subject: [PATCH] v1.5.0 - külső program indítása funkció beépítése --- Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Menu.cs | 5 +++++ Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs | 4 ++-- Vrh.Log4Pro.MaintenanceConsole/Vrh.Log4Pro.MaintenanceConsole.csproj | 8 ++++---- Vrh.Log4Pro.MaintenanceConsole/packages.config | 4 ++-- 5 files changed, 64 insertions(+), 9 deletions(-) diff --git a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Menu.cs b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Menu.cs index ce2d4f3..9c628a5 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Menu.cs +++ b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Menu.cs @@ -541,6 +541,11 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MenuNS { return _config as TXMLPROCESSORTYPE; } + public TXMLPROCESSORTYPE GetConfig2() + where TXMLPROCESSORTYPE : XmlLinqBase + { + return _config as TXMLPROCESSORTYPE; + } private object _config; public object Parameters; diff --git a/Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs b/Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs index 5bd36cf..6298358 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs +++ b/Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs @@ -41,12 +41,30 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS .AddMenuItem(new Menu.Item(CLP.Module.MaintenanceToolManager.Functions.RegexTester.KEY, "Regex tester", RegexTester,new Menu.ExecutorParameter(cfg:config))) .AddMenuItem(new Menu.Item(CLP.Module.MaintenanceToolManager.Functions.Tool.KEY, "Tool sample", Tool2, new Menu.ExecutorParameter(cfg: config, null))) .SetSelectionMode(Menu.SelectionMode.Single); + foreach (var x in config.ExternalUtilityConfigList) + { + menufunctions.AddMenuItem(new Menu.Item(x.Key, x.Description, ExternalUtilityStarter, new Menu.ExecutorParameter(cfg: x, null))); + } menufunctions.ExecuteMenu(); return null; } #endregion Execute #region First level Executors with UI + private static object ExternalUtilityStarter(object parameter, object o) + { + var config = (parameter as Menu.ExecutorParameter).GetConfig2(); + using (System.Diagnostics.Process pProcess = new System.Diagnostics.Process()) + { + Process ExternalProcess = new Process(); + ExternalProcess.StartInfo.FileName = config.Exe; + ExternalProcess.StartInfo.WindowStyle = config.ProcessWindowsStyle; + ExternalProcess.Start(); + int waitingtime = config.WaitForExit ? -1 : 0; + ExternalProcess.WaitForExit(waitingtime); + } + return o; + } #region RegexTester private static object RegexTester(object parameter, object o) { @@ -97,18 +115,50 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS #region MaintenanceToolsXmlProcessor class public class MaintenanceToolsXmlProcessor : XmlParser { + public class ExternalUtilityConfig: XmlLinqBase + { + 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); + 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 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; + } public XElement RegexpTesterConfig; - + public List ExternalUtilityConfigList = new List(); + #region constructor public MaintenanceToolsXmlProcessor(string xmlcs, string basefolder, string lcid) : base(xmlcs, basefolder, lcid, null) { RegexpTesterConfig = GetXElement(nameof(XmlStructure.RegexpTester)); + var euElementList = GetAllXElements(nameof(XmlStructure.ExternalUtility)); + foreach (var euElement in euElementList) { var euc = new ExternalUtilityConfig(euElement); if (euc.Valid && !ExternalUtilityConfigList.Exists(x=>x.Key==euc.Key)) { ExternalUtilityConfigList.Add(euc); } } } #endregion constructor #region XmlStructure public static class XmlStructure { public static class RegexpTester { } + public static class ExternalUtility + { + public static class Attributes + { + 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 WindowStyle { public static class Values { public static ProcessWindowStyle DEFAULT = ProcessWindowStyle.Normal; } } + public static class WaitForExit { public static class Values { public static bool DEFAULT = true; } } + } + } } #endregion XmlStructure } diff --git a/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs b/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs index 3c8c6eb..12350af 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.4.0.0")] -[assembly: AssemblyFileVersion("1.4.0.0")] +[assembly: AssemblyVersion("1.5.0.0")] +[assembly: AssemblyFileVersion("1.5.0.0")] diff --git a/Vrh.Log4Pro.MaintenanceConsole/Vrh.Log4Pro.MaintenanceConsole.csproj b/Vrh.Log4Pro.MaintenanceConsole/Vrh.Log4Pro.MaintenanceConsole.csproj index 9e8bada..558d9a4 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/Vrh.Log4Pro.MaintenanceConsole.csproj +++ b/Vrh.Log4Pro.MaintenanceConsole/Vrh.Log4Pro.MaintenanceConsole.csproj @@ -337,14 +337,14 @@ - - ..\packages\VRH.Common.2.21.2\lib\net45\VRH.Common.dll + + ..\packages\VRH.Common.2.21.3\lib\net45\VRH.Common.dll ..\packages\VRH.Web.Providers.2.0.2\lib\net452\Vrh.Web.Providers.dll - - ..\packages\Vrh.XmlProcessing.1.27.0\lib\net45\Vrh.XmlProcessing.dll + + ..\packages\Vrh.XmlProcessing.1.27.1\lib\net45\Vrh.XmlProcessing.dll diff --git a/Vrh.Log4Pro.MaintenanceConsole/packages.config b/Vrh.Log4Pro.MaintenanceConsole/packages.config index 8a15381..9cada53 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/packages.config +++ b/Vrh.Log4Pro.MaintenanceConsole/packages.config @@ -71,7 +71,7 @@ - + - + \ No newline at end of file -- libgit2 0.21.2