public void Update()
        {
            AGENT.DBDescriptionAgent_Factory oDescriptionFactory = new AGENT.DBDescriptionAgent_Factory(DBID: m_DBID);

            DescriptionUpdateBegin(DateTime.Now);

            TypeDescriptionUpdate(UTIL.Constants.FUNCTIONNODE.ToString(), DateTime.Now);
            using (SQLAutoDocLib.BLL.Function_Factory oFunction_Factory = new SQLAutoDocLib.BLL.Function_Factory())
                foreach (BLL.Function oFunction in oFunction_Factory.ListAllFunctionsInDatabase(DBID: m_DBID))
                {
                    oDescriptionFactory.UpdateFunctionDescription(
                        Name: oFunction.Name,
                        Description: oFunction.Description);
                }

            TypeDescriptionUpdate(UTIL.Constants.PROCEDURENODE.ToString(), DateTime.Now);
            using (SQLAutoDocLib.BLL.Procedure_Factory oProcedure_Factory = new SQLAutoDocLib.BLL.Procedure_Factory())
                foreach (BLL.Procedure oProcedure in oProcedure_Factory.ListAllProceduresInDatabase(DBID:m_DBID))
                {
                    oDescriptionFactory.UpdateProcedureDescription(
                        Name: oProcedure.Name,
                        Description: oProcedure.Description);
                }

            TypeDescriptionUpdate(UTIL.Constants.TABLENODE.ToString(), DateTime.Now);
            using (SQLAutoDocLib.BLL.Table_Factory oTable_Factory = new SQLAutoDocLib.BLL.Table_Factory())
                foreach (BLL.Table oTable in oTable_Factory.ListAllTablesInDatabase(DBID:m_DBID))
                {
                    oDescriptionFactory.UpdateTableDescription(
                        Name: oTable.Name,
                        Description: oTable.Description);
                }

            TypeDescriptionUpdate(UTIL.Constants.VIEWNODE.ToString(), DateTime.Now);
            using (SQLAutoDocLib.BLL.View_Factory oView_Factory = new SQLAutoDocLib.BLL.View_Factory())
                foreach (BLL.View oView in oView_Factory.ListAllViewsInDatabase(DBID:m_DBID))
                {
                    oDescriptionFactory.UpdateViewDescription(
                        Name: oView.Name,
                        Description: oView.Description);
                }

            /*
             * Can't update trigger descriptions at this time...
             * SQLAutoDocLib.BLL.Trigger_Factory oTrigger_Factory = new SQLAutoDocLib.BLL.Trigger_Factory();
             * oFunction_Factory.UpdateExtendedDescriptions(DBID: m_DBID);
             * Application.DoEvents();
             * */

            DescriptionUpdateEnd(DateTime.Now);
        }
Exemplo n.º 2
0
        public static void ShowFunctionDetail(
            System.Windows.Forms.Form oParent,
            Guid DBID,
            string VersionID,
            string FunctionName)
        {
            SQLAutoDocLib.BLL.Function_Factory oFactory  = new SQLAutoDocLib.BLL.Function_Factory();
            SQLAutoDocLib.BLL.Function         oFunction = oFactory.GetFunctionByName(DBID: DBID, FunctionName: FunctionName, VersionID: VersionID);

            StringReader  oReader = new StringReader(oFunction.Configuration);
            XPathDocument oMyDoc  = new XPathDocument(oReader);

            XslCompiledTransform oProcessor = new XslCompiledTransform();
            string sXSL = GetResourceTextFile(oParent, "SQLAutoDoc.xsl.function.xsl");

            oProcessor.Load(XmlReader.Create(new StringReader(sXSL)));

            StringBuilder oBuffer  = new StringBuilder();
            StringWriter  oSWriter = new StringWriter(oBuffer);

            oProcessor.Transform(
                XmlReader.Create(new StringReader(oFunction.Configuration)),
                null,
                oSWriter);

            SetFormFields(
                oParent: oParent,
                VersionID: VersionID,
                Name: FunctionName,
                Desc: oFunction.Description,
                FirstDate: oFunction.FindFirstVersion,
                LastDate: oFunction.FindLastVersion,
                HTML: oSWriter.ToString());

            oSWriter.Flush();
            oSWriter.Dispose();

            Application.DoEvents();
        }
