private PickedInventory CreatePickedInventory(IPickedInventoryKey pickedInventoryKey, tblRinconDTO rincon) { _loadCount.AddRead(EntityTypes.PickedInventory); var identifiable = rincon.tblRinconDetails.Cast <IEmployeeIdentifiableDTO>().ToList(); identifiable.Add(rincon); int? employeeID; DateTime?timestamp; identifiable.GetLatest(out employeeID, out timestamp); if (timestamp == null) { Log(new CallbackParameters(CallbackReason.PickedInventoryUndeterminedTimestamp) { Rincon = rincon }); return(null); } employeeID = employeeID ?? _newContextHelper.DefaultEmployee.EmployeeId; if (employeeID == _newContextHelper.DefaultEmployee.EmployeeId) { Log(new CallbackParameters(CallbackReason.PickedInventoryUsedDefaultEmployee) { Rincon = rincon, DefaultEmployeeID = employeeID.Value }); } return(new PickedInventory { EmployeeId = employeeID.Value, TimeStamp = timestamp.Value, DateCreated = pickedInventoryKey.PickedInventoryKey_DateCreated, Sequence = pickedInventoryKey.PickedInventoryKey_Sequence, Archived = true, PickedReason = PickedReason.IntraWarehouseMovement, Items = CreatePickedInventoryItems(pickedInventoryKey, rincon).ToList() }); }
private IEnumerable <PickedInventoryItem> CreatePickedInventoryItems(IPickedInventoryKey pickedInventoryKey, tblRinconDTO rincon) { var sequence = 0; foreach (var detail in rincon.tblRinconDetails) { _loadCount.AddRead(EntityTypes.PickedInventoryItem); LotKey lotKey; if (!LotNumberParser.ParseLotNumber(detail.Lot, out lotKey)) { Log(new CallbackParameters(CallbackReason.InvalidLotKey) { Detail = detail }); continue; } if (!_newContextHelper.LotLoaded(lotKey)) { Log(new CallbackParameters(CallbackReason.LotNotLoaded) { Detail = detail }); continue; } var packagingProduct = detail.PTypeID == (int?)LotTypeEnum.Packaging ? _newContextHelper.NoPackagingProduct : _newContextHelper.GetPackagingProduct(detail.PkgID); if (packagingProduct == null) { Log(new CallbackParameters(CallbackReason.PackagingNotLoaded) { Detail = detail }); continue; } var fromWarehouseLocation = _newContextHelper.GetLocation(detail.CurrLocID); if (fromWarehouseLocation == null) { Log(new CallbackParameters(CallbackReason.FromWarehouseLocationNotLoaded) { Detail = detail }); continue; } var treatment = _newContextHelper.GetInventoryTreatment(detail.TrtmtID); if (treatment == null) { Log(new CallbackParameters(CallbackReason.TreatmentNotLoaded) { Detail = detail }); continue; } var destinationLocation = _newContextHelper.GetLocation(detail.DestLocID); if (destinationLocation == null) { Log(new CallbackParameters(CallbackReason.DestinationLocationNotLoaded) { Detail = detail }); continue; } if (detail.Quantity == null) { Log(new CallbackParameters(CallbackReason.MissingQuantity) { Detail = detail }); continue; } yield return(new PickedInventoryItem { DateCreated = pickedInventoryKey.PickedInventoryKey_DateCreated, Sequence = pickedInventoryKey.PickedInventoryKey_Sequence, ItemSequence = ++sequence, LotDateCreated = lotKey.LotKey_DateCreated, LotDateSequence = lotKey.LotKey_DateSequence, LotTypeId = lotKey.LotKey_LotTypeId, PackagingProductId = packagingProduct.Id, FromLocationId = fromWarehouseLocation.Id, TreatmentId = treatment.Id, CurrentLocationId = destinationLocation.Id, ToteKey = "", Quantity = (int)detail.Quantity }); } }