public ChileLot CreateUnserializedChileLot(LotDTO oldLot, Lot newLot, ChileProduct chileProduct, IEnumerable <AttributeName> attributeNames, out List <LotAttributeDefect> lotAttributeDefects) { var attributeCommonData = new AttributeCommonData(oldLot, LotMother); newLot.Attributes = new List <LotAttribute>(); foreach (var attribute in StaticAttributeNames.AttributeNames) { var newAttribute = newLot.AddNewAttribute(oldLot, attribute, attributeCommonData, LotMother); if (newAttribute != null) { var wrapper = new ILotAttributesExtensions.LotAttributeWrapper(oldLot, oldLot.OriginalHistory, attribute); newAttribute.Computed = wrapper.Computed; } } return(CreateChileLotAndDefects(oldLot, newLot, chileProduct, attributeNames, out lotAttributeDefects)); }
private void AddNewLotAttribute(ILotAttributes oldAttributes, Lot newLot, ChileProductAttributeRange range, AttributeName attributeName, AttributeCommonData attributeData, double value, ref List <LotAttributeDefect> lotAttributeDefects) { var attribute = newLot.AddNewAttribute(oldAttributes, attributeName, attributeData, LotMother); if (attribute == null) { return; } if (range.ValueOutOfRange(attribute.AttributeValue)) { LotMother.AddRead(EntityTypes.LotDefect); LotMother.AddRead(EntityTypes.LotAttributeDefect); CreateOrUpdateOpenAttributeDefect(newLot, attributeName, value, range, ref lotAttributeDefects); } else { CloseOpenAttributeDefects(attribute, lotAttributeDefects); } }
private void UpdateExistingLotAttribute(LotAttribute existingLotAttribute, AttributeName attributeName, AttributeCommonData attributeData, ChileProductAttributeRange range, double value, ref List <LotAttributeDefect> lotAttributeDefects) { if (range.ValueOutOfRange(value)) { CreateOrUpdateOpenAttributeDefect(existingLotAttribute.Lot, attributeName, value, range, ref lotAttributeDefects); } else { CloseOpenAttributeDefects(existingLotAttribute, lotAttributeDefects); } if (Math.Abs(existingLotAttribute.AttributeValue - value) > 0.0001) { existingLotAttribute.AttributeValue = value; existingLotAttribute.Computed = attributeData.NullTestDate; existingLotAttribute.AttributeDate = attributeData.DeterminedTestDate; } }
private void ReconcileLotAttributesAndDefects(LotDTO oldLot, Lot newLot, ChileProduct chileProduct, AttributeCommonData attributeData, ref List <LotAttributeDefect> lotAttributeDefects) { foreach (var name in StaticAttributeNames.AttributeNames) { var getValue = oldLot.AttributeGet(name); if (getValue == null) { continue; } var oldContextValue = getValue(); var nameKey = new AttributeNameKey(name); var productAttributeRange = chileProduct.ProductAttributeRanges.FirstOrDefault(r => nameKey.Equals(r)); var newContextAttribute = newLot.Attributes.FirstOrDefault(a => nameKey.Equals(a)); if (newContextAttribute == null) { if (oldContextValue != null) { AddNewLotAttribute(oldLot, newLot, productAttributeRange, name, attributeData, (double)oldContextValue, ref lotAttributeDefects); } } else { if (oldContextValue != null) { UpdateExistingLotAttribute(newContextAttribute, name, attributeData, productAttributeRange, (double)oldContextValue, ref lotAttributeDefects); } else { RemoveExistingLotAttribute(newContextAttribute, ref lotAttributeDefects); } } } }