Ejemplo n.º 1
0
        static void Main(string[] args)
        {
            //TODO: add param support
            string connStr = "Server=.; Database=AdventureWorks; Integrated Security=true;";

            DatabaseInspector dbi = new DatabaseInspector(connStr);
            var metadata          = dbi.GetDatabaseMetaData();



            DatabaseHtmlDocumentGenerator gen = new DatabaseHtmlDocumentGenerator();

            using (var sw = new StreamWriter("database.html", false))
            {
                var str = gen.ExportToHtml(metadata, sw);
            }

            Console.ReadLine();
        }
        private void btnGenerateDoc_Click(object sender, EventArgs e)
        {
            if (!this.validateFormInput(true))
            {
                return;
            }

            this.lockUi();

            this.Cursor = Cursors.WaitCursor;
            Application.DoEvents();

            DocumentGeneratorConfiguration docGenConfig = this.createDocumentGeneratorConfigurationFroUi();

            //perform database operations aysnc
            var taskMeta = getDatabaseMetaDataAysnc(this.txtConnectionString.Text);

            var metadata = taskMeta.Result;

            DatabaseHtmlDocumentGenerator gen = new DatabaseHtmlDocumentGenerator();

            string docFilePath = this.txtDocFile.Text.Trim();

            using (var sw = new StreamWriter(docFilePath, false))
            {
                var str = gen.ExportToHtml(metadata, sw, docGenConfig);
            }



            this.Cursor = Cursors.Default;
            Application.DoEvents();

            if (this.chkOpenDoc.Checked && File.Exists(docFilePath))
            {
                Process.Start(docFilePath);
            }

            this.unLockUi();
        }