Beispiel #1
0
        /// <summary>Archives a Allocation 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="allocationId">The value for the AllocationId 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 allocationId)
        {
            // Accessor for the Allocation Table.
            ServerMarketData.AllocationDataTable allocationTable = ServerMarketData.Allocation;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.AllocationRow allocationRow = allocationTable.FindByAllocationId(allocationId);
            if ((allocationRow == null))
            {
                throw new Exception(string.Format("The Allocation table does not have an element identified by {0}", allocationId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((allocationRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            allocationRow[allocationTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(allocationRow);
            allocationRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Allocation\" set \"IsArchived\" = 1 where \"AllocationId\"=@allocationId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@allocationId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, allocationId));
            sqlCommand.ExecuteNonQuery();
        }
Beispiel #2
0
        /// <summary>Updates a Allocation 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="accountId">The value for the AccountId column.</param>
        /// <param name="accruedInterest">The value for the AccruedInterest column.</param>
        /// <param name="allocationId">The value for the AllocationId 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="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="positionTypeCode">The value for the PositionTypeCode column.</param>
        /// <param name="price">The value for the Price column.</param>
        /// <param name="quantity">The value for the Quantity column.</param>
        /// <param name="securityId">The value for the SecurityId column.</param>
        /// <param name="settlementDate">The value for the SettlementDate column.</param>
        /// <param name="settlementId">The value for the SettlementId 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>
        /// <param name="workingOrderId">The value for the WorkingOrderId column.</param>
        public static void Update(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            object accountId,
            object accruedInterest,
            int allocationId,
            object commission,
            object createdTime,
            object createdUserId,
            object modifiedTime,
            object modifiedUserId,
            object orderTypeCode,
            object positionTypeCode,
            object price,
            object quantity,
            object securityId,
            object settlementDate,
            object settlementId,
            object tradeDate,
            object userFee0,
            object userFee1,
            object userFee2,
            object userFee3,
            object workingOrderId)
        {
            // Accessor for the Allocation Table.
            ServerMarketData.AllocationDataTable allocationTable = ServerMarketData.Allocation;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.AllocationRow allocationRow = allocationTable.FindByAllocationId(allocationId);
            if ((allocationRow == null))
            {
                throw new Exception(string.Format("The Allocation table does not have an element identified by {0}", allocationId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((allocationRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((accountId == null))
            {
                accountId = allocationRow[allocationTable.AccountIdColumn];
            }
            if ((accruedInterest == null))
            {
                accruedInterest = allocationRow[allocationTable.AccruedInterestColumn];
            }
            if ((commission == null))
            {
                commission = allocationRow[allocationTable.CommissionColumn];
            }
            if ((createdTime == null))
            {
                createdTime = allocationRow[allocationTable.CreatedTimeColumn];
            }
            if ((createdUserId == null))
            {
                createdUserId = allocationRow[allocationTable.CreatedUserIdColumn];
            }
            if ((modifiedTime == null))
            {
                modifiedTime = allocationRow[allocationTable.ModifiedTimeColumn];
            }
            if ((modifiedUserId == null))
            {
                modifiedUserId = allocationRow[allocationTable.ModifiedUserIdColumn];
            }
            if ((orderTypeCode == null))
            {
                orderTypeCode = allocationRow[allocationTable.OrderTypeCodeColumn];
            }
            if ((positionTypeCode == null))
            {
                positionTypeCode = allocationRow[allocationTable.PositionTypeCodeColumn];
            }
            if ((price == null))
            {
                price = allocationRow[allocationTable.PriceColumn];
            }
            if ((quantity == null))
            {
                quantity = allocationRow[allocationTable.QuantityColumn];
            }
            if ((securityId == null))
            {
                securityId = allocationRow[allocationTable.SecurityIdColumn];
            }
            if ((settlementDate == null))
            {
                settlementDate = allocationRow[allocationTable.SettlementDateColumn];
            }
            if ((settlementId == null))
            {
                settlementId = allocationRow[allocationTable.SettlementIdColumn];
            }
            if ((tradeDate == null))
            {
                tradeDate = allocationRow[allocationTable.TradeDateColumn];
            }
            if ((userFee0 == null))
            {
                userFee0 = allocationRow[allocationTable.UserFee0Column];
            }
            if ((userFee1 == null))
            {
                userFee1 = allocationRow[allocationTable.UserFee1Column];
            }
            if ((userFee2 == null))
            {
                userFee2 = allocationRow[allocationTable.UserFee2Column];
            }
            if ((userFee3 == null))
            {
                userFee3 = allocationRow[allocationTable.UserFee3Column];
            }
            if ((workingOrderId == null))
            {
                workingOrderId = allocationRow[allocationTable.WorkingOrderIdColumn];
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Update the record in the ADO database.
            allocationRow[allocationTable.RowVersionColumn]       = rowVersion;
            allocationRow[allocationTable.AccountIdColumn]        = accountId;
            allocationRow[allocationTable.AccruedInterestColumn]  = accruedInterest;
            allocationRow[allocationTable.CommissionColumn]       = commission;
            allocationRow[allocationTable.CreatedTimeColumn]      = createdTime;
            allocationRow[allocationTable.CreatedUserIdColumn]    = createdUserId;
            allocationRow[allocationTable.ModifiedTimeColumn]     = modifiedTime;
            allocationRow[allocationTable.ModifiedUserIdColumn]   = modifiedUserId;
            allocationRow[allocationTable.OrderTypeCodeColumn]    = orderTypeCode;
            allocationRow[allocationTable.PositionTypeCodeColumn] = positionTypeCode;
            allocationRow[allocationTable.PriceColumn]            = price;
            allocationRow[allocationTable.QuantityColumn]         = quantity;
            allocationRow[allocationTable.SecurityIdColumn]       = securityId;
            allocationRow[allocationTable.SettlementDateColumn]   = settlementDate;
            allocationRow[allocationTable.SettlementIdColumn]     = settlementId;
            allocationRow[allocationTable.TradeDateColumn]        = tradeDate;
            allocationRow[allocationTable.UserFee0Column]         = userFee0;
            allocationRow[allocationTable.UserFee1Column]         = userFee1;
            allocationRow[allocationTable.UserFee2Column]         = userFee2;
            allocationRow[allocationTable.UserFee3Column]         = userFee3;
            allocationRow[allocationTable.WorkingOrderIdColumn]   = workingOrderId;
            adoTransaction.DataRows.Add(allocationRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""Allocation"" set ""RowVersion""=@rowVersion,""AccountId""=@accountId,""AccruedInterest""=@accruedInterest,""Commission""=@commission,""CreatedTime""=@createdTime,""CreatedUserId""=@createdUserId,""ModifiedTime""=@modifiedTime,""ModifiedUserId""=@modifiedUserId,""OrderTypeCode""=@orderTypeCode,""PositionTypeCode""=@positionTypeCode,""Price""=@price,""Quantity""=@quantity,""SecurityId""=@securityId,""SettlementDate""=@settlementDate,""SettlementId""=@settlementId,""TradeDate""=@tradeDate,""UserFee0""=@userFee0,""UserFee1""=@userFee1,""UserFee2""=@userFee2,""UserFee3""=@userFee3,""WorkingOrderId""=@workingOrderId where ""AllocationId""=@allocationId");

            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("@accountId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accountId));
            sqlCommand.Parameters.Add(new SqlParameter("@accruedInterest", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accruedInterest));
            sqlCommand.Parameters.Add(new SqlParameter("@allocationId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, allocationId));
            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("@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("@positionTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, positionTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@price", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, price));
            sqlCommand.Parameters.Add(new SqlParameter("@quantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, quantity));
            sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId));
            sqlCommand.Parameters.Add(new SqlParameter("@settlementDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementDate));
            sqlCommand.Parameters.Add(new SqlParameter("@settlementId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementId));
            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.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();
        }
Beispiel #3
0
        /// <summary>Inserts a Allocation record.</summary>
        /// <param name="transaction">Commits or rejects a set of commands as a unit</param>
        /// <param name="accountId">The value for the AccountId column.</param>
        /// <param name="accruedInterest">The value for the AccruedInterest 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="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="positionTypeCode">The value for the PositionTypeCode column.</param>
        /// <param name="price">The value for the Price column.</param>
        /// <param name="quantity">The value for the Quantity column.</param>
        /// <param name="securityId">The value for the SecurityId column.</param>
        /// <param name="settlementDate">The value for the SettlementDate column.</param>
        /// <param name="settlementId">The value for the SettlementId 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>
        /// <param name="workingOrderId">The value for the WorkingOrderId column.</param>
        public static int Insert(
            AdoTransaction adoTransaction,
            SqlTransaction sqlTransaction,
            ref long rowVersion,
            int accountId,
            decimal accruedInterest,
            decimal commission,
            System.DateTime createdTime,
            int createdUserId,
            System.DateTime modifiedTime,
            int modifiedUserId,
            int orderTypeCode,
            int positionTypeCode,
            decimal price,
            decimal quantity,
            int securityId,
            System.DateTime settlementDate,
            int settlementId,
            System.DateTime tradeDate,
            decimal userFee0,
            decimal userFee1,
            decimal userFee2,
            decimal userFee3,
            int workingOrderId)
        {
            // Accessor for the Allocation Table.
            ServerMarketData.AllocationDataTable allocationTable = ServerMarketData.Allocation;
            // Apply Defaults
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerMarketData.AllocationRow allocationRow = allocationTable.NewAllocationRow();
            allocationRow[allocationTable.RowVersionColumn]       = rowVersion;
            allocationRow[allocationTable.AccountIdColumn]        = accountId;
            allocationRow[allocationTable.AccruedInterestColumn]  = accruedInterest;
            allocationRow[allocationTable.CommissionColumn]       = commission;
            allocationRow[allocationTable.CreatedTimeColumn]      = createdTime;
            allocationRow[allocationTable.CreatedUserIdColumn]    = createdUserId;
            allocationRow[allocationTable.ModifiedTimeColumn]     = modifiedTime;
            allocationRow[allocationTable.ModifiedUserIdColumn]   = modifiedUserId;
            allocationRow[allocationTable.OrderTypeCodeColumn]    = orderTypeCode;
            allocationRow[allocationTable.PositionTypeCodeColumn] = positionTypeCode;
            allocationRow[allocationTable.PriceColumn]            = price;
            allocationRow[allocationTable.QuantityColumn]         = quantity;
            allocationRow[allocationTable.SecurityIdColumn]       = securityId;
            allocationRow[allocationTable.SettlementDateColumn]   = settlementDate;
            allocationRow[allocationTable.SettlementIdColumn]     = settlementId;
            allocationRow[allocationTable.TradeDateColumn]        = tradeDate;
            allocationRow[allocationTable.UserFee0Column]         = userFee0;
            allocationRow[allocationTable.UserFee1Column]         = userFee1;
            allocationRow[allocationTable.UserFee2Column]         = userFee2;
            allocationRow[allocationTable.UserFee3Column]         = userFee3;
            allocationRow[allocationTable.WorkingOrderIdColumn]   = workingOrderId;
            allocationTable.AddAllocationRow(allocationRow);
            adoTransaction.DataRows.Add(allocationRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""Allocation"" (""rowVersion"",""AccountId"",""AccruedInterest"",""AllocationId"",""Commission"",""CreatedTime"",""CreatedUserId"",""ModifiedTime"",""ModifiedUserId"",""OrderTypeCode"",""PositionTypeCode"",""Price"",""Quantity"",""SecurityId"",""SettlementDate"",""SettlementId"",""TradeDate"",""UserFee0"",""UserFee1"",""UserFee2"",""UserFee3"",""WorkingOrderId"") values (@rowVersion,@accountId,@accruedInterest,@allocationId,@commission,@createdTime,@createdUserId,@modifiedTime,@modifiedUserId,@orderTypeCode,@positionTypeCode,@price,@quantity,@securityId,@settlementDate,@settlementId,@tradeDate,@userFee0,@userFee1,@userFee2,@userFee3,@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("@accountId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accountId));
            sqlCommand.Parameters.Add(new SqlParameter("@accruedInterest", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, accruedInterest));
            sqlCommand.Parameters.Add(new SqlParameter("@allocationId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, allocationRow[allocationTable.AllocationIdColumn]));
            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("@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("@positionTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, positionTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@price", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, price));
            sqlCommand.Parameters.Add(new SqlParameter("@quantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, quantity));
            sqlCommand.Parameters.Add(new SqlParameter("@securityId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, securityId));
            sqlCommand.Parameters.Add(new SqlParameter("@settlementDate", SqlDbType.DateTime, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementDate));
            sqlCommand.Parameters.Add(new SqlParameter("@settlementId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, settlementId));
            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.Parameters.Add(new SqlParameter("@workingOrderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, workingOrderId));
            sqlCommand.ExecuteNonQuery();
            // Return Statements
            return(allocationRow.AllocationId);
        }