internal void Analyze(Entities edc, Batch parent, Material.Ratios materialRatios, bool newBatch, NamedTraceLogger.TraceAction trace) { trace("Entering SummaryContentInfo.Analyze", 120, TraceSeverity.Verbose); this.ReplaceMaterials(edc, parent, materialRatios, newBatch, trace); List <Material> _tobacco = this.Values.Where <Material>(x => x.ProductType.Value == ProductType.IPRTobacco || x.ProductType.Value == ProductType.Tobacco).ToList <Material>(); List <Material> _IPTobacco = _tobacco.Where <Material>(x => x.ProductType.Value == ProductType.IPRTobacco).ToList <Material>(); if (this.Product.ProductType.Value == ProductType.Cigarette && this.BatchStatus == Linq.BatchStatus.Final) { foreach (Material _mx in _IPTobacco) { _mx.AdjustTobaccoQuantity(ref myTotalTobacco, trace); } } this.GetOverusage(parent.UsageMax.Value, parent.UsageMin.Value); if (this.BatchStatus == Linq.BatchStatus.Progress) { return; } foreach (Material _mx in _IPTobacco) { _mx.CalculateOveruse(edc, materialRatios, CalculatedOveruse); } this.AdjustOveruse(materialRatios, _IPTobacco); foreach (Material _mx in _tobacco) { _mx.CalculateCompensationComponents(materialRatios); AccumulatedDisposalsAnalysis.Accumutate(_mx); } foreach (InvoiceContent _ix in parent.InvoiceContent(edc, newBatch)) { _ix.UpdateExportedDisposals(edc, trace); } this.UpdateNotStartedDisposals(edc, trace); }
private void ReplaceMaterials(Entities entities, Batch parent, Material.Ratios materialRatios, bool newBatch, NamedTraceLogger.TraceAction trace) { trace("Entering SummaryContentInfo.ReplaceMaterials", 159, TraceSeverity.Verbose); if (Product == null) { trace("IPRDataConsistencyException at Entering SummaryContentInfo.ReplaceMaterials: Summary content info has unassigned Product property", 162, TraceSeverity.High); throw new IPRDataConsistencyException("SummaryContentInfo.ReplaceMaterials", "Summary content info has unassigned Product property", null, "Wrong batch - product is unrecognized."); } try { List <Material> _newMaterialList = new List <Material>(); List <Material> _oldMaterialList = new List <Material>(); List <Material> _copyThis = new List <Material>(); _copyThis.AddRange(this.Values); Dictionary <string, Material> _parentsMaterials = parent.Material(entities, newBatch).ToDictionary <Material, string>(x => x.GetKey()); foreach (Material _materialX in _copyThis) { _materialX.ReplaceByExistingOne(_oldMaterialList, _newMaterialList, _parentsMaterials, parent); } if (_newMaterialList.Count > 0) { entities.Material.InsertAllOnSubmit(_newMaterialList); } foreach (Material _omx in _oldMaterialList) { this.Remove(_omx.GetKey()); this.Add(_omx.GetKey(), _omx); } } catch (Exception _ex) { trace("IPRDataConsistencyException at Entering SummaryContentInfo.ReplaceMaterials: " + _ex.Message, 184, TraceSeverity.High); throw new IPRDataConsistencyException("SummaryContentInfo.ReplaceMaterials", _ex.Message, _ex, "Disposal processing error"); } }
/// <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 void AdjustOveruse(Material.Ratios materialRatios, List <Material> _IPRTobacco) { if (CalculatedOveruse <= 0) { return; } decimal _2remove = 0; List <Material> _2Add = new List <Material>(); foreach (Material _mx in _IPRTobacco) { _2remove += _mx.RemoveOveruseIfPossible(_2Add, materialRatios); } if (_2Add.Count == 0) { _2Add.Add(_IPRTobacco.Max <Material, Material>(x => x)); } decimal _AddingCff = _2remove / _2Add.Sum <Material>(x => x.TobaccoQuantityDec); foreach (Material _mx in _2Add) { _mx.IncreaseOveruse(_AddingCff, materialRatios); } }