Commit 61c9a762c8f55b7ce73a0c876617d50e7054d7cb
1 parent
2c000e17
v1.19.0
AseConfig utility beépítése
Showing
4 changed files
with
262 additions
and
10 deletions
Show diff stats
Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - ColorConsole.cs
| @@ -157,7 +157,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ColorConsoleNS | @@ -157,7 +157,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ColorConsoleNS | ||
| 157 | if (defaultvalue != null) { prompt += $" Default value is '{defaultvalue}'."; } | 157 | if (defaultvalue != null) { prompt += $" Default value is '{defaultvalue}'."; } |
| 158 | if (exitvalue != null) { prompt += $" Enter '{exitvalue}' to exit."; } | 158 | if (exitvalue != null) { prompt += $" Enter '{exitvalue}' to exit."; } |
| 159 | 159 | ||
| 160 | - WriteLine(text, f, b, bracket, prefix, suffix); | 160 | + Write(text, f, b, bracket, prefix, suffix); |
| 161 | + if (!string.IsNullOrWhiteSpace(text+bracket+prefix+suffix)) WriteLine(); | ||
| 161 | if (prompt != null) { WriteLine(prompt); } | 162 | if (prompt != null) { WriteLine(prompt); } |
| 162 | Write("-->"); input = Console.ReadLine(); | 163 | Write("-->"); input = Console.ReadLine(); |
| 163 | if (defaultvalue!=null && (input == null || input == "")) { input = defaultvalue; } | 164 | if (defaultvalue!=null && (input == null || input == "")) { input = defaultvalue; } |
Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - CommandLineParser.cs
| @@ -328,6 +328,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.CommandLineParserNS | @@ -328,6 +328,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.CommandLineParserNS | ||
| 328 | public static class StartAsSystem { public const string KEY = "SAS"; } | 328 | public static class StartAsSystem { public const string KEY = "SAS"; } |
| 329 | public static class RegexTester { public const string KEY = "RGX"; } | 329 | public static class RegexTester { public const string KEY = "RGX"; } |
| 330 | public static class TCPIPTester { public const string KEY = "TCP"; } | 330 | public static class TCPIPTester { public const string KEY = "TCP"; } |
| 331 | + public static class ASEConfig { public const string KEY = "ACF"; } | ||
| 331 | public static class Tool { public const string KEY = "TOL"; } | 332 | public static class Tool { public const string KEY = "TOL"; } |
| 332 | } | 333 | } |
| 333 | } | 334 | } |
Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs
| @@ -42,7 +42,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | @@ -42,7 +42,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | ||
| 42 | .AddMenuItem(new Menu.Item(CLP.Module.MaintenanceToolManager.Functions.StartAsSystem.KEY, "Start As NT AUTHORITY/SYSTEM", StartAsSystem, new Menu.ExecutorParameter(cfg: config))) | 42 | .AddMenuItem(new Menu.Item(CLP.Module.MaintenanceToolManager.Functions.StartAsSystem.KEY, "Start As NT AUTHORITY/SYSTEM", StartAsSystem, new Menu.ExecutorParameter(cfg: config))) |
| 43 | .AddMenuItem(new Menu.Item(CLP.Module.MaintenanceToolManager.Functions.RegexTester.KEY, "Regex tester", RegexTester,new Menu.ExecutorParameter(cfg:config))) | 43 | .AddMenuItem(new Menu.Item(CLP.Module.MaintenanceToolManager.Functions.RegexTester.KEY, "Regex tester", RegexTester,new Menu.ExecutorParameter(cfg:config))) |
| 44 | .AddMenuItem(new Menu.Item(CLP.Module.MaintenanceToolManager.Functions.TCPIPTester.KEY, "TcpIp Tester", TcpIpTester, new Menu.ExecutorParameter(cfg: config, null))) | 44 | .AddMenuItem(new Menu.Item(CLP.Module.MaintenanceToolManager.Functions.TCPIPTester.KEY, "TcpIp Tester", TcpIpTester, new Menu.ExecutorParameter(cfg: config, null))) |
| 45 | - .AddMenuItem(new Menu.Item(CLP.Module.MaintenanceToolManager.Functions.Tool.KEY, "Tool sample", Tool2, new Menu.ExecutorParameter(cfg: config, null))) | 45 | + .AddMenuItem(new Menu.Item(CLP.Module.MaintenanceToolManager.Functions.ASEConfig.KEY, "ASEConfig Utility", AseConfig, new Menu.ExecutorParameter(cfg: config, null))) |
| 46 | + //.AddMenuItem(new Menu.Item(CLP.Module.MaintenanceToolManager.Functions.Tool.KEY, "Tool sample", Tool, new Menu.ExecutorParameter(cfg: config, null))) | ||
| 46 | 47 | ||
| 47 | .SetSelectionMode(Menu.SelectionMode.Single); | 48 | .SetSelectionMode(Menu.SelectionMode.Single); |
| 48 | foreach (var x in config.ExternalUtilityConfigList) | 49 | foreach (var x in config.ExternalUtilityConfigList) |
| @@ -81,7 +82,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | @@ -81,7 +82,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | ||
| 81 | private static object RegexTester(object parameter, object o) | 82 | private static object RegexTester(object parameter, object o) |
| 82 | { | 83 | { |
| 83 | var config = (parameter as Menu.ExecutorParameter).GetConfig<MaintenanceToolsXmlProcessor>(); | 84 | var config = (parameter as Menu.ExecutorParameter).GetConfig<MaintenanceToolsXmlProcessor>(); |
| 84 | - var regexptesterconfig = config.RegexpTesterConfig; | 85 | + var regexptesterconfig = config.RegexpTesterConfigXml; |
| 85 | while(true) | 86 | while(true) |
| 86 | { | 87 | { |
| 87 | var regexstr = ColorConsole.ReadLine($"Enter REGEX to test with:", ConsoleColor.Yellow); | 88 | var regexstr = ColorConsole.ReadLine($"Enter REGEX to test with:", ConsoleColor.Yellow); |
| @@ -364,12 +365,255 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | @@ -364,12 +365,255 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | ||
| 364 | #endregion TcpIpTester | 365 | #endregion TcpIpTester |
| 365 | 366 | ||
| 366 | 367 | ||
| 368 | + #region ASEConfig | ||
| 369 | + private static object AseConfig(object parameter, object o) | ||
| 370 | + { | ||
| 371 | + var config = (parameter as Menu.ExecutorParameter).GetConfig<MaintenanceToolsXmlProcessor>(); | ||
| 372 | + var CommandXmlList = config.ASEConfigXml.Elements(XName.Get("Command")); | ||
| 373 | + if (CommandXmlList == null) return o; | ||
| 374 | + List<ASEConfigCommand> aseconfigcommandList = new List<ASEConfigCommand>(); | ||
| 375 | + foreach (var commandXml in CommandXmlList) { aseconfigcommandList.Add(new ASEConfigCommand(commandXml)); } | ||
| 376 | + var selectedkey = SelectAseConfigCommand(aseconfigcommandList); | ||
| 377 | + if (selectedkey == null) return o; | ||
| 378 | + var selectedcommand = aseconfigcommandList.FirstOrDefault(c=>c.EqualsTo(selectedkey)); | ||
| 379 | + if (selectedcommand == null) return o; | ||
| 380 | + selectedcommand.Ini(); | ||
| 381 | + if (!selectedcommand.SetArgumentParameters()) return o;//a paraméterek interaktív értékeit kéri be | ||
| 382 | + if (!selectedcommand.DisplayArgumentParameters()) return o; | ||
| 383 | + foreach (string currentip in selectedcommand.GetIpList()) | ||
| 384 | + { | ||
| 385 | + ColorConsole.WriteLine($"Processing IP:{currentip}", ConsoleColor.Yellow); | ||
| 386 | + var success = selectedcommand.Resolve(currentip);//feloldja az argument listát | ||
| 387 | + if (success) { selectedcommand.Execute(); }//végrehajtja a parancsot } | ||
| 388 | + string successmsg = success ? "succeeded" : "failed"; | ||
| 389 | + string answer = ColorConsole.ReadLine($"{nameof(AseConfig)} command execution {successmsg} on {currentip}!\nEnter EX to exit from execution loop, anything else to continue!", success?ConsoleColor.Yellow: ConsoleColor.Red); | ||
| 390 | + if (answer.ToLower() == "ex") break; | ||
| 391 | + } | ||
| 392 | + return o; | ||
| 393 | + } | ||
| 394 | + private static string SelectAseConfigCommand(List<ASEConfigCommand> aseconfigcommandList) | ||
| 395 | + { | ||
| 396 | + ColorConsole.WriteLine("ASEConfig Utility",ConsoleColor.Green); | ||
| 397 | + int maxkeylength = aseconfigcommandList.Select(c => c.Key.Length).Concat(new List<int> { 0}).Max(); | ||
| 398 | + int maxdesclength = aseconfigcommandList.Select(c => c.Description.Length).Concat(new List<int> { 0 }).Max(); | ||
| 399 | + | ||
| 400 | + foreach (var c in aseconfigcommandList) | ||
| 401 | + { | ||
| 402 | + var onelineinfo = c.GetOneLineInfo(maxkeylength, maxdesclength); | ||
| 403 | + ColorConsole.Write(onelineinfo.Item1, ConsoleColor.Yellow,suffix:" "); | ||
| 404 | + ColorConsole.Write(onelineinfo.Item2, ConsoleColor.White, suffix: " "); | ||
| 405 | + ColorConsole.WriteLine(onelineinfo.Item3, ConsoleColor.Gray); | ||
| 406 | + } | ||
| 407 | + var answer = ColorConsole.ReadLine($"Select command key", ConsoleColor.Gray, bracket: "[]",validitylist: aseconfigcommandList.Select(c => c.Key).ToList()); | ||
| 408 | + if (answer.ToLower() == "ex") return null; | ||
| 409 | + return answer; | ||
| 410 | + } | ||
| 411 | + private class ASEConfigCommand | ||
| 412 | + { | ||
| 413 | + private enum CommandType { export,import,importnoanswer, exportpartial,} | ||
| 414 | + public ASEConfigCommand(XElement commandXml) | ||
| 415 | + { | ||
| 416 | + const string DEFAULTIMPORTARGUMENTS = "-u {ASEUSERNAME}:{ASEPASSWORD} -X POST --form configrecord=\"@{CONFIGFILE}\" http://{ASEIP}/import/config"; | ||
| 417 | + const string DEFAULTIMPORTNOANSWERARGUMENTS = "-u {ASEUSERNAME}:{ASEPASSWORD} -X POST --form configrecord=\"@{CONFIGFILE}\" http://{ASEIP}/import/config -m 5"; | ||
| 418 | + const string DEFAULTEXPORTARGUMENTS = "-u {ASEUSERNAME}:{ASEPASSWORD} -X POST http://{ASEIP}/export/config -o ASECONFIG-{ASEIP}.xml"; | ||
| 419 | + const string DEFAULTEXPORTPARTIALARGUMENTS = "-u {ASEUSERNAME}:{ASEPASSWORD} -X POST -d \"optionalGroupList = {CONFIGGROUPNAME}:{CONFIGGROUPINSTANCE}\" http://{ASEIP}/export/config -o ASECONFIG-{ASEIP}.xml"; | ||
| 420 | + var typestr = (commandXml.Attribute(XName.Get(nameof(Type)))?.Value)??nameof(CommandType.import); | ||
| 421 | + Type = CommandType.import; try { Type = (CommandType)Enum.Parse(typeof(CommandType),typestr); } catch { } | ||
| 422 | + | ||
| 423 | + ConfigGroupName = commandXml.Attribute(XName.Get(nameof(ConfigGroupName)))?.Value; | ||
| 424 | + ConfigGroupInstance = commandXml.Attribute(XName.Get(nameof(ConfigGroupInstance)))?.Value; | ||
| 425 | + AseUsername = (commandXml.Attribute(XName.Get(nameof(AseUsername)))?.Value) ?? "admin"; | ||
| 426 | + AsePassword = (commandXml.Attribute(XName.Get(nameof(AsePassword)))?.Value) ?? "PASSWORD"; | ||
| 427 | + Key = (commandXml.Attribute(XName.Get(nameof(Key)))?.Value) ?? ""; | ||
| 428 | + Exe = (commandXml.Attribute(XName.Get(nameof(Exe)))?.Value)??"CURL\\curl.exe"; | ||
| 429 | + ExeDir = Path.GetDirectoryName(Exe); | ||
| 430 | + AseIp = commandXml.Attribute(XName.Get(nameof(AseIp)))?.Value; | ||
| 431 | + ConfigFile = commandXml.Attribute(XName.Get(nameof(ConfigFile)))?.Value; | ||
| 432 | + if (!Path.IsPathRooted(ConfigFile)) ConfigFile = Path.Combine(ExeDir, ConfigFile); | ||
| 433 | + Description = (commandXml.Attribute(XName.Get(nameof(Description)))?.Value)??""; | ||
| 434 | + Arguments = (commandXml.Attribute(XName.Get(nameof(Arguments)))?.Value)?? | ||
| 435 | + ( | ||
| 436 | + Type== CommandType.export? DEFAULTEXPORTARGUMENTS | ||
| 437 | + : Type== CommandType.exportpartial ? DEFAULTEXPORTPARTIALARGUMENTS | ||
| 438 | + : Type == CommandType.importnoanswer ? DEFAULTIMPORTNOANSWERARGUMENTS | ||
| 439 | + : /*Type == CommandType.import ?*/DEFAULTIMPORTARGUMENTS | ||
| 440 | + ); | ||
| 441 | + ArgumentParameters = (commandXml.Attribute(XName.Get(nameof(ArgumentParameters)))?.Value)??""; | ||
| 442 | + var plist = ArgumentParameters.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); | ||
| 443 | + foreach (var p in plist) | ||
| 444 | + { | ||
| 445 | + var aname = p.Split('=')[0]; | ||
| 446 | + string pvalue=""; try { pvalue = p.Split('=')[1]; } catch { } | ||
| 447 | + var po = new ASEConfigCommandParameter(); | ||
| 448 | + po.Name = aname; | ||
| 449 | + if (pvalue.StartsWith("?")) { po.Interactive = true; po.Prompt = pvalue.Substring(1); } | ||
| 450 | + else { po.Value = pvalue; } | ||
| 451 | + ArgumentParameterList.Add(po); | ||
| 452 | + } | ||
| 453 | + } | ||
| 454 | + public bool EqualsTo(string selection) | ||
| 455 | + { | ||
| 456 | + return Key.ToLower()==selection.ToLower(); | ||
| 457 | + } | ||
| 458 | + public List<string> GetIpList() | ||
| 459 | + { | ||
| 460 | + return AseIpResolved.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList(); | ||
| 461 | + } | ||
| 462 | + public Tuple<string, string, string> GetOneLineInfo(int keylength,int desclength) | ||
| 463 | + { | ||
| 464 | + if (keylength == 0) keylength = 6; | ||
| 465 | + if (desclength == 0) desclength = 20; | ||
| 466 | + string keystring = (Key + new string(' ', keylength)).Substring(0, keylength); | ||
| 467 | + string descstring = (Description + new string(' ', desclength)).Substring(0, desclength); | ||
| 468 | + return Tuple.Create(keystring, descstring, $"(Type={Type},CfgFile={ConfigFile},Ase:Ip={AseIp},UN={AseUsername},PSW={AsePassword})"); | ||
| 469 | + } | ||
| 470 | + public void Ini() | ||
| 471 | + { | ||
| 472 | + AseIpResolved = AseIp; | ||
| 473 | + AseUsernameResolved=AseUsername; | ||
| 474 | + AsePasswordResolved = AsePassword; | ||
| 475 | + ConfigFileResolved = ConfigFile; | ||
| 476 | + ArgumentsResolved = Arguments; | ||
| 477 | + } | ||
| 478 | + public bool SetArgumentParameters() | ||
| 479 | + { | ||
| 480 | + AseUsernameResolved = ASEConfigCommandParameter.SetCurrentValue(AseUsername, nameof(AseUsername)); | ||
| 481 | + AsePasswordResolved = ASEConfigCommandParameter.SetCurrentValue(AsePassword, nameof(AsePassword)); | ||
| 482 | + ConfigFileResolved = ASEConfigCommandParameter.SetCurrentValue(ConfigFile, nameof(ConfigFile)); | ||
| 483 | + foreach (var p in ArgumentParameterList) { p.SetCurrentValue(); if (p.Value == null) return false; } | ||
| 484 | + AseIpResolved = ASEConfigCommandParameter.SetCurrentValue(AseIp, nameof(AseIp)); | ||
| 485 | + return true; | ||
| 486 | + } | ||
| 487 | + public bool DisplayArgumentParameters() | ||
| 488 | + { | ||
| 489 | + ColorConsole.WriteLine("Command parameters:"); | ||
| 490 | + ColorConsole.WriteLine(AseIpResolved,prefix:$"{nameof(AseIp)}="); | ||
| 491 | + ColorConsole.WriteLine(AseUsernameResolved, prefix: $"{nameof(AseUsername)}="); | ||
| 492 | + ColorConsole.WriteLine(AsePasswordResolved, prefix: $"{nameof(AsePassword)}="); | ||
| 493 | + ColorConsole.WriteLine(ConfigFileResolved, prefix: $"{nameof(ConfigFile)}="); | ||
| 494 | + foreach (var p in ArgumentParameterList) { ColorConsole.WriteLine($"{p.Name}={p.Value}"); } | ||
| 495 | + var answer = ColorConsole.ReadLine("Execute command with these parameters?", defaultvalue: "no", validitylist: new List<string>() { "yes", "no", }, bracket: "[]"); | ||
| 496 | + return answer.ToLower() == "yes"; | ||
| 497 | + } | ||
| 498 | + public bool Resolve(string currentip) | ||
| 499 | + { | ||
| 500 | + //resolve arguments | ||
| 501 | + foreach (var a in ArgumentParameterList) | ||
| 502 | + { | ||
| 503 | + ArgumentsResolved = ArgumentsResolved.Replace($"{{{a.Name}}}", a.Value); | ||
| 504 | + ConfigFileResolved = ConfigFileResolved.Replace($"{{{a.Name}}}", a.Value); | ||
| 505 | + currentip = currentip.Replace($"{{{a.Name}}}", a.Value); | ||
| 506 | + AseUsernameResolved = AseUsernameResolved.Replace($"{{{a.Name}}}", a.Value); | ||
| 507 | + AsePasswordResolved = AsePasswordResolved.Replace($"{{{a.Name}}}", a.Value); | ||
| 508 | + } | ||
| 509 | + ConfigFileResolved = ConfigFileResolved.Replace($"{{{nameof(AseIp).ToUpper()}}}", currentip); | ||
| 510 | + ArgumentsResolved = ArgumentsResolved.Replace($"{{{nameof(AseIp).ToUpper()}}}", currentip); | ||
| 511 | + ArgumentsResolved = ArgumentsResolved.Replace($"{{{nameof(AseUsername).ToUpper()}}}", AseUsernameResolved); | ||
| 512 | + ArgumentsResolved = ArgumentsResolved.Replace($"{{{nameof(AsePassword).ToUpper()}}}", AsePasswordResolved); | ||
| 513 | + if (Type== CommandType.exportpartial) ArgumentsResolved = ArgumentsResolved.Replace($"{{{nameof(ConfigGroupName).ToUpper()}}}", ConfigGroupName); | ||
| 514 | + if (Type == CommandType.exportpartial) ArgumentsResolved = ArgumentsResolved.Replace($"{{{nameof(ConfigGroupInstance).ToUpper()}}}", ConfigGroupInstance); | ||
| 515 | + | ||
| 516 | + //resolve config files | ||
| 517 | + if (Type == CommandType.import || Type == CommandType.importnoanswer) | ||
| 518 | + { | ||
| 519 | + try | ||
| 520 | + { | ||
| 521 | + var cfgfilecontent = System.IO.File.ReadAllText(ConfigFileResolved); | ||
| 522 | + foreach (var a in ArgumentParameterList) | ||
| 523 | + { | ||
| 524 | + cfgfilecontent = cfgfilecontent.Replace($"{{{a.Name}}}", a.Value); | ||
| 525 | + } | ||
| 526 | + cfgfilecontent = cfgfilecontent.Replace($"{{{nameof(AseIp).ToUpper()}}}", currentip); | ||
| 527 | + cfgfilecontent = cfgfilecontent.Replace($"{{{nameof(ConfigFile).ToUpper()}}}", ConfigFileResolved); | ||
| 528 | + var tempfilename = Path.GetTempFileName(); | ||
| 529 | + System.IO.File.WriteAllText(tempfilename, cfgfilecontent); | ||
| 530 | + ArgumentsResolved = ArgumentsResolved.Replace($"{{{nameof(ConfigFile).ToUpper()}}}", tempfilename); | ||
| 531 | + return true; | ||
| 532 | + } | ||
| 533 | + catch (Exception ex) | ||
| 534 | + { | ||
| 535 | + ColorConsole.WriteLine(ex.Message, f: ConsoleColor.Red); | ||
| 536 | + return false; | ||
| 537 | + } | ||
| 538 | + } | ||
| 539 | + return true; | ||
| 540 | + } | ||
| 541 | + public void Execute() | ||
| 542 | + { | ||
| 543 | + Console.WriteLine($"Executing:{Exe} {ArgumentsResolved}"); | ||
| 544 | + using (System.Diagnostics.Process pProcess = new System.Diagnostics.Process()) | ||
| 545 | + { | ||
| 546 | + Process ExternalProcess = new Process(); | ||
| 547 | + ExternalProcess.StartInfo.FileName = Exe; | ||
| 548 | + ExternalProcess.StartInfo.UseShellExecute = false; | ||
| 549 | + ExternalProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; | ||
| 550 | + | ||
| 551 | + ExternalProcess.StartInfo.RedirectStandardOutput = true; | ||
| 552 | + ExternalProcess.OutputDataReceived += (sender, args) => Console.WriteLine("received output: {0}", args.Data); | ||
| 553 | + | ||
| 554 | + ExternalProcess.StartInfo.Arguments = ArgumentsResolved; | ||
| 555 | + ExternalProcess.Start(); | ||
| 556 | + ExternalProcess.BeginOutputReadLine(); | ||
| 557 | + ExternalProcess.WaitForExit(-1); | ||
| 558 | + } | ||
| 559 | + } | ||
| 560 | + public string Key; | ||
| 561 | + private CommandType Type; | ||
| 562 | + private string ConfigGroupName; | ||
| 563 | + private string ConfigGroupInstance; | ||
| 564 | + private string AseUsername; | ||
| 565 | + private string AseUsernameResolved; | ||
| 566 | + private string AsePassword; | ||
| 567 | + private string AsePasswordResolved; | ||
| 568 | + public string Description; | ||
| 569 | + private string Exe; | ||
| 570 | + private string ExeDir; | ||
| 571 | + private string ConfigFile; | ||
| 572 | + private string ConfigFileResolved; | ||
| 573 | + private string AseIp; | ||
| 574 | + private string AseIpResolved; | ||
| 575 | + private string Arguments; | ||
| 576 | + private string ArgumentsResolved; | ||
| 577 | + private string ArgumentParameters; | ||
| 578 | + private List<ASEConfigCommandParameter> ArgumentParameterList = new List<ASEConfigCommandParameter>(); | ||
| 579 | + } | ||
| 580 | + private class ASEConfigCommandParameter | ||
| 581 | + { | ||
| 582 | + public string Name; | ||
| 583 | + public string Value=""; | ||
| 584 | + public bool Interactive=false; | ||
| 585 | + public string Prompt=""; | ||
| 586 | + public string SetCurrentValue() { return SetCurrentValue(Interactive,Value,Prompt,Name); } | ||
| 587 | + public static string SetCurrentValue(string valueorinteractive, string name) | ||
| 588 | + { | ||
| 589 | + string prompt = null; | ||
| 590 | + string value = null; | ||
| 591 | + bool interactive = valueorinteractive.StartsWith("?"); | ||
| 592 | + if (interactive) { prompt = valueorinteractive == "?" ? "" : valueorinteractive.Substring(1); } else { value = valueorinteractive; } | ||
| 593 | + return SetCurrentValue(interactive,value,prompt,name); | ||
| 594 | + } | ||
| 595 | + private static string SetCurrentValue(bool interactive, string value,string prompt, string name) | ||
| 596 | + { | ||
| 597 | + if (!interactive) return value; | ||
| 598 | + string prompttext = string.IsNullOrWhiteSpace(prompt) ? $"Enter {name}" : $"{prompt} ({name})"; | ||
| 599 | + ColorConsole.WriteLine(prompttext,ConsoleColor.Yellow); | ||
| 600 | + ColorConsole.WriteLine($"Enter NONE (or nothing) for no value!", ConsoleColor.Gray); | ||
| 601 | + value = ColorConsole.ReadLine(); | ||
| 602 | + value = value.ToLower() == "ex" ? null | ||
| 603 | + : value.ToLower() == "none" ? "<None>" | ||
| 604 | + : value == "" ? "<None>" | ||
| 605 | + : value; | ||
| 606 | + return value; | ||
| 607 | + } | ||
| 608 | + } | ||
| 609 | + #endregion ASEConfig | ||
| 610 | + | ||
| 367 | #region Tool templates | 611 | #region Tool templates |
| 368 | - private static object Tool2(object parameter, object o) | 612 | + private static object Tool(object parameter, object o) |
| 369 | { | 613 | { |
| 370 | var config = (parameter as Menu.ExecutorParameter).GetConfig<MaintenanceToolsXmlProcessor>(); | 614 | var config = (parameter as Menu.ExecutorParameter).GetConfig<MaintenanceToolsXmlProcessor>(); |
| 371 | - var regexptesterconfig = config.RegexpTesterConfig; | ||
| 372 | - ColorConsole.ReadLine($"{nameof(Tool2)} is not ready yet...", ConsoleColor.Yellow); | 615 | + var regexptesterconfig = config.ToolConfigXml; |
| 616 | + ColorConsole.ReadLine($"{nameof(Tool)} is not ready yet...", ConsoleColor.Yellow); | ||
| 373 | return o; | 617 | return o; |
| 374 | } | 618 | } |
| 375 | #endregion Tool templates | 619 | #endregion Tool templates |
| @@ -406,8 +650,10 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | @@ -406,8 +650,10 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | ||
| 406 | public bool WaitForExit=XmlStructure.ExternalUtility.Attributes.WaitForExit.Values.DEFAULT; | 650 | public bool WaitForExit=XmlStructure.ExternalUtility.Attributes.WaitForExit.Values.DEFAULT; |
| 407 | public bool Valid; | 651 | public bool Valid; |
| 408 | } | 652 | } |
| 409 | - public XElement RegexpTesterConfig; | 653 | + public XElement RegexpTesterConfigXml; |
| 410 | public XElement PingerConfigXml; | 654 | public XElement PingerConfigXml; |
| 655 | + public XElement ASEConfigXml; | ||
| 656 | + public XElement ToolConfigXml; | ||
| 411 | public class IPAddressParsingResult | 657 | public class IPAddressParsingResult |
| 412 | { | 658 | { |
| 413 | public IPAddress IP; | 659 | public IPAddress IP; |
| @@ -421,7 +667,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | @@ -421,7 +667,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | ||
| 421 | #region constructor | 667 | #region constructor |
| 422 | public MaintenanceToolsXmlProcessor(string xmlcs, string basefolder, string lcid) : base(xmlcs, basefolder, lcid, null) | 668 | public MaintenanceToolsXmlProcessor(string xmlcs, string basefolder, string lcid) : base(xmlcs, basefolder, lcid, null) |
| 423 | { | 669 | { |
| 424 | - RegexpTesterConfig = GetXElement(nameof(XmlStructure.RegexpTester)); | 670 | + RegexpTesterConfigXml = GetXElement(nameof(XmlStructure.RegexpTester)); |
| 671 | + ASEConfigXml = GetXElement(nameof(XmlStructure.ASEConfig)); | ||
| 672 | + ToolConfigXml = GetXElement(nameof(XmlStructure.ToolConfig)); | ||
| 425 | 673 | ||
| 426 | var TcpIpTesterXml = GetXElement(nameof(XmlStructure.TcpIpTester)); | 674 | var TcpIpTesterXml = GetXElement(nameof(XmlStructure.TcpIpTester)); |
| 427 | if (TcpIpTesterXml != null) | 675 | if (TcpIpTesterXml != null) |
| @@ -451,6 +699,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | @@ -451,6 +699,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS | ||
| 451 | public static class XmlStructure | 699 | public static class XmlStructure |
| 452 | { | 700 | { |
| 453 | public static class RegexpTester { } | 701 | public static class RegexpTester { } |
| 702 | + public static class ASEConfig { } | ||
| 703 | + public static class ToolConfig { } | ||
| 454 | public static class ExternalUtility | 704 | public static class ExternalUtility |
| 455 | { | 705 | { |
| 456 | public static class Attributes | 706 | public static class Attributes |
Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
| @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; | @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; | ||
| 32 | // You can specify all the values or you can default the Build and Revision Numbers | 32 | // You can specify all the values or you can default the Build and Revision Numbers |
| 33 | // by using the '*' as shown below: | 33 | // by using the '*' as shown below: |
| 34 | // [assembly: AssemblyVersion("1.0.*")] | 34 | // [assembly: AssemblyVersion("1.0.*")] |
| 35 | -[assembly: AssemblyVersion("1.18.1.0")] | ||
| 36 | -[assembly: AssemblyFileVersion("1.18.1.0")] | 35 | +[assembly: AssemblyVersion("1.19.0.0")] |
| 36 | +[assembly: AssemblyFileVersion("1.19.0.0")] |