コード例 #1
0
        public static void GetAccessors(this ILotAttributes lotAttributes, IAttributeNameKey attribute, out Func <decimal?> get, out Func <decimal?, decimal?> set)
        {
            var attributeNameKey = new AttributeNameKey(attribute);

            get = () => AttributeGetters[attributeNameKey](lotAttributes);
            set = v => AttributeSetters[attributeNameKey](lotAttributes, v);
        }
コード例 #2
0
 public LotAttributesCopy(ILotAttributes source)
 {
     _wrappedAttributes = this.GetAttributes(null).ToDictionary(a => a.AttributeNameKey.ToString());
     foreach (var attribute in _wrappedAttributes)
     {
         attribute.Value.Value = source.AttributeGet(attribute.Value.AttributeNameKey)();
     }
 }
コード例 #3
0
        public static Func <decimal?> AttributeGet(this ILotAttributes lotAttributes, IAttributeNameKey attributeNameKey)
        {
            Func <ILotAttributes, decimal?> getter;

            AttributeGetters.TryGetValue(new AttributeNameKey(attributeNameKey), out getter);
            if (getter == null)
            {
                return(null);
            }
            return(() => getter(lotAttributes));
        }
コード例 #4
0
            public LotAttributeWrapper(ILotAttributes lot, ILotAttributes untestedHistory, AttributeName attributeName)
            {
                ActualValueRequired = attributeName.ActualValueRequired;
                AttributeNameKey    = new AttributeNameKey(attributeName);
                lot.GetAccessors(attributeName, out _get, out _set);

                Computed = lot.TestDate == null;
                if (untestedHistory != null)
                {
                    Computed = Value == untestedHistory.AttributeGet(attributeName)();
                }
            }
コード例 #5
0
        public static Func <decimal?, decimal?> AttributeSet(this ILotAttributes lotAttributes, IAttributeNameKey attributeNameKey, bool rounded = false)
        {
            Func <ILotAttributes, decimal?, decimal?> setter;

            AttributeSetters.TryGetValue(new AttributeNameKey(attributeNameKey), out setter);
            if (setter == null)
            {
                return(null);
            }

            if (rounded)
            {
                return(v => setter(lotAttributes, Rounded(v, GetRoundDecimalPlaces(attributeNameKey))));
            }

            return(v => setter(lotAttributes, v));
        }
コード例 #6
0
        public static LotAttribute AddNewAttribute(this Lot lot, ILotAttributes oldLot, IAttributeNameKey attributeNameKey, CreateChileLotHelper.AttributeCommonData attributeData, ILotMother lotMother)
        {
            var getter = oldLot.AttributeGet(attributeNameKey);

            if (getter == null)
            {
                return(null);
            }

            var setter = oldLot.AttributeSet(attributeNameKey, true);
            var value  = setter(getter());

            if (value == null)
            {
                return(null);
            }

            lotMother.AddRead(EntityTypes.LotAttribute);
            if (attributeData.EntryDate == null)
            {
                return(null);
            }

            var lotAttribute = new LotAttribute
            {
                LotDateCreated     = lot.LotDateCreated,
                LotDateSequence    = lot.LotDateSequence,
                LotTypeId          = lot.LotTypeId,
                AttributeShortName = attributeNameKey.AttributeNameKey_ShortName,

                AttributeValue = (double)value,
                AttributeDate  = attributeData.DeterminedTestDate,

                EmployeeId = attributeData.TesterId,
                TimeStamp  = attributeData.EntryDate.Value,
                Computed   = attributeData.NullTestDate
            };

            lot.Attributes.Add(lotAttribute);
            return(lotAttribute);
        }
コード例 #7
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);
                }
            }
コード例 #8
0
 public static IEnumerable <LotAttributeWrapper> GetAttributes(this ILotAttributes lot, ILotAttributes oldestUntestedHistory)
 {
     return(StaticAttributeNames.AttributeNames.Select(attribute => new LotAttributeWrapper(lot, oldestUntestedHistory, attribute)));
 }