Commit 027cf12665b5fe724fc25ad960396666eec27c1d
1 parent
066d5d55
v1.33.0
-MoveDbFromPrimaryToSecondary átdolgozása és javítása
Showing
2 changed files
with
134 additions
and
75 deletions
Show diff stats
Vrh.Log4Pro.MaintenanceConsole/Manager - SQLDataBaseManager.cs
@@ -214,7 +214,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | @@ -214,7 +214,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | ||
214 | else if (string.IsNullOrWhiteSpace(selectedbackupfilepath)) goto enterpathtobackupfileloop; | 214 | else if (string.IsNullOrWhiteSpace(selectedbackupfilepath)) goto enterpathtobackupfileloop; |
215 | } | 215 | } |
216 | 216 | ||
217 | - SQLDataBaseManagerCore.RestoreBackup(sqld, selectedbackupfilepath, targetdirectorypath, restorefromzip, targetdbname); | 217 | + SQLDataBaseManagerCore.RestoreBackup(sqld.SQLCS_Primary, selectedbackupfilepath, targetdirectorypath, restorefromzip, targetdbname); |
218 | ColorConsole.WriteLine($"Database '{sqld.DBName}' restored to '{targetdbname}' into directory '{targetdirectorypath}'.", ConsoleColor.Green); | 218 | ColorConsole.WriteLine($"Database '{sqld.DBName}' restored to '{targetdbname}' into directory '{targetdirectorypath}'.", ConsoleColor.Green); |
219 | } | 219 | } |
220 | catch (Exception ex) { ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red); } | 220 | catch (Exception ex) { ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red); } |
@@ -252,7 +252,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | @@ -252,7 +252,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | ||
252 | if (targetdirectorypath.ToUpper() == "EX") { return o; } | 252 | if (targetdirectorypath.ToUpper() == "EX") { return o; } |
253 | if (string.IsNullOrWhiteSpace(selectedbackupfilepath)) { targetdbname = st.DBName; } | 253 | if (string.IsNullOrWhiteSpace(selectedbackupfilepath)) { targetdbname = st.DBName; } |
254 | bool restorefromzip =Path.GetExtension(selectedbackupfilepath).ToLower() == ".zip"; ; | 254 | bool restorefromzip =Path.GetExtension(selectedbackupfilepath).ToLower() == ".zip"; ; |
255 | - SQLDataBaseManagerCore.RestoreBackup(st, selectedbackupfilepath, targetdirectorypath, restorefromzip, targetdbname); | 255 | + SQLDataBaseManagerCore.RestoreBackup(st.SQLCS_Primary, selectedbackupfilepath, targetdirectorypath, restorefromzip, targetdbname); |
256 | ColorConsole.WriteLine($"Database '{targetdbname}' restored into directory '{targetdirectorypath}'.", ConsoleColor.Green); | 256 | ColorConsole.WriteLine($"Database '{targetdbname}' restored into directory '{targetdirectorypath}'.", ConsoleColor.Green); |
257 | goto startselection; | 257 | goto startselection; |
258 | } | 258 | } |
@@ -443,7 +443,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | @@ -443,7 +443,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | ||
443 | 443 | ||
444 | if (!srvrlogintoexecute.Remove) | 444 | if (!srvrlogintoexecute.Remove) |
445 | { | 445 | { |
446 | - SQLDataBaseManagerCore.CreateLogin(sqlcs, srvrlogintoexecute.LoginName, srvrlogintoexecute.LoginPassword, srvrlogintoexecute.DefaultDatabase, srvrlogintoexecute.LoginType, null, srvrlogintoexecute.GrantorUserLoginName, srvrlogintoexecute.GrantorUserLoginPassword); | 446 | + SQLDataBaseManagerCore.CreateLogin(sqlcs,sqldbname:null, srvrlogintoexecute.LoginName, srvrlogintoexecute.LoginPassword, srvrlogintoexecute.DefaultDatabase, srvrlogintoexecute.LoginType, null, srvrlogintoexecute.GrantorUserLoginName, srvrlogintoexecute.GrantorUserLoginPassword); |
447 | ColorConsole.WriteLine($"SUCCESS! {removeactionText} server login: {SRVRLogin_fulldesignation}", ConsoleColor.Green); | 447 | ColorConsole.WriteLine($"SUCCESS! {removeactionText} server login: {SRVRLogin_fulldesignation}", ConsoleColor.Green); |
448 | } | 448 | } |
449 | else | 449 | else |
@@ -604,7 +604,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | @@ -604,7 +604,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | ||
604 | 604 | ||
605 | if (!dbusertoexecute.Remove) | 605 | if (!dbusertoexecute.Remove) |
606 | { | 606 | { |
607 | - SQLDataBaseManagerCore.CreateUser(sqlcs, dbusertoexecute.UserName, dbusertoexecute.RoleNameCommaList, dbusertoexecute.LoginName); | 607 | + SQLDataBaseManagerCore.CreateUser(sqlcs,sqldbname:null, dbusertoexecute.UserName, dbusertoexecute.RoleNameCommaList, dbusertoexecute.LoginName); |
608 | ColorConsole.WriteLine($"SUCCESS! {removeactionText} database user: {DBUser_fulldesignation}", ConsoleColor.Green); | 608 | ColorConsole.WriteLine($"SUCCESS! {removeactionText} database user: {DBUser_fulldesignation}", ConsoleColor.Green); |
609 | } | 609 | } |
610 | else | 610 | else |
@@ -630,25 +630,25 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | @@ -630,25 +630,25 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | ||
630 | { | 630 | { |
631 | var DateTimeNow = DateTime.Now; | 631 | var DateTimeNow = DateTime.Now; |
632 | SQLDataBase dbtomove = null; | 632 | SQLDataBase dbtomove = null; |
633 | - | ||
634 | - movedatabaseloop: | ||
635 | - (Menu.SelectionResult selectionresult, bool yes) yesornoanswer = YesOrNo(new List<string>() { $"Do You want to move ANY database from local server to remote server?" }); | 633 | + string todbname=null; |
634 | + movedatabaseloop: | ||
635 | + (Menu.SelectionResult selectionresult, bool yes) yesornoanswer = YesOrNo(new List<string>() { $">>>> Do You want to move ANY database from local server to remote server?" }); | ||
636 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Exit) return o; | 636 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Exit) return o; |
637 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Ok && yesornoanswer.yes) | 637 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Ok && yesornoanswer.yes) |
638 | { | 638 | { |
639 | - var dbselection = SelectDbToMove(config, selectedsqldbindexes, $"Select the SQL database to move from its PRIMARY to SECONDARY location!"); | 639 | + var dbselection = SelectDbToMove(config, selectedsqldbindexes, $">>>> Select the SQL database to move from its PRIMARY to SECONDARY location!"); |
640 | if (dbselection.selection == Menu.SelectionResult.Exit) { return o; } | 640 | if (dbselection.selection == Menu.SelectionResult.Exit) { return o; } |
641 | if (dbselection.selection != Menu.SelectionResult.Ok) { goto movedatabaseloop; } | 641 | if (dbselection.selection != Menu.SelectionResult.Ok) { goto movedatabaseloop; } |
642 | dbtomove = dbselection.dbtomove; | 642 | dbtomove = dbselection.dbtomove; |
643 | if (NoDBNameSpecified(dbtomove)) { continue; } | 643 | if (NoDBNameSpecified(dbtomove)) { continue; } |
644 | var dbnameSecondary = SQLDataBaseManagerCore.GetDBName(dbtomove.SQLCS_Secondary); | 644 | var dbnameSecondary = SQLDataBaseManagerCore.GetDBName(dbtomove.SQLCS_Secondary); |
645 | 645 | ||
646 | - var todbname = ColorConsole.ReadLine($"Enter the name of the target DB. EMPTY={dbnameSecondary}, EX=exit."); | 646 | + todbname = ColorConsole.ReadLine($">>>> Enter the name of the target DB. EMPTY={dbnameSecondary}, EX=exit."); |
647 | if (todbname.ToUpper() == "EX") { return o; } | 647 | if (todbname.ToUpper() == "EX") { return o; } |
648 | else if (string.IsNullOrWhiteSpace(todbname)) todbname = dbnameSecondary; | 648 | else if (string.IsNullOrWhiteSpace(todbname)) todbname = dbnameSecondary; |
649 | 649 | ||
650 | confirmloop:; | 650 | confirmloop:; |
651 | - var confirmtext = ColorConsole.ReadLine("Enter CONFIRM to start, EX to exit, SKIP to skip."); | 651 | + var confirmtext = ColorConsole.ReadLine(">>>> Enter CONFIRM to start, EX to exit, SKIP to skip."); |
652 | if (confirmtext.ToUpper() == "EX") { return o; } | 652 | if (confirmtext.ToUpper() == "EX") { return o; } |
653 | else if (confirmtext.ToUpper() == "CONFIRM") | 653 | else if (confirmtext.ToUpper() == "CONFIRM") |
654 | { | 654 | { |
@@ -659,41 +659,45 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | @@ -659,41 +659,45 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | ||
659 | } | 659 | } |
660 | 660 | ||
661 | serverloginloop: | 661 | serverloginloop: |
662 | - yesornoanswer = YesOrNo(new List<string>() { $"Do You want to create server and DB logins for the server/database PRIMARY and/or SECONDARY locations?", }); | 662 | + yesornoanswer = YesOrNo(new List<string>() { $">>>> Do You want to create server and DB logins for the server/database PRIMARY and/or SECONDARY locations?", }); |
663 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Exit) return o; | 663 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Exit) return o; |
664 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Ok && yesornoanswer.yes) | 664 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Ok && yesornoanswer.yes) |
665 | { | 665 | { |
666 | if (dbtomove == null) | 666 | if (dbtomove == null) |
667 | { | 667 | { |
668 | - var dbselection = SelectDbToMove(config, selectedsqldbindexes, $"Select the SQL database to add server and DB logins to its PRIMARY and its SECONDARY location!"); | 668 | + var dbselection = SelectDbToMove(config, selectedsqldbindexes, $">>>> Select the SQL database to add server and DB logins to its PRIMARY and its SECONDARY location!"); |
669 | if (dbselection.selection == Menu.SelectionResult.Exit) { return o; } | 669 | if (dbselection.selection == Menu.SelectionResult.Exit) { return o; } |
670 | if (dbselection.selection != Menu.SelectionResult.Ok) { goto serverloginloop; } | 670 | if (dbselection.selection != Menu.SelectionResult.Ok) { goto serverloginloop; } |
671 | dbtomove = dbselection.dbtomove; | 671 | dbtomove = dbselection.dbtomove; |
672 | } | 672 | } |
673 | - var usernamelist = new string[] { "corplear\\lschwirg", "corplear\\gen_vrhalmadmin", $"corplear\\{Program.ThisComputer.ComputerName}$" }; | ||
674 | 673 | ||
675 | - string l1 = $"Do You want to create the following mandatory server/database logins for the PRIMARY location?"; | 674 | + var usernamelist = new List<string> { "corplear\\lschwirg", "corplear\\gen_vrhalmadmin", $"corplear\\{Program.ThisComputer.ComputerName}$" }; |
675 | + if (!string.IsNullOrWhiteSpace(dbtomove.Xml_PrimaryDB_ServerName)) usernamelist.Add( $"corplear\\{dbtomove.Xml_PrimaryDB_ServerName}$"); | ||
676 | + if (!string.IsNullOrWhiteSpace(dbtomove.Xml_SecondaryDB_ServerName)) usernamelist.Add($"corplear\\{dbtomove.Xml_SecondaryDB_ServerName}$"); | ||
677 | + | ||
678 | + string l1 = $">>>> Do You want to create the following mandatory server/database logins for the PRIMARY location?"; | ||
676 | string l2 = $" SQL connection string: {dbtomove.SQLCS_Primary}"; | 679 | string l2 = $" SQL connection string: {dbtomove.SQLCS_Primary}"; |
677 | string l3 = $" Username list: " + string.Join(",", usernamelist); | 680 | string l3 = $" Username list: " + string.Join(",", usernamelist); |
678 | - yesornoanswer = YesOrNo(new List<string>() { l1, l2, l3, }); | 681 | + yesornoanswer = YesOrNo(new List<string>() { l1, l2, l3 }); |
679 | if (yesornoanswer.selectionresult== Menu.SelectionResult.Exit) return o; | 682 | if (yesornoanswer.selectionresult== Menu.SelectionResult.Exit) return o; |
680 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Ok && yesornoanswer.yes) | 683 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Ok && yesornoanswer.yes) |
681 | { | 684 | { |
682 | - SQLDataBaseManagerCore.CreateServerAndDBLogins(false, dbtomove.SQLCS_Primary, usernamelist, serverloginrolelist, fullaccessdbloginrolelist); | 685 | + SQLDataBaseManagerCore.CreateServerAndDBLogins(false, dbtomove.SQLCS_Primary, null, usernamelist.ToArray(), serverloginrolelist, fullaccessdbloginrolelist); |
683 | } | 686 | } |
684 | 687 | ||
685 | - string l13 = $"Do You want to create the following mandatory server/database logins for SECONDARY location?"; | 688 | + string l13 = $">>>> Do You want to create the following mandatory server/database logins for SECONDARY location?"; |
686 | string l23 = $" SQL connection string: {dbtomove.SQLCS_Secondary}"; | 689 | string l23 = $" SQL connection string: {dbtomove.SQLCS_Secondary}"; |
687 | - string l33 = $" Username list: " + string.Join(",", usernamelist); | ||
688 | - yesornoanswer = YesOrNo(new List<string>() { l13,l23,l33,}); | 690 | + string l33 = $" SQL database name: {todbname}"; |
691 | + string l43 = $" Username list: " + string.Join(",", usernamelist); | ||
692 | + yesornoanswer = YesOrNo(new List<string>() { l13,l23,l33,l43}); | ||
689 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Exit) return o; | 693 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Exit) return o; |
690 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Ok && yesornoanswer.yes) | 694 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Ok && yesornoanswer.yes) |
691 | { | 695 | { |
692 | - SQLDataBaseManagerCore.CreateServerAndDBLogins(false, dbtomove.SQLCS_Secondary, usernamelist, serverloginrolelist, fullaccessdbloginrolelist); | 696 | + SQLDataBaseManagerCore.CreateServerAndDBLogins(false, dbtomove.SQLCS_Secondary, todbname, usernamelist.ToArray(), serverloginrolelist, fullaccessdbloginrolelist); |
693 | } | 697 | } |
694 | } | 698 | } |
695 | 699 | ||
696 | - yesornoanswer = YesOrNo(new List<string>() { $"Do You want to set database '{SQLDataBaseManagerCore.GetDBName(dbtomove.SQLCS_Primary)}' OFFLINE on server '{SQLDataBaseManagerCore.GetDataSource(dbtomove.SQLCS_Primary)}'?", }); | 700 | + yesornoanswer = YesOrNo(new List<string>() { $">>>> Do You want to set database '{SQLDataBaseManagerCore.GetDBName(dbtomove.SQLCS_Primary)}' OFFLINE on server '{SQLDataBaseManagerCore.GetDataSource(dbtomove.SQLCS_Primary)}'?", }); |
697 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Exit) return o; | 701 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Exit) return o; |
698 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Ok && yesornoanswer.yes) | 702 | if (yesornoanswer.selectionresult == Menu.SelectionResult.Ok && yesornoanswer.yes) |
699 | { | 703 | { |
@@ -1291,10 +1295,7 @@ GO | @@ -1291,10 +1295,7 @@ GO | ||
1291 | ColorConsole.Write(st.Status.ToString(), statuscolor, bracket: "[]", prefix: " ", suffix: ". "); | 1295 | ColorConsole.Write(st.Status.ToString(), statuscolor, bracket: "[]", prefix: " ", suffix: ". "); |
1292 | if (!string.IsNullOrWhiteSpace(st.DBName)) { ColorConsole.Write(st.DBName, statuscolor, bracket: "[]", prefix: "Database ", suffix: ". "); } | 1296 | if (!string.IsNullOrWhiteSpace(st.DBName)) { ColorConsole.Write(st.DBName, statuscolor, bracket: "[]", prefix: "Database ", suffix: ". "); } |
1293 | ColorConsole.Write(st.DataSource, statuscolor, bracket: "[]", prefix: "from server ", suffix: ". "); | 1297 | ColorConsole.Write(st.DataSource, statuscolor, bracket: "[]", prefix: "from server ", suffix: ". "); |
1294 | - if (st.Status != SQLDataBase.SQLDBStatus.NoAccess) | ||
1295 | - { | ||
1296 | - } | ||
1297 | - if (st.Xml_PrimaryDB_IsUseTranzit) { ColorConsole.Write("REMOTE", ConsoleColor.Cyan, bracket: "[]", prefix: "", suffix: ""); } | 1298 | + if (st.Status != SQLDataBase.SQLDBStatus.NoAccess) {} |
1298 | ColorConsole.WriteLine(); | 1299 | ColorConsole.WriteLine(); |
1299 | return Menu.MenuItemDisplayerReturnValue.NEXTLINE; | 1300 | return Menu.MenuItemDisplayerReturnValue.NEXTLINE; |
1300 | } | 1301 | } |
@@ -1314,21 +1315,59 @@ GO | @@ -1314,21 +1315,59 @@ GO | ||
1314 | } | 1315 | } |
1315 | else if (lineix == 3) | 1316 | else if (lineix == 3) |
1316 | { | 1317 | { |
1318 | + const string STANDARD = "STANDARD"; | ||
1317 | if (string.IsNullOrWhiteSpace(st.DBName)) return Menu.MenuItemDisplayerReturnValue.SAMELINE; | 1319 | if (string.IsNullOrWhiteSpace(st.DBName)) return Menu.MenuItemDisplayerReturnValue.SAMELINE; |
1318 | var PhysicalFilesDirectoryPathcolor = st.PrimaryDB_PhysicalFilesDirectoryPath.StartsWith("ERR") ? ConsoleColor.Red : ConsoleColor.Yellow; | 1320 | var PhysicalFilesDirectoryPathcolor = st.PrimaryDB_PhysicalFilesDirectoryPath.StartsWith("ERR") ? ConsoleColor.Red : ConsoleColor.Yellow; |
1319 | - ColorConsole.Write($"{st.PrimaryDB_PhysicalFilesDirectoryPath}", PhysicalFilesDirectoryPathcolor, prefix: "DB files physical location:", suffix: " "); | 1321 | + ColorConsole.Write($"{st.PrimaryDB_PhysicalFilesDirectoryPath??STANDARD}", PhysicalFilesDirectoryPathcolor, prefix: "DB files PHYSICAL location:", suffix: " "); |
1320 | ColorConsole.WriteLine(" "); | 1322 | ColorConsole.WriteLine(" "); |
1321 | return Menu.MenuItemDisplayerReturnValue.NEXTLINE; | 1323 | return Menu.MenuItemDisplayerReturnValue.NEXTLINE; |
1322 | } | 1324 | } |
1323 | - else if (lineix == 4) | ||
1324 | - { | 1325 | + else if (lineix == 4) |
1326 | + { | ||
1325 | if (string.IsNullOrWhiteSpace(st.DBName)) return Menu.MenuItemDisplayerReturnValue.SAMELINE; | 1327 | if (string.IsNullOrWhiteSpace(st.DBName)) return Menu.MenuItemDisplayerReturnValue.SAMELINE; |
1326 | - var SizeStringcolor = st.SizeString.StartsWith("ERR") ? ConsoleColor.Red : ConsoleColor.Yellow; | ||
1327 | - ColorConsole.Write(st.SizeString, SizeStringcolor, prefix: "DB size:", suffix: " "); | ||
1328 | - ColorConsole.WriteLine(" "); | ||
1329 | - return Menu.MenuItemDisplayerReturnValue.NEXTLINE; | ||
1330 | - } | ||
1331 | - else if (5 <= lineix && lineix <= 5 + st.Xml_SQLScriptList.Count) | 1328 | + if (!st.Xml_PrimaryDB_IsUseTranzit) return Menu.MenuItemDisplayerReturnValue.SAMELINE; |
1329 | + var TranzitDirectoryPathcolor = st.Xml_PrimaryDB_TranzitDirectoryPath.StartsWith("ERR") ? ConsoleColor.Red : ConsoleColor.Yellow; | ||
1330 | + ColorConsole.Write($"{st.Xml_PrimaryDB_TranzitDirectoryPath}", TranzitDirectoryPathcolor, prefix: "DB files TRANZIT location:", suffix: " "); | ||
1331 | + ColorConsole.WriteLine(" "); | ||
1332 | + return Menu.MenuItemDisplayerReturnValue.NEXTLINE; | ||
1333 | + } | ||
1334 | + else if (lineix == 5) | ||
1335 | + { | ||
1336 | + if (string.IsNullOrWhiteSpace(st.DBName)) return Menu.MenuItemDisplayerReturnValue.SAMELINE; | ||
1337 | + var SizeStringcolor = st.SizeString_Primary.StartsWith("ERR") ? ConsoleColor.Red : ConsoleColor.Yellow; | ||
1338 | + ColorConsole.Write(st.SizeString_Primary, SizeStringcolor, prefix: "DB size:", suffix: " "); | ||
1339 | + ColorConsole.WriteLine(" "); | ||
1340 | + return Menu.MenuItemDisplayerReturnValue.NEXTLINE; | ||
1341 | + } | ||
1342 | + else if (lineix == 6) | ||
1343 | + { | ||
1344 | + if (string.IsNullOrWhiteSpace(st.DBName)) return Menu.MenuItemDisplayerReturnValue.SAMELINE; | ||
1345 | + if (!st.Xml_SecondaryDB_IsDefined) return Menu.MenuItemDisplayerReturnValue.SAMELINE; | ||
1346 | + ColorConsole.Write($"{st.SQLCS_Secondary}", ConsoleColor.Yellow, prefix: "Secondary SQL DB connection:", suffix: ", "); | ||
1347 | + ColorConsole.WriteLine(" "); | ||
1348 | + return Menu.MenuItemDisplayerReturnValue.NEXTLINE; | ||
1349 | + } | ||
1350 | + else if (lineix == 7) | ||
1351 | + { | ||
1352 | + const string STANDARD = "STANDARD"; | ||
1353 | + if (string.IsNullOrWhiteSpace(st.DBName)) return Menu.MenuItemDisplayerReturnValue.SAMELINE; | ||
1354 | + if (!st.Xml_SecondaryDB_IsDefined) return Menu.MenuItemDisplayerReturnValue.SAMELINE; | ||
1355 | + var PhysicalFilesDirectoryPathcolor = st.SecondaryDB_PhysicalFilesDirectoryPath.StartsWith("ERR") ? ConsoleColor.Red : ConsoleColor.Yellow; | ||
1356 | + ColorConsole.Write($"{st.SecondaryDB_PhysicalFilesDirectoryPath??STANDARD}", PhysicalFilesDirectoryPathcolor, prefix: "Secondary DB files PHYSICAL location:", suffix: " "); | ||
1357 | + ColorConsole.WriteLine(" "); | ||
1358 | + return Menu.MenuItemDisplayerReturnValue.NEXTLINE; | ||
1359 | + } | ||
1360 | + else if (lineix == 8) | ||
1361 | + { | ||
1362 | + if (string.IsNullOrWhiteSpace(st.DBName)) return Menu.MenuItemDisplayerReturnValue.SAMELINE; | ||
1363 | + if (!st.Xml_SecondaryDB_IsDefined) return Menu.MenuItemDisplayerReturnValue.SAMELINE; | ||
1364 | + if (!st.Xml_SecondaryDB_IsUseTranzit) return Menu.MenuItemDisplayerReturnValue.SAMELINE; | ||
1365 | + var TranzitDirectoryPathcolor = st.Xml_SecondaryDB_TranzitDirectoryPath.StartsWith("ERR") ? ConsoleColor.Red : ConsoleColor.Yellow; | ||
1366 | + ColorConsole.Write($"{st.Xml_SecondaryDB_TranzitDirectoryPath}", TranzitDirectoryPathcolor, prefix: "Secondary DB files TRANZIT location:", suffix: " "); | ||
1367 | + ColorConsole.WriteLine(" "); | ||
1368 | + return Menu.MenuItemDisplayerReturnValue.NEXTLINE; | ||
1369 | + } | ||
1370 | + else if (9 <= lineix && lineix <= 9 + st.Xml_SQLScriptList.Count) | ||
1332 | { | 1371 | { |
1333 | if (st.Xml_SQLScriptList.Count == 0) { return Menu.MenuItemDisplayerReturnValue.EXIT; } | 1372 | if (st.Xml_SQLScriptList.Count == 0) { return Menu.MenuItemDisplayerReturnValue.EXIT; } |
1334 | if (st.Xml_SQLScriptList.Count-1 < lineix-5) { return Menu.MenuItemDisplayerReturnValue.EXIT; } | 1373 | if (st.Xml_SQLScriptList.Count-1 < lineix-5) { return Menu.MenuItemDisplayerReturnValue.EXIT; } |
@@ -1358,7 +1397,7 @@ GO | @@ -1358,7 +1397,7 @@ GO | ||
1358 | { | 1397 | { |
1359 | var dbbackupfilepath = CreateBackup(sqld, false,null); | 1398 | var dbbackupfilepath = CreateBackup(sqld, false,null); |
1360 | if (dbbackupfilepath == null) return; | 1399 | if (dbbackupfilepath == null) return; |
1361 | - RestoreBackup(sqld, dbbackupfilepath, targetdirectory, false, restoredbname); | 1400 | + RestoreBackup(sqld.SQLCS_Primary, dbbackupfilepath, targetdirectory, false, restoredbname); |
1362 | if (File.Exists(dbbackupfilepath)) { File.Delete(dbbackupfilepath); } | 1401 | if (File.Exists(dbbackupfilepath)) { File.Delete(dbbackupfilepath); } |
1363 | } | 1402 | } |
1364 | 1403 | ||
@@ -1378,18 +1417,18 @@ GO | @@ -1378,18 +1417,18 @@ GO | ||
1378 | 1417 | ||
1379 | if (!emulation && !File.Exists(backupfileFullname)) { return false; } | 1418 | if (!emulation && !File.Exists(backupfileFullname)) { return false; } |
1380 | 1419 | ||
1381 | - string tranzitfileFullname = backupfileFullname; | ||
1382 | - if (dbtomove.Xml_SecondaryDB_IsUseTranzit) | 1420 | + string tranzitfileNetworkFullname = backupfileFullname; |
1421 | + if (dbtomove.Xml_SecondaryDB_IsUseTranzit) | ||
1383 | { | 1422 | { |
1384 | try | 1423 | try |
1385 | { | 1424 | { |
1386 | string backupfileFilename = Path.GetFileName(backupfileFullname); | 1425 | string backupfileFilename = Path.GetFileName(backupfileFullname); |
1387 | - tranzitfileFullname = Path.Combine(dbtomove.Xml_SecondaryDB_TranzitDirectoryPath, backupfileFilename); | 1426 | + tranzitfileNetworkFullname = Path.Combine(dbtomove.Xml_SecondaryDB_TranzitDirectoryPath, backupfileFilename); |
1388 | ColorConsole.WriteLine($"Moving backup file {backupfileFullname} to tranzit location: {dbtomove.Xml_SecondaryDB_TranzitDirectoryPath}", ConsoleColor.Yellow); | 1427 | ColorConsole.WriteLine($"Moving backup file {backupfileFullname} to tranzit location: {dbtomove.Xml_SecondaryDB_TranzitDirectoryPath}", ConsoleColor.Yellow); |
1389 | if (!emulation) | 1428 | if (!emulation) |
1390 | { | 1429 | { |
1391 | - if (File.Exists(tranzitfileFullname)) { File.Delete(tranzitfileFullname); } | ||
1392 | - File.Move(backupfileFullname, tranzitfileFullname); | 1430 | + if (File.Exists(tranzitfileNetworkFullname)) { File.Delete(tranzitfileNetworkFullname); } |
1431 | + File.Move(backupfileFullname, tranzitfileNetworkFullname); | ||
1393 | ColorConsole.WriteLine($"...completed...", ConsoleColor.Yellow); | 1432 | ColorConsole.WriteLine($"...completed...", ConsoleColor.Yellow); |
1394 | } | 1433 | } |
1395 | } | 1434 | } |
@@ -1400,10 +1439,10 @@ GO | @@ -1400,10 +1439,10 @@ GO | ||
1400 | return false; | 1439 | return false; |
1401 | } | 1440 | } |
1402 | } | 1441 | } |
1403 | - if (!emulation && !File.Exists(tranzitfileFullname)) { return false; } | 1442 | + if (!emulation && !File.Exists(tranzitfileNetworkFullname)) { return false; } |
1404 | 1443 | ||
1405 | //restore backup to dbto | 1444 | //restore backup to dbto |
1406 | - SQLDataBaseManagerCore.RestoreBackup(dbtomove, tranzitfileFullname, dbtomove.Xml_SecondaryDB_PhysicalFilesDirectoryPath, false, selecteddbname, emulation); | 1445 | + SQLDataBaseManagerCore.RestoreBackup(dbtomove.SQLCS_Secondary, tranzitfileNetworkFullname, dbtomove.Xml_SecondaryDB_PhysicalFilesDirectoryPath, false, selecteddbname, emulation); |
1407 | return true; | 1446 | return true; |
1408 | } | 1447 | } |
1409 | 1448 | ||
@@ -1416,19 +1455,22 @@ GO | @@ -1416,19 +1455,22 @@ GO | ||
1416 | /// <param name="restorefromZIP">true=sourcesqlbackupfilepath is a zip file</param> | 1455 | /// <param name="restorefromZIP">true=sourcesqlbackupfilepath is a zip file</param> |
1417 | /// <param name="restoretodbname"></param> | 1456 | /// <param name="restoretodbname"></param> |
1418 | /// <param name="emulate"></param> | 1457 | /// <param name="emulate"></param> |
1419 | - public static void RestoreBackup(SQLDataBase sqldb, string sourcesqlbackupfilepath, string targetdbphysicalfilesdirectorypath, bool restorefromZIP = false, string restoretodbname = null,bool emulate=false) | 1458 | + public static void RestoreBackup(string sqldbcs, string sourcesqlbackupfilepath, string targetdbphysicalfilesdirectorypath, bool restorefromZIP = false, string restoretodbname = null,bool emulate=false) |
1420 | { | 1459 | { |
1421 | - string sqlcs = sqldb.SQLCS_Primary; //sqlcs = sqlcs.Replace("LearALM2", "master"); | 1460 | + string sqlcs = sqldbcs; //sqlcs = sqlcs.Replace("LearALM2", "master"); |
1422 | string zippedbackupfilepath = restorefromZIP? sourcesqlbackupfilepath:Path.Combine(Path.GetDirectoryName(sourcesqlbackupfilepath), Path.GetFileNameWithoutExtension(sourcesqlbackupfilepath) + ".zip"); | 1461 | string zippedbackupfilepath = restorefromZIP? sourcesqlbackupfilepath:Path.Combine(Path.GetDirectoryName(sourcesqlbackupfilepath), Path.GetFileNameWithoutExtension(sourcesqlbackupfilepath) + ".zip"); |
1423 | string normalbackupfilepath = !restorefromZIP? sourcesqlbackupfilepath : Path.Combine(Path.GetDirectoryName(sourcesqlbackupfilepath), Path.GetFileNameWithoutExtension(sourcesqlbackupfilepath) + ".bak"); | 1462 | string normalbackupfilepath = !restorefromZIP? sourcesqlbackupfilepath : Path.Combine(Path.GetDirectoryName(sourcesqlbackupfilepath), Path.GetFileNameWithoutExtension(sourcesqlbackupfilepath) + ".bak"); |
1424 | 1463 | ||
1425 | ColorConsole.WriteLine(nameof(RestoreBackup), ConsoleColor.Yellow, prefix: "running...."); | 1464 | ColorConsole.WriteLine(nameof(RestoreBackup), ConsoleColor.Yellow, prefix: "running...."); |
1426 | ColorConsole.WriteLine(restoretodbname, ConsoleColor.Yellow, prefix: " restoretodbname:"); | 1465 | ColorConsole.WriteLine(restoretodbname, ConsoleColor.Yellow, prefix: " restoretodbname:"); |
1427 | - ColorConsole.WriteLine(sqldb.SQLCS_Primary, ConsoleColor.Yellow, prefix: " sqldb.SQLCS:"); | 1466 | + ColorConsole.WriteLine(sqldbcs, ConsoleColor.Yellow, prefix: " sqldb.SQLCS:"); |
1428 | ColorConsole.WriteLine(sourcesqlbackupfilepath, ConsoleColor.Yellow, prefix: " sourcesqlbackupfilepath:"); | 1467 | ColorConsole.WriteLine(sourcesqlbackupfilepath, ConsoleColor.Yellow, prefix: " sourcesqlbackupfilepath:"); |
1429 | - ColorConsole.WriteLine(normalbackupfilepath, ConsoleColor.Yellow, prefix: " backupfilepath:"); | ||
1430 | - ColorConsole.WriteLine(restorefromZIP.ToString(), ConsoleColor.Yellow, prefix: " restorefromZIP:"); | ||
1431 | - ColorConsole.WriteLine(zippedbackupfilepath, ConsoleColor.Yellow, prefix: " zippedbackupfilepath:"); | 1468 | + ColorConsole.WriteLine(restorefromZIP.ToString(), ConsoleColor.Yellow, prefix: " restorefromZIP:"); |
1469 | + if (restorefromZIP) | ||
1470 | + { | ||
1471 | + ColorConsole.WriteLine(normalbackupfilepath, ConsoleColor.Yellow, prefix: " backupfilepath:"); | ||
1472 | + ColorConsole.WriteLine(zippedbackupfilepath, ConsoleColor.Yellow, prefix: " zippedbackupfilepath:"); | ||
1473 | + } | ||
1432 | ColorConsole.WriteLine(targetdbphysicalfilesdirectorypath, ConsoleColor.Yellow, prefix: " targetdbphysicalfilesdirectorypath:"); | 1474 | ColorConsole.WriteLine(targetdbphysicalfilesdirectorypath, ConsoleColor.Yellow, prefix: " targetdbphysicalfilesdirectorypath:"); |
1433 | if (emulate) { return; } | 1475 | if (emulate) { return; } |
1434 | 1476 | ||
@@ -1444,18 +1486,14 @@ GO | @@ -1444,18 +1486,14 @@ GO | ||
1444 | while (DateTime.Now.Subtract(starttime).TotalSeconds > 5) { if (File.Exists(normalbackupfilepath)) { break; } Thread.Sleep(500); } | 1486 | while (DateTime.Now.Subtract(starttime).TotalSeconds > 5) { if (File.Exists(normalbackupfilepath)) { break; } Thread.Sleep(500); } |
1445 | } | 1487 | } |
1446 | 1488 | ||
1447 | - if (!File.Exists(normalbackupfilepath)) | ||
1448 | - { | ||
1449 | - ColorConsole.WriteLine($"ERROR! Restore source backup file '{normalbackupfilepath}' does not exist!", ConsoleColor.Red, prefix: ""); | ||
1450 | - return; | ||
1451 | - } | ||
1452 | Server sqlserver = null; | 1489 | Server sqlserver = null; |
1453 | try | 1490 | try |
1454 | { | 1491 | { |
1455 | var sc = ServerConnectionPool.GetSqlConnection(sqlcs, "master"); | 1492 | var sc = ServerConnectionPool.GetSqlConnection(sqlcs, "master"); |
1456 | sqlserver = SQLServerConnect(sc);if (sqlserver == null) { return; } | 1493 | sqlserver = SQLServerConnect(sc);if (sqlserver == null) { return; } |
1494 | + sqlserver.ConnectionContext.StatementTimeout = 2000;// sqld.Xml_BackupTimeout; | ||
1457 | 1495 | ||
1458 | - var smoRestore = new Restore(); | 1496 | + var smoRestore = new Restore(); |
1459 | smoRestore.NoRecovery = false; | 1497 | smoRestore.NoRecovery = false; |
1460 | smoRestore.ReplaceDatabase = true; | 1498 | smoRestore.ReplaceDatabase = true; |
1461 | smoRestore.Action = RestoreActionType.Database; | 1499 | smoRestore.Action = RestoreActionType.Database; |
@@ -1588,9 +1626,10 @@ GO | @@ -1588,9 +1626,10 @@ GO | ||
1588 | sqlserver = SQLServerConnect(sqld.SQLCS_Primary, "master"); if (sqlserver == null) { return null; } | 1626 | sqlserver = SQLServerConnect(sqld.SQLCS_Primary, "master"); if (sqlserver == null) { return null; } |
1589 | sqlserver.ConnectionContext.StatementTimeout = sqld.Xml_BackupTimeout; | 1627 | sqlserver.ConnectionContext.StatementTimeout = sqld.Xml_BackupTimeout; |
1590 | backupstarttime = DateTime.Now; | 1628 | backupstarttime = DateTime.Now; |
1591 | - smoBackup.SqlBackup(sqlserver); | ||
1592 | - //smoBackup.Wait(); | ||
1593 | - Console.WriteLine($""); | 1629 | + smoBackup.SqlBackupAsync(sqlserver); |
1630 | + smoBackup.Wait(); | ||
1631 | + //smoBackup.Wait(); | ||
1632 | + Console.WriteLine($""); | ||
1594 | Console.WriteLine($"Backup completed. Backup time: {(int)(DateTime.Now.Subtract(backupstarttime).TotalSeconds)}sec."); | 1633 | Console.WriteLine($"Backup completed. Backup time: {(int)(DateTime.Now.Subtract(backupstarttime).TotalSeconds)}sec."); |
1595 | } | 1634 | } |
1596 | catch (Exception ex) | 1635 | catch (Exception ex) |
@@ -1672,9 +1711,9 @@ GO | @@ -1672,9 +1711,9 @@ GO | ||
1672 | } | 1711 | } |
1673 | finally { sqlserver?.ConnectionContext.SqlConnectionObject.Dispose(); } | 1712 | finally { sqlserver?.ConnectionContext.SqlConnectionObject.Dispose(); } |
1674 | } | 1713 | } |
1675 | - public static void CreateUser(string sqldbconnectionString, string dbusername, string dbrolenamecommalist,string loginname) | 1714 | + public static void CreateUser(string sqldbconnectionString, string sqldbname, string dbusername, string dbrolenamecommalist,string loginname) |
1676 | { | 1715 | { |
1677 | - using (SqlConnection connection = ServerConnectionPool.GetSqlConnection(sqldbconnectionString,open:true)) | 1716 | + using (SqlConnection connection = ServerConnectionPool.GetSqlConnection(sqldbconnectionString, sqldbname,open: true)) |
1678 | { | 1717 | { |
1679 | // Create user | 1718 | // Create user |
1680 | //USE [LearALM2] | 1719 | //USE [LearALM2] |
@@ -1758,12 +1797,12 @@ GO | @@ -1758,12 +1797,12 @@ GO | ||
1758 | 1797 | ||
1759 | } | 1798 | } |
1760 | } | 1799 | } |
1761 | - public static void CreateLogin(string sqldbconnectionString, string name, string password, string defaultDatabase, LoginType logintype, string[] roles,string grantoruser=null,string grantoruserpsw=null) | 1800 | + public static void CreateLogin(string sqldbconnectionString,string sqldbname, string name, string password, string defaultDatabase, LoginType logintype, string[] roles,string grantoruser=null,string grantoruserpsw=null) |
1762 | { | 1801 | { |
1763 | Server sqlserver = null; | 1802 | Server sqlserver = null; |
1764 | try | 1803 | try |
1765 | { | 1804 | { |
1766 | - var sc = ServerConnectionPool.GetSqlConnection(sqldbconnectionString,null, grantoruser, grantoruserpsw); | 1805 | + var sc = ServerConnectionPool.GetSqlConnection(sqldbconnectionString, sqldbname, grantoruser, grantoruserpsw); |
1767 | sqlserver = SQLServerConnect(sc); if (sqlserver == null) return; | 1806 | sqlserver = SQLServerConnect(sc); if (sqlserver == null) return; |
1768 | Login login = new Login(sqlserver, name); | 1807 | Login login = new Login(sqlserver, name); |
1769 | login.LoginType = logintype; | 1808 | login.LoginType = logintype; |
@@ -1782,14 +1821,14 @@ GO | @@ -1782,14 +1821,14 @@ GO | ||
1782 | } | 1821 | } |
1783 | finally { sqlserver?.ConnectionContext.SqlConnectionObject.Dispose(); } | 1822 | finally { sqlserver?.ConnectionContext.SqlConnectionObject.Dispose(); } |
1784 | } | 1823 | } |
1785 | - public static void CreateServerAndDBLogins(bool emulation, string sqlcs, string[] usernamelist,string[] serverloginrolelist, string[] dbloginrolelist) | 1824 | + public static void CreateServerAndDBLogins(bool emulation, string sqlcs,string dbname, string[] usernamelist,string[] serverloginrolelist, string[] dbloginrolelist) |
1786 | { | 1825 | { |
1787 | foreach (var username in usernamelist) | 1826 | foreach (var username in usernamelist) |
1788 | { | 1827 | { |
1789 | ColorConsole.WriteLine(username, ConsoleColor.Yellow, prefix: nameof(SQLDataBaseManagerCore.CreateServerAndDBLogins) + ":"); | 1828 | ColorConsole.WriteLine(username, ConsoleColor.Yellow, prefix: nameof(SQLDataBaseManagerCore.CreateServerAndDBLogins) + ":"); |
1790 | - try { if (!emulation) SQLDataBaseManagerCore.CreateLogin(sqlcs, username, null, "master", LoginType.WindowsUser, serverloginrolelist); } | 1829 | + try { if (!emulation) SQLDataBaseManagerCore.CreateLogin(sqlcs, dbname, username, null, "master", LoginType.WindowsUser, serverloginrolelist); } |
1791 | catch (Exception ex) { ColorConsole.WriteLine(nameof(SQLDataBaseManagerCore.CreateLogin) + ">>>: " + ex.MessageNested(), ConsoleColor.Red); } | 1830 | catch (Exception ex) { ColorConsole.WriteLine(nameof(SQLDataBaseManagerCore.CreateLogin) + ">>>: " + ex.MessageNested(), ConsoleColor.Red); } |
1792 | - try { if (!emulation) SQLDataBaseManagerCore.CreateUser(sqlcs, username, string.Join(",", dbloginrolelist), "w"); } | 1831 | + try { if (!emulation) SQLDataBaseManagerCore.CreateUser(sqlcs, dbname, username, string.Join(",", dbloginrolelist), "w"); } |
1793 | catch (Exception ex) { ColorConsole.WriteLine(nameof(SQLDataBaseManagerCore.CreateUser) + "\n" + ex.MessageNested(), ConsoleColor.Red); } | 1832 | catch (Exception ex) { ColorConsole.WriteLine(nameof(SQLDataBaseManagerCore.CreateUser) + "\n" + ex.MessageNested(), ConsoleColor.Red); } |
1794 | } | 1833 | } |
1795 | } | 1834 | } |
@@ -1925,7 +1964,12 @@ GO | @@ -1925,7 +1964,12 @@ GO | ||
1925 | var sqlcb = new SqlConnectionStringBuilder(cs); | 1964 | var sqlcb = new SqlConnectionStringBuilder(cs); |
1926 | return sqlcb.InitialCatalog; | 1965 | return sqlcb.InitialCatalog; |
1927 | } | 1966 | } |
1928 | - public static string GetDataSource(string cs) | 1967 | + public static string GetDBServerName(string cs) |
1968 | + { | ||
1969 | + var sqlcb = new SqlConnectionStringBuilder(cs); | ||
1970 | + return sqlcb. DataSource; | ||
1971 | + } | ||
1972 | + public static string GetDataSource(string cs) | ||
1929 | { | 1973 | { |
1930 | var sqlcb = new SqlConnectionStringBuilder(cs); | 1974 | var sqlcb = new SqlConnectionStringBuilder(cs); |
1931 | return sqlcb.DataSource; | 1975 | return sqlcb.DataSource; |
@@ -2635,6 +2679,7 @@ GO | @@ -2635,6 +2679,7 @@ GO | ||
2635 | public int Xml_ScriptCommandTimeout; | 2679 | public int Xml_ScriptCommandTimeout; |
2636 | public int Xml_BackupTimeout; | 2680 | public int Xml_BackupTimeout; |
2637 | 2681 | ||
2682 | + public string Xml_PrimaryDB_ServerName; | ||
2638 | public string Xml_PrimaryDB_SQLConnectionString; | 2683 | public string Xml_PrimaryDB_SQLConnectionString; |
2639 | public string Xml_PrimaryDB_TranzitDirectoryPath; | 2684 | public string Xml_PrimaryDB_TranzitDirectoryPath; |
2640 | public bool Xml_PrimaryDB_IsUseTranzit { get { return !string.IsNullOrWhiteSpace(Xml_PrimaryDB_TranzitDirectoryPath); } } | 2685 | public bool Xml_PrimaryDB_IsUseTranzit { get { return !string.IsNullOrWhiteSpace(Xml_PrimaryDB_TranzitDirectoryPath); } } |
@@ -2675,9 +2720,12 @@ GO | @@ -2675,9 +2720,12 @@ GO | ||
2675 | } | 2720 | } |
2676 | } | 2721 | } |
2677 | 2722 | ||
2723 | + public string Xml_SecondaryDB_ServerName; | ||
2678 | public string Xml_SecondaryDB_SQLConnectionString; | 2724 | public string Xml_SecondaryDB_SQLConnectionString; |
2679 | public string Xml_SecondaryDB_TranzitDirectoryPath; | 2725 | public string Xml_SecondaryDB_TranzitDirectoryPath; |
2680 | - public bool Xml_SecondaryDB_IsUseTranzit { get { return !string.IsNullOrWhiteSpace(Xml_SecondaryDB_TranzitDirectoryPath); } } | 2726 | + |
2727 | + public bool Xml_SecondaryDB_IsDefined { get { return !string.IsNullOrWhiteSpace(Xml_SecondaryDB_SQLConnectionString); } } | ||
2728 | + public bool Xml_SecondaryDB_IsUseTranzit { get { return !string.IsNullOrWhiteSpace(Xml_SecondaryDB_TranzitDirectoryPath); } } | ||
2681 | public string Xml_SecondaryDB_PhysicalFilesDirectoryPath; | 2729 | public string Xml_SecondaryDB_PhysicalFilesDirectoryPath; |
2682 | public string SQLCS_Secondary | 2730 | public string SQLCS_Secondary |
2683 | { | 2731 | { |
@@ -2698,9 +2746,11 @@ GO | @@ -2698,9 +2746,11 @@ GO | ||
2698 | public string DataSource; | 2746 | public string DataSource; |
2699 | public SQLDBStatus Status; | 2747 | public SQLDBStatus Status; |
2700 | public string PrimaryDB_PhysicalFilesDirectoryPath; | 2748 | public string PrimaryDB_PhysicalFilesDirectoryPath; |
2701 | - public string SizeString; | ||
2702 | - #endregion fields | ||
2703 | - public enum SQLDBStatus { NoAccess, OK, } | 2749 | + public string SecondaryDB_PhysicalFilesDirectoryPath; |
2750 | + public string SizeString_Primary; | ||
2751 | + public string SizeString_Secondary; | ||
2752 | + #endregion fields | ||
2753 | + public enum SQLDBStatus { NoAccess, OK, } | ||
2704 | 2754 | ||
2705 | #region CollectInfo | 2755 | #region CollectInfo |
2706 | public SQLDataBase CollectInfo() | 2756 | public SQLDataBase CollectInfo() |
@@ -2725,8 +2775,9 @@ GO | @@ -2725,8 +2775,9 @@ GO | ||
2725 | } | 2775 | } |
2726 | else | 2776 | else |
2727 | { | 2777 | { |
2728 | - GetPhysicalFilesLocationAndSize(this.SQLCS_Primary, out this.SizeString, out this.PrimaryDB_PhysicalFilesDirectoryPath); | ||
2729 | - this.Status = this.PrimaryDB_PhysicalFilesDirectoryPath.StartsWith("ERR") ? SQLDBStatus.NoAccess : SQLDBStatus.OK; | 2778 | + GetPhysicalFilesLocationAndSize(this.SQLCS_Primary, out this.SizeString_Primary, out this.PrimaryDB_PhysicalFilesDirectoryPath); |
2779 | + GetPhysicalFilesLocationAndSize(this.SQLCS_Secondary, out this.SizeString_Secondary, out this.SecondaryDB_PhysicalFilesDirectoryPath); | ||
2780 | + this.Status = this.PrimaryDB_PhysicalFilesDirectoryPath.StartsWith("ERR") ? SQLDBStatus.NoAccess : SQLDBStatus.OK; | ||
2730 | this.DBName = SQLDataBaseManagerCore.GetDBName(this.SQLCS_Primary); | 2781 | this.DBName = SQLDataBaseManagerCore.GetDBName(this.SQLCS_Primary); |
2731 | this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS_Primary); | 2782 | this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS_Primary); |
2732 | } | 2783 | } |
@@ -2736,10 +2787,12 @@ GO | @@ -2736,10 +2787,12 @@ GO | ||
2736 | { | 2787 | { |
2737 | this.Status = SQLDBStatus.NoAccess; | 2788 | this.Status = SQLDBStatus.NoAccess; |
2738 | this.PrimaryDB_PhysicalFilesDirectoryPath = ""; | 2789 | this.PrimaryDB_PhysicalFilesDirectoryPath = ""; |
2790 | + this.SecondaryDB_PhysicalFilesDirectoryPath = ""; | ||
2739 | this.DBName = ""; | 2791 | this.DBName = ""; |
2740 | this.DataSource = ""; | 2792 | this.DataSource = ""; |
2741 | - this.SizeString = ""; | ||
2742 | - try | 2793 | + this.SizeString_Primary = ""; |
2794 | + this.SizeString_Secondary = ""; | ||
2795 | + try | ||
2743 | { | 2796 | { |
2744 | this.DBName = SQLDataBaseManagerCore.GetDBName(this.SQLCS_Primary); | 2797 | this.DBName = SQLDataBaseManagerCore.GetDBName(this.SQLCS_Primary); |
2745 | this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS_Primary); | 2798 | this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS_Primary); |
@@ -2760,6 +2813,7 @@ GO | @@ -2760,6 +2813,7 @@ GO | ||
2760 | { | 2813 | { |
2761 | dbsizetext = null; | 2814 | dbsizetext = null; |
2762 | dbpathtext = null; | 2815 | dbpathtext = null; |
2816 | + if (string.IsNullOrWhiteSpace(sqlconnectionstring)) { return; } | ||
2763 | try | 2817 | try |
2764 | { | 2818 | { |
2765 | var sqlc = ServerConnectionPool.GetSqlConnection(sqlconnectionstring,open:true); | 2819 | var sqlc = ServerConnectionPool.GetSqlConnection(sqlconnectionstring,open:true); |
@@ -2821,9 +2875,11 @@ GO | @@ -2821,9 +2875,11 @@ GO | ||
2821 | Xml_RestoreFileNameMask = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.RestoreFileNameMask), sqldatabasexml, common.Xml_RestoreFileNameMask); | 2875 | Xml_RestoreFileNameMask = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.RestoreFileNameMask), sqldatabasexml, common.Xml_RestoreFileNameMask); |
2822 | Xml_BackupTargetDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.BackupTargetDirectoryPath), sqldatabasexml, common.Xml_BackupTargetDirectoryPath); | 2876 | Xml_BackupTargetDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.BackupTargetDirectoryPath), sqldatabasexml, common.Xml_BackupTargetDirectoryPath); |
2823 | Xml_PrimaryDB_TranzitDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.TranzitDirectoryNetworkPath), sqldatabasexml, common.Xml_PrimaryDB_TranzitDirectoryPath); | 2877 | Xml_PrimaryDB_TranzitDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.TranzitDirectoryNetworkPath), sqldatabasexml, common.Xml_PrimaryDB_TranzitDirectoryPath); |
2878 | + Xml_PrimaryDB_ServerName = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.Server), sqldatabasexml, XmlStructure.SQLDataBase.Attributes.Server.Values.DEFAULT); | ||
2824 | Xml_PrimaryDB_SQLConnectionString = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.SQLConnectionString), sqldatabasexml, XmlStructure.SQLDataBase.Attributes.SQLConnectionString.Values.DEFAULT); | 2879 | Xml_PrimaryDB_SQLConnectionString = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.SQLConnectionString), sqldatabasexml, XmlStructure.SQLDataBase.Attributes.SQLConnectionString.Values.DEFAULT); |
2825 | 2880 | ||
2826 | var secdbxml = GetXElement(sqldatabasexml,nameof(XmlStructure.SQLDataBase.SecondaryDB)); | 2881 | var secdbxml = GetXElement(sqldatabasexml,nameof(XmlStructure.SQLDataBase.SecondaryDB)); |
2882 | + Xml_SecondaryDB_ServerName = GetValue(nameof(XmlStructure.SQLDataBase.SecondaryDB.Attributes.Server), secdbxml, ""); | ||
2827 | Xml_SecondaryDB_SQLConnectionString = GetValue(nameof(XmlStructure.SQLDataBase.SecondaryDB.Attributes.SQLConnectionString), secdbxml, ""); | 2883 | Xml_SecondaryDB_SQLConnectionString = GetValue(nameof(XmlStructure.SQLDataBase.SecondaryDB.Attributes.SQLConnectionString), secdbxml, ""); |
2828 | Xml_SecondaryDB_TranzitDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.SecondaryDB.Attributes.TranzitDirectoryNetworkPath), secdbxml, ""); | 2884 | Xml_SecondaryDB_TranzitDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.SecondaryDB.Attributes.TranzitDirectoryNetworkPath), secdbxml, ""); |
2829 | Xml_SecondaryDB_PhysicalFilesDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.SecondaryDB.Attributes.PhysicalFilesDirectoryPath), secdbxml, ""); | 2885 | Xml_SecondaryDB_PhysicalFilesDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.SecondaryDB.Attributes.PhysicalFilesDirectoryPath), secdbxml, ""); |
@@ -2899,6 +2955,7 @@ GO | @@ -2899,6 +2955,7 @@ GO | ||
2899 | { | 2955 | { |
2900 | public static class Key { public static class Values { public const string DEFAULT = ""; } } | 2956 | public static class Key { public static class Values { public const string DEFAULT = ""; } } |
2901 | public static class Description { } | 2957 | public static class Description { } |
2958 | + public static class Server { public static class Values { public const string DEFAULT = ""; } } | ||
2902 | public static class SQLConnectionString { public static class Values { public const string DEFAULT = ""; } } | 2959 | public static class SQLConnectionString { public static class Values { public const string DEFAULT = ""; } } |
2903 | public static class BackupFileNameMask { } | 2960 | public static class BackupFileNameMask { } |
2904 | public static class RestoreFileNameMask { } | 2961 | public static class RestoreFileNameMask { } |
@@ -2976,9 +3033,11 @@ GO | @@ -2976,9 +3033,11 @@ GO | ||
2976 | { | 3033 | { |
2977 | public static class Attributes | 3034 | public static class Attributes |
2978 | { | 3035 | { |
3036 | + public static class TranzitDirectoryLocalPath { public static class Values { public const string DEFAULT = ""; } } | ||
2979 | public static class TranzitDirectoryNetworkPath { public static class Values { public const string DEFAULT = ""; } } | 3037 | public static class TranzitDirectoryNetworkPath { public static class Values { public const string DEFAULT = ""; } } |
2980 | public static class PhysicalFilesDirectoryPath { public static class Values { public const string DEFAULT = ""; } } | 3038 | public static class PhysicalFilesDirectoryPath { public static class Values { public const string DEFAULT = ""; } } |
2981 | public static class SQLConnectionString { public static class Values { public const string DEFAULT = null; } } | 3039 | public static class SQLConnectionString { public static class Values { public const string DEFAULT = null; } } |
3040 | + public static class Server { public static class Values { public const string DEFAULT = null; } } | ||
2982 | } | 3041 | } |
2983 | } | 3042 | } |
2984 | } | 3043 | } |
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.32.0.0")] | ||
36 | -[assembly: AssemblyFileVersion("1.32.0.0")] | 35 | +[assembly: AssemblyVersion("1.33.0.0")] |
36 | +[assembly: AssemblyFileVersion("1.33.0.0")] |