Commit 1ff12b69628093373f0183c7fbae12dc136abbe4

Authored by Schwirg László
1 parent f450c758

v1.31.3.0

- Scriptek kezelésének módosítása
- DB név nélküli connectionstringek kezelése
Vrh.Log4Pro.MaintenanceConsole/Manager - SQLDataBaseManager.cs
@@ -112,7 +112,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS @@ -112,7 +112,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
112 SQLDataBase sqld = p.Parameters as SQLDataBase; 112 SQLDataBase sqld = p.Parameters as SQLDataBase;
113 try 113 try
114 { 114 {
115 - SQLDataBaseManagerCore.BackupSqlData(sqld,TS); 115 + if (FunctionIsNotAvailable(sqld)) { return o; }
  116 + SQLDataBaseManagerCore.BackupSqlData(sqld,TS);
116 ColorConsole.WriteLine($"SQLDB data scripts created. Name:{sqld.Xml_Description}", ConsoleColor.Green); 117 ColorConsole.WriteLine($"SQLDB data scripts created. Name:{sqld.Xml_Description}", ConsoleColor.Green);
117 } 118 }
118 catch (Exception ex){ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red);} 119 catch (Exception ex){ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red);}
@@ -141,7 +142,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS @@ -141,7 +142,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
141 SQLDataBase sqld = p.Parameters as SQLDataBase; 142 SQLDataBase sqld = p.Parameters as SQLDataBase;
142 try 143 try
143 { 144 {
144 - SQLDataBaseManagerCore.BackupSqlScripts(sqld,TS); 145 + if (FunctionIsNotAvailable(sqld)) { return o; }
  146 + SQLDataBaseManagerCore.BackupSqlScripts(sqld,TS);
145 ColorConsole.WriteLine($"SQLDB code scripts created. Name:{sqld.Xml_Description}", ConsoleColor.Green); 147 ColorConsole.WriteLine($"SQLDB code scripts created. Name:{sqld.Xml_Description}", ConsoleColor.Green);
146 } 148 }
147 catch (Exception ex) { ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red); } 149 catch (Exception ex) { ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red); }
@@ -167,17 +169,24 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS @@ -167,17 +169,24 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
167 var TS = DateTime.Now; 169 var TS = DateTime.Now;
168 foreach (var p in sr.SelectedParameterList) 170 foreach (var p in sr.SelectedParameterList)
169 { 171 {
170 - SQLDataBase ssqldb = p.Parameters as SQLDataBase; 172 + SQLDataBase sqld = p.Parameters as SQLDataBase;
171 try 173 try
172 { 174 {
173 - SQLDataBaseManagerCore.CreateBackup(ssqldb,null,TS);  
174 - ColorConsole.WriteLine($"Database backup created. Name:{ssqldb.DBName}", ConsoleColor.Green); 175 + if (FunctionIsNotAvailable(sqld)) { return o; }
  176 + SQLDataBaseManagerCore.CreateBackup(sqld,null,TS);
  177 + ColorConsole.WriteLine($"Database backup created. Name:{sqld.DBName}", ConsoleColor.Green);
175 } 178 }
176 catch (Exception ex) { ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red); } 179 catch (Exception ex) { ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red); }
177 } 180 }
178 return o; 181 return o;
179 } 182 }
180 - private static object RestoreDataBase(object parameter, object o) 183 + private static bool FunctionIsNotAvailable(SQLDataBase ssqldb)
  184 + {
  185 + const string FUNNOTAVAILTXT = "Function is not available for server connection strings wit no DB name specified!";
  186 + if (string.IsNullOrWhiteSpace(SQLDataBaseManagerCore.GetDBName(ssqldb.SQLCS))) { ColorConsole.WriteLine(FUNNOTAVAILTXT, ConsoleColor.Red); return true; }
  187 + return false;
  188 + }
  189 + private static object RestoreDataBase(object parameter, object o)
