internal static bool IsValidResolution(this AttributeName attributeName, ResolutionTypeEnum resolutionType) { return(attributeName.DefectType.GetValidResolutions().Contains(resolutionType)); }
public static bool UpdateLot(Lot newLot, SerializableLot deserialized, bool tested, out List <LotAttributeDefect> attributeDefects) { if (deserialized == null) { newLot.Attributes = new List <LotAttribute>(); newLot.LotDefects = new List <LotDefect>(); attributeDefects = new List <LotAttributeDefect>(); return(false); } if (deserialized.LotIdentifiable != null) { newLot.EmployeeId = deserialized.LotIdentifiable.EmployeeKey.EmployeeKeyId; newLot.TimeStamp = deserialized.LotIdentifiable.TimeStamp; } var newAttributeDefects = new List <LotAttributeDefect>(); var attributeNameKeyParser = new AttributeNameKey(); var employeeKeyParser = new EmployeeKey(); newLot.Hold = deserialized.HoldType; newLot.HoldDescription = deserialized.HoldDescription; newLot.Attributes = deserialized.Attributes.Select(a => { var nameKey = attributeNameKeyParser.Parse(a.NameKey); var employeeKey = employeeKeyParser.Parse(a.EmployeeKey); return(new LotAttribute { Lot = newLot, TimeStamp = a.TimeStamp, EmployeeId = employeeKey.EmployeeKey_Id, LotDateCreated = newLot.LotDateCreated, LotDateSequence = newLot.LotDateSequence, LotTypeId = newLot.LotTypeId, AttributeShortName = nameKey.AttributeNameKey_ShortName, AttributeValue = a.Value, AttributeDate = a.DateTested.Date, Computed = a.Computed ?? !tested }); }).ToList(); var defectId = 0; newLot.LotDefects = deserialized.Defects.Select(d => { DefectTypeEnum defectType; if (!DefectTypeEnum.TryParse(d.DefectType, out defectType)) { throw new Exception(string.Format("Could not parse DefectTypeEnum[{0}]", d.DefectType)); } var resolutionType = default(ResolutionTypeEnum); if (d.DefectResolution != null) { if (!ResolutionTypeEnum.TryParse(d.DefectResolution.ResolutionType, out resolutionType)) { throw new Exception(string.Format("Could not parse ResolutionTypeEnum[{0}]", d.DefectResolution.ResolutionType)); } } defectId += 1; var defect = new LotDefect { LotDateCreated = newLot.LotDateCreated, LotDateSequence = newLot.LotDateSequence, LotTypeId = newLot.LotTypeId, DefectId = defectId, DefectType = defectType, Description = d.Description, Resolution = d.DefectResolution == null ? null : new LotDefectResolution { EmployeeId = employeeKeyParser.Parse(d.DefectResolution.EmployeeKey).EmployeeKey_Id, TimeStamp = d.DefectResolution.TimeStamp, LotDateCreated = newLot.LotDateCreated, LotDateSequence = newLot.LotDateSequence, LotTypeId = newLot.LotTypeId, DefectId = defectId, ResolutionType = resolutionType, Description = d.DefectResolution.Description, } }; if (d.AttributeDefect != null) { var nameKey = attributeNameKeyParser.Parse(d.AttributeDefect.NameKey); newAttributeDefects.Add(new LotAttributeDefect { LotDateCreated = newLot.LotDateCreated, LotDateSequence = newLot.LotDateSequence, LotTypeId = newLot.LotTypeId, DefectId = defectId, AttributeShortName = nameKey.AttributeNameKey_ShortName, OriginalAttributeValue = d.AttributeDefect.Value, OriginalAttributeMinLimit = d.AttributeDefect.Min, OriginalAttributeMaxLimit = d.AttributeDefect.Max, LotDefect = defect }); } return(defect); }).ToList(); attributeDefects = newAttributeDefects; return(true); }
public static bool IsValidResolution(this LotAttribute attribute, ResolutionTypeEnum resolutionType) { return(attribute.AttributeName.IsValidResolution(resolutionType)); }