/// <summary>Collects the table lock request(s) for an Update operation</summary> /// <param name="adoTransaction">A list of locks required for this operation.</param> public static void Archive(AdoTransaction adoTransaction) { // These table lock(s) are required for the 'Archive' operation. adoTransaction.LockRequests.AddWriterLock(ServerMarketData.StateLock); DestinationOrder.Archive(adoTransaction); Execution.Archive(adoTransaction); }
/// <summary>Collects the table lock request(s) for an Update operation</summary> /// <param name="adoTransaction">A list of locks required for this operation.</param> public static void Archive(AdoTransaction adoTransaction) { // These table lock(s) are required for the 'Archive' operation. adoTransaction.LockRequests.AddWriterLock(ServerMarketData.TimeInForceLock); DestinationOrder.Archive(adoTransaction); SourceOrder.Archive(adoTransaction); WorkingOrder.Archive(adoTransaction); }
/// <summary>Collects the table lock request(s) for an Update operation</summary> /// <param name="adoTransaction">A list of locks required for this operation.</param> public static void Delete(AdoTransaction adoTransaction) { // These table lock(s) are required for the 'Delete' operation. adoTransaction.LockRequests.AddWriterLock(ServerMarketData.StatusLock); DestinationOrder.Archive(adoTransaction); Match.Archive(adoTransaction); Negotiation.Archive(adoTransaction); SourceOrder.Archive(adoTransaction); WorkingOrder.Archive(adoTransaction); }
/// <summary>Archives a Status record.</summary> /// <param name="transaction">Commits or rejects a set of commands as a unit</param> /// <param name="RowVersion">The version number of this row.</param> /// <param name="statusCode">The value for the StatusCode column.</param> /// <param name="archive">true to archive the object, false to unarchive it.</param> public static void Archive(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int statusCode) { // Accessor for the Status Table. ServerMarketData.StatusDataTable statusTable = ServerMarketData.Status; // Rule #1: Make sure the record exists before updating it. ServerMarketData.StatusRow statusRow = statusTable.FindByStatusCode(statusCode); if ((statusRow == null)) { throw new Exception(string.Format("The Status table does not have an element identified by {0}", statusCode)); } // Rule #2: Optimistic Concurrency Check if ((statusRow.RowVersion != rowVersion)) { throw new System.Exception("This record is busy. Please try again later."); } // Archive the child records. for (int index = 0; (index < statusRow.GetDestinationOrderRows().Length); index = (index + 1)) { ServerMarketData.DestinationOrderRow childDestinationOrderRow = statusRow.GetDestinationOrderRows()[index]; DestinationOrder.Archive(adoTransaction, sqlTransaction, childDestinationOrderRow.RowVersion, childDestinationOrderRow.DestinationOrderId); } for (int index = 0; (index < statusRow.GetMatchRows().Length); index = (index + 1)) { ServerMarketData.MatchRow childMatchRow = statusRow.GetMatchRows()[index]; Match.Archive(adoTransaction, sqlTransaction, childMatchRow.RowVersion, childMatchRow.MatchId); } for (int index = 0; (index < statusRow.GetNegotiationRows().Length); index = (index + 1)) { ServerMarketData.NegotiationRow childNegotiationRow = statusRow.GetNegotiationRows()[index]; Negotiation.Archive(adoTransaction, sqlTransaction, childNegotiationRow.RowVersion, childNegotiationRow.NegotiationId); } for (int index = 0; (index < statusRow.GetSourceOrderRows().Length); index = (index + 1)) { ServerMarketData.SourceOrderRow childSourceOrderRow = statusRow.GetSourceOrderRows()[index]; SourceOrder.Archive(adoTransaction, sqlTransaction, childSourceOrderRow.RowVersion, childSourceOrderRow.SourceOrderId); } for (int index = 0; (index < statusRow.GetWorkingOrderRows().Length); index = (index + 1)) { ServerMarketData.WorkingOrderRow childWorkingOrderRow = statusRow.GetWorkingOrderRows()[index]; WorkingOrder.Archive(adoTransaction, sqlTransaction, childWorkingOrderRow.RowVersion, childWorkingOrderRow.WorkingOrderId); } // Increment the row version rowVersion = ServerMarketData.RowVersion.Increment(); // Delete the record in the ADO database. statusRow[statusTable.RowVersionColumn] = rowVersion; adoTransaction.DataRows.Add(statusRow); statusRow.Delete(); // Archive the record in the SQL database. SqlCommand sqlCommand = new SqlCommand("update \"Status\" set \"IsArchived\" = 1 where \"StatusCode\"=@statusCode"); sqlCommand.Connection = sqlTransaction.Connection; sqlCommand.Transaction = sqlTransaction; sqlCommand.Parameters.Add(new SqlParameter("@statusCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, statusCode)); sqlCommand.ExecuteNonQuery(); }
/// <summary>Inserts a DestinationOrder record using Metadata Parameters.</summary> /// <param name="parameters">Contains the metadata parameters.</param> public static void Archive(ParameterList parameters) { // Extract the parameters from the command batch. AdoTransaction adoTransaction = parameters["adoTransaction"]; SqlTransaction sqlTransaction = parameters["sqlTransaction"]; long rowVersion = parameters["rowVersion"]; int destinationOrderId = parameters["destinationOrderId"]; // Call the internal method to complete the operation. DestinationOrder.Archive(adoTransaction, sqlTransaction, rowVersion, destinationOrderId); }