Commit 066d5d55548f5843f3e5570f23664f47a5a9d3e9

Authored by Schwirg László
1 parent 31cca809

v1.32.0

- MoveSQLDB from PRIMARY to SECONDARY rendbehozása
Vrh.Log4Pro.MaintenanceConsole/Manager - SQLDataBaseManager.cs
... ... @@ -64,7 +64,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
64 64 .AddMenuItem(new Menu.Item(CLP.Module.SQLDataBaseManager.Function.CreateLoginAndUser.KEY, "Create Server login", CreateServerLogin, ep))
65 65 .AddMenuItem(new Menu.Item(CLP.Module.SQLDataBaseManager.Function.AddUserForLogin.KEY, "Create DB user", CreateDBUser, ep))
66 66 .AddMenuItem(new Menu.Item(CLP.Module.SQLDataBaseManager.Function.CreateLastUpdatedTrigger.KEY, "Add/remove LastUpdated trigger to a datatable column", ManageLastUpdatedTrigger, ep))
67   - .AddMenuItem(new Menu.Item(CLP.Module.SQLDataBaseManager.Function.MoveDbToRemoteServer.KEY, "Move DB from local to remote server", MoveDbToRemoteServer, ep))
  67 + .AddMenuItem(new Menu.Item(CLP.Module.SQLDataBaseManager.Function.MoveDbToRemoteServer.KEY, "Move DB from local to remote server", MoveDbFromPrimaryToSecondary, ep))
68 68 .SetSelectionMode(Menu.SelectionMode.Single)
69 69 .SetMenuHeaderDisplayer(DataBaseListDisplayer);
70 70 menufunctions.ExecuteMenu(functionkey);
... ... @@ -186,7 +186,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
186 186 try
187 187 {
188 188 if (NoDBNameSpecified(sqld)) { return o; }
189   - var targetdirectorypath = sqld.Xml_PhysicalFilesDirectoryPath;
  189 + var targetdirectorypath = sqld.Xml_PrimaryDB_PhysicalFilesDirectoryPath;
190 190 var targetdbname = sqld.DBName;
191 191 bool restorefromzip = sqld.Xml_CreateZip;
192 192 var backupfilelist = SQLDataBaseManagerCore.GetBackupFilePathList(sqld);
... ... @@ -338,7 +338,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
338 338 bool allconfirmed = false;
339 339 foreach (var SrvrLoginToExecute in ServerLoginsToExecuteList)
340 340 {
341   - var retcode = ExecuteOneServerLogin(sqld.SQLCS, SrvrLoginToExecute, allconfirmed);
  341 + var retcode = ExecuteOneServerLogin(sqld.SQLCS_Primary, SrvrLoginToExecute, allconfirmed);
342 342 if (retcode == "EX") return o;
343 343 else if (retcode == "ALL") { allconfirmed = true; }
344 344 else if (retcode != null) goto getparametersloop;
... ... @@ -554,7 +554,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
554 554 bool allconfirmed = false;
555 555 foreach (var DbusrToExecute in DbusrToExecuteList)
556 556 {
557   - var retcode = ExecuteOneDBUser(sqld.SQLCS, DbusrToExecute, allconfirmed);
  557 + var retcode = ExecuteOneDBUser(sqld.SQLCS_Primary, DbusrToExecute, allconfirmed);
558 558 if (retcode == "EX") return o;
559 559 else if (retcode == "ALL") { allconfirmed = true; }
560 560 else if (retcode != null) goto getparametersloop;
... ... @@ -616,10 +616,10 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
616 616 catch (Exception e) { ColorConsole.WriteLine("FATAL ERROR! " + e.MessageNested(), ConsoleColor.Red); returntext = null; }
617 617 return returntext;
618 618 }
619   - #endregion CreateDBUser
  619 + #endregion CreateDBUser
620 620  
621   - #region MoveDbToRemoteServer
622   - private static object MoveDbToRemoteServer(object parameter, object o)
  621 + #region MoveDbFromPrimaryToSecondary
  622 + private static object MoveDbFromPrimaryToSecondary(object parameter, object o)
623 623 {
624 624 var config = (parameter as Menu.ExecutorParameter).GetConfig<SQLDataBaseManagerXmlProcessor>();
625 625 var args = (parameter as Menu.ExecutorParameter).Args;
... ... @@ -629,122 +629,113 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS
629 629 while (true)
630 630 {
631 631 var DateTimeNow = DateTime.Now;
632   - SQLDataBase dbfrom = null;
633   - SQLDataBase dbto = null;
  632 + SQLDataBase dbtomove = null;
634 633  
635 634 movedatabaseloop:
636 635 (Menu.SelectionResult selectionresult, bool yes) yesornoanswer = YesOrNo(new List<string>() { $"Do You want to move ANY database from local server to remote server?" });
637 636 if (yesornoanswer.selectionresult == Menu.SelectionResult.Exit) return o;
638 637 if (yesornoanswer.selectionresult == Menu.SelectionResult.Ok && yesornoanswer.yes)
639 638 {
640   - var dbselection = SelectToDbAndFromDb(config, selectedsqldbindexes, $"Select the SQL database(s) to move the first to the second.!");
  639 + var dbselection = SelectDbToMove(config, selectedsqldbindexes, $"Select the SQL database to move from its PRIMARY to SECONDARY location!");
641 640 if (dbselection.selection == Menu.SelectionResult.Exit) { return o; }
642 641 if (dbselection.selection != Menu.SelectionResult.Ok) { goto movedatabaseloop; }
643   - dbfrom = dbselection.dbfrom;
644   - dbto = dbselection.dbto;
645   - if (NoDBNameSpecified(dbfrom) || NoDBNameSpecified(dbto)) { continue; }
  642 + dbtomove = dbselection.dbtomove;
  643 + if (NoDBNameSpecified(dbtomove)) { continue; }
  644 + var dbnameSecondary = SQLDataBaseManagerCore.GetDBName(dbtomove.SQLCS_Secondary);
646 645  
647   - var todbname = ColorConsole.ReadLine($"Enter the name of the target DB. EMPTY={dbto.DBName}, EX=exit.");
  646 + var todbname = ColorConsole.ReadLine($"Enter the name of the target DB. EMPTY={dbnameSecondary}, EX=exit.");
648 647 if (todbname.ToUpper() == "EX") { return o; }
649   - else if (string.IsNullOrWhiteSpace(todbname)) todbname = dbto.DBName;
  648 + else if (string.IsNullOrWhiteSpace(todbname)) todbname = dbnameSecondary;
650 649  
651 650 confirmloop:;
652 651 var confirmtext = ColorConsole.ReadLine("Enter CONFIRM to start, EX to exit, SKIP to skip.");
653 652 if (confirmtext.ToUpper() == "EX") { return o; }
654 653 else if (confirmtext.ToUpper() == "CONFIRM")
655 654 {
656   - var movesuccess = SQLDataBaseManagerCore.MoveDbToRemoteServer(dbfrom, dbto, todbname, false);
  655 + var movesuccess = SQLDataBaseManagerCore.MoveDbFromPrimaryToSecondary(dbtomove, todbname, false);
657 656 if (!movesuccess) continue;
658 657 }
659 658 else if (confirmtext.ToUpper() != "SKIP") { goto confirmloop; };
660 659 }
661 660  
662 661 serverloginloop:
663   - yesornoanswer = YesOrNo(new List<string>() { $"Do You want to create server and DB logins for local and/or remote server/database?", });
  662 + yesornoanswer = YesOrNo(new List<string>() { $"Do You want to create server and DB logins for the server/database PRIMARY and/or SECONDARY locations?", });
664 663 if (yesornoanswer.selectionresult == Menu.SelectionResult.Exit) return o;
665 664 if (yesornoanswer.selectionresult == Menu.SelectionResult.Ok && yesornoanswer.yes)
666 665 {
667   - if (dbfrom == null || dbto == null)
  666 + if (dbtomove == null)
668 667 {
669   - var dbselection = SelectToDbAndFromDb(config, selectedsqldbindexes, $"Select the SQL database(s) to add server and DB logins!");
  668 + var dbselection = SelectDbToMove(config, selectedsqldbindexes, $"Select the SQL database to add server and DB logins to its PRIMARY and its SECONDARY location!");
670 669 if (dbselection.selection == Menu.SelectionResult.Exit) { return o; }
671 670 if (dbselection.selection != Menu.SelectionResult.Ok) { goto serverloginloop; }
672   - dbfrom = dbselection.dbfrom;
673   - dbto = dbselection.dbto;
  671 + dbtomove = dbselection.dbtomove;
674 672 }
675 673 var usernamelist = new string[] { "corplear\\lschwirg", "corplear\\gen_vrhalmadmin", $"corplear\\{Program.ThisComputer.ComputerName}$" };
676 674  
677   - string l1 = $"Do You want to create the following mandatory server and DB logins for SOURCE server and DB?";
678   - string l2 = $" SQL connection string: {dbfrom.SQLCS}";
  675 + 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 677 string l3 = $" Username list: " + string.Join(",", usernamelist);
680 678 yesornoanswer = YesOrNo(new List<string>() { l1, l2, l3, });
681 679 if (yesornoanswer.selectionresult== Menu.SelectionResult.Exit) return o;
682 680 if (yesornoanswer.selectionresult == Menu.SelectionResult.Ok && yesornoanswer.yes)
683 681 {
684   - SQLDataBaseManagerCore.CreateServerAndDBLogins(false, dbfrom.SQLCS, usernamelist, serverloginrolelist, fullaccessdbloginrolelist);
  682 + SQLDataBaseManagerCore.CreateServerAndDBLogins(false, dbtomove.SQLCS_Primary, usernamelist, serverloginrolelist, fullaccessdbloginrolelist);
685 683 }
686 684  
687   - string l13 = $"Do You want to create the following mandatory server and DB logins for TARGET server and DB?";
688   - string l23 = $" SQL connection string: {dbto.SQLCS}";
  685 + 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 687 string l33 = $" Username list: " + string.Join(",", usernamelist);
690 688 yesornoanswer = YesOrNo(new List<string>() { l13,l23,l33,});
691 689 if (yesornoanswer.selectionresult == Menu.SelectionResult.Exit) return o;
692 690 if (yesornoanswer.selectionresult == Menu.SelectionResult.Ok && yesornoanswer.yes)
693 691 {
694   - SQLDataBaseManagerCore.CreateServerAndDBLogins(false, dbto.SQLCS, usernamelist, serverloginrolelist, fullaccessdbloginrolelist);
  692 + SQLDataBaseManagerCore.CreateServerAndDBLogins(false, dbtomove.SQLCS_Secondary, usernamelist, serverloginrolelist, fullaccessdbloginrolelist);
695 693 }
696 694 }
697 695  
698   - yesornoanswer = YesOrNo(new List<string>() { $"Do You want to set database '{SQLDataBaseManagerCore.GetDBName(dbfrom.SQLCS)}' OFFLINE on server '{SQLDataBaseManagerCore.GetDataSource(dbfrom.SQLCS)}'?", });
  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)}'?", });
699 697 if (yesornoanswer.selectionresult == Menu.SelectionResult.Exit) return o;
700 698 if (yesornoanswer.selectionresult == Menu.SelectionResult.Ok && yesornoanswer.yes)
701 699 {
702   - SQLDataBaseManagerCore.SetDatabaseOffline(dbfrom.SQLCS);
  700 + SQLDataBaseManagerCore.SetDatabaseOffline(dbtomove.SQLCS_Primary);
703 701 }
704 702  
705 703 ColorConsole.WriteLine($"Process completed. Required time: {(int)(DateTime.Now.Subtract(DateTimeNow).TotalSeconds)} seconds.", ConsoleColor.Green);
706 704 }
707 705 }
708   - private static (Menu.SelectionResult selection,SQLDataBase dbfrom,SQLDataBase dbto) SelectToDbAndFromDb(SQLDataBaseManagerXmlProcessor config, string selectedsqldbindexes, string databaseselectionheadertext)
  706 + private static (Menu.SelectionResult selection,SQLDataBase dbtomove) SelectDbToMove(SQLDataBaseManagerXmlProcessor config, string selectedsqldbindexes, string databaseselectionheadertext)
