//===================================================================== /// <summary> /// Constructor /// </summary> /// <param name="configuration">The configuration to edit</param> public DeploymentConfigDlg(XElement configuration) { InitializeComponent(); this.configuration = configuration ?? throw new ArgumentNullException(nameof(configuration)); // Load the current settings if (!configuration.IsEmpty) { chkDeleteAfterDeploy.IsChecked = (bool)configuration.Attribute("deleteAfterDeploy"); chkVerboseLogging.IsChecked = (bool?)configuration.Attribute("verboseLogging") ?? false; // Get HTML Help 1 deployment information ucHelp1.LoadFromSettings(DeploymentLocation.FromXml(configuration, "help1x")); // Get MS Help Viewer deployment information var msHelpViewer = configuration.XPathSelectElement("deploymentLocation[@id='helpViewer']"); if (msHelpViewer != null) { chkRenameMSHA.IsChecked = (bool)msHelpViewer.Attribute("renameMSHA"); } ucMSHelpViewer.LoadFromSettings(DeploymentLocation.FromXml(configuration, "helpViewer")); // Get website deployment information ucWebsite.LoadFromSettings(DeploymentLocation.FromXml(configuration, "website")); // Get Open XML deployment information ucOpenXml.LoadFromSettings(DeploymentLocation.FromXml(configuration, "openXml")); // Get markdown content deployment information ucMarkdown.LoadFromSettings(DeploymentLocation.FromXml(configuration, "markdown")); } }
public static SqlConnectionStringBuilder GetDatabaseConnectionStringBuilder(DeploymentLocation deploymentLocation) { var builder = new SqlConnectionStringBuilder(); builder.InitialCatalog = "AffinityDmsDesktop"; builder.IntegratedSecurity = true; builder.MultipleActiveResultSets = true; switch (deploymentLocation) { case DeploymentLocation.W10EeVs2015CeU2: { builder.DataSource = @"W10EEVS2015CEU2\MSSQLEXPRESS2014"; break; } case DeploymentLocation.HosHp: { builder.DataSource = @"HOSLAPTOPHP\MSSQLS2016EXP"; break; } case DeploymentLocation.HosMonster: { builder.DataSource = @"MONSTER\MSSQLEXPRESS2014"; break; } case DeploymentLocation.HosRkPc: { builder.DataSource = @"RAHEELKHAN-PC\SQLEXPRESS"; break; } case DeploymentLocation.HosKausar: { builder.DataSource = @"KAUSARPC\SQLEXPRESSKAUSAR"; break; } case DeploymentLocation.BtsRizwan: { builder.DataSource = "."; break; } case DeploymentLocation.BtsDanish: { builder.DataSource = "."; break; } case DeploymentLocation.BtsUzma: { builder.DataSource = "."; break; } case DeploymentLocation.BtsSaleem: { builder.DataSource = "benztech-pc"; break; } case DeploymentLocation.BtsUsmanJamal: { builder.DataSource = @"HOME-PC\SqlExpress2014"; break; } case DeploymentLocation.BtsFabehaMalik: { builder.DataSource = @"FABEHA-HDK\SQLEXPRESS"; break; } case DeploymentLocation.BtsFaraz: { builder.DataSource = @"BENZFARAZ-PC\SQLEXPRESS"; builder.UserID = @"sa"; builder.Password = @"123456"; builder.PersistSecurityInfo = true; builder.IntegratedSecurity = false; break; } default: { builder.DataSource = ""; break; } } //builder.InitialCatalog = @""; //builder.DataSource = @"(LocalDb)\v11.0"; //builder.IntegratedSecurity = true; //builder.MultipleActiveResultSets = true; //builder.AttachDBFilename = AffinityConfigurationDesktop.FileApplicationData.FullName; return(builder); }
/// <summary> /// Get a list of the possible names (ordered by priority) that the setting /// could have in the config file, depending on the supplied location. /// </summary> /// <returns></returns> private static IEnumerable<string> GetLocationizedNames(DeploymentLocation loc, string name) { if (loc == DeploymentLocation.Live) yield return name + "-live"; if (loc == DeploymentLocation.Dev) yield return name + "-dev"; if (loc == DeploymentLocation.Local) { yield return name + "-local"; yield return name + "-dev"; } if (loc == DeploymentLocation.Cassini) { yield return name + "-cassini"; yield return name + "-local"; yield return name + "-dev"; } yield return name; }
//===================================================================== /// <summary> /// Load the control values from the specified deployment location /// settings object. /// </summary> /// <param name="location">The location settings</param> public void LoadFromSettings(DeploymentLocation location) { if (location == null) { throw new ArgumentNullException(nameof(location)); } txtTargetLocation.Text = location.Location?.OriginalString; chkUseDefaultCredentials.IsChecked = location.UserCredentials.UseDefaultCredentials; txtUserName.Text = location.UserCredentials.UserName; txtPassword.Text = location.UserCredentials.Password; chkUseProxyServer.IsChecked = location.ProxyCredentials.UseProxyServer; txtProxyServer.Text = location.ProxyCredentials.ProxyServer?.OriginalString; chkUseProxyDefCreds.IsChecked = location.ProxyCredentials.Credentials.UseDefaultCredentials; txtProxyUserName.Text = location.ProxyCredentials.Credentials.UserName; txtProxyPassword.Text = location.ProxyCredentials.Credentials.Password; }
public static SqlConnectionStringBuilder GetDatabaseConnectionStringBuilder(DeploymentLocation deploymentLocation) { var builder = new SqlConnectionStringBuilder(); builder.IntegratedSecurity = true; builder.MultipleActiveResultSets = true; builder.InitialCatalog = "AffinityDmsMaster"; switch (deploymentLocation) { case DeploymentLocation.W10EeVs2015CeU2: { builder.DataSource = @"W10EEVS2015CEU2\MSSQLEXPRESS2014"; break; } case DeploymentLocation.HosHp: { builder.DataSource = @"HOSLAPTOPHP\MSSQLS2016EXP"; break; } case DeploymentLocation.HosMonster: { builder.DataSource = @"MONSTER\MSSQLEXPRESS2014"; break; } case DeploymentLocation.HosRkPc: { builder.DataSource = @"RAHEELKHAN-PC\SQLEXPRESS"; break; } case DeploymentLocation.HosKausar: { builder.DataSource = @"KAUSARPC\SQLEXPRESSKAUSAR"; break; } case DeploymentLocation.BtsRizwan: { builder.DataSource = @"."; break; } case DeploymentLocation.BtsDanish: { builder.DataSource = @"."; break; } case DeploymentLocation.BtsUsmanJamal: { builder.DataSource = @"HOME-PC\SqlExpress2014"; break; } case DeploymentLocation.BtsFabehaMalik: { builder.DataSource = @"FABEHA-HDK\SQLEXPRESS"; break; } case DeploymentLocation.BtsUzma: { builder.DataSource = @"UZMA-PC\SQLEXPRESS"; builder.UserID = @"sa"; builder.Password = @"123456"; builder.PersistSecurityInfo = true; builder.IntegratedSecurity = false; break; } case DeploymentLocation.BtsSaleem: { builder.DataSource = @"UzmaHashmi\SqlServer2014"; builder.UserID = @"sa"; builder.Password = @"123456"; builder.PersistSecurityInfo = true; builder.IntegratedSecurity = false; break; } case DeploymentLocation.KsManjuLenovo: { builder.DataSource = @"LENOVO"; //builder.UserID = @"sa"; //builder.Password = @"123456"; builder.PersistSecurityInfo = true; builder.IntegratedSecurity = true; break; } case DeploymentLocation.KsAdmintech: { builder.DataSource = @"ADMINNTECH"; //builder.UserID = @"sa"; //builder.Password = @"123456"; builder.PersistSecurityInfo = true; builder.IntegratedSecurity = true; break; } case DeploymentLocation.KsThiya: { builder.DataSource = @"VAIO_HFTEH"; //builder.UserID = @"sa"; //builder.Password = @"123456"; builder.PersistSecurityInfo = true; builder.IntegratedSecurity = true; break; } case DeploymentLocation.Live: { builder.ConnectionString = @"Server=tcp:coboxdev.database.windows.net,1433;" + @"Database=Affinity-GlobalAdmin-DB;" + @"User ID=sysadmin;" + @"Password=KLS@dm1nKLS@dm1n;" + @"Encrypt=True;" + @"TrustServerCertificate=False;" + @"MultipleActiveResultSets=True;" + @"Connection Timeout=60;"; break; } default: { throw (new NotImplementedException()); } } return(builder); }
/// <summary> /// Validate the control values and, if valid, create and return a new /// deployment location settings object. /// </summary> /// <returns>The deployment location settings if they are valid or /// null if they are not valid.</returns> public DeploymentLocation CreateDeploymentLocation() { DeploymentLocation location = null; bool isValid = true; foreach (var c in new[] { txtTargetLocation, txtUserName, txtPassword, txtProxyServer, txtProxyUserName, txtProxyPassword }) { c.Text = c.Text.Trim(); c.SetValidationState(true, null); } if (txtTargetLocation.Text.Length == 0 || !Uri.TryCreate(txtTargetLocation.Text, UriKind.RelativeOrAbsolute, out Uri targetUri)) { targetUri = null; } if (txtTargetLocation.Text.Length != 0 && targetUri == null) { txtTargetLocation.SetValidationState(false, "The target location does not appear to be valid"); isValid = false; } if (!chkUseDefaultCredentials.IsChecked.Value) { if (txtUserName.Text.Length == 0) { txtUserName.SetValidationState(false, "A user name is required if not using default credentials"); isValid = false; } if (txtPassword.Text.Length == 0) { txtPassword.SetValidationState(false, "A password is required if not using default credentials"); isValid = false; } } if (!Uri.TryCreate(txtProxyServer.Text, UriKind.RelativeOrAbsolute, out Uri proxyServer)) { proxyServer = null; } if (chkUseProxyServer.IsChecked.Value) { if (txtProxyServer.Text.Length == 0) { txtProxyServer.SetValidationState(false, "A proxy server is required if one is used"); isValid = false; } else { if (proxyServer == null) { txtProxyServer.SetValidationState(false, "The proxy server name does not appear to be valid"); isValid = false; } } if (!chkUseProxyDefCreds.IsChecked.Value) { if (txtProxyUserName.Text.Length == 0) { txtProxyUserName.SetValidationState(false, "A user name is required if not using " + "default credentials"); isValid = false; } if (txtProxyPassword.Text.Length == 0) { txtProxyPassword.SetValidationState(false, "A password is required if not using default " + "credentials"); isValid = false; } } } if (isValid) { var userCreds = new UserCredentials(chkUseDefaultCredentials.IsChecked.Value, txtUserName.Text, txtPassword.Text); var proxyCreds = new ProxyCredentials(chkUseProxyServer.IsChecked.Value, proxyServer, new UserCredentials(chkUseProxyDefCreds.IsChecked.Value, txtProxyUserName.Text, txtProxyPassword.Text)); location = new DeploymentLocation(targetUri, userCreds, proxyCreds); } return(location); }