Пример #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.Add(new TableWriterRequest(ServerDataModel.Country));
     Account.ArchiveChildren(adoTransaction);
     Security.ArchiveChildren(adoTransaction);
     Holiday.Archive(adoTransaction);
     Province.Archive(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.
            ServerDataModel.CountryDataTable countryTable = ServerDataModel.Country;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.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.GetAccountRows().Length); index = (index + 1))
            {
                ServerDataModel.AccountRow childAccountRow = countryRow.GetAccountRows()[index];
                Account.ArchiveChildren(adoTransaction, sqlTransaction, childAccountRow.RowVersion, childAccountRow.AccountId);
            }
            for (int index = 0; (index < countryRow.GetSecurityRows().Length); index = (index + 1))
            {
                ServerDataModel.SecurityRow childSecurityRow = countryRow.GetSecurityRows()[index];
                Security.ArchiveChildren(adoTransaction, sqlTransaction, childSecurityRow.RowVersion, childSecurityRow.SecurityId);
            }
            for (int index = 0; (index < countryRow.GetHolidayRows().Length); index = (index + 1))
            {
                ServerDataModel.HolidayRow childHolidayRow = countryRow.GetHolidayRows()[index];
                Holiday.Archive(adoTransaction, sqlTransaction, childHolidayRow.RowVersion, childHolidayRow.HolidayId);
            }
            for (int index = 0; (index < countryRow.GetProvinceRows().Length); index = (index + 1))
            {
                ServerDataModel.ProvinceRow childProvinceRow = countryRow.GetProvinceRows()[index];
                Province.Archive(adoTransaction, sqlTransaction, childProvinceRow.RowVersion, childProvinceRow.ProvinceId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.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.
            ServerDataModel.HolidayTypeDataTable holidayTypeTable = ServerDataModel.HolidayType;
            // Rule #1: Make sure the record exists before updating it.
            ServerDataModel.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))
            {
                ServerDataModel.HolidayRow childHolidayRow = holidayTypeRow.GetHolidayRows()[index];
                Holiday.Archive(adoTransaction, sqlTransaction, childHolidayRow.RowVersion, childHolidayRow.HolidayId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.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.Add(new TableWriterRequest(ServerDataModel.HolidayType));
     Holiday.Archive(adoTransaction);
 }