181 { 190 {
182 var config = (parameter as Menu.ExecutorParameter).GetConfig<SQLDataBaseManagerXmlProcessor>(); 191 var config = (parameter as Menu.ExecutorParameter).GetConfig<SQLDataBaseManagerXmlProcessor>();
183 var args = (parameter as Menu.ExecutorParameter).Args; 192 var args = (parameter as Menu.ExecutorParameter).Args;
@@ -196,13 +205,14 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS @@ -196,13 +205,14 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
196 else if (sr.Result == Menu.SelectionResult.Ok) { } 205 else if (sr.Result == Menu.SelectionResult.Ok) { }
197 else { } 206 else { }
198 var p = sr.SelectedParameterList.First(); 207 var p = sr.SelectedParameterList.First();
199 - SQLDataBase st = p.Parameters as SQLDataBase; 208 + SQLDataBase sqld = p.Parameters as SQLDataBase;
200 try 209 try
201 { 210 {
202 - var targetdirectorypath = st.Xml_PhysicalFilesDirectoryPath;  
203 - var targetdbname = st.DBName;  
204 - bool restorefromzip = st.Xml_CreateZip;  
205 - var backupfilelist = SQLDataBaseManagerCore.GetBackupFilePathList(st); 211 + if (FunctionIsNotAvailable(sqld)) { return o; }
  212 + var targetdirectorypath = sqld.Xml_PhysicalFilesDirectoryPath;
  213 + var targetdbname = sqld.DBName;
  214 + bool restorefromzip = sqld.Xml_CreateZip;
  215 + var backupfilelist = SQLDataBaseManagerCore.GetBackupFilePathList(sqld);
206 Dictionary<string, string> selectionlist = new Dictionary<string, string>(); 216 Dictionary<string, string> selectionlist = new Dictionary<string, string>();
207 217
208 string selectedbackupfilepath=null; 218 string selectedbackupfilepath=null;
@@ -214,7 +224,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS @@ -214,7 +224,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
214 .Select(x => new KeyValuePair<string, string>($"{x.Name}({x.Length}bytes,created:{x.CreationTime})", x.FullName)) 224 .Select(x => new KeyValuePair<string, string>($"{x.Name}({x.Length}bytes,created:{x.CreationTime})", x.FullName))
215 .ToDictionary(x => x.Key, x => x.Value); 225 .ToDictionary(x => x.Key, x => x.Value);
216 selectionlist.Add("*", "other..."); 226 selectionlist.Add("*", "other...");
217 - var ms = Menu.SelectFromItemList($"Backup files of {st.DBName}", "Select the backup file to restore! First is the newest!", selectionlist, Menu.SelectionMode.Single, getconfirmation: true); 227 + var ms = Menu.SelectFromItemList($"Backup files of {sqld.DBName}", "Select the backup file to restore! First is the newest!", selectionlist, Menu.SelectionMode.Single, getconfirmation: true);
218 if (ms == null) { goto startselection; } 228 if (ms == null) { goto startselection; }
219 else if (ms.SelectedKeyList.First() == "*") { } 229 else if (ms.SelectedKeyList.First() == "*") { }
220 else { selectedbackupfilepath = ms.SelectedParameterList.First().Parameters.ToString(); } 230 else { selectedbackupfilepath = ms.SelectedParameterList.First().Parameters.ToString(); }
@@ -227,8 +237,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS @@ -227,8 +237,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
227 else if (string.IsNullOrWhiteSpace(selectedbackupfilepath)) goto enterpathtobackupfileloop; 237 else if (string.IsNullOrWhiteSpace(selectedbackupfilepath)) goto enterpathtobackupfileloop;
228 } 238 }
229 239
230 - SQLDataBaseManagerCore.RestoreBackup(st, selectedbackupfilepath, targetdirectorypath, restorefromzip, targetdbname);  
231 - ColorConsole.WriteLine($"Database '{st.DBName}' restored to '{targetdbname}' into directory '{targetdirectorypath}'.", ConsoleColor.Green); 240 + SQLDataBaseManagerCore.RestoreBackup(sqld, selectedbackupfilepath, targetdirectorypath, restorefromzip, targetdbname);
  241 + ColorConsole.WriteLine($"Database '{sqld.DBName}' restored to '{targetdbname}' into directory '{targetdirectorypath}'.", ConsoleColor.Green);
232 } 242 }
233 catch (Exception ex) { ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red); } 243 catch (Exception ex) { ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red); }
234 return o; 244 return o;
@@ -495,8 +505,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS @@ -495,8 +505,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
495 505
496 var p = sr.SelectedParameterList.FirstOrDefault(); 506 var p = sr.SelectedParameterList.FirstOrDefault();
497 SQLDataBase sqld = p.Parameters as SQLDataBase; 507 SQLDataBase sqld = p.Parameters as SQLDataBase;
  508 + if (FunctionIsNotAvailable(sqld)) { return o; }
498 509
499 - getparametersloop: 510 + getparametersloop:
500 List<SQLDataBase.DBUser> DbusrToExecuteList = new List<SQLDataBase.DBUser>(); 511 List<SQLDataBase.DBUser> DbusrToExecuteList = new List<SQLDataBase.DBUser>();
501 string selecteddbusrkey = null; 512 string selecteddbusrkey = null;
502 if (sqld.Xml_SQLDbUserList.Count == 0) 513 if (sqld.Xml_SQLDbUserList.Count == 0)
@@ -645,7 +656,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS @@ -645,7 +656,9 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
645 var DateTimeNow = DateTime.Now; 656 var DateTimeNow = DateTime.Now;
646 657
647 movedbanswer = YesOrNo_MoveDbToRemoteServer(config, selectedsqldbindexes); 658 movedbanswer = YesOrNo_MoveDbToRemoteServer(config, selectedsqldbindexes);
648 - if (movedbanswer.Exit) break; 659 + if (FunctionIsNotAvailable(movedbanswer.Dbfrom)) { continue; }
  660 + if (FunctionIsNotAvailable(movedbanswer.Dbto)) { continue; }
  661 + if (movedbanswer.Exit) break;
