Esempio n. 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);
        }
Esempio n. 2
0
 private static double GetAverage(this PackSchedule packSchedule, IAttributeNameKey attributeName)
 {
     return(packSchedule.ProductionBatches.SelectMany(b => b.Production.ResultingChileLot.Lot.Attributes).Where(a => a.AttributeShortName == attributeName.AttributeNameKey_ShortName)
            .Select(a => a.AttributeValue)
            .DefaultIfEmpty(0.0)
            .Average());
 }
            private void CloseOpenAttributeDefects(IAttributeNameKey attributeNameKey, IEnumerable <LotAttributeDefect> lotAttributeDefects)
            {
                var nameKey = attributeNameKey.ToAttributeNameKey();

                foreach (var attributeDefect in lotAttributeDefects.Where(a => a.LotDefect.Resolution == null && nameKey.Equals(a)).ToList())
                {
                    attributeDefect.LotDefect.ResolveDefect(LotMother.DefaultEmployee);
                }
            }
Esempio n. 4
0
        private static int GetRoundDecimalPlaces(IAttributeNameKey attributeNameKey)
        {
            int decimals;

            if (attributeNameKey == null || !AttributeDecimalPlaces.TryGetValue(new AttributeNameKey(attributeNameKey), out decimals))
            {
                return(0);
            }

            return(decimals);
        }
Esempio n. 5
0
            public SetRange(IAttributeNameKey attribute, Expression <Func <tblProduct, decimal?> > selectMin, Expression <Func <tblProduct, decimal?> > selectMax)
            {
                Attribute = attribute;

                var memberExpression = selectMin.Body as MemberExpression;

                _min = memberExpression.Member as PropertyInfo;

                memberExpression = selectMax.Body as MemberExpression;
                _max             = memberExpression.Member as PropertyInfo;
            }
 public static IAttributeDefect BuildProductSpecDefect(IAttributeNameKey nameKey, double value, double min, double max, bool resolution)
 {
     return(new AttributeDefect
     {
         HasResolution = resolution,
         AttributeNameKey_ShortName = nameKey.AttributeNameKey_ShortName,
         Value = value,
         RangeMin = min,
         RangeMax = max,
         DefectType = DefectTypeEnum.ProductSpec
     });
 }
        private string GetLotAttribute(IAttributeNameKey attribute)
        {
            if (LotAttributes != null)
            {
                var key  = attribute.ToAttributeNameKey();
                var attr = LotAttributes.FirstOrDefault(a => key.Equals(a));
                if (attr != null)
                {
                    return(attr.AttributeValue.ToString("0.####"));
                }
            }

            return("n/a");
        }
        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);
        }
Esempio n. 9
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);
        }
Esempio n. 10
0
 public AttributeRange(IAttributeNameKey attributeNameKey, double min, double max)
 {
     AttributeNameKey = attributeNameKey;
     Min = min;
     Max = max;
 }
Esempio n. 11
0
 public LotAttributeKey(ILotKey lotKey, IAttributeNameKey attributeNameKey) : this(lotKey.LotKey_DateCreated, lotKey.LotKey_DateSequence, lotKey.LotKey_LotTypeId, attributeNameKey.AttributeNameKey_ShortName)
 {
 }
Esempio n. 12
0
 public decimal?this[IAttributeNameKey k]
 {
     get { return(_wrappedAttributes[new AttributeNameKey(k)].Value); }
     set { _wrappedAttributes[new AttributeNameKey(k)].Value = value; }
 }
Esempio n. 13
0
        private static bool AttributeInLoBacRange(ILotContainer lotContainer, IEnumerable <AttributeName> attributeNames, IAttributeNameKey staticAttributeName)
        {
            var attributeName = attributeNames.SingleOrDefault(n => n.AttributeNameKey_ShortName == staticAttributeName.AttributeNameKey_ShortName);

            if (attributeName == null)
            {
                return(false);
            }

            var attribute = lotContainer.Lot.Attributes.SingleOrDefault(c => c.AttributeShortName == attributeName.AttributeNameKey_ShortName);

            if (attribute == null)
            {
                return(false);
            }

            return(attribute.AttributeValue <= attributeName.LoBacLimit);
        }
 internal static LotAttribute SetValues(this LotAttribute lotAttribute, IAttributeNameKey attributeNameKey = null, double?value = null, bool?computed = null)
 {
     return(lotAttribute.SetValues(null, attributeNameKey, value, computed));
 }
 internal static AttributeName SetKey(this AttributeName attributeName, IAttributeNameKey attributeNameKey)
 {
     attributeName.ShortName = attributeNameKey.AttributeNameKey_ShortName;
     return(attributeName);
 }
