Beispiel #1
0
        public static SODatabase ToSODatabase(PDPackage package)
        {
            if (package == null)
            {
                return(null);
            }

            SODatabase db = new SODatabase();

            db.Name      = package.Code;
            db.Comment   = string.IsNullOrEmpty(package.Comment) ? package.Name : package.Comment;
            db.TableList = new List <SOTable>();
            foreach (PDTable item in package.TableList)
            {
                db.TableList.Add(ToSOTable(item));
            }
            db.ViewList = new List <SOView>();
            //foreach (PDView item in package.ViewList)
            //{
            //    db.ViewList.Add(ToSOView(item));
            //}
            db.CommandList = new List <SOCommand>();
            //foreach (PDProcedure item in package.ProcedureList)
            //{
            //    db.CommandList.Add(ToSOCommand(item));
            //}

            return(db);
        }
        public static SODatabase ToSODatabase(PDPackage package)
        {
            if (package == null) return null;

            SODatabase db = new SODatabase();

            db.Name = package.Code;
            db.Comment = string.IsNullOrEmpty(package.Comment) ? package.Name : package.Comment;
            db.TableList = new List<SOTable>();
            foreach (PDTable item in package.TableList)
            {
                db.TableList.Add(ToSOTable(item));
            }
            db.ViewList = new List<SOView>();
            //foreach (PDView item in package.ViewList)
            //{
            //    db.ViewList.Add(ToSOView(item));
            //}
            db.CommandList = new List<SOCommand>();
            //foreach (PDProcedure item in package.ProcedureList)
            //{
            //    db.CommandList.Add(ToSOCommand(item));   
            //}

            return db;
        }
Beispiel #3
0
        void ParseColumns(PDModel m, PDPackage package, PDTable table, XmlNode root)
        {
            foreach (XmlNode columnNode in root.ChildNodes)
            {
                PDColumn column = new PDColumn();
                column.Model   = m;
                column.Package = package;
                column.Table   = table;
                column.ID      = columnNode.Attributes["Id"].Value;

                foreach (XmlNode node in columnNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                    case "a:Name":
                        column.Name = node.InnerText;
                        break;

                    case "a:Code":
                        column.Code = node.InnerText;
                        break;

                    case "a:Comment":
                        column.Comment = node.InnerText;
                        break;

                    case "a:DataType":
                        column.DataType = node.InnerText;
                        break;

                    case "a:Length":
                        column.Length = ConvertUtil.ToInt32(node.InnerText, 0);
                        break;

                    case "a:Precision":
                        column.Precision = ConvertUtil.ToInt32(node.InnerText, 0);
                        break;

                    case "a:Mandatory":
                        column.Mandatory = node.InnerText == "1" ? true : false;
                        break;

                    case "a:DefaultValue":
                        column.DefaultValue = node.InnerText;
                        break;

                    case "a:Identity":
                        column.Identity = node.InnerText == "1";
                        break;

                    default:
                        column.AddUnparsedNode(node);
                        break;
                    }
                }//end parse column

                table.AddColumn(column);
            }//end parse columns
        }
Beispiel #4
0
 void ParseChildPackageList(IList<PDPackage> list , PDPackage package)
 {
     if (list == null) return;
     foreach (PDPackage item in package.ChildrenList)
     {
         list.Add(item);
         ParseChildPackageList(list, item);
     }
 }
Beispiel #5
0
 void ParseChildPackageList(IList <PDPackage> list, PDPackage package)
 {
     if (list == null)
     {
         return;
     }
     foreach (PDPackage item in package.ChildrenList)
     {
         list.Add(item);
         ParseChildPackageList(list, item);
     }
 }
        public void LoadPackage(PDPackage p)
        {
            this.Text = p.Name;

            dgvTable.AutoGenerateColumns = false;
            dgvView.AutoGenerateColumns = false;
            dgvSP.AutoGenerateColumns = false;

            dgvTable.DataSource = p.TableList;
            dgvView.DataSource = p.ViewList;
            dgvSP.DataSource = p.ProcedureList;

            tpTable.Text = string.Format("表[{0}]", dgvTable.Rows.Count);
            tpView.Text = string.Format("视图[{0}]", dgvView.Rows.Count);
            tpSP.Text = string.Format("存储过程[{0}]", dgvSP.Rows.Count);
        }