649 if (movedbanswer.Yes) 662 if (movedbanswer.Yes)
650 { 663 {
651 var movesuccess = SQLDataBaseManagerCore.MoveDbToRemoteServer(movedbanswer.Dbfrom, movedbanswer.Dbto, movedbanswer.Selecteddbname, movedbanswer.Emulation); 664 var movesuccess = SQLDataBaseManagerCore.MoveDbToRemoteServer(movedbanswer.Dbfrom, movedbanswer.Dbto, movedbanswer.Selecteddbname, movedbanswer.Emulation);
@@ -814,8 +827,9 @@ GO @@ -814,8 +827,9 @@ GO
814 var p = sr.SelectedParameterList.FirstOrDefault(); 827 var p = sr.SelectedParameterList.FirstOrDefault();
815 if (p == null) { return o; } 828 if (p == null) { return o; }
816 SQLDataBase sqld = p.Parameters as SQLDataBase; 829 SQLDataBase sqld = p.Parameters as SQLDataBase;
  830 + if (FunctionIsNotAvailable(sqld)) { return o; }
817 831
818 - getparametersloop:; 832 + getparametersloop:;
819 833
820 List<SQLDataBase.LastUpdatedTrigger> TriggerToExecuteList = new List<SQLDataBase.LastUpdatedTrigger>(); 834 List<SQLDataBase.LastUpdatedTrigger> TriggerToExecuteList = new List<SQLDataBase.LastUpdatedTrigger>();
821 string selectedtrgkey =null; 835 string selectedtrgkey =null;
@@ -1015,7 +1029,7 @@ GO @@ -1015,7 +1029,7 @@ GO
1015 bool multirunmode = !string.IsNullOrWhiteSpace(ss.MultirunParameters); 1029 bool multirunmode = !string.IsNullOrWhiteSpace(ss.MultirunParameters);
1016 int commandtimeout = ss.CommandTimeout; 1030 int commandtimeout = ss.CommandTimeout;
1017 ReturnInfoJSON result = null; 1031 ReturnInfoJSON result = null;
1018 - using (var sqlc = ServerConnectionPool.GetSqlConnection(sqld.SQLCS, open: true)) 1032 + using (var sqlc = ServerConnectionPool.GetSqlConnection(ss.SQLCS, open: true))
1019 { 1033 {
1020 if (multirunmode) { result = SQLDataBaseManagerCore.ExecuteMultirunSQLScript(sqlc, ss, ExitAtThisPoint); } 1034 if (multirunmode) { result = SQLDataBaseManagerCore.ExecuteMultirunSQLScript(sqlc, ss, ExitAtThisPoint); }
1021 else 1035 else
@@ -1085,7 +1099,8 @@ GO @@ -1085,7 +1099,8 @@ GO
1085 SQLDataBase sqld = p.Parameters as SQLDataBase; 1099 SQLDataBase sqld = p.Parameters as SQLDataBase;
1086 try 1100 try
1087 { 1101 {
1088 - ColorConsole.WriteLine(prefix: $"Enter the userid/password (for the user in favour you want to drop the DB). Format:", bracket: "()", text: "[USERID[,PASSWORD]]:", f: ConsoleColor.Yellow); 1102 + if (FunctionIsNotAvailable(sqld)) { return o; }
  1103 + ColorConsole.WriteLine(prefix: $"Enter the userid/password (for the user in favour you want to drop the DB). Format:", bracket: "()", text: "[USERID[,PASSWORD]]:", f: ConsoleColor.Yellow);
1089 ColorConsole.WriteLine(prefix: " ", text: "[USERID,PASSWORD empty]", bracket: "[]", suffix: $":use windows authentication with current user", f: ConsoleColor.Yellow); 1104 ColorConsole.WriteLine(prefix: " ", text: "[USERID,PASSWORD empty]", bracket: "[]", suffix: $":use windows authentication with current user", f: ConsoleColor.Yellow);
1090 ColorConsole.WriteLine(prefix: " ", text: "USERID", bracket: "[]", suffix: $":use windows authentication with this user", f: ConsoleColor.Yellow); 1105 ColorConsole.WriteLine(prefix: " ", text: "USERID", bracket: "[]", suffix: $":use windows authentication with this user", f: ConsoleColor.Yellow);
1091 ColorConsole.WriteLine(prefix: " ", text: "USERID,PASSWORD", bracket: "[]", suffix: $":use sql server authentication with this user and password.", f: ConsoleColor.Yellow); 1106 ColorConsole.WriteLine(prefix: " ", text: "USERID,PASSWORD", bracket: "[]", suffix: $":use sql server authentication with this user and password.", f: ConsoleColor.Yellow);
@@ -1170,7 +1185,8 @@ GO @@ -1170,7 +1185,8 @@ GO
1170 SQLDataBase sqld = p.Parameters as SQLDataBase; 1185 SQLDataBase sqld = p.Parameters as SQLDataBase;
1171 try 1186 try
1172 { 1187 {
1173 - ColorConsole.WriteLine(prefix: $"Enter the shrink options. Format:", bracket:"()", text:"OPTION,FreeSpacePercent:", f:ConsoleColor.Yellow); 1188 + if (FunctionIsNotAvailable(sqld)) { return o; }
  1189 + ColorConsole.WriteLine(prefix: $"Enter the shrink options. Format:", bracket:"()", text:"OPTION,FreeSpacePercent:", f:ConsoleColor.Yellow);
1174 ColorConsole.WriteLine(prefix:" ", text:"Default", bracket: "[]", suffix: $": (default) compacts the data and removes free space from the DB. Use togethere with FreeSpacePercent.", f:ConsoleColor.Yellow); 1190 ColorConsole.WriteLine(prefix:" ", text:"Default", bracket: "[]", suffix: $": (default) compacts the data and removes free space from the DB. Use togethere with FreeSpacePercent.", f:ConsoleColor.Yellow);
1175 ColorConsole.WriteLine(prefix: " ", text: "NoTruncate",bracket:"[]", suffix: $": compacts the data, but does not remove free space from the DB. FreeSpacePercent is not applicable.", f: ConsoleColor.Yellow); 1191 ColorConsole.WriteLine(prefix: " ", text: "NoTruncate",bracket:"[]", suffix: $": compacts the data, but does not remove free space from the DB. FreeSpacePercent is not applicable.", f: ConsoleColor.Yellow);
1176 ColorConsole.WriteLine(prefix: " ", text: "TruncateOnly", bracket: "[]", suffix: $": does not compact the data, but removes free space from the DB. Use togethere with FreeSpacePercent.", f: ConsoleColor.Yellow); 1192 ColorConsole.WriteLine(prefix: " ", text: "TruncateOnly", bracket: "[]", suffix: $": does not compact the data, but removes free space from the DB. Use togethere with FreeSpacePercent.", f: ConsoleColor.Yellow);
@@ -1213,7 +1229,8 @@ GO @@ -1213,7 +1229,8 @@ GO
1213 SQLDataBase sqld = p.Parameters as SQLDataBase; 1229 SQLDataBase sqld = p.Parameters as SQLDataBase;
1214 try 1230 try
1215 { 1231 {
1216 - var restoredbname = ColorConsole.ReadLine($"Enter the name of the DB to copy '{sqld.DBName}' to. Empty={sqld.DBName}. EX=exit.", ConsoleColor.Yellow, suffix: " --> "); 1232 + if (FunctionIsNotAvailable(sqld)) { return o; }
  1233 + var restoredbname = ColorConsole.ReadLine($"Enter the name of the DB to copy '{sqld.DBName}' to. Empty={sqld.DBName}. EX=exit.", ConsoleColor.Yellow, suffix: " --> ");
1217 if (restoredbname.ToUpper() == "EX") { continue; } 1234 if (restoredbname.ToUpper() == "EX") { continue; }
1218 else if (string.IsNullOrWhiteSpace(restoredbname)) { restoredbname = sqld.DBName; } 1235 else if (string.IsNullOrWhiteSpace(restoredbname)) { restoredbname = sqld.DBName; }
1219 ColorConsole.WriteLine("Enter the path for the DB physical files.", ConsoleColor.Yellow); 1236 ColorConsole.WriteLine("Enter the path for the DB physical files.", ConsoleColor.Yellow);
@@ -1266,7 +1283,7 @@ GO @@ -1266,7 +1283,7 @@ GO
1266 ColorConsole.Write($"{st.Xml_Description}", ConsoleColor.Black, ConsoleColor.White); 1283 ColorConsole.Write($"{st.Xml_Description}", ConsoleColor.Black, ConsoleColor.White);
1267 var statuscolor = st.Status == SQLDataBase.SQLDBStatus.NoAccess ? ConsoleColor.Red:ConsoleColor.Green; 1284 var statuscolor = st.Status == SQLDataBase.SQLDBStatus.NoAccess ? ConsoleColor.Red:ConsoleColor.Green;
1268 ColorConsole.Write(st.Status.ToString(), statuscolor, bracket: "[]", prefix: " ", suffix: ". "); 1285 ColorConsole.Write(st.Status.ToString(), statuscolor, bracket: "[]", prefix: " ", suffix: ". ");
1269 - ColorConsole.Write(st.DBName, statuscolor, bracket: "[]", prefix: "Database ", suffix: ". "); 1286 + if (!string.IsNullOrWhiteSpace(st.DBName)) { ColorConsole.Write(st.DBName, statuscolor, bracket: "[]", prefix: "Database ", suffix: ". "); }
1270 ColorConsole.Write(st.DataSource, statuscolor, bracket: "[]", prefix: "from server ", suffix: ". "); 1287 ColorConsole.Write(st.DataSource, statuscolor, bracket: "[]", prefix: "from server ", suffix: ". ");
1271 if (st.Status != SQLDataBase.SQLDBStatus.NoAccess) 1288 if (st.Status != SQLDataBase.SQLDBStatus.NoAccess)
1272 { 1289 {
@@ -1277,7 +1294,8 @@ GO @@ -1277,7 +1294,8 @@ GO
1277 } 1294 }
1278 else if (lineix == 1) 1295 else if (lineix == 1)
1279 { 1296 {
1280 - ColorConsole.Write($"{st.Xml_BackupFileNameMask}", ConsoleColor.Yellow, prefix: "Backup to:", suffix: ".xxx"); 1297 + if (string.IsNullOrWhiteSpace(st.DBName)) return Menu.MenuItemDisplayerReturnValue.SAMELINE;
  1298 + ColorConsole.Write($"{st.Xml_BackupFileNameMask}", ConsoleColor.Yellow, prefix: "Backup to:", suffix: ".xxx");
1281 ColorConsole.WriteLine(); 1299 ColorConsole.WriteLine();
1282 return Menu.MenuItemDisplayerReturnValue.NEXTLINE; 1300 return Menu.MenuItemDisplayerReturnValue.NEXTLINE;
1283 } 1301 }
@@ -1289,14 +1307,16 @@ GO @@ -1289,14 +1307,16 @@ GO
1289 } 1307 }
1290 else if (lineix == 3) 1308 else if (lineix == 3)
1291 { 1309 {
1292 - var PhysicalFilesDirectoryPathcolor = st.PhysicalFilesDirectoryPath.StartsWith("ERR") ? ConsoleColor.Red : ConsoleColor.Yellow; 1310 + if (string.IsNullOrWhiteSpace(st.DBName)) return Menu.MenuItemDisplayerReturnValue.SAMELINE;
  1311 + var PhysicalFilesDirectoryPathcolor = st.PhysicalFilesDirectoryPath.StartsWith("ERR") ? ConsoleColor.Red : ConsoleColor.Yellow;
1293 ColorConsole.Write($"{st.PhysicalFilesDirectoryPath}", PhysicalFilesDirectoryPathcolor, prefix: "DB files physical location:", suffix: " "); 1312 ColorConsole.Write($"{st.PhysicalFilesDirectoryPath}", PhysicalFilesDirectoryPathcolor, prefix: "DB files physical location:", suffix: " ");
1294 ColorConsole.WriteLine(" "); 1313 ColorConsole.WriteLine(" ");
1295 return Menu.MenuItemDisplayerReturnValue.NEXTLINE; 1314 return Menu.MenuItemDisplayerReturnValue.NEXTLINE;
1296 } 1315 }
1297 else if (lineix == 4) 1316 else if (lineix == 4)
1298 { 1317 {
1299 - var SizeStringcolor = st.SizeString.StartsWith("ERR") ? ConsoleColor.Red : ConsoleColor.Yellow; 1318 + if (string.IsNullOrWhiteSpace(st.DBName)) return Menu.MenuItemDisplayerReturnValue.SAMELINE;
  1319 + var SizeStringcolor = st.SizeString.StartsWith("ERR") ? ConsoleColor.Red : ConsoleColor.Yellow;
1300 ColorConsole.Write(st.SizeString, SizeStringcolor, prefix: "DB size:", suffix: " "); 1320 ColorConsole.Write(st.SizeString, SizeStringcolor, prefix: "DB size:", suffix: " ");
1301 ColorConsole.WriteLine(" "); 1321 ColorConsole.WriteLine(" ");
1302 return Menu.MenuItemDisplayerReturnValue.NEXTLINE; 1322 return Menu.MenuItemDisplayerReturnValue.NEXTLINE;
@@ -1307,7 +1327,8 @@ GO @@ -1307,7 +1327,8 @@ GO
1307 if (st.Xml_SQLScriptList.Count-1 < lineix-5) { return Menu.MenuItemDisplayerReturnValue.EXIT; } 1327 if (st.Xml_SQLScriptList.Count-1 < lineix-5) { return Menu.MenuItemDisplayerReturnValue.EXIT; }
1308 var s = st.Xml_SQLScriptList.ToArray()[lineix-5]; 1328 var s = st.Xml_SQLScriptList.ToArray()[lineix-5];
1309 ColorConsole.Write(s.Key, ConsoleColor.Yellow, bracket: "[]", suffix: " ", prefix: " Script: "); 1329 ColorConsole.Write(s.Key, ConsoleColor.Yellow, bracket: "[]", suffix: " ", prefix: " Script: ");
1310 - ColorConsole.WriteLine($"{s.Description} ({s.Name})", ConsoleColor.Yellow); 1330 + ColorConsole.Write(s.Name, ConsoleColor.Yellow, bracket: "[]", suffix: " ");
  1331 + ColorConsole.WriteLine(s.Description, ConsoleColor.White);
1311 return Menu.MenuItemDisplayerReturnValue.NEXTLINE; 1332 return Menu.MenuItemDisplayerReturnValue.NEXTLINE;
1312 } 1333 }
1313 return Menu.MenuItemDisplayerReturnValue.EXIT; 1334 return Menu.MenuItemDisplayerReturnValue.EXIT;
@@ -1981,18 +2002,18 @@ GO @@ -1981,18 +2002,18 @@ GO
1981 /// </param> 2002 /// </param>
1982 /// <returns></returns> 2003 /// <returns></returns>
1983 2004
1984 - public static ReturnInfoJSON ExecuteMultirunSQLScript(SqlConnection sqlc, SQLDataBase.SQLScript sqlscript, Func<ReturnInfoJSON,TimeSpan?, bool> ExitAtThisPoint=null) 2005 + public static ReturnInfoJSON ExecuteMultirunSQLScript(SqlConnection sqlc,SQLDataBase.SQLScript sqlscript, Func<ReturnInfoJSON,TimeSpan?, bool> ExitAtThisPoint=null)
1985 { 2006 {
1986 - ReturnInfoJSON ret1=null;  
1987 - string sqltxt = null;  
1988 - int? getdbnumofrowsresult=null;  
1989 - DateTime? getdbmindateresult=null; 2007 + ReturnInfoJSON ret1 = null;
  2008 + string sqltxt = null;
  2009 + int? getdbnumofrowsresult = null;
  2010 + DateTime? getdbmindateresult = null;
1990 2011
1991 var multirunresult = new List<KeyValuePair<string, string>>(); 2012 var multirunresult = new List<KeyValuePair<string, string>>();
1992 2013
1993 var scriptparameterkvplist = (new Tools.KvpString(sqlscript.ScriptParameters)).ResolveInteractive(); 2014 var scriptparameterkvplist = (new Tools.KvpString(sqlscript.ScriptParameters)).ResolveInteractive();
1994 - string sqltxtalmostresolved = scriptparameterkvplist.Substitute(sqlscript.ScriptText); //parameters of the run are still unresolved  
1995 - if (sqltxtalmostresolved == null) {return Finalize(1, Add(multirunresult, ERRMSG_NOTHINGTOEXECUTE));} //won't really get, but we never know... 2015 + string sqltxtalmostresolved = scriptparameterkvplist.Substitute(sqlscript.ScriptText); //parameters of the run are still unresolved
  2016 + if (sqltxtalmostresolved == null) { return Finalize(1, Add(multirunresult, ERRMSG_NOTHINGTOEXECUTE)); } //won't really get, but we never know...
1996 2017
1997 //get number of total records in the database 2018 //get number of total records in the database
1998 getdbnumofrowsresult = GetDBNumofRows(sqltxtalmostresolved, multirunresult, sqlscript.CommandTimeout, sqlc); 2019 getdbnumofrowsresult = GetDBNumofRows(sqltxtalmostresolved, multirunresult, sqlscript.CommandTimeout, sqlc);
@@ -2003,27 +2024,27 @@ GO @@ -2003,27 +2024,27 @@ GO
2003 getdbmindateresult = GetDBMindate(sqltxtalmostresolved, multirunresult, sqlscript.CommandTimeout, sqlc); 2024 getdbmindateresult = GetDBMindate(sqltxtalmostresolved, multirunresult, sqlscript.CommandTimeout, sqlc);
2004 if (getdbmindateresult == null) return Finalize(1, multirunresult); 2025 if (getdbmindateresult == null) return Finalize(1, multirunresult);
2005 DateTime mindateTS_before = getdbmindateresult.Value; 2026 DateTime mindateTS_before = getdbmindateresult.Value;
2006 - var _multirunresult = multirunresult.Select(kvp => new KeyValuePair<string, string>(kvp.Key, kvp.Value)).ToList(); 2027 + var _multirunresult = multirunresult.Select(kvp => new KeyValuePair<string, string>(kvp.Key, kvp.Value)).ToList();
2007 Add(_multirunresult, $"DBRECORDS", $"{numoftotaldbrecords_before}"); 2028 Add(_multirunresult, $"DBRECORDS", $"{numoftotaldbrecords_before}");
2008 Add(_multirunresult, $"MINDATE", $"{mindateTS_before}"); 2029 Add(_multirunresult, $"MINDATE", $"{mindateTS_before}");
2009 2030
2010 - var exithere = (ExitAtThisPoint?.Invoke(Finalize(0, _multirunresult),null)) ?? false; 2031 + var exithere = (ExitAtThisPoint?.Invoke(Finalize(0, _multirunresult), null)) ?? false;
2011 if (exithere) { Add(_multirunresult, $"Exit requested by user"); return Finalize(0, _multirunresult); } 2032 if (exithere) { Add(_multirunresult, $"Exit requested by user"); return Finalize(0, _multirunresult); }
2012 2033
2013 var multirunparameterskvplist = (new Tools.KvpString(sqlscript.MultirunParameters)).ResolveInteractive(); 2034 var multirunparameterskvplist = (new Tools.KvpString(sqlscript.MultirunParameters)).ResolveInteractive();
2014 - if(multirunparameterskvplist == null) { return Finalize(0, Add(multirunresult, ERRMSG_NOMULTIRUNPARAMETERS)); } //user exit with selecting EX  
2015 - var smrp = SetMultirunParameters(multirunparameterskvplist, multirunresult);  
2016 - if (smrp == null) { return Finalize(1, multirunresult);}  
2017 - (bool par_testmode, DateTime par_limitdate, TimeSpan par_lengthofonerun, TimeSpan par_delaybetweenruns) = smrp.Value; 2035 + if (multirunparameterskvplist == null) { return Finalize(0, Add(multirunresult, ERRMSG_NOMULTIRUNPARAMETERS)); } //user exit with selecting EX
  2036 + var smrp = SetMultirunParameters(multirunparameterskvplist, multirunresult);
  2037 + if (smrp == null) { return Finalize(1, multirunresult); }
  2038 + (bool par_testmode, DateTime par_limitdate, TimeSpan par_lengthofonerun, TimeSpan par_delaybetweenruns) = smrp.Value;
2018 2039
2019 try 2040 try
2020 { 2041 {
2021 - DateTime starttime = DateTime.Now; 2042 + DateTime starttime = DateTime.Now;
2022 var limitdatefornextrun = mindateTS_before; 2043 var limitdatefornextrun = mindateTS_before;
2023 int exceptioncounter = 0; 2044 int exceptioncounter = 0;
2024 - const int MAXEXCEPTIONS = 3; //after this number of subsequent exceptions we exit  
2025 - int deleteruncounter = 0;  
2026 - int runresult; 2045 + const int MAXEXCEPTIONS = 3; //after this number of subsequent exceptions we exit
  2046 + int deleteruncounter = 0;
  2047 + int runresult;
2027 while (true) 2048 while (true)
2028 { 2049 {
2029 if (limitdatefornextrun >= par_limitdate) break; 2050 if (limitdatefornextrun >= par_limitdate) break;
@@ -2031,36 +2052,36 @@ GO @@ -2031,36 +2052,36 @@ GO
2031 var loople = new List<KeyValuePair<string, string>>(); 2052 var loople = new List<KeyValuePair<string, string>>();
2032 if (limitdatefornextrun > par_limitdate) limitdatefornextrun = par_limitdate; 2053 if (limitdatefornextrun > par_limitdate) limitdatefornextrun = par_limitdate;
2033 Add(loople, $"RUN#{deleteruncounter}"); 2054 Add(loople, $"RUN#{deleteruncounter}");
2034 - try  
2035 - {  
2036 - sqltxt = Tools.KvpString.Substitute($"{RUNNINGMODE}={RUNNINGMODE_ONERUN};{RUNNINGMODE_ONERUN_PARAMETER_DELETEBEFOREDATE}={limitdatefornextrun:s};", sqltxtalmostresolved);  
2037 - if (sqltxt == null) { return Finalize(1, Add(multirunresult, ERRMSG_NOTHINGTOEXECUTE)); } //won't really get, but we never know...  
2038 - ret1 = ExecuteSQLScript(sqlc, sqltxt, sqlscript.CommandTimeout, null);  
2039 - Add(loople, $"LIMITDATE", limitdatefornextrun.ToString());  
2040 - Add(loople, $"RETCODE", ret1.ReturnValue.ToString());  
2041 - Add(loople, $"RETMSG", ret1.ReturnMessage);  
2042 -  
2043 - deleteruncounter++;  
2044 - exceptioncounter = 0;  
2045 - runresult = 0; 2055 + try
  2056 + {
  2057 + sqltxt = Tools.KvpString.Substitute($"{RUNNINGMODE}={RUNNINGMODE_ONERUN};{RUNNINGMODE_ONERUN_PARAMETER_DELETEBEFOREDATE}={limitdatefornextrun:s};", sqltxtalmostresolved);
  2058 + if (sqltxt == null) { return Finalize(1, Add(multirunresult, ERRMSG_NOTHINGTOEXECUTE)); } //won't really get, but we never know...
  2059 + ret1 = ExecuteSQLScript(sqlc, sqltxt, sqlscript.CommandTimeout, null);
  2060 + Add(loople, $"LIMITDATE", limitdatefornextrun.ToString());
  2061 + Add(loople, $"RETCODE", ret1.ReturnValue.ToString());
  2062 + Add(loople, $"RETMSG", ret1.ReturnMessage);
  2063 +
  2064 + deleteruncounter++;
  2065 + exceptioncounter = 0;
  2066 + runresult = 0;
2046 } 2067 }
2047 - catch (Exception ex)  
2048 - {  
2049 - exceptioncounter++;  
2050 - string errmsg = ""; while (ex != null) { errmsg += ex.Message; ex = ex.InnerException; }  
2051 - Add(loople, $"EXCEPTION RESULT DeleteRun", errmsg); 2068 + catch (Exception ex)
  2069 + {
  2070 + exceptioncounter++;
  2071 + string errmsg = ""; while (ex != null) { errmsg += ex.Message; ex = ex.InnerException; }
  2072 + Add(loople, $"EXCEPTION RESULT DeleteRun", errmsg);
2052 runresult = 1; 2073 runresult = 1;
2053 if (exceptioncounter > MAXEXCEPTIONS) { return Finalize(1, multirunresult); } 2074 if (exceptioncounter > MAXEXCEPTIONS) { return Finalize(1, multirunresult); }
2054 } 2075 }
2055 - var exitfromloop = (ExitAtThisPoint?.Invoke(Finalize(runresult, loople),new TimeSpan(0,0,5))) ?? false; 2076 + var exitfromloop = (ExitAtThisPoint?.Invoke(Finalize(runresult, loople), new TimeSpan(0, 0, 5))) ?? false;
2056 if (exitfromloop) { Add(multirunresult, $"Exit requested by user"); break; } 2077 if (exitfromloop) { Add(multirunresult, $"Exit requested by user"); break; }
2057 Thread.Sleep((int)(par_delaybetweenruns.TotalMilliseconds)); 2078 Thread.Sleep((int)(par_delaybetweenruns.TotalMilliseconds));
2058 } 2079 }
2059 2080
2060 //get minimum date in the database 2081 //get minimum date in the database
2061 - getdbmindateresult = GetDBMindate(sqltxtalmostresolved,multirunresult, sqlscript.CommandTimeout,sqlc);  
2062 - if (getdbmindateresult==null) return Finalize(1, multirunresult);  
2063 - DateTime mindateTS_after = getdbmindateresult.Value; 2082 + getdbmindateresult = GetDBMindate(sqltxtalmostresolved, multirunresult, sqlscript.CommandTimeout, sqlc);
  2083 + if (getdbmindateresult == null) return Finalize(1, multirunresult);
  2084 + DateTime mindateTS_after = getdbmindateresult.Value;
2064 2085
2065 //get number of total records in the database 2086 //get number of total records in the database
2066 getdbnumofrowsresult = GetDBNumofRows(sqltxtalmostresolved, multirunresult, sqlscript.CommandTimeout, sqlc); 2087 getdbnumofrowsresult = GetDBNumofRows(sqltxtalmostresolved, multirunresult, sqlscript.CommandTimeout, sqlc);
@@ -2075,7 +2096,7 @@ GO @@ -2075,7 +2096,7 @@ GO
2075 } 2096 }
2076 catch (Exception ex) { return Finalize(1, Add(multirunresult, ex)); } 2097 catch (Exception ex) { return Finalize(1, Add(multirunresult, ex)); }
2077 } 2098 }
2078 - private static (bool par_testmode, DateTime par_limitdate, TimeSpan par_lengthofonerun, TimeSpan par_delaybetweenruns)? SetMultirunParameters(Tools.KvpString argkvplist,List<KeyValuePair<string, string>> multirunresult) 2099 + private static (bool par_testmode, DateTime par_limitdate, TimeSpan par_lengthofonerun, TimeSpan par_delaybetweenruns)? SetMultirunParameters(Tools.KvpString argkvplist,List<KeyValuePair<string, string>> multirunresult)
2079 { 2100 {
2080 bool par_testmode; 2101 bool par_testmode;
2081 int par_limitdays; 2102 int par_limitdays;
@@ -2628,11 +2649,22 @@ GO @@ -2628,11 +2649,22 @@ GO
2628 { 2649 {
2629 try 2650 try
2630 { 2651 {
2631 - GetPhysicalFilesLocationAndSize(this.SQLCS, out this.SizeString, out this.PhysicalFilesDirectoryPath);  
2632 - this.Status = this.PhysicalFilesDirectoryPath.StartsWith("ERR") ? SQLDBStatus.NoAccess : SQLDBStatus.OK;  
2633 - this.DBName = SQLDataBaseManagerCore.GetDBName(this.SQLCS);  
2634 - this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS);  
2635 - } 2652 + string dbname = SQLDataBaseManagerCore.GetDBName(this.SQLCS);
  2653 + if (string.IsNullOrWhiteSpace(dbname))
  2654 + {
  2655 + var sqlc = ServerConnectionPool.GetSqlConnection(this.SQLCS, open: true);
  2656 + this.Status = SQLDBStatus.OK;
  2657 + this.DBName = "";
  2658 + this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS);
  2659 + }
  2660 + else
  2661 + {
  2662 + GetPhysicalFilesLocationAndSize(this.SQLCS, out this.SizeString, out this.PhysicalFilesDirectoryPath);
  2663 + this.Status = this.PhysicalFilesDirectoryPath.StartsWith("ERR") ? SQLDBStatus.NoAccess : SQLDBStatus.OK;
  2664 + this.DBName = SQLDataBaseManagerCore.GetDBName(this.SQLCS);
  2665 + this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS);
  2666 + }
  2667 + }
2636 catch 2668 catch
2637 { 2669 {
2638 this.Status = SQLDBStatus.NoAccess; 2670 this.Status = SQLDBStatus.NoAccess;
@@ -2725,7 +2757,8 @@ GO @@ -2725,7 +2757,8 @@ GO
2725 Xml_BackupTimeout = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.BackupTimeout), sqldatabasexml, common.Xml_BackupTimeout); 2757 Xml_BackupTimeout = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.BackupTimeout), sqldatabasexml, common.Xml_BackupTimeout);
2726 2758
2727 Xml_SQLDataList = new List<SQLData>(); 2759 Xml_SQLDataList = new List<SQLData>();
2728 - var sqldataXmlList = GetAllXElements(sqldatabasexml, nameof(XmlStructure.SQLDataBase.SQLData)); 2760 + IEnumerable<XElement> sqldataXmlList=null;
  2761 + try { sqldataXmlList = GetAllXElements(sqldatabasexml, nameof(XmlStructure.SQLDataBase.SQLData)); } catch { }
2729 if (sqldataXmlList!=null) { foreach (var sqldataXml in sqldataXmlList) { Xml_SQLDataList.Add(new SQLData(sqldataXml)); } } 2762 if (sqldataXmlList!=null) { foreach (var sqldataXml in sqldataXmlList) { Xml_SQLDataList.Add(new SQLData(sqldataXml)); } }
2730 2763
2731 Xml_SQLLastUpdatedTriggerList = new List<LastUpdatedTrigger>(); 2764 Xml_SQLLastUpdatedTriggerList = new List<LastUpdatedTrigger>();
@@ -2746,7 +2779,7 @@ GO @@ -2746,7 +2779,7 @@ GO
2746 Xml_SQLScriptList = new List<SQLScript>(); 2779 Xml_SQLScriptList = new List<SQLScript>();
2747 var sqlscriptsXml = GetXElement(sqldatabasexml, nameof(XmlStructure.SQLDataBase.Scripts)); 2780 var sqlscriptsXml = GetXElement(sqldatabasexml, nameof(XmlStructure.SQLDataBase.Scripts));
2748 var sqlscriptXmlList = GetAllXElements(sqlscriptsXml, nameof(XmlStructure.SQLDataBase.Scripts.Script)); 2781 var sqlscriptXmlList = GetAllXElements(sqlscriptsXml, nameof(XmlStructure.SQLDataBase.Scripts.Script));
2749 - if (sqlscriptXmlList != null) { int scriptindex = 1; foreach (var sqlscriptXml in sqlscriptXmlList) { Xml_SQLScriptList.Add(new SQLScript(sqlscriptXml, Xml_ScriptCommandTimeout,scriptindex++)); } } 2782 + if (sqlscriptXmlList != null) { int scriptindex = 1; foreach (var sqlscriptXml in sqlscriptXmlList) { Xml_SQLScriptList.Add(new SQLScript(sqlscriptXml, Xml_SQLConnectionString,Xml_ScriptCommandTimeout, scriptindex++)); } }
2750 } 2783 }
2751 #endregion xml constructor 2784 #endregion xml constructor
2752 #region cloner constructor 2785 #region cloner constructor
@@ -2857,8 +2890,9 @@ GO @@ -2857,8 +2890,9 @@ GO
2857 public static class ScriptCommandTimeout { public static class Values { public const int DEFAULT = 10000; } } 2890 public static class ScriptCommandTimeout { public static class Values { public const int DEFAULT = 10000; } }
2858 public static class Parameters { public static class Values { public const string DEFAULT = ""; } } 2891 public static class Parameters { public static class Values { public const string DEFAULT = ""; } }
2859 public static class Multirun { public static class Values { public const string DEFAULT = ""; } } 2892 public static class Multirun { public static class Values { public const string DEFAULT = ""; } }
2860 - }  
2861 - } 2893 + public static class SQLConnectionString { public static class Values { public const string DEFAULT = null; } }
  2894 + }
  2895 + }
2862 } 2896 }
2863 } 2897 }
2864 } 2898 }
@@ -2874,10 +2908,15 @@ GO @@ -2874,10 +2908,15 @@ GO
2874 public int CommandTimeout = 10000; 2908 public int CommandTimeout = 10000;
2875 public string ScriptParameters=null; 2909 public string ScriptParameters=null;
2876 public string MultirunParameters=null; 2910 public string MultirunParameters=null;
  2911 + public string SQLConnectionString=null;
  2912 + public string SQLCS
  2913 + {
  2914 + get { return XmlProcessing.ConnectionStringStore.GetSQL(this.SQLConnectionString); }
  2915 + }
