Commit 0e407387b06660cc1372ad0ddb31e0c22b603522
1 parent
e4527b29
- KeyGroupList általánosítása folyamatban
Showing
1 changed file
with
26 additions
and
32 deletions
Show diff stats
Vrh.Log4Pro.MaintenanceConsole/Manager - WindowsServiceManager.cs
| @@ -46,9 +46,10 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WindowsServiceManagerNS | @@ -46,9 +46,10 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WindowsServiceManagerNS | ||
| 46 | 46 | ||
| 47 | if (!ColorConsole.SilentMode) | 47 | if (!ColorConsole.SilentMode) |
| 48 | { | 48 | { |
| 49 | - var menuservicegroups = DisplayWindowsServiceGroupMenu(config, $"Select the windows service group(s) to manage!"); | ||
| 50 | - if (menuservicegroups == null) { selectedServicegroups = null; if (exitwasrequested) { break; } } | 49 | + KeyGroupList wsgdefList = KeyGroupList.Factory(config.GetRootElement()); |
| 50 | + if (wsgdefList == null) { selectedServicegroups = null; if (exitwasrequested) { break; } } | ||
| 51 | else { | 51 | else { |
| 52 | + var menuservicegroups = wsgdefList.DisplayKeyGroupMenu(DisplayServiceInfo, ServiceListDisplayer, "Windows services", $"Select the windows service group(s) to manage!"); | ||
| 52 | menuservicegroups.AddMenuItem(new Menu.ItemSeparator()); | 53 | menuservicegroups.AddMenuItem(new Menu.ItemSeparator()); |
| 53 | menuservicegroups.AddMenuItem(new Menu.Item(CLP.Module.WindowsServiceManager.Function.Purge.KEY, "Purge")); | 54 | menuservicegroups.AddMenuItem(new Menu.Item(CLP.Module.WindowsServiceManager.Function.Purge.KEY, "Purge")); |
| 54 | menuservicegroups.AddMenuItem(new Menu.ItemSeparator()); | 55 | menuservicegroups.AddMenuItem(new Menu.ItemSeparator()); |
| @@ -276,26 +277,6 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WindowsServiceManagerNS | @@ -276,26 +277,6 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WindowsServiceManagerNS | ||
| 276 | } | 277 | } |
| 277 | return menuservices; | 278 | return menuservices; |
| 278 | } | 279 | } |
| 279 | - public static Menu DisplayWindowsServiceGroupMenu(WindowsServiceManagerXmlProcessor config = null, string prompt = null) | ||
| 280 | - { | ||
| 281 | - if (config == null) { config = new WindowsServiceManagerXmlProcessor(XMLCONNECTIONSTRING, "", "hu-HU"); } | ||
| 282 | - var menuservices = new Menu("Windows services", prompt) | ||
| 283 | - .SetMenuItemDisplayer(DisplayServiceInfo) | ||
| 284 | - .SetSelectionMode(Menu.SelectionMode.Single) | ||
| 285 | - .SetMenuHeaderDisplayer(ServiceListDisplayer) | ||
| 286 | - ; | ||
| 287 | - menuservices.ClearMenuItemList(); | ||
| 288 | - | ||
| 289 | - KeyGroupList wsgdefList = config.WinServiceKeyGroupList; | ||
| 290 | - if (wsgdefList == null || !wsgdefList.Any()) return null; | ||
| 291 | - foreach (var wsgdef in wsgdefList) | ||
| 292 | - { | ||
| 293 | - //string menuitemtext = wsgdef.Xml_Description + "(" + string.Join(",", wsgdef.Xml_WindowsServiceKeyList) + ")"; | ||
| 294 | - string menuitemtext = wsgdef.Xml_Description; | ||
| 295 | - menuservices.AddMenuItem(new Menu.Item(wsgdef.Xml_Key, menuitemtext, null, new Menu.ExecutorParameter(pars: wsgdef))); | ||
| 296 | - } | ||
| 297 | - return menuservices; | ||
| 298 | - } | ||
| 299 | #endregion DisplayServices | 280 | #endregion DisplayServices |
| 300 | 281 | ||
| 301 | #region private method: DisplayServiceInfo | 282 | #region private method: DisplayServiceInfo |
| @@ -688,7 +669,6 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WindowsServiceManagerNS | @@ -688,7 +669,6 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WindowsServiceManagerNS | ||
| 688 | List<WindowsService> _winservicelist; | 669 | List<WindowsService> _winservicelist; |
| 689 | List<WindowsService> _winservicelistinstartorder; | 670 | List<WindowsService> _winservicelistinstartorder; |
| 690 | List<WindowsService> _winservicelistinstoporder; | 671 | List<WindowsService> _winservicelistinstoporder; |
| 691 | - public KeyGroupList WinServiceKeyGroupList; | ||
| 692 | #region constructor | 672 | #region constructor |
| 693 | public WindowsServiceManagerXmlProcessor(string xmlcs, string basefolder, string lcid) : base(xmlcs, basefolder, lcid, null) | 673 | public WindowsServiceManagerXmlProcessor(string xmlcs, string basefolder, string lcid) : base(xmlcs, basefolder, lcid, null) |
| 694 | { | 674 | { |
| @@ -701,7 +681,6 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WindowsServiceManagerNS | @@ -701,7 +681,6 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WindowsServiceManagerNS | ||
| 701 | _winservicelistinstartorder = ProduceWindowsServiceDefinitionListInStartOrder(); | 681 | _winservicelistinstartorder = ProduceWindowsServiceDefinitionListInStartOrder(); |
| 702 | _winservicelistinstoporder = ProduceWindowsServiceDefinitionListInStartOrder(); _winservicelistinstoporder.Reverse(); | 682 | _winservicelistinstoporder = ProduceWindowsServiceDefinitionListInStartOrder(); _winservicelistinstoporder.Reverse(); |
| 703 | 683 | ||
| 704 | - WinServiceKeyGroupList = new KeyGroupList(this.RootElement); | ||
| 705 | } | 684 | } |
| 706 | #endregion constructor | 685 | #endregion constructor |
| 707 | 686 | ||
| @@ -1058,16 +1037,13 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WindowsServiceManagerNS | @@ -1058,16 +1037,13 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WindowsServiceManagerNS | ||
| 1058 | } | 1037 | } |
| 1059 | public static KeyGroupList Factory(XElement keygrouplistcontainer) | 1038 | public static KeyGroupList Factory(XElement keygrouplistcontainer) |
| 1060 | { | 1039 | { |
| 1061 | - return new KeyGroupList(keygrouplistcontainer); | ||
| 1062 | - } | ||
| 1063 | - public KeyGroupList(XElement keygrouplistcontainer) | ||
| 1064 | - { | ||
| 1065 | var wsgxmllist = keygrouplistcontainer.Elements(XName.Get(nameof(KeyGroup.XmlStructure.KeyGroup))); | 1040 | var wsgxmllist = keygrouplistcontainer.Elements(XName.Get(nameof(KeyGroup.XmlStructure.KeyGroup))); |
| 1066 | - if (wsgxmllist != null && wsgxmllist.Any()) | ||
| 1067 | - { | ||
| 1068 | - foreach (var wsgxml in wsgxmllist) { var wsg = new KeyGroup(wsgxml); if (wsg.Valid) { this.Add(wsg); } } | ||
| 1069 | - } | 1041 | + if (wsgxmllist == null || !wsgxmllist.Any()) return null; |
| 1042 | + var kgl = new KeyGroupList(); | ||
| 1043 | + foreach (var wsgxml in wsgxmllist) { var wsg = new KeyGroup(wsgxml); if (wsg.Valid) { kgl.Add(wsg); } } | ||
| 1044 | + return kgl; | ||
| 1070 | } | 1045 | } |
| 1046 | + public KeyGroupList() { } | ||
| 1071 | public KeyGroupList(List<KeyGroup> keygrouplist) | 1047 | public KeyGroupList(List<KeyGroup> keygrouplist) |
| 1072 | { | 1048 | { |
| 1073 | foreach (var kg in keygrouplist) { this.Add(kg); } | 1049 | foreach (var kg in keygrouplist) { this.Add(kg); } |
| @@ -1083,6 +1059,24 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WindowsServiceManagerNS | @@ -1083,6 +1059,24 @@ namespace Vrh.Log4Pro.MaintenanceConsole.WindowsServiceManagerNS | ||
| 1083 | foreach (var wsg in wsgdefList) { allwskeys = allwskeys.Concat(wsg.Xml_KeyList).ToList(); } | 1059 | foreach (var wsg in wsgdefList) { allwskeys = allwskeys.Concat(wsg.Xml_KeyList).ToList(); } |
| 1084 | return allwskeys; | 1060 | return allwskeys; |
| 1085 | } | 1061 | } |
| 1062 | + public Menu DisplayKeyGroupMenu(Menu.MenuItemDisplayerFunc menuitemdisplayer, Menu.MenuHeaderDisplayerFunc menuheaderdisplayer, string title, string prompt = null) | ||
| 1063 | + { | ||
| 1064 | + var menuservices = new Menu(title, prompt) | ||
| 1065 | + .SetMenuItemDisplayer(menuitemdisplayer) | ||
| 1066 | + .SetSelectionMode(Menu.SelectionMode.Single) | ||
| 1067 | + .SetMenuHeaderDisplayer(menuheaderdisplayer) | ||
| 1068 | + ; | ||
| 1069 | + menuservices.ClearMenuItemList(); | ||
| 1070 | + | ||
| 1071 | + if (!this.Any()) return null; | ||
| 1072 | + foreach (var wsgdef in this) | ||
| 1073 | + { | ||
| 1074 | + //string menuitemtext = wsgdef.Xml_Description + "(" + string.Join(",", wsgdef.Xml_KeyList) + ")"; | ||
| 1075 | + string menuitemtext = wsgdef.Xml_Description; | ||
| 1076 | + menuservices.AddMenuItem(new Menu.Item(wsgdef.Xml_Key, menuitemtext, null, new Menu.ExecutorParameter(pars: wsgdef))); | ||
| 1077 | + } | ||
| 1078 | + return menuservices; | ||
| 1079 | + } | ||
| 1086 | } | 1080 | } |
| 1087 | #endregion KeyGroupList class | 1081 | #endregion KeyGroupList class |
| 1088 | } | 1082 | } |