示例#1
0
        private IList <PdmTableInfoModel> GetTables(List <string> tableNames)
        {
            List <PdmTableInfoModel> list = new List <PdmTableInfoModel>();

            foreach (var item in tableNames)
            {
                string tableName, tableDescription;
                List <DbTableColumnSchema> dbColumnList = DbSchemaBLL.GetDbTableColumnSchema(item, sqlconnection, out tableName, out tableDescription);
                if (dbColumnList == null)
                {
                    throw new Exception("table {0} 不存在,请确认表名及数据库名是否正确!".Formats(item));
                }
                PdmTableInfoModel tbmodel = new PdmTableInfoModel()
                {
                    Code = tableName, Comment = tableDescription, Name = tableDescription
                };
                dbColumnList.ForEach(p =>
                {
                    PdmColumnInfoModel pcim = new PdmColumnInfoModel(tbmodel);
                    pcim.Code     = p.columnName;
                    pcim.Comment  = p.Description;
                    pcim.DataType = GetDataType(p);
                    pcim.ColumnId = p.columnName;
                    if (p.isPrimarykey == 1)
                    {
                        var keymodel = new PdmKeyModel(tbmodel)
                        {
                            KeyId = p.columnName
                        };
                        keymodel.AddColumnObjCode(p.columnName);
                        tbmodel.Keys.Add(keymodel);
                        tbmodel.PrimaryKeyRefCode = p.columnName;
                    }
                    pcim.Identity  = p.isIdentity == 1;
                    pcim.Mandatory = p.isAllowNull == 1;
                    tbmodel.Columns.Add(pcim);
                });
                list.Add(tbmodel);
            }
            return(list);
        }
示例#2
0
        private static PdmColumnInfoModel GetColumn(XmlNode xnColumn, PdmTableInfoModel ownerTable)
        {
            PdmColumnInfoModel PdmColumnInfoModel = new PdmColumnInfoModel(ownerTable);
            XmlElement         xmlElement         = (XmlElement)xnColumn;

            PdmColumnInfoModel.ColumnId = xmlElement.GetAttribute("Id");
            XmlNodeList childNodes = xmlElement.ChildNodes;

            foreach (XmlNode xmlNode in childNodes)
            {
                string name = xmlNode.Name;
                switch (name)
                {
                case "a:ObjectID":
                    PdmColumnInfoModel.ObjectID = xmlNode.InnerText;
                    break;

                case "a:Name":
                    PdmColumnInfoModel.Name = xmlNode.InnerText;
                    break;

                case "a:Code":
                    PdmColumnInfoModel.Code = xmlNode.InnerText;
                    break;

                case "a:CreationDate":
                    PdmColumnInfoModel.CreationDate = String2DateTime(xmlNode.InnerText);
                    break;

                case "a:Creator":
                    PdmColumnInfoModel.Creator = xmlNode.InnerText;
                    break;

                case "a:ModificationDate":
                    PdmColumnInfoModel.ModificationDate = String2DateTime(xmlNode.InnerText);
                    break;

                case "a:Modifier":
                    PdmColumnInfoModel.Modifier = xmlNode.InnerText;
                    break;

                case "a:Comment":
                    PdmColumnInfoModel.Comment = xmlNode.InnerText;
                    break;

                case "a:DataType":
                    PdmColumnInfoModel.DataType = xmlNode.InnerText;
                    break;

                case "a:Length":
                    PdmColumnInfoModel.Length = xmlNode.InnerText;
                    break;

                case "a:Identity":
                    PdmColumnInfoModel.Identity = ConvertToBooleanPg(xmlNode.InnerText);
                    break;

                case "a:Mandatory":
                    PdmColumnInfoModel.Mandatory = ConvertToBooleanPg(xmlNode.InnerText);
                    break;

                case "a:PhysicalOptions":
                    PdmColumnInfoModel.PhysicalOptions = xmlNode.InnerText;
                    break;

                case "a:ExtendedAttributesText":
                    PdmColumnInfoModel.ExtendedAttributesText = xmlNode.InnerText;
                    break;

                case "a:Precision":
                    PdmColumnInfoModel.Precision = xmlNode.InnerText;
                    break;
                }
            }
            return(PdmColumnInfoModel);
        }