示例#1
0
        private async Task DispatchEvents(IReadOnlyList <INotification> events)
        {
            using (_connection = _sqlRepository.CreateConnection())
            {
                _connection.Open();

                using (_transaction = _connection.BeginTransaction(IsolationLevel.ReadCommitted))
                {
                    try
                    {
                        foreach (var @event in events)
                        {
                            switch (@event)
                            {
                            case ServiceMethodAddedEvent serviceMethodAdded:
                                await AddServiceMethod(serviceMethodAdded).ConfigureAwait(false);

                                break;
                            }
                        }

                        _transaction.Commit();
                    }
                    catch (Exception e)
                    {
                        _transaction.Rollback();

                        _logger.Error(e);

                        throw;
                    }
                }
            }
        }