Ejemplo n.º 1
0
        private async void loginButton_Click(object sender, EventArgs e)
        {
            var agent = this.sqlAgentsComboBox.SelectedValue as SqlAgentBase;

            if (agent == null)
            {
                MessageBox.Show("Agent type not specified.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (agent.IsFileBased && databaseTextBox.Text.IsNullOrWhiteSpace())
            {
                MessageBox.Show("Database file not specified.", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            try
            {
                ISqlDictionary dictionary = null;
                if (this.useSqlRepositoryCheckBox.Checked)
                {
                    dictionary = new SqlDictionary(this.sqlRepositoryFolderTextBox.Text, true);
                }
                _agent = (SqlAgentBase)Activator.CreateInstance(agent.GetType(),
                                                                this.connectionStringTextBox.Text, this.databaseTextBox.Text, dictionary, null);
                await _agent.TestConnectionAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            this.DialogResult = DialogResult.OK;
            this.Close();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new SqliteAgent instance.
 /// </summary>
 /// <param name="baseConnectionString">a connection string to use to connect to
 /// a database (should not include database parameter that is added by the
 /// SqlAgent implementation depending on the database chosen, should include password
 /// (if any), password replacement (if needed) should be handled by the user class)</param>
 /// <param name="databaseName">a name of the database to use (if any)</param>
 /// <param name="sqlDictionary">an implementation of SQL dictionary to use (if any)</param>
 /// <param name="logger">a logger to log errors and warnings (if any)</param>
 public SqliteAgent(string baseConnectionString, string databaseName, ISqlDictionary sqlDictionary, ILogger logger)
     : base(baseConnectionString, true, databaseName, sqlDictionary, logger)
 {
     if (databaseName.IsNullOrWhiteSpace())
     {
         throw new ArgumentNullException(nameof(databaseName));
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Initializes a new SqlAgent instance.
        /// </summary>
        /// <param name="baseConnectionString">a connection string to use to connect to
        /// a database (should not include database parameter that is added by the
        /// SqlAgent implementation depending on the database chosen, should include password
        /// (if any), password replacement (if needed) should be handled by the user class)</param>
        /// <param name="allowEmptyConnString">whether the SqlAgent implementation can handle
        /// empty connection string (e.g. when the database parameter is the only parameter)</param>
        /// <param name="databaseName">a name of the database to use (if any)</param>
        /// <param name="sqlDictionary">an implementation of SQL dictionary to use (if any)</param>
        protected SqlAgentBase(string baseConnectionString, bool allowEmptyConnString,
                               string databaseName, ISqlDictionary sqlDictionary, ILogger logger)
        {
            if (baseConnectionString.IsNullOrWhiteSpace() && !allowEmptyConnString)
            {
                throw new ArgumentNullException(nameof(baseConnectionString));
            }

            _sqlDictionary       = sqlDictionary;
            BaseConnectionString = baseConnectionString?.Trim() ?? string.Empty;
            CurrentDatabase      = databaseName ?? string.Empty;
            _Logger = logger;
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Creates an SqlAgent clone.
        /// </summary>
        /// <param name="agentToClone">an SqlAgent to clone</param>
        protected SqlAgentBase(SqlAgentBase agentToClone)
        {
            if (agentToClone.IsNull())
            {
                throw new ArgumentNullException(nameof(agentToClone));
            }

            BaseConnectionString      = agentToClone.BaseConnectionString;
            CurrentDatabase           = agentToClone.CurrentDatabase;
            BooleanStoredAsTinyInt    = agentToClone.BooleanStoredAsTinyInt;
            AllSchemaNamesLowerCased  = agentToClone.AllSchemaNamesLowerCased;
            GuidStoredAsBlob          = agentToClone.GuidStoredAsBlob;
            QueryTimeOut              = agentToClone.QueryTimeOut;
            UseTransactionPerInstance = agentToClone.UseTransactionPerInstance;
            _sqlDictionary            = agentToClone._sqlDictionary;
            _Logger = agentToClone._Logger;
        }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new MySqlAgent instance.
 /// </summary>
 /// <param name="baseConnectionString">a connection string to use to connect to
 /// a database (should not include database parameter that is added by the
 /// SqlAgent implementation depending on the database chosen, should include password
 /// (if any), password replacement (if needed) should be handled by the user class)</param>
 /// <param name="databaseName">a name of the database to use (if any)</param>
 /// <param name="sqlDictionary">an implementation of SQL dictionary to use (if any)</param>
 /// <param name="logger">a logger to log errors and warnings (if any)</param>
 public MySqlAgent(string baseConnectionString, string databaseName, ISqlDictionary sqlDictionary, ILogger logger)
     : base(baseConnectionString, false, databaseName, sqlDictionary, logger)
 {
 }