Beispiel #7
0
        void ParseIndexes(PDModel m, PDPackage package, PDTable table, XmlNode root)
        {
            foreach (XmlNode indexNode in root.ChildNodes)
            {
                PDIndex index = new PDIndex();
                index.Model   = m;
                index.Package = package;
                index.Table   = table;
                index.ID      = indexNode.Attributes["Id"].Value;

                foreach (XmlNode node in indexNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                    case "a:Name":
                        index.Name = node.InnerText;
                        break;

                    case "a:Code":
                        index.Code = node.InnerText;
                        break;

                    case "a:Comment":
                        index.Comment = node.InnerText;
                        break;

                    case "a:Unique":
                        index.Unique = node.InnerText == "1" ? true : false;
                        break;

                    case "c:IndexColumns":
                        index.ColumnIDList = ParseIndexColumnIDs(node.ChildNodes);
                        break;

                    default:
                        break;
                    }
                }//end parse index

                table.AddIndex(index);
            }//end parse indexes
        }
Beispiel #8
0
        void ParseProcedures(PDModel m, PDPackage package, XmlNode root)
        {
            foreach (XmlNode procedureNode in root.ChildNodes)
            {
                PDProcedure procedure = new PDProcedure();
                procedure.Model   = m;
                procedure.Package = package;
                procedure.ID      = procedureNode.Attributes["Id"].Value;

                foreach (XmlNode node in procedureNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                    case "a:Name":
                        procedure.Name = node.InnerText;
                        break;

                    case "a:Code":
                        procedure.Code = node.InnerText;
                        break;

                    case "a:Comment":
                        procedure.Comment = node.InnerText;
                        break;

                    default:
                        break;
                    }
                }//end parse procedure

                if (package == null)
                {
                    m.AddProcedure(procedure);
                }
                else
                {
                    package.AddProcedure(procedure);
                }
            }//end parse procedures
        }
Beispiel #9
0
        void ParseViews(PDModel m, PDPackage package, XmlNode root)
        {
            foreach (XmlNode viewNode in root.ChildNodes)
            {
                PDView view = new PDView();
                view.Model   = m;
                view.Package = package;
                view.ID      = viewNode.Attributes["Id"].Value;

                foreach (XmlNode node in viewNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                    case "a:Name":
                        view.Name = node.InnerText;
                        break;

                    case "a:Code":
                        view.Code = node.InnerText;
                        break;

                    case "a:Comment":
                        view.Comment = node.InnerText;
                        break;

                    default:
                        break;
                    }
                }//end parse view

                if (package == null)
                {
                    m.AddView(view);
                }
                else
                {
                    package.AddView(view);
                }
            }//end parse views
        }
Beispiel #10
0
        void ParseKeys(PDModel m, PDPackage package, PDTable table, XmlNode root)
        {
            foreach (XmlNode keyNode in root.ChildNodes)
            {
                PDKey key = new PDKey();
                key.Model   = m;
                key.Package = package;
                key.Table   = table;
                key.ID      = keyNode.Attributes["Id"].Value;

                foreach (XmlNode node in keyNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                    case "a:Name":
                        key.Name = node.InnerText;
                        break;

                    case "a:Code":
                        key.Code = node.InnerText;
                        break;

                    case "a:Comment":
                        key.Comment = node.InnerText;
                        break;

                    case "c:Key.Columns":
                        key.ColumnIDList = ParseKeyColumnIDs(node.ChildNodes);
                        break;

                    default:
                        break;
                    }
                }//end parse key

                table.AddKey(key);
            }//end parse keys
        }
Beispiel #11
0
        void ParseIndexes(PDModel m, PDPackage package, PDTable table, XmlNode root)
        {
            foreach (XmlNode indexNode in root.ChildNodes)
            {
                PDIndex index = new PDIndex();
                index.Model = m;
                index.Package = package;
                index.Table = table;
                index.ID = indexNode.Attributes["Id"].Value;

                foreach (XmlNode node in indexNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                        case "a:Name":
                            index.Name = node.InnerText;
                            break;
                        case "a:Code":
                            index.Code = node.InnerText;
                            break;
                        case "a:Comment":
                            index.Comment = node.InnerText;
                            break;
                        case "a:Unique":
                            index.Unique = node.InnerText == "1" ? true : false;
                            break;
                        case "c:IndexColumns":
                            index.ColumnIDList = ParseIndexColumnIDs(node.ChildNodes);
                            break;
                        default:
                            break;
                    }
                }//end parse index

                table.AddIndex(index);
            }//end parse indexes
        }
