public string FillPropertyUnit(int sourceMaterialId, int sourceId, int subgroupId, IMaterialsContextUow context, PropertyFilter propertyClient, Condition condition)
        {
            string unit = "";

            EquivalentProperty eq = context.EquivalentProperties.AllAsNoTracking.Where(m => m.PropertyId == propertyClient.TypeId && m.SourceId == sourceId).FirstOrDefault();

            switch (sourceId)
            {
            case 1:

                unit = FillMappedPropertyUnit(eq);
                break;

            case 2:

                if (eq != null)
                {
                    unit = FillMappedPropertyUnit(eq);
                }
                else
                {
                    ElsevierMaterials.Models.Property propertyTm = FillNotMappedProperty(propertyClient, condition);
                    unit = propertyTm.OrigUnit;
                }
                break;

            case 3:

                if (eq != null)
                {
                    unit = FillMappedPropertyUnit(eq);
                }

                else if (propertyClient.TypeId == 0 || eq == null)
                {
                    ElsevierMaterials.Models.Property propertyTm = FillNotMappedProperty(propertyClient, condition);
                    if (propertyTm != null)
                    {
                        unit = propertyTm.OrigUnit;
                    }
                }
                else
                {
                    unit = "";
                }

                break;

            default:

                unit = "";
                break;
            }

            return(unit.Replace("<sup>", "^").Replace("</sup>", "").Replace("<sub>", "").Replace("</sub>", "").Replace("&deg;", "°"));
        }
        public void FillElsMaterial(int materialId, int subgroupId, int sourceMaterialId, IMaterialsContextUow context, MaterialDetailsModel model, int type)
        {
            int setId = (int)context.RecordLinks.All.Where(m => m.MaterialID == materialId && m.SubgroupID == subgroupId).FirstOrDefault().SetID;

            IList <RecordLink> conditions = context.RecordLinks.All.Where(n => n.MaterialID == materialId && n.SubgroupID == subgroupId).ToList();

            IDictionary <ProductGroup.ProductGroupType, ProductGroup> listOfGroups = new Dictionary <ProductGroup.ProductGroupType, ProductGroup>();

            IList <ConditionModel> conditionWithProperties = new List <ConditionModel>();

            foreach (var conditionObj in conditions)
            {
                IList <MaterialProperty> propertiesPerCond = context.MaterialProperties.All.Where(m => m.MaterialId == materialId && m.SubgroupId == subgroupId && m.RowId == conditionObj.RowID).ToList();
                foreach (var prop in propertiesPerCond)
                {
                    ProductGroup.ProductGroupType groupId = (ProductGroup.ProductGroupType)context.Trees.Find(n => n.PN_ID == prop.PropertyId).BT_ID;

                    if (!listOfGroups.ContainsKey(groupId))
                    {
                        conditionWithProperties = new List <ConditionModel>();

                        ConditionModel condition = new ConditionElsBinder().FillElsCondition(materialId, subgroupId, context, conditionObj, prop, type);
                        conditionWithProperties.Add(condition);

                        ProductGroup productGroup = FillElsProductGroup(conditionWithProperties, groupId, context);

                        productGroup.MaterialConditions = productGroup.MaterialConditions.OrderBy(c => c.ConditionName).ToList();
                        listOfGroups.Add(groupId, productGroup);
                    }
                    else
                    {
                        ProductGroup selectedGroup = listOfGroups[groupId];

                        if (!selectedGroup.MaterialConditions.Any(v => v.ConditionId == conditionObj.RowID))
                        {
                            ConditionModel condition = new ConditionElsBinder().FillElsCondition(materialId, subgroupId, context, conditionObj, prop, type);
                            selectedGroup.MaterialConditions.Add(condition);
                        }
                        else
                        {
                            ConditionModel condition = selectedGroup.MaterialConditions.Where(v => v.ConditionId == conditionObj.RowID).FirstOrDefault();

                            string unitName = prop.OrigUnit == null ? "" : context.Units.Find(n => n.UnitId == prop.OrigUnit).UnitText;
                            ElsevierMaterials.Models.Property property = context.PropertiesWithConvertedValues.GetPropertyInfoForMaterialForSelectedMetric(context.PreferredNames.Find(o => o.PN_ID == prop.PropertyId).PN, materialId, subgroupId, conditionObj.RowID, prop.PropertyId, prop.ValueId, type, unitName);
                            condition.Properties.Add(property);
                        }
                    }

                    listOfGroups[groupId].PropertyCount++;
                }
            }


            model.Properties = new PropertiesModel();
            OrderPropertiesGroups(model, listOfGroups);
        }
