Example #1
0
 /// <summary>
 /// Adds the specified balance.
 /// </summary>
 /// <param name="balance">The balance.</param>
 internal void Add(IPR.Balance balance)
 {
     foreach (IPR.ValueKey _vkx in Enum.GetValues(typeof(IPR.ValueKey)))
     {
         base[_vkx] += balance.Base[_vkx];
     }
 }
Example #2
0
 internal IPR.Balance Update(Entities edc, NamedTraceLogger.TraceAction trace)
 {
     trace("Entering BalanceIPR.Update", 453, TraceSeverity.Verbose);
     if (this.IPRIndex == null)
     {
         throw new ArgumentNullException("IPRIndex", "IPRIndex for Balance IPR cannot be null");
     }
     IPR.Balance _balnce = new IPR.Balance(edc, this.IPRIndex, trace);
     DustCSNotStarted               = _balnce[IPR.ValueKey.DustCSNotStarted];
     DustCSStarted                  = _balnce[IPR.ValueKey.DustCSStarted];
     IPRBook                        = _balnce[IPR.ValueKey.IPRBook];
     OveruseCSNotStarted            = _balnce[IPR.ValueKey.OveruseCSNotStarted];
     OveruseCSStarted               = _balnce[IPR.ValueKey.OveruseCSStarted];
     PureTobaccoCSNotStarted        = _balnce[IPR.ValueKey.PureTobaccoCSNotStarted];
     PureTobaccoCSStarted           = _balnce[IPR.ValueKey.PureTobaccoCSStarted];
     SHMentholCSNotStarted          = _balnce[IPR.ValueKey.SHMentholCSNotStarted];
     SHMentholCSStarted             = _balnce[IPR.ValueKey.SHMentholCSStarted];
     SHWasteOveruseCSNotStarted     = _balnce[IPR.ValueKey.SHWasteOveruseCSNotStarted];
     TobaccoAvailable               = _balnce[IPR.ValueKey.TobaccoAvailable];
     TobaccoCSFinished              = _balnce[IPR.ValueKey.TobaccoCSFinished];
     TobaccoEnteredIntoIPR          = _balnce[IPR.ValueKey.TobaccoEnteredIntoIPR];
     TobaccoInFGCSNotStarted        = _balnce[IPR.ValueKey.TobaccoInFGCSNotStarted];
     TobaccoInFGCSStarted           = _balnce[IPR.ValueKey.TobaccoInFGCSStarted];
     TobaccoToBeUsedInTheProduction = _balnce[IPR.ValueKey.TobaccoToBeUsedInTheProduction];
     TobaccoUsedInTheProduction     = _balnce[IPR.ValueKey.TobaccoUsedInTheProduction];
     WasteCSNotStarted              = _balnce[IPR.ValueKey.WasteCSNotStarted];
     WasteCSStarted                 = _balnce[IPR.ValueKey.WasteCSStarted];
     TobaccoStarted                 = _balnce[IPR.ValueKey.TobaccoStarted];
     Balance                        = this.IPRIndex.TobaccoNotAllocated - _balnce[IPR.ValueKey.TobaccoToBeUsedInTheProduction];
     Title = String.Format("{0}/{1}", this.Batch, this.DocumentNo);
     return(_balnce);
 }