Beispiel #12
0
        void ParseKeys(PDModel m, PDPackage package, PDTable table, XmlNode root)
        {
            foreach (XmlNode keyNode in root.ChildNodes)
            {
                PDKey key = new PDKey();
                key.Model = m;
                key.Package = package;
                key.Table = table;
                key.ID = keyNode.Attributes["Id"].Value;

                foreach (XmlNode node in keyNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                        case "a:Name":
                            key.Name = node.InnerText;
                            break;
                        case "a:Code":
                            key.Code = node.InnerText;
                            break;
                        case "a:Comment":
                            key.Comment = node.InnerText;
                            break;
                        case "c:Key.Columns":
                            key.ColumnIDList = ParseKeyColumnIDs(node.ChildNodes);
                            break;
                        default:
                            break;
                    }
                }//end parse key

                table.AddKey(key);
            }//end parse keys
        }
Beispiel #13
0
        void ParseColumns(PDModel m, PDPackage package,PDTable table,XmlNode root)
        {
            foreach (XmlNode columnNode in root.ChildNodes)
            {
                PDColumn column = new PDColumn();
                column.Model = m;
                column.Package = package;
                column.Table = table;
                column.ID = columnNode.Attributes["Id"].Value;

                foreach (XmlNode node in columnNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                        case "a:Name":
                            column.Name = node.InnerText;
                            break;
                        case "a:Code":
                            column.Code = node.InnerText;
                            break;
                        case "a:Comment":
                            column.Comment = node.InnerText;
                            break;
                        case "a:DataType":
                            column.DataType = node.InnerText;
                            break;
                        case "a:Length":
                            column.Length = ConvertUtil.ToInt32(node.InnerText, 0);
                            break;
                        case "a:Precision":
                            column.Precision = ConvertUtil.ToInt32(node.InnerText, 0);
                            break;
                        case "a:Mandatory":
                            column.Mandatory = node.InnerText == "1" ? true : false;
                            break;
                        case "a:DefaultValue":
                            column.DefaultValue = node.InnerText;
                            break;
                        case "a:Identity":
                            column.Identity = node.InnerText == "1";
                            break;
                        default:
                            column.AddUnparsedNode(node);
                            break;
                    }
                }//end parse column

                table.AddColumn(column);
            }//end parse columns
        }
Beispiel #14
0
        void ParseTables(PDModel m, PDPackage package, XmlNode root)
        {
            foreach (XmlNode tableNode in root.ChildNodes)
            {
                PDTable table = new PDTable();
                table.Model = m;
                table.Package = package;
                table.ID = tableNode.Attributes["Id"].Value;

                foreach (XmlNode node in tableNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                        case "a:Name":
                            table.Name = node.InnerText;
                            break;
                        case "a:Code":
                            table.Code = node.InnerText;
                            break;
                        case "a:Comment":
                            table.Comment = node.InnerText;
                            break;
                        case "c:Owner":
                            table.UserID = node["o:User"].Attributes["Ref"].Value;
                            break;
                        case "c:PrimaryKey":
                            table.PrimaryKeyID = node["o:Key"].Attributes["Ref"].Value;
                            break;
                        case "c:ClusterObject":
                            table.ClusterObjectID = node.FirstChild.Attributes["Ref"].Value;
                            break;
                        case "c:Columns":
                            ParseColumns(m, package, table, node);
                            break;
                        case "c:Keys":
                            ParseKeys(m, package, table, node);
                            break;
                        case "c:Indexes":
                            ParseIndexes(m, package, table, node);
                            break;
                        default:
                            table.AddUnparsedNode(node);
                            break;
                    }
                }//end parse table

                if (package == null)
                {
                    m.AddTable(table);
                }
                else
                {
                    package.AddTable(table);
                }
            }//end parse tables
        }