709 707 {
710   - var menufolders = DisplaySQLDataBaseMenu(config, $"{databaseselectionheadertext} Format:FROMLOCALDB,TOREMOTEDB", silent: true, selectionmode: Menu.SelectionMode.Multi);
  708 + var menufolders = DisplaySQLDataBaseMenu(config, $"{databaseselectionheadertext} Format:DB", silent: true, selectionmode: Menu.SelectionMode.Single);
711 709 Menu.Selection sr = menufolders.Select(selectedsqldbindexes);
712   - if (sr.Result == Menu.SelectionResult.Exit) { return (Menu.SelectionResult.Exit, null,null); }
713   - else if (sr.Result == Menu.SelectionResult.None) { return (Menu.SelectionResult.None, null,null); }
714   - else if (sr.Result == Menu.SelectionResult.Error) { return (Menu.SelectionResult.Error, null, null); }
715   - else if (sr.Result == Menu.SelectionResult.Ok && sr.SelectedParameterList.FirstOrDefault() == null) { return (Menu.SelectionResult.Error, null, null); }
716   - else if (sr.Result == Menu.SelectionResult.Ok && sr.SelectedParameterList.Count() != 2)
  710 + if (sr.Result == Menu.SelectionResult.Exit) { return (Menu.SelectionResult.Exit, null); }
  711 + else if (sr.Result == Menu.SelectionResult.None) { return (Menu.SelectionResult.None, null); }
  712 + else if (sr.Result == Menu.SelectionResult.Error) { return (Menu.SelectionResult.Error, null); }
  713 + else if (sr.Result == Menu.SelectionResult.Ok && sr.SelectedParameterList.FirstOrDefault() == null) { return (Menu.SelectionResult.Error, null); }
  714 + else if (sr.Result == Menu.SelectionResult.Ok && sr.SelectedParameterList.Count() != 1)
717 715 {
718   - ColorConsole.WriteLine($"Select exactly 2 DB. Format:FROMLOCALDB,TOREMOTEDB", ConsoleColor.Red);
719   - return (Menu.SelectionResult.Error, null, null);
  716 + ColorConsole.WriteLine($"Select only one DB. Format:DB", ConsoleColor.Red);
  717 + return (Menu.SelectionResult.Error, null);
720 718 }
721 719 else if (sr.Result == Menu.SelectionResult.Ok) { }
722 720 else { }
723   - var spfrom = sr.SelectedParameterList.First();
724   - var spto = sr.SelectedParameterList.ElementAt(1);
725   - SQLDataBase dbfrom = spfrom.Parameters as SQLDataBase;
726   - SQLDataBase dbto = spto.Parameters as SQLDataBase;
727   - if (!dbto.Xml_IsRemoteDB)
  721 + var spdb = sr.SelectedParameterList.First();
  722 + SQLDataBase dbtomove = spdb.Parameters as SQLDataBase;
  723 + if (string.IsNullOrWhiteSpace(dbtomove.Xml_SecondaryDB_SQLConnectionString))
728 724 {
729   - ColorConsole.WriteLine($"TOREMOTEDB '{dbto.SQLCS}' has to be remote!", ConsoleColor.Red);
730   - return (Menu.SelectionResult.Error, null, null);
  725 + ColorConsole.WriteLine($"No SECONDARY db is specified!", ConsoleColor.Red);
  726 + return (Menu.SelectionResult.Error, null);
731 727 }
732   - if (dbfrom.Xml_IsRemoteDB)
733   - {
734   - ColorConsole.WriteLine($"FROMLOCALDB '{dbfrom.SQLCS}' has to be local!", ConsoleColor.Red);
735   - return (Menu.SelectionResult.Error, null, null);
736   - }
737   - return (Menu.SelectionResult.Ok, dbfrom,dbto);
  728 + return (Menu.SelectionResult.Ok, dbtomove);
738 729 }
739 730 private static (Menu.SelectionResult selectionresult, bool yes) YesOrNo(List<string> questiontextLines)
740 731 {
741 732 if (questiontextLines!=null) foreach(string l in questiontextLines) { ColorConsole.WriteLine(l, ConsoleColor.Yellow); }
742 733 var yesorno = ColorConsole.ReadLine("Do action?", ConsoleColor.Yellow, validitylist: new List<string> { "yes", "no" }, defaultvalue: "yes");
743 734 if (yesorno.ToUpper() == "EX") return (Menu.SelectionResult.Exit, false);
744   - else if (yesorno.ToUpper() == "yes") return (Menu.SelectionResult.Ok, true);
  735 + else if (yesorno.ToUpper() == "YES") return (Menu.SelectionResult.Ok, true);
745 736 else return (Menu.SelectionResult.Ok, false);
746 737 }
747   - #endregion MoveDbToRemoteServer
  738 + #endregion MoveDbFromPrimaryToSecondary
