Esempio n. 1
0
        /// <summary>ArchiveChildrens a Source 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="sourceId">The value for the SourceId 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 sourceId)
        {
            // Accessor for the Source Table.
            ServerMarketData.SourceDataTable sourceTable = ServerMarketData.Source;
            // This record can be used to iterate through all the children.
            ServerMarketData.SourceRow sourceRow = sourceTable.FindBySourceId(sourceId);
            // Archive the child records.
            for (int index = 0; (index < sourceRow.GetBrokerRows().Length); index = (index + 1))
            {
                ServerMarketData.BrokerRow childBrokerRow = sourceRow.GetBrokerRows()[index];
                Broker.ArchiveChildren(adoTransaction, sqlTransaction, childBrokerRow.RowVersion, childBrokerRow.BrokerId);
            }
            for (int index = 0; (index < sourceRow.GetInstitutionRows().Length); index = (index + 1))
            {
                ServerMarketData.InstitutionRow childInstitutionRow = sourceRow.GetInstitutionRows()[index];
                Institution.ArchiveChildren(adoTransaction, sqlTransaction, childInstitutionRow.RowVersion, childInstitutionRow.InstitutionId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            sourceRow[sourceTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(sourceRow);
            sourceRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Source\" set \"IsArchived\" = 1 where \"SourceId\"=@sourceId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@sourceId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, sourceId));
            sqlCommand.ExecuteNonQuery();
        }
Esempio n. 2
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.SourceLock);
     Broker.ArchiveChildren(adoTransaction);
     Institution.ArchiveChildren(adoTransaction);
 }