Ejemplo n.º 1
0
 public static Task StoreReceived(this SqlTransaction tx, Guid id, string messageType)
 {
     return(tx.CreateCommand("insert into receiver.received_track (id, message_type) values (@id, @type)")
            .With("id", id)
            .With("type", messageType)
            .ExecuteNonQueryAsync());
 }
Ejemplo n.º 2
0
        public void Handle(TraceMessage message, SqlTransaction tx)
        {
            var traceDoc = new TraceDoc {
                Name = message.Name
            };

            tx.CreateCommand("insert into receiver.trace_doc (id, name) values (@id, @name)")
            .With("id", traceDoc.Id)
            .With("name", traceDoc.Name)
            .ExecuteNonQuery();
        }
Ejemplo n.º 3
0
 public static async Task Handle(
     ItemCreated created,
     SqlTransaction tx // the current transaction
     )
 {
     // Using some extension method helpers inside of Jasper here
     await tx.CreateCommand("insert into receiver.item_created (id, name) values (@id, @name)")
     .With("id", created.Id)
     .With("name", created.Name)
     .ExecuteNonQueryAsync();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Create a <see cref="SqlCommand"/> using the provided parameters.
        /// </summary>
        /// <param name="sqlCon">The <see cref="SqlTransaction"/> to use.</param>
        /// <param name="commandText">The sql command text to use.</param>
        /// <param name="commandType">The type of command.</param>
        /// <returns></returns>
        public static SqlCommand CreateCommand(this SqlTransaction sqlTxn, string commandText, CommandType commandType)
        {
            if (sqlTxn == null)
            {
                throw new ArgumentNullException(nameof(sqlTxn));
            }
            if (string.IsNullOrWhiteSpace(commandText))
            {
                throw new ArgumentNullException(nameof(commandText));
            }

            return(sqlTxn.CreateCommand(commandText, commandType, 3 * 60));
        }
        public static async Task Handle(
            ItemCreated created,
            SqlTransaction tx, // the current transaction
            Jasper.Messaging.Tracking.MessageTracker tracker,
            Envelope envelope)
        {
            // Using some extension method helpers inside of Jasper here
            await tx.CreateCommand("insert into receiver.item_created (id, name) values (@id, @name)")
            .With("id", created.Id)
            .With("name", created.Name)
            .ExecuteNonQueryAsync();

            tracker.Record(created, envelope);
        }
 /// <summary>
 /// Shortcut for creating a stored procedure SqlCommand from any SqlTransaction.
 /// </summary>
 /// <param name="transaction">The transaction to create a command from.</param>
 /// <param name="procedureName">The command text or stored procedure name to use.</param>
 /// <param name="secondsTimeout">The number of seconds to wait before the command times out.</param>
 /// <returns>The created SqlCommand.</returns>
 public static SqlCommand CreateStoredProcedureCommand(this SqlTransaction transaction,
                                                       string procedureName, int secondsTimeout = CommandTimeout.DEFAULT_SECONDS)
 => transaction.CreateCommand(CommandType.StoredProcedure, procedureName, secondsTimeout);