748 739  
749 740 #region ManageLastUpdatedTrigger
750 741 private static object ManageLastUpdatedTrigger(object parameter, object o) { return _ManageLastUpdatedTrigger(parameter, o, null); }
... ... @@ -908,7 +899,7 @@ GO
908 899 bool allconfirmed = false;
909 900 foreach (var triggertoexecute in TriggerToExecuteList)
910 901 {
911   - var retcode = ExecuteOneLastUpdateTrigger(sqld.SQLCS, triggertoexecute, allconfirmed);
  902 + var retcode = ExecuteOneLastUpdateTrigger(sqld.SQLCS_Primary, triggertoexecute, allconfirmed);
912 903 if (retcode == "EX") return o;
913 904 else if (retcode == "ALL") { allconfirmed = true; }
914 905 else if (retcode != null) goto getparametersloop;
... ... @@ -1118,7 +1109,7 @@ GO
1118 1109 }
1119 1110 if (string.IsNullOrWhiteSpace(dbnamemask)) { dbnamemask = ""; }
1120 1111  
1121   - var dbdescriptordict = SQLDataBaseManagerCore.GetDatabases(sqld.SQLCS, dbnamemask, userid, password);
  1112 + var dbdescriptordict = SQLDataBaseManagerCore.GetDatabases(sqld.SQLCS_Primary, dbnamemask, userid, password);
1122 1113 ColorConsole.WriteLine(text: "Available DBs", f: ConsoleColor.Yellow,suffix: $" (name masked with:'{dbnamemask}')");
1123 1114 foreach (var (dbdescriptor,ix) in dbdescriptordict.Select((text,ix)=> (text, ix)))
1124 1115 {
... ... @@ -1140,7 +1131,7 @@ GO
1140 1131 if (string.IsNullOrWhiteSpace(dbname)) { dbname = sqld.DBName; }
1141 1132  
1142 1133 ColorConsole.WriteLine($"Dropping DB...");
1143   - ColorConsole.WriteLine(prefix: " connection string to server:", text: sqld.SQLCS, bracket: "[]", f: ConsoleColor.Yellow);
  1134 + ColorConsole.WriteLine(prefix: " connection string to server:", text: sqld.SQLCS_Primary, bracket: "[]", f: ConsoleColor.Yellow);
1144 1135 ColorConsole.WriteLine(prefix: " DB name to drop:", text: dbname, bracket: "[]", f: ConsoleColor.Yellow);
1145 1136 ColorConsole.WriteLine(prefix: " userid:", text: userid ?? "-", bracket: "[]", f: ConsoleColor.Yellow);
1146 1137 ColorConsole.WriteLine(prefix: " user psw:", text: password ?? "-", bracket: "[]", f: ConsoleColor.Yellow);
... ... @@ -1148,7 +1139,7 @@ GO
1148 1139 if (confirmation.ToUpper() == "EX") { continue; }
1149 1140 else if (confirmation.ToUpper() != "CONFIRM") { continue; }
1150 1141  
1151   - var success = SQLDataBaseManagerCore.DropDatabase(sqld.SQLCS, dbname, userid, password);
  1142 + var success = SQLDataBaseManagerCore.DropDatabase(sqld.SQLCS_Primary, dbname, userid, password);
1152 1143 if (success) { ColorConsole.WriteLine($"SUCCESS! Database dropped. Name:{dbname}", ConsoleColor.Green); }
1153 1144 else { ColorConsole.WriteLine($"FAILURE! Database is NOT dropped. Name:{dbname}", ConsoleColor.Red); }
1154 1145 }
... ... @@ -1193,7 +1184,7 @@ GO
1193 1184 var shrinkmethod = (ShrinkMethod)Enum.Parse(typeof(ShrinkMethod), option);
1194 1185 if (string.IsNullOrWhiteSpace(fsp) || !int.TryParse(fsp, out fspint)) { fspint = 10; }
1195 1186  
1196   - SQLDataBaseManagerCore.ShrinkDB(sqld.SQLCS, shrinkmethod, fspint);
  1187 + SQLDataBaseManagerCore.ShrinkDB(sqld.SQLCS_Primary, shrinkmethod, fspint);
1197 1188 ColorConsole.WriteLine($"Database shrinked. Name:{sqld.DBName}", ConsoleColor.Green);
1198 1189 }
1199 1190 catch (Exception ex) { ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red); }
... ... @@ -1225,15 +1216,15 @@ GO
1225 1216 if (restoredbname.ToUpper() == "EX") { continue; }
1226 1217 else if (string.IsNullOrWhiteSpace(restoredbname)) { restoredbname = sqld.DBName; }
1227 1218 ColorConsole.WriteLine("Enter the path for the DB physical files.", ConsoleColor.Yellow);
1228   - var PhysicalFilesDirectoryPathcolor = sqld.PhysicalFilesDirectoryPath.StartsWith("ERR") ? ConsoleColor.Red : ConsoleColor.Yellow;
1229   - ColorConsole.WriteLine(sqld.PhysicalFilesDirectoryPath, PhysicalFilesDirectoryPathcolor, prefix: $" Empty=current location of source DB: ", bracket: "[]");
1230   - ColorConsole.WriteLine(SQLDataBaseManagerCore.GetServerDefaultPhysicalDATFileLocation(sqld.SQLCS)??"???", ConsoleColor.Yellow,prefix: $" DEFAULT= sql server default location.",bracket:"[]");
  1219 + var PhysicalFilesDirectoryPathcolor = sqld.PrimaryDB_PhysicalFilesDirectoryPath.StartsWith("ERR") ? ConsoleColor.Red : ConsoleColor.Yellow;
  1220 + ColorConsole.WriteLine(sqld.PrimaryDB_PhysicalFilesDirectoryPath, PhysicalFilesDirectoryPathcolor, prefix: $" Empty=current location of source DB: ", bracket: "[]");
  1221 + ColorConsole.WriteLine(SQLDataBaseManagerCore.GetServerDefaultPhysicalDATFileLocation(sqld.SQLCS_Primary)??"???", ConsoleColor.Yellow,prefix: $" DEFAULT= sql server default location.",bracket:"[]");
1231 1222 var targetdirectory = ColorConsole.ReadLine($"Enter the target path.EX=exit.", ConsoleColor.Yellow, suffix: " --> ");
1232 1223 if (targetdirectory.ToUpper() == "EX") { continue; }
1233 1224 else if (targetdirectory == "DEFAULT") { targetdirectory = null; ; }
1234   - else if (string.IsNullOrWhiteSpace(targetdirectory)) { targetdirectory = sqld.PhysicalFilesDirectoryPath; }
  1225 + else if (string.IsNullOrWhiteSpace(targetdirectory)) { targetdirectory = sqld.PrimaryDB_PhysicalFilesDirectoryPath; }
1235 1226  
1236   - if (restoredbname == sqld.DBName && targetdirectory == sqld.PhysicalFilesDirectoryPath) { continue; }
  1227 + if (restoredbname == sqld.DBName && targetdirectory == sqld.PrimaryDB_PhysicalFilesDirectoryPath) { continue; }
1237 1228  
1238 1229 SQLDataBaseManagerCore.RelocatePhysicalFiles(sqld, targetdirectory, restoredbname);
1239 1230 ColorConsole.WriteLine($"Database physical files relocated. Name:{sqld.DBName}", ConsoleColor.Green);
... ... @@ -1248,7 +1239,7 @@ GO
1248 1239 private static bool NoDBNameSpecified(SQLDataBase ssqldb)
1249 1240 {
1250 1241 const string FUNNOTAVAILTXT = "Function is not available for server connection strings wit no DB name specified!";
1251   - if (string.IsNullOrWhiteSpace(SQLDataBaseManagerCore.GetDBName(ssqldb.SQLCS))) { ColorConsole.WriteLine(FUNNOTAVAILTXT, ConsoleColor.Red); ssqldb.DBName = "master"; return true; }
  1242 + if (string.IsNullOrWhiteSpace(SQLDataBaseManagerCore.GetDBName(ssqldb.SQLCS_Primary))) { ColorConsole.WriteLine(FUNNOTAVAILTXT, ConsoleColor.Red); ssqldb.DBName = "master"; return true; }
1252 1243 return false;
1253 1244 }
1254 1245 public static void Execute(string key, bool enabledbbackup, bool enablescriptbackup, bool enabletabledatabackup, string targetfolder=null,DateTime? timestamp = null)
... ... @@ -1259,7 +1250,7 @@ GO
1259 1250 if (origsqld != null)
1260 1251 {
1261 1252 var sqld = new SQLDataBase(origsqld);
1262   - var dbname = SQLDataBaseManagerCore.GetDBName(sqld.SQLCS);
  1253 + var dbname = SQLDataBaseManagerCore.GetDBName(sqld.SQLCS_Primary);
1263 1254 ColorConsole.WriteLine($"Database backup process started. DB key:'{key}', name:'{dbname}'...", ConsoleColor.Yellow);
1264 1255 if (!string.IsNullOrWhiteSpace(targetfolder)) { sqld.Xml_BackupTargetDirectoryPath = targetfolder; }
1265 1256 if (enabledbbackup) { SQLDataBaseManagerCore.CreateBackup(sqld,null, timestamp); }
... ... @@ -1303,7 +1294,7 @@ GO
1303 1294 if (st.Status != SQLDataBase.SQLDBStatus.NoAccess)
1304 1295 {
1305 1296 }
1306   - if (st.Xml_IsRemoteDB) { ColorConsole.Write("REMOTE", ConsoleColor.Cyan, bracket: "[]", prefix: "", suffix: ""); }
  1297 + if (st.Xml_PrimaryDB_IsUseTranzit) { ColorConsole.Write("REMOTE", ConsoleColor.Cyan, bracket: "[]", prefix: "", suffix: ""); }
1307 1298 ColorConsole.WriteLine();
1308 1299 return Menu.MenuItemDisplayerReturnValue.NEXTLINE;
1309 1300 }
... ... @@ -1316,16 +1307,16 @@ GO
1316 1307 }
1317 1308 else if (lineix == 2)
1318 1309 {
1319   - if (!st.isSQLCSselected) { return Menu.MenuItemDisplayerReturnValue.SAMELINE; }
1320   - ColorConsole.Write($"{st.SQLCS}", ConsoleColor.Yellow, prefix: "SQL DB connection:", suffix: ", ");
  1310 + if (!st.is_PrimaryDB_SQLCSselected) { return Menu.MenuItemDisplayerReturnValue.SAMELINE; }
  1311 + ColorConsole.Write($"{st.SQLCS_Primary}", ConsoleColor.Yellow, prefix: "SQL DB connection:", suffix: ", ");
1321 1312 ColorConsole.WriteLine(" ");
1322 1313 return Menu.MenuItemDisplayerReturnValue.NEXTLINE;
1323 1314 }
1324 1315 else if (lineix == 3)
1325 1316 {
1326 1317 if (string.IsNullOrWhiteSpace(st.DBName)) return Menu.MenuItemDisplayerReturnValue.SAMELINE;
1327   - var PhysicalFilesDirectoryPathcolor = st.PhysicalFilesDirectoryPath.StartsWith("ERR") ? ConsoleColor.Red : ConsoleColor.Yellow;
1328   - ColorConsole.Write($"{st.PhysicalFilesDirectoryPath}", PhysicalFilesDirectoryPathcolor, prefix: "DB files physical location:", suffix: " ");
  1318 + var PhysicalFilesDirectoryPathcolor = st.PrimaryDB_PhysicalFilesDirectoryPath.StartsWith("ERR") ? ConsoleColor.Red : ConsoleColor.Yellow;
  1319 + ColorConsole.Write($"{st.PrimaryDB_PhysicalFilesDirectoryPath}", PhysicalFilesDirectoryPathcolor, prefix: "DB files physical location:", suffix: " ");
1329 1320 ColorConsole.WriteLine(" ");
1330 1321 return Menu.MenuItemDisplayerReturnValue.NEXTLINE;
1331 1322 }
... ... @@ -1374,45 +1365,45 @@ GO
1374 1365 /// <summary>
1375 1366 /// Egy adatbázis átmozgatása egy távoli szerverre
1376 1367 /// </summary>
1377   - /// <param name="dbfrom"></param>
  1368 + /// <param name="dbtomove"></param>
1378 1369 /// <param name="dbto"></param>
1379 1370 /// <param name="selecteddbname"></param>
1380 1371 /// <param name="emulation"></param>
1381 1372 /// <returns></returns>
1382   - public static bool MoveDbToRemoteServer(SQLDataBase dbfrom, SQLDataBase dbto, string selecteddbname, bool emulation)
  1373 + public static bool MoveDbFromPrimaryToSecondary(SQLDataBase dbtomove, string selecteddbname, bool emulation)
1383 1374 {
1384 1375 //backup dbfrom
1385 1376 var DateTimeNow = DateTime.Now;
1386   - var backupfileFullname = SQLDataBaseManagerCore.CreateBackup(dbfrom, false, DateTimeNow, emulation);
1387   - //move dbfrom to tranit area
  1377 + var backupfileFullname = SQLDataBaseManagerCore.CreateBackup(dbtomove, false, DateTimeNow, emulation);
1388 1378  
1389 1379 if (!emulation && !File.Exists(backupfileFullname)) { return false; }
1390 1380  
1391   - string backupfileFilename = null;
1392   - string tranzitfileFullname = null;
1393   - try
  1381 + string tranzitfileFullname = backupfileFullname;
  1382 + if (dbtomove.Xml_SecondaryDB_IsUseTranzit)
1394 1383 {
1395   - backupfileFilename = Path.GetFileName(backupfileFullname);
1396   - tranzitfileFullname = Path.Combine(dbto.Xml_TranzitDirectoryPath, backupfileFilename);
1397   - ColorConsole.WriteLine($"Moving backup file {backupfileFullname} to tranzit location: {dbto.Xml_TranzitDirectoryPath}", ConsoleColor.Yellow);
1398   - if (!emulation)
1399   - {
1400   - if (File.Exists(tranzitfileFullname)) { File.Delete(tranzitfileFullname); }
1401   - File.Move(backupfileFullname, tranzitfileFullname);
1402   - ColorConsole.WriteLine($"...completed...", ConsoleColor.Yellow);
1403   - }
1404   - }
1405   - catch (Exception ex)
1406   - {
1407   - ColorConsole.WriteLine($"Moving file FAILED!", ConsoleColor.Red);
1408   - ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red);
1409   - return false;
1410   - }
1411   - if (!emulation && !File.Exists(tranzitfileFullname)) { return false; }
  1384 + try
  1385 + {
  1386 + string backupfileFilename = Path.GetFileName(backupfileFullname);
  1387 + tranzitfileFullname = Path.Combine(dbtomove.Xml_SecondaryDB_TranzitDirectoryPath, backupfileFilename);
  1388 + ColorConsole.WriteLine($"Moving backup file {backupfileFullname} to tranzit location: {dbtomove.Xml_SecondaryDB_TranzitDirectoryPath}", ConsoleColor.Yellow);
  1389 + if (!emulation)
  1390 + {
  1391 + if (File.Exists(tranzitfileFullname)) { File.Delete(tranzitfileFullname); }
  1392 + File.Move(backupfileFullname, tranzitfileFullname);
  1393 + ColorConsole.WriteLine($"...completed...", ConsoleColor.Yellow);
  1394 + }
  1395 + }
  1396 + catch (Exception ex)
  1397 + {
  1398 + ColorConsole.WriteLine($"Moving file FAILED!", ConsoleColor.Red);
  1399 + ColorConsole.WriteLine(ex.MessageNested(), ConsoleColor.Red);
  1400 + return false;
  1401 + }
  1402 + }
  1403 + if (!emulation && !File.Exists(tranzitfileFullname)) { return false; }