Beispiel #15
0
        void ParsePackages(PDModel m,PDPackage parent, XmlNode root)
        {
            foreach (XmlNode packageNode in root.ChildNodes)
            {
                PDPackage package = new PDPackage();
                package.Model = m;
                package.Parent = parent;
                package.ID = packageNode.Attributes["Id"].Value;

                foreach (XmlNode node in packageNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                        case "a:Name":
                            package.Name = node.InnerText;
                            break;
                        case "a:Code":
                            package.Code = node.InnerText;
                            break;
                        case "a:Comment":
                            package.Comment = node.InnerText;
                            break;
                        case "c:Packages":
                            ParsePackages(m, package, node);
                            break;
                        case "c:Tables":
                            ParseTables(m, package, node);
                            break;
                        case "c:Views":
                            ParseViews(m, package, node);
                            break;
                        case "c:Procedures":
                            ParseProcedures(m, package, node);
                            break;
                        case "c:References":
                            ParseReferences(m, package, node);
                            break;
                        default:
                            package.AddUnparsedNode(node);
                            break;
                    }
                }//end parse package

                if (parent == null)
                {
                    m.AddPackage(package);
                }
                else
                {
                    parent.AddPackage(package);
                }
            }//end parse packages
        }
Beispiel #16
0
        void ParseTables(PDModel m, PDPackage package, XmlNode root)
        {
            foreach (XmlNode tableNode in root.ChildNodes)
            {
                PDTable table = new PDTable();
                table.Model   = m;
                table.Package = package;
                table.ID      = tableNode.Attributes["Id"].Value;

                foreach (XmlNode node in tableNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                    case "a:Name":
                        table.Name = node.InnerText;
                        break;

                    case "a:Code":
                        table.Code = node.InnerText;
                        break;

                    case "a:Comment":
                        table.Comment = node.InnerText;
                        break;

                    case "c:Owner":
                        table.UserID = node["o:User"].Attributes["Ref"].Value;
                        break;

                    case "c:PrimaryKey":
                        table.PrimaryKeyID = node["o:Key"].Attributes["Ref"].Value;
                        break;

                    case "c:ClusterObject":
                        table.ClusterObjectID = node.FirstChild.Attributes["Ref"].Value;
                        break;

                    case "c:Columns":
                        ParseColumns(m, package, table, node);
                        break;

                    case "c:Keys":
                        ParseKeys(m, package, table, node);
                        break;

                    case "c:Indexes":
                        ParseIndexes(m, package, table, node);
                        break;

                    default:
                        table.AddUnparsedNode(node);
                        break;
                    }
                }//end parse table

                if (package == null)
                {
                    m.AddTable(table);
                }
                else
                {
                    package.AddTable(table);
                }
            }//end parse tables
        }
Beispiel #17
0
        void ParsePackages(PDModel m, PDPackage parent, XmlNode root)
        {
            foreach (XmlNode packageNode in root.ChildNodes)
            {
                PDPackage package = new PDPackage();
                package.Model  = m;
                package.Parent = parent;
                package.ID     = packageNode.Attributes["Id"].Value;

                foreach (XmlNode node in packageNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                    case "a:Name":
                        package.Name = node.InnerText;
                        break;

                    case "a:Code":
                        package.Code = node.InnerText;
                        break;

                    case "a:Comment":
                        package.Comment = node.InnerText;
                        break;

                    case "c:Packages":
                        ParsePackages(m, package, node);
                        break;

                    case "c:Tables":
                        ParseTables(m, package, node);
                        break;

                    case "c:Views":
                        ParseViews(m, package, node);
                        break;

                    case "c:Procedures":
                        ParseProcedures(m, package, node);
                        break;

                    case "c:References":
                        ParseReferences(m, package, node);
                        break;

                    default:
                        package.AddUnparsedNode(node);
                        break;
                    }
                }//end parse package

                if (parent == null)
                {
                    m.AddPackage(package);
                }
                else
                {
                    parent.AddPackage(package);
                }
            }//end parse packages
        }
Beispiel #18
0
        void ParseReferences(PDModel m, PDPackage package, XmlNode root)
        {
            foreach (XmlNode referenceNode in root.ChildNodes)
            {
                PDReference reference = new PDReference();
                reference.Model = m;
                reference.Package = package;
                reference.ID = referenceNode.Attributes["Id"].Value;

                foreach (XmlNode node in referenceNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                        case "a:Name":
                            reference.Name = node.InnerText;
                            break;
                        case "a:Code":
                            reference.Code = node.InnerText;
                            break;
                        case "a:Comment":
                            reference.Comment = node.InnerText;
                            break;
                        case "a:Cardinality":
                            reference.Cardinality = node.InnerText;
                            break;
                        case "a:UpdateConstraint":
                            reference.UpdateConstraint = node.InnerText == "1" ? true : false;
                            break;
                        case "a:DeleteConstraint":
                            reference.DeleteConstraint = node.InnerText == "1" ? true : false;
                            break;
                        case "c:ParentTable":
                            reference.ParentTableID = node.FirstChild.Attributes["Ref"].Value;
                            break;
                        case "c:ChildTable":
                            reference.ChildTableID = node.FirstChild.Attributes["Ref"].Value;
                            break;
                        case "c:ParentKey":
                            reference.ParentKeyID = node.FirstChild.Attributes["Ref"].Value;
                            break;
                        case "c:Joins":
                            reference.JoinList = ParseJoins(node.ChildNodes);
                            break;
                        default:
                            break;
                    }
                }//end parse reference

                if (package == null)
                {
                    m.AddReference(reference);
                }
                else
                {
                    package.AddReference(reference);
                }
            }//end parse references
        }
