Esempio n. 1
0
 /// <summary>Initializes the static elements of an Object.</summary>
 static DestinationOrder()
 {
     // The table must be locked before the indices can be read into an accelerator array.
     ServerMarketData.DestinationOrderLock.AcquireReaderLock(System.Threading.Timeout.Infinite);
     // Accessor for the DestinationOrder Table.
     ServerMarketData.DestinationOrderDataTable destinationOrderTable = ServerMarketData.DestinationOrder;
     // 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.
     DestinationOrder.externalKeyArray = new DataView[] {
             destinationOrderTable.KeyDestinationOrderExternalId0};
     // The table must be released after the array is constructed.
     ServerMarketData.DestinationOrderLock.ReleaseReaderLock();
 }
Esempio n. 2
0
 /// <summary>Updates a DestinationOrder 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 DestinationOrder Table.
     ServerMarketData.DestinationOrderDataTable destinationOrderTable = ServerMarketData.DestinationOrder;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object canceledQuantity = parameters["canceledQuantity"].Value;
     object canceledTime = parameters["canceledTime"].Value;
     object createdTime = parameters["createdTime"].Value;
     object createdUserId = parameters["createdUserId"].Value;
     object externalDestinationId = parameters["destinationId"].Value;
     string externalDestinationOrderId = ((string)(parameters["destinationOrderId"]));
     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 externalPriceTypeCode = parameters["priceTypeCode"].Value;
     object externalStateCode = parameters["stateCode"].Value;
     object externalStatusCode = parameters["statusCode"].Value;
     object stopPrice = parameters["stopPrice"].Value;
     object externalTraderId = parameters["traderId"].Value;
     object externalTimeInForceCode = parameters["timeInForceCode"].Value;
     object externalWorkingOrderId = parameters["workingOrderId"].Value;
     // The row versioning is largely disabled for external operations.
     long rowVersion = long.MinValue;
     // Resolve External Identifiers
     object destinationId = Destination.FindOptionalKey(configurationId, "destinationId", externalDestinationId);
     int destinationOrderId = DestinationOrder.FindRequiredKey(configurationId, "destinationOrderId", externalDestinationOrderId);
     object priceTypeCode = PriceType.FindOptionalKey(configurationId, "priceTypeCode", externalPriceTypeCode);
     object stateCode = State.FindOptionalKey(configurationId, "stateCode", externalStateCode);
     object statusCode = Status.FindOptionalKey(configurationId, "statusCode", externalStatusCode);
     object traderId = Trader.FindOptionalKey(configurationId, "traderId", externalTraderId);
     object timeInForceCode = TimeInForce.FindOptionalKey(configurationId, "timeInForceCode", externalTimeInForceCode);
     object workingOrderId = WorkingOrder.FindOptionalKey(configurationId, "workingOrderId", externalWorkingOrderId);
     // 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.DestinationOrderRow destinationOrderRow = destinationOrderTable.FindByDestinationOrderId(destinationOrderId);
     rowVersion = ((long)(destinationOrderRow[destinationOrderTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.DestinationOrder.Update(adoTransaction, sqlTransaction, ref rowVersion, canceledQuantity, canceledTime, createdTime, createdUserId, destinationId, destinationOrderId, null, isCanceledByUser, isHidden, limitPrice, modifiedTime, modifiedUserId, orderTypeCode, orderedQuantity, priceTypeCode, stateCode, statusCode, stopPrice, traderId, timeInForceCode, workingOrderId);
     // Return values.
     parameters["rowVersion"] = rowVersion;
 }
Esempio n. 3
0
 /// <summary>Finds a a DestinationOrder 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 DestinationOrder Table.
     ServerMarketData.DestinationOrderDataTable destinationOrderTable = ServerMarketData.DestinationOrder;
     // 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 = DestinationOrder.GetExternalKeyIndex(configurationId, parameterId);
     System.Data.DataView externalKeyView = DestinationOrder.externalKeyArray[externalKeyIndex];
     int recordIndex = externalKeyView.Find(new object[] {
                 externalId});
     if ((recordIndex == -1))
     {
         return int.MinValue;
     }
     return ((int)(externalKeyView[recordIndex].Row[destinationOrderTable.DestinationOrderIdColumn]));
 }
Esempio n. 4
0
 /// <summary>Archives a DestinationOrder 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 DestinationOrder Table.
     ServerMarketData.DestinationOrderDataTable destinationOrderTable = ServerMarketData.DestinationOrder;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     string externalDestinationOrderId = parameters["destinationOrderId"];
     // 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 destinationOrderId = DestinationOrder.FindRequiredKey(configurationId, "destinationOrderId", externalDestinationOrderId);
     // 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.DestinationOrderRow destinationOrderRow = destinationOrderTable.FindByDestinationOrderId(destinationOrderId);
     rowVersion = ((long)(destinationOrderRow[destinationOrderTable.RowVersionColumn]));
     // Call the internal method to complete the operation.
     MarkThree.Guardian.Core.DestinationOrder.Archive(adoTransaction, sqlTransaction, rowVersion, destinationOrderId);
 }
