Exemple #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 new static void ArchiveChildren(AdoTransaction adoTransaction)
 {
     // These table lock(s) are required for the 'Archive' operation.
     adoTransaction.LockRequests.AddWriterLock(ServerMarketData.BrokerLock);
     Execution.Archive(adoTransaction);
     BrokerAccount.Archive(adoTransaction);
     ClearingBroker.ArchiveChildren(adoTransaction);
 }
Exemple #2
0
        /// <summary>Inserts a BrokerAccount record using Metadata Parameters.</summary>
        /// <param name="parameters">Contains the metadata parameters.</param>
        public static void Archive(ParameterList parameters)
        {
            // Extract the parameters from the command batch.
            AdoTransaction adoTransaction  = parameters["adoTransaction"];
            SqlTransaction sqlTransaction  = parameters["sqlTransaction"];
            long           rowVersion      = parameters["rowVersion"];
            int            brokerAccountId = parameters["brokerAccountId"];

            // Call the internal method to complete the operation.
            BrokerAccount.Archive(adoTransaction, sqlTransaction, rowVersion, brokerAccountId);
        }
Exemple #3
0
        /// <summary>Inserts a BrokerAccount record using Metadata Parameters.</summary>
        /// <param name="parameters">Contains the metadata parameters.</param>
        public static void Update(ParameterList parameters)
        {
            // Extract the parameters from the command batch.
            AdoTransaction adoTransaction  = parameters["adoTransaction"];
            SqlTransaction sqlTransaction  = parameters["sqlTransaction"];
            long           rowVersion      = parameters["rowVersion"];
            int            brokerAccountId = parameters["brokerAccountId"];
            object         brokerId        = parameters["brokerId"].Value;
            object         description     = parameters["description"].Value;
            object         externalId0     = parameters["externalId0"].Value;
            object         externalId1     = parameters["externalId1"].Value;
            object         externalId2     = parameters["externalId2"].Value;
            object         externalId3     = parameters["externalId3"].Value;
            object         mnemonic        = parameters["mnemonic"].Value;
            object         traderId        = parameters["traderId"].Value;

            // Call the internal method to complete the operation.
            BrokerAccount.Update(adoTransaction, sqlTransaction, ref rowVersion, brokerAccountId, brokerId, description, externalId0, externalId1, externalId2, externalId3, mnemonic, traderId);
            // Return values.
            parameters["rowVersion"] = rowVersion;
        }
Exemple #4
0
        /// <summary>Inserts a BrokerAccount record using Metadata Parameters.</summary>
        /// <param name="parameters">Contains the metadata parameters.</param>
        public static void Insert(ParameterList parameters)
        {
            // Extract the parameters from the command batch.
            AdoTransaction adoTransaction = parameters["adoTransaction"];
            SqlTransaction sqlTransaction = parameters["sqlTransaction"];
            int            brokerId       = parameters["brokerId"];
            string         description    = parameters["description"];
            object         externalId0    = parameters["externalId0"].Value;
            object         externalId1    = parameters["externalId1"].Value;
            object         externalId2    = parameters["externalId2"].Value;
            object         externalId3    = parameters["externalId3"].Value;
            string         mnemonic       = parameters["mnemonic"];
            int            traderId       = parameters["traderId"];
            // The rowVersion is passed back to the caller in the event it's needed for additional commands in the batch.
            long rowVersion = long.MinValue;
            // Call the internal method to complete the operation.
            int brokerAccountId = BrokerAccount.Insert(adoTransaction, sqlTransaction, ref rowVersion, brokerId, description, externalId0, externalId1, externalId2, externalId3, mnemonic, traderId);

            // Return values.
            parameters["rowVersion"] = rowVersion;
            parameters.Return        = brokerAccountId;
        }
Exemple #5
0
        /// <summary>ArchiveChildrens a Broker 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="brokerId">The value for the BrokerId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        internal new static void ArchiveChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int brokerId)
        {
            // Accessor for the Broker Table.
            ServerMarketData.BrokerDataTable brokerTable = ServerMarketData.Broker;
            // This record can be used to iterate through all the children.
            ServerMarketData.BrokerRow brokerRow = brokerTable.FindByBrokerId(brokerId);
            // Archive the child records.
            for (int index = 0; (index < brokerRow.GetExecutionRows().Length); index = (index + 1))
            {
                ServerMarketData.ExecutionRow childExecutionRow = brokerRow.GetExecutionRows()[index];
                Execution.Archive(adoTransaction, sqlTransaction, childExecutionRow.RowVersion, childExecutionRow.ExecutionId);
            }
            for (int index = 0; (index < brokerRow.GetBrokerAccountRows().Length); index = (index + 1))
            {
                ServerMarketData.BrokerAccountRow childBrokerAccountRow = brokerRow.GetBrokerAccountRows()[index];
                BrokerAccount.Archive(adoTransaction, sqlTransaction, childBrokerAccountRow.RowVersion, childBrokerAccountRow.BrokerAccountId);
            }
            for (int index = 0; (index < brokerRow.GetClearingBrokerRows().Length); index = (index + 1))
            {
                ServerMarketData.ClearingBrokerRow childClearingBrokerRow = brokerRow.GetClearingBrokerRows()[index];
                ClearingBroker.ArchiveChildren(adoTransaction, sqlTransaction, childClearingBrokerRow.RowVersion, childClearingBrokerRow.ClearingBrokerId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            brokerRow[brokerTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(brokerRow);
            brokerRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Broker\" set \"IsArchived\" = 1 where \"BrokerId\"=@brokerId");

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