/// <summary>
        /// This event is fired when the Test Database Connection button is clieccked.
        /// </summary>
        private void TestDatabaseConnectionButton_Click(object sender, EventArgs e)
        {
            try
            {
                // set the connectionTest
                bool connectionTest = false;

                // Set the connectionString
                string connectionString = this.ConnectionStringTextBox.Text;

                // test for a connectionString
                bool hasConnectionString = (!String.IsNullOrEmpty(connectionString));

                // if a connection string has been established
                if (hasConnectionString)
                {
                    // set the dataConnector
                    SQLDatabaseConnector dataConnector = new SQLDatabaseConnector();

                    // set the connection string
                    dataConnector.ConnectionString = connectionString;

                    // Test the connection
                    connectionTest = SQLDatabaseTester.TestDatabaseConnection(dataConnector);

                    // if the connection test passed
                    if (connectionTest)
                    {
                        // Show success icon
                        PassedImage.Visible = true;
                    }
                    else
                    {
                        // Show a success message
                        FailedImage.Visible = false;
                    }

                    // Start the timer to hide the images in 3 seconds
                    Timer.Start();
                }
                else
                {
                    // Show a warning message
                    MessageBox.Show("You must build or enter a connection string.", "Missing Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception error)
            {
                // for debugging only
                string err = error.ToString();

                // Show a success message
                MessageBox.Show("A connection to the database count not be estalished.", "Connection Test Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// This method returns the Create Xml File
        /// </summary>
        public bool ValidateCreateXmlFile()
        {
            // initial value
            bool isValid = false;

            // locals
            bool validXmlFile = false;
            bool sourceDatabaseConnectionPassed = false;

            // if the SourceDatabaseConnectionString exists and the OutputXmlFilePath exists
            if ((this.HasSourceDatabaseConnectionString) && (this.HasOutputXmlFilePath))
            {
                // Create the SourceDatabaseConnector
                this.SourceDatabaseConnector = new SQLDatabaseConnector();

                // Set the database connector
                this.SourceDatabaseConnector.ConnectionString = this.SourceDatabaseConnectionString;

                // Test the SourceDatabaseConnection
                sourceDatabaseConnectionPassed = SQLDatabaseTester.TestDatabaseConnection(this.SourceDatabaseConnector);

                // validate a valid Xml File Path
                validXmlFile = ValidateXmlFile(this.OutputXmlFilePath, false);

                // if the sourceDatabaseConnectionPassed and the validXmlFile
                if ((sourceDatabaseConnectionPassed) && (validXmlFile))
                {
                    // Set to true
                    isValid = true;
                }
                else if ((!sourceDatabaseConnectionPassed) && (!validXmlFile))
                {
                    // Set to true
                    this.InvalidReason = "The 'Source Database Connection' failed to connect and the 'Output Xml File' is not valid.";
                }
                else if (!sourceDatabaseConnectionPassed)
                {
                    // Set to true
                    this.InvalidReason = "The 'Source Database Connection' failed to connect.";
                }
                else if (!validXmlFile)
                {
                    // Set to true
                    this.InvalidReason = "The 'Output Xml File' is not valid.";
                }
            }
            else if ((!this.HasSourceDatabaseConnectionString) && (!HasOutputXmlFilePath))
            {
                // Set to true
                this.InvalidReason = "The 'Source Database Connection' must be set and 'Output Xml File' must be set.";
            }
            else if (!this.HasSourceDatabaseConnectionString)
            {
                // Set to true
                this.InvalidReason = "The 'Source Database Connection' must be set.";
            }
            else if (!this.HasOutputXmlFilePath)
            {
                // Set to true
                this.InvalidReason = "The 'Output Xml File' must be set.";
            }

            // return value
            return(isValid);
        }
Exemplo n.º 3
0
        /// <summary>
        /// This method returns the Xml File And SQL Database
        /// </summary>
        public bool ValidateXmlFileAndSQLDatabase()
        {
            // initial value
            bool isValid = false;

            // local
            bool targetDatabaseConnectionPassed = false;
            bool sourceXmlFileIsValid           = false;

            // if the SourceXmlFilePath exists and the TargetDatabaseConnectionString exists
            if ((this.HasSourceXmlFilePath) && (this.HasTargetDatabaseConnectionString))
            {
                // Create The TargetDatabaseConnector
                this.targetDatabaseConnector = new SQLDatabaseConnector();

                // Set the ConnectionString
                this.TargetDatabaseConnector.ConnectionString = this.TargetDatabaseConnectionString;

                // test the TargetDatabaseConnector
                targetDatabaseConnectionPassed = SQLDatabaseTester.TestDatabaseConnection(this.TargetDatabaseConnector);

                // set the sourceXmlFileIsValid
                sourceXmlFileIsValid = ValidateXmlFile(this.SourceXmlFilePath, true);

                // For now set this to valid, the Xml
                isValid = ((targetDatabaseConnectionPassed) && (sourceXmlFileIsValid));

                // if the value for isValid is false
                if (!isValid)
                {
                    // if the TargetDatabaseConnectionPassed is false and the sourceXmlFile is not valid
                    if ((!targetDatabaseConnectionPassed) && (!sourceXmlFileIsValid))
                    {
                        // The Source Xml File is not valid
                        this.InvalidReason = "The 'Source Xml File' is not valid and the 'Target Database Connection' failed to connect";
                    }
                    else if (!targetDatabaseConnectionPassed)
                    {
                        // The Source Xml File is not valid
                        this.InvalidReason = "The 'Target Database Connection' failed to connect";
                    }
                    else
                    {
                        // The Source Xml File is not valid
                        this.InvalidReason = "The 'Source Xml File' is not valid";
                    }
                }
            }
            else if ((!this.HasTargetDatabaseConnectionString) && (!sourceXmlFileIsValid))
            {
                // If the InvalidReason
                this.InvalidReason = "The 'Target Connection String' and the 'Source Xml File' must both be set";
            }
            else if (!this.HasTargetDatabaseConnectionString)
            {
                // If the InvalidReason
                this.InvalidReason = "The 'Target Connection String' must be set.";
            }
            else if (!this.HasSourceXmlFilePath)
            {
                // If the InvalidReason
                this.InvalidReason = "The 'Source Xml File' must be set";
            }

            // return value
            return(isValid);
        }
Exemplo n.º 4
0
        /// <summary>
        /// This method returns the Two SQL Databases
        /// </summary>
        public bool ValidateTwoSQLDatabases()
        {
            // initial value
            bool isValid = false;

            // if the SourceDatabaseConnectionString and the TargetDatabaseConnectionString
            if ((this.HasSourceDatabaseConnectionString) && (this.HasTargetDatabaseConnectionString))
            {
                // Create a new instance of a 'SQLDatabaseConnector' object.
                this.SourceDatabaseConnector = new SQLDatabaseConnector();
                this.TargetDatabaseConnector = new SQLDatabaseConnector();

                // Set the Source & Target ConnectionString
                this.SourceDatabaseConnector.ConnectionString = this.SourceDatabaseConnectionString;
                this.TargetDatabaseConnector.ConnectionString = this.TargetDatabaseConnectionString;

                // test the sourceConnectionTested
                bool sourceConnectionTested = SQLDatabaseTester.TestDatabaseConnection(this.SourceDatabaseConnector);
                bool targetConnectionTested = SQLDatabaseTester.TestDatabaseConnection(this.TargetDatabaseConnector);

                // if both connections tested
                if ((sourceConnectionTested) && (targetConnectionTested))
                {
                    // this is a valid connection
                    isValid = true;
                }
                else if ((!sourceConnectionTested) && (targetConnectionTested))
                {
                    // Set the InvalidReason
                    this.InvalidReason = "The source and target connections failed to connect.";
                }
                else if (!sourceConnectionTested)
                {
                    // Set the InvalidReason
                    this.InvalidReason = "The source connection failed to connect.";
                }
                else
                {
                    // The Target Connection Failed
                    this.InvalidReason = "The target connection failed to connect.";
                }
            }
            else if ((!this.HasSourceDatabaseConnectionString) && (!this.HasTargetDatabaseConnectionString))
            {
                // Set the InvalidReason
                this.InvalidReason = "The 'Source Connection String' and the 'Target Connection String' must both be set";
            }
            else if (!this.HasSourceDatabaseConnectionString)
            {
                // Set the InvalidReason
                this.InvalidReason = "The 'Source Connection String' must be set";
            }
            else if (!this.HasTargetDatabaseConnectionString)
            {
                // Set the InvalidReason
                this.InvalidReason = "The 'Target Connection String' must be set";
            }

            // return value
            return(isValid);
        }
        /// <summary>
        /// This event is fired when the Test Database Connection button is clieccked.
        /// </summary>
        private void TestDatabaseConnectionButton_Click(object sender, EventArgs e)
        {
            try
            {
                // set the connectionTest
                bool connectionTest = false;

                // Set the connectionString
                string connectionString = this.ConnectionstringControl.Text;

                // test for a connectionString
                bool hasConnectionString = (!String.IsNullOrEmpty(connectionString));

                // if a connection string has been established
                if (hasConnectionString)
                {
                    // set the dataConnector
                    SQLDatabaseConnector dataConnector = new SQLDatabaseConnector();

                    // set the connection string
                    dataConnector.ConnectionString = connectionString;

                    // Test the connection
                    connectionTest = SQLDatabaseTester.TestDatabaseConnection(dataConnector);

                    // if the connection test passed
                    if (connectionTest)
                    {
                        // Change the text to passed
                        this.StatusLabel.Text = "Database Connection Test Passed.";

                        // Show Success
                        this.StatusImage.BackgroundImage = Properties.Resources.Success;

                        // Set the text to the clipboard
                        Clipboard.SetText(connectionString);

                        // Show the CopiedImage and start the CopiedTimer
                        ShowCopiedImage();
                    }
                    else
                    {
                        // Show a success message
                        this.StatusLabel.Text = "Database Connection Failed.";

                        // Show Failure
                        this.StatusImage.BackgroundImage = Properties.Resources.Failure;
                    }

                    // Show the StatusLabel and Image
                    this.StatusLabel.Visible = true;
                    this.StatusImage.Visible = true;
                }
                else
                {
                    // Show a warning message
                    MessageBox.Show("You must build or enter a connection string.", "Missing Information", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            }
            catch (Exception error)
            {
                // for debugging only
                string err = error.ToString();

                // Show a success message
                MessageBox.Show("A connection to the database count not be estalished.", "Connection Test Failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }