public bool ServiceStatus()
        {
            _logger.Info("Запрос статуса службы отправки кассовых чеков");
            try
            {
                using (var uow = UnitOfWorkFactory.CreateWithoutRoot())
                {
                    var ordersAndReceiptNodes = _orderRepository
                                                .GetOrdersForCashReceiptServiceToSend(uow, _orderParametersProvider, DateTime.Today.AddDays(-3)).ToList();

                    var receiptsToSend = ordersAndReceiptNodes.Count(r => r.ReceiptId == null || r.WasSent.HasValue && !r.WasSent.Value);
                    _logger.Info($"Количество чеков на отправку: {receiptsToSend}");

                    var activeUoWCount = UowWatcher.GetActiveUoWCount();
                    _logger.Info($"Количество активных UoW: {activeUoWCount}");

                    return(receiptsToSend <= _salesReceiptsServiceSettings.MaxUnsendedCashReceiptsForWorkingService &&
                           activeUoWCount <= _salesReceiptsServiceSettings.MaxUoWAllowed);
                }
            }
            catch (Exception ex)
            {
                _logger.Error(ex, "Ошибка при проверке работоспособности службы отправки кассовых чеков");
                return(false);
            }
        }
        public bool ServiceStatus()
        {
            int activeUoWCount = UowWatcher.GetActiveUoWCount();

            if (activeUoWCount > parameters.MaxUoWAllowed)
            {
                return(false);
            }
            return(true);
        }
예제 #3
0
        protected virtual void DisposeUoW()
        {
            if (transaction != null)
            {
                if (!transaction.WasCommitted && !transaction.WasRolledBack &&
                    transaction.IsActive && session.Connection.State == System.Data.ConnectionState.Open)
                {
                    transaction.Rollback();
                }

                transaction.Dispose();
                transaction = null;
            }
            Session.Dispose();
            UowWatcher.UnregisterUow(this);
        }