Exemple #1
0
    private CustomNode GenerateServerNode()
    {
        int count      = 0;
        int totalCount = GetTotalCount();

        CustomNode serverNode = new CustomNode(NodeType.Server, null, ConfigHandler.ServerName, NodeImage.ServerDatabase, 0);

        NodeDataGenerator.GenerateDatabaseNode(serverNode, _databaseOperation.GetDatabaseName(), 0);

        if (_objectsSelectorForm.IncludeObjectType(NodeType.Tables) || ((_fileFormat == "sql" || _fileFormat == "xls") && (_objectsSelectorForm.tableColumnsCheckBox.Checked || _objectsSelectorForm.tableKeysCheckBox.Checked || _objectsSelectorForm.tableConstraintsCheckBox.Checked || _objectsSelectorForm.tableTriggersCheckBox.Checked || _objectsSelectorForm.tableIndexesCheckBox.Checked)))
        {
            CustomNode tablesNode = (CustomNode)serverNode.Nodes[0].Nodes["Tables"];
            NodeDataGenerator.GenerateTablesNode(tablesNode, _databaseOperation);

            if (_objectsSelectorForm.IncludeObjectType(NodeType.TableColumns))
            {
                ExportTableColumns(tablesNode, ++count, totalCount);
            }

            if (_objectsSelectorForm.IncludeObjectType(NodeType.TableKeys))
            {
                ExportTableKeys(tablesNode, ++count, totalCount);
            }

            if (_objectsSelectorForm.IncludeObjectType(NodeType.TableConstraints))
            {
                ExportTableConstraints(tablesNode, ++count, totalCount);
            }

            if (_objectsSelectorForm.IncludeObjectType(NodeType.TableTriggers))
            {
                ExportTableTriggers(tablesNode, ++count, totalCount);
            }

            if (_objectsSelectorForm.IncludeObjectType(NodeType.TableIndexes))
            {
                ExportTableIndexes(tablesNode, ++count, totalCount);
            }
        }

        if (_objectsSelectorForm.IncludeObjectType(NodeType.Views) || ((_fileFormat == "sql" || _fileFormat == "xls") && (_objectsSelectorForm.viewColumnsCheckBox.Checked || _objectsSelectorForm.viewTriggersCheckBox.Checked || _objectsSelectorForm.viewIndexesCheckBox.Checked)))
        {
            CustomNode viewsNode = (CustomNode)serverNode.Nodes[0].Nodes["Views"];
            NodeDataGenerator.GenerateViewsNode(viewsNode, _databaseOperation);

            if (_objectsSelectorForm.IncludeObjectType(NodeType.ViewColumns))
            {
                ExportViewColumns(viewsNode, ++count, totalCount);
            }

            if (_objectsSelectorForm.IncludeObjectType(NodeType.ViewTriggers))
            {
                ExportViewTriggers(viewsNode, ++count, totalCount);
            }

            if (_objectsSelectorForm.IncludeObjectType(NodeType.ViewIndexes))
            {
                ExportViewIndexes(viewsNode, ++count, totalCount);
            }
        }

        if (_objectsSelectorForm.IncludeObjectType(NodeType.StoredProcedures) || ((_fileFormat == "sql" || _fileFormat == "xls") && (_objectsSelectorForm.storedProcedureParametersCheckBox.Checked)))
        {
            CustomNode proceduresNode = (CustomNode)serverNode.Nodes[0].Nodes["Programmability"].Nodes["Stored Procedures"];
            NodeDataGenerator.GenerateProceduresNode(proceduresNode, _databaseOperation);

            if (_objectsSelectorForm.IncludeObjectType(NodeType.StoredProcedureParameters))
            {
                ExportStoredProcedureParameters(proceduresNode, ++count, totalCount);
            }
        }

        if (_objectsSelectorForm.IncludeObjectType(NodeType.TableValuedFunctions) || ((_fileFormat == "sql" || _fileFormat == "xls") && (_objectsSelectorForm.tableValuedFunctionParametersCheckBox.Checked)))
        {
            CustomNode tableValuedFunctionsNode = (CustomNode)serverNode.Nodes[0].Nodes["Programmability"].Nodes["Functions"].Nodes["Table-valued Functions"];
            NodeDataGenerator.GenerateTableValuedFunctionsNode(tableValuedFunctionsNode, _databaseOperation);

            if (_objectsSelectorForm.IncludeObjectType(NodeType.TableValuedFunctionParameters))
            {
                ExportTableValuedFunctionParameters(tableValuedFunctionsNode, ++count, totalCount);
            }
        }

        if (_objectsSelectorForm.IncludeObjectType(NodeType.ScalarValuedFunctions) || ((_fileFormat == "sql" || _fileFormat == "xls") && (_objectsSelectorForm.scalarValuedFunctionParametersCheckBox.Checked)))
        {
            CustomNode scalarValuedFunctionsNode = (CustomNode)serverNode.Nodes[0].Nodes["Programmability"].Nodes["Functions"].Nodes["Scalar-valued Functions"];
            NodeDataGenerator.GenerateScalarValuedFunctionsNode(scalarValuedFunctionsNode, _databaseOperation);

            if (_objectsSelectorForm.IncludeObjectType(NodeType.ScalarValuedFunctionParameters))
            {
                ExportScalarValuedFunctionParameters(scalarValuedFunctionsNode, ++count, totalCount);
            }
        }

        return(serverNode);
    }
    private void GenerateChildNodes(CustomNode node)
    {
        switch (node.Type)
        {
        case NodeType.Server:
            NodeDataGenerator.GenerateDatabasesNode(node, _databaseOperation);
            break;

        case NodeType.Tables:
            NodeDataGenerator.GenerateTablesNode(node, _databaseOperation);
            break;

        case NodeType.Views:
            NodeDataGenerator.GenerateViewsNode(node, _databaseOperation);
            break;

        case NodeType.StoredProcedures:
            NodeDataGenerator.GenerateProceduresNode(node, _databaseOperation);
            break;

        case NodeType.TableValuedFunctions:
            NodeDataGenerator.GenerateTableValuedFunctionsNode(node, _databaseOperation);
            break;

        case NodeType.ScalarValuedFunctions:
            NodeDataGenerator.GenerateScalarValuedFunctionsNode(node, _databaseOperation);
            break;

        case NodeType.TableColumns:
            NodeDataGenerator.GenerateTableColumnsNode(node, node.ParentNode.Text, _databaseOperation);
            break;

        case NodeType.ViewColumns:
            NodeDataGenerator.GenerateViewColumnsNode(node, node.ParentNode.Text, _databaseOperation);
            break;

        case NodeType.TableKeys:
            NodeDataGenerator.GenerateTableKeysNode(node, node.ParentNode.Text, _databaseOperation);
            break;

        case NodeType.TableConstraints:
            NodeDataGenerator.GenerateTableConstraintsNode(node, node.ParentNode.Text, _databaseOperation);
            break;

        case NodeType.TableTriggers:
            NodeDataGenerator.GenerateTableTriggersNode(node, node.ParentNode.Text, _databaseOperation);
            break;

        case NodeType.TableIndexes:
            NodeDataGenerator.GenerateTableIndexesNode(node, node.ParentNode.Text, _databaseOperation);
            break;

        case NodeType.ViewTriggers:
            NodeDataGenerator.GenerateViewTriggersNode(node, node.ParentNode.Text, _databaseOperation);
            break;

        case NodeType.ViewIndexes:
            NodeDataGenerator.GenerateViewIndexesNode(node, node.ParentNode.Text, _databaseOperation);
            break;

        case NodeType.TableValuedFunctionParameters:
            NodeDataGenerator.GenerateTableValuedFunctionParametersNode(node, node.ParentNode.Text, _databaseOperation);
            break;

        case NodeType.ScalarValuedFunctionParameters:
            NodeDataGenerator.GenerateScalarValuedFunctionParametersNode(node, node.ParentNode.Text, _databaseOperation);
            break;

        case NodeType.StoredProcedureParameters:
            NodeDataGenerator.GenerateStoredProcedureParametersNode(node, node.ParentNode.Text, _databaseOperation);
            break;
        }
    }