コード例 #1
0
        /// <summary>Archives a Placement 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="placementId">The value for the PlacementId 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 placementId)
        {
            // Accessor for the Placement Table.
            ServerDataModel.PlacementDataTable placementTable = ServerDataModel.Placement;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.PlacementRow placementRow = placementTable.FindByPlacementId(placementId);
            if ((placementRow == null))
            {
                throw new Exception(string.Format("The Placement table does not have an element identified by {0}", placementId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((placementRow.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.
            placementRow[placementTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(placementRow);
            placementRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Placement\" set \"IsArchived\" = 1 where \"PlacementId\"=@placementId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@placementId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, placementId));
            sqlCommand.ExecuteNonQuery();
        }
コード例 #2
0
        /// <summary>Inserts a Placement 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="timeInForceCode">The value for the TimeInForceCode column.</param>
        /// <param name="orderTypeCode">The value for the OrderTypeCode column.</param>
        /// <param name="isDeleted">The value for the IsDeleted column.</param>
        /// <param name="isRouted">The value for the IsRouted column.</param>
        /// <param name="quantity">The value for the Quantity column.</param>
        /// <param name="price1">The value for the Price1 column.</param>
        /// <param name="price2">The value for the Price2 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,
            int timeInForceCode,
            int orderTypeCode,
            object isDeleted,
            object isRouted,
            decimal quantity,
            object price1,
            object price2,
            System.DateTime createdTime,
            int createdUserId,
            System.DateTime modifiedTime,
            int modifiedUserId)
        {
            // Accessor for the Placement Table.
            ServerDataModel.PlacementDataTable placementTable = ServerDataModel.Placement;
            // Apply Defaults
            if ((isDeleted == null))
            {
                isDeleted = false;
            }
            if ((isRouted == null))
            {
                isRouted = false;
            }
            if ((price1 == null))
            {
                price1 = System.DBNull.Value;
            }
            if ((price2 == null))
            {
                price2 = System.DBNull.Value;
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Insert the record into the ADO database.
            ServerDataModel.PlacementRow placementRow = placementTable.NewPlacementRow();
            placementRow[placementTable.RowVersionColumn]      = rowVersion;
            placementRow[placementTable.BlockOrderIdColumn]    = blockOrderId;
            placementRow[placementTable.BrokerIdColumn]        = brokerId;
            placementRow[placementTable.TimeInForceCodeColumn] = timeInForceCode;
            placementRow[placementTable.OrderTypeCodeColumn]   = orderTypeCode;
            placementRow[placementTable.IsDeletedColumn]       = isDeleted;
            placementRow[placementTable.IsRoutedColumn]        = isRouted;
            placementRow[placementTable.QuantityColumn]        = quantity;
            placementRow[placementTable.Price1Column]          = price1;
            placementRow[placementTable.Price2Column]          = price2;
            placementRow[placementTable.CreatedTimeColumn]     = createdTime;
            placementRow[placementTable.CreatedUserIdColumn]   = createdUserId;
            placementRow[placementTable.ModifiedTimeColumn]    = modifiedTime;
            placementRow[placementTable.ModifiedUserIdColumn]  = modifiedUserId;
            placementTable.AddPlacementRow(placementRow);
            adoTransaction.DataRows.Add(placementRow);
            // Insert the record into the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"insert ""Placement"" (""rowVersion"",""PlacementId"",""BlockOrderId"",""BrokerId"",""TimeInForceCode"",""OrderTypeCode"",""IsDeleted"",""IsRouted"",""Quantity"",""Price1"",""Price2"",""CreatedTime"",""CreatedUserId"",""ModifiedTime"",""ModifiedUserId"") values (@rowVersion,@placementId,@blockOrderId,@brokerId,@timeInForceCode,@orderTypeCode,@isDeleted,@isRouted,@quantity,@price1,@price2,@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("@placementId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, placementRow[placementTable.PlacementIdColumn]));
            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("@timeInForceCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, timeInForceCode));
            sqlCommand.Parameters.Add(new SqlParameter("@orderTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, orderTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@isDeleted", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isDeleted));
            sqlCommand.Parameters.Add(new SqlParameter("@isRouted", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isRouted));
            sqlCommand.Parameters.Add(new SqlParameter("@quantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, quantity));
            sqlCommand.Parameters.Add(new SqlParameter("@price1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, price1));
            sqlCommand.Parameters.Add(new SqlParameter("@price2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, price2));
            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(placementRow.PlacementId);
        }
コード例 #3
0
        /// <summary>Updates a Placement 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="placementId">The value for the PlacementId column.</param>
        /// <param name="blockOrderId">The value for the BlockOrderId column.</param>
        /// <param name="brokerId">The value for the BrokerId column.</param>
        /// <param name="timeInForceCode">The value for the TimeInForceCode column.</param>
        /// <param name="orderTypeCode">The value for the OrderTypeCode column.</param>
        /// <param name="isDeleted">The value for the IsDeleted column.</param>
        /// <param name="isRouted">The value for the IsRouted column.</param>
        /// <param name="quantity">The value for the Quantity column.</param>
        /// <param name="price1">The value for the Price1 column.</param>
        /// <param name="price2">The value for the Price2 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 placementId,
            object blockOrderId,
            object brokerId,
            object timeInForceCode,
            object orderTypeCode,
            object isDeleted,
            object isRouted,
            object quantity,
            object price1,
            object price2,
            object createdTime,
            object createdUserId,
            object modifiedTime,
            object modifiedUserId)
        {
            // Accessor for the Placement Table.
            ServerDataModel.PlacementDataTable placementTable = ServerDataModel.Placement;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.PlacementRow placementRow = placementTable.FindByPlacementId(placementId);
            if ((placementRow == null))
            {
                throw new Exception(string.Format("The Placement table does not have an element identified by {0}", placementId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((placementRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Apply Defaults
            if ((blockOrderId == null))
            {
                blockOrderId = placementRow[placementTable.BlockOrderIdColumn];
            }
            if ((brokerId == null))
            {
                brokerId = placementRow[placementTable.BrokerIdColumn];
            }
            if ((timeInForceCode == null))
            {
                timeInForceCode = placementRow[placementTable.TimeInForceCodeColumn];
            }
            if ((orderTypeCode == null))
            {
                orderTypeCode = placementRow[placementTable.OrderTypeCodeColumn];
            }
            if ((isDeleted == null))
            {
                isDeleted = placementRow[placementTable.IsDeletedColumn];
            }
            if ((isRouted == null))
            {
                isRouted = placementRow[placementTable.IsRoutedColumn];
            }
            if ((quantity == null))
            {
                quantity = placementRow[placementTable.QuantityColumn];
            }
            if ((price1 == null))
            {
                price1 = placementRow[placementTable.Price1Column];
            }
            if ((price2 == null))
            {
                price2 = placementRow[placementTable.Price2Column];
            }
            if ((createdTime == null))
            {
                createdTime = placementRow[placementTable.CreatedTimeColumn];
            }
            if ((createdUserId == null))
            {
                createdUserId = placementRow[placementTable.CreatedUserIdColumn];
            }
            if ((modifiedTime == null))
            {
                modifiedTime = placementRow[placementTable.ModifiedTimeColumn];
            }
            if ((modifiedUserId == null))
            {
                modifiedUserId = placementRow[placementTable.ModifiedUserIdColumn];
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Update the record in the ADO database.
            placementRow[placementTable.RowVersionColumn]      = rowVersion;
            placementRow[placementTable.BlockOrderIdColumn]    = blockOrderId;
            placementRow[placementTable.BrokerIdColumn]        = brokerId;
            placementRow[placementTable.TimeInForceCodeColumn] = timeInForceCode;
            placementRow[placementTable.OrderTypeCodeColumn]   = orderTypeCode;
            placementRow[placementTable.IsDeletedColumn]       = isDeleted;
            placementRow[placementTable.IsRoutedColumn]        = isRouted;
            placementRow[placementTable.QuantityColumn]        = quantity;
            placementRow[placementTable.Price1Column]          = price1;
            placementRow[placementTable.Price2Column]          = price2;
            placementRow[placementTable.CreatedTimeColumn]     = createdTime;
            placementRow[placementTable.CreatedUserIdColumn]   = createdUserId;
            placementRow[placementTable.ModifiedTimeColumn]    = modifiedTime;
            placementRow[placementTable.ModifiedUserIdColumn]  = modifiedUserId;
            adoTransaction.DataRows.Add(placementRow);
            // Update the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand(@"update ""Placement"" set ""RowVersion""=@rowVersion,""BlockOrderId""=@blockOrderId,""BrokerId""=@brokerId,""TimeInForceCode""=@timeInForceCode,""OrderTypeCode""=@orderTypeCode,""IsDeleted""=@isDeleted,""IsRouted""=@isRouted,""Quantity""=@quantity,""Price1""=@price1,""Price2""=@price2,""CreatedTime""=@createdTime,""CreatedUserId""=@createdUserId,""ModifiedTime""=@modifiedTime,""ModifiedUserId""=@modifiedUserId where ""PlacementId""=@placementId");

            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("@placementId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, placementId));
            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("@timeInForceCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, timeInForceCode));
            sqlCommand.Parameters.Add(new SqlParameter("@orderTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, orderTypeCode));
            sqlCommand.Parameters.Add(new SqlParameter("@isDeleted", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isDeleted));
            sqlCommand.Parameters.Add(new SqlParameter("@isRouted", SqlDbType.Bit, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, isRouted));
            sqlCommand.Parameters.Add(new SqlParameter("@quantity", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, quantity));
            sqlCommand.Parameters.Add(new SqlParameter("@price1", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, price1));
            sqlCommand.Parameters.Add(new SqlParameter("@price2", SqlDbType.Decimal, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, price2));
            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();
        }