Exemplo n.º 1
0
        /// <summary>Inserts a DestinationOrder 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         canceledQuantity   = parameters["canceledQuantity"].Value;
            object         canceledTime       = parameters["canceledTime"].Value;
            object         createdTime        = parameters["createdTime"].Value;
            object         createdUserId      = parameters["createdUserId"].Value;
            object         destinationId      = parameters["destinationId"].Value;
            int            destinationOrderId = parameters["destinationOrderId"];
            object         externalId0        = parameters["externalId0"].Value;
            object         isCanceledByUser   = parameters["isCanceledByUser"].Value;
            object         isHidden           = parameters["isHidden"].Value;
            object         limitPrice         = parameters["limitPrice"].Value;
            object         modifiedTime       = parameters["modifiedTime"].Value;
            object         modifiedUserId     = parameters["modifiedUserId"].Value;
            object         orderTypeCode      = parameters["orderTypeCode"].Value;
            object         orderedQuantity    = parameters["orderedQuantity"].Value;
            object         priceTypeCode      = parameters["priceTypeCode"].Value;
            object         stateCode          = parameters["stateCode"].Value;
            object         statusCode         = parameters["statusCode"].Value;
            object         stopPrice          = parameters["stopPrice"].Value;
            object         traderId           = parameters["traderId"].Value;
            object         timeInForceCode    = parameters["timeInForceCode"].Value;
            object         workingOrderId     = parameters["workingOrderId"].Value;

            // Call the internal method to complete the operation.
            DestinationOrder.Update(adoTransaction, sqlTransaction, ref rowVersion, canceledQuantity, canceledTime, createdTime, createdUserId, destinationId, destinationOrderId, externalId0, isCanceledByUser, isHidden, limitPrice, modifiedTime, modifiedUserId, orderTypeCode, orderedQuantity, priceTypeCode, stateCode, statusCode, stopPrice, traderId, timeInForceCode, workingOrderId);
            // Return values.
            parameters["rowVersion"] = rowVersion;
        }
Exemplo n.º 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.StateLock);
     DestinationOrder.Archive(adoTransaction);
     Execution.Archive(adoTransaction);
 }
Exemplo n.º 3
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.TimeInForceLock);
     DestinationOrder.Archive(adoTransaction);
     SourceOrder.Archive(adoTransaction);
     WorkingOrder.Archive(adoTransaction);
 }
Exemplo n.º 4
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 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);
 }
Exemplo n.º 5
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();
        }
Exemplo n.º 6
0
        /// <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);
        }
Exemplo n.º 7
0
        /// <summary>Deletes a TimeInForce 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="timeInForceCode">The value for the TimeInForceCode column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        public static void Delete(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int timeInForceCode)
        {
            // Accessor for the TimeInForce Table.
            ServerMarketData.TimeInForceDataTable timeInForceTable = ServerMarketData.TimeInForce;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.TimeInForceRow timeInForceRow = timeInForceTable.FindByTimeInForceCode(timeInForceCode);
            if ((timeInForceRow == null))
            {
                throw new Exception(string.Format("The TimeInForce table does not have an element identified by {0}", timeInForceCode));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((timeInForceRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Delete the child records.
            for (int index = 0; (index < timeInForceRow.GetDestinationOrderRows().Length); index = (index + 1))
            {
                ServerMarketData.DestinationOrderRow childDestinationOrderRow = timeInForceRow.GetDestinationOrderRows()[index];
                DestinationOrder.Delete(adoTransaction, sqlTransaction, childDestinationOrderRow.RowVersion, childDestinationOrderRow.DestinationOrderId);
            }
            for (int index = 0; (index < timeInForceRow.GetSourceOrderRows().Length); index = (index + 1))
            {
                ServerMarketData.SourceOrderRow childSourceOrderRow = timeInForceRow.GetSourceOrderRows()[index];
                SourceOrder.Delete(adoTransaction, sqlTransaction, childSourceOrderRow.RowVersion, childSourceOrderRow.SourceOrderId);
            }
            for (int index = 0; (index < timeInForceRow.GetWorkingOrderRows().Length); index = (index + 1))
            {
                ServerMarketData.WorkingOrderRow childWorkingOrderRow = timeInForceRow.GetWorkingOrderRows()[index];
                WorkingOrder.Delete(adoTransaction, sqlTransaction, childWorkingOrderRow.RowVersion, childWorkingOrderRow.WorkingOrderId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            timeInForceRow[timeInForceTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(timeInForceRow);
            timeInForceRow.Delete();
            // Delete the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"TimeInForce\" set \"IsDeleted\" = 1 where \"TimeInForceCode\"=@timeInForceCode" +
                                                   "");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@timeInForceCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, timeInForceCode));
            sqlCommand.ExecuteNonQuery();
        }
Exemplo n.º 8
0
        /// <summary>Inserts a DestinationOrder 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         canceledQuantity = parameters["canceledQuantity"].Value;
            object         canceledTime     = parameters["canceledTime"].Value;

            System.DateTime createdTime      = parameters["createdTime"];
            int             createdUserId    = parameters["createdUserId"];
            int             destinationId    = parameters["destinationId"];
            object          externalId0      = parameters["externalId0"].Value;
            object          isCanceledByUser = parameters["isCanceledByUser"].Value;
            object          isHidden         = parameters["isHidden"].Value;
            object          limitPrice       = parameters["limitPrice"].Value;

            System.DateTime modifiedTime    = parameters["modifiedTime"];
            int             modifiedUserId  = parameters["modifiedUserId"];
            int             orderTypeCode   = parameters["orderTypeCode"];
            decimal         orderedQuantity = parameters["orderedQuantity"];
            int             priceTypeCode   = parameters["priceTypeCode"];
            int             stateCode       = parameters["stateCode"];
            int             statusCode      = parameters["statusCode"];
            object          stopPrice       = parameters["stopPrice"].Value;
            object          traderId        = parameters["traderId"].Value;
            int             timeInForceCode = parameters["timeInForceCode"];
            int             workingOrderId  = parameters["workingOrderId"];
            // 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 destinationOrderId = DestinationOrder.Insert(adoTransaction, sqlTransaction, ref rowVersion, canceledQuantity, canceledTime, createdTime, createdUserId, destinationId, externalId0, isCanceledByUser, isHidden, limitPrice, modifiedTime, modifiedUserId, orderTypeCode, orderedQuantity, priceTypeCode, stateCode, statusCode, stopPrice, traderId, timeInForceCode, workingOrderId);

            // Return values.
            parameters["rowVersion"] = rowVersion;
            parameters.Return        = destinationOrderId;
        }