Exemple #3
0
        public string GetPropertyValue(PropertyFilter propertyClient, Condition condition)
        {
            ElsevierMaterials.Models.Property prop = condition.Properties.Where(m => m.SourcePropertyId == propertyClient.SourceTypeId && m.ValueId == propertyClient.RowId).FirstOrDefault();
            if (prop != null)
            {
                return(prop.OrigValue);
            }

            return(null);
        }
 public double GetPropertyTemperature(PropertyFilter propertyClient, Condition condition)
 {
     ElsevierMaterials.Models.Property prop = condition.Properties.Where(m => m.SourcePropertyId == propertyClient.SourceTypeId && m.ValueId == propertyClient.RowId).FirstOrDefault();
     if (prop.Temperature != null)
     {
         return((double)prop.Temperature);
     }
     else
     {
         return(23);
     }
 }
Exemple #5
0
        public ConditionModel FillElsCondition(int materialId, int subgroupId, IMaterialsContextUow context, RecordLink conditionObj, MaterialProperty prop, int type)
        {
            ConditionModel condition = new ConditionModel();

            condition.ConditionId   = (int)conditionObj.RowID;
            condition.Properties    = new List <Property>();
            condition.ConditionName = FillElsConditionName(conditionObj);
            string unitName = prop.OrigUnit == null ? "" : context.Units.Find(n => n.UnitId == prop.OrigUnit).UnitText;

            ElsevierMaterials.Models.Property property = context.PropertiesWithConvertedValues.GetPropertyInfoForMaterialForSelectedMetric(context.PreferredNames.Find(o => o.PN_ID == prop.PropertyId).PN, materialId, subgroupId, conditionObj.RowID, prop.PropertyId, prop.ValueId, type, unitName);
            condition.Properties.Add(property);
            return(condition);
        }
        public Property FillNotMappedProperty(PropertyFilter propertyClient, Condition condition)
        {
            ElsevierMaterials.Models.Property propertyTm = null;

            if (propertyClient.SourceTypeId > 0)
            {
                propertyTm = condition.Properties.Where(m => m.SourcePropertyId == propertyClient.SourceTypeId).FirstOrDefault();
            }
            else
            {
                //Chemical composition
                propertyTm = condition.Properties.Where(m => m.ValueId == propertyClient.RowId).FirstOrDefault();
            }
            return(propertyTm);
        }
        public string FillPropertyName(int sourceMaterialId, int sourceId, int subgroupId, IMaterialsContextUow context, PropertyFilter propertyClient, Condition condition)
        {
            string             name = "";
            EquivalentProperty eq   = context.EquivalentProperties.AllAsNoTracking.Where(m => m.PropertyId == propertyClient.TypeId && m.SourceId == sourceId).FirstOrDefault();

            //TODO: Source stavi u Enum: 1- els, 2-TMMetals, 3-TMPlus
            switch (sourceId)
            {
            case 1:
                name = FillMappedPropertyName(context, propertyClient);
                break;

            case 2:

                if (eq != null)
                {
                    name = FillMappedPropertyName(context, propertyClient);
                }
                else
                {
                    ElsevierMaterials.Models.Property propertyTm = FillNotMappedProperty(propertyClient, condition);
                    name = propertyTm.PropertyName;
                }
                break;

            case 3:

                if (eq != null)
                {
                    name = FillMappedPropertyName(context, propertyClient);
                }

                if (propertyClient.TypeId == 0 || eq == null)
                {
                    ElsevierMaterials.Models.Property propertyTm = FillNotMappedProperty(propertyClient, condition);
                    if (propertyTm != null)
                    {
                        name = propertyTm.PropertyName;
                    }
                }
                break;

            default:
                break;
            }
            return(name);
        }
Exemple #8
0
        public ElsevierMaterials.Models.Domain.Comparison.Material AddMaterial(int materialId, int sourceMaterialId, int sourceId, int subgroupId, IMaterialsContextUow context, PropertyFilter propertyClient, ElsevierMaterials.Models.Domain.Comparison.Property property, ref ElsevierMaterials.Models.Domain.Comparison.Material materialForProperty, Condition condition)
        {
            new ComparisonMaterialBinder().FillMaterialBasicData(materialId, context, sourceMaterialId, propertyClient.ConditionId, sourceId, subgroupId, ref materialForProperty);
            ElsevierMaterials.Models.Property prop = condition.Properties.Where(m => m.SourcePropertyId == propertyClient.SourceTypeId && m.ValueId == propertyClient.RowId).FirstOrDefault();
            if (sourceId == 2)
            {
                materialForProperty.Value = _binderPropertyTMMetals.GetPropertyValue(propertyClient, condition);
            }
            else if (sourceId == 3)
            {
                materialForProperty.Value = _binderPropertyTMPLUS.GetPropertyValue(propertyClient, condition);
            }

            //TODO: material with e value
            //if (materialForProperty.Value.Contains("E"))
            //{
            //    materialForProperty.Value = double.Parse(materialForProperty.Value).ToString();
            //}

            materialForProperty.Condition   = condition.ConditionName + (!string.IsNullOrEmpty(prop.OrigValueText) ? " " + prop.OrigValueText : "");
            materialForProperty.ConditionId = condition.ConditionId;
            return(materialForProperty);
        }