示例#1
0
 /// <summary>Collects the table lock request(s) for an Update operation</summary>
 /// <param name="adoTransaction">A list of locks required for this operation.</param>
 internal static void ArchiveChildren(AdoTransaction adoTransaction)
 {
     // These table lock(s) are required for the 'Archive' operation.
     adoTransaction.LockRequests.AddWriterLock(ServerMarketData.UserLock);
     AccountBase.ArchiveChildren(adoTransaction);
     Allocation.Archive(adoTransaction);
     ComplianceOfficer.ArchiveChildren(adoTransaction);
     Execution.Archive(adoTransaction);
     SourceOrder.Archive(adoTransaction);
     Trader.ArchiveChildren(adoTransaction);
     WorkingOrder.Archive(adoTransaction);
 }
示例#2
0
        /// <summary>ArchiveChildrens a User 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="userId">The value for the UserId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        internal static void ArchiveChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int userId)
        {
            // Accessor for the User Table.
            ServerMarketData.UserDataTable userTable = ServerMarketData.User;
            // This record can be used to iterate through all the children.
            ServerMarketData.UserRow userRow = userTable.FindByUserId(userId);
            // Archive the child records.
            for (int index = 0; (index < userRow.GetAccountBaseRows().Length); index = (index + 1))
            {
                ServerMarketData.AccountBaseRow childAccountBaseRow = userRow.GetAccountBaseRows()[index];
                AccountBase.ArchiveChildren(adoTransaction, sqlTransaction, childAccountBaseRow.RowVersion, childAccountBaseRow.AccountBaseId);
            }
            for (int index = 0; (index < userRow.GetAllocationRowsByUserAllocationCreatedUserId().Length); index = (index + 1))
            {
                ServerMarketData.AllocationRow childAllocationRow = userRow.GetAllocationRowsByUserAllocationCreatedUserId()[index];
                Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
            }
            for (int index = 0; (index < userRow.GetAllocationRowsByUserAllocationModifiedUserId().Length); index = (index + 1))
            {
                ServerMarketData.AllocationRow childAllocationRow = userRow.GetAllocationRowsByUserAllocationModifiedUserId()[index];
                Allocation.Archive(adoTransaction, sqlTransaction, childAllocationRow.RowVersion, childAllocationRow.AllocationId);
            }
            for (int index = 0; (index < userRow.GetComplianceOfficerRows().Length); index = (index + 1))
            {
                ServerMarketData.ComplianceOfficerRow childComplianceOfficerRow = userRow.GetComplianceOfficerRows()[index];
                ComplianceOfficer.ArchiveChildren(adoTransaction, sqlTransaction, childComplianceOfficerRow.RowVersion, childComplianceOfficerRow.ComplianceOfficerId);
            }
            for (int index = 0; (index < userRow.GetExecutionRowsByUserExecutionCreatedUserId().Length); index = (index + 1))
            {
                ServerMarketData.ExecutionRow childExecutionRow = userRow.GetExecutionRowsByUserExecutionCreatedUserId()[index];
                Execution.Archive(adoTransaction, sqlTransaction, childExecutionRow.RowVersion, childExecutionRow.ExecutionId);
            }
            for (int index = 0; (index < userRow.GetExecutionRowsByUserExecutionModifiedUserId().Length); index = (index + 1))
            {
                ServerMarketData.ExecutionRow childExecutionRow = userRow.GetExecutionRowsByUserExecutionModifiedUserId()[index];
                Execution.Archive(adoTransaction, sqlTransaction, childExecutionRow.RowVersion, childExecutionRow.ExecutionId);
            }
            for (int index = 0; (index < userRow.GetSourceOrderRowsByUserSourceOrderCreatedUserId().Length); index = (index + 1))
            {
                ServerMarketData.SourceOrderRow childSourceOrderRow = userRow.GetSourceOrderRowsByUserSourceOrderCreatedUserId()[index];
                SourceOrder.Archive(adoTransaction, sqlTransaction, childSourceOrderRow.RowVersion, childSourceOrderRow.SourceOrderId);
            }
            for (int index = 0; (index < userRow.GetSourceOrderRowsByUserSourceOrderModifiedUserId().Length); index = (index + 1))
            {
                ServerMarketData.SourceOrderRow childSourceOrderRow = userRow.GetSourceOrderRowsByUserSourceOrderModifiedUserId()[index];
                SourceOrder.Archive(adoTransaction, sqlTransaction, childSourceOrderRow.RowVersion, childSourceOrderRow.SourceOrderId);
            }
            for (int index = 0; (index < userRow.GetTraderRows().Length); index = (index + 1))
            {
                ServerMarketData.TraderRow childTraderRow = userRow.GetTraderRows()[index];
                Trader.ArchiveChildren(adoTransaction, sqlTransaction, childTraderRow.RowVersion, childTraderRow.TraderId);
            }
            for (int index = 0; (index < userRow.GetWorkingOrderRowsByUserWorkingOrderCreatedUserId().Length); index = (index + 1))
            {
                ServerMarketData.WorkingOrderRow childWorkingOrderRow = userRow.GetWorkingOrderRowsByUserWorkingOrderCreatedUserId()[index];
                WorkingOrder.Archive(adoTransaction, sqlTransaction, childWorkingOrderRow.RowVersion, childWorkingOrderRow.WorkingOrderId);
            }
            for (int index = 0; (index < userRow.GetWorkingOrderRowsByUserWorkingOrderModifiedUserId().Length); index = (index + 1))
            {
                ServerMarketData.WorkingOrderRow childWorkingOrderRow = userRow.GetWorkingOrderRowsByUserWorkingOrderModifiedUserId()[index];
                WorkingOrder.Archive(adoTransaction, sqlTransaction, childWorkingOrderRow.RowVersion, childWorkingOrderRow.WorkingOrderId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            userRow[userTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(userRow);
            userRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"User\" set \"IsArchived\" = 1 where \"UserId\"=@userId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@userId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, userId));
            sqlCommand.ExecuteNonQuery();
        }