private static void SetLotHoldStatus(LotStat?lotStat, Lot newLot) { string description; var hold = LotHelper.GetHoldStatus(lotStat, out description); if (newLot.Hold != hold) { newLot.Hold = hold; newLot.HoldDescription = description; } }
protected override IEnumerable <LotHistory> BirthRecords() { _loadCount.Reset(); foreach (var lot in SelectRecords(OldContext)) { LotKey lotKey; if (!LotNumberParser.ParseLotNumber(lot.Lot, out lotKey)) { Log(new CallbackParameters(CallbackReason.InvalidLotNumber) { Lot = lot }); continue; } if (!_newContextHelper.LotLoaded(lotKey)) { Log(new CallbackParameters(CallbackReason.LotNotLoaded) { Lot = lot }); continue; } var sequence = 0; var computedHistory = lot.History.Where(h => h.TestDate == null).OrderBy(h => h.ArchiveDate).FirstOrDefault(); DateTime?lotHistoryTimeStamp = null; foreach (var history in lot.History.OrderBy(h => h.ArchiveDate)) { _loadCount.AddRead(EntityTypes.LotAttributeHistory); if (history.EmployeeID == null) { Log(new CallbackParameters(CallbackReason.EmployeeIDIsNull) { History = history }); } var employeeId = history.TesterID ?? history.EmployeeID ?? _newContextHelper.DefaultEmployee.EmployeeId; string holdDescription; var hold = LotHelper.GetHoldStatus((LotStat?)history.LotStat, out holdDescription); var serializedData = new SerializedLotHistory { TimeStamp = lotHistoryTimeStamp ?? history.EntryDate.ConvertLocalToUTC() ?? lotKey.LotKey_DateCreated, QualityStatus = DetermineLotQualityStatus((LotStat?)history.LotStat), ProductionStatus = LotProductionStatus.Produced, Hold = hold, HoldDescription = holdDescription, LoBac = history.LoBac, Attributes = history.GetAttributes(computedHistory) .Where(a => a.Value != null) .Select(attribute => new SerializedLotHistoryAttribute { AttributeShortName = attribute.AttributeNameKey, AttributeValue = (double)attribute.Value, AttributeDate = (history.TestDate ?? history.ArchiveDate).Date, Computed = attribute.Computed }).ToList() }; yield return(new LotHistory { LotTypeId = lotKey.LotKey_LotTypeId, LotDateCreated = lotKey.LotKey_DateCreated, LotDateSequence = lotKey.LotKey_DateSequence, Sequence = sequence++, TimeStamp = (lotHistoryTimeStamp = history.ArchiveDate.ConvertLocalToUTC()).Value, EmployeeId = employeeId, Serialized = JsonConvert.SerializeObject(serializedData) }); _loadCount.AddLoaded(EntityTypes.LotAttributeHistory); } } _loadCount.LogResults(l => Log(new CallbackParameters(l))); }