/// <summary>
        /// Form input validation
        /// </summary>
        /// <param name="requireDocumentationFile">Is documentation file required, applies when generating document</param>
        /// <returns></returns>
        private bool validateFormInput(bool requireDocumentationFile = true)
        {
            bool errorFound = false;

            this.clearErrorMessages();

            //was a connection string provided?
            if (String.IsNullOrWhiteSpace(this.txtConnectionString.Text))
            {
                errorFound = true;
                this.errorProviderMainForm.SetError(this.txtConnectionString, "Please provide a connection string");
            }
            else
            {
                var connectionTestResult = SqlConnectionTester.TestConnectionString(this.txtConnectionString.Text, true);
                if (!connectionTestResult.Success)
                {
                    errorFound = true;
                    this.errorProviderMainForm.SetError(this.txtConnectionString, (connectionTestResult.ErrorMessage ?? "Invalid connection string"));
                }
            }

            //has an ouptut filename with optional path been provided?
            if (requireDocumentationFile && String.IsNullOrWhiteSpace(this.txtDocFile.Text))
            {
                errorFound = true;
                this.errorProviderMainForm.SetError(this.txtDocFile, "Please enter a filename for the documentation file to be created");
            }
            else
            {
                string proposedFilename = this.txtDocFile.Text.Trim();

                FileInfo fileInfo = null;

                try
                {
                    fileInfo = new FileInfo(proposedFilename);
                }
                catch
                {
                    errorFound = true;
                    this.errorProviderMainForm.SetError(this.txtDocFile, "Proposed filename is invalid");
                }


                //is an HTML file extension
                if (fileInfo != null && !(fileInfo.Extension.ToLower() == ".htm" || fileInfo.Extension.ToLower() == ".html"))
                {
                    errorFound = true;
                    this.errorProviderMainForm.SetError(this.txtDocFile, "File name must have .htm or .html file extension");
                }
            }


            return(!errorFound); //input valid when no errors found
        }
        private void testConnectionString()
        {
            string connStr = this.GetConnectionString();


            var testResult = SqlConnectionTester.TestConnectionString(connStr);

            if (testResult.Success)
            {
                MessageBox.Show("Connection test successful", "Connection Test Result", MessageBoxButtons.OK, MessageBoxIcon.None);
            }
            else
            {
                MessageBox.Show(String.Format("Connection test failed.\n{0}", testResult.ErrorMessage), "Connection Test Result", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #3
0
        public Database GetDatabaseMetaData()
        {
            Database database = null;

            if (SqlConnectionTester.TestConnectionString(this.sqlConnectionString, false).Success)
            {
                this.peta = new PetaPoco.Database(this.sqlConnectionString, "System.Data.SqlClient");


                database = this.queryForDatabase();

                var schemaInspector = new SchemaInspector(this.peta);

                database.Schemas = schemaInspector.GetSchemas(database);

                //TODO: add input parameter to control inspection for design issues
                DesignIssue.DatabaseDesignIssueInspector designIssueInspector = new DesignIssue.DatabaseDesignIssueInspector();
                database.DesignIssueWarnings = designIssueInspector.GetDesignIssueWarnings(database);
            }

            return(database);
        }