1412 1404  
1413 1405 //restore backup to dbto
1414   - tranzitfileFullname = Path.Combine(dbto.Xml_TranzitDirectoryPath, backupfileFilename);
1415   - SQLDataBaseManagerCore.RestoreBackup(dbto, tranzitfileFullname, dbto.Xml_PhysicalFilesDirectoryPath, false, selecteddbname, emulation);
  1406 + SQLDataBaseManagerCore.RestoreBackup(dbtomove, tranzitfileFullname, dbtomove.Xml_SecondaryDB_PhysicalFilesDirectoryPath, false, selecteddbname, emulation);
1416 1407 return true;
1417 1408 }
1418 1409  
... ... @@ -1427,13 +1418,13 @@ GO
1427 1418 /// <param name="emulate"></param>
1428 1419 public static void RestoreBackup(SQLDataBase sqldb, string sourcesqlbackupfilepath, string targetdbphysicalfilesdirectorypath, bool restorefromZIP = false, string restoretodbname = null,bool emulate=false)
1429 1420 {
1430   - string sqlcs = sqldb.SQLCS; //sqlcs = sqlcs.Replace("LearALM2", "master");
  1421 + string sqlcs = sqldb.SQLCS_Primary; //sqlcs = sqlcs.Replace("LearALM2", "master");
1431 1422 string zippedbackupfilepath = restorefromZIP? sourcesqlbackupfilepath:Path.Combine(Path.GetDirectoryName(sourcesqlbackupfilepath), Path.GetFileNameWithoutExtension(sourcesqlbackupfilepath) + ".zip");
1432 1423 string normalbackupfilepath = !restorefromZIP? sourcesqlbackupfilepath : Path.Combine(Path.GetDirectoryName(sourcesqlbackupfilepath), Path.GetFileNameWithoutExtension(sourcesqlbackupfilepath) + ".bak");
1433 1424  
1434 1425 ColorConsole.WriteLine(nameof(RestoreBackup), ConsoleColor.Yellow, prefix: "running....");
1435 1426 ColorConsole.WriteLine(restoretodbname, ConsoleColor.Yellow, prefix: " restoretodbname:");
1436   - ColorConsole.WriteLine(sqldb.SQLCS, ConsoleColor.Yellow, prefix: " sqldb.SQLCS:");
  1427 + ColorConsole.WriteLine(sqldb.SQLCS_Primary, ConsoleColor.Yellow, prefix: " sqldb.SQLCS:");
1437 1428 ColorConsole.WriteLine(sourcesqlbackupfilepath, ConsoleColor.Yellow, prefix: " sourcesqlbackupfilepath:");
1438 1429 ColorConsole.WriteLine(normalbackupfilepath, ConsoleColor.Yellow, prefix: " backupfilepath:");
1439 1430 ColorConsole.WriteLine(restorefromZIP.ToString(), ConsoleColor.Yellow, prefix: " restorefromZIP:");
... ... @@ -1520,16 +1511,15 @@ GO
1520 1511 public static string CreateBackup(SQLDataBase sqld,bool? forcecreatezip, DateTime? timestamp,bool emulate=false)
1521 1512 {
1522 1513 string backupdirectorypath = sqld.Xml_BackupTargetDirectoryPath;
1523   - string tranzitdirectorypath = sqld.Xml_TranzitDirectoryPath;
1524   - bool usetranzit = sqld.Xml_IsRemoteDB;
  1514 + string tranzitdirectorypath = sqld.Xml_PrimaryDB_TranzitDirectoryPath;
1525 1515 string backupfilenamemask = sqld.Xml_BackupFileNameMask;
1526 1516 bool createzip = forcecreatezip ?? sqld.Xml_CreateZip;
1527 1517 //tranzitdirectorypathlocal = @"F:\ALM";
1528 1518 //tranzitdirectorypathnetwork = @"\\matng-sql01\ALM";
1529 1519  
1530 1520 string returnfilename = null;
1531   - var dbname = GetDBName(sqld.SQLCS);
1532   - var datasource = GetDataSource(sqld.SQLCS);
  1521 + var dbname = GetDBName(sqld.SQLCS_Primary);
  1522 + var datasource = GetDataSource(sqld.SQLCS_Primary);
1533 1523  
1534 1524 var backupts = (timestamp.HasValue ? timestamp.Value : DateTime.Now).ToString("yyyyMMddHHmmss");
1535 1525  
... ... @@ -1547,7 +1537,7 @@ GO
1547 1537  
1548 1538 string backupfilename = backupfileNameOnly + ".bak";
1549 1539 string backupFullName = Path.Combine(backupdirectorypath, backupfilename);
1550   - string tranzitFullName = usetranzit ? Path.Combine(tranzitdirectorypath, backupfilename) : null;
  1540 + string tranzitFullName = sqld.Xml_PrimaryDB_IsUseTranzit ? Path.Combine(tranzitdirectorypath, backupfilename) : null;
1551 1541  
1552 1542 string ZIPbackupfilename = backupfileNameOnly + ".zip";
1553 1543 string ZIPbackupFullName = Path.Combine(backupdirectorypath, ZIPbackupfilename);
... ... @@ -1555,7 +1545,7 @@ GO
1555 1545  
1556 1546 ColorConsole.WriteLine(nameof(CreateBackup), ConsoleColor.Yellow, prefix: "running....");
1557 1547 ColorConsole.WriteLine(dbname, ConsoleColor.Yellow, prefix: " dbname:");
1558   - ColorConsole.WriteLine(sqld.SQLCS, ConsoleColor.Yellow, prefix: " sqld.SQLCS:");
  1548 + ColorConsole.WriteLine(sqld.SQLCS_Primary, ConsoleColor.Yellow, prefix: " sqld.SQLCS:");
1559 1549 ColorConsole.WriteLine(backupdirectorypath, ConsoleColor.Yellow, prefix: " backupdirectorypath:");
1560 1550 ColorConsole.WriteLine(backupfilename, ConsoleColor.Yellow, prefix: " backupfilename:");
1561 1551 ColorConsole.WriteLine(backupFullName, ConsoleColor.Yellow, prefix: " backupFullName:");
... ... @@ -1565,7 +1555,7 @@ GO
1565 1555 ColorConsole.WriteLine(ZIPbackupfilename, ConsoleColor.Yellow, prefix: " ZIPbackupfilename:");
1566 1556 ColorConsole.WriteLine(ZIPbackupFullName, ConsoleColor.Yellow, prefix: " ZIPbackupFullName:");
1567 1557 }
1568   - ColorConsole.WriteLine(usetranzit.ToString(), ConsoleColor.Yellow, prefix: " usetranzit:");
  1558 + ColorConsole.WriteLine(sqld.Xml_PrimaryDB_IsUseTranzit.ToString(), ConsoleColor.Yellow, prefix: " usetranzit:");
1569 1559 ColorConsole.WriteLine(tranzitFullName, ConsoleColor.Yellow, prefix: " tranzitFullName:");
1570 1560 ColorConsole.WriteLine(returnfilename, ConsoleColor.Yellow, prefix: " returnfilename:");
1571 1561  
... ... @@ -1580,12 +1570,12 @@ GO
1580 1570 smoBackup.BackupSetDescription = $"Full Backup of {smoBackup.Database}";
1581 1571 smoBackup.MediaDescription = "Disk";
1582 1572 Console.WriteLine($"Backup set: {smoBackup.BackupSetName} ({smoBackup.BackupSetDescription}) to media: {smoBackup.MediaDescription}");
1583   - string dummystring = usetranzit ? " REMOTE SQL SERVER!" : "";
  1573 + string dummystring = sqld.Xml_PrimaryDB_IsUseTranzit ? " REMOTE SQL SERVER!" : "";
1584 1574 Console.WriteLine($"Database name: {smoBackup.Database}{dummystring}");
1585   - Console.WriteLine($"Connection string: {sqld.SQLCS}");
1586   - smoBackup.Devices.AddDevice(usetranzit ? tranzitFullName : backupFullName, DeviceType.File);
  1575 + Console.WriteLine($"Connection string: {sqld.SQLCS_Primary}");
  1576 + smoBackup.Devices.AddDevice(sqld.Xml_PrimaryDB_IsUseTranzit ? tranzitFullName : backupFullName, DeviceType.File);
1587 1577 Console.WriteLine($"Backup full name:{backupFullName}");
1588   - if (usetranzit)
  1578 + if (sqld.Xml_PrimaryDB_IsUseTranzit)
1589 1579 {
1590 1580 Console.WriteLine($" ...will be created through tranzit: {tranzitFullName}");
1591 1581 }
... ... @@ -1595,7 +1585,7 @@ GO
1595 1585 Server sqlserver = null;
1596 1586 try
1597 1587 {
1598   - sqlserver = SQLServerConnect(sqld.SQLCS, "master"); if (sqlserver == null) { return null; }
  1588 + sqlserver = SQLServerConnect(sqld.SQLCS_Primary, "master"); if (sqlserver == null) { return null; }
1599 1589 sqlserver.ConnectionContext.StatementTimeout = sqld.Xml_BackupTimeout;
1600 1590 backupstarttime = DateTime.Now;
1601 1591 smoBackup.SqlBackup(sqlserver);
... ... @@ -1611,7 +1601,7 @@ GO
1611 1601 return null;
1612 1602 }
1613 1603 finally { sqlserver?.ConnectionContext.SqlConnectionObject.Dispose(); }
1614   - if (usetranzit && File.Exists(tranzitFullName))
  1604 + if (sqld.Xml_PrimaryDB_IsUseTranzit && File.Exists(tranzitFullName))
1615 1605 {
1616 1606 File.Move(tranzitFullName, backupFullName);
1617 1607 Console.WriteLine($"Moving backup file...");
... ... @@ -2336,14 +2326,14 @@ GO
2336 2326 #region BackupSqlScripts
2337 2327 public static void BackupSqlScripts(SQLDataBase sqld, DateTime? timestamp=null)
2338 2328 {
2339   - if (sqld.Xml_IsRemoteDB)
  2329 + if (sqld.Xml_PrimaryDB_IsUseTranzit)
2340 2330 {
2341 2331 ColorConsole.WriteLine(text:$" {nameof(BackupSqlScripts)}: scrip backup is not available for remote SQL Servers! DBname:'{sqld.DBName}'.",prefix:$"WARNING!",f: ConsoleColor.Yellow);
2342 2332 return;
2343 2333 }
2344 2334 string backupdirectorypath = sqld.Xml_BackupTargetDirectoryPath;
2345 2335 string backupfilenamemask = sqld.Xml_BackupFileNameMask;
2346   - string sqlcs = sqld.SQLCS;
  2336 + string sqlcs = sqld.SQLCS_Primary;
2347 2337 bool createZip = sqld.Xml_CreateZip;
2348 2338  
2349 2339 var dbname = GetDBName(sqlcs);
... ... @@ -2458,12 +2448,12 @@ GO
2458 2448 #region BackupSqlData
2459 2449 public static void BackupSqlData(SQLDataBase sqld,DateTime? timestamp=null)
2460 2450 {
2461   - if (sqld.Xml_IsRemoteDB)
  2451 + if (sqld.Xml_PrimaryDB_IsUseTranzit)
2462 2452 {
2463 2453 ColorConsole.WriteLine(text: $" {nameof(BackupSqlData)}: data backup as scripts is not available for remote SQL Servers! DBname:'{sqld.DBName}'.", prefix: $"WARNING!", f:ConsoleColor.Yellow);
2464 2454 return;
2465 2455 }
2466   - string sqlcs = sqld.SQLCS;
  2456 + string sqlcs = sqld.SQLCS_Primary;
2467 2457 var dbname = GetDBName(sqlcs);
2468 2458  
2469 2459 string backupts = (timestamp.HasValue ? timestamp.Value : DateTime.Now).ToString("yyyyMMddHHmmss");
... ... @@ -2613,8 +2603,8 @@ GO
2613 2603 Xml_BackupFileNameMask = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.BackupFileNameMask), this.RootElement, SQLDataBase.XmlStructure.Attributes.BackupFileNameMask.Values.DEFAULT),
2614 2604 Xml_RestoreFileNameMask = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.RestoreFileNameMask), this.RootElement, SQLDataBase.XmlStructure.Attributes.RestoreFileNameMask.Values.DEFAULT),
2615 2605 Xml_BackupTargetDirectoryPath = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.BackupTargetDirectoryPath), this.RootElement, SQLDataBase.XmlStructure.Attributes.BackupTargetDirectoryPath.Values.DEFAULT),
2616   - Xml_TranzitDirectoryPath = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.TranzitDirectoryPath), this.RootElement, SQLDataBase.XmlStructure.Attributes.TranzitDirectoryPath.Values.DEFAULT),
2617   - Xml_PhysicalFilesDirectoryPath = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.PhysicalFilesDirectoryPath), this.RootElement, SQLDataBase.XmlStructure.Attributes.PhysicalFilesDirectoryPath.Values.DEFAULT),
  2606 + Xml_PrimaryDB_TranzitDirectoryPath = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.TranzitDirectoryPath), this.RootElement, SQLDataBase.XmlStructure.Attributes.TranzitDirectoryPath.Values.DEFAULT),
  2607 + Xml_PrimaryDB_PhysicalFilesDirectoryPath = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.PhysicalFilesDirectoryPath), this.RootElement, SQLDataBase.XmlStructure.Attributes.PhysicalFilesDirectoryPath.Values.DEFAULT),
