示例#1
0
        public async static Task <object> ExecuteScalarCommand(DbCommand <T> command)
        {
            IConnector     connector    = ConnectorFactory.CreateConnector();
            IErrorHandling errorHandler = ErrorHandlerFactory.CreateErrorHandler();

            object          scalarResult = null;
            MySqlConnection connection   = connector.CreateConnection();

            try
            {
                await connector.OpenConnection(connection);

                scalarResult = await CommandExecutor <T> .TryExecutingScalarRead(connection, command);

                return(scalarResult);
            }

            catch (MySqlException exception)
            {
                errorHandler.HandleException(exception);
                return(scalarResult);
            }
            finally
            {
                await connector.CloseConnection(connection);
            }
        }
示例#2
0
        public async static Task <List <T> > ExecuteSelectCommand(DbCommand <T> command, T entity = default(T))
        {
            IConnector     connector    = ConnectorFactory.CreateConnector();
            IErrorHandling errorHandler = ErrorHandlerFactory.CreateErrorHandler();

            List <T> clinics = new List <T>();

            MySqlConnection connection = connector.CreateConnection();

            try
            {
                await connector.OpenConnection(connection);

                var reader = await CommandExecutor <T> .TryExecutingSelectQueryDataReader(connection, command, entity);

                while (await reader.ReadAsync())
                {
                    clinics.Add(ReadOneObject(reader));
                }
                return(clinics);
            }

            catch (MySqlException exception)
            {
                errorHandler.HandleException(exception);
                return(clinics);
            }
            finally
            {
                await connector.CloseConnection(connection);
            }
        }
示例#3
0
 public virtual ProxyBuilder UseSession(bool distributed = false, IErrorHandling errorHandling = null)
 {
     _sessionMiddleware = new SessionMiddleware(_configuration.SessionHandler, errorHandling ?? _configuration.ErrorHandling)
     {
         UseDistributedSession = distributed
     };
     return(this);
 }
示例#4
0
        public virtual ProxyBuilder Recoverable(int retries, TimeSpan retryDelay, IErrorHandling errorHandling = null)
        {
            _retryRequest = new RetryRequestMiddleware(errorHandling ?? _configuration.ErrorHandling)
            {
                Retries    = retries,
                RetryDelay = retryDelay
            };

            return(this);
        }
示例#5
0
        protected IClientPipeline CreatePipeline(int recoveries = 0, IErrorHandling errorHandling = null)
        {
            var builder = ClientConfiguration.ProxyBuilder().Url(ServerUrl).UseSession(errorHandling: errorHandling);

            if (recoveries > 0)
            {
                builder.Recoverable(recoveries, TimeSpan.FromMilliseconds(10), errorHandling);
            }

            return(builder.BuildPipeline());
        }
示例#6
0
        public async static Task <DbStatus> ExecuteCRUDCommand(DbCommand <T> command, T entity)
        {
            IConnector     connector    = ConnectorFactory.CreateConnector();
            IErrorHandling errorHandler = ErrorHandlerFactory.CreateErrorHandler();

            MySqlConnection connection = connector.CreateConnection();

            try
            {
                await connector.OpenConnection(connection);

                return(await CommandExecutor <T> .TryExecutingCRUDQuery(connection, command, entity));
            }
            catch (MySqlException exception)
            {
                return(errorHandler.HandleException(exception));
            }
            finally
            {
                await connector.CloseConnection(connection);
            }
        }
 public ErrorHandlingMiddleware(IErrorHandling errorHandling)
 {
     _errorHandling = errorHandling ?? throw new ArgumentNullException(nameof(errorHandling));
 }
示例#8
0
 public SessionMiddleware(IClientSessionHandler sessionHandler, IErrorHandling errorHandling)
 {
     ClientSessionHandler = sessionHandler;
     ErrorHandling = errorHandling;
     Recoverable = true;
 }
示例#9
0
 public Customer(IErrorHandling errorHandling)
 {
     _errorHandling = errorHandling;
 }
示例#10
0
 public RetryRequestMiddleware(IErrorHandling errorHandling)
 {
     ErrorHandling = errorHandling;
 }
 public RetryRequestMiddleware(IErrorHandling errorHandling)
 {
     ErrorHandling = errorHandling;
 }
示例#12
0
        protected IPipeline<ClientActionContext> CreatePipeline(int recoveries = 0, IErrorHandling errorHandling = null)
        {
            var builder = ClientConfiguration.ProxyBuilder().Url(ServerUrl).UseSession(errorHandling: errorHandling);
            if (recoveries > 0)
            {
                builder.Recoverable(recoveries, TimeSpan.FromMilliseconds(10), errorHandling);
            }

            return builder.BuildPipeline();
        }
示例#13
0
 public SessionMiddleware(IClientSessionHandler sessionHandler, IErrorHandling errorHandling)
 {
     ClientSessionHandler = sessionHandler;
     ErrorHandling        = errorHandling;
     Recoverable          = true;
 }