Beispiel #1
0
 public CalculationExceptionPersister(ICalculatorEngineFactory calculatorEngineFactory, IEventPublisher publisher)
 {
     this.calculatorEngineFactory = calculatorEngineFactory;
     this.publisher = publisher;
     Task.Factory.StartNew(() =>
     {
         CalculationExceptionReady data;
         while (!calcEnded)
         {
             while (queue.TryDequeue(out data))
             {
                 var engine = calculatorEngineFactory.Create();
                 try
                 {
                     engine.AddCalculationException(data.CalculationId, data.EmployeeId, data.CalculationPathNo, data.Messages);
                 }
                 finally
                 {
                     calculatorEngineFactory.Release(engine);
                 }
             }
             trigger.WaitOne();
         }
         var x = 1;
     }
                           );
 }
 public JobIndexPointCalculator(IEventPublisher publisher,
                                ICalculatorEngineFactory calculatorEngineFactory, IEmployeeServiceFactory employeeServiceFactory)
 {
     this.calculatorEngineFactory = calculatorEngineFactory;
     this.publisher = publisher;
     this.employeeServiceFactory = employeeServiceFactory;
 }
Beispiel #3
0
        public JobIndexPointPersister(ICalculatorEngineFactory calculatorEngineFactory, IEventPublisher publisher)
        {
            this.calculatorEngineFactory = calculatorEngineFactory;
            this.publisher = publisher;
            Task.Factory.StartNew(() =>
            {
                JobIndexPointsReady data;
                while (!calcEnded)
                {
                    while (queue.TryDequeue(out data))
                    {
                        var engine = calculatorEngineFactory.Create();
                        try
                        {
                            if (data.PointsHolder.EmployeePointsForAdd != null)
                            {
                                engine.AddEmployeePoints(data.PointsHolder.EmployeePointsForAdd);
                            }
                            if (data.PointsHolder.EmployeePointsForUpdate != null)
                            {
                                engine.UpdateEmployeePoints(data.PointsHolder.EmployeePointsForUpdate);
                            }
                        }
                        catch (Exception ex)
                        {
                            hasExceptionInPersist = true;
                            publisher.Publish(new CalculationExceptionReady(data.CalculationId, data.EmployeeId, data.CalculationPathNo, ex));
                        }
                        finally
                        {
                            calculatorEngineFactory.Release(engine);
                        }
                    }
                    if (pathCompleted)
                    {
                        publisher.Publish(new PathPersisteCompleted(hasExceptionInPersist));
                        pathCompleted = false;
                    }

                    trigger.WaitOne();
                }
            }
                                  );
        }