private void AssignContentInfo(SummaryContentInfo contentInfo, bool newBatch) { if (newBatch) { FGQuantityAvailable = contentInfo.Product.FGQuantity; } else { double _diff = contentInfo.Product.FGQuantity.Value - FGQuantity.Value; double _available = FGQuantityAvailable.Value; if (_diff + _available < 0) { string _ptrn = "The previous batch {0} has quantity of finished good greater then the new one - it looks like wrong messages sequence. Available={1}, Diff={2}"; throw new InputDataValidationException("wrong status of the input batch", "BatchProcessing", String.Format(_ptrn, contentInfo.Product.Batch, _available, _diff), true); } FGQuantityAvailable = _diff + _available; } Archival = false; BatchStatus = contentInfo.BatchStatus; Batch0 = contentInfo.Product.Batch; SKU = contentInfo.Product.SKU; Title = String.Format("{0} SKU: {1}; Batch: {2}", contentInfo.Product.ProductType, SKU, Batch0); CalculatedOveruse = contentInfo.CalculatedOveruse; MaterialQuantity = contentInfo.TotalTobacco; FGQuantity = contentInfo.Product.FGQuantity; MaterialQuantityPrevious = 0; SKUIndex = contentInfo.SKULookup; ProductType = contentInfo.Product.ProductType; Dust = contentInfo[Linq.DisposalEnum.Dust]; SHMenthol = contentInfo[Linq.DisposalEnum.SHMenthol]; Waste = contentInfo[Linq.DisposalEnum.Waste]; Tobacco = contentInfo[Linq.DisposalEnum.TobaccoInCigaretess]; Overuse = contentInfo[Linq.DisposalEnum.OverusageInKg]; }
/// <summary> /// Batches the processing. /// </summary> /// <param name="edc">The <see cref="Entities" /> instance.</param> /// <param name="contentInfo">The content info.</param> /// <param name="parent">The parent.</param> /// <param name="newBatch">if set to <c>true</c> it is new batch.</param> /// <param name="trace">The trace action.</param> public void BatchProcessing(Entities edc, SummaryContentInfo contentInfo, BatchLib parent, bool newBatch, SharePoint.Logging.NamedTraceLogger.TraceAction trace) { trace("Entering Batch.BatchProcessing", 73, TraceSeverity.Verbose); BatchLibraryIndex = parent; Material.Ratios _mr = GetDependences(edc, contentInfo); contentInfo.Analyze(edc, this, _mr, newBatch, trace); AssignContentInfo(contentInfo, newBatch); }
private Material.Ratios GetDependences(Entities edc, SummaryContentInfo contentInfo) { Linq.ProductType _producttype = contentInfo.Product.ProductType.Value; //Dependences Dust DustIndex = Linq.Dust.GetLookup(_producttype, edc); BatchDustCooeficiency = DustIndex.DustRatio; DustCooeficiencyVersion = DustIndex.Version; SHMenthol SHMentholIndex = Linq.SHMenthol.GetLookup(_producttype, edc); BatchSHCooeficiency = SHMentholIndex.SHMentholRatio; SHCooeficiencyVersion = SHMentholIndex.Version; Waste WasteIndex = Linq.Waste.GetLookup(_producttype, edc); BatchWasteCooeficiency = WasteIndex.WasteRatio; WasteCooeficiencyVersion = WasteIndex.Version; CutfillerCoefficient _cc = CutfillerCoefficient.GetLookup(edc); this.CFTProductivityNormMax = _cc.CFTProductivityNormMax; this.CFTProductivityNormMin = _cc.CFTProductivityNormMin; this.CFTProductivityRateMax = _cc.CFTProductivityRateMax; this.CFTProductivityRateMin = _cc.CFTProductivityRateMin; this.CFTProductivityVersion = _cc.Version; Usage _usage = Usage.GetLookup(contentInfo.SKULookup.FormatIndex, edc); this.CTFUsageMax = _usage.CTFUsageMax; this.CTFUsageMin = _usage.CTFUsageMin; this.UsageMin = _usage.UsageMin; this.UsageMax = _usage.UsageMax; this.UsageVersion = _usage.Version; double _shmcf = 0; if ((contentInfo.SKULookup is SKUCigarette) && ((SKUCigarette)contentInfo.SKULookup).MentholMaterial.Value) { _shmcf = ((SKUCigarette)contentInfo.SKULookup).MentholMaterial.Value ? SHMentholIndex.SHMentholRatio.Value : 0; } return(new Material.Ratios { dustRatio = DustIndex.DustRatio.ValueOrException <double>("Batch", "Material.Ratios", "dustRatio"), shMentholRatio = _shmcf, wasteRatio = WasteIndex.WasteRatio.ValueOrException <double>("Batch", "Material.Ratios", "wasteRatio") }); }