2618 2608 Xml_ScriptCommandTimeout = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.ScriptCommandTimeout), this.RootElement, SQLDataBase.XmlStructure.Attributes.ScriptCommandTimeout.Values.DEFAULT),
2619 2609 Xml_BackupTimeout = GetValue(nameof(SQLDataBase.XmlStructure.Attributes.BackupTimeout), this.RootElement, SQLDataBase.XmlStructure.Attributes.BackupTimeout.Values.DEFAULT),
2620 2610 };
... ... @@ -2642,59 +2632,73 @@ GO
2642 2632 public string Xml_BackupFileNameMask;
2643 2633 public string Xml_RestoreFileNameMask;
2644 2634 public string Xml_BackupTargetDirectoryPath;
2645   - public bool Xml_IsRemoteDB { get { return !string.IsNullOrWhiteSpace(Xml_TranzitDirectoryPath); } }
2646   - public string Xml_TranzitDirectoryPath;
2647   - public string Xml_SQLConnectionString;
2648   - public string Xml_PhysicalFilesDirectoryPath;
2649   - public int Xml_ScriptCommandTimeout;
2650   - public int Xml_BackupTimeout;
2651   - public List<SQLData> Xml_SQLDataList;
2652   - public List<LastUpdatedTrigger> Xml_SQLLastUpdatedTriggerList;
2653   - public List<DBUser> Xml_SQLDbUserList;
2654   - public List<ServerLogin> Xml_SQLServerLoginList;
2655   - public List<SQLScript> Xml_SQLScriptList;
2656   -
2657   - public string DBName;
2658   - public string DataSource;
2659   - public SQLDBStatus Status;
2660   - public string PhysicalFilesDirectoryPath;
2661   - public string SizeString;
2662   - public bool isSQLCSselected
  2635 + public int Xml_ScriptCommandTimeout;
  2636 + public int Xml_BackupTimeout;
  2637 +
  2638 + public string Xml_PrimaryDB_SQLConnectionString;
  2639 + public string Xml_PrimaryDB_TranzitDirectoryPath;
  2640 + public bool Xml_PrimaryDB_IsUseTranzit { get { return !string.IsNullOrWhiteSpace(Xml_PrimaryDB_TranzitDirectoryPath); } }
  2641 + public string Xml_PrimaryDB_PhysicalFilesDirectoryPath;
  2642 + public bool is_PrimaryDB_SQLCSselected
