Commit 08a28ecbf94b1d1b5a3edca41091cf21aca0f411
1 parent
1ff12b69
v1.31.4.0
-Script/SQLConnectionString= és SQLDataBase/SQLConnectionString= attributumokba vesszővel határolva lehet beírni a connstr neveket, amik közül választani lehet
Showing
2 changed files
with
121 additions
and
42 deletions
Show diff stats
Vrh.Log4Pro.MaintenanceConsole/Manager - SQLDataBaseManager.cs
@@ -112,7 +112,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | @@ -112,7 +112,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | ||
112 | SQLDataBase sqld = p.Parameters as SQLDataBase; | 112 | SQLDataBase sqld = p.Parameters as SQLDataBase; |
113 | try | 113 | try |
114 | { | 114 | { |
115 | - if (FunctionIsNotAvailable(sqld)) { return o; } | 115 | + if (NoDBNameSpecified(sqld)) { return o; } |
116 | SQLDataBaseManagerCore.BackupSqlData(sqld,TS); | 116 | SQLDataBaseManagerCore.BackupSqlData(sqld,TS); |
117 | ColorConsole.WriteLine($"SQLDB data scripts created. Name:{sqld.Xml_Description}", ConsoleColor.Green); | 117 | ColorConsole.WriteLine($"SQLDB data scripts created. Name:{sqld.Xml_Description}", ConsoleColor.Green); |
118 | } | 118 | } |
@@ -142,7 +142,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | @@ -142,7 +142,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | ||
142 | SQLDataBase sqld = p.Parameters as SQLDataBase; | 142 | SQLDataBase sqld = p.Parameters as SQLDataBase; |
143 | try | 143 | try |
144 | { | 144 | { |
145 | - if (FunctionIsNotAvailable(sqld)) { return o; } | 145 | + if (NoDBNameSpecified(sqld)) { return o; } |
146 | SQLDataBaseManagerCore.BackupSqlScripts(sqld,TS); | 146 | SQLDataBaseManagerCore.BackupSqlScripts(sqld,TS); |
147 | ColorConsole.WriteLine($"SQLDB code scripts created. Name:{sqld.Xml_Description}", ConsoleColor.Green); | 147 | ColorConsole.WriteLine($"SQLDB code scripts created. Name:{sqld.Xml_Description}", ConsoleColor.Green); |
148 | } | 148 | } |
@@ -172,7 +172,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | @@ -172,7 +172,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | ||
172 | SQLDataBase sqld = p.Parameters as SQLDataBase; | 172 | SQLDataBase sqld = p.Parameters as SQLDataBase; |
173 | try | 173 | try |
174 | { | 174 | { |
175 | - if (FunctionIsNotAvailable(sqld)) { return o; } | 175 | + if (NoDBNameSpecified(sqld)) { return o; } |
176 | SQLDataBaseManagerCore.CreateBackup(sqld,null,TS); | 176 | SQLDataBaseManagerCore.CreateBackup(sqld,null,TS); |
177 | ColorConsole.WriteLine($"Database backup created. Name:{sqld.DBName}", ConsoleColor.Green); | 177 | ColorConsole.WriteLine($"Database backup created. Name:{sqld.DBName}", ConsoleColor.Green); |
178 | } | 178 | } |
@@ -180,10 +180,10 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | @@ -180,10 +180,10 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | ||
180 | } | 180 | } |
181 | return o; | 181 | return o; |
182 | } | 182 | } |
183 | - private static bool FunctionIsNotAvailable(SQLDataBase ssqldb) | 183 | + private static bool NoDBNameSpecified(SQLDataBase ssqldb) |
184 | { | 184 | { |
185 | const string FUNNOTAVAILTXT = "Function is not available for server connection strings wit no DB name specified!"; | 185 | const string FUNNOTAVAILTXT = "Function is not available for server connection strings wit no DB name specified!"; |
186 | - if (string.IsNullOrWhiteSpace(SQLDataBaseManagerCore.GetDBName(ssqldb.SQLCS))) { ColorConsole.WriteLine(FUNNOTAVAILTXT, ConsoleColor.Red); return true; } | 186 | + if (string.IsNullOrWhiteSpace(SQLDataBaseManagerCore.GetDBName(ssqldb.SQLCS))) { ColorConsole.WriteLine(FUNNOTAVAILTXT, ConsoleColor.Red); ssqldb.DBName = "master"; return true; } |
187 | return false; | 187 | return false; |
188 | } | 188 | } |
189 | private static object RestoreDataBase(object parameter, object o) | 189 | private static object RestoreDataBase(object parameter, object o) |
@@ -208,7 +208,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | @@ -208,7 +208,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | ||
208 | SQLDataBase sqld = p.Parameters as SQLDataBase; | 208 | SQLDataBase sqld = p.Parameters as SQLDataBase; |
209 | try | 209 | try |
210 | { | 210 | { |
211 | - if (FunctionIsNotAvailable(sqld)) { return o; } | 211 | + if (NoDBNameSpecified(sqld)) { return o; } |
212 | var targetdirectorypath = sqld.Xml_PhysicalFilesDirectoryPath; | 212 | var targetdirectorypath = sqld.Xml_PhysicalFilesDirectoryPath; |
213 | var targetdbname = sqld.DBName; | 213 | var targetdbname = sqld.DBName; |
214 | bool restorefromzip = sqld.Xml_CreateZip; | 214 | bool restorefromzip = sqld.Xml_CreateZip; |
@@ -505,7 +505,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | @@ -505,7 +505,7 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | ||
505 | 505 | ||
506 | var p = sr.SelectedParameterList.FirstOrDefault(); | 506 | var p = sr.SelectedParameterList.FirstOrDefault(); |
507 | SQLDataBase sqld = p.Parameters as SQLDataBase; | 507 | SQLDataBase sqld = p.Parameters as SQLDataBase; |
508 | - if (FunctionIsNotAvailable(sqld)) { return o; } | 508 | + if (NoDBNameSpecified(sqld)) { return o; } |
509 | 509 | ||
510 | getparametersloop: | 510 | getparametersloop: |
511 | List<SQLDataBase.DBUser> DbusrToExecuteList = new List<SQLDataBase.DBUser>(); | 511 | List<SQLDataBase.DBUser> DbusrToExecuteList = new List<SQLDataBase.DBUser>(); |
@@ -656,8 +656,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | @@ -656,8 +656,8 @@ namespace Vrh.Log4Pro.MaintenanceConsole.SQLDataBaseManagerNS | ||
656 | var DateTimeNow = DateTime.Now; | 656 | var DateTimeNow = DateTime.Now; |
657 | 657 | ||
658 | movedbanswer = YesOrNo_MoveDbToRemoteServer(config, selectedsqldbindexes); | 658 | movedbanswer = YesOrNo_MoveDbToRemoteServer(config, selectedsqldbindexes); |
659 | - if (FunctionIsNotAvailable(movedbanswer.Dbfrom)) { continue; } | ||
660 | - if (FunctionIsNotAvailable(movedbanswer.Dbto)) { continue; } | 659 | + if (NoDBNameSpecified(movedbanswer.Dbfrom)) { continue; } |
660 | + if (NoDBNameSpecified(movedbanswer.Dbto)) { continue; } | ||
661 | if (movedbanswer.Exit) break; | 661 | if (movedbanswer.Exit) break; |
662 | if (movedbanswer.Yes) | 662 | if (movedbanswer.Yes) |
663 | { | 663 | { |
@@ -827,7 +827,7 @@ GO | @@ -827,7 +827,7 @@ GO | ||
827 | var p = sr.SelectedParameterList.FirstOrDefault(); | 827 | var p = sr.SelectedParameterList.FirstOrDefault(); |
828 | if (p == null) { return o; } | 828 | if (p == null) { return o; } |
829 | SQLDataBase sqld = p.Parameters as SQLDataBase; | 829 | SQLDataBase sqld = p.Parameters as SQLDataBase; |
830 | - if (FunctionIsNotAvailable(sqld)) { return o; } | 830 | + if (NoDBNameSpecified(sqld)) { return o; } |
831 | 831 | ||
832 | getparametersloop:; | 832 | getparametersloop:; |
833 | 833 | ||
@@ -1031,6 +1031,7 @@ GO | @@ -1031,6 +1031,7 @@ GO | ||
1031 | ReturnInfoJSON result = null; | 1031 | ReturnInfoJSON result = null; |
1032 | using (var sqlc = ServerConnectionPool.GetSqlConnection(ss.SQLCS, open: true)) | 1032 | using (var sqlc = ServerConnectionPool.GetSqlConnection(ss.SQLCS, open: true)) |
1033 | { | 1033 | { |
1034 | + if (string.IsNullOrWhiteSpace(sqlc.Database)) { sqlc.ChangeDatabase("master"); } | ||
1034 | if (multirunmode) { result = SQLDataBaseManagerCore.ExecuteMultirunSQLScript(sqlc, ss, ExitAtThisPoint); } | 1035 | if (multirunmode) { result = SQLDataBaseManagerCore.ExecuteMultirunSQLScript(sqlc, ss, ExitAtThisPoint); } |
1035 | else | 1036 | else |
1036 | { | 1037 | { |
@@ -1099,7 +1100,7 @@ GO | @@ -1099,7 +1100,7 @@ GO | ||
1099 | SQLDataBase sqld = p.Parameters as SQLDataBase; | 1100 | SQLDataBase sqld = p.Parameters as SQLDataBase; |
1100 | try | 1101 | try |
1101 | { | 1102 | { |
1102 | - if (FunctionIsNotAvailable(sqld)) { return o; } | 1103 | + if (NoDBNameSpecified(sqld)) { return o; } |
1103 | ColorConsole.WriteLine(prefix: $"Enter the userid/password (for the user in favour you want to drop the DB). Format:", bracket: "()", text: "[USERID[,PASSWORD]]:", f: ConsoleColor.Yellow); | 1104 | ColorConsole.WriteLine(prefix: $"Enter the userid/password (for the user in favour you want to drop the DB). Format:", bracket: "()", text: "[USERID[,PASSWORD]]:", f: ConsoleColor.Yellow); |
1104 | ColorConsole.WriteLine(prefix: " ", text: "[USERID,PASSWORD empty]", bracket: "[]", suffix: $":use windows authentication with current user", f: ConsoleColor.Yellow); | 1105 | ColorConsole.WriteLine(prefix: " ", text: "[USERID,PASSWORD empty]", bracket: "[]", suffix: $":use windows authentication with current user", f: ConsoleColor.Yellow); |
1105 | ColorConsole.WriteLine(prefix: " ", text: "USERID", bracket: "[]", suffix: $":use windows authentication with this user", f: ConsoleColor.Yellow); | 1106 | ColorConsole.WriteLine(prefix: " ", text: "USERID", bracket: "[]", suffix: $":use windows authentication with this user", f: ConsoleColor.Yellow); |
@@ -1185,7 +1186,7 @@ GO | @@ -1185,7 +1186,7 @@ GO | ||
1185 | SQLDataBase sqld = p.Parameters as SQLDataBase; | 1186 | SQLDataBase sqld = p.Parameters as SQLDataBase; |
1186 | try | 1187 | try |
1187 | { | 1188 | { |
1188 | - if (FunctionIsNotAvailable(sqld)) { return o; } | 1189 | + if (NoDBNameSpecified(sqld)) { return o; } |
1189 | ColorConsole.WriteLine(prefix: $"Enter the shrink options. Format:", bracket:"()", text:"OPTION,FreeSpacePercent:", f:ConsoleColor.Yellow); | 1190 | ColorConsole.WriteLine(prefix: $"Enter the shrink options. Format:", bracket:"()", text:"OPTION,FreeSpacePercent:", f:ConsoleColor.Yellow); |
1190 | ColorConsole.WriteLine(prefix:" ", text:"Default", bracket: "[]", suffix: $": (default) compacts the data and removes free space from the DB. Use togethere with FreeSpacePercent.", f:ConsoleColor.Yellow); | 1191 | ColorConsole.WriteLine(prefix:" ", text:"Default", bracket: "[]", suffix: $": (default) compacts the data and removes free space from the DB. Use togethere with FreeSpacePercent.", f:ConsoleColor.Yellow); |
1191 | ColorConsole.WriteLine(prefix: " ", text: "NoTruncate",bracket:"[]", suffix: $": compacts the data, but does not remove free space from the DB. FreeSpacePercent is not applicable.", f: ConsoleColor.Yellow); | 1192 | ColorConsole.WriteLine(prefix: " ", text: "NoTruncate",bracket:"[]", suffix: $": compacts the data, but does not remove free space from the DB. FreeSpacePercent is not applicable.", f: ConsoleColor.Yellow); |
@@ -1229,7 +1230,7 @@ GO | @@ -1229,7 +1230,7 @@ GO | ||
1229 | SQLDataBase sqld = p.Parameters as SQLDataBase; | 1230 | SQLDataBase sqld = p.Parameters as SQLDataBase; |
1230 | try | 1231 | try |
1231 | { | 1232 | { |
1232 | - if (FunctionIsNotAvailable(sqld)) { return o; } | 1233 | + if (NoDBNameSpecified(sqld)) { return o; } |
1233 | var restoredbname = ColorConsole.ReadLine($"Enter the name of the DB to copy '{sqld.DBName}' to. Empty={sqld.DBName}. EX=exit.", ConsoleColor.Yellow, suffix: " --> "); | 1234 | var restoredbname = ColorConsole.ReadLine($"Enter the name of the DB to copy '{sqld.DBName}' to. Empty={sqld.DBName}. EX=exit.", ConsoleColor.Yellow, suffix: " --> "); |
1234 | if (restoredbname.ToUpper() == "EX") { continue; } | 1235 | if (restoredbname.ToUpper() == "EX") { continue; } |
1235 | else if (string.IsNullOrWhiteSpace(restoredbname)) { restoredbname = sqld.DBName; } | 1236 | else if (string.IsNullOrWhiteSpace(restoredbname)) { restoredbname = sqld.DBName; } |
@@ -1301,6 +1302,7 @@ GO | @@ -1301,6 +1302,7 @@ GO | ||
1301 | } | 1302 | } |
1302 | else if (lineix == 2) | 1303 | else if (lineix == 2) |
1303 | { | 1304 | { |
1305 | + if (!st.isSQLCSselected) { return Menu.MenuItemDisplayerReturnValue.SAMELINE; } | ||
1304 | ColorConsole.Write($"{st.SQLCS}", ConsoleColor.Yellow, prefix: "SQL DB connection:", suffix: ", "); | 1306 | ColorConsole.Write($"{st.SQLCS}", ConsoleColor.Yellow, prefix: "SQL DB connection:", suffix: ", "); |
1305 | ColorConsole.WriteLine(" "); | 1307 | ColorConsole.WriteLine(" "); |
1306 | return Menu.MenuItemDisplayerReturnValue.NEXTLINE; | 1308 | return Menu.MenuItemDisplayerReturnValue.NEXTLINE; |
@@ -2637,10 +2639,42 @@ GO | @@ -2637,10 +2639,42 @@ GO | ||
2637 | public SQLDBStatus Status; | 2639 | public SQLDBStatus Status; |
2638 | public string PhysicalFilesDirectoryPath; | 2640 | public string PhysicalFilesDirectoryPath; |
2639 | public string SizeString; | 2641 | public string SizeString; |
2642 | + public bool isSQLCSselected | ||
2643 | + { | ||
2644 | + get | ||
2645 | + { | ||
2646 | + var sqlcsList = this.Xml_SQLConnectionString.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries).ToList(); | ||
2647 | + return sqlcsList.Count() == 1 || !string.IsNullOrWhiteSpace(this.Xml_SQLConnectionStringSelected); | ||
2648 | + } | ||
2649 | + } | ||
2640 | public string SQLCS | 2650 | public string SQLCS |
2641 | { | 2651 | { |
2642 | - get { return XmlProcessing.ConnectionStringStore.GetSQL(this.Xml_SQLConnectionString); } | 2652 | + get |
2653 | + { | ||
2654 | + if (string.IsNullOrWhiteSpace(this.Xml_SQLConnectionStringSelected)) { SelectSQLConnectionString(); } | ||
2655 | + if (string.IsNullOrWhiteSpace(this.Xml_SQLConnectionStringSelected)) { return null; } | ||
2656 | + return XmlProcessing.ConnectionStringStore.GetSQL(this.Xml_SQLConnectionStringSelected); | ||
2657 | + } | ||
2643 | } | 2658 | } |
2659 | + private string Xml_SQLConnectionStringSelected; | ||
2660 | + | ||
2661 | + public void SelectSQLConnectionString(int? forceselection=null) | ||
2662 | + { | ||
2663 | + this.Xml_SQLConnectionStringSelected = null; | ||
2664 | + var sqlcsList = this.Xml_SQLConnectionString.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries).ToList(); | ||
2665 | + if (forceselection.HasValue) | ||
2666 | + { | ||
2667 | + if (forceselection.Value >=0 && sqlcsList.Count() > forceselection.Value) { this.Xml_SQLConnectionStringSelected = sqlcsList[forceselection.Value]; } | ||
2668 | + return; | ||
2669 | + } | ||
2670 | + else | ||
2671 | + { | ||
2672 | + if (sqlcsList.Count() == 1) { this.Xml_SQLConnectionStringSelected = sqlcsList[0]; return; } | ||
2673 | + var selection = ColorConsole.ReadLine("Select SQL connection string to use:", bracket: "[]", suffix: "ENTER==first", validitylist: sqlcsList); | ||
2674 | + if (selection == "EX") return; | ||
2675 | + if (string.IsNullOrWhiteSpace(selection)) { this.Xml_SQLConnectionStringSelected = sqlcsList[0]; } else { this.Xml_SQLConnectionStringSelected = selection; } | ||
2676 | + } | ||
2677 | + } | ||
2644 | #endregion fields | 2678 | #endregion fields |
2645 | public enum SQLDBStatus { NoAccess, OK, } | 2679 | public enum SQLDBStatus { NoAccess, OK, } |
2646 | 2680 | ||
@@ -2649,29 +2683,44 @@ GO | @@ -2649,29 +2683,44 @@ GO | ||
2649 | { | 2683 | { |
2650 | try | 2684 | try |
2651 | { | 2685 | { |
2652 | - string dbname = SQLDataBaseManagerCore.GetDBName(this.SQLCS); | ||
2653 | - if (string.IsNullOrWhiteSpace(dbname)) | 2686 | + if (!this.isSQLCSselected) |
2654 | { | 2687 | { |
2655 | - var sqlc = ServerConnectionPool.GetSqlConnection(this.SQLCS, open: true); | ||
2656 | - this.Status = SQLDBStatus.OK; | ||
2657 | - this.DBName = ""; | ||
2658 | - this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS); | ||
2659 | - } | ||
2660 | - else | 2688 | + this.Status = SQLDBStatus.OK; |
2689 | + this.DBName = ""; | ||
2690 | + this.DataSource = this.Xml_SQLConnectionString; | ||
2691 | + } | ||
2692 | + else | ||
2661 | { | 2693 | { |
2662 | - GetPhysicalFilesLocationAndSize(this.SQLCS, out this.SizeString, out this.PhysicalFilesDirectoryPath); | ||
2663 | - this.Status = this.PhysicalFilesDirectoryPath.StartsWith("ERR") ? SQLDBStatus.NoAccess : SQLDBStatus.OK; | ||
2664 | - this.DBName = SQLDataBaseManagerCore.GetDBName(this.SQLCS); | ||
2665 | - this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS); | ||
2666 | - } | 2694 | + string dbname = SQLDataBaseManagerCore.GetDBName(this.SQLCS); |
2695 | + if (string.IsNullOrWhiteSpace(dbname)) | ||
2696 | + { | ||
2697 | + var sqlc = ServerConnectionPool.GetSqlConnection(this.SQLCS, open: true); | ||
2698 | + this.Status = SQLDBStatus.OK; | ||
2699 | + this.DBName = ""; | ||
2700 | + this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS); | ||
2701 | + } | ||
2702 | + else | ||
2703 | + { | ||
2704 | + GetPhysicalFilesLocationAndSize(this.SQLCS, out this.SizeString, out this.PhysicalFilesDirectoryPath); | ||
2705 | + this.Status = this.PhysicalFilesDirectoryPath.StartsWith("ERR") ? SQLDBStatus.NoAccess : SQLDBStatus.OK; | ||
2706 | + this.DBName = SQLDataBaseManagerCore.GetDBName(this.SQLCS); | ||
2707 | + this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS); | ||
2708 | + } | ||
2709 | + } | ||
2667 | } | 2710 | } |
2668 | catch | 2711 | catch |
2669 | { | 2712 | { |
2670 | this.Status = SQLDBStatus.NoAccess; | 2713 | this.Status = SQLDBStatus.NoAccess; |
2671 | this.PhysicalFilesDirectoryPath = ""; | 2714 | this.PhysicalFilesDirectoryPath = ""; |
2672 | - this.DBName = SQLDataBaseManagerCore.GetDBName(this.SQLCS); | ||
2673 | - this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS); | ||
2674 | - this.SizeString = ""; | 2715 | + this.DBName = ""; |
2716 | + this.DataSource = ""; | ||
2717 | + this.SizeString = ""; | ||
2718 | + try | ||
2719 | + { | ||
2720 | + this.DBName = SQLDataBaseManagerCore.GetDBName(this.SQLCS); | ||
2721 | + this.DataSource = SQLDataBaseManagerCore.GetDataSource(this.SQLCS); | ||
2722 | + } | ||
2723 | + catch { } | ||
2675 | } | 2724 | } |
2676 | return this; | 2725 | return this; |
2677 | } | 2726 | } |
@@ -2909,9 +2958,41 @@ GO | @@ -2909,9 +2958,41 @@ GO | ||
2909 | public string ScriptParameters=null; | 2958 | public string ScriptParameters=null; |
2910 | public string MultirunParameters=null; | 2959 | public string MultirunParameters=null; |
2911 | public string SQLConnectionString=null; | 2960 | public string SQLConnectionString=null; |
2961 | + private string SQLConnectionStringSelected=null; | ||
2962 | + public bool isSQLCSselected | ||
2963 | + { | ||
2964 | + get | ||
2965 | + { | ||
2966 | + var sqlcsList = this.SQLConnectionString.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries).ToList(); | ||
2967 | + return sqlcsList.Count() == 1 || !string.IsNullOrWhiteSpace(this.SQLConnectionStringSelected); | ||
2968 | + } | ||
2969 | + } | ||
2912 | public string SQLCS | 2970 | public string SQLCS |
2913 | { | 2971 | { |
2914 | - get { return XmlProcessing.ConnectionStringStore.GetSQL(this.SQLConnectionString); } | 2972 | + get |
2973 | + { | ||
2974 | + if (string.IsNullOrWhiteSpace(this.SQLConnectionStringSelected)) { SelectSQLConnectionString(); } | ||
2975 | + if (string.IsNullOrWhiteSpace(this.SQLConnectionStringSelected)) { return null; } | ||
2976 | + return XmlProcessing.ConnectionStringStore.GetSQL(this.SQLConnectionStringSelected); | ||
2977 | + } | ||
2978 | + } | ||
2979 | + | ||
2980 | + public void SelectSQLConnectionString(int? forceselection = null) | ||
2981 | + { | ||
2982 | + this.SQLConnectionStringSelected = null; | ||
2983 | + var sqlcsList = this.SQLConnectionString.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries).ToList(); | ||
2984 | + if (forceselection.HasValue) | ||
2985 | + { | ||
2986 | + if (forceselection.Value >= 0 && sqlcsList.Count() > forceselection.Value) { this.SQLConnectionStringSelected = sqlcsList[forceselection.Value]; } | ||
2987 | + return; | ||
2988 | + } | ||
2989 | + else | ||
2990 | + { | ||
2991 | + if (sqlcsList.Count() == 1) { this.SQLConnectionStringSelected = sqlcsList[0]; return; } | ||
2992 | + var selection = ColorConsole.ReadLine("Select SQL connection string to use:", bracket: "[]", suffix: "[ENTER]==first", validitylist: sqlcsList); | ||
2993 | + if (selection == "EX") return; | ||
2994 | + if (string.IsNullOrWhiteSpace(selection)) { this.SQLConnectionStringSelected = sqlcsList[0]; } else { this.SQLConnectionStringSelected = selection; } | ||
2995 | + } | ||
2915 | } | 2996 | } |
2916 | 2997 | ||
2917 | public SQLScript() { } | 2998 | public SQLScript() { } |
@@ -3066,7 +3147,8 @@ GO | @@ -3066,7 +3147,8 @@ GO | ||
3066 | { | 3147 | { |
3067 | var scb = new SqlConnectionStringBuilder(sqlconnectionstring); | 3148 | var scb = new SqlConnectionStringBuilder(sqlconnectionstring); |
3068 | if (!string.IsNullOrWhiteSpace(dbname)) { scb.InitialCatalog = dbname; } | 3149 | if (!string.IsNullOrWhiteSpace(dbname)) { scb.InitialCatalog = dbname; } |
3069 | - if (!string.IsNullOrWhiteSpace(userid) && !string.IsNullOrWhiteSpace(userpassword)) { scb.UserID = userid; scb.Password = userpassword; } | 3150 | + if (string.IsNullOrWhiteSpace(scb.InitialCatalog)) { scb.InitialCatalog = "master"; scb.AttachDBFilename = ""; } |
3151 | + if (!string.IsNullOrWhiteSpace(userid) && !string.IsNullOrWhiteSpace(userpassword)) { scb.UserID = userid; scb.Password = userpassword; } | ||
3070 | else if (!string.IsNullOrWhiteSpace(userid) && string.IsNullOrWhiteSpace(userpassword)) { scb.UserID = userid; scb.IntegratedSecurity = true; } | 3152 | else if (!string.IsNullOrWhiteSpace(userid) && string.IsNullOrWhiteSpace(userpassword)) { scb.UserID = userid; scb.IntegratedSecurity = true; } |
3071 | var sqlc = new SqlConnection(scb.ToString()); | 3153 | var sqlc = new SqlConnection(scb.ToString()); |
3072 | if (open) Open(sqlc); | 3154 | if (open) Open(sqlc); |
@@ -3075,15 +3157,12 @@ GO | @@ -3075,15 +3157,12 @@ GO | ||
3075 | public static void Open(SqlConnection sqlc) | 3157 | public static void Open(SqlConnection sqlc) |
3076 | { | 3158 | { |
3077 | if (IsMasterInacessible(sqlc) || IsInacessible(sqlc)) { throw new Exception($"SQL server {sqlc.DataSource} is inaccessible!"); } | 3159 | if (IsMasterInacessible(sqlc) || IsInacessible(sqlc)) { throw new Exception($"SQL server {sqlc.DataSource} is inaccessible!"); } |
3078 | - if (!string.IsNullOrWhiteSpace(sqlc.Database)) | 3160 | + try { sqlc.Open(); } |
3161 | + catch (Exception ex) | ||
3079 | { | 3162 | { |
3080 | - try { sqlc.Open(); } | ||
3081 | - catch (Exception ex) | ||
3082 | - { | ||
3083 | - MarkMasterInacessible(sqlc); | ||
3084 | - MarkInacessible(sqlc); | ||
3085 | - throw ex; | ||
3086 | - } | 3163 | + MarkMasterInacessible(sqlc); |
3164 | + MarkInacessible(sqlc); | ||
3165 | + throw ex; | ||
3087 | } | 3166 | } |
3088 | } | 3167 | } |
3089 | private static bool IsMasterDBConnected(SqlConnection sqlc) | 3168 | private static bool IsMasterDBConnected(SqlConnection sqlc) |
Vrh.Log4Pro.MaintenanceConsole/Properties/AssemblyInfo.cs
@@ -32,5 +32,5 @@ using System.Runtime.InteropServices; | @@ -32,5 +32,5 @@ using System.Runtime.InteropServices; | ||
32 | // You can specify all the values or you can default the Build and Revision Numbers | 32 | // You can specify all the values or you can default the Build and Revision Numbers |
33 | // by using the '*' as shown below: | 33 | // by using the '*' as shown below: |
34 | // [assembly: AssemblyVersion("1.0.*")] | 34 | // [assembly: AssemblyVersion("1.0.*")] |
35 | -[assembly: AssemblyVersion("1.31.3.0")] | ||
36 | -[assembly: AssemblyFileVersion("1.31.3.0")] | 35 | +[assembly: AssemblyVersion("1.31.4.0")] |
36 | +[assembly: AssemblyFileVersion("1.31.4.0")] |