Example #3
0
 internal void Update(Entities edc, IGrouping <string, IPR> grouping, StockDictionary.BalanceStock balanceStock, List <BalanceIPR> iprCollection, NamedTraceLogger.TraceAction trace)
 {
     trace("Entering BalanceBatch.Update", 66, TraceSeverity.Verbose);
     if (grouping == null)
     {
         throw new ArgumentNullException("grouping", "grouping at BalanceBatch.Update is null.");
     }
     if (balanceStock == null)
     {
         throw new ArgumentNullException("balanceStock", "balanceStock at BalanceBatch.Update is null.");
     }
     try
     {
         Dictionary <string, IPR> _iprDictionary = grouping.ToDictionary(x => x.DocumentNo);
         List <string>            _processed     = new List <string>();
         BalanceTotals            _totals        = new BalanceTotals();
         trace("BalanceBatch.Update at BalanceIPR", 70, TraceSeverity.Verbose);
         foreach (BalanceIPR _balanceIPRx in this.BalanceIPR(edc))
         {
             if (_iprDictionary.ContainsKey(_balanceIPRx.DocumentNo))
             {
                 IPR.Balance _new = _balanceIPRx.Update(edc, trace);
                 _totals.Add(_new);
                 iprCollection.Add(_balanceIPRx);
             }
             else
             {
                 edc.BalanceIPR.DeleteOnSubmit(_balanceIPRx);
             }
             _processed.Add(_balanceIPRx.DocumentNo);
         }
         foreach (string _dcn in _processed)
         {
             _iprDictionary.Remove(_dcn);
         }
         trace("BalanceBatch.Update at BalanceIPR.Create", 55, TraceSeverity.Verbose);
         foreach (IPR _iprx in _iprDictionary.Values)
         {
             IPR.Balance _newBipr = Linq.BalanceIPR.Create(edc, _iprx, this, this.Balance2JSOXLibraryIndex, iprCollection, trace);
             _totals.Add(_newBipr);
         }
         trace("BalanceBatch.Update at update this.", 90, TraceSeverity.Verbose);
         this.DustCSNotStarted               = _totals[IPR.ValueKey.DustCSNotStarted];
         this.DustCSStarted                  = _totals[IPR.ValueKey.DustCSStarted];
         this.IPRBook                        = _totals[IPR.ValueKey.IPRBook];
         this.OveruseCSNotStarted            = _totals[IPR.ValueKey.OveruseCSNotStarted];
         this.OveruseCSStarted               = _totals[IPR.ValueKey.OveruseCSStarted];
         this.PureTobaccoCSNotStarted        = _totals[IPR.ValueKey.PureTobaccoCSNotStarted];
         this.PureTobaccoCSStarted           = _totals[IPR.ValueKey.PureTobaccoCSStarted];
         this.SHMentholCSNotStarted          = _totals[IPR.ValueKey.SHMentholCSNotStarted];
         this.SHMentholCSStarted             = _totals[IPR.ValueKey.SHMentholCSStarted];
         this.SHWasteOveruseCSNotStarted     = _totals[IPR.ValueKey.SHWasteOveruseCSNotStarted];
         this.TobaccoAvailable               = _totals[IPR.ValueKey.TobaccoAvailable];
         this.TobaccoCSFinished              = _totals[IPR.ValueKey.TobaccoCSFinished];
         this.TobaccoEnteredIntoIPR          = _totals[IPR.ValueKey.TobaccoEnteredIntoIPR];
         this.TobaccoInFGCSNotStarted        = _totals[IPR.ValueKey.TobaccoInFGCSNotStarted];
         this.TobaccoInFGCSStarted           = _totals[IPR.ValueKey.TobaccoInFGCSStarted];
         this.TobaccoToBeUsedInTheProduction = _totals[IPR.ValueKey.TobaccoToBeUsedInTheProduction];
         this.TobaccoUsedInTheProduction     = _totals[IPR.ValueKey.TobaccoUsedInTheProduction];
         this.WasteCSNotStarted              = _totals[IPR.ValueKey.WasteCSNotStarted];
         this.WasteCSStarted                 = _totals[IPR.ValueKey.WasteCSStarted];
         this.TobaccoStarted                 = _totals[IPR.ValueKey.TobaccoStarted];
         //
         balanceStock.CalculateBalance(_totals.Base[IPR.ValueKey.TobaccoInFGCSNotStarted], _totals.Base[IPR.ValueKey.TobaccoAvailable]);
         this.Balance = balanceStock[StockDictionary.StockValueKey.Balance];
         this.TobaccoInCigarettesProduction = balanceStock[StockDictionary.StockValueKey.TobaccoInCigarettesProduction];
         this.TobaccoInCigarettesWarehouse  = balanceStock[StockDictionary.StockValueKey.TobaccoInCigarettesWarehouse];
         this.TobaccoInCutfillerWarehouse   = balanceStock[StockDictionary.StockValueKey.TobaccoInCutfillerWarehouse];
         this.TobaccoInWarehouse            = balanceStock[StockDictionary.StockValueKey.TobaccoInWarehouse];
     }
     catch (Exception ex)
     {
         trace("Exception at BalanceBatch.Update: " + ex.Message, 128, TraceSeverity.High);
         throw new SharePoint.ApplicationError("BalanceBatch.Update", "Body", ex.Message, ex);
     }
     trace("Finished BalanceBatch.Update", 131, TraceSeverity.Verbose);
 }