Beispiel #1
0
        /// <summary>
        /// This method does not need custom TransactionArgs parameter.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="args"></param>
        public void SomeMethod(Library.TransactionWrapper sender, Library.TransactionArgs args)
        {
            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.Transaction = args.Transaction as System.Data.SqlClient.SqlTransaction;
            sqlCommand.Connection  = args.Connection as System.Data.SqlClient.SqlConnection;

            sqlCommand.CommandText = "";             /* Some suitable text here */

            sqlCommand.ExecuteNonQuery();
        }
Beispiel #2
0
        private ILog log = null;         // Initialise this somewhere...

        /// <summary>
        ///
        /// </summary>
        /// <param name="dataSet"></param>
        public void UpdateCustomDetails(CustomDataSet dataSet)
        {
            IDbConnection connection = new System.Data.SqlClient.SqlConnection(/* Connection string goes here*/);

            Library.TransactionWrapper transactionWrapper = new Library.TransactionWrapper(connection);

            // Hook the data onto the operation parameters
            CustomDataUpdate             customDataUpdate = new CustomDataUpdate(this.log);
            CustomTransactionedOperation operation        = new CustomTransactionedOperation(dataSet);

            operation.Execute += new Library.TransactionedOperationDelegate(customDataUpdate.UpdateData);

            transactionWrapper.MakeAtomic(operation);
        }
Beispiel #3
0
        public static void SelfContainedUpdateData(Library.TransactionWrapper sender, Library.TransactionArgs args)
        {
            // TODO: Paramter checks

            AggregateTransactionedOperation operation = args.Operation as AggregateTransactionedOperation;

            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.Transaction = args.Transaction as System.Data.SqlClient.SqlTransaction;
            sqlCommand.Connection  = args.Connection as System.Data.SqlClient.SqlConnection;

            sqlCommand.CommandText = "";             /* Some suitable text here */

            sqlCommand.ExecuteNonQuery();
        }
Beispiel #4
0
        public override void UpdateData(Library.TransactionWrapper sender, Library.TransactionArgs args)
        {
            CustomTransactionedOperation operation = args.Operation as CustomTransactionedOperation;

            SqlCommand sqlCommand = new SqlCommand();

            sqlCommand.Transaction = args.Transaction as System.Data.SqlClient.SqlTransaction;
            sqlCommand.Connection  = args.Connection as System.Data.SqlClient.SqlConnection;

            sqlCommand.CommandText = operation.Example; /* Some suitable text here */

            sqlCommand.ExecuteNonQuery();               // TODO: note the number of rows affected and publish via an event

            base.UpdateData(sender, args);
        }
Beispiel #5
0
        /// <summary>
        /// Performs multiple updates in a single transaction, with disparate (but presumably related) data.
        /// </summary>
        /// <param name="dataSet1">first data set</param>
        /// <param name="dataSet2">second data set</param>
        public void UpdateMultipleDetails(CustomDataSet dataSet1, SpecialDataSet dataSet2)
        {
            // Prepare the connection
            IDbConnection connection = new System.Data.SqlClient.SqlConnection(/* Connection string goes here*/);

            Library.TransactionWrapper transactionWrapper = new Library.TransactionWrapper(connection);

            // Hook data for first operation
            CustomDataUpdate             customDataUpdate = new CustomDataUpdate(this.log);
            CustomTransactionedOperation operation1       = new CustomTransactionedOperation(dataSet1);

            operation1.Execute += new Library.TransactionedOperationDelegate(customDataUpdate.UpdateData);

            // Hook data for second operation
            AggregateTransactionedOperation operation2 = new AggregateTransactionedOperation(dataSet2);

            operation2.Execute += new Library.TransactionedOperationDelegate(AggregateTransactionedOperation.SelfContainedUpdateData);

            // Collect together the operations and make them atomic
            Library.TransactionedOperation[] operations = new Library.TransactionedOperation[] { operation1, operation2 };
            transactionWrapper.MakeAtomic(operations);
        }
Beispiel #6
0
 public virtual void UpdateData(Library.TransactionWrapper sender, Library.TransactionArgs args)
 {
     log.Write(DateTime.Now, sender.Connection, args);
 }
        /// <summary>
        /// Performs multiple updates in a single transaction, with disparate (but presumably related) data.
        /// </summary>
        /// <param name="dataSet1">first data set</param>
        /// <param name="dataSet2">second data set</param>
        public void UpdateMultipleDetails(CustomDataSet dataSet1, SpecialDataSet dataSet2)
        {
            // Prepare the connection
            IDbConnection connection = new System.Data.SqlClient.SqlConnection( /* Connection string goes here*/ );
            Library.TransactionWrapper transactionWrapper = new Library.TransactionWrapper(connection);

            // Hook data for first operation
            CustomDataUpdate customDataUpdate = new CustomDataUpdate(this.log);
            CustomTransactionedOperation operation1 = new CustomTransactionedOperation(dataSet1);
            operation1.Execute += new Library.TransactionedOperationDelegate(customDataUpdate.UpdateData);

            // Hook data for second operation
            AggregateTransactionedOperation operation2 = new AggregateTransactionedOperation(dataSet2);
            operation2.Execute += new Library.TransactionedOperationDelegate(AggregateTransactionedOperation.SelfContainedUpdateData);

            // Collect together the operations and make them atomic
            Library.TransactionedOperation[] operations = new Library.TransactionedOperation[] {operation1, operation2};
            transactionWrapper.MakeAtomic(operations);
        }
        private ILog log = null; // Initialise this somewhere...

        #endregion Fields

        #region Methods

        /// <summary>
        /// 
        /// </summary>
        /// <param name="dataSet"></param>
        public void UpdateCustomDetails(CustomDataSet dataSet)
        {
            IDbConnection connection = new System.Data.SqlClient.SqlConnection( /* Connection string goes here*/ );
            Library.TransactionWrapper transactionWrapper = new Library.TransactionWrapper(connection);

            // Hook the data onto the operation parameters
            CustomDataUpdate customDataUpdate = new CustomDataUpdate(this.log);
            CustomTransactionedOperation operation = new CustomTransactionedOperation(dataSet);
            operation.Execute += new Library.TransactionedOperationDelegate(customDataUpdate.UpdateData);

            transactionWrapper.MakeAtomic(operation);
        }