コード例 #1
0
        private List <RequiredFieldsDto> GetRequiredFields(string assetType)
        {
            var fields = new List <RequiredFieldsDto>();
            var attributeDefinitionAssetType = metaModel.GetAssetType("AttributeDefinition");
            var nameAttributeDef             = attributeDefinitionAssetType.GetAttributeDefinition("Name");
            var assetNameAttributeDef        = attributeDefinitionAssetType.GetAttributeDefinition("Asset.AssetTypesMeAndDown.Name");
            var taskType = metaModel.GetAssetType(assetType);

            var query = new Query(attributeDefinitionAssetType);

            query.Selection.Add(nameAttributeDef);
            var assetTypeTerm = new FilterTerm(assetNameAttributeDef);

            assetTypeTerm.Equal(assetType);
            query.Filter = new AndFilterTerm(new IFilterTerm[] { assetTypeTerm });

            QueryResult result;

            try {
                result = services.Retrieve(query);
            } catch (Exception ex) {
                logger.Error("Cannot get meta data for " + assetType, ex);
                return(null);
            }

            foreach (var asset in result.Assets)
            {
                try {
                    var name = asset.GetAttribute(nameAttributeDef).Value.ToString();

                    if (IsRequiredField(taskType, name))
                    {
                        var reqFieldData = new RequiredFieldsDto(name, taskType.GetAttributeDefinition(name).DisplayName);
                        fields.Add(reqFieldData);
                    }
                } catch (Exception ex) {
                    logger.Error("Cannot get meta data for " + assetType, ex);
                }
            }

            return(fields);
        }
        private List<RequiredFieldsDto> GetRequiredFields(string assetType) {
            var fields = new List<RequiredFieldsDto>();
            var attributeDefinitionAssetType = metaModel.GetAssetType("AttributeDefinition");
            var nameAttributeDef = attributeDefinitionAssetType.GetAttributeDefinition("Name");
            var assetNameAttributeDef = attributeDefinitionAssetType.GetAttributeDefinition("Asset.AssetTypesMeAndDown.Name");
            var taskType = metaModel.GetAssetType(assetType);

            var query = new Query(attributeDefinitionAssetType);
            query.Selection.Add(nameAttributeDef);
            var assetTypeTerm = new FilterTerm(assetNameAttributeDef);
            assetTypeTerm.Equal(assetType);
            query.Filter = new AndFilterTerm(new IFilterTerm[] { assetTypeTerm });

            QueryResult result;
            try {
                result = services.Retrieve(query);
            } catch (Exception ex) {
                logger.Error("Cannot get meta data for " + assetType, ex);
                return null;
            }

            foreach (var asset in result.Assets) {
                try {
                    var name = asset.GetAttribute(nameAttributeDef).Value.ToString();
                    
                    if(IsRequiredField(taskType, name)) {
                        var reqFieldData = new RequiredFieldsDto(name, taskType.GetAttributeDefinition(name).DisplayName);
                        fields.Add(reqFieldData);
                    }
                } catch(Exception ex) {
                    logger.Error("Cannot get meta data for " + assetType, ex);
                }
            }

            return fields;
        }