Esempio n. 5
0
        /// <summary>Archives a DestinationOrder 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="destinationOrderId">The value for the DestinationOrderId 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 destinationOrderId)
        {
            // Accessor for the DestinationOrder Table.
            ServerMarketData.DestinationOrderDataTable destinationOrderTable = ServerMarketData.DestinationOrder;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.DestinationOrderRow destinationOrderRow = destinationOrderTable.FindByDestinationOrderId(destinationOrderId);
            if ((destinationOrderRow == null))
            {
                throw new Exception(string.Format("The DestinationOrder table does not have an element identified by {0}", destinationOrderId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((destinationOrderRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < destinationOrderRow.GetExecutionRows().Length); index = (index + 1))
            {
                ServerMarketData.ExecutionRow childExecutionRow = destinationOrderRow.GetExecutionRows()[index];
                Execution.Archive(adoTransaction, sqlTransaction, childExecutionRow.RowVersion, childExecutionRow.ExecutionId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            destinationOrderRow[destinationOrderTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(destinationOrderRow);
            destinationOrderRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"DestinationOrder\" set \"IsArchived\" = 1 where \"DestinationOrderId\"=@destin" +
                                                   "ationOrderId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@destinationOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationOrderId));
            sqlCommand.ExecuteNonQuery();
        }
Esempio n. 6
0
        /// <summary>Updates a DestinationOrder 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="canceledQuantity">The value for the CanceledQuantity column.</param>
        /// <param name="canceledTime">The value for the CanceledTime column.</param>
        /// <param name="createdTime">The value for the CreatedTime column.</param>
        /// <param name="createdUserId">The value for the CreatedUserId column.</param>
        /// <param name="destinationId">The value for the DestinationId column.</param>
        /// <param name="destinationOrderId">The value for the DestinationOrderId column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="isCanceledByUser">The value for the IsCanceledByUser column.</param>
        /// <param name="isHidden">The value for the IsHidden column.</param>
        /// <param name="limitPrice">The value for the LimitPrice column.</param>
        /// <param name="modifiedTime">The value for the ModifiedTime column.</param>
        /// <param name="modifiedUserId">The value for the ModifiedUserId column.</param>
        /// <param name="orderTypeCode">The value for the OrderTypeCode column.</param>
        /// <param name="orderedQuantity">The value for the OrderedQuantity column.</param>
        /// <param name="priceTypeCode">The value for the PriceTypeCode column.</param>
        /// <param name="stateCode">The value for the StateCode column.</param>
        /// <param name="statusCode">The value for the StatusCode column.</param>
        /// <param name="stopPrice">The value for the StopPrice column.</param>
        /// <param name="traderId">The value for the TraderId column.</param>
        /// <param name="timeInForceCode">The value for the TimeInForceCode column.</param>
        /// <param name="workingOrderId">The value for the WorkingOrderId column.</param>
        public static void Update(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            object canceledQuantity,
            object canceledTime,
            object createdTime,
            object createdUserId,
            object destinationId,
            int destinationOrderId,
            object externalId0,
            object isCanceledByUser,
            object isHidden,
            object limitPrice,
            object modifiedTime,
            object modifiedUserId,
            object orderTypeCode,
            object orderedQuantity,
            object priceTypeCode,
            object stateCode,
            object statusCode,
            object stopPrice,
            object traderId,
            object timeInForceCode,
            object workingOrderId)
        {
            // Accessor for the DestinationOrder Table.
            ServerMarketData.DestinationOrderDataTable destinationOrderTable = ServerMarketData.DestinationOrder;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.DestinationOrderRow destinationOrderRow = destinationOrderTable.FindByDestinationOrderId(destinationOrderId);
            if ((destinationOrderRow == null))
            {
                throw new Exception(string.Format("The DestinationOrder table does not have an element identified by {0}", destinationOrderId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((destinationOrderRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((canceledQuantity == null))
            {
                canceledQuantity = destinationOrderRow[destinationOrderTable.CanceledQuantityColumn];
            }
            if ((canceledTime == null))
            {
                canceledTime = destinationOrderRow[destinationOrderTable.CanceledTimeColumn];
            }
            if ((createdTime == null))
            {
                createdTime = destinationOrderRow[destinationOrderTable.CreatedTimeColumn];
            }
            if ((createdUserId == null))
            {
                createdUserId = destinationOrderRow[destinationOrderTable.CreatedUserIdColumn];
            }
            if ((destinationId == null))
            {
                destinationId = destinationOrderRow[destinationOrderTable.DestinationIdColumn];
            }
            if ((externalId0 == null))
            {
                externalId0 = destinationOrderRow[destinationOrderTable.ExternalId0Column];
            }
            if ((isCanceledByUser == null))
            {
                isCanceledByUser = destinationOrderRow[destinationOrderTable.IsCanceledByUserColumn];
            }
            if ((isHidden == null))
            {
                isHidden = destinationOrderRow[destinationOrderTable.IsHiddenColumn];
            }
            if ((limitPrice == null))
            {
                limitPrice = destinationOrderRow[destinationOrderTable.LimitPriceColumn];
            }
            if ((modifiedTime == null))
            {
                modifiedTime = destinationOrderRow[destinationOrderTable.ModifiedTimeColumn];
            }
            if ((modifiedUserId == null))
            {
                modifiedUserId = destinationOrderRow[destinationOrderTable.ModifiedUserIdColumn];
            }
            if ((orderTypeCode == null))
            {
                orderTypeCode = destinationOrderRow[destinationOrderTable.OrderTypeCodeColumn];
            }
            if ((orderedQuantity == null))
            {
                orderedQuantity = destinationOrderRow[destinationOrderTable.OrderedQuantityColumn];
            }
            if ((priceTypeCode == null))
            {
                priceTypeCode = destinationOrderRow[destinationOrderTable.PriceTypeCodeColumn];
            }
            if ((stateCode == null))
            {
                stateCode = destinationOrderRow[destinationOrderTable.StateCodeColumn];
            }
            if ((statusCode == null))
            {
                statusCode = destinationOrderRow[destinationOrderTable.StatusCodeColumn];
            }
            if ((stopPrice == null))
            {
                stopPrice = destinationOrderRow[destinationOrderTable.StopPriceColumn];
            }
            if ((traderId == null))
            {
                traderId = destinationOrderRow[destinationOrderTable.TraderIdColumn];
            }
            if ((timeInForceCode == null))
            {
                timeInForceCode = destinationOrderRow[destinationOrderTable.TimeInForceCodeColumn];
            }
            if ((workingOrderId == null))
            {
                workingOrderId = destinationOrderRow[destinationOrderTable.WorkingOrderIdColumn];
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Update the record in the ADO database.
            destinationOrderRow[destinationOrderTable.RowVersionColumn]       = rowVersion;
            destinationOrderRow[destinationOrderTable.CanceledQuantityColumn] = canceledQuantity;
            destinationOrderRow[destinationOrderTable.CanceledTimeColumn]     = canceledTime;
            destinationOrderRow[destinationOrderTable.CreatedTimeColumn]      = createdTime;
            destinationOrderRow[destinationOrderTable.CreatedUserIdColumn]    = createdUserId;
            destinationOrderRow[destinationOrderTable.DestinationIdColumn]    = destinationId;
            destinationOrderRow[destinationOrderTable.ExternalId0Column]      = externalId0;
            destinationOrderRow[destinationOrderTable.IsCanceledByUserColumn] = isCanceledByUser;
            destinationOrderRow[destinationOrderTable.IsHiddenColumn]         = isHidden;
            destinationOrderRow[destinationOrderTable.LimitPriceColumn]       = limitPrice;
            destinationOrderRow[destinationOrderTable.ModifiedTimeColumn]     = modifiedTime;
            destinationOrderRow[destinationOrderTable.ModifiedUserIdColumn]   = modifiedUserId;
            destinationOrderRow[destinationOrderTable.OrderTypeCodeColumn]    = orderTypeCode;
            destinationOrderRow[destinationOrderTable.OrderedQuantityColumn]  = orderedQuantity;
            destinationOrderRow[destinationOrderTable.PriceTypeCodeColumn]    = priceTypeCode;
            destinationOrderRow[destinationOrderTable.StateCodeColumn]        = stateCode;
            destinationOrderRow[destinationOrderTable.StatusCodeColumn]       = statusCode;
            destinationOrderRow[destinationOrderTable.StopPriceColumn]        = stopPrice;
            destinationOrderRow[destinationOrderTable.TraderIdColumn]         = traderId;
            destinationOrderRow[destinationOrderTable.TimeInForceCodeColumn]  = timeInForceCode;
            destinationOrderRow[destinationOrderTable.WorkingOrderIdColumn]   = workingOrderId;
            adoTransaction.DataRows.Add(destinationOrderRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""DestinationOrder"" set ""RowVersion""=@rowVersion,""CanceledQuantity""=@canceledQuantity,""CanceledTime""=@canceledTime,""CreatedTime""=@createdTime,""CreatedUserId""=@createdUserId,""DestinationId""=@destinationId,""ExternalId0""=@externalId0,""IsCanceledByUser""=@isCanceledByUser,""IsHidden""=@isHidden,""LimitPrice""=@limitPrice,""ModifiedTime""=@modifiedTime,""ModifiedUserId""=@modifiedUserId,""OrderTypeCode""=@orderTypeCode,""OrderedQuantity""=@orderedQuantity,""PriceTypeCode""=@priceTypeCode,""StateCode""=@stateCode,""StatusCode""=@statusCode,""StopPrice""=@stopPrice,""TraderId""=@traderId,""TimeInForceCode""=@timeInForceCode,""WorkingOrderId""=@workingOrderId where ""DestinationOrderId""=@destinationOrderId");

            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("@canceledQuantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, canceledQuantity));
            sqlCommand.Parameters.Add(new SqlParameter("@canceledTime", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, canceledTime));
            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("@destinationId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationId));
            sqlCommand.Parameters.Add(new SqlParameter("@destinationOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationOrderId));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@isCanceledByUser", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isCanceledByUser));
            sqlCommand.Parameters.Add(new SqlParameter("@isHidden", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isHidden));
            sqlCommand.Parameters.Add(new SqlParameter("@limitPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, limitPrice));
            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("@orderTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, orderTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@orderedQuantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, orderedQuantity));
            sqlCommand.Parameters.Add(new SqlParameter("@priceTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, priceTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@stateCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, stateCode));
            sqlCommand.Parameters.Add(new SqlParameter("@statusCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, statusCode));
            sqlCommand.Parameters.Add(new SqlParameter("@stopPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, stopPrice));
            sqlCommand.Parameters.Add(new SqlParameter("@traderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, traderId));
            sqlCommand.Parameters.Add(new SqlParameter("@timeInForceCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, timeInForceCode));
            sqlCommand.Parameters.Add(new SqlParameter("@workingOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, workingOrderId));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }
Esempio n. 7
0
        /// <summary>Inserts a DestinationOrder record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="canceledQuantity">The value for the CanceledQuantity column.</param>
        /// <param name="canceledTime">The value for the CanceledTime column.</param>
        /// <param name="createdTime">The value for the CreatedTime column.</param>
        /// <param name="createdUserId">The value for the CreatedUserId column.</param>
        /// <param name="destinationId">The value for the DestinationId column.</param>
        /// <param name="externalId0">The value for the ExternalId0 column.</param>
        /// <param name="isCanceledByUser">The value for the IsCanceledByUser column.</param>
        /// <param name="isHidden">The value for the IsHidden column.</param>
        /// <param name="limitPrice">The value for the LimitPrice column.</param>
        /// <param name="modifiedTime">The value for the ModifiedTime column.</param>
        /// <param name="modifiedUserId">The value for the ModifiedUserId column.</param>
        /// <param name="orderTypeCode">The value for the OrderTypeCode column.</param>
        /// <param name="orderedQuantity">The value for the OrderedQuantity column.</param>
        /// <param name="priceTypeCode">The value for the PriceTypeCode column.</param>
        /// <param name="stateCode">The value for the StateCode column.</param>
        /// <param name="statusCode">The value for the StatusCode column.</param>
        /// <param name="stopPrice">The value for the StopPrice column.</param>
        /// <param name="traderId">The value for the TraderId column.</param>
        /// <param name="timeInForceCode">The value for the TimeInForceCode column.</param>
        /// <param name="workingOrderId">The value for the WorkingOrderId column.</param>
        public static int Insert(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            object canceledQuantity,
            object canceledTime,
            System.DateTime createdTime,
            int createdUserId,
            int destinationId,
            object externalId0,
            object isCanceledByUser,
            object isHidden,
            object limitPrice,
            System.DateTime modifiedTime,
            int modifiedUserId,
            int orderTypeCode,
            decimal orderedQuantity,
            int priceTypeCode,
            int stateCode,
            int statusCode,
            object stopPrice,
            object traderId,
            int timeInForceCode,
            int workingOrderId)
        {
            // Accessor for the DestinationOrder Table.
            ServerMarketData.DestinationOrderDataTable destinationOrderTable = ServerMarketData.DestinationOrder;
            // Apply Defaults
            if ((canceledQuantity == null))
            {
                canceledQuantity = 0m;
            }
            if ((canceledTime == null))
            {
                canceledTime = System.DBNull.Value;
            }
            if ((externalId0 == null))
            {
                externalId0 = System.DBNull.Value;
            }
            if ((isCanceledByUser == null))
            {
                isCanceledByUser = false;
            }
            if ((isHidden == null))
            {
                isHidden = false;
            }
            if ((limitPrice == null))
            {
                limitPrice = System.DBNull.Value;
            }
            if ((stopPrice == null))
            {
                stopPrice = System.DBNull.Value;
            }
            if ((traderId == null))
            {
                traderId = System.DBNull.Value;
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerMarketData.DestinationOrderRow destinationOrderRow = destinationOrderTable.NewDestinationOrderRow();
            destinationOrderRow[destinationOrderTable.RowVersionColumn]       = rowVersion;
            destinationOrderRow[destinationOrderTable.CanceledQuantityColumn] = canceledQuantity;
            destinationOrderRow[destinationOrderTable.CanceledTimeColumn]     = canceledTime;
            destinationOrderRow[destinationOrderTable.CreatedTimeColumn]      = createdTime;
            destinationOrderRow[destinationOrderTable.CreatedUserIdColumn]    = createdUserId;
            destinationOrderRow[destinationOrderTable.DestinationIdColumn]    = destinationId;
            destinationOrderRow[destinationOrderTable.ExternalId0Column]      = externalId0;
            destinationOrderRow[destinationOrderTable.IsCanceledByUserColumn] = isCanceledByUser;
            destinationOrderRow[destinationOrderTable.IsHiddenColumn]         = isHidden;
            destinationOrderRow[destinationOrderTable.LimitPriceColumn]       = limitPrice;
            destinationOrderRow[destinationOrderTable.ModifiedTimeColumn]     = modifiedTime;
            destinationOrderRow[destinationOrderTable.ModifiedUserIdColumn]   = modifiedUserId;
            destinationOrderRow[destinationOrderTable.OrderTypeCodeColumn]    = orderTypeCode;
            destinationOrderRow[destinationOrderTable.OrderedQuantityColumn]  = orderedQuantity;
            destinationOrderRow[destinationOrderTable.PriceTypeCodeColumn]    = priceTypeCode;
            destinationOrderRow[destinationOrderTable.StateCodeColumn]        = stateCode;
            destinationOrderRow[destinationOrderTable.StatusCodeColumn]       = statusCode;
            destinationOrderRow[destinationOrderTable.StopPriceColumn]        = stopPrice;
            destinationOrderRow[destinationOrderTable.TraderIdColumn]         = traderId;
            destinationOrderRow[destinationOrderTable.TimeInForceCodeColumn]  = timeInForceCode;
            destinationOrderRow[destinationOrderTable.WorkingOrderIdColumn]   = workingOrderId;
            destinationOrderTable.AddDestinationOrderRow(destinationOrderRow);
            adoTransaction.DataRows.Add(destinationOrderRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""DestinationOrder"" (""rowVersion"",""CanceledQuantity"",""CanceledTime"",""CreatedTime"",""CreatedUserId"",""DestinationId"",""DestinationOrderId"",""ExternalId0"",""IsCanceledByUser"",""IsHidden"",""LimitPrice"",""ModifiedTime"",""ModifiedUserId"",""OrderTypeCode"",""OrderedQuantity"",""PriceTypeCode"",""StateCode"",""StatusCode"",""StopPrice"",""TraderId"",""TimeInForceCode"",""WorkingOrderId"") values (@rowVersion,@canceledQuantity,@canceledTime,@createdTime,@createdUserId,@destinationId,@destinationOrderId,@externalId0,@isCanceledByUser,@isHidden,@limitPrice,@modifiedTime,@modifiedUserId,@orderTypeCode,@orderedQuantity,@priceTypeCode,@stateCode,@statusCode,@stopPrice,@traderId,@timeInForceCode,@workingOrderId)");

            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("@canceledQuantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, canceledQuantity));
            sqlCommand.Parameters.Add(new SqlParameter("@canceledTime", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, canceledTime));
            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("@destinationId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationId));
            sqlCommand.Parameters.Add(new SqlParameter("@destinationOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, destinationOrderRow[destinationOrderTable.DestinationOrderIdColumn]));
            sqlCommand.Parameters.Add(new SqlParameter("@externalId0", SqlDbType.NVarChar, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, externalId0));
            sqlCommand.Parameters.Add(new SqlParameter("@isCanceledByUser", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isCanceledByUser));
            sqlCommand.Parameters.Add(new SqlParameter("@isHidden", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isHidden));
            sqlCommand.Parameters.Add(new SqlParameter("@limitPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, limitPrice));
            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("@orderTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, orderTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@orderedQuantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, orderedQuantity));
            sqlCommand.Parameters.Add(new SqlParameter("@priceTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, priceTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@stateCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, stateCode));
            sqlCommand.Parameters.Add(new SqlParameter("@statusCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, statusCode));
            sqlCommand.Parameters.Add(new SqlParameter("@stopPrice", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, stopPrice));
            sqlCommand.Parameters.Add(new SqlParameter("@traderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, traderId));
            sqlCommand.Parameters.Add(new SqlParameter("@timeInForceCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, timeInForceCode));
            sqlCommand.Parameters.Add(new SqlParameter("@workingOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, workingOrderId));
            sqlCommand.ExecuteNonQuery();
            // Return Statements
            return(destinationOrderRow.DestinationOrderId);
        }
Esempio n. 8
0
        /// <summary>Inserts a DestinationOrder 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 DestinationOrder Table.
            ServerMarketData.DestinationOrderDataTable destinationOrderTable = ServerMarketData.DestinationOrder;
            // Extract the parameters from the command batch.
            AdoTransaction adoTransaction             = parameters["adoTransaction"];
            SqlTransaction sqlTransaction             = parameters["sqlTransaction"];
            object         configurationId            = parameters["configurationId"].Value;
            object         externalBlotterId          = parameters["blotterId"].Value;
            string         externalDestinationOrderId = parameters["destinationOrderId"];
            string         externalDestinationId      = parameters["destinationId"];
            object         externalId0   = parameters["externalId0"].Value;
            object         isAdvertised  = parameters["isAdvertised"].Value;
            object         isAutoExecute = parameters["isAutoExecute"].Value;
            object         isCanceled    = parameters["isCanceled"].Value;
            object         isSteppedIn   = parameters["isSteppedIn"].Value;

            System.Decimal orderedQuantity         = parameters["orderedQuantity"];
            string         externalOrderTypeCode   = parameters["orderTypeCode"];
            string         externalPriceTypeCode   = parameters["priceTypeCode"];
            object         receivedTime            = parameters["receivedTime"].Value;
            string         externalSecurityId      = parameters["securityId"];
            object         externalSettlementId    = parameters["settlementId"].Value;
            object         targetPrice             = parameters["targetPrice"].Value;
            string         externalTimeInForceCode = parameters["timeInForceCode"];
            object         uploadedTime            = parameters["uploadedTime"].Value;
            string         externalWorkingOrderId  = parameters["workingOrderId"];
            // 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;
            // Resolve External Identifiers
            object blotterId          = External.Blotter.FindOptionalKey(configurationId, "blotterId", externalBlotterId);
            int    destinationOrderId = External.DestinationOrder.FindKey(configurationId, "destinationOrderId", externalDestinationOrderId);
            int    orderTypeCode      = External.OrderType.FindRequiredKey(configurationId, "orderTypeCode", externalOrderTypeCode);
            int    destinationId      = External.Destination.FindRequiredKey(configurationId, "destinationId", externalDestinationId);
            int    priceTypeCode      = External.PriceType.FindRequiredKey(configurationId, "priceTypeCode", externalPriceTypeCode);
            int    securityId         = External.Security.FindRequiredKey(configurationId, "securityId", externalSecurityId);
            object settlementId       = External.Security.FindOptionalKey(configurationId, "settlementId", externalSettlementId);
            int    timeInForceCode    = External.TimeInForce.FindRequiredKey(configurationId, "timeInForceCode", externalTimeInForceCode);
            int    workingOrderId     = External.WorkingOrder.FindRequiredKey(configurationId, "workingOrderId", externalWorkingOrderId);

            // All parameters from the xml file arrive as strings.  Any required or optional parameter needs to be converted to a
            // native type here.
            decimal quantityOrdered = Convert.ToDecimal(parameters["quantity"].Value);

            // Optional Parameters
            object isHidden = parameters["isHidden"] is MissingParameter ? (object)null :
                              Convert.ToBoolean(parameters["isHidden"].Value);
            object limitPrice = parameters["limitPrice"] is MissingParameter ? (object)null :
                                Convert.ToDecimal(parameters["limitPrice"].Value);
            object stopPrice = parameters["stopPrice"] is MissingParameter ? (object)null :
                               Convert.ToDecimal(parameters["stopPrice"].Value);

            // Time stamps and user stamps
            int      createdUserId  = ServerMarketData.UserId;
            DateTime createdTime    = DateTime.Now;
            int      modifiedUserId = ServerMarketData.UserId;
            DateTime modifiedTime   = DateTime.Now;
            int      statusCode     = Status.New;
            int      stateCode      = State.Initial;

            // 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 (destinationOrderId == 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.DestinationOrder.GetExternalKeyIndex(configurationId, "destinationOrderId");
                object[] externalIdArray  = new object[1];
                externalIdArray[externalKeyIndex] = externalDestinationOrderId;
                externalId0 = externalIdArray[0];

                // Call the internal method to complete the operation.
                MarkThree.Guardian.Core.DestinationOrder.Insert(adoTransaction, sqlTransaction, ref rowVersion, null, null, createdTime,
                                                                createdUserId, destinationId, externalId0, null, isHidden, limitPrice, modifiedTime, modifiedUserId,
                                                                orderTypeCode, orderedQuantity, priceTypeCode, stateCode, statusCode, stopPrice, createdUserId, timeInForceCode,
                                                                workingOrderId);
            }
            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.DestinationOrderRow destinationOrderRow = destinationOrderTable.FindByDestinationOrderId((int)destinationOrderId);
                rowVersion = ((long)(destinationOrderRow[destinationOrderTable.RowVersionColumn]));

                // Call the internal method to complete the operation.
                MarkThree.Guardian.Core.DestinationOrder.Update(adoTransaction, sqlTransaction, ref rowVersion, null, null, createdTime,
                                                                createdUserId, destinationId, (int)destinationOrderId, externalId0, null, isHidden, limitPrice, modifiedTime,
                                                                modifiedUserId, orderedQuantity, orderTypeCode, priceTypeCode, stateCode, statusCode, stopPrice, modifiedUserId,
                                                                timeInForceCode, workingOrderId);
            }

            // Return values.
            parameters["rowVersion"] = rowVersion;
        }
Esempio n. 9
0
 /// <summary>Loads a DestinationOrder record using Metadata Parameters.</summary>
 /// <param name="transaction">Contains the parameters and exceptions for this command.</param>
 public static void Load(ParameterList parameters)
 {
     // Accessor for the DestinationOrder Table.
     ServerMarketData.DestinationOrderDataTable destinationOrderTable = ServerMarketData.DestinationOrder;
     // Extract the parameters from the command batch.
     AdoTransaction adoTransaction = parameters["adoTransaction"];
     SqlTransaction sqlTransaction = parameters["sqlTransaction"];
     object configurationId = parameters["configurationId"].Value;
     object canceledQuantity = parameters["canceledQuantity"].Value;
     object canceledTime = parameters["canceledTime"].Value;
     System.DateTime createdTime = parameters["createdTime"];
     int createdUserId = parameters["createdUserId"];
     string externalDestinationId = parameters["destinationId"];
     object externalDestinationOrderId = parameters["destinationOrderId"].Value;
     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"];
     string externalPriceTypeCode = parameters["priceTypeCode"];
     string externalStateCode = parameters["stateCode"];
     string externalStatusCode = parameters["statusCode"];
     object stopPrice = parameters["stopPrice"].Value;
     object externalTraderId = parameters["traderId"].Value;
     string externalTimeInForceCode = parameters["timeInForceCode"];
     string externalWorkingOrderId = parameters["workingOrderId"];
     // 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;
     // Resolve External Identifiers
     int destinationId = Destination.FindRequiredKey(configurationId, "destinationId", externalDestinationId);
     int destinationOrderId = DestinationOrder.FindKey(configurationId, "destinationOrderId", externalDestinationOrderId);
     int priceTypeCode = PriceType.FindRequiredKey(configurationId, "priceTypeCode", externalPriceTypeCode);
     int stateCode = State.FindRequiredKey(configurationId, "stateCode", externalStateCode);
     int statusCode = Status.FindRequiredKey(configurationId, "statusCode", externalStatusCode);
     object traderId = Trader.FindOptionalKey(configurationId, "traderId", externalTraderId);
     int timeInForceCode = TimeInForce.FindRequiredKey(configurationId, "timeInForceCode", externalTimeInForceCode);
     int workingOrderId = WorkingOrder.FindRequiredKey(configurationId, "workingOrderId", externalWorkingOrderId);
     // 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 ((destinationOrderId == 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 = DestinationOrder.GetExternalKeyIndex(configurationId, "destinationOrderId");
         object[] externalIdArray = new object[1];
         externalIdArray[externalKeyIndex] = externalDestinationOrderId;
         externalId0 = externalIdArray[0];
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.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);
     }
     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.DestinationOrderRow destinationOrderRow = destinationOrderTable.FindByDestinationOrderId(destinationOrderId);
         rowVersion = ((long)(destinationOrderRow[destinationOrderTable.RowVersionColumn]));
         // Call the internal method to complete the operation.
         MarkThree.Guardian.Core.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;
 }