Create() 공개 메소드

public Create ( string name, string description, System systemType ) : DataType
name string
description string
systemType System
리턴 BExIS.Dlm.Entities.DataStructure.DataType
예제 #1
0
        private void createMetadataAttribute()
        {
            //UnitManager um = new UnitManager();
            //Unit km = um.Create("Kilometer", "Km", "This is the Kilometer", "Length", MeasurementSystem.Metric);
            DataTypeManager dtManager = new DataTypeManager();
            DataType dt1 = dtManager.Repo.Get(p => p.Name.Equals("String")).FirstOrDefault();
            if (dt1 == null)
            {
                dt1 = dtManager.Create("String", "A test String", System.TypeCode.String);
            }

            MetadataAttributeManager maManager = new MetadataAttributeManager();

            // for unique name checks USE maManager.MetadataAttributeRepo that is searching both simple and compound attribute names
            var msa1 = maManager.MetadataAttributeRepo.Get(p => p.ShortName.Equals("Simple 1")).FirstOrDefault();
            if (msa1 == null)
            {
                msa1 = new MetadataSimpleAttribute()
                {
                    ShortName = "Simple 1",
                    DataType = dt1,
                };
                maManager.Create((MetadataSimpleAttribute)msa1);
            }
            var msa2 = maManager.MetadataAttributeRepo.Get(p => p.ShortName.Equals("Simple 2")).FirstOrDefault();
            if (msa2 == null)
            {
                msa2 = new MetadataSimpleAttribute()
                {
                    ShortName = "Simple 2",
                    DataType = dt1,
                };
                maManager.Create((MetadataSimpleAttribute)msa2);
            }

            MetadataCompoundAttribute mca1 = (MetadataCompoundAttribute)maManager.MetadataAttributeRepo.Get(p => p.ShortName.Equals("Compound 1")).FirstOrDefault();
            if (mca1 == null)
            {
                mca1 = new MetadataCompoundAttribute()
                {
                    ShortName = "Compound 1",
                    DataType = dt1,

                };
                MetadataNestedAttributeUsage u1 = new MetadataNestedAttributeUsage()
                {
                    Label = "First member",
                    Description = "I am a link between Compound 1 and Simple 1",
                    MinCardinality = 0,
                    MaxCardinality = 2,
                    Master = mca1,
                    Member = msa1,
                };
                mca1.MetadataNestedAttributeUsages.Add(u1);

                MetadataNestedAttributeUsage u2 = new MetadataNestedAttributeUsage()
                {
                    Label = "Second member",
                    Description = "I am a link between Compound 1 and Simple 2",
                    MinCardinality = 0,
                    MaxCardinality = 2,
                    Master = mca1,
                    Member = msa2,
                };
                mca1.MetadataNestedAttributeUsages.Add(u2);

                maManager.Create(mca1);
            }

            maManager.Delete(msa1);
        }
예제 #2
0
        // create read data types in bpp
        public void CreateDataTypes(ref DataTable mappedDataTypes)
        {
            DataTypeManager dataTypeManager = new DataTypeManager();

            foreach (DataRow mappedDataType in mappedDataTypes.Rows)
            {
                string dtName = mappedDataType["Name"].ToString();
                string dtDescription = mappedDataType["Description"].ToString();
                DataTypeDisplayPattern dtDisplayPettern =  new DataTypeDisplayPattern();
                TypeCode dtSystemType = new TypeCode();
                foreach (TypeCode type in Enum.GetValues(typeof(TypeCode)))
                {
                    if (type.ToString().Equals(mappedDataType["SystemType"].ToString()))
                    {
                        dtSystemType = type;
                    }
                }

                if (dtSystemType == TypeCode.DateTime)
                {
                    if (mappedDataType["DisplayPattern"] != null && mappedDataType["DisplayPattern"].ToString() != "")
                    {
                        dtDisplayPettern = DataTypeDisplayPattern.Pattern.Where(p => p.Systemtype.Equals(DataTypeCode.DateTime) && p.Name.Equals(mappedDataType["DisplayPattern"].ToString())).FirstOrDefault();
                    }
                    else
                    {
                        dtDisplayPettern = DataTypeDisplayPattern.Pattern.Where(p => p.Name.Equals("DateTimeIso")).FirstOrDefault();
                    }
                }

                DataType dataType = new DataType();
                // get existing dataTypes
                DataType existDT = dataTypeManager.Repo.Get().Where(d =>
                    d.Name.Equals(dtName) &&
                    d.SystemType.ToString().Equals(mappedDataType["SystemType"].ToString())
                    ).FirstOrDefault();
                // return ID of existing dataType or create dataType
                if (existDT == null && dtSystemType != null)
                {
                    dataType = dataTypeManager.Create(dtName, dtDescription, dtSystemType);

                    XmlDocument xmlDoc = new XmlDocument();
                    XmlNode xmlNode;
                    xmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "Extra", null);
                    xmlDoc.AppendChild(xmlNode);
                    xmlNode = xmlDoc.CreateNode(XmlNodeType.Element, "DisplayPattern", null);
                    xmlNode.InnerXml = DataTypeDisplayPattern.Dematerialize(dtDisplayPettern).InnerXml;
                    xmlDoc.DocumentElement.AppendChild(xmlNode);
                    dataType.Extra = xmlDoc;

                    dataTypeManager.Update(dataType);
                }
                else
                {
                    dataType = existDT;
                }

                mappedDataType["DataTypesId"] = dataType.Id;
            }
        }