internal static IEnumerable <Expression <Func <PickedInventoryItem, InventoryShipmentOrderItemAnalysisReturn> > > SplitSelectCOAItem() { var lotKey = LotProjectors.SelectLotKey <Lot>(); var loBac = LotProjectors.SelectLoBac(); var lotProduct = LotProjectors.SelectDerivedProduct(); var treatment = InventoryTreatmentProjectors.SelectInventoryTreatment(); var attribute = LotAttributeProjectors.Select(); return(new Projectors <PickedInventoryItem, InventoryShipmentOrderItemAnalysisReturn> { i => new InventoryShipmentOrderItemAnalysisReturn { LotKeyReturn = lotKey.Invoke(i.Lot), TreatmentReturn = treatment.Invoke(i.Treatment), Attributes = i.Lot.Attributes.Select(a => attribute.Invoke(a)), Notes = i.Lot.Notes }, i => new InventoryShipmentOrderItemAnalysisReturn { ProductionDate = new [] { i.Lot.ChileLot }.Where(c => c != null && c.Production != null && c.Production.Results != null) .Select(c => (DateTime?)c.Production.Results.ProductionEnd).FirstOrDefault(), }, i => new InventoryShipmentOrderItemAnalysisReturn { LoBac = loBac.Invoke(i.Lot), LotProduct = lotProduct.Invoke(i.Lot), } }); }
internal static IEnumerable <Expression <Func <Lot, LotHistoryReturn> > > SplitSelectHistory() { var lotKey = SelectLotKey <Lot>(); var product = SelectDerivedProduct(); var attributes = LotAttributeProjectors.SelectHistory(); var history = LotHistoryProjectors.Select(); var employee = EmployeeProjectors.SelectSummary(); return(new Projectors <Lot, LotHistoryReturn> { l => new LotHistoryReturn { LotKeyReturn = lotKey.Invoke(l), Timestamp = l.TimeStamp, Employee = employee.Invoke(l.Employee), LoBac = new [] { l.ChileLot }.Where(c => c != null).Select(c => c.AllAttributesAreLoBac).DefaultIfEmpty(true).FirstOrDefault(), HoldType = l.Hold, HoldDescription = l.HoldDescription, QualityStatus = l.QualityStatus, ProductionStatus = l.ProductionStatus, Product = product.Invoke(l) }, l => new LotHistoryReturn { Attributes = l.Attributes.Select(a => attributes.Invoke(a)) }, l => new LotHistoryReturn { SerializedHistory = l.History.Select(h => history.Invoke(h)) } }); }
internal static Expression <Func <PickedInventoryItem, PickedLotReturn> > SelectPickedLot() { var lotKey = LotProjectors.SelectLotKey <Lot>(); var attribute = LotAttributeProjectors.SelectParameter(); return(i => new PickedLotReturn { LotKey = lotKey.Invoke(i.Lot), ToteKey = i.ToteKey, LotWeight = i.PackagingProduct.Weight * i.Quantity, LotAttributes = i.Lot.Attributes.Select(a => attribute.Invoke(a)) }); }
internal static IEnumerable <Expression <Func <Lot, LotSummaryReturn> > > SplitSelectLotSummary(ILotUnitOfWork lotUnitOfWork, DateTime currentDate) { if (lotUnitOfWork == null) { throw new ArgumentNullException("lotUnitOfWork"); } var attributes = LotAttributeProjectors.Select(); var lotDefects = LotDefectProjectors.SelectLotDefect(); var product = SelectDerivedProduct(); var loBac = SelectLoBac(); var astaCalc = SelectAstaCalc(lotUnitOfWork, currentDate); var customer = PackScheduleProjectors.SelectCustomerHeader(); var productionBatches = lotUnitOfWork.ProductionBatchRepository.All(); var lotKeyFilter = LotPredicates.ConstructLotKeyPredicate <Lot, ProductionBatch>(); return(new[] { SelectLotBase().Merge(l => new LotSummaryReturn { LotDateCreated = l.LotDateCreated, }).ExpandAll(), Projector <Lot> .To(l => new LotSummaryReturn { AstaCalcDate = currentDate, Attributes = l.Attributes.Select(a => attributes.Invoke(a)), Defects = l.LotDefects.OrderBy(d => d.DefectId).Select(d => lotDefects.Invoke(d)) }), Projector <Lot> .To(l => new LotSummaryReturn { LoBac = loBac.Invoke(l), LotProduct = product.Invoke(l), }), Projector <Lot> .To(l => new LotSummaryReturn { AstaCalc = astaCalc.Invoke(l), }), Projector <Lot> .To(l => new LotSummaryReturn { Customer = productionBatches .Where(lotKeyFilter.Invoke(l)) .Select(b => customer.Invoke(b.PackSchedule)).FirstOrDefault() }) }); }
internal static IEnumerable <Expression <Func <ChileLot, LabReportChileLotReturn> > > SplitSelectLabReportChileLot(IQueryable <ProductionBatch> productionBatches, IQueryable <LotProductionResults> lotProdcutionResuls, IQueryable <ChileLotProduction> chileLotProduction) { var chileProductKey = ProductProjectors.SelectProductKey(); var packSchedule = PackScheduleProjectors.SelectBaseWithCustomer(); var productionResult = LotProductionResultsProjectors.SelectBase(); var attribute = LotAttributeProjectors.Select <WeightedLotAttributeReturn>(); var lotTotes = PickedInventoryItemProjectors.SelectPickedLot(); var customerAllowance = LotCustomerAllowanceProjectors.Select(); return(new[] { SelectLotBase().Merge(Projector <ChileLot> .To(c => new LabReportChileLotReturn { LoBac = c.AllAttributesAreLoBac }), c => c.Lot).ExpandAll(), Projector <ChileLot> .To(c => new LabReportChileLotReturn { UnresolvedDefects = c.Lot.LotDefects.Where(d => d.Resolution == null).Select(d => d.Description), WeightedAttributes = c.Lot.Attributes.Select(a => attribute.Invoke(a)), CustomerAllowances = c.Lot.CustomerAllowances.Select(a => customerAllowance.Invoke(a)) }), Projector <ChileLot> .To(c => new LabReportChileLotReturn { WeightedAttributes = c.Lot.Attributes.Select(a => new WeightedLotAttributeReturn { HasResolvedDefects = c.Lot.AttributeDefects.Any(d => d.AttributeShortName == a.AttributeShortName) && c.Lot.AttributeDefects.Where(d => d.AttributeShortName == a.AttributeShortName).All(d => d.LotDefect.Resolution != null) }) }), Projector <ChileLot> .To(c => new LabReportChileLotReturn { ChileProductKeyReturn = chileProductKey.Invoke(c.ChileProduct.Product), PackScheduleBaseReturn = productionBatches.Where(b => b.LotDateCreated == c.LotDateCreated && b.LotDateSequence == c.LotDateSequence && b.LotTypeId == c.LotTypeId) .Select(b => packSchedule.Invoke(b.PackSchedule)).FirstOrDefault() }), Projector <ChileLot> .To(c => new LabReportChileLotReturn { ProductionResultBaseReturn = lotProdcutionResuls.Where(r => r.LotDateCreated == c.LotDateCreated && r.LotDateSequence == c.LotDateSequence && r.LotTypeId == c.LotTypeId) .Select(r => productionResult.Invoke(r)).FirstOrDefault(), PickedLots = chileLotProduction.Where(r => r.LotDateCreated == c.LotDateCreated && r.LotDateSequence == c.LotDateSequence && r.LotTypeId == c.LotTypeId) .SelectMany(r => r.PickedInventory.Items.Select(i => lotTotes.Invoke(i))) }) }); }
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)))); }