internal static IEnumerable <Expression <Func <PackSchedule, PackScheduleSummaryReturn> > > SplitSelectSummary() { var productionLocationKey = LocationProjectors.SelectLocationKey(); var workTypeKey = WorkTypeProjectors.SelectWorkTypeKey(); var productKey = ProductProjectors.SelectProductKey(); var company = CustomerProjectors.SelectCompanyHeader(); return(new[] { SelectBaseParameters().Merge(p => new PackScheduleSummaryReturn { DateCreated = p.DateCreated, ScheduledProductionDate = p.ScheduledProductionDate, ProductionDeadline = p.ProductionDeadline, OrderNumber = p.OrderNumber }).ExpandAll(), Projector <PackSchedule> .To(p => new PackScheduleSummaryReturn { WorkTypeKeyReturn = workTypeKey.Invoke(p.WorkType), ChileProductKeyReturn = productKey.Invoke(p.ChileProduct.Product), ChileProductName = p.ChileProduct.Product.Name, }), Projector <PackSchedule> .To(p => new PackScheduleSummaryReturn { ProductionLocationKeyReturn = productionLocationKey.Invoke(p.ProductionLineLocation), Customer = new[] { p.Customer }.Where(c => c != null).Select(c => company.Invoke(c)).FirstOrDefault(), }) }); }
private static IEnumerable <Expression <Func <LotProductionResults, ProductionResultReturn> > > SplitSelectReturn() { var productionLocationKey = LocationProjectors.SelectLocationKey(); var lotKey = LotProjectors.SelectLotKey <LotProductionResults>(); var productKey = ProductProjectors.SelectProductKey(); return(new[] { SelectBase().Merge(r => new ProductionResultReturn { LotKeyReturn = lotKey.Invoke(r), DateTimeEntered = r.DateTimeEntered, ProductionStartDate = r.ProductionBegin }).ExpandAll(), Projector <LotProductionResults> .To(r => new ProductionResultReturn { User = r.Employee.UserName, ProductionLocationKeyReturn = productionLocationKey.Invoke(r.ProductionLineLocation) }), Projector <LotProductionResults> .To(r => new ProductionResultReturn { ChileProductName = r.Production.ResultingChileLot.ChileProduct.Product.Name, ChileProductKeyReturn = productKey.Invoke(r.Production.ResultingChileLot.ChileProduct.Product) }) }); }
internal static IEnumerable <Expression <Func <InventoryPickOrderItem, InventoryPickOrderItemReturn> > > SplitSelect() { var key = SelectKey(); var productKey = ProductProjectors.SelectProductKey(); var inventoryTreatmentKey = InventoryTreatmentProjectors.SelectInventoryTreatmentKey(); var company = CompanyProjectors.SelectHeader(); return(new Projectors <InventoryPickOrderItem, InventoryPickOrderItemReturn> { i => new InventoryPickOrderItemReturn { InventoryPickOrderItemKeyReturn = key.Invoke(i), ProductKeyReturn = productKey.Invoke(i.Product), ProductName = i.Product.Name, ProductCode = i.Product.ProductCode, TreatmentNameShort = i.InventoryTreatment.ShortName, InventoryTreatmentKeyReturn = inventoryTreatmentKey.Invoke(i.InventoryTreatment), Quantity = i.Quantity, CustomerLotCode = i.CustomerLotCode, CustomerProductCode = i.CustomerProductCode }, i => new InventoryPickOrderItemReturn { PackagingProductKeyReturn = productKey.Invoke(i.PackagingProduct.Product), PackagingName = i.PackagingProduct.Product.Name, PackagingWeight = i.PackagingProduct.Weight, TotalWeight = i.PackagingProduct.Weight * i.Quantity }, i => new InventoryPickOrderItemReturn { Customer = new [] { i.Customer }.Where(c => c != null).Select(c => company.Invoke(c.Company)).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 IEnumerable <Expression <Func <ProductionBatch, ProductionBatchDetailReturn> > > SplitSelectDetail(Data.Interfaces.UnitsOfWork.IProductionUnitOfWork productionUnitOfWork, DateTime currentDate) { if (productionUnitOfWork == null) { throw new ArgumentNullException("productionUnitOfWork"); } var packScheduleKey = PackScheduleProjectors.SelectKey(); var productKey = ProductProjectors.SelectProductKey(); var chileProduct = ProductProjectors.SelectChileProductWithIngredients(); var workType = WorkTypeProjectors.Select(); var notebook = NotebookProjectors.Select(); var pickedChile = PickedInventoryProjectors.SelectPickedChileInventoryItem(productionUnitOfWork); var pickedPackaging = PickedInventoryProjectors.SelectPickedPackagingInventoryItem(productionUnitOfWork); var pickedAdditve = PickedInventoryProjectors.SelectPickedAdditiveInventoryItem(productionUnitOfWork); var pickedItemProjectors = PickedInventoryItemProjectors.SplitSelect(productionUnitOfWork, currentDate); return(new[] { SelectSummary().Merge(b => new ProductionBatchDetailReturn { HasProductionBeenCompleted = b.ProductionHasBeenCompleted, }).ExpandAll(), Projector <ProductionBatch> .To(b => new ProductionBatchDetailReturn { PackScheduleKeyReturn = packScheduleKey.Invoke(b.PackSchedule), ChileProductKeyReturn = productKey.Invoke(b.Production.ResultingChileLot.ChileProduct.Product), ChileProductName = b.Production.ResultingChileLot.ChileProduct.Product.Name, ChileProductWithIngredients = chileProduct.Invoke(b.Production.ResultingChileLot.ChileProduct) }), Projector <ProductionBatch> .To(b => new ProductionBatchDetailReturn { WorkType = workType.Invoke(b.PackSchedule.WorkType), InstructionsNotebook = notebook.Invoke(b.InstructionNotebook) }), Projector <ProductionBatch> .To(b => new ProductionBatchDetailReturn { PickedChileItems = pickedChile.Invoke(b.Production.PickedInventory), PickedPackagingItems = pickedPackaging.Invoke(b.Production.PickedInventory), PickedAdditiveItems = pickedAdditve.Invoke(b.Production.PickedInventory) }) }.ToAppendedList(pickedItemProjectors.Select(p => Projector <ProductionBatch> .To(b => new ProductionBatchDetailReturn { PickedInventoryItems = b.Production.PickedInventory.Items.Select(i => p.Invoke(i)) })))); }
internal static IEnumerable <Expression <Func <PackSchedule, PackScheduleDetailReturn> > > SplitSelectDetail() { var productKey = ProductProjectors.SelectProductKey(); var productionBatches = ProductionBatchProjectors.SelectSummary(); return(SplitSelectSummary().Select(ConvertSummaryToDetail) .ToListWithModifiedElement(0, e => e.Merge(p => new PackScheduleDetailReturn { SummaryOfWork = p.SummaryOfWork, }).ExpandAll()) .ToAppendedList( Projector <PackSchedule> .To(p => new PackScheduleDetailReturn { PackagingProductKeyReturn = productKey.Invoke(p.PackagingProduct.Product), PackagingProductName = p.PackagingProduct.Product.Name, PackagingWeight = p.PackagingProduct.Weight, }), Projector <PackSchedule> .To(p => new PackScheduleDetailReturn { ProductionBatches = p.ProductionBatches.Select(b => productionBatches.Invoke(b)) }))); }
internal static Expression <Func <SampleOrderItem, SampleOrderItemReturn> > Select() { var key = SelectKey(); var lotKey = LotProjectors.SelectLotKey <Lot>(); var productKey = ProductProjectors.SelectProductKey(); var spec = SampleOrderItemSpecProjectors.Select(); var match = SampleOrderItemMatchProjectors.Select(); return(i => new SampleOrderItemReturn { CustomerProductName = i.CustomerProductName, Quantity = i.Quantity, Description = i.Description, CustomerSpec = new[] { i.Spec }.Where(s => s != null).Select(s => spec.Invoke(s)).FirstOrDefault(), LabResults = new[] { i.Match }.Where(m => m != null).Select(m => match.Invoke(m)).FirstOrDefault(), SampleOrderItemKeyReturn = key.Invoke(i), LotKeyReturn = new[] { i.Lot }.Where(l => l != null).Select(l => lotKey.Invoke(l)).FirstOrDefault(), ProductKeyReturn = new[] { i.Product }.Where(p => p != null).Select(p => productKey.Invoke(p)).FirstOrDefault(), ProductType = new[] { i.Product }.Where(p => p != null).Select(p => (ProductTypeEnum?)p.ProductType).FirstOrDefault() }); }
private static Expression <Func <ChileLotProduction, MillAndWetdownReturn> > SelectBase() { var lotKey = LotProjectors.SelectLotKey <ChileLotProduction>(); var productKey = ProductProjectors.SelectProductKey(); var productionLocationKey = LocationProjectors.SelectLocationKey(); return(m => new MillAndWetdownReturn { OutputChileLotKeyReturn = lotKey.Invoke(m), ChileProductKeyReturn = productKey.Invoke(m.ResultingChileLot.ChileProduct.Product), ProductionLineLocationKeyReturn = productionLocationKey.Invoke(m.Results.ProductionLineLocation), ShiftKey = m.Results.ShiftKey, ProductionLineDescription = m.Results.ProductionLineLocation.Description, ChileProductName = m.ResultingChileLot.ChileProduct.Product.Name, ProductionBegin = m.Results.ProductionBegin, ProductionEnd = m.Results.ProductionEnd, TotalProductionTimeMinutes = EntityFunctions.DiffMinutes(m.Results.ProductionBegin, m.Results.ProductionEnd) ?? 0, TotalWeightProduced = m.Results.ResultItems.Any() ? (int)m.Results.ResultItems.Sum(i => i.PackagingProduct.Weight * i.Quantity) : 0, TotalWeightPicked = m.PickedInventory.Items.Any() ? (int)m.PickedInventory.Items.Sum(i => i.PackagingProduct.Weight * i.Quantity) : 0 }); }