public string GetPropertiesForExport(int sourceMaterialId, int sourceId, int subgroupId, List <PropertyFilter> properties, ElsevierMaterials.Models.Domain.Export.Exporter exporter, out List <PropertyFilter> propertiesForExport, IMaterialsContextUow materialContextUow) { propertiesForExport = new List <PropertyFilter>(); PropertyBinder propertyBinder = new PropertyBinder(); ConditionBinder conditionBinder = new ConditionBinder(); string message = ""; string propertes1 = ""; string propertes2 = ""; string ulOpen = "<ul>"; string ulClose = "</ul>"; string title1 = "The following properties are added to export: "; string title2 = "The following properties cannot be exported: "; foreach (var addedProperty in properties) { ElsevierMaterials.Models.Condition condition = conditionBinder.FillCondition(sourceMaterialId, sourceId, subgroupId, materialContextUow, addedProperty); int notMappedPropertyId = addedProperty.SourceTypeId != 0 ? addedProperty.SourceTypeId : addedProperty.TypeId; TMPropertyTypeEnum propertyId = MapElsPropertyId(notMappedPropertyId, (SourceTypeEnum)sourceId); if (!exporter.Properties.Contains(propertyId)) { if (propertes2 == "") { propertes2 = propertes2 + ulOpen; } propertes2 = propertes2 + "<li>" + propertyBinder.FillPropertyName(sourceMaterialId, sourceId, subgroupId, materialContextUow, addedProperty, condition) + "</li>"; } else { propertiesForExport.Add(addedProperty); if (propertes1 == "") { propertes1 = propertes1 + ulOpen; } propertes1 = propertes1 + "<li>" + propertyBinder.FillPropertyName(sourceMaterialId, sourceId, subgroupId, materialContextUow, addedProperty, condition) + "</li>"; } } if (propertes1 != "" && propertes2 != "") { message = title1 + propertes1 + ulClose + "<br/>" + title2 + propertes2 + ulClose; } else if (propertes1 != "") { message = title1 + propertes1 + ulClose; } else if (propertes2 != "") { message = title2 + propertes2 + ulClose; } return(message); }
public void AddPropertiesForMaterial(int sourceMaterialId, int sourceId, int subgroupId, List <PropertyFilter> propertiesForExport, Material material, IMaterialsContextUow materialContextUow) { foreach (var propertyClient in propertiesForExport) { Property property = material.Properties.Where(m => m.ElsBasicInfo.GroupId == propertyClient.GroupId && m.ElsBasicInfo.TypeId == propertyClient.TypeId && m.ElsBasicInfo.SourceTypeId == propertyClient.SourceTypeId).FirstOrDefault(); ElsevierMaterials.Models.Condition condition = _conditionBinder.FillCondition(sourceMaterialId, sourceId, subgroupId, materialContextUow, propertyClient); property = AddProperty(sourceMaterialId, sourceId, subgroupId, material, property, materialContextUow, propertyClient, condition); } }
public ElsevierMaterials.Models.Domain.Export.Property AddProperty(int sourceMaterialId, int sourceId, int subgroupId, ElsevierMaterials.Models.Domain.Export.Material material, ElsevierMaterials.Models.Domain.Export.Property property, IMaterialsContextUow materialContextUow, PropertyFilter propertyClient, ElsevierMaterials.Models.Condition condition) { if (property == null) { property = new ElsevierMaterials.Models.Domain.Export.Property(); PropertyBasicInfo propertyInfo = _propertyBinder.FillPropertyBasicData(materialContextUow, propertyClient, null); property.ElsBasicInfo = propertyInfo; property.ElsBasicInfo.Name = _propertyBinder.FillPropertyName(sourceMaterialId, sourceId, subgroupId, materialContextUow, propertyClient, condition); property.ElsBasicInfo.Unit = _propertyBinder.FillPropertyUnit(sourceMaterialId, sourceId, subgroupId, materialContextUow, propertyClient, condition); material.Properties.Add(property); } property.Value = _propertyBinder.FillPropertyValue(material.MaterialInfo.MaterialId, sourceMaterialId, sourceId, subgroupId, materialContextUow, propertyClient, condition); property.Temperature = _propertyBinder.FillPropertyTemperature(material.MaterialInfo.MaterialId, sourceMaterialId, sourceId, subgroupId, materialContextUow, propertyClient, condition); return(property); }