public AwardCalculator(IAwardCalculationQueueRepository awardCalcRepository, IEventDefinitionService eventDefinitionService, IUserRepository userRepository, IErrorLog errorLog, IAwardDefinitionService awardDefinitionService, IUserAwardService userAwardService, IPointLedgerRepository pointLedgerRepository) { _awardCalcRepository = awardCalcRepository; _eventDefinitionService = eventDefinitionService; _userRepository = userRepository; _errorLog = errorLog; _awardDefinitionService = awardDefinitionService; _userAwardService = userAwardService; _pointLedgerRepository = pointLedgerRepository; }
public async Task ProcessCalculation(IAwardCalculator calculator, IAwardCalculationQueueRepository awardCalculationQueueRepository, IErrorLog errorLog) { try { var nextItem = await awardCalculationQueueRepository.Dequeue(); if (string.IsNullOrEmpty(nextItem.Key)) { return; } await calculator.ProcessCalculation(nextItem.Key, nextItem.Value); } catch (Exception exc) { errorLog.Log(exc, ErrorSeverity.Error); } }
public void ProcessCalculation(IAwardCalculator calculator, IAwardCalculationQueueRepository awardCalculationQueueRepository, IErrorLog errorLog) { if (!Monitor.TryEnter(_syncRoot)) { return; } try { var nextItem = awardCalculationQueueRepository.Dequeue(); if (string.IsNullOrEmpty(nextItem.Key)) { return; } calculator.ProcessCalculation(nextItem.Key, nextItem.Value); } catch (Exception exc) { errorLog.Log(exc, ErrorSeverity.Error); } finally { Monitor.Exit(_syncRoot); } }