示例#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.CountryLock);
     AccountBase.ArchiveChildren(adoTransaction);
     Holiday.Archive(adoTransaction);
     Province.Archive(adoTransaction);
     Security.ArchiveChildren(adoTransaction);
 }
示例#2
0
        /// <summary>Inserts a Holiday 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            holidayId      = parameters["holidayId"];

            // Call the internal method to complete the operation.
            Holiday.Archive(adoTransaction, sqlTransaction, rowVersion, holidayId);
        }
示例#3
0
        /// <summary>Archives a Country 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="countryId">The value for the CountryId 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 countryId)
        {
            // Accessor for the Country Table.
            ServerMarketData.CountryDataTable countryTable = ServerMarketData.Country;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.CountryRow countryRow = countryTable.FindByCountryId(countryId);
            if ((countryRow == null))
            {
                throw new Exception(string.Format("The Country table does not have an element identified by {0}", countryId));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((countryRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < countryRow.GetAccountBaseRows().Length); index = (index + 1))
            {
                ServerMarketData.AccountBaseRow childAccountBaseRow = countryRow.GetAccountBaseRows()[index];
                AccountBase.ArchiveChildren(adoTransaction, sqlTransaction, childAccountBaseRow.RowVersion, childAccountBaseRow.AccountBaseId);
            }
            for (int index = 0; (index < countryRow.GetHolidayRows().Length); index = (index + 1))
            {
                ServerMarketData.HolidayRow childHolidayRow = countryRow.GetHolidayRows()[index];
                Holiday.Archive(adoTransaction, sqlTransaction, childHolidayRow.RowVersion, childHolidayRow.HolidayId);
            }
            for (int index = 0; (index < countryRow.GetProvinceRows().Length); index = (index + 1))
            {
                ServerMarketData.ProvinceRow childProvinceRow = countryRow.GetProvinceRows()[index];
                Province.Archive(adoTransaction, sqlTransaction, childProvinceRow.RowVersion, childProvinceRow.ProvinceId);
            }
            for (int index = 0; (index < countryRow.GetSecurityRows().Length); index = (index + 1))
            {
                ServerMarketData.SecurityRow childSecurityRow = countryRow.GetSecurityRows()[index];
                Security.ArchiveChildren(adoTransaction, sqlTransaction, childSecurityRow.RowVersion, childSecurityRow.SecurityId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            countryRow[countryTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(countryRow);
            countryRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Country\" set \"IsArchived\" = 1 where \"CountryId\"=@countryId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@countryId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, countryId));
            sqlCommand.ExecuteNonQuery();
        }
示例#4
0
        /// <summary>Archives a HolidayType 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="holidayTypeCode">The value for the HolidayTypeCode 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 holidayTypeCode)
        {
            // Accessor for the HolidayType Table.
            ServerMarketData.HolidayTypeDataTable holidayTypeTable = ServerMarketData.HolidayType;
            // Rule #1: Make sure the record exists before updating it.
            ServerMarketData.HolidayTypeRow holidayTypeRow = holidayTypeTable.FindByHolidayTypeCode(holidayTypeCode);
            if ((holidayTypeRow == null))
            {
                throw new Exception(string.Format("The HolidayType table does not have an element identified by {0}", holidayTypeCode));
            }
            // Rule #2: Optimistic Concurrency Check
            if ((holidayTypeRow.RowVersion != rowVersion))
            {
                throw new System.Exception("This record is busy.  Please try again later.");
            }
            // Archive the child records.
            for (int index = 0; (index < holidayTypeRow.GetHolidayRows().Length); index = (index + 1))
            {
                ServerMarketData.HolidayRow childHolidayRow = holidayTypeRow.GetHolidayRows()[index];
                Holiday.Archive(adoTransaction, sqlTransaction, childHolidayRow.RowVersion, childHolidayRow.HolidayId);
            }
            // Increment the row version
            rowVersion = ServerMarketData.RowVersion.Increment();
            // Delete the record in the ADO database.
            holidayTypeRow[holidayTypeTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(holidayTypeRow);
            holidayTypeRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"HolidayType\" set \"IsArchived\" = 1 where \"HolidayTypeCode\"=@holidayTypeCod" +
                                                   "e");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@holidayTypeCode", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, holidayTypeCode));
            sqlCommand.ExecuteNonQuery();
        }
示例#5
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.HolidayTypeLock);
     Holiday.Archive(adoTransaction);
 }