protected bool CheckConnection(AbstractConnection connection) {
            var result = false;
            try {
                using (var cn = connection.GetConnection()) {

                    if (connection.Type.Equals(ProviderType.SqlServer)) {
                        cn.ConnectionString = connection.GetConnectionString().TrimEnd(";".ToCharArray()) + string.Format(";Connection Timeout={0};", _timeOut);
                    } else {
                        cn.ConnectionString = connection.GetConnectionString();
                    }

                    try {
                        cn.Open();
                        result = cn.State == ConnectionState.Open;
                        if (result) {
                            _logger.Debug("{0} connection is ready.", connection.Name);
                        } else {
                            _logger.Warn("{0} connection is not responding.", connection.Name);
                        }
                    } catch (Exception e) {
                        _logger.Error("{0} connection caused error message: {1}", connection.Name, e.Message);
                    }
                }
            } catch (Exception ex) {
                throw new TransformalizeException(_logger, "{0} connection type '{1}' is unavailable.  Make sure the assembly (*.dll) is in the same folder as your executable. Error Message: {2}", connection.Name, connection.Type, ex.Message);
            }

            CachedResults[connection.Name] = result;
            return result;
        }
        public void Drop(AbstractConnection connection, Entity entity) {
            if (!EntityExists.Exists(connection, entity))
                return;

            var sql = string.Format(FORMAT, connection.Enclose(entity.OutputName()));

            using (var cn = connection.GetConnection()) {
                cn.Open();
                cn.Execute(sql);
                connection.Logger.EntityDebug(entity.Name, "Dropped Output {0}", entity.OutputName());
            }
        }
Exemplo n.º 3
0
        public void Drop(AbstractConnection connection, Entity entity)
        {
            if (!EntityExists.Exists(connection, entity))
            {
                return;
            }

            var sql = string.Format(FORMAT, connection.Enclose(entity.OutputName()));

            using (var cn = connection.GetConnection()) {
                cn.Open();
                cn.Execute(sql);
                connection.Logger.EntityDebug(entity.Name, "Dropped Output {0}", entity.OutputName());
            }
        }
        public IScriptReponse Execute(AbstractConnection connection, string script, int timeOut) {
            var response = new ScriptResponse();

            using (var cn = connection.GetConnection()) {
                try {
                    cn.Open();
                    var cmd = cn.CreateCommand();
                    cmd.CommandTimeout = timeOut;
                    cmd.CommandText = script;
                    cmd.CommandType = CommandType.Text;
                    response.RowsAffected = cmd.ExecuteNonQuery();
                    response.Success = true;
                } catch (Exception e) {
                    response.Messages.Add(e.Message);
                    if (e.InnerException != null) {
                        response.Messages.Add(e.InnerException.Message);
                    }
                }
            }
            return response;
        }
Exemplo n.º 5
0
        public IScriptReponse Execute(AbstractConnection connection, string script, int timeOut)
        {
            var response = new ScriptResponse();

            using (var cn = connection.GetConnection()) {
                try {
                    cn.Open();
                    var cmd = cn.CreateCommand();
                    cmd.CommandTimeout    = timeOut;
                    cmd.CommandText       = script;
                    cmd.CommandType       = CommandType.Text;
                    response.RowsAffected = cmd.ExecuteNonQuery();
                    response.Success      = true;
                } catch (Exception e) {
                    response.Messages.Add(e.Message);
                    if (e.InnerException != null)
                    {
                        response.Messages.Add(e.InnerException.Message);
                    }
                }
            }
            return(response);
        }
        protected bool CheckConnection(AbstractConnection connection)
        {
            var result = false;

            try {
                using (var cn = connection.GetConnection()) {
                    if (connection.Type.Equals(ProviderType.SqlServer))
                    {
                        cn.ConnectionString = connection.GetConnectionString().TrimEnd(";".ToCharArray()) + string.Format(";Connection Timeout={0};", _timeOut);
                    }
                    else
                    {
                        cn.ConnectionString = connection.GetConnectionString();
                    }

                    try {
                        cn.Open();
                        result = cn.State == ConnectionState.Open;
                        if (result)
                        {
                            _logger.Debug("{0} connection is ready.", connection.Name);
                        }
                        else
                        {
                            _logger.Warn("{0} connection is not responding.", connection.Name);
                        }
                    } catch (Exception e) {
                        _logger.Error("{0} connection caused error message: {1}", connection.Name, e.Message);
                    }
                }
            } catch (Exception ex) {
                throw new TransformalizeException(_logger, "{0} connection type '{1}' is unavailable.  Make sure the assembly (*.dll) is in the same folder as your executable. Error Message: {2}", connection.Name, connection.Type, ex.Message);
            }

            CachedResults[connection.Name] = result;
            return(result);
        }
Exemplo n.º 7
0
 public RunOperation(string inKey, AbstractConnection connection, int timeOut)
     : base(inKey, string.Empty) {
     _timeOut = timeOut;
     _connection = connection.GetConnection();
     _logger = connection.Logger;
 }