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); } }
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); } }
public virtual ProxyBuilder UseSession(bool distributed = false, IErrorHandling errorHandling = null) { _sessionMiddleware = new SessionMiddleware(_configuration.SessionHandler, errorHandling ?? _configuration.ErrorHandling) { UseDistributedSession = distributed }; return(this); }
public virtual ProxyBuilder Recoverable(int retries, TimeSpan retryDelay, IErrorHandling errorHandling = null) { _retryRequest = new RetryRequestMiddleware(errorHandling ?? _configuration.ErrorHandling) { Retries = retries, RetryDelay = retryDelay }; return(this); }
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()); }
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)); }
public SessionMiddleware(IClientSessionHandler sessionHandler, IErrorHandling errorHandling) { ClientSessionHandler = sessionHandler; ErrorHandling = errorHandling; Recoverable = true; }
public Customer(IErrorHandling errorHandling) { _errorHandling = errorHandling; }
public RetryRequestMiddleware(IErrorHandling errorHandling) { ErrorHandling = errorHandling; }
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(); }