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>
 public static void Archive(AdoTransaction adoTransaction)
 {
     // These table lock(s) are required for the 'Archive' operation.
     adoTransaction.LockRequests.AddWriterLock(ServerMarketData.VolumeCategoryLock);
     Security.ArchiveChildren(adoTransaction);
     TraderVolumeSetting.Archive(adoTransaction);
 }
Exemple #2
0
        /// <summary>Inserts a TraderVolumeSetting 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            traderVolumeSettingId = parameters["traderVolumeSettingId"];

            // Call the internal method to complete the operation.
            TraderVolumeSetting.Archive(adoTransaction, sqlTransaction, rowVersion, traderVolumeSettingId);
        }
Exemple #3
0
        /// <summary>Archives a VolumeCategory 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="volumeCategoryId">The value for the VolumeCategoryId 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 volumeCategoryId)
        {
            // Accessor for the VolumeCategory Table.
            ServerMarketData.VolumeCategoryDataTable volumeCategoryTable = ServerMarketData.VolumeCategory;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.VolumeCategoryRow volumeCategoryRow = volumeCategoryTable.FindByVolumeCategoryId(volumeCategoryId);
            if ((volumeCategoryRow == null))
            {
                throw new Exception(string.Format("The VolumeCategory table does not have an element identified by {0}", volumeCategoryId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((volumeCategoryRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < volumeCategoryRow.GetSecurityRows().Length); index = (index + 1))
            {
                ServerMarketData.SecurityRow childSecurityRow = volumeCategoryRow.GetSecurityRows()[index];
                Security.ArchiveChildren(adoTransaction, sqlTransaction, childSecurityRow.RowVersion, childSecurityRow.SecurityId);
            }
            for (int index = 0; (index < volumeCategoryRow.GetTraderVolumeSettingRows().Length); index = (index + 1))
            {
                ServerMarketData.TraderVolumeSettingRow childTraderVolumeSettingRow = volumeCategoryRow.GetTraderVolumeSettingRows()[index];
                TraderVolumeSetting.Archive(adoTransaction, sqlTransaction, childTraderVolumeSettingRow.RowVersion, childTraderVolumeSettingRow.TraderVolumeSettingId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            volumeCategoryRow[volumeCategoryTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(volumeCategoryRow);
            volumeCategoryRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"VolumeCategory\" set \"IsArchived\" = 1 where \"VolumeCategoryId\"=@volumeCate" +
                                                   "goryId");

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