diff --git a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - ColorConsole.cs b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - ColorConsole.cs index bb0a745..24d96a3 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - ColorConsole.cs +++ b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - ColorConsole.cs @@ -134,7 +134,8 @@ 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, bool required = false) + 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) diff --git a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - CommandLineParser.cs b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - CommandLineParser.cs index 60bbc7a..2c24f07 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - CommandLineParser.cs +++ b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - CommandLineParser.cs @@ -301,6 +301,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.CommandLineParserNS } public static class RelocatePhysicalFiles { public const string KEY = "COP"; } public static class ShrinkDB { public const string KEY = "SHR"; } + public static class ExecuteScript{ public const string KEY = "EXE"; } } } diff --git a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools.cs b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools.cs index c78c600..e170eb1 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools.cs +++ b/Vrh.Log4Pro.MaintenanceConsole/ConsoleFunction - Tools.cs @@ -302,6 +302,48 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS if (list32.Count() > 0) { if (list64.Count() > 0) { os = "64bit"; } else { os = "32bit"; } } return os; } + public static bool ResolveArguments(string parameterkvpstring, string stringwithparameters, out string resolvedtext, bool interactive = true) + { + var argumentparametersdictionary = parameterkvpstring.Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries) + .Select(kvp => CreateKVP(kvp)) + .Where(kvp => kvp.Key != null) + .ToDictionary(kvp => kvp.Key, kvp => kvp.Value); + Dictionary resolveddictionary = new Dictionary(); + resolvedtext = stringwithparameters; + foreach (var kvp in argumentparametersdictionary) + { + if (kvp.Value.StartsWith("?") && interactive) + { + string prompt = $"Enter value for {kvp.Key}:"; + string kvpdefaultvalue = null; + if (kvp.Value.Length > 1) + { + prompt = kvp.Value.Substring(1).Split(new char[] { '?' }, StringSplitOptions.RemoveEmptyEntries)[0]; + if (kvp.Value.Substring(1).IndexOf('?') != -1) kvpdefaultvalue = kvp.Value.Substring(1).Split(new char[] { '?' }, StringSplitOptions.RemoveEmptyEntries)[1]; + } + string value = ColorConsole.ReadLine(prompt, ConsoleColor.Yellow, defaultvalue: kvpdefaultvalue); + if (value.ToLower() == "ex") { return false; } + resolveddictionary.Add(kvp.Key, value); + } + else if (kvp.Value.StartsWith("?") && !interactive) resolveddictionary.Add(kvp.Key, $"{{{kvp.Key}}}"); + else { resolveddictionary.Add(kvp.Key, kvp.Value); } + } + resolvedtext = VRH.Common.StringConstructor.ResolveConstructorR(resolveddictionary, stringwithparameters, "{}@@"); + return true; + } + 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); } + } } class ComputerInfo @@ -451,5 +493,6 @@ namespace Vrh.Log4Pro.MaintenanceConsole.ToolsNS return rexmsg.Replace("\n\n","\n"); } } + #endregion ExceptionExtension class } diff --git a/Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs b/Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs index 07ef467..0b70249 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs +++ b/Vrh.Log4Pro.MaintenanceConsole/Manager - MaintenanceToolManager.cs @@ -63,7 +63,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS ExternalProcess.StartInfo.FileName = config.Exe; ExternalProcess.StartInfo.WindowStyle = config.ProcessWindowsStyle; - ExternalProcess.StartInfo.Arguments = config.ResolveArguments(); + if (!Tools.ResolveArguments(config.ArgumentParameters, config.Arguments, out string resolvedtext)) { return o; }; + ExternalProcess.StartInfo.Arguments = resolvedtext; ExternalProcess.Start(); int waitingtime = config.WaitForExit ? -1 : 0; ExternalProcess.WaitForExit(waitingtime); @@ -382,16 +383,15 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS { public ExternalUtilityConfig(XElement x) { - 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); + ArgumentParameters = GetValue(nameof(XmlStructure.ExternalUtility.Attributes.ArgumentParameters), x, XmlStructure.ExternalUtility.Attributes.ArgumentParameters.Values.DEFAULT); - 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), "{}@@"); + Exe = GetValue(nameof(XmlStructure.ExternalUtility.Attributes.Exe), x, ""); + this.Key = GetValue(nameof(XmlStructure.ExternalUtility.Attributes.Key), x, ""); + this.Description = GetValue(nameof(XmlStructure.ExternalUtility.Attributes.Description), x, Exe); + Tools.ResolveArguments(ArgumentParameters, this.Key,out this.Key,interactive:false); + Tools.ResolveArguments(ArgumentParameters, this.Description, out this.Description, interactive: false); Arguments = 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); @@ -399,43 +399,11 @@ namespace Vrh.Log4Pro.MaintenanceConsole.MaintenanceToolManagerNS 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 ArgumentParameters = XmlStructure.ExternalUtility.Attributes.ArgumentParameters.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; - - 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 string ResolveArguments() - { - var resolveddictionary = new Dictionary(); - foreach (var kvp in ArgumentParametersDictionary) - { - if (!kvp.Value.StartsWith("?")) { resolveddictionary.Add(kvp.Key, kvp.Value); } - else - { - string prompt; - if (kvp.Value.Length == 1) { prompt = $"Enter value for {kvp.Key}:"; } - else { prompt = kvp.Value.Substring(1); } - string value = ColorConsole.ReadLine(prompt, ConsoleColor.Yellow); - if (value.ToLower() == "ex") { Valid = false; return null; } - resolveddictionary.Add(kvp.Key, value); - } - } - return VRH.Common.StringConstructor.ResolveConstructorR(resolveddictionary, Arguments, "{}@@"); - } } public XElement RegexpTesterConfig; public XElement PingerConfigXml; diff --git a/Vrh.Log4Pro.MaintenanceConsole/Manager - SQLDataBaseManager.cs b/Vrh.Log4Pro.MaintenanceConsole/Manager - SQLDataBaseManager.cs index 3ec3a35..76e7d4d 100644 --- a/Vrh.Log4Pro.MaintenanceConsole/Manager - SQLDataBaseManager.cs +++ b/Vrh.Log4Pro.MaintenanceConsole/Manager - SQLDataBaseManager.cs @@ -49,6 +49,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS .AddMenuItem(new Menu.Item(CLP.Module.SQLDataBaseManager.Function.RestoreDataBase.KEY, "Restore database backup", RestoreDataBase, ep)) .AddMenuItem(new Menu.Item(CLP.Module.SQLDataBaseManager.Function.RelocatePhysicalFiles.KEY, "Copy database and or relocate its physical files", RelocatePhysicalFiles, ep)) .AddMenuItem(new Menu.Item(CLP.Module.SQLDataBaseManager.Function.ShrinkDB.KEY, "Shrink database", ShrinkDB, ep)) + .AddMenuItem(new Menu.Item(CLP.Module.SQLDataBaseManager.Function.ExecuteScript.KEY, "Execute script", ExecuteScript, ep)) .SetSelectionMode(Menu.SelectionMode.Single) .SetMenuHeaderDisplayer(DataBaseListDisplayer); menufunctions.ExecuteMenu(functionkey); @@ -215,6 +216,56 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS } return o; } + private static object ExecuteScript(object parameter, object o) + { + var config = (parameter as Menu.ExecutorParameter).GetConfig(); + var args = (parameter as Menu.ExecutorParameter).Args; + + var selectedtaskindexes = CommandLine.GetCommandLineArgument(args, CLP.Module.ScheduledTaskManager.Function.CMD_TASKS); + + var menufolders = DisplaySQLDataBaseMenu(config, $"Select the SQL database(s) to manage with function '{nameof(ExecuteScript)}'!", silent: true); + Menu.Selection sr = menufolders.Select(selectedtaskindexes); + if (sr.Result == Menu.SelectionResult.Exit) { return o; } + else if (sr.Result == Menu.SelectionResult.None) { return o; } + else if (sr.Result == Menu.SelectionResult.Error) { return o; } + else if (sr.Result == Menu.SelectionResult.Ok) { } + else { } + foreach (var p in sr.SelectedParameterList) + { + SQLDataBase sqld = p.Parameters as SQLDataBase; + try + { + if (sqld.Xml_SQLScriptList.Count==0) + { + ColorConsole.WriteLine($"There are no scripts for database. Name:{sqld.DBName}, server: {sqld.DataSource}", ConsoleColor.Red); + } + else + { + ColorConsole.WriteLine(); + ColorConsole.WriteLine($"Select the scripts for database. Name:{sqld.DBName}, server: {sqld.DataSource}", ConsoleColor.Yellow); + var vlist = new List(); + foreach (var s in sqld.Xml_SQLScriptList) + { + ColorConsole.Write(s.Key, ConsoleColor.Yellow, bracket: "[]",suffix:" ",prefix: " "); + ColorConsole.Write($"{s.Description} ({s.Name})", ConsoleColor.Yellow, prefix: "Script:"); + ColorConsole.WriteLine(); + vlist.Add(s.Key); + } + var scriptkey = ColorConsole.ReadLine("Select the script! [empty]=next DB, [*]=all, [EX]=exit.", ConsoleColor.Yellow, prefix:" ", suffix: " --> ", validitylist: vlist); + if (string.IsNullOrWhiteSpace(scriptkey)) { continue; } + if (scriptkey.ToLower()=="ex") { return o; } + SQLDataBase.SQLScript ss = sqld.Xml_SQLScriptList.FirstOrDefault(s=>s.Key==scriptkey); + if (!Tools.ResolveArguments(ss.ArgumentParameters, ss.ScriptText,out string ssScriptText)) { return o; } + ColorConsole.WriteLine(ssScriptText); + //SQLDataBaseManagerCore.ExecuteSQLScript(sqld.SQLCS, ssScriptText, ss.CommandTimeout, null); + ColorConsole.WriteLine($"Script executed. Name:{sqld.DBName}, script name: {ss.Name}", ConsoleColor.Green); + } + } + catch (Exception ex) { ColorConsole.WriteLine(ex.Message, ConsoleColor.Red); } + } + return o; + } + private static object ShrinkDB(object parameter, object o) { var config = (parameter as Menu.ExecutorParameter).GetConfig(); @@ -303,13 +354,13 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS #region private methods #region private DisplaySQLDataBaseMenu private static void DataBaseListDisplayer() { DisplaySQLDataBaseMenu(); } - private static Menu DisplaySQLDataBaseMenu(SQLDataBaseManagerXmlProcessor config = null, string prompt = null, bool silent = false) + private static Menu DisplaySQLDataBaseMenu(SQLDataBaseManagerXmlProcessor config = null, string prompt = null, bool silent = false, Menu.SelectionMode selectionmode = Menu.SelectionMode.Multi) { if (config == null) { config = new SQLDataBaseManagerXmlProcessor(XMLCONNECTIONSTRING, "", "hu-HU"); } List schtskdefList = config.GetDefinitionList(); var menufct = new Menu("SQL Databases", prompt) .SetMenuItemDisplayer(DisplayDataBaseInfo) - .SetSelectionMode(Menu.SelectionMode.Multi); + .SetSelectionMode(selectionmode); menufct.ClearMenuItemList(); foreach (var schtskdef in schtskdefList) { @@ -363,6 +414,15 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS ColorConsole.WriteLine(" "); return " "; } + else if (5 <= lineix && lineix <= 5 + st.Xml_SQLScriptList.Count) + { + if (st.Xml_SQLScriptList.Count == 0) { return null; } + if (st.Xml_SQLScriptList.Count-1 < lineix-5) { return null; } + var s = st.Xml_SQLScriptList.ToArray()[lineix-5]; + ColorConsole.Write(s.Key, ConsoleColor.Yellow, bracket: "[]", suffix: " ", prefix: " Script: "); + ColorConsole.WriteLine($"{s.Description} ({s.Name})", ConsoleColor.Yellow); + return " "; + } return null; } #endregion private method: DisplayDataBaseInfo @@ -723,11 +783,13 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS else { return new ReturnInfoJSON() { ReturnValue = 0, ReturnMessage = null, }; } } - - - - - + /// + /// Egy SQL batch végrehajtása + /// + /// + /// + /// + /// private static System.Data.DataSet ExecuteSQLScriptBatch(Microsoft.Data.SqlClient.SqlConnection sqlc, string sqlbatchtxt, int commandtimeout) { var sqlcommand = sqlc.CreateCommand(); @@ -1064,7 +1126,6 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS public SQLDataBaseManagerXmlProcessor(string xmlcs, string basefolder, string lcid) : base(xmlcs, basefolder, lcid, null) { _sqldatabaselist = new List(); - var schtskxmllist = GetAllXElements(nameof(SQLDataBase.XmlStructure.SQLDataBase)); var common = new SQLDataBase() { Xml_CreateZip = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.CreateZip), this.RootElement, SQLDataBase.XmlStructure.Attributes.CreateZip.Values.DEFAULT), @@ -1072,11 +1133,12 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS Xml_RestoreFileNameMask = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.RestoreFileNameMask), this.RootElement, SQLDataBase.XmlStructure.Attributes.RestoreFileNameMask.Values.DEFAULT), Xml_BackupTargetDirectoryPath = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.BackupTargetDirectoryPath), this.RootElement, SQLDataBase.XmlStructure.Attributes.BackupTargetDirectoryPath.Values.DEFAULT), Xml_PhysicalFilesDirectoryPath = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.PhysicalFilesDirectoryPath), this.RootElement, SQLDataBase.XmlStructure.Attributes.PhysicalFilesDirectoryPath.Values.DEFAULT), - + Xml_ScriptCommandTimeout = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.ScriptCommandTimeout), this.RootElement, SQLDataBase.XmlStructure.Attributes.ScriptCommandTimeout.Values.DEFAULT), }; - if (schtskxmllist != null && schtskxmllist.Any()) + var sqldatabasexmllist = GetAllXElements(nameof(SQLDataBase.XmlStructure.SQLDataBase)); + if (sqldatabasexmllist != null && sqldatabasexmllist.Any()) { - foreach (var schtskxml in schtskxmllist) { var st = new SQLDataBase(schtskxml,common); if (st.Valid) { _sqldatabaselist.Add(st); } } + foreach (var sqldatabasexml in sqldatabasexmllist) { var st = new SQLDataBase(sqldatabasexml,common); if (st.Valid) { _sqldatabaselist.Add(st); } } } } #endregion constructor @@ -1099,7 +1161,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS public string Xml_BackupTargetDirectoryPath; public string Xml_SQLConnectionString; public string Xml_PhysicalFilesDirectoryPath; + public int Xml_ScriptCommandTimeout; public List Xml_SQLDataList; + public List Xml_SQLScriptList; public string DBName; public string DataSource; @@ -1128,11 +1192,19 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS Xml_BackupTargetDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.BackupTargetDirectoryPath), sqldatabasexml, common.Xml_BackupTargetDirectoryPath); Xml_SQLConnectionString = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.SQLConnectionString), sqldatabasexml, XmlStructure.SQLDataBase.Attributes.SQLConnectionString.Values.DEFAULT); - var sqldataXmlList = GetAllXElements(sqldatabasexml, nameof(XmlStructure.SQLDataBase.SQLData)); Xml_CreateZip = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.CreateZip), sqldatabasexml, common.Xml_CreateZip); Xml_PhysicalFilesDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.PhysicalFilesDirectoryPath), sqldatabasexml, common.Xml_PhysicalFilesDirectoryPath); + + Xml_ScriptCommandTimeout = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.ScriptCommandTimeout), sqldatabasexml, common.Xml_ScriptCommandTimeout); + Xml_SQLDataList = new List(); + var sqldataXmlList = GetAllXElements(sqldatabasexml, nameof(XmlStructure.SQLDataBase.SQLData)); if (sqldataXmlList!=null) { foreach (var sqldataXml in sqldataXmlList) { Xml_SQLDataList.Add(new SQLData(sqldataXml)); } } + + Xml_SQLScriptList = new List(); + var sqlscriptsXml = GetXElement(sqldatabasexml, nameof(XmlStructure.SQLDataBase.Scripts)); + var sqlscriptXmlList = GetAllXElements(sqlscriptsXml, nameof(XmlStructure.SQLDataBase.Scripts.Script)); + if (sqlscriptXmlList != null) { int scriptindex = 1; foreach (var sqlscriptXml in sqlscriptXmlList) { Xml_SQLScriptList.Add(new SQLScript(sqlscriptXml, Xml_ScriptCommandTimeout,scriptindex++)); } } } #endregion xml constructor #region cloner constructor @@ -1147,7 +1219,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS Xml_BackupTargetDirectoryPath = sqld.Xml_BackupTargetDirectoryPath; Xml_SQLConnectionString = sqld.Xml_SQLConnectionString; Xml_PhysicalFilesDirectoryPath = sqld.Xml_PhysicalFilesDirectoryPath; - Xml_SQLDataList = sqld.Xml_SQLDataList.Select(x => x).ToList(); + Xml_SQLDataList = sqld.Xml_SQLDataList.Select(x => new SQLData(x)).ToList(); + Xml_SQLScriptList = sqld.Xml_SQLScriptList.Select(x => new SQLScript(x)).ToList(); } #endregion cloner constructor #region XmlStructure @@ -1159,6 +1232,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS public static class RestoreFileNameMask { public static class Values { public const string DEFAULT = ""; } } public static class BackupTargetDirectoryPath { public static class Values { public const string DEFAULT = ""; } } public static class PhysicalFilesDirectoryPath { public static class Values { public const string DEFAULT = ""; } } + public static class ScriptCommandTimeout { public static class Values { public const int DEFAULT = 10000; } } public static class CreateZip{ public static class Values { public const bool DEFAULT = true; } } @@ -1175,6 +1249,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS public static class BackupTargetDirectoryPath { } public static class CreateZip { } public static class PhysicalFilesDirectoryPath { } + public static class ScriptCommandTimeout { public static class Values { public const int DEFAULT = 10000; } } } public static class SQLData { @@ -1184,9 +1259,49 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS public static class Group { public static class Values { public const string DEFAULT = ""; } } } } + public static class Scripts + { + public static class Script + { + public static class Values { public const string DEFAULT = ""; } + public static class Attributes + { + public static class Name { public static class Values { public const string DEFAULT = ""; } } + public static class Description { public static class Values { public const string DEFAULT = ""; } } + public static class ScriptCommandTimeout { public static class Values { public const int DEFAULT = 10000; } } + public static class Parameters { public static class Values { public const string DEFAULT = ""; } } + } + } + } } } #endregion XmlStructure + #region SQLScript class + public class SQLScript : XmlLinqBase + { + public string Key = ""; + public string Name = ""; + public string Description = ""; + public string ScriptText = ""; + public int CommandTimeout = 10000; + public string ArgumentParameters; + + public SQLScript() { } + public SQLScript(SQLScript sqls) { Name = sqls.Name; Description = sqls.Description; ScriptText= sqls.ScriptText; } + public SQLScript(XElement sqlscriptXml, int defaultcommandtimeout, int index) + { + ArgumentParameters = GetValue(nameof(XmlStructure.SQLDataBase.Scripts.Script.Attributes.Parameters), sqlscriptXml, XmlStructure.SQLDataBase.Scripts.Script.Attributes.Parameters.Values.DEFAULT); + + Key = $"S{index}"; + Name = GetValue(nameof(XmlStructure.SQLDataBase.Scripts.Script.Attributes.Name), sqlscriptXml, XmlStructure.SQLDataBase.Scripts.Script.Attributes.Name.Values.DEFAULT); + Description= GetValue(nameof(XmlStructure.SQLDataBase.Scripts.Script.Attributes.Description), sqlscriptXml, XmlStructure.SQLDataBase.Scripts.Script.Attributes.Description.Values.DEFAULT); + Tools.ResolveArguments(ArgumentParameters, this.Name, out this.Name, interactive: false); + Tools.ResolveArguments(ArgumentParameters, this.Description, out this.Description, interactive: false); + ScriptText = GetValue(sqlscriptXml, XmlStructure.SQLDataBase.Scripts.Script.Values.DEFAULT); + CommandTimeout = GetValue(nameof(XmlStructure.SQLDataBase.Scripts.Script.Attributes.ScriptCommandTimeout), sqlscriptXml, defaultcommandtimeout); + } + } + #endregion SQLScript class #region SQLData class public class SQLData : XmlLinqBase { diff --git a/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs b/Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs index 6ea1d84..6ded9e1 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.10.2.0")] -[assembly: AssemblyFileVersion("1.10.2.0")] +[assembly: AssemblyVersion("1.11.0.0")] +[assembly: AssemblyFileVersion("1.11.0.0")] -- libgit2 0.21.2