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); }
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); } }
private static int GetRoundDecimalPlaces(IAttributeNameKey attributeNameKey) { int decimals; if (attributeNameKey == null || !AttributeDecimalPlaces.TryGetValue(new AttributeNameKey(attributeNameKey), out decimals)) { return(0); } return(decimals); }
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); }
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); }
public AttributeRange(IAttributeNameKey attributeNameKey, double min, double max) { AttributeNameKey = attributeNameKey; Min = min; Max = max; }
public LotAttributeKey(ILotKey lotKey, IAttributeNameKey attributeNameKey) : this(lotKey.LotKey_DateCreated, lotKey.LotKey_DateSequence, lotKey.LotKey_LotTypeId, attributeNameKey.AttributeNameKey_ShortName) { }
public decimal?this[IAttributeNameKey k] { get { return(_wrappedAttributes[new AttributeNameKey(k)].Value); } set { _wrappedAttributes[new AttributeNameKey(k)].Value = value; } }
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); }
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)))); }
public LotAttributeDefectKey(ILotDefectKey defectKey, IAttributeNameKey attributeNameKey) : this(defectKey.LotKey_DateCreated, defectKey.LotKey_DateSequence, defectKey.LotKey_LotTypeId, defectKey.LotDefectKey_Id, attributeNameKey.AttributeNameKey_ShortName) { }
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); }
public void Add(IAttributeNameKey nameKey, double min, double max) { Add(new AttributeRange(nameKey, min, max)); }
public static AttributeNameKey ToAttributeNameKey(this IAttributeNameKey k) { return(new AttributeNameKey(k)); }
public CustomerProductAttributeRangeKey(ICustomerKey customerKey, IChileProductKey chileProductKey, IAttributeNameKey attributeNameKey) : base(customerKey.CustomerKey_Id, chileProductKey.ChileProductKey_ProductId, attributeNameKey.AttributeNameKey_ShortName) { }
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); }
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)); }
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); }
public Attribute(IAttributeNameKey nameKey, double value) { NameKey = nameKey; Value = value; }
public ChileProductAttributeRangeKey(IChileProductKey chileProductKey, IAttributeNameKey attributeNameKey) : this(chileProductKey.ChileProductKey_ProductId, attributeNameKey.AttributeNameKey_ShortName) { }
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()); }
public void Add(IAttributeNameKey nameKey, double value) { Add(new Attribute(nameKey, value)); }