예제 #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.
            ServerDataModel.ExecutionDataTable executionTable = ServerDataModel.Execution;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.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.
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            executionRow[executionTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(executionRow);
            executionRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Execution\" set \"IsArchived\" = 1 where \"ExecutionId\"=@executionId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@executionId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionId));
            sqlCommand.ExecuteNonQuery();
        }
예제 #2
0
        /// <summary>Inserts a Execution record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="blockOrderId">The value for the BlockOrderId column.</param>
        /// <param name="brokerId">The value for the BrokerId column.</param>
        /// <param name="isDeleted">The value for the IsDeleted column.</param>
        /// <param name="quantity">The value for the Quantity column.</param>
        /// <param name="price">The value for the Price column.</param>
        /// <param name="commission">The value for the Commission column.</param>
        /// <param name="accruedInterest">The value for the AccruedInterest 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>
        /// <param name="tradeDate">The value for the TradeDate column.</param>
        /// <param name="settlementDate">The value for the SettlementDate column.</param>
        /// <param name="createdTime">The value for the CreatedTime column.</param>
        /// <param name="createdUserId">The value for the CreatedUserId column.</param>
        /// <param name="modifiedTime">The value for the ModifiedTime column.</param>
        /// <param name="modifiedUserId">The value for the ModifiedUserId column.</param>
        public static int Insert(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            int blockOrderId,
            int brokerId,
            object isDeleted,
            decimal quantity,
            decimal price,
            object commission,
            object accruedInterest,
            object userFee0,
            object userFee1,
            object userFee2,
            object userFee3,
            System.DateTime tradeDate,
            System.DateTime settlementDate,
            object createdTime,
            object createdUserId,
            object modifiedTime,
            object modifiedUserId)
        {
            // Accessor for the Execution Table.
            ServerDataModel.ExecutionDataTable executionTable = ServerDataModel.Execution;
            // Apply Defaults
            if ((isDeleted == null))
            {
                isDeleted = false;
            }
            if ((commission == null))
            {
                commission = 0.0m;
            }
            if ((accruedInterest == null))
            {
                accruedInterest = 0.0m;
            }
            if ((userFee0 == null))
            {
                userFee0 = 0.0m;
            }
            if ((userFee1 == null))
            {
                userFee1 = 0.0m;
            }
            if ((userFee2 == null))
            {
                userFee2 = 0.0m;
            }
            if ((userFee3 == null))
            {
                userFee3 = 0.0m;
            }
            if ((createdTime == null))
            {
                createdTime = System.DBNull.Value;
            }
            if ((createdUserId == null))
            {
                createdUserId = System.DBNull.Value;
            }
            if ((modifiedTime == null))
            {
                modifiedTime = System.DBNull.Value;
            }
            if ((modifiedUserId == null))
            {
                modifiedUserId = System.DBNull.Value;
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerDataModel.ExecutionRow executionRow = executionTable.NewExecutionRow();
            executionRow[executionTable.RowVersionColumn]      = rowVersion;
            executionRow[executionTable.BlockOrderIdColumn]    = blockOrderId;
            executionRow[executionTable.BrokerIdColumn]        = brokerId;
            executionRow[executionTable.IsDeletedColumn]       = isDeleted;
            executionRow[executionTable.QuantityColumn]        = quantity;
            executionRow[executionTable.PriceColumn]           = price;
            executionRow[executionTable.CommissionColumn]      = commission;
            executionRow[executionTable.AccruedInterestColumn] = accruedInterest;
            executionRow[executionTable.UserFee0Column]        = userFee0;
            executionRow[executionTable.UserFee1Column]        = userFee1;
            executionRow[executionTable.UserFee2Column]        = userFee2;
            executionRow[executionTable.UserFee3Column]        = userFee3;
            executionRow[executionTable.TradeDateColumn]       = tradeDate;
            executionRow[executionTable.SettlementDateColumn]  = settlementDate;
            executionRow[executionTable.CreatedTimeColumn]     = createdTime;
            executionRow[executionTable.CreatedUserIdColumn]   = createdUserId;
            executionRow[executionTable.ModifiedTimeColumn]    = modifiedTime;
            executionRow[executionTable.ModifiedUserIdColumn]  = modifiedUserId;
            executionTable.AddExecutionRow(executionRow);
            adoTransaction.DataRows.Add(executionRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""Execution"" (""rowVersion"",""ExecutionId"",""BlockOrderId"",""BrokerId"",""IsDeleted"",""Quantity"",""Price"",""Commission"",""AccruedInterest"",""UserFee0"",""UserFee1"",""UserFee2"",""UserFee3"",""TradeDate"",""SettlementDate"",""CreatedTime"",""CreatedUserId"",""ModifiedTime"",""ModifiedUserId"") values (@rowVersion,@executionId,@blockOrderId,@brokerId,@isDeleted,@quantity,@price,@commission,@accruedInterest,@userFee0,@userFee1,@userFee2,@userFee3,@tradeDate,@settlementDate,@createdTime,@createdUserId,@modifiedTime,@modifiedUserId)");

            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("@executionId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionRow[executionTable.ExecutionIdColumn]));
            sqlCommand.Parameters.Add(new SqlParameter("@blockOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, blockOrderId));
            sqlCommand.Parameters.Add(new SqlParameter("@brokerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerId));
            sqlCommand.Parameters.Add(new SqlParameter("@isDeleted", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isDeleted));
            sqlCommand.Parameters.Add(new SqlParameter("@quantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, quantity));
            sqlCommand.Parameters.Add(new SqlParameter("@price", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, price));
            sqlCommand.Parameters.Add(new SqlParameter("@commission", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, commission));
            sqlCommand.Parameters.Add(new SqlParameter("@accruedInterest", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accruedInterest));
            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.Parameters.Add(new SqlParameter("@tradeDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, tradeDate));
            sqlCommand.Parameters.Add(new SqlParameter("@settlementDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementDate));
            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("@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.ExecuteNonQuery();
            // Return Statements
            return(executionRow.ExecutionId);
        }
예제 #3
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="executionId">The value for the ExecutionId column.</param>
        /// <param name="blockOrderId">The value for the BlockOrderId column.</param>
        /// <param name="brokerId">The value for the BrokerId column.</param>
        /// <param name="isDeleted">The value for the IsDeleted column.</param>
        /// <param name="quantity">The value for the Quantity column.</param>
        /// <param name="price">The value for the Price column.</param>
        /// <param name="commission">The value for the Commission column.</param>
        /// <param name="accruedInterest">The value for the AccruedInterest 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>
        /// <param name="tradeDate">The value for the TradeDate column.</param>
        /// <param name="settlementDate">The value for the SettlementDate column.</param>
        /// <param name="createdTime">The value for the CreatedTime column.</param>
        /// <param name="createdUserId">The value for the CreatedUserId column.</param>
        /// <param name="modifiedTime">The value for the ModifiedTime column.</param>
        /// <param name="modifiedUserId">The value for the ModifiedUserId column.</param>
        public static void Update(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            int executionId,
            object blockOrderId,
            object brokerId,
            object isDeleted,
            object quantity,
            object price,
            object commission,
            object accruedInterest,
            object userFee0,
            object userFee1,
            object userFee2,
            object userFee3,
            object tradeDate,
            object settlementDate,
            object createdTime,
            object createdUserId,
            object modifiedTime,
            object modifiedUserId)
        {
            // Accessor for the Execution Table.
            ServerDataModel.ExecutionDataTable executionTable = ServerDataModel.Execution;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.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 ((blockOrderId == null))
            {
                blockOrderId = executionRow[executionTable.BlockOrderIdColumn];
            }
            if ((brokerId == null))
            {
                brokerId = executionRow[executionTable.BrokerIdColumn];
            }
            if ((isDeleted == null))
            {
                isDeleted = executionRow[executionTable.IsDeletedColumn];
            }
            if ((quantity == null))
            {
                quantity = executionRow[executionTable.QuantityColumn];
            }
            if ((price == null))
            {
                price = executionRow[executionTable.PriceColumn];
            }
            if ((commission == null))
            {
                commission = executionRow[executionTable.CommissionColumn];
            }
            if ((accruedInterest == null))
            {
                accruedInterest = executionRow[executionTable.AccruedInterestColumn];
            }
            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];
            }
            if ((tradeDate == null))
            {
                tradeDate = executionRow[executionTable.TradeDateColumn];
            }
            if ((settlementDate == null))
            {
                settlementDate = executionRow[executionTable.SettlementDateColumn];
            }
            if ((createdTime == null))
            {
                createdTime = executionRow[executionTable.CreatedTimeColumn];
            }
            if ((createdUserId == null))
            {
                createdUserId = executionRow[executionTable.CreatedUserIdColumn];
            }
            if ((modifiedTime == null))
            {
                modifiedTime = executionRow[executionTable.ModifiedTimeColumn];
            }
            if ((modifiedUserId == null))
            {
                modifiedUserId = executionRow[executionTable.ModifiedUserIdColumn];
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Update the record in the ADO database.
            executionRow[executionTable.RowVersionColumn]      = rowVersion;
            executionRow[executionTable.BlockOrderIdColumn]    = blockOrderId;
            executionRow[executionTable.BrokerIdColumn]        = brokerId;
            executionRow[executionTable.IsDeletedColumn]       = isDeleted;
            executionRow[executionTable.QuantityColumn]        = quantity;
            executionRow[executionTable.PriceColumn]           = price;
            executionRow[executionTable.CommissionColumn]      = commission;
            executionRow[executionTable.AccruedInterestColumn] = accruedInterest;
            executionRow[executionTable.UserFee0Column]        = userFee0;
            executionRow[executionTable.UserFee1Column]        = userFee1;
            executionRow[executionTable.UserFee2Column]        = userFee2;
            executionRow[executionTable.UserFee3Column]        = userFee3;
            executionRow[executionTable.TradeDateColumn]       = tradeDate;
            executionRow[executionTable.SettlementDateColumn]  = settlementDate;
            executionRow[executionTable.CreatedTimeColumn]     = createdTime;
            executionRow[executionTable.CreatedUserIdColumn]   = createdUserId;
            executionRow[executionTable.ModifiedTimeColumn]    = modifiedTime;
            executionRow[executionTable.ModifiedUserIdColumn]  = modifiedUserId;
            adoTransaction.DataRows.Add(executionRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""Execution"" set ""RowVersion""=@rowVersion,""BlockOrderId""=@blockOrderId,""BrokerId""=@brokerId,""IsDeleted""=@isDeleted,""Quantity""=@quantity,""Price""=@price,""Commission""=@commission,""AccruedInterest""=@accruedInterest,""UserFee0""=@userFee0,""UserFee1""=@userFee1,""UserFee2""=@userFee2,""UserFee3""=@userFee3,""TradeDate""=@tradeDate,""SettlementDate""=@settlementDate,""CreatedTime""=@createdTime,""CreatedUserId""=@createdUserId,""ModifiedTime""=@modifiedTime,""ModifiedUserId""=@modifiedUserId 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("@executionId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, executionId));
            sqlCommand.Parameters.Add(new SqlParameter("@blockOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, blockOrderId));
            sqlCommand.Parameters.Add(new SqlParameter("@brokerId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, brokerId));
            sqlCommand.Parameters.Add(new SqlParameter("@isDeleted", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isDeleted));
            sqlCommand.Parameters.Add(new SqlParameter("@quantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, quantity));
            sqlCommand.Parameters.Add(new SqlParameter("@price", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, price));
            sqlCommand.Parameters.Add(new SqlParameter("@commission", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, commission));
            sqlCommand.Parameters.Add(new SqlParameter("@accruedInterest", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accruedInterest));
            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.Parameters.Add(new SqlParameter("@tradeDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, tradeDate));
            sqlCommand.Parameters.Add(new SqlParameter("@settlementDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementDate));
            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("@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));
            // Update the record in the SQL database.
            sqlCommand.ExecuteNonQuery();
        }