Ejemplo n.º 1
0
 internal SQLiteServerTransaction(SQLiteServerConnection connection)
 {
     if (null == connection)
     {
         throw new ArgumentNullException(nameof(connection));
     }
     _connection = connection;
 }
Ejemplo n.º 2
0
        public SQLiteServerCommand(string commandText, SQLiteServerConnection connection)
        {
            _connection = connection;
            CommandText = commandText;

            // set the connection timeout
            var builder = new SQLiteServerConnectionStringBuilder(connection?.ConnectionString);

            CommandTimeout = builder.DefaultTimeout;
        }
Ejemplo n.º 3
0
 internal SQLiteServerDataReader(ISQLiteServerDataReaderWorker worker,
                                 SQLiteServerConnection connection,
                                 CommandBehavior commandBehavior)
 {
     if (null == worker)
     {
         throw new ArgumentNullException(nameof(worker), "The worker cannot be null");
     }
     _worker          = worker;
     _connection      = connection;
     _commandBehavior = commandBehavior;
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Backup the database
        /// </summary>
        /// <param name="destination"></param>
        /// <param name="destinationName"></param>
        /// <param name="sourceName"></param>
        /// <param name="pages"></param>
        /// <param name="callback"></param>
        /// <param name="retryMilliseconds"></param>
        public void BackupDatabase(
            SQLiteServerConnection destination,
            string destinationName,
            string sourceName,
            int pages,
            SQLiteServerBackupCallback callback,
            int retryMilliseconds)
        {
            //  check not disposed
            ThrowIfAny();

            // check destination is valid.
            if (destination == null)
            {
                throw new ArgumentNullException(nameof(destination));
            }
            if (destination.State != ConnectionState.Open)
            {
                throw new InvalidOperationException("Destination database is not open.");
            }

            // validate the names
            if (destinationName == null)
            {
                throw new ArgumentNullException(nameof(destinationName));
            }
            if (sourceName == null)
            {
                throw new ArgumentNullException(nameof(sourceName));
            }

            // convert the callback to sqlite callback
            // but only if the caller gave us a callback.
            var callback2 = callback == null ?
                            null
        :
                            new SQLiteBackupCallback(
                (source2, sourceName2, destination2, destinationName2, pages2, remainingPages, totalPages, retry)
                => callback(this, sourceName2, destination, destinationName2, pages2, remainingPages, totalPages, retry));

            try
            {
                // get the sqlite connections.
                Task.Run(async() =>
                {
                    var sourceConnection      = await _worker.LockConnectionAsync().ConfigureAwait(false);
                    var destinationConnection = await destination._worker.LockConnectionAsync().ConfigureAwait(false);

                    // Call the SQlite connection.
                    sourceConnection.BackupDatabase(destinationConnection, destinationName, sourceName, pages, callback2,
                                                    retryMilliseconds);
                }).Wait();
            }
            finally
            {
                Task.Run(async() =>
                {
                    await _worker.UnLockConnectionAsync().ConfigureAwait(false);
                    await destination._worker.UnLockConnectionAsync().ConfigureAwait(false);
                }).Wait();
            }
        }
Ejemplo n.º 5
0
 public SQLiteServerCommand(SQLiteServerConnection connection) : this(null, connection)
 {
 }