Ejemplo n.º 1
0
        internal static ChileProductAttributeRange SetValues(this ChileProductAttributeRange range, IAttributeNameKey attribute = null, double?min = null, double?max = null)
        {
            range.SetValues(min, max, attribute != null ? attribute.AttributeNameKey_ShortName : null);
            if (attribute != null)
            {
                range.AttributeName = null;
            }

            return(range);
        }
Ejemplo n.º 2
0
        internal static ChileProductAttributeRange ConstrainByKeys(this ChileProductAttributeRange range, IChileProductKey chileProductKey = null, IAttributeNameKey attributeNameKey = null)
        {
            if (range == null)
            {
                throw new ArgumentNullException("range");
            }

            if (chileProductKey != null)
            {
                range.ChileProduct   = null;
                range.ChileProductId = chileProductKey.ChileProductKey_ProductId;
            }

            if (attributeNameKey != null)
            {
                range.AttributeName      = null;
                range.AttributeShortName = attributeNameKey.AttributeNameKey_ShortName;
            }

            return(range);
        }
Ejemplo n.º 3
0
        internal static ChileProductAttributeRange SetValues(this ChileProductAttributeRange range, double?min = null, double?max = null, string attributeShortName = null)
        {
            if (range == null)
            {
                throw new ArgumentNullException("range");
            }

            if (attributeShortName != null)
            {
                range.AttributeShortName = attributeShortName;
            }

            if (min != null)
            {
                range.RangeMin = (double)min;
            }

            if (max != null)
            {
                range.RangeMax = (double)max;
            }

            return(range);
        }
Ejemplo n.º 4
0
 internal static void AssertEquivalent(this ISetAttributeRangeParameters expected, ChileProductAttributeRange actual)
 {
     Assert.AreEqual(expected.AttributeNameKey, actual.ToAttributeNameKey().KeyValue);
     Assert.AreEqual(expected.RangeMin, actual.RangeMin);
     Assert.AreEqual(expected.RangeMax, actual.RangeMax);
 }
Ejemplo n.º 5
0
            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;
                }
            }
Ejemplo n.º 6
0
            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 IResult UpdateOrCreateLotDefects(LotAttribute lotAttribute, IAttributeValueParameters attributeValue, ChileProductAttributeRange range)
        {
            var unresolvedDefects = _parameters.LotAttributeDefects.Where(d => d.AttributeShortName == lotAttribute.AttributeShortName && d.LotDefect.Resolution == null).ToList();

            if (unresolvedDefects.Any())
            {
                unresolvedDefects.ForEach(d =>
                {
                    d.OriginalAttributeValue    = attributeValue.NewValue.Value;
                    d.OriginalAttributeMinLimit = range.RangeMin;
                    d.OriginalAttributeMaxLimit = range.RangeMax;
                });
            }
            else
            {
                int defectId;
                lock (LotDefectLock)
                {
                    defectId = new EFUnitOfWorkHelper(_lotUnitOfWork).GetNextSequence <LotDefect>(d => d.LotDateCreated == _parameters.Lot.LotDateCreated && d.LotDateSequence == _parameters.Lot.LotDateSequence && d.LotTypeId == _parameters.Lot.LotTypeId, d => d.DefectId);
                }

                var lotDefect = _lotUnitOfWork.LotDefectRepository.Add(new LotDefect
                {
                    LotDateCreated  = _parameters.Lot.LotDateCreated,
                    LotDateSequence = _parameters.Lot.LotDateSequence,
                    LotTypeId       = _parameters.Lot.LotTypeId,
                    DefectId        = defectId,
                    DefectType      = lotAttribute.AttributeName.DefectType,
                    Description     = lotAttribute.AttributeName.Name,
                });
                _lotUnitOfWork.LotAttributeDefectRepository.Add(new LotAttributeDefect
                {
                    LotDateCreated     = lotDefect.LotDateCreated,
                    LotDateSequence    = lotDefect.LotDateSequence,
                    LotTypeId          = lotDefect.LotTypeId,
                    DefectId           = lotDefect.DefectId,
                    AttributeShortName = lotAttribute.AttributeShortName,

                    OriginalAttributeValue    = attributeValue.NewValue.Value,
                    OriginalAttributeMinLimit = range.RangeMin,
                    OriginalAttributeMaxLimit = range.RangeMax,
                    AttributeName             = lotAttribute.AttributeName,
                });
            }

            return(new SuccessResult());
        }