示例#1
0
        /// <summary>Archives a Execution 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="executionId">The value for the ExecutionId 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 executionId)
        {
            // Accessor for the Execution Table.
            ServerMarketData.ExecutionDataTable executionTable = ServerMarketData.Execution;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.ExecutionRow executionRow = executionTable.FindByExecutionId(executionId);
            if ((executionRow == null))
            {
                throw new Exception(string.Format("The Execution table does not have an element identified by {0}", executionId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((executionRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < executionRow.GetNegotiationRows().Length); index = (index + 1))
            {
                ServerMarketData.NegotiationRow childNegotiationRow = executionRow.GetNegotiationRows()[index];
                Negotiation.Archive(adoTransaction, sqlTransaction, childNegotiationRow.RowVersion, childNegotiationRow.NegotiationId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            executionRow[executionTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(executionRow);
            executionRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Execution\" set \"IsArchived\" = 1 where \"ExecutionId\"=@executionId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@executionId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionId));
            sqlCommand.ExecuteNonQuery();
        }
示例#2
0
 /// <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.StatusLock);
     DestinationOrder.Archive(adoTransaction);
     Match.Archive(adoTransaction);
     Negotiation.Archive(adoTransaction);
     SourceOrder.Archive(adoTransaction);
     WorkingOrder.Archive(adoTransaction);
 }
示例#3
0
        /// <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();
        }
示例#4
0
        /// <summary>Inserts a Negotiation 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            negotiationId  = parameters["negotiationId"];

            // Call the internal method to complete the operation.
            Negotiation.Archive(adoTransaction, sqlTransaction, rowVersion, negotiationId);
        }
示例#5
0
        /// <summary>Inserts a Negotiation record using Metadata Parameters.</summary>
        /// <param name="parameters">Contains the metadata parameters.</param>
        public static void Update(ParameterList parameters)
        {
            // Extract the parameters from the command batch.
            AdoTransaction adoTransaction = parameters["adoTransaction"];
            SqlTransaction sqlTransaction = parameters["sqlTransaction"];
            long           rowVersion     = parameters["rowVersion"];
            object         executionId    = parameters["executionId"].Value;
            object         matchId        = parameters["matchId"].Value;
            int            negotiationId  = parameters["negotiationId"];
            object         quantity       = parameters["quantity"].Value;
            object         statusCode     = parameters["statusCode"].Value;

            // Call the internal method to complete the operation.
            Negotiation.Update(adoTransaction, sqlTransaction, ref rowVersion, executionId, matchId, negotiationId, quantity, statusCode);
            // Return values.
            parameters["rowVersion"] = rowVersion;
        }
示例#6
0
        /// <summary>Inserts a Negotiation record using Metadata Parameters.</summary>
        /// <param name="parameters">Contains the metadata parameters.</param>
        public static void Insert(ParameterList parameters)
        {
            // Extract the parameters from the command batch.
            AdoTransaction adoTransaction = parameters["adoTransaction"];
            SqlTransaction sqlTransaction = parameters["sqlTransaction"];
            object         executionId    = parameters["executionId"].Value;
            int            matchId        = parameters["matchId"];
            decimal        quantity       = parameters["quantity"];
            int            statusCode     = parameters["statusCode"];
            // The rowVersion is passed back to the caller in the event it's needed for additional commands in the batch.
            long rowVersion = long.MinValue;
            // Call the internal method to complete the operation.
            int negotiationId = Negotiation.Insert(adoTransaction, sqlTransaction, ref rowVersion, executionId, matchId, quantity, statusCode);

            // Return values.
            parameters["rowVersion"] = rowVersion;
            parameters.Return        = negotiationId;
        }
示例#7
0
 /// <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.ExecutionLock);
     Negotiation.Archive(adoTransaction);
 }