2877 2916
2878 - public SQLScript() { } 2917 + public SQLScript() { }
2879 public SQLScript(SQLScript sqls) { Name = sqls.Name; Description = sqls.Description; ScriptText= sqls.ScriptText; } 2918 public SQLScript(SQLScript sqls) { Name = sqls.Name; Description = sqls.Description; ScriptText= sqls.ScriptText; }
2880 - public SQLScript(XElement sqlscriptXml, int defaultcommandtimeout, int index) 2919 + public SQLScript(XElement sqlscriptXml,string sqlconnectionstring, int defaultcommandtimeout, int index)
2881 { 2920 {
2882 ScriptParameters = GetValue(nameof(XmlStructure.SQLDataBase.Scripts.Script.Attributes.Parameters), sqlscriptXml, XmlStructure.SQLDataBase.Scripts.Script.Attributes.Parameters.Values.DEFAULT); 2921 ScriptParameters = GetValue(nameof(XmlStructure.SQLDataBase.Scripts.Script.Attributes.Parameters), sqlscriptXml, XmlStructure.SQLDataBase.Scripts.Script.Attributes.Parameters.Values.DEFAULT);
2883 MultirunParameters= GetValue(nameof(XmlStructure.SQLDataBase.Scripts.Script.Attributes.Multirun), sqlscriptXml, XmlStructure.SQLDataBase.Scripts.Script.Attributes.Multirun.Values.DEFAULT); 2922 MultirunParameters= GetValue(nameof(XmlStructure.SQLDataBase.Scripts.Script.Attributes.Multirun), sqlscriptXml, XmlStructure.SQLDataBase.Scripts.Script.Attributes.Multirun.Values.DEFAULT);
@@ -2886,6 +2925,8 @@ GO @@ -2886,6 +2925,8 @@ GO
2886 Name = GetValue(nameof(XmlStructure.SQLDataBase.Scripts.Script.Attributes.Name), sqlscriptXml, XmlStructure.SQLDataBase.Scripts.Script.Attributes.Name.Values.DEFAULT); 2925 Name = GetValue(nameof(XmlStructure.SQLDataBase.Scripts.Script.Attributes.Name), sqlscriptXml, XmlStructure.SQLDataBase.Scripts.Script.Attributes.Name.Values.DEFAULT);
2887 FilePath = GetValue(nameof(XmlStructure.SQLDataBase.Scripts.Script.Attributes.File), sqlscriptXml, XmlStructure.SQLDataBase.Scripts.Script.Attributes.File.Values.DEFAULT); 2926 FilePath = GetValue(nameof(XmlStructure.SQLDataBase.Scripts.Script.Attributes.File), sqlscriptXml, XmlStructure.SQLDataBase.Scripts.Script.Attributes.File.Values.DEFAULT);
2888 Description= GetValue(nameof(XmlStructure.SQLDataBase.Scripts.Script.Attributes.Description), sqlscriptXml, XmlStructure.SQLDataBase.Scripts.Script.Attributes.Description.Values.DEFAULT); 2927 Description= GetValue(nameof(XmlStructure.SQLDataBase.Scripts.Script.Attributes.Description), sqlscriptXml, XmlStructure.SQLDataBase.Scripts.Script.Attributes.Description.Values.DEFAULT);
  2928 + SQLConnectionString = GetValue(nameof(XmlStructure.SQLDataBase.Scripts.Script.Attributes.SQLConnectionString), sqlscriptXml, XmlStructure.SQLDataBase.Scripts.Script.Attributes.SQLConnectionString.Values.DEFAULT);
  2929 + if (SQLConnectionString == null) SQLConnectionString = sqlconnectionstring;
2889 2930
2890 Tools.KvpString.Resolve(ScriptParameters, this.Name, out this.Name, disableinteractive: true); 2931 Tools.KvpString.Resolve(ScriptParameters, this.Name, out this.Name, disableinteractive: true);
2891 Tools.KvpString.Resolve(ScriptParameters, this.Description, out this.Description, disableinteractive: true); 2932 Tools.KvpString.Resolve(ScriptParameters, this.Description, out this.Description, disableinteractive: true);
@@ -3033,16 +3074,16 @@ GO @@ -3033,16 +3074,16 @@ GO
3033 } 3074 }
3034 public static void Open(SqlConnection sqlc) 3075 public static void Open(SqlConnection sqlc)
3035 { 3076 {
3036 - if (IsMasterInacessible(sqlc) || IsInacessible(sqlc))  
3037 - {  
3038 - throw new Exception($"DB {sqlc.Database} on server {sqlc.DataSource} is inaccessible!");  
3039 - }  
3040 - try { sqlc.Open(); }  
3041 - catch (Exception ex) 3077 + if (IsMasterInacessible(sqlc) || IsInacessible(sqlc)) { throw new Exception($"SQL server {sqlc.DataSource} is inaccessible!"); }
  3078 + if (!string.IsNullOrWhiteSpace(sqlc.Database))
3042 { 3079 {
3043 - MarkMasterInacessible(sqlc);  
3044 - MarkInacessible(sqlc);  
3045 - throw ex; 3080 + try { sqlc.Open(); }
  3081 + catch (Exception ex)
  3082 + {
  3083 + MarkMasterInacessible(sqlc);
  3084 + MarkInacessible(sqlc);
  3085 + throw ex;
  3086 + }
3046 } 3087 }
3047 } 3088 }
3048 private static bool IsMasterDBConnected(SqlConnection sqlc) 3089 private static bool IsMasterDBConnected(SqlConnection sqlc)
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.31.2.0")]  
36 -[assembly: AssemblyFileVersion("1.31.2.0")] 35 +[assembly: AssemblyVersion("1.31.3.0")]
  36 +[assembly: AssemblyFileVersion("1.31.3.0")]