public static List <string> GetRecentServers(out ServerConnectConfig.ServerConfigurationDataTable serverConfigTbl) { serverConfigTbl = null; string homePath = SqlBuildManager.Logging.Configure.AppDataPath; List <string> recentDbs = new List <string>(); if (System.IO.File.Exists(Path.Combine(homePath, ConfigFileName))) { try { ServerConnectConfig config = new ServerConnectConfig(); config.ReadXml(Path.Combine(homePath, ConfigFileName)); serverConfigTbl = config.ServerConfiguration; DataView view = config.ServerConfiguration.DefaultView; view.Sort = config.ServerConfiguration.LastAccessedColumn.ColumnName + " DESC"; for (int i = 0; i < view.Count; i++) { recentDbs.Add(((ServerConnectConfig.ServerConfigurationRow)view[i].Row).Name); } } catch { } } return(recentDbs); }
public static AuthenticationType GetServerCredentials(ServerConnectConfig.ServerConfigurationDataTable serverConfigTbl, string serverName, out string username, out string password) { bool s; if (serverConfigTbl != null) { var row = serverConfigTbl.Where(r => r.Name.Trim().ToLower() == serverName.Trim().ToLower()); if (row.Any()) { var r = row.First(); if (!string.IsNullOrWhiteSpace(r.UserName)) { (s, username) = Cryptography.DecryptText(r.UserName, ConnectionHelper.ConnectCryptoKey, "UserName"); } else { username = string.Empty; } if (!string.IsNullOrWhiteSpace(r.Password)) { (s, password) = Cryptography.DecryptText(r.Password, ConnectionHelper.ConnectCryptoKey, "Password"); } else { password = string.Empty; } AuthenticationType authType; if (Enum.TryParse <AuthenticationType>(r.AuthenticationType, out authType)) { return(authType); } else { return(AuthenticationType.Password); } } } password = string.Empty; username = string.Empty; return(AuthenticationType.Password); }