2663 2643 {
2664 2644 get
2665 2645 {
2666   - var sqlcsList = this.Xml_SQLConnectionString.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
2667   - return sqlcsList.Count() == 1 || !string.IsNullOrWhiteSpace(this.Xml_SQLConnectionStringSelected);
  2646 + var sqlcsList = this.Xml_PrimaryDB_SQLConnectionString.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
  2647 + return sqlcsList.Count() == 1 || !string.IsNullOrWhiteSpace(this.Xml_PrimaryDB_SQLConnectionStringSelected);
2668 2648 }
2669 2649 }
2670   - public string SQLCS
  2650 + public string SQLCS_Primary
2671 2651 {
2672 2652 get
2673 2653 {
2674   - if (string.IsNullOrWhiteSpace(this.Xml_SQLConnectionStringSelected)) { SelectSQLConnectionString(); }
2675   - if (string.IsNullOrWhiteSpace(this.Xml_SQLConnectionStringSelected)) { return null; }
2676   - return XmlProcessing.ConnectionStringStore.GetSQL(this.Xml_SQLConnectionStringSelected);
  2654 + if (string.IsNullOrWhiteSpace(this.Xml_PrimaryDB_SQLConnectionStringSelected)) { Select_PrimaryDB_SQLConnectionString(); }
  2655 + if (string.IsNullOrWhiteSpace(this.Xml_PrimaryDB_SQLConnectionStringSelected)) { return null; }
  2656 + return XmlProcessing.ConnectionStringStore.GetSQL(this.Xml_PrimaryDB_SQLConnectionStringSelected);
2677 2657 }
2678 2658 }
2679   - private string Xml_SQLConnectionStringSelected;
2680   -
2681   - public void SelectSQLConnectionString(int? forceselection=null)
  2659 + private string Xml_PrimaryDB_SQLConnectionStringSelected;
  2660 + public void Select_PrimaryDB_SQLConnectionString(int? forceselection=null)
2682 2661 {
2683   - this.Xml_SQLConnectionStringSelected = null;
2684   - var sqlcsList = this.Xml_SQLConnectionString.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
2685   - if (forceselection.HasValue)
  2662 + this.Xml_PrimaryDB_SQLConnectionStringSelected = null;
  2663 + var sqlcsList = this.Xml_PrimaryDB_SQLConnectionString.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries).ToList();
  2664 + if (forceselection.HasValue)
2686 2665 {
2687   - if (forceselection.Value >=0 && sqlcsList.Count() > forceselection.Value) { this.Xml_SQLConnectionStringSelected = sqlcsList[forceselection.Value]; }
2688   - return;
  2666 + if (forceselection.Value >=0 && sqlcsList.Count() > forceselection.Value) { this.Xml_PrimaryDB_SQLConnectionStringSelected = sqlcsList[forceselection.Value]; }
  2667 + return;
2689 2668 }
2690 2669 else
2691 2670 {
2692   - if (sqlcsList.Count() == 1) { this.Xml_SQLConnectionStringSelected = sqlcsList[0]; return; }
  2671 + if (sqlcsList.Count() == 1) { this.Xml_PrimaryDB_SQLConnectionStringSelected = sqlcsList[0]; return; }
2693 2672 var selection = ColorConsole.ReadLine("Select SQL connection string to use:", bracket: "[]", suffix: "ENTER==first", validitylist: sqlcsList);
2694 2673 if (selection == "EX") return;
2695   - if (string.IsNullOrWhiteSpace(selection)) { this.Xml_SQLConnectionStringSelected = sqlcsList[0]; } else { this.Xml_SQLConnectionStringSelected = selection; }
  2674 + if (string.IsNullOrWhiteSpace(selection)) { this.Xml_PrimaryDB_SQLConnectionStringSelected = sqlcsList[0]; } else { this.Xml_PrimaryDB_SQLConnectionStringSelected = selection; }
2696 2675 }
2697 2676 }
  2677 +
  2678 + public string Xml_SecondaryDB_SQLConnectionString;
  2679 + public string Xml_SecondaryDB_TranzitDirectoryPath;
  2680 + public bool Xml_SecondaryDB_IsUseTranzit { get { return !string.IsNullOrWhiteSpace(Xml_SecondaryDB_TranzitDirectoryPath); } }
  2681 + public string Xml_SecondaryDB_PhysicalFilesDirectoryPath;
  2682 + public string SQLCS_Secondary
  2683 + {
  2684 + get
  2685 + {
  2686 + if (string.IsNullOrWhiteSpace(this.Xml_SecondaryDB_SQLConnectionString)) { return null; }
  2687 + return XmlProcessing.ConnectionStringStore.GetSQL(this.Xml_SecondaryDB_SQLConnectionString);
  2688 + }
  2689 + }
  2690 +
  2691 + public List<SQLData> Xml_SQLDataList;
  2692 + public List<LastUpdatedTrigger> Xml_SQLLastUpdatedTriggerList;
  2693 + public List<DBUser> Xml_SQLDbUserList;
  2694 + public List<ServerLogin> Xml_SQLServerLoginList;
  2695 + public List<SQLScript> Xml_SQLScriptList;
  2696 +
  2697 + public string DBName;
  2698 + public string DataSource;
  2699 + public SQLDBStatus Status;
  2700 + public string PrimaryDB_PhysicalFilesDirectoryPath;
  2701 + public string SizeString;
2698 2702 #endregion fields
2699 2703 public enum SQLDBStatus { NoAccess, OK, }
2700 2704  
... ... @@ -2703,42 +2707,42 @@ GO
2703 2707 {
2704 2708 try
2705 2709 {
2706   - if (!this.isSQLCSselected)
  2710 + if (!this.is_PrimaryDB_SQLCSselected)
2707 2711 {
2708 2712 this.Status = SQLDBStatus.OK;
2709 2713 this.DBName = "";
2710   - this.DataSource = this.Xml_SQLConnectionString;
  2714 + this.DataSource = this.Xml_PrimaryDB_SQLConnectionString;
2711 2715 }
2712 2716 else
2713 2717 {
2714   - string dbname = SQLDataBaseManagerCore.GetDBName(this.SQLCS);
  2718 + string dbname = SQLDataBaseManagerCore.GetDBName(this.SQLCS_Primary);
2715 2719 if (string.IsNullOrWhiteSpace(dbname))
2716 2720 {
2717   - var sqlc = ServerConnectionPool.GetSqlConnection(this.SQLCS, open: true);
  2721 + var sqlc = ServerConnectionPool.GetSqlConnection(this.SQLCS_Primary, open: true);
2718 2722 this.Status = SQLDBStatus.OK;
2719 2723 this.DBName = "";
2720   - this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS);
  2724 + this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS_Primary);
2721 2725 }
2722 2726 else
2723 2727 {
2724   - GetPhysicalFilesLocationAndSize(this.SQLCS, out this.SizeString, out this.PhysicalFilesDirectoryPath);
2725   - this.Status = this.PhysicalFilesDirectoryPath.StartsWith("ERR") ? SQLDBStatus.NoAccess : SQLDBStatus.OK;
2726   - this.DBName = SQLDataBaseManagerCore.GetDBName(this.SQLCS);
2727   - this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS);
  2728 + GetPhysicalFilesLocationAndSize(this.SQLCS_Primary, out this.SizeString, out this.PrimaryDB_PhysicalFilesDirectoryPath);
  2729 + this.Status = this.PrimaryDB_PhysicalFilesDirectoryPath.StartsWith("ERR") ? SQLDBStatus.NoAccess : SQLDBStatus.OK;
  2730 + this.DBName = SQLDataBaseManagerCore.GetDBName(this.SQLCS_Primary);
  2731 + this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS_Primary);
2728 2732 }
2729 2733 }
2730 2734 }
2731 2735 catch
2732 2736 {
2733 2737 this.Status = SQLDBStatus.NoAccess;
2734   - this.PhysicalFilesDirectoryPath = "";
  2738 + this.PrimaryDB_PhysicalFilesDirectoryPath = "";
2735 2739 this.DBName = "";
2736 2740 this.DataSource = "";
2737 2741 this.SizeString = "";
2738 2742 try
2739 2743 {
2740   - this.DBName = SQLDataBaseManagerCore.GetDBName(this.SQLCS);
2741   - this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS);
  2744 + this.DBName = SQLDataBaseManagerCore.GetDBName(this.SQLCS_Primary);
  2745 + this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS_Primary);
2742 2746 }
2743 2747 catch { }
2744 2748 }
... ... @@ -2816,11 +2820,16 @@ GO
2816 2820 Xml_BackupFileNameMask = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.BackupFileNameMask), sqldatabasexml, common.Xml_BackupFileNameMask);
2817 2821 Xml_RestoreFileNameMask = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.RestoreFileNameMask), sqldatabasexml, common.Xml_RestoreFileNameMask);
2818 2822 Xml_BackupTargetDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.BackupTargetDirectoryPath), sqldatabasexml, common.Xml_BackupTargetDirectoryPath);
2819   - Xml_TranzitDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.TranzitDirectoryPath), sqldatabasexml, common.Xml_TranzitDirectoryPath);
2820   - Xml_SQLConnectionString = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.SQLConnectionString), sqldatabasexml, XmlStructure.SQLDataBase.Attributes.SQLConnectionString.Values.DEFAULT);
  2823 + Xml_PrimaryDB_TranzitDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.TranzitDirectoryNetworkPath), sqldatabasexml, common.Xml_PrimaryDB_TranzitDirectoryPath);
  2824 + Xml_PrimaryDB_SQLConnectionString = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.SQLConnectionString), sqldatabasexml, XmlStructure.SQLDataBase.Attributes.SQLConnectionString.Values.DEFAULT);
2821 2825  
2822   - Xml_CreateZip = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.CreateZip), sqldatabasexml, common.Xml_CreateZip);
2823   - Xml_PhysicalFilesDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.PhysicalFilesDirectoryPath), sqldatabasexml, common.Xml_PhysicalFilesDirectoryPath);
  2826 + var secdbxml = GetXElement(sqldatabasexml,nameof(XmlStructure.SQLDataBase.SecondaryDB));
  2827 + Xml_SecondaryDB_SQLConnectionString = GetValue(nameof(XmlStructure.SQLDataBase.SecondaryDB.Attributes.SQLConnectionString), secdbxml, "");
  2828 + Xml_SecondaryDB_TranzitDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.SecondaryDB.Attributes.TranzitDirectoryNetworkPath), secdbxml, "");
  2829 + Xml_SecondaryDB_PhysicalFilesDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.SecondaryDB.Attributes.PhysicalFilesDirectoryPath), secdbxml, "");
  2830 +
  2831 + Xml_CreateZip = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.CreateZip), sqldatabasexml, common.Xml_CreateZip);
  2832 + Xml_PrimaryDB_PhysicalFilesDirectoryPath = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.PhysicalFilesDirectoryPath), sqldatabasexml, common.Xml_PrimaryDB_PhysicalFilesDirectoryPath);
2824 2833  
2825 2834 Xml_ScriptCommandTimeout = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.ScriptCommandTimeout), sqldatabasexml, common.Xml_ScriptCommandTimeout);
2826 2835 Xml_BackupTimeout = GetValue(nameof(XmlStructure.SQLDataBase.Attributes.BackupTimeout), sqldatabasexml, common.Xml_BackupTimeout);
... ... @@ -2848,7 +2857,7 @@ GO
2848 2857 Xml_SQLScriptList = new List<SQLScript>();
2849 2858 var sqlscriptsXml = GetXElement(sqldatabasexml, nameof(XmlStructure.SQLDataBase.Scripts));
2850 2859 var sqlscriptXmlList = GetAllXElements(sqlscriptsXml, nameof(XmlStructure.SQLDataBase.Scripts.Script));
2851   - if (sqlscriptXmlList != null) { int scriptindex = 1; foreach (var sqlscriptXml in sqlscriptXmlList) { Xml_SQLScriptList.Add(new SQLScript(sqlscriptXml, Xml_SQLConnectionString,Xml_ScriptCommandTimeout, scriptindex++)); } }
  2860 + if (sqlscriptXmlList != null) { int scriptindex = 1; foreach (var sqlscriptXml in sqlscriptXmlList) { Xml_SQLScriptList.Add(new SQLScript(sqlscriptXml, Xml_PrimaryDB_SQLConnectionString,Xml_ScriptCommandTimeout, scriptindex++)); } }
2852 2861 }
2853 2862 #endregion xml constructor
2854 2863 #region cloner constructor
... ... @@ -2861,9 +2870,9 @@ GO
2861 2870 Xml_BackupFileNameMask = sqld.Xml_BackupFileNameMask;
2862 2871 Xml_RestoreFileNameMask = sqld.Xml_RestoreFileNameMask;
2863 2872 Xml_BackupTargetDirectoryPath = sqld.Xml_BackupTargetDirectoryPath;
2864   - Xml_TranzitDirectoryPath = sqld.Xml_TranzitDirectoryPath;
2865   - Xml_SQLConnectionString = sqld.Xml_SQLConnectionString;
2866   - Xml_PhysicalFilesDirectoryPath = sqld.Xml_PhysicalFilesDirectoryPath;
  2873 + Xml_PrimaryDB_TranzitDirectoryPath = sqld.Xml_PrimaryDB_TranzitDirectoryPath;
  2874 + Xml_PrimaryDB_SQLConnectionString = sqld.Xml_PrimaryDB_SQLConnectionString;
  2875 + Xml_PrimaryDB_PhysicalFilesDirectoryPath = sqld.Xml_PrimaryDB_PhysicalFilesDirectoryPath;
2867 2876 Xml_SQLDataList = sqld.Xml_SQLDataList.Select(x => new SQLData(x)).ToList();
2868 2877 Xml_SQLScriptList = sqld.Xml_SQLScriptList.Select(x => new SQLScript(x)).ToList();
2869 2878 }
... ... @@ -2894,7 +2903,7 @@ GO
2894 2903 public static class BackupFileNameMask { }
2895 2904 public static class RestoreFileNameMask { }
2896 2905 public static class BackupTargetDirectoryPath { }
2897   - public static class TranzitDirectoryPath { }
  2906 + public static class TranzitDirectoryNetworkPath { }
2898 2907 public static class CreateZip { }
2899 2908 public static class PhysicalFilesDirectoryPath { }
2900 2909 public static class ScriptCommandTimeout { public static class Values { public const int DEFAULT = 10000; } }
... ... @@ -2963,8 +2972,17 @@ GO
2963 2972 }
2964 2973 }
2965 2974 }
2966   - }
2967   - }
  2975 + public static class SecondaryDB
  2976 + {
  2977 + public static class Attributes
  2978 + {
  2979 + 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 = ""; } }
  2981 + public static class SQLConnectionString { public static class Values { public const string DEFAULT = null; } }
  2982 + }
  2983 + }
  2984 + }
  2985 + }
2968 2986 #endregion XmlStructure
2969 2987 #region SQLScript class
2970 2988 public class SQLScript : XmlLinqBase
... ...
Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
... ... @@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
32 32 // You can specify all the values or you can default the Build and Revision Numbers
33 33 // by using the '*' as shown below:
34 34 // [assembly: AssemblyVersion("1.0.*")]
35   -[assembly: AssemblyVersion("1.31.8.0")]
36   -[assembly: AssemblyFileVersion("1.31.8.0")]
  35 +[assembly: AssemblyVersion("1.32.0.0")]
  36 +[assembly: AssemblyFileVersion("1.32.0.0")]
... ...