Ejemplo n.º 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();
        }
Ejemplo n.º 2
0
 /// <summary>Updates a Execution record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public static void Update(ParameterList parameters)
 {
     // Accessor for the Execution Table.
     ServerMarketData.ExecutionDataTable executionTable = ServerMarketData.Execution;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object accruedInterest = parameters["accruedInterest"].Value;
     object externalBrokerAccountId = parameters["brokerAccountId"].Value;
     object externalBrokerId = parameters["brokerId"].Value;
     object commission = parameters["commission"].Value;
     object createdTime = parameters["createdTime"].Value;
     object externalCreatedUserId = parameters["createdUserId"].Value;
     object externalDestinationOrderId = parameters["destinationOrderId"].Value;
     object externalDestinationStateCode = parameters["destinationStateCode"].Value;
     string externalExecutionId = ((string)(parameters["executionId"]));
     object executionPrice = parameters["executionPrice"].Value;
     object executionQuantity = parameters["executionQuantity"].Value;
     object fixMessageId = parameters["fixMessageId"].Value;
     object isHidden = parameters["isHidden"].Value;
     object modifiedTime = parameters["modifiedTime"].Value;
     object externalModifiedUserId = parameters["modifiedUserId"].Value;
     object originalDestinationOrderId = parameters["originalDestinationOrderId"].Value;
     object originalPrice = parameters["originalPrice"].Value;
     object originalQuantity = parameters["originalQuantity"].Value;
     object settlementDate = parameters["settlementDate"].Value;
     object sourceExecutionId = parameters["sourceExecutionId"].Value;
     object externalSourceStateCode = parameters["sourceStateCode"].Value;
     object tradeDate = parameters["tradeDate"].Value;
     object userFee0 = parameters["userFee0"].Value;
     object userFee1 = parameters["userFee1"].Value;
     object userFee2 = parameters["userFee2"].Value;
     object userFee3 = parameters["userFee3"].Value;
     // The row versioning is largely disabled for external operations.
     long rowVersion = long.MinValue;
     // Resolve External Identifiers
     object brokerAccountId = BrokerAccount.FindOptionalKey(configurationId, "brokerAccountId", externalBrokerAccountId);
     object brokerId = Broker.FindOptionalKey(configurationId, "brokerId", externalBrokerId);
     object createdUserId = User.FindOptionalKey(configurationId, "createdUserId", externalCreatedUserId);
     object destinationOrderId = DestinationOrder.FindOptionalKey(configurationId, "destinationOrderId", externalDestinationOrderId);
     object destinationStateCode = State.FindOptionalKey(configurationId, "destinationStateCode", externalDestinationStateCode);
     int executionId = Execution.FindRequiredKey(configurationId, "executionId", externalExecutionId);
     object modifiedUserId = User.FindOptionalKey(configurationId, "modifiedUserId", externalModifiedUserId);
     object sourceStateCode = State.FindOptionalKey(configurationId, "sourceStateCode", externalSourceStateCode);
     // While the optimistic concurrency checking is disabled for the external methods, the internal methods
     // still need to perform the check.  This ncurrency checking logic by finding the current row version to be
     // will bypass the coused when the internal method is called.
     ServerMarketData.ExecutionRow executionRow = executionTable.FindByExecutionId(executionId);
     rowVersion = ((long)(executionRow[executionTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Execution.Update(adoTransaction, sqlTransaction, ref rowVersion, accruedInterest, brokerAccountId, brokerId, commission, createdTime, createdUserId, destinationOrderId, destinationStateCode, executionId, executionPrice, executionQuantity, null, fixMessageId, isHidden, modifiedTime, modifiedUserId, originalDestinationOrderId, originalPrice, originalQuantity, settlementDate, sourceExecutionId, sourceStateCode, tradeDate, userFee0, userFee1, userFee2, userFee3);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Ejemplo n.º 3
0
 /// <summary>Initializes the static elements of an Object.</summary>
 static Execution()
 {
     // The table must be locked before the indices can be read into an accelerator array.
     ServerMarketData.ExecutionLock.AcquireReaderLock(System.Threading.Timeout.Infinite);
     // Accessor for the Execution Table.
     ServerMarketData.ExecutionDataTable executionTable = ServerMarketData.Execution;
     // This does an indirect lookup operation using the views created for the ExternalId columns.  Take the index of the user
     // identifier column calcualted above and use it to find a record containing the external identifier.
     Execution.externalKeyArray = new DataView[] {
             executionTable.KeyExecutionExternalId0};
     // The table must be released after the array is constructed.
     ServerMarketData.ExecutionLock.ReleaseReaderLock();
 }
Ejemplo n.º 4
0
        /// <summary>Deletes a Execution record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="executionId">The value for the ExecutionId column.</param>
        /// <param name="rowVersion">The value for the RowVersion column.</param>
        public static void Delete(Transaction transaction, int executionId, long rowVersion)
        {
            // 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.");
            }
            // Provide the modified time and current user id to the base class.
            int      modifiedLoginId = ServerMarketData.LoginId;
            DateTime modifiedTime    = DateTime.Now;

            // Delete the child records.
            // Delete the record in the ADO database.
            transaction.DataRows.Add(executionRow);
            executionRow.Delete();
            // Delete the record in the SQL database.
            SqlCommand updateCommand = new SqlCommand(@"update ""Execution"" set ""ModifiedTime""=@modifiedTime,""ModifiedLoginId""=@modifiedLoginId where ""ExecutionId""=@executionId");

            updateCommand.Connection  = transaction.SqlConnection;
            updateCommand.Transaction = transaction.SqlTransaction;
            updateCommand.Parameters.Add("@executionId", @executionId);
            updateCommand.Parameters.Add("@modifiedTime", modifiedTime);
            updateCommand.Parameters.Add("@modifiedLoginId", modifiedLoginId);
            updateCommand.ExecuteNonQuery();
            // Delete the record in the SQL database.
            SqlCommand deleteCommand = new SqlCommand(@"delete ""Execution"" where ""ExecutionId""=@executionId");

            deleteCommand.Connection  = transaction.SqlConnection;
            deleteCommand.Transaction = transaction.SqlTransaction;
            deleteCommand.Parameters.Add("@executionId", @executionId);
            deleteCommand.ExecuteNonQuery();
        }
Ejemplo n.º 5
0
 /// <summary>Finds a a Execution record using a configuration and an external identifier.</summary>
 /// <param name="configurationId">Specified which mappings (user id columns) to use when looking up external identifiers.</param>
 /// <param name="parameterId">The name of the parameter as specified in the configuration table.</param>
 /// <param name="externalId">The external (user supplied) identifier for the record.</param>
 public static int FindKey(object configurationId, string parameterId, object externalId)
 {
     // A missing key will never match a column.
     if ((externalId == null))
     {
         return int.MinValue;
     }
     // Accessor for the Execution Table.
     ServerMarketData.ExecutionDataTable executionTable = ServerMarketData.Execution;
     // Look for the record using the external identifier.  The configuration selected the key to use, which effectively
     // selected the external id column to use for the search.  If a record is found in the view, a translation still needs
     // to be made back to the original table before an index to the record can be returned to the caller.
     int externalKeyIndex = Execution.GetExternalKeyIndex(configurationId, parameterId);
     System.Data.DataView externalKeyView = Execution.externalKeyArray[externalKeyIndex];
     int recordIndex = externalKeyView.Find(new object[] {
                 externalId});
     if ((recordIndex == -1))
     {
         return int.MinValue;
     }
     return ((int)(externalKeyView[recordIndex].Row[executionTable.ExecutionIdColumn]));
 }
Ejemplo n.º 6
0
 /// <summary>Archives a Execution record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public static void Archive(ParameterList parameters)
 {
     // Accessor for the Execution Table.
     ServerMarketData.ExecutionDataTable executionTable = ServerMarketData.Execution;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string externalExecutionId = parameters["executionId"];
     // The row versioning is largely disabled for external operations.
     long rowVersion = long.MinValue;
     // Find the internal identifier using the primar key elements.
     // identifier is used to determine if a record exists with the same key.
     int executionId = Execution.FindRequiredKey(configurationId, "executionId", externalExecutionId);
     // While the optimistic concurrency checking is disabled for the external methods, the internal methods
     // still need to perform the check.  This ncurrency checking logic by finding the current row version to be
     // will bypass the coused when the internal method is called.
     ServerMarketData.ExecutionRow executionRow = executionTable.FindByExecutionId(executionId);
     rowVersion = ((long)(executionRow[executionTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.Execution.Archive(adoTransaction, sqlTransaction, rowVersion, executionId);
 }
Ejemplo n.º 7
0
        /// <summary>Inserts a Execution record using Metadata Parameters.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit.</param>
        /// <param name="remoteMethod">Contains the metadata parameters and exceptions for this command.</param>
        public static void InsertFile(ParameterList parameters)
        {
            // Accessor for the Execution Table.
            ServerMarketData.ExecutionDataTable executionTable = ServerMarketData.Execution;

            // Extract the parameters from the command batch.
            AdoTransaction adoTransaction             = parameters["adoTransaction"];
            SqlTransaction sqlTransaction             = parameters["sqlTransaction"];
            object         configurationId            = parameters["configurationId"].Value;
            object         sourceExecutionId          = parameters["sourceExecutionId"].Value;
            string         externalDestinationOrderId = parameters["destinationOrderId"];
            object         externalExecutionId        = parameters["executionId"].Value;
            object         externalId0 = parameters["externalId0"].Value;

            System.Decimal  executionPrice    = parameters["executionPrice"];
            System.Decimal  executionQuantity = parameters["executionQuantity"];
            System.DateTime settlementDate    = parameters["settlementDate"];
            System.DateTime tradeDate         = parameters["tradeDate"];

            // Resolve External Identifiers
            int destinationOrderId = External.DestinationOrder.FindRequiredKey(configurationId, "destinationOrderId", externalDestinationOrderId);
            int executionId        = External.Execution.FindKey(configurationId, "executionId", (string)externalExecutionId);

            // The row versioning is largely disabled for external operations.  The value is returned to the caller in the
            // event it's needed for operations within the batch.
            long rowVersion = long.MinValue;

            // Optional Parameters
            object accruedInterest = parameters["accruedInterest"] is MissingParameter ? (object)null :
                                     Convert.ToDecimal(parameters["accruedInterest"].Value);
            object commission = parameters["commission"] is MissingParameter ? (object)null :
                                Convert.ToDecimal(parameters["commission"].Value);
            object isHidden = parameters["isHidden"] is MissingParameter ? (object)null :
                              Convert.ToBoolean(parameters["isHidden"].Value);
            object userFee0 = parameters["userFee0"] is MissingParameter ? (object)null :
                              Convert.ToDecimal(parameters["userFee0"].Value);
            object userFee1 = parameters["userFee1"] is MissingParameter ? (object)null :
                              Convert.ToDecimal(parameters["userFee1"].Value);
            object userFee2 = parameters["userFee2"] is MissingParameter ? (object)null :
                              Convert.ToDecimal(parameters["userFee2"].Value);
            object userFee3 = parameters["userFee3"] is MissingParameter ? (object)null :
                              Convert.ToDecimal(parameters["userFee3"].Value);

            // Default Status codes
            int destinationStateCode = State.Acknowledged;
            int sourceStateCode      = State.Initial;

            // Time stamps and user stamps
            int      createdUserId  = ServerMarketData.UserId;
            DateTime createdTime    = DateTime.Now;
            int      modifiedUserId = ServerMarketData.UserId;
            DateTime modifiedTime   = DateTime.Now;

            // The load operation will create a record if it doesn't exist, or update an existing record.  The external
            // identifier is used to determine if a record exists with the same key.
            if ((executionId == int.MinValue))
            {
                // Populate the 'externalId' varaibles so that the external identifier can be used to find the row when an
                // external method is called with the same 'configurationId' parameter.
                int      externalKeyIndex = External.Execution.GetExternalKeyIndex(configurationId, "executionId");
                object[] externalIdArray  = new object[1];
                externalIdArray[externalKeyIndex] = externalExecutionId;
                externalId0 = externalIdArray[0];

                // Call the internal method to complete the operation.
                MarkThree.Guardian.Core.Execution.Insert(adoTransaction, sqlTransaction, ref rowVersion, accruedInterest,
                                                         null, null, commission, createdTime, createdUserId, destinationOrderId, destinationStateCode, executionPrice,
                                                         executionQuantity, externalId0, null, isHidden, modifiedTime, modifiedUserId, null, null, null,
                                                         settlementDate, sourceExecutionId, sourceStateCode, tradeDate, userFee0, userFee1, userFee2, userFee3);
            }
            else
            {
                // While the optimistic concurrency checking is disabled for the external methods, the internal methods
                // still need to perform the check.  This ncurrency checking logic by finding the current row version to be
                // will bypass the coused when the internal method is called.
                ServerMarketData.ExecutionRow executionRow = executionTable.FindByExecutionId(executionId);
                rowVersion = ((long)(executionRow[executionTable.RowVersionColumn]));

                // Call the internal method to complete the operation.
                MarkThree.Guardian.Core.Execution.Update(adoTransaction, sqlTransaction, ref rowVersion, accruedInterest,
                                                         null, null, commission, createdTime, createdUserId, destinationOrderId, destinationStateCode, executionId,
                                                         executionPrice, executionQuantity, externalId0, null, isHidden, modifiedTime, modifiedUserId, null, null,
                                                         null, settlementDate, sourceExecutionId, sourceStateCode, tradeDate, userFee0, userFee1, userFee2, userFee3);
            }

            // Return values.
            parameters["rowVersion"] = rowVersion;
        }
Ejemplo n.º 8
0
        /// <summary>Updates 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 the row</param>
        /// <param name="accruedInterest">The value for the AccruedInterest column.</param>
        /// <param name="brokerAccountId">The value for the BrokerAccountId column.</param>
        /// <param name="brokerId">The value for the BrokerId column.</param>
        /// <param name="commission">The value for the Commission column.</param>
        /// <param name="createdTime">The value for the CreatedTime column.</param>
        /// <param name="createdUserId">The value for the CreatedUserId column.</param>
        /// <param name="destinationOrderId">The value for the DestinationOrderId column.</param>
        /// <param name="destinationStateCode">The value for the DestinationStateCode column.</param>
        /// <param name="executionId">The value for the ExecutionId column.</param>
        /// <param name="executionPrice">The value for the ExecutionPrice column.</param>
        /// <param name="executionQuantity">The value for the ExecutionQuantity column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="fixMessageId">The value for the FixMessageId column.</param>
        /// <param name="isHidden">The value for the IsHidden column.</param>
        /// <param name="modifiedTime">The value for the ModifiedTime column.</param>
        /// <param name="modifiedUserId">The value for the ModifiedUserId column.</param>
        /// <param name="originalDestinationOrderId">The value for the OriginalDestinationOrderId column.</param>
        /// <param name="originalPrice">The value for the OriginalPrice column.</param>
        /// <param name="originalQuantity">The value for the OriginalQuantity column.</param>
        /// <param name="settlementDate">The value for the SettlementDate column.</param>
        /// <param name="sourceExecutionId">The value for the SourceExecutionId column.</param>
        /// <param name="sourceStateCode">The value for the SourceStateCode column.</param>
        /// <param name="tradeDate">The value for the TradeDate column.</param>
        /// <param name="userFee0">The value for the UserFee0 column.</param>
        /// <param name="userFee1">The value for the UserFee1 column.</param>
        /// <param name="userFee2">The value for the UserFee2 column.</param>
        /// <param name="userFee3">The value for the UserFee3 column.</param>
        public static void Update(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            object accruedInterest,
            object brokerAccountId,
            object brokerId,
            object commission,
            object createdTime,
            object createdUserId,
            object destinationOrderId,
            object destinationStateCode,
            int executionId,
            object executionPrice,
            object executionQuantity,
            object externalId0,
            object fixMessageId,
            object isHidden,
            object modifiedTime,
            object modifiedUserId,
            object originalDestinationOrderId,
            object originalPrice,
            object originalQuantity,
            object settlementDate,
            object sourceExecutionId,
            object sourceStateCode,
            object tradeDate,
            object userFee0,
            object userFee1,
            object userFee2,
            object userFee3)
        {
            // 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.");
            }
            // Apply Defaults
            if ((accruedInterest == null))
            {
                accruedInterest = executionRow[executionTable.AccruedInterestColumn];
            }
            if ((brokerAccountId == null))
            {
                brokerAccountId = executionRow[executionTable.BrokerAccountIdColumn];
            }
            if ((brokerId == null))
            {
                brokerId = executionRow[executionTable.BrokerIdColumn];
            }
            if ((commission == null))
            {
                commission = executionRow[executionTable.CommissionColumn];
            }
            if ((createdTime == null))
            {
                createdTime = executionRow[executionTable.CreatedTimeColumn];
            }
            if ((createdUserId == null))
            {
                createdUserId = executionRow[executionTable.CreatedUserIdColumn];
            }
            if ((destinationOrderId == null))
            {
                destinationOrderId = executionRow[executionTable.DestinationOrderIdColumn];
            }
            if ((destinationStateCode == null))
            {
                destinationStateCode = executionRow[executionTable.DestinationStateCodeColumn];
            }
            if ((executionPrice == null))
            {
                executionPrice = executionRow[executionTable.ExecutionPriceColumn];
            }
            if ((executionQuantity == null))
            {
                executionQuantity = executionRow[executionTable.ExecutionQuantityColumn];
            }
            if ((externalId0 == null))
            {
                externalId0 = executionRow[executionTable.ExternalId0Column];
            }
            if ((fixMessageId == null))
            {
                fixMessageId = executionRow[executionTable.FixMessageIdColumn];
            }
            if ((isHidden == null))
            {
                isHidden = executionRow[executionTable.IsHiddenColumn];
            }
            if ((modifiedTime == null))
            {
                modifiedTime = executionRow[executionTable.ModifiedTimeColumn];
            }
            if ((modifiedUserId == null))
            {
                modifiedUserId = executionRow[executionTable.ModifiedUserIdColumn];
            }
            if ((originalDestinationOrderId == null))
            {
                originalDestinationOrderId = executionRow[executionTable.OriginalDestinationOrderIdColumn];
            }
            if ((originalPrice == null))
            {
                originalPrice = executionRow[executionTable.OriginalPriceColumn];
            }
            if ((originalQuantity == null))
            {
                originalQuantity = executionRow[executionTable.OriginalQuantityColumn];
            }
            if ((settlementDate == null))
            {
                settlementDate = executionRow[executionTable.SettlementDateColumn];
            }
            if ((sourceExecutionId == null))
            {
                sourceExecutionId = executionRow[executionTable.SourceExecutionIdColumn];
            }
            if ((sourceStateCode == null))
            {
                sourceStateCode = executionRow[executionTable.SourceStateCodeColumn];
            }
            if ((tradeDate == null))
            {
                tradeDate = executionRow[executionTable.TradeDateColumn];
            }
            if ((userFee0 == null))
            {
                userFee0 = executionRow[executionTable.UserFee0Column];
            }
            if ((userFee1 == null))
            {
                userFee1 = executionRow[executionTable.UserFee1Column];
            }
            if ((userFee2 == null))
            {
                userFee2 = executionRow[executionTable.UserFee2Column];
            }
            if ((userFee3 == null))
            {
                userFee3 = executionRow[executionTable.UserFee3Column];
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Update the record in the ADO database.
            executionRow[executionTable.RowVersionColumn]                 = rowVersion;
            executionRow[executionTable.AccruedInterestColumn]            = accruedInterest;
            executionRow[executionTable.BrokerAccountIdColumn]            = brokerAccountId;
            executionRow[executionTable.BrokerIdColumn]                   = brokerId;
            executionRow[executionTable.CommissionColumn]                 = commission;
            executionRow[executionTable.CreatedTimeColumn]                = createdTime;
            executionRow[executionTable.CreatedUserIdColumn]              = createdUserId;
            executionRow[executionTable.DestinationOrderIdColumn]         = destinationOrderId;
            executionRow[executionTable.DestinationStateCodeColumn]       = destinationStateCode;
            executionRow[executionTable.ExecutionPriceColumn]             = executionPrice;
            executionRow[executionTable.ExecutionQuantityColumn]          = executionQuantity;
            executionRow[executionTable.ExternalId0Column]                = externalId0;
            executionRow[executionTable.FixMessageIdColumn]               = fixMessageId;
            executionRow[executionTable.IsHiddenColumn]                   = isHidden;
            executionRow[executionTable.ModifiedTimeColumn]               = modifiedTime;
            executionRow[executionTable.ModifiedUserIdColumn]             = modifiedUserId;
            executionRow[executionTable.OriginalDestinationOrderIdColumn] = originalDestinationOrderId;
            executionRow[executionTable.OriginalPriceColumn]              = originalPrice;
            executionRow[executionTable.OriginalQuantityColumn]           = originalQuantity;
            executionRow[executionTable.SettlementDateColumn]             = settlementDate;
            executionRow[executionTable.SourceExecutionIdColumn]          = sourceExecutionId;
            executionRow[executionTable.SourceStateCodeColumn]            = sourceStateCode;
            executionRow[executionTable.TradeDateColumn]                  = tradeDate;
            executionRow[executionTable.UserFee0Column]                   = userFee0;
            executionRow[executionTable.UserFee1Column]                   = userFee1;
            executionRow[executionTable.UserFee2Column]                   = userFee2;
            executionRow[executionTable.UserFee3Column]                   = userFee3;
            adoTransaction.DataRows.Add(executionRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""Execution"" set ""RowVersion""=@rowVersion,""AccruedInterest""=@accruedInterest,""BrokerAccountId""=@brokerAccountId,""BrokerId""=@brokerId,""Commission""=@commission,""CreatedTime""=@createdTime,""CreatedUserId""=@createdUserId,""DestinationOrderId""=@destinationOrderId,""DestinationStateCode""=@destinationStateCode,""ExecutionPrice""=@executionPrice,""ExecutionQuantity""=@executionQuantity,""ExternalId0""=@externalId0,""FixMessageId""=@fixMessageId,""IsHidden""=@isHidden,""ModifiedTime""=@modifiedTime,""ModifiedUserId""=@modifiedUserId,""OriginalDestinationOrderId""=@originalDestinationOrderId,""OriginalPrice""=@originalPrice,""OriginalQuantity""=@originalQuantity,""SettlementDate""=@settlementDate,""SourceExecutionId""=@sourceExecutionId,""SourceStateCode""=@sourceStateCode,""TradeDate""=@tradeDate,""UserFee0""=@userFee0,""UserFee1""=@userFee1,""UserFee2""=@userFee2,""UserFee3""=@userFee3 where ""ExecutionId""=@executionId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@rowVersion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rowVersion));
            sqlCommand.Parameters.Add(new SqlParameter("@accruedInterest", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accruedInterest));
            sqlCommand.Parameters.Add(new SqlParameter("@brokerAccountId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerAccountId));
            sqlCommand.Parameters.Add(new SqlParameter("@brokerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerId));
            sqlCommand.Parameters.Add(new SqlParameter("@commission", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, commission));
            sqlCommand.Parameters.Add(new SqlParameter("@createdTime", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, createdTime));
            sqlCommand.Parameters.Add(new SqlParameter("@createdUserId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, createdUserId));
            sqlCommand.Parameters.Add(new SqlParameter("@destinationOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationOrderId));
            sqlCommand.Parameters.Add(new SqlParameter("@destinationStateCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationStateCode));
            sqlCommand.Parameters.Add(new SqlParameter("@executionId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionId));
            sqlCommand.Parameters.Add(new SqlParameter("@executionPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionPrice));
            sqlCommand.Parameters.Add(new SqlParameter("@executionQuantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionQuantity));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@fixMessageId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, fixMessageId));
            sqlCommand.Parameters.Add(new SqlParameter("@isHidden", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isHidden));
            sqlCommand.Parameters.Add(new SqlParameter("@modifiedTime", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, modifiedTime));
            sqlCommand.Parameters.Add(new SqlParameter("@modifiedUserId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, modifiedUserId));
            sqlCommand.Parameters.Add(new SqlParameter("@originalDestinationOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, originalDestinationOrderId));
            sqlCommand.Parameters.Add(new SqlParameter("@originalPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, originalPrice));
            sqlCommand.Parameters.Add(new SqlParameter("@originalQuantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, originalQuantity));
            sqlCommand.Parameters.Add(new SqlParameter("@settlementDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementDate));
            sqlCommand.Parameters.Add(new SqlParameter("@sourceExecutionId", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sourceExecutionId));
            sqlCommand.Parameters.Add(new SqlParameter("@sourceStateCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sourceStateCode));
            sqlCommand.Parameters.Add(new SqlParameter("@tradeDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, tradeDate));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee0", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee0));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee1));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee2));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee3", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee3));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }
Ejemplo n.º 9
0
        /// <summary>Inserts a Execution record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="accruedInterest">The value for the AccruedInterest column.</param>
        /// <param name="brokerAccountId">The value for the BrokerAccountId column.</param>
        /// <param name="brokerId">The value for the BrokerId column.</param>
        /// <param name="commission">The value for the Commission column.</param>
        /// <param name="createdTime">The value for the CreatedTime column.</param>
        /// <param name="createdUserId">The value for the CreatedUserId column.</param>
        /// <param name="destinationOrderId">The value for the DestinationOrderId column.</param>
        /// <param name="destinationStateCode">The value for the DestinationStateCode column.</param>
        /// <param name="executionPrice">The value for the ExecutionPrice column.</param>
        /// <param name="executionQuantity">The value for the ExecutionQuantity column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="fixMessageId">The value for the FixMessageId column.</param>
        /// <param name="isHidden">The value for the IsHidden column.</param>
        /// <param name="modifiedTime">The value for the ModifiedTime column.</param>
        /// <param name="modifiedUserId">The value for the ModifiedUserId column.</param>
        /// <param name="originalDestinationOrderId">The value for the OriginalDestinationOrderId column.</param>
        /// <param name="originalPrice">The value for the OriginalPrice column.</param>
        /// <param name="originalQuantity">The value for the OriginalQuantity column.</param>
        /// <param name="settlementDate">The value for the SettlementDate column.</param>
        /// <param name="sourceExecutionId">The value for the SourceExecutionId column.</param>
        /// <param name="sourceStateCode">The value for the SourceStateCode column.</param>
        /// <param name="tradeDate">The value for the TradeDate column.</param>
        /// <param name="userFee0">The value for the UserFee0 column.</param>
        /// <param name="userFee1">The value for the UserFee1 column.</param>
        /// <param name="userFee2">The value for the UserFee2 column.</param>
        /// <param name="userFee3">The value for the UserFee3 column.</param>
        public static int Insert(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            object accruedInterest,
            object brokerAccountId,
            object brokerId,
            object commission,
            object createdTime,
            object createdUserId,
            int destinationOrderId,
            int destinationStateCode,
            decimal executionPrice,
            decimal executionQuantity,
            object externalId0,
            object fixMessageId,
            object isHidden,
            object modifiedTime,
            object modifiedUserId,
            object originalDestinationOrderId,
            object originalPrice,
            object originalQuantity,
            System.DateTime settlementDate,
            object sourceExecutionId,
            int sourceStateCode,
            System.DateTime tradeDate,
            object userFee0,
            object userFee1,
            object userFee2,
            object userFee3)
        {
            // Accessor for the Execution Table.
            ServerMarketData.ExecutionDataTable executionTable = ServerMarketData.Execution;
            // Apply Defaults
            if ((accruedInterest == null))
            {
                accruedInterest = 0.0m;
            }
            if ((brokerAccountId == null))
            {
                brokerAccountId = System.DBNull.Value;
            }
            if ((brokerId == null))
            {
                brokerId = System.DBNull.Value;
            }
            if ((commission == null))
            {
                commission = 0.0m;
            }
            if ((createdTime == null))
            {
                createdTime = System.DBNull.Value;
            }
            if ((createdUserId == null))
            {
                createdUserId = System.DBNull.Value;
            }
            if ((externalId0 == null))
            {
                externalId0 = System.DBNull.Value;
            }
            if ((fixMessageId == null))
            {
                fixMessageId = System.DBNull.Value;
            }
            if ((isHidden == null))
            {
                isHidden = false;
            }
            if ((modifiedTime == null))
            {
                modifiedTime = System.DBNull.Value;
            }
            if ((modifiedUserId == null))
            {
                modifiedUserId = System.DBNull.Value;
            }
            if ((originalDestinationOrderId == null))
            {
                originalDestinationOrderId = System.DBNull.Value;
            }
            if ((originalPrice == null))
            {
                originalPrice = System.DBNull.Value;
            }
            if ((originalQuantity == null))
            {
                originalQuantity = System.DBNull.Value;
            }
            if ((sourceExecutionId == null))
            {
                sourceExecutionId = System.DBNull.Value;
            }
            if ((userFee0 == null))
            {
                userFee0 = 0.0m;
            }
            if ((userFee1 == null))
            {
                userFee1 = 0.0m;
            }
            if ((userFee2 == null))
            {
                userFee2 = 0.0m;
            }
            if ((userFee3 == null))
            {
                userFee3 = 0.0m;
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerMarketData.ExecutionRow executionRow = executionTable.NewExecutionRow();
            executionRow[executionTable.RowVersionColumn]                 = rowVersion;
            executionRow[executionTable.AccruedInterestColumn]            = accruedInterest;
            executionRow[executionTable.BrokerAccountIdColumn]            = brokerAccountId;
            executionRow[executionTable.BrokerIdColumn]                   = brokerId;
            executionRow[executionTable.CommissionColumn]                 = commission;
            executionRow[executionTable.CreatedTimeColumn]                = createdTime;
            executionRow[executionTable.CreatedUserIdColumn]              = createdUserId;
            executionRow[executionTable.DestinationOrderIdColumn]         = destinationOrderId;
            executionRow[executionTable.DestinationStateCodeColumn]       = destinationStateCode;
            executionRow[executionTable.ExecutionPriceColumn]             = executionPrice;
            executionRow[executionTable.ExecutionQuantityColumn]          = executionQuantity;
            executionRow[executionTable.ExternalId0Column]                = externalId0;
            executionRow[executionTable.FixMessageIdColumn]               = fixMessageId;
            executionRow[executionTable.IsHiddenColumn]                   = isHidden;
            executionRow[executionTable.ModifiedTimeColumn]               = modifiedTime;
            executionRow[executionTable.ModifiedUserIdColumn]             = modifiedUserId;
            executionRow[executionTable.OriginalDestinationOrderIdColumn] = originalDestinationOrderId;
            executionRow[executionTable.OriginalPriceColumn]              = originalPrice;
            executionRow[executionTable.OriginalQuantityColumn]           = originalQuantity;
            executionRow[executionTable.SettlementDateColumn]             = settlementDate;
            executionRow[executionTable.SourceExecutionIdColumn]          = sourceExecutionId;
            executionRow[executionTable.SourceStateCodeColumn]            = sourceStateCode;
            executionRow[executionTable.TradeDateColumn]                  = tradeDate;
            executionRow[executionTable.UserFee0Column]                   = userFee0;
            executionRow[executionTable.UserFee1Column]                   = userFee1;
            executionRow[executionTable.UserFee2Column]                   = userFee2;
            executionRow[executionTable.UserFee3Column]                   = userFee3;
            executionTable.AddExecutionRow(executionRow);
            adoTransaction.DataRows.Add(executionRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""Execution"" (""rowVersion"",""AccruedInterest"",""BrokerAccountId"",""BrokerId"",""Commission"",""CreatedTime"",""CreatedUserId"",""DestinationOrderId"",""DestinationStateCode"",""ExecutionId"",""ExecutionPrice"",""ExecutionQuantity"",""ExternalId0"",""FixMessageId"",""IsHidden"",""ModifiedTime"",""ModifiedUserId"",""OriginalDestinationOrderId"",""OriginalPrice"",""OriginalQuantity"",""SettlementDate"",""SourceExecutionId"",""SourceStateCode"",""TradeDate"",""UserFee0"",""UserFee1"",""UserFee2"",""UserFee3"") values (@rowVersion,@accruedInterest,@brokerAccountId,@brokerId,@commission,@createdTime,@createdUserId,@destinationOrderId,@destinationStateCode,@executionId,@executionPrice,@executionQuantity,@externalId0,@fixMessageId,@isHidden,@modifiedTime,@modifiedUserId,@originalDestinationOrderId,@originalPrice,@originalQuantity,@settlementDate,@sourceExecutionId,@sourceStateCode,@tradeDate,@userFee0,@userFee1,@userFee2,@userFee3)");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@rowVersion", SqlDbType.BigInt, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, rowVersion));
            sqlCommand.Parameters.Add(new SqlParameter("@accruedInterest", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accruedInterest));
            sqlCommand.Parameters.Add(new SqlParameter("@brokerAccountId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerAccountId));
            sqlCommand.Parameters.Add(new SqlParameter("@brokerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerId));
            sqlCommand.Parameters.Add(new SqlParameter("@commission", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, commission));
            sqlCommand.Parameters.Add(new SqlParameter("@createdTime", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, createdTime));
            sqlCommand.Parameters.Add(new SqlParameter("@createdUserId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, createdUserId));
            sqlCommand.Parameters.Add(new SqlParameter("@destinationOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationOrderId));
            sqlCommand.Parameters.Add(new SqlParameter("@destinationStateCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationStateCode));
            sqlCommand.Parameters.Add(new SqlParameter("@executionId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionRow[executionTable.ExecutionIdColumn]));
            sqlCommand.Parameters.Add(new SqlParameter("@executionPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionPrice));
            sqlCommand.Parameters.Add(new SqlParameter("@executionQuantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionQuantity));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@fixMessageId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, fixMessageId));
            sqlCommand.Parameters.Add(new SqlParameter("@isHidden", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isHidden));
            sqlCommand.Parameters.Add(new SqlParameter("@modifiedTime", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, modifiedTime));
            sqlCommand.Parameters.Add(new SqlParameter("@modifiedUserId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, modifiedUserId));
            sqlCommand.Parameters.Add(new SqlParameter("@originalDestinationOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, originalDestinationOrderId));
            sqlCommand.Parameters.Add(new SqlParameter("@originalPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, originalPrice));
            sqlCommand.Parameters.Add(new SqlParameter("@originalQuantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, originalQuantity));
            sqlCommand.Parameters.Add(new SqlParameter("@settlementDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementDate));
            sqlCommand.Parameters.Add(new SqlParameter("@sourceExecutionId", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sourceExecutionId));
            sqlCommand.Parameters.Add(new SqlParameter("@sourceStateCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sourceStateCode));
            sqlCommand.Parameters.Add(new SqlParameter("@tradeDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, tradeDate));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee0", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee0));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee1));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee2));
            sqlCommand.Parameters.Add(new SqlParameter("@userFee3", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userFee3));
            sqlCommand.ExecuteNonQuery();
            // Return Statements
            return(executionRow.ExecutionId);
        }