Beispiel #19
0
        void ParseViews(PDModel m, PDPackage package, XmlNode root)
        {
            foreach (XmlNode viewNode in root.ChildNodes)
            {
                PDView view = new PDView();
                view.Model = m;
                view.Package = package;
                view.ID = viewNode.Attributes["Id"].Value;

                foreach (XmlNode node in viewNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                        case "a:Name":
                            view.Name = node.InnerText;
                            break;
                        case "a:Code":
                            view.Code = node.InnerText;
                            break;
                        case "a:Comment":
                            view.Comment = node.InnerText;
                            break;
                        default:
                            break;
                    }
                }//end parse view

                if (package == null)
                {
                    m.AddView(view);
                }
                else
                {
                    package.AddView(view);
                }
            }//end parse views
        }
Beispiel #20
0
        void ParseReferences(PDModel m, PDPackage package, XmlNode root)
        {
            foreach (XmlNode referenceNode in root.ChildNodes)
            {
                PDReference reference = new PDReference();
                reference.Model   = m;
                reference.Package = package;
                reference.ID      = referenceNode.Attributes["Id"].Value;

                foreach (XmlNode node in referenceNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                    case "a:Name":
                        reference.Name = node.InnerText;
                        break;

                    case "a:Code":
                        reference.Code = node.InnerText;
                        break;

                    case "a:Comment":
                        reference.Comment = node.InnerText;
                        break;

                    case "a:Cardinality":
                        reference.Cardinality = node.InnerText;
                        break;

                    case "a:UpdateConstraint":
                        reference.UpdateConstraint = node.InnerText == "1" ? true : false;
                        break;

                    case "a:DeleteConstraint":
                        reference.DeleteConstraint = node.InnerText == "1" ? true : false;
                        break;

                    case "c:ParentTable":
                        reference.ParentTableID = node.FirstChild.Attributes["Ref"].Value;
                        break;

                    case "c:ChildTable":
                        reference.ChildTableID = node.FirstChild.Attributes["Ref"].Value;
                        break;

                    case "c:ParentKey":
                        reference.ParentKeyID = node.FirstChild.Attributes["Ref"].Value;
                        break;

                    case "c:Joins":
                        reference.JoinList = ParseJoins(node.ChildNodes);
                        break;

                    default:
                        break;
                    }
                }//end parse reference

                if (package == null)
                {
                    m.AddReference(reference);
                }
                else
                {
                    package.AddReference(reference);
                }
            }//end parse references
        }
Beispiel #21
0
        void ParseProcedures(PDModel m, PDPackage package, XmlNode root)
        {
            foreach (XmlNode procedureNode in root.ChildNodes)
            {
                PDProcedure procedure = new PDProcedure();
                procedure.Model = m;
                procedure.Package = package;
                procedure.ID = procedureNode.Attributes["Id"].Value;

                foreach (XmlNode node in procedureNode.ChildNodes)
                {
                    switch (node.Name)
                    {
                        case "a:Name":
                            procedure.Name = node.InnerText;
                            break;
                        case "a:Code":
                            procedure.Code = node.InnerText;
                            break;
                        case "a:Comment":
                            procedure.Comment = node.InnerText;
                            break;
                        default:
                            break;
                    }
                }//end parse procedure

                if (package == null)
                {
                    m.AddProcedure(procedure);
                }
                else
                {
                    package.AddProcedure(procedure);
                }
            }//end parse procedures
        }
Beispiel #22
0
 public void AddPackage(PDPackage package) { _PackageList.Add(package); }
Beispiel #23
0
 public void AddPackage(PDPackage package) { _ChildrenList.Add(package); }
Beispiel #24
0
 public void AddPackage(PDPackage package)
 {
     _PackageList.Add(package);
 }