Esempio n. 16
0
        internal static Expression <Func <PackSchedule, double> > SelectAverage(IAttributeNameKey attribute)
        {
            var average = LotAttributeProjectors.SelectAverage(attribute);

            return(Projector <PackSchedule> .To(p => average.Invoke(p.ProductionBatches.SelectMany(b => b.Production.ResultingChileLot.Lot.Attributes))));
        }
Esempio n. 17
0
 public LotAttributeDefectKey(ILotDefectKey defectKey, IAttributeNameKey attributeNameKey)
     : this(defectKey.LotKey_DateCreated, defectKey.LotKey_DateSequence, defectKey.LotKey_LotTypeId, defectKey.LotDefectKey_Id, attributeNameKey.AttributeNameKey_ShortName)
 {
 }
Esempio n. 18
0
        internal static CustomerProductAttributeRange SetValues(this CustomerProductAttributeRange range, ICustomerKey customer = null, IAttributeNameKey attribute = null, double?min = null, double?max = null,
                                                                IChileProductKey chileProduct = null, bool active = true)
        {
            if (range == null)
            {
                throw new ArgumentNullException("range");
            }

            if (customer != null)
            {
                range.Customer   = null;
                range.CustomerId = customer.CustomerKey_Id;
            }

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

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

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

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

            range.Active = active;

            return(range);
        }
Esempio n. 19
0
 public void Add(IAttributeNameKey nameKey, double min, double max)
 {
     Add(new AttributeRange(nameKey, min, max));
 }
Esempio n. 20
0
 public static AttributeNameKey ToAttributeNameKey(this IAttributeNameKey k)
 {
     return(new AttributeNameKey(k));
 }
Esempio n. 21
0
 public CustomerProductAttributeRangeKey(ICustomerKey customerKey, IChileProductKey chileProductKey, IAttributeNameKey attributeNameKey) : base(customerKey.CustomerKey_Id, chileProductKey.ChileProductKey_ProductId, attributeNameKey.AttributeNameKey_ShortName)
 {
 }
Esempio n. 22
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));
        }
        internal static LotAttribute SetValues(this LotAttribute lotAttribute, ILotKey lotKey = null, IAttributeNameKey attributeNameKey = null, double?value = null, bool?computed = null)
        {
            if (lotKey != null)
            {
                lotAttribute.Lot             = null;
                lotAttribute.LotDateCreated  = lotKey.LotKey_DateCreated;
                lotAttribute.LotDateSequence = lotKey.LotKey_DateSequence;
                lotAttribute.LotTypeId       = lotKey.LotKey_LotTypeId;
            }

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

            if (value != null)
            {
                lotAttribute.AttributeValue = (double)value;
            }

            if (computed != null)
            {
                lotAttribute.Computed = computed.Value;
            }

            return(lotAttribute);
        }
Esempio n. 24
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));
        }
Esempio n. 25
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);
        }
        internal static LotAttributeDefect SetValues(this LotAttributeDefect defect, ILotKey lotKey = null, IAttributeNameKey attributeNameKey = null, DefectTypeEnum?defectType = null, double?value = null, double?rangeMin = null, double?rangeMax = null)
        {
            if (lotKey != null)
            {
                if (defect.LotDefect != null)
                {
                    defect.LotDefect.SetValues(lotKey);
                }

                defect.LotDateCreated  = lotKey.LotKey_DateCreated;
                defect.LotDateSequence = lotKey.LotKey_DateSequence;
                defect.LotTypeId       = lotKey.LotKey_LotTypeId;
            }

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

            if (defectType != null)
            {
                defect.LotDefect.DefectType = (DefectTypeEnum)defectType;
            }

            if (value != null)
            {
                defect.OriginalAttributeValue = (double)value;
            }

            if (rangeMin != null)
            {
                defect.OriginalAttributeMinLimit = (double)rangeMin;
            }

            if (rangeMax != null)
            {
                defect.OriginalAttributeMaxLimit = (double)rangeMax;
            }

            return(defect);
        }
Esempio n. 27
0
 public Attribute(IAttributeNameKey nameKey, double value)
 {
     NameKey = nameKey;
     Value   = value;
 }
Esempio n. 28
0
 public ChileProductAttributeRangeKey(IChileProductKey chileProductKey, IAttributeNameKey attributeNameKey)
     : this(chileProductKey.ChileProductKey_ProductId, attributeNameKey.AttributeNameKey_ShortName)
 {
 }
Esempio n. 29
0
 internal static Expression <Func <IEnumerable <LotAttribute>, double> > SelectAverage(IAttributeNameKey attribute)
 {
     return(attributes => attributes.Where(a => a.AttributeShortName == attribute.AttributeNameKey_ShortName)
            .Select(a => a.AttributeValue)
            .DefaultIfEmpty(0.0)
            .Average());
 }
Esempio n. 30
0
 public void Add(IAttributeNameKey nameKey, double value)
 {
     Add(new Attribute(nameKey, value));
 }