/// <summary> /// This method ensures that a table object exists in the physical model against the catalog. /// </summary> /// <param name="fullyQualifiedValidationObject"></param> /// <param name="teamConnection"></param> /// <returns></returns> internal static string ValidateObjectExistencePhysical(KeyValuePair <string, string> fullyQualifiedValidationObject, TeamConnection teamConnection) { var conn = new SqlConnection { ConnectionString = teamConnection.CreateSqlServerConnectionString(false) }; conn.Open(); var localTable = fullyQualifiedValidationObject.Value.Replace("[", "").Replace("]", ""); var localSchema = fullyQualifiedValidationObject.Key.Replace("[", "").Replace("]", ""); // Execute the check var cmd = new SqlCommand( "SELECT CASE WHEN EXISTS ((SELECT * " + "FROM sys.objects a " + "JOIN sys.schemas b on a.schema_id = b.schema_id " + "WHERE a.[name] = '" + localTable + "' and b.[name]= '" + localSchema + "')) THEN 1 ELSE 0 END", conn); var exists = (int)cmd.ExecuteScalar() == 1; string returnExistenceEvaluation = exists.ToString(); conn.Close(); // return the result of the test; return(returnExistenceEvaluation); }
public void TestConnection(object sender, EventArgs e) { UpdateRichTextBoxInformation("Validating database connection.\r\n"); var connectionString = _localConnection.CreateSqlServerConnectionString(false); using (var connectionVersion = new SqlConnection(connectionString)) { try { connectionVersion.Open(); UpdateRichTextBoxInformation("The database connection could be successfully established.\r\n"); } catch (Exception) { UpdateRichTextBoxInformation("The database connection could not be established.\r\n"); } } }
/// <summary> /// This method ensures that an attribute object exists in the physical model against the catalog. /// </summary> /// <param name="validationObject"></param> /// <param name="validationAttribute"></param> /// <param name="teamConnection"></param> /// <returns></returns> internal static string ValidateAttributeExistencePhysical(string validationObject, string validationAttribute, TeamConnection teamConnection) { var returnExistenceEvaluation = "False"; // Temporary fix to allow 'transformations', in this case hard-coded NULL values to be loaded. if (validationAttribute != "NULL") { var fullyQualifiedValidationObject = MetadataHandling.GetFullyQualifiedDataObjectName(validationObject, teamConnection).FirstOrDefault(); var localTable = fullyQualifiedValidationObject.Value.Replace("[", "").Replace("]", ""); var localSchema = fullyQualifiedValidationObject.Key.Replace("[", "").Replace("]", ""); var conn = new SqlConnection { ConnectionString = teamConnection.CreateSqlServerConnectionString(false) }; conn.Open(); // Execute the check var cmd = new SqlCommand( "SELECT CASE WHEN EXISTS ((SELECT * FROM INFORMATION_SCHEMA.COLUMNS " + "WHERE " + "[TABLE_NAME] = '" + localTable + "' AND " + "[TABLE_SCHEMA] = '" + localSchema + "' AND " + "[COLUMN_NAME] = '" + validationAttribute + "')) THEN 1 ELSE 0 END", conn); var exists = (int)cmd.ExecuteScalar() == 1; returnExistenceEvaluation = exists.ToString(); conn.Close(); } else { // Set True if NULL returnExistenceEvaluation = "True"; } // return the result of the test; return(returnExistenceEvaluation); }
/// <summary> /// Validate the Business Key definition against the physical model, taking the source object and business key definition as input parameters, together with a connection string to validate against. /// </summary> /// <param name="validationObject"></param> /// <param name="connectionString"></param> /// <returns></returns> internal static Dictionary <Tuple <string, string>, bool> ValidateSourceBusinessKeyExistencePhysical(string validationObject, string businessKeyDefinition, TeamConnection teamConnection) { // First, the Business Keys for each table need to be identified information. This can be the combination of Business keys separated by a comma. // Every business key needs to be iterated over to validate if the attribute exists in that table. List <string> businessKeys = businessKeyDefinition.Split(',').ToList(); // Get the table the component belongs to if available var fullyQualifiedValidationObject = MetadataHandling.GetFullyQualifiedDataObjectName(validationObject, teamConnection).FirstOrDefault(); var localTable = fullyQualifiedValidationObject.Value.Replace("[", "").Replace("]", ""); var localSchema = fullyQualifiedValidationObject.Key.Replace("[", "").Replace("]", ""); // Now iterate over each table, as identified by the business key. var conn = new SqlConnection { ConnectionString = teamConnection.CreateSqlServerConnectionString(false) }; conn.Open(); Dictionary <Tuple <string, string>, bool> result = new Dictionary <Tuple <string, string>, bool>(); foreach (string businessKey in businessKeys) { var trimBusinessKey = businessKey.Trim(); // Handle concatenate and composite List <string> subKeys = new List <string>(); if (trimBusinessKey.StartsWith("CONCATENATE")) { var localBusinessKey = trimBusinessKey.Replace("CONCATENATE(", "").Replace(")", ""); subKeys = localBusinessKey.Split(';').ToList(); } else if (trimBusinessKey.StartsWith("COMPOSITE")) { var localBusinessKey = trimBusinessKey.Replace("COMPOSITE(", "").Replace(")", ""); subKeys = localBusinessKey.Split(';').ToList(); } else { subKeys.Add(trimBusinessKey); } foreach (string businessKeyPart in subKeys) { // Handle hard-coded business key values if (businessKeyPart.Trim().StartsWith("'") && businessKeyPart.Trim().EndsWith("'")) { // Do nothing } else { // Query the data dictionary to validate existence var cmd = new SqlCommand("SELECT CASE WHEN EXISTS (" + "(" + "SELECT * FROM sys.columns a " + "JOIN sys.objects b ON a.object_id = b.object_id " + "JOIN sys.schemas c on b.schema_id = c.schema_id " + "WHERE OBJECT_NAME(a.[object_id]) = '" + localTable + "' AND c.[name] = '" + localSchema + "' AND a.[name] = '" + businessKeyPart.Trim() + "'" + ")" + ") THEN 1 ELSE 0 END", conn); var exists = (int)cmd.ExecuteScalar() == 1; result.Add(Tuple.Create(validationObject, businessKeyPart.Trim()), exists); } } } conn.Close(); // Return the result of the test; return(result); }
internal static List <Tuple <string, string, bool> > BasicDataVaultValidation(string dataObjectName, TeamConnection teamConnection, MetadataHandling.TableTypes tableType) { // Initialise the return type List <Tuple <string, string, bool> > returnList = new List <Tuple <string, string, bool> >(); // Define the list to validate, this is different for each validation type. List <string> validationAttributeList = new List <string>(); switch (tableType) { case MetadataHandling.TableTypes.CoreBusinessConcept: validationAttributeList.Add(FormBase.TeamConfiguration.LoadDateTimeAttribute); break; case MetadataHandling.TableTypes.Context: if (FormBase.TeamConfiguration.EnableAlternativeSatelliteLoadDateTimeAttribute == "True") { validationAttributeList.Add(FormBase.TeamConfiguration.AlternativeSatelliteLoadDateTimeAttribute); } else { validationAttributeList.Add(FormBase.TeamConfiguration.LoadDateTimeAttribute); } validationAttributeList.Add(FormBase.TeamConfiguration.RecordChecksumAttribute); break; case MetadataHandling.TableTypes.NaturalBusinessRelationship: validationAttributeList.Add(FormBase.TeamConfiguration.LoadDateTimeAttribute); break; } // Now check if the attribute exists in the table foreach (string validationAttribute in validationAttributeList) { var fullyQualifiedValidationObject = MetadataHandling.GetFullyQualifiedDataObjectName(dataObjectName, teamConnection).FirstOrDefault(); var localTable = fullyQualifiedValidationObject.Value.Replace("[", "").Replace("]", ""); var localSchema = fullyQualifiedValidationObject.Key.Replace("[", "").Replace("]", ""); if (GlobalParameters.EnvironmentMode == EnvironmentModes.PhysicalMode) { var conn = new SqlConnection { ConnectionString = teamConnection.CreateSqlServerConnectionString(false) }; conn.Open(); // Execute the check var cmd = new SqlCommand( "SELECT CASE WHEN EXISTS ((SELECT * FROM INFORMATION_SCHEMA.COLUMNS " + "WHERE " + "[TABLE_NAME] = '" + localTable + "' AND " + "[TABLE_SCHEMA] = '" + localSchema + "' AND " + "[COLUMN_NAME] = '" + validationAttribute + "')) THEN 1 ELSE 0 END", conn); var exists = (int)cmd.ExecuteScalar() == 1; returnList.Add(new Tuple <string, string, bool>(localSchema + '.' + localTable, validationAttribute, exists)); conn.Close(); } } // return the result of the test; return(returnList); }
/// <summary> /// Constructor to instantiate a new Custom Tab Page. /// </summary> public CustomTabPageConnection(object input) { _localConnection = (TeamConnection)input; // Workaround to handle older config files that do not have this object yet. if (_localConnection.FileConnection == null) { TeamFileConnection connectionFile = new TeamFileConnection(); connectionFile.FilePath = @"<File Path>"; connectionFile.FileName = @"<File Name>"; _localConnection.FileConnection = connectionFile; } //var inputNiceName = Regex.Replace(connectionName, "(\\B[A-Z])", " $1"); #region Main Tab Page controls ToolTip toolTipConnections = new ToolTip(); toolTipConnections.AutoPopDelay = 3000; // Base properties of the custom tab page Name = $"{_localConnection.ConnectionKey}"; Text = _localConnection.ConnectionName; BackColor = Color.Transparent; BorderStyle = BorderStyle.None; UseVisualStyleBackColor = true; Size = new Size(1330, 601); AutoSizeMode = AutoSizeMode.GrowOnly; AutoSize = true; // Add Panel to facilitate docking var localPanel = new Panel(); Controls.Add(localPanel); localPanel.Dock = DockStyle.Fill; localPanel.AutoSize = true; localPanel.TabStop = false; #region Database connection controls // Add ConnectionString TextBox _textBoxConnectionString = new TextBox(); localPanel.Controls.Add(_textBoxConnectionString); _textBoxConnectionString.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _textBoxConnectionString.Location = new Point(6, 212); _textBoxConnectionString.Size = new Size(850, 21); _textBoxConnectionString.BorderStyle = BorderStyle.None; _textBoxConnectionString.BackColor = Color.White; _textBoxConnectionString.Name = $"textBoxConnectionString"; _textBoxConnectionString.ReadOnly = true; _textBoxConnectionString.TabStop = false; // Add GroupBox for Database content _groupBoxDatabase = new GroupBox(); localPanel.Controls.Add(_groupBoxDatabase); _groupBoxDatabase.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _groupBoxDatabase.Location = new Point(6, 6); _groupBoxDatabase.Size = new Size(502, 124); _groupBoxDatabase.Name = $"groupBoxDatabaseName"; _groupBoxDatabase.Text = $"Database"; _groupBoxDatabase.TabStop = false; // Add Database Label var labelDatabase = new Label(); _groupBoxDatabase.Controls.Add(labelDatabase); labelDatabase.Anchor = (AnchorStyles.Top | AnchorStyles.Left); labelDatabase.Location = new Point(6, 19); labelDatabase.Size = new Size(160, 13); labelDatabase.Name = $"labelDatabaseName"; labelDatabase.Text = $"Database name"; labelDatabase.TabStop = false; // Add Server Label var labelServer = new Label(); _groupBoxDatabase.Controls.Add(labelServer); labelServer.Anchor = (AnchorStyles.Top | AnchorStyles.Left); labelServer.Location = new Point(6, 44); labelServer.Size = new Size(160, 13); labelServer.Name = $"labelDatabaseServerName"; labelServer.Text = $"Database server name"; labelServer.TabStop = false; // Add Port Label var labelPortNumber = new Label(); _groupBoxDatabase.Controls.Add(labelPortNumber); labelPortNumber.Anchor = (AnchorStyles.Top | AnchorStyles.Left); labelPortNumber.Location = new Point(6, 69); labelPortNumber.Size = new Size(160, 13); labelPortNumber.Name = $"labelPortNumber"; labelPortNumber.Text = $"Database server port number"; labelPortNumber.TabStop = false; // Add Schema Label var labelSchema = new Label(); _groupBoxDatabase.Controls.Add(labelSchema); labelSchema.Anchor = (AnchorStyles.Top | AnchorStyles.Left); labelSchema.Location = new Point(6, 94); labelSchema.Size = new Size(160, 13); labelSchema.Name = $"labelSchema"; labelSchema.Text = $"Schema"; labelSchema.TabStop = false; // Add Database TextBox _textBoxDatabase = new TextBox(); _groupBoxDatabase.Controls.Add(_textBoxDatabase); _textBoxDatabase.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _textBoxDatabase.Location = new Point(172, 16); _textBoxDatabase.Size = new Size(317, 20); _textBoxDatabase.Name = $"textBoxDatabaseName"; _textBoxDatabase.Text = _localConnection.DatabaseServer.DatabaseName; _textBoxDatabase.TextChanged += new EventHandler(UpdateConnectionString); _textBoxDatabase.TabIndex = 1; // Add Server TextBox _textBoxServer = new TextBox(); _groupBoxDatabase.Controls.Add(_textBoxServer); _textBoxServer.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _textBoxServer.Location = new Point(172, 41); _textBoxServer.Size = new Size(317, 20); _textBoxServer.Name = $"textBoxServerName"; _textBoxServer.Text = _localConnection.DatabaseServer.ServerName; _textBoxServer.TextChanged += new EventHandler(UpdateConnectionString); _textBoxServer.TabIndex = 2; // Add Port Number TextBox _textBoxPortNumber = new TextBox(); _groupBoxDatabase.Controls.Add(_textBoxPortNumber); _textBoxPortNumber.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _textBoxPortNumber.Location = new Point(172, 69); _textBoxPortNumber.Size = new Size(317, 20); _textBoxPortNumber.Name = $"textBoxPortNumber"; _textBoxPortNumber.Text = _localConnection.DatabaseServer.PortNumber; _textBoxPortNumber.TextChanged += new EventHandler(UpdateConnectionString); _textBoxPortNumber.TabIndex = 3; toolTipConnections.SetToolTip(this._textBoxPortNumber, "Optional port number that can be used to connect to the database server."); // Add Schema TextBox _textBoxSchema = new TextBox(); _groupBoxDatabase.Controls.Add(_textBoxSchema); _textBoxSchema.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _textBoxSchema.Location = new Point(172, 94); _textBoxSchema.Size = new Size(317, 20); _textBoxSchema.Name = $"textBoxSchemaName"; _textBoxSchema.Text = _localConnection.DatabaseServer.SchemaName; _textBoxSchema.TextChanged += new EventHandler(UpdateConnectionString); _textBoxSchema.TabIndex = 4; // Add GroupBox for Authentication content _groupBoxAuthentication = new GroupBox(); localPanel.Controls.Add(_groupBoxAuthentication); _groupBoxAuthentication.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _groupBoxAuthentication.Location = new Point(6, 136); _groupBoxAuthentication.Size = new Size(140, 70); _groupBoxAuthentication.Name = $"groupBoxAuthentication"; _groupBoxAuthentication.Text = $"Authentication"; _groupBoxAuthentication.TabStop = false; // Add RadioButton for Integrated Security _radioButtonIntegratedSecurity = new RadioButton(); _groupBoxAuthentication.Controls.Add(_radioButtonIntegratedSecurity); _radioButtonIntegratedSecurity.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _radioButtonIntegratedSecurity.Location = new Point(6, 19); _radioButtonIntegratedSecurity.Size = new Size(106, 17); _radioButtonIntegratedSecurity.Name = $"radioButtonIntegratedSecurity"; _radioButtonIntegratedSecurity.Text = $@"Integrated (SSPI)"; _radioButtonIntegratedSecurity.Checked = _localConnection.DatabaseServer.IntegratedSecuritySelectionEvaluation(); _radioButtonIntegratedSecurity.CheckedChanged += (RadioButtonIntegratedSecurityCheckedChanged); _radioButtonIntegratedSecurity.TabIndex = 5; // Add RadioButton for Named User _radioButtonNamedUserSecurity = new RadioButton(); _groupBoxAuthentication.Controls.Add(_radioButtonNamedUserSecurity); _radioButtonNamedUserSecurity.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _radioButtonNamedUserSecurity.Location = new Point(6, 42); _radioButtonNamedUserSecurity.Size = new Size(84, 17); _radioButtonNamedUserSecurity.Name = $"radioButtonNamedUserSecurity"; _radioButtonNamedUserSecurity.Text = $@"Named User details"; _radioButtonNamedUserSecurity.Checked = _localConnection.DatabaseServer.NamedUserSecuritySelectionEvaluation(); _radioButtonNamedUserSecurity.CheckedChanged += (RadioButtonNamedUserCheckedChanged); _radioButtonNamedUserSecurity.TabIndex = 6; // Add GroupBox for Named User content _groupBoxNamedUser = new GroupBox(); localPanel.Controls.Add(_groupBoxNamedUser); _groupBoxNamedUser.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _groupBoxNamedUser.Location = new Point(152, 136); _groupBoxNamedUser.Size = new Size(356, 70); _groupBoxNamedUser.Name = $"groupBoxNamedUser"; _groupBoxNamedUser.Text = $"Named User details"; _groupBoxNamedUser.TabStop = false; // Add Username Label var labelUserName = new Label(); _groupBoxNamedUser.Controls.Add(labelUserName); labelUserName.Anchor = (AnchorStyles.Top | AnchorStyles.Left); labelUserName.Location = new Point(6, 19); labelUserName.Size = new Size(55, 13); labelUserName.Name = $"labelUserName"; labelUserName.Text = $"Username"; labelUserName.TabStop = false; // Add Password Label var labelPassword = new Label(); _groupBoxNamedUser.Controls.Add(labelPassword); labelPassword.Anchor = (AnchorStyles.Top | AnchorStyles.Left); labelPassword.Location = new Point(6, 44); labelPassword.Size = new Size(53, 13); labelPassword.Name = $"labelPassword"; labelPassword.Text = $"Password"; labelPassword.TabStop = false; // Add Username TextBox _textboxUserName = new TextBox(); _groupBoxNamedUser.Controls.Add(_textboxUserName); _textboxUserName.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _textboxUserName.Location = new Point(67, 16); _textboxUserName.Size = new Size(276, 20); _textboxUserName.Name = $"textboxUserName"; _textboxUserName.Text = _localConnection.DatabaseServer.NamedUserName; _textboxUserName.TextChanged += UpdateConnectionString; _textboxUserName.TabIndex = 7; // Add Password TextBox _textBoxPassword = new MaskedTextBox(); _groupBoxNamedUser.Controls.Add(_textBoxPassword); _textBoxPassword.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _textBoxPassword.Location = new Point(67, 41); _textBoxPassword.Size = new Size(276, 20); _textBoxPassword.PasswordChar = '*'; _textBoxPassword.Name = $"textboxUserName"; _textBoxPassword.Text = _localConnection.DatabaseServer.NamedUserPassword; _textBoxPassword.TextChanged += new EventHandler(UpdateConnectionStringWithPassword); _textBoxPassword.TabIndex = 8; #endregion // Add GroupBox for File Connection content _groupBoxFileConnection = new GroupBox(); localPanel.Controls.Add(_groupBoxFileConnection); _groupBoxFileConnection.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _groupBoxFileConnection.Location = new Point(6, 6); _groupBoxFileConnection.Size = new Size(502, 124); _groupBoxFileConnection.Name = $"groupBoxFileConnection"; _groupBoxFileConnection.Text = $"File"; _groupBoxFileConnection.TabStop = false; // Add File Path Label _labelFilePath = new Label(); _groupBoxFileConnection.Controls.Add(_labelFilePath); _labelFilePath.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _labelFilePath.Location = new Point(6, 19); _labelFilePath.Size = new Size(100, 13); _labelFilePath.Name = $"labelFilePath"; _labelFilePath.Text = $"File path"; _labelFilePath.TabStop = false; // Add File Name Label _labelFileName = new Label(); _groupBoxFileConnection.Controls.Add(_labelFileName); _labelFileName.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _labelFileName.Location = new Point(6, 44); _labelFileName.Size = new Size(100, 13); _labelFileName.Name = $"labelFileName"; _labelFileName.Text = $"File name"; _labelFileName.TabStop = false; // Add File Path TextBox _textBoxFilePath = new TextBox(); _groupBoxFileConnection.Controls.Add(_textBoxFilePath); _textBoxFilePath.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _textBoxFilePath.Location = new Point(122, 16); _textBoxFilePath.Size = new Size(367, 20); _textBoxFilePath.Name = $"textBoxFilePath"; _textBoxFilePath.Text = _localConnection.FileConnection.FilePath; _textBoxFilePath.TextChanged += (UpdateConnectionFilePath); _textBoxFilePath.TabIndex = 1; // Add File Name TextBox _textBoxFileName = new TextBox(); _groupBoxFileConnection.Controls.Add(_textBoxFileName); _textBoxFileName.Anchor = (AnchorStyles.Top | AnchorStyles.Left); _textBoxFileName.Location = new Point(122, 41); _textBoxFileName.Size = new Size(367, 20); _textBoxFileName.Name = $"textBoxFileName"; _textBoxFileName.Text = _localConnection.FileConnection.FileName; _textBoxFileName.TextChanged += (UpdateConnectionFileName); _textBoxFileName.TabIndex = 2; #region Connection generic controls // Add GroupBox for Connection content var groupBoxConnection = new GroupBox(); localPanel.Controls.Add(groupBoxConnection); groupBoxConnection.Anchor = (AnchorStyles.Top | AnchorStyles.Left); groupBoxConnection.Location = new Point(516, 6); groupBoxConnection.Size = new Size(502, 200); groupBoxConnection.Name = $"groupBoxConnection"; groupBoxConnection.Text = $"Connection"; groupBoxConnection.TabStop = false; // Add Connection Key Label var labelConnectionKey = new Label(); groupBoxConnection.Controls.Add(labelConnectionKey); //labelConnectionKey.Anchor = (AnchorStyles.Top | AnchorStyles.Right); labelConnectionKey.Location = new Point(6, 19); labelConnectionKey.Size = new Size(160, 13); labelConnectionKey.Name = $"labelConnectionKey"; labelConnectionKey.Text = $"Connection key"; //labelConnectionKey.TextChanged += new EventHandler(ManageKeyNameChange); labelConnectionKey.TabStop = false; // Add Connection Name Label var labelConnectionName = new Label(); groupBoxConnection.Controls.Add(labelConnectionName); //labelConnectionName.Anchor = (AnchorStyles.Top | AnchorStyles.Right); labelConnectionName.Location = new Point(6, 44); labelConnectionName.Size = new Size(160, 13); labelConnectionName.Name = $"labelConnectionName"; labelConnectionName.Text = $"Connection name"; labelConnectionName.TabStop = false; // Add Connection Type Label var labelConnectionType = new Label(); groupBoxConnection.Controls.Add(labelConnectionType); labelConnectionType.Location = new Point(6, 69); labelConnectionType.Size = new Size(160, 13); labelConnectionType.Name = $"labelConnectionType"; labelConnectionType.Text = $"Connection type"; labelConnectionType.TabStop = false; // Add Connection Notes Label var labelConnectionNotes = new Label(); groupBoxConnection.Controls.Add(labelConnectionNotes); labelConnectionNotes.Location = new Point(6, 119); labelConnectionNotes.Size = new Size(160, 13); labelConnectionNotes.Name = $"labelConnectionNotes"; labelConnectionNotes.Text = $"Connection notes"; labelConnectionNotes.TabStop = false; // Add Connection Key TextBox _textBoxConnectionKey = new TextBox(); groupBoxConnection.Controls.Add(_textBoxConnectionKey); _textBoxConnectionKey.Location = new Point(172, 16); _textBoxConnectionKey.Size = new Size(317, 20); _textBoxConnectionKey.Name = $"textBoxServerName"; _textBoxConnectionKey.Text = _localConnection.ConnectionKey; _textBoxConnectionKey.TextChanged += (UpdateConnectionKey); _textBoxConnectionKey.TabIndex = 50; toolTipConnections.SetToolTip(this._textBoxConnectionKey, "The Connection Key is a short and easily recognisable reference for the connection that can be used within TEAM."); // Add Connection Name TextBox _textBoxConnectionName = new TextBox(); groupBoxConnection.Controls.Add(_textBoxConnectionName); _textBoxConnectionName.Location = new Point(172, 41); _textBoxConnectionName.Size = new Size(317, 20); _textBoxConnectionName.Name = $"textBoxConnectionName"; _textBoxConnectionName.Text = _localConnection.ConnectionName; _textBoxConnectionName.TextChanged += (UpdateConnectionName); _textBoxConnectionName.TabIndex = 51; // Add Connection Type Radiobutton for Database _radioButtonDatabase = new RadioButton(); groupBoxConnection.Controls.Add(_radioButtonDatabase); _radioButtonDatabase.Location = new Point(172, 66); //_textBoxConnectionName.Size = new Size(317, 20); _radioButtonDatabase.Name = $"radioButtonDatabase"; _radioButtonDatabase.Text = ConnectionTypes.Database.ToString(); _radioButtonDatabase.CheckedChanged += (UpdateConnectionTypeControls); _radioButtonDatabase.TabIndex = 52; // Add Connection Type Radiobutton for File _radioButtonFile = new RadioButton(); groupBoxConnection.Controls.Add(_radioButtonFile); _radioButtonFile.Location = new Point(172, 88); //_textBoxConnectionName.Size = new Size(317, 20); _radioButtonFile.Name = $"radioButtonFile"; _radioButtonFile.Text = ConnectionTypes.File.ToString(); _radioButtonFile.CheckedChanged += (UpdateConnectionTypeControls); _radioButtonFile.TabIndex = 53; SetConnectionTypesRadioButton(); // Add Connection Notes Panel var panelConnectionNotes = new Panel(); groupBoxConnection.Controls.Add(panelConnectionNotes); panelConnectionNotes.Location = new Point(172, 119); panelConnectionNotes.Size = new Size(317, 71); panelConnectionNotes.Name = $"panelConnectionNotes"; panelConnectionNotes.BorderStyle = BorderStyle.FixedSingle; // Add Connection Notes RichTextBox _richTextBoxConnectionNotes = new RichTextBox(); _richTextBoxConnectionNotes.TabIndex = 54; panelConnectionNotes.Controls.Add(_richTextBoxConnectionNotes); _richTextBoxConnectionNotes.Name = $"richTextBoxConnectionNotes"; _richTextBoxConnectionNotes.BorderStyle = BorderStyle.None; _richTextBoxConnectionNotes.Dock = DockStyle.Fill; _richTextBoxConnectionNotes.Text = _localConnection.ConnectionNotes; _richTextBoxConnectionNotes.TextChanged += (UpdateConnectionNotes); toolTipConnections.SetToolTip(this._richTextBoxConnectionNotes, "Free format notes to provide additional information about the connection."); #endregion // Add Save Button Button saveButton = new Button(); localPanel.Controls.Add(saveButton); saveButton.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left); saveButton.Location = new Point(6, 555); saveButton.Size = new Size(120, 40); saveButton.Name = $"saveButton"; saveButton.Text = $"Save Connection"; saveButton.Click += (SaveConnection); saveButton.TabIndex = 60; // Add Delete Button Button deleteButton = new Button(); localPanel.Controls.Add(deleteButton); deleteButton.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left); deleteButton.Location = new Point(132, 555); deleteButton.Size = new Size(120, 40); deleteButton.Name = $"deleteButton"; deleteButton.Text = $"Delete Connection"; deleteButton.Click += (DeleteConnection); deleteButton.TabIndex = 70; // Add test Button Button testButton = new Button(); localPanel.Controls.Add(testButton); testButton.Anchor = (AnchorStyles.Bottom | AnchorStyles.Left); testButton.Location = new Point(258, 555); testButton.Size = new Size(120, 40); testButton.Name = $"testButton"; testButton.Text = $"Test Connection"; testButton.Click += (TestConnection); testButton.TabIndex = 80; #endregion #region Constructor Methods // Prevention of double hitting of some event handlers this.StartUpIndicator = false; // Retrieve the values from memory bool localSSPI = _localConnection.DatabaseServer.IntegratedSecuritySelectionEvaluation(); bool localNamed = _localConnection.DatabaseServer.NamedUserSecuritySelectionEvaluation(); // Display the connection string results _textBoxConnectionString.Text = _localConnection.CreateSqlServerConnectionString(true); if (_radioButtonIntegratedSecurity.Checked) { _groupBoxNamedUser.Visible = false; } #endregion }