Exemplo n.º 3
0
        private void InitTree(string VersionID)
        {
            string sCurrentVersion = CurrentVersion();

            ClearTree();

            if (VersionID.Length > 0)
            {
                try
                {
                    TreeNode oDatabase = GetNodeByKey(tvwObject.Nodes, SQLAutoDocLib.UTIL.Constants.DATABASENODE);

                    //Add tables
                    SQLAutoDocLib.BLL.Table_Factory oTableFactory = new SQLAutoDocLib.BLL.Table_Factory();
                    List <SQLAutoDocLib.BLL.Table>  oTableList    = oTableFactory.ListAllTablesInDatabase(
                        DBID: m_DBID,
                        VersionID: sCurrentVersion,
                        ChangedOnly: false);

                    TreeNode oTablesNode = GetNodeByKey(oDatabase.Nodes, SQLAutoDocLib.UTIL.Constants.TABLENODE);
                    foreach (SQLAutoDocLib.BLL.Table oTable in oTableList)
                    {
                        if (chkShowChangesOnly.Checked == false || oTable.ChangedInLastScan == true)
                        {
                            TreeNode oTableNode = oTablesNode.Nodes.Add(oTable.Name, oTable.Name, imageIndex: (int)ImageKeys.table);
                            oTableNode.SelectedImageIndex = (int)ImageKeys.table_go;

                            if (oTable.ChangedInLastScan == true)
                            {
                                if (oTable.CurrentlyExists == false)
                                {
                                    oTableNode.ImageIndex        = (int)ImageKeys.table_delete;
                                    oTableNode.Parent.ImageIndex = (int)ImageKeys.table_edit;
                                }
                                else
                                {
                                    oTableNode.ImageIndex        = (int)ImageKeys.table_edit;
                                    oTableNode.Parent.ImageIndex = (int)ImageKeys.table_edit;
                                }
                            }
                        }
                    }

                    //Add views
                    SQLAutoDocLib.BLL.View_Factory oViewFactory = new SQLAutoDocLib.BLL.View_Factory();
                    List <SQLAutoDocLib.BLL.View>  oViewList    = oViewFactory.ListAllViewsInDatabase(
                        DBID: m_DBID,
                        VersionID: sCurrentVersion,
                        ChangedOnly: false);

                    TreeNode oViewsNode = GetNodeByKey(oDatabase.Nodes, SQLAutoDocLib.UTIL.Constants.VIEWNODE);
                    foreach (SQLAutoDocLib.BLL.View oView in oViewList)
                    {
                        if (chkShowChangesOnly.Checked == false || oView.ChangedInLastScan == true)
                        {
                            TreeNode oViewNode = oViewsNode.Nodes.Add(oView.Name, oView.Name, imageIndex: (int)ImageKeys.table);
                            oViewNode.SelectedImageIndex = (int)ImageKeys.table_go;

                            if (oView.ChangedInLastScan == true)
                            {
                                if (oView.CurrentlyExists == false)
                                {
                                    oViewNode.ImageIndex        = (int)ImageKeys.table_delete;
                                    oViewNode.Parent.ImageIndex = (int)ImageKeys.table_edit;
                                }
                                else
                                {
                                    oViewNode.ImageIndex        = (int)ImageKeys.table_edit;
                                    oViewNode.Parent.ImageIndex = (int)ImageKeys.table_edit;
                                }
                            }
                        }
                    }

                    //Add procs
                    SQLAutoDocLib.BLL.Procedure_Factory oProcFactory = new SQLAutoDocLib.BLL.Procedure_Factory();
                    List <SQLAutoDocLib.BLL.Procedure>  oProcList    = oProcFactory.ListAllProceduresInDatabase(
                        DBID: m_DBID,
                        VersionID: sCurrentVersion,
                        ChangedOnly: false);

                    TreeNode oProcsNode = GetNodeByKey(oDatabase.Nodes, SQLAutoDocLib.UTIL.Constants.PROCEDURENODE);
                    foreach (SQLAutoDocLib.BLL.Procedure oProc in oProcList)
                    {
                        if (chkShowChangesOnly.Checked == false || oProc.ChangedInLastScan == true)
                        {
                            TreeNode oProcNode = oProcsNode.Nodes.Add(oProc.Name, oProc.Name, imageIndex: (int)ImageKeys.table);
                            oProcNode.SelectedImageIndex = (int)ImageKeys.table_go;

                            if (oProc.ChangedInLastScan == true)
                            {
                                if (oProc.CurrentlyExists == false)
                                {
                                    oProcNode.ImageIndex        = (int)ImageKeys.table_delete;
                                    oProcNode.Parent.ImageIndex = (int)ImageKeys.table_edit;
                                }
                                else
                                {
                                    oProcNode.ImageIndex        = (int)ImageKeys.table_edit;
                                    oProcNode.Parent.ImageIndex = (int)ImageKeys.table_edit;
                                }
                            }
                        }
                    }

                    //Add functions
                    SQLAutoDocLib.BLL.Function_Factory oFunctionFactory = new SQLAutoDocLib.BLL.Function_Factory();
                    List <SQLAutoDocLib.BLL.Function>  oFunctionList    = oFunctionFactory.ListAllFunctionsInDatabase(
                        DBID: m_DBID,
                        VersionID: sCurrentVersion,
                        ChangedOnly: false);

                    TreeNode oFunctionsNode = GetNodeByKey(oDatabase.Nodes, SQLAutoDocLib.UTIL.Constants.FUNCTIONNODE);
                    foreach (SQLAutoDocLib.BLL.Function oFunction in oFunctionList)
                    {
                        if (chkShowChangesOnly.Checked == false || oFunction.ChangedInLastScan == true)
                        {
                            TreeNode oFunctionNode = oFunctionsNode.Nodes.Add(oFunction.Name, oFunction.Name, imageIndex: (int)ImageKeys.table);
                            oFunctionsNode.SelectedImageIndex = (int)ImageKeys.table_go;

                            if (oFunction.ChangedInLastScan == true)
                            {
                                if (oFunction.CurrentlyExists == false)
                                {
                                    oFunctionsNode.ImageIndex        = (int)ImageKeys.table_delete;
                                    oFunctionsNode.Parent.ImageIndex = (int)ImageKeys.table_edit;
                                }
                                else
                                {
                                    oFunctionsNode.ImageIndex       = (int)ImageKeys.table_edit;
                                    oFunctionNode.Parent.ImageIndex = (int)ImageKeys.table_edit;
                                }
                            }
                        }
                    }

                    //Add triggers
                    SQLAutoDocLib.BLL.Trigger_Factory oTriggerFactory = new SQLAutoDocLib.BLL.Trigger_Factory();
                    List <SQLAutoDocLib.BLL.Trigger>  oTriggerList    = oTriggerFactory.ListAllTriggersInDatabase(
                        DBID: m_DBID,
                        VersionID: sCurrentVersion,
                        ChangedOnly: false);

                    TreeNode oTriggersNode = GetNodeByKey(oDatabase.Nodes, SQLAutoDocLib.UTIL.Constants.TRIGGERNODE);
                    foreach (SQLAutoDocLib.BLL.Trigger oTrigger in oTriggerList)
                    {
                        if (chkShowChangesOnly.Checked == false || oTrigger.ChangedInLastScan == true)
                        {
                            TreeNode oTriggerNode = oTriggersNode.Nodes.Add(oTrigger.Name, oTrigger.Name, imageIndex: (int)ImageKeys.table);
                            oTriggersNode.SelectedImageIndex = (int)ImageKeys.table_go;

                            if (oTrigger.ChangedInLastScan == true)
                            {
                                if (oTrigger.CurrentlyExists == false)
                                {
                                    oTriggersNode.ImageIndex        = (int)ImageKeys.table_delete;
                                    oTriggersNode.Parent.ImageIndex = (int)ImageKeys.table_edit;
                                }
                                else
                                {
                                    oTriggersNode.ImageIndex        = (int)ImageKeys.table_edit;
                                    oTriggersNode.Parent.ImageIndex = (int)ImageKeys.table_edit;
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
            }
        }
Exemplo n.º 4
0
        private void ShowDesc()
        {
            string VersionID = cmbVersion.SelectedValue.ToString();

            TreeNode CurrentNode = tvwObject.SelectedNode;

            if (CurrentNode.Parent != null)
            {
                if (CurrentNode.Parent.Name == SQLAutoDocLib.UTIL.Constants.TABLENODE)
                {
                    SQLAutoDocLib.BLL.Table_Factory oFactory = new SQLAutoDocLib.BLL.Table_Factory();
                    SQLAutoDocLib.BLL.Table         oTable   = oFactory.GetTableByName(DBID: m_DBID, TableName: CurrentNode.Name, VersionID: VersionID);

                    frmDesc oForm = new frmDesc(
                        ObjectName: CurrentNode.Name,
                        ObjectDesc: oTable.Description,
                        ObjectType: SQLAutoDocLib.UTIL.ObjectType.Table);

                    if (oForm.ShowDialog() == DialogResult.OK)
                    {
                        oTable.Load();
                        oTable.Description = oForm.Desc;
                        oTable.Save();

                        txtDesc.Text = oForm.Desc;
                    }
                }

                else if (CurrentNode.Parent.Name == SQLAutoDocLib.UTIL.Constants.VIEWNODE)
                {
                    SQLAutoDocLib.BLL.View_Factory oFactory = new SQLAutoDocLib.BLL.View_Factory();
                    SQLAutoDocLib.BLL.View         oView    = oFactory.GetViewByName(DBID: m_DBID, ViewName: CurrentNode.Name, VersionID: VersionID);

                    frmDesc oForm = new frmDesc(
                        ObjectName: CurrentNode.Name,
                        ObjectDesc: oView.Description,
                        ObjectType: SQLAutoDocLib.UTIL.ObjectType.View);

                    if (oForm.ShowDialog() == DialogResult.OK)
                    {
                        oView.Load();
                        oView.Description = oForm.Desc;
                        oView.Save();

                        txtDesc.Text = oForm.Desc;
                    }
                }

                else if (CurrentNode.Parent.Name == SQLAutoDocLib.UTIL.Constants.TRIGGERNODE)
                {
                    SQLAutoDocLib.BLL.Trigger_Factory oFactory = new SQLAutoDocLib.BLL.Trigger_Factory();
                    SQLAutoDocLib.BLL.Trigger         oTrigger = oFactory.GetTriggerByName(DBID: m_DBID, TriggerName: CurrentNode.Name, VersionID: VersionID);

                    frmDesc oForm = new frmDesc(
                        ObjectName: CurrentNode.Name,
                        ObjectDesc: oTrigger.Description,
                        ObjectType: SQLAutoDocLib.UTIL.ObjectType.Trigger);

                    if (oForm.ShowDialog() == DialogResult.OK)
                    {
                        oTrigger.Load();
                        oTrigger.Description = oForm.Desc;
                        oTrigger.Save();

                        txtDesc.Text = oForm.Desc;
                    }
                }

                else if (CurrentNode.Parent.Name == SQLAutoDocLib.UTIL.Constants.PROCEDURENODE)
                {
                    SQLAutoDocLib.BLL.Procedure_Factory oFactory   = new SQLAutoDocLib.BLL.Procedure_Factory();
                    SQLAutoDocLib.BLL.Procedure         oProcedure = oFactory.GetProcedureByName(DBID: m_DBID, ProcedureName: CurrentNode.Name, VersionID: VersionID);

                    frmDesc oForm = new frmDesc(
                        ObjectName: CurrentNode.Name,
                        ObjectDesc: oProcedure.Description,
                        ObjectType: SQLAutoDocLib.UTIL.ObjectType.Procedure);

                    if (oForm.ShowDialog() == DialogResult.OK)
                    {
                        oProcedure.Load();
                        oProcedure.Description = oForm.Desc;
                        oProcedure.Save();

                        txtDesc.Text = oForm.Desc;
                    }
                }

                else if (CurrentNode.Parent.Name == SQLAutoDocLib.UTIL.Constants.FUNCTIONNODE)
                {
                    SQLAutoDocLib.BLL.Function_Factory oFactory  = new SQLAutoDocLib.BLL.Function_Factory();
                    SQLAutoDocLib.BLL.Function         oFunction = oFactory.GetFunctionByName(DBID: m_DBID, FunctionName: CurrentNode.Name, VersionID: VersionID);

                    frmDesc oForm = new frmDesc(
                        ObjectName: CurrentNode.Name,
                        ObjectDesc: oFunction.Description,
                        ObjectType: SQLAutoDocLib.UTIL.ObjectType.Function);

                    if (oForm.ShowDialog() == DialogResult.OK)
                    {
                        oFunction.Load();
                        oFunction.Description = oForm.Desc;
                        oFunction.Save();

                        txtDesc.Text = oForm.Desc;
                    }
                }
            }
        }
Exemplo n.º 5
0
        public void ShowVersion()
        {
            this.Show();
            this.TopMost = true;

            this.UseWaitCursor = true;

            lblVersion.Text = m_Version;

            //Add tables
            SQLAutoDocLib.BLL.Table_Factory oTableFactory = new SQLAutoDocLib.BLL.Table_Factory();
            List <SQLAutoDocLib.BLL.Table>  oTableList    = oTableFactory.ListAllTablesInDatabase(m_DBID, m_Version, ChangedOnly: true);

            foreach (SQLAutoDocLib.BLL.Table oTable in oTableList)
            {
                ListViewItem oItem = new ListViewItem(text: oTable.Name);
                oItem.Tag   = oTable;
                oItem.Group = lvwDifferences.Groups[0];
                lvwDifferences.Items.Add(oItem);
            }

            //Add views
            SQLAutoDocLib.BLL.View_Factory oViewFactory = new SQLAutoDocLib.BLL.View_Factory();
            List <SQLAutoDocLib.BLL.View>  oViewList    = oViewFactory.ListAllViewsInDatabase(m_DBID, m_Version, ChangedOnly: true);

            foreach (SQLAutoDocLib.BLL.View oView in oViewList)
            {
                ListViewItem oItem = new ListViewItem(text: oView.Name);
                oItem.Tag   = oView;
                oItem.Group = lvwDifferences.Groups[1];
                lvwDifferences.Items.Add(oItem);
            }

            //Add procs
            SQLAutoDocLib.BLL.Procedure_Factory oProcFactory = new SQLAutoDocLib.BLL.Procedure_Factory();
            List <SQLAutoDocLib.BLL.Procedure>  oProcList    = oProcFactory.ListAllProceduresInDatabase(m_DBID, m_Version, ChangedOnly: true);

            foreach (SQLAutoDocLib.BLL.Procedure oProc in oProcList)
            {
                ListViewItem oItem = new ListViewItem(text: oProc.Name);
                oItem.Tag   = oProc;
                oItem.Group = lvwDifferences.Groups[2];
                lvwDifferences.Items.Add(oItem);
            }

            //Add functions
            SQLAutoDocLib.BLL.Function_Factory oFunctionFactory = new SQLAutoDocLib.BLL.Function_Factory();
            List <SQLAutoDocLib.BLL.Function>  oFunctionList    = oFunctionFactory.ListAllFunctionsInDatabase(m_DBID, m_Version, ChangedOnly: true);

            foreach (SQLAutoDocLib.BLL.Function oFunction in oFunctionList)
            {
                ListViewItem oItem = new ListViewItem(text: oFunction.Name);
                oItem.Tag   = oFunction;
                oItem.Group = lvwDifferences.Groups[3];
                lvwDifferences.Items.Add(oItem);
            }

            //Add triggers
            SQLAutoDocLib.BLL.Trigger_Factory oTriggerFactory = new SQLAutoDocLib.BLL.Trigger_Factory();
            List <SQLAutoDocLib.BLL.Trigger>  oTriggerList    = oTriggerFactory.ListAllTriggersInDatabase(m_DBID, m_Version, ChangedOnly: true);

            foreach (SQLAutoDocLib.BLL.Trigger oTrigger in oTriggerList)
            {
                ListViewItem oItem = new ListViewItem(text: oTrigger.Name);
                oItem.Tag   = oTrigger;
                oItem.Group = lvwDifferences.Groups[4];
                lvwDifferences.Items.Add(oItem);
            }

            this.UseWaitCursor = false;
        }
Exemplo n.º 6
0
        private void SaveScript(string sFileName)
        {
            using (StreamWriter oSW = new StreamWriter(path: sFileName, append: false))
            {
                oSW.WriteLine("/* VERSION: " + m_Version + " */");

                foreach (ListViewItem oItem in lvwDifferences.Items)
                {
                    if (oItem.Checked == true)
                    {
                        object oValue    = oItem.Tag;
                        string sTypeName = oValue.GetType().ToString();

                        if (oValue.GetType() == typeof(SQLAutoDocLib.BLL.Table))
                        {
                            //This is a table
                            SQLAutoDocLib.BLL.Table oTable = (SQLAutoDocLib.BLL.Table)oValue;
                            if (oTable.CurrentlyExists == true)
                            {
                                oSW.WriteLine("/* ALTER */");
                            }
                            else
                            {
                                oSW.WriteLine("/* CREATE */");
                            }

                            SQLAutoDocLib.BLL.Table_Factory oFactory = new SQLAutoDocLib.BLL.Table_Factory();
                            oSW.WriteLine(oFactory.Reconstitute(oTable));
                        }
                        else if (oValue.GetType() == typeof(SQLAutoDocLib.BLL.View))
                        {
                            //This is a view
                            SQLAutoDocLib.BLL.View         oView    = (SQLAutoDocLib.BLL.View)oValue;
                            SQLAutoDocLib.BLL.View_Factory oFactory = new SQLAutoDocLib.BLL.View_Factory();
                            oSW.WriteLine(oFactory.Reconstitute(oView));
                        }
                        else if (oValue.GetType() == typeof(SQLAutoDocLib.BLL.Function))
                        {
                            //This is a function
                            SQLAutoDocLib.BLL.Function         oFunction = (SQLAutoDocLib.BLL.Function)oValue;
                            SQLAutoDocLib.BLL.Function_Factory oFactory  = new SQLAutoDocLib.BLL.Function_Factory();
                            oSW.WriteLine(oFactory.Reconstitute(oFunction));
                        }
                        else if (oValue.GetType() == typeof(SQLAutoDocLib.BLL.Procedure))
                        {
                            //This is a procedure
                            SQLAutoDocLib.BLL.Procedure         oProcedure = (SQLAutoDocLib.BLL.Procedure)oValue;
                            SQLAutoDocLib.BLL.Procedure_Factory oFactory   = new SQLAutoDocLib.BLL.Procedure_Factory();
                            oSW.WriteLine(oFactory.Reconstitute(oProcedure));
                        }
                        else if (oValue.GetType() == typeof(SQLAutoDocLib.BLL.Trigger))
                        {
                            //This is a trigger
                            SQLAutoDocLib.BLL.Trigger         oTrigger = (SQLAutoDocLib.BLL.Trigger)oValue;
                            SQLAutoDocLib.BLL.Trigger_Factory oFactory = new SQLAutoDocLib.BLL.Trigger_Factory();
                            oSW.WriteLine(oFactory.Reconstitute(oTrigger));
                        }
                    }
                }
            }
        }