Ejemplo n.º 1
0
        /// <summary>ArchiveChildrens a Folder 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="folderId">The value for the FolderId column.</param>
        /// <param name="archive">true to archive the object, false to unarchive it.</param>
        internal static void ArchiveChildren(AdoTransaction adoTransaction, SqlTransaction sqlTransaction, long rowVersion, int folderId)
        {
            // Accessor for the Folder Table.
            ServerDataModel.FolderDataTable folderTable = ServerDataModel.Folder;
            // This record can be used to iterate through all the children.
            ServerDataModel.FolderRow folderRow = folderTable.FindByFolderId(folderId);
            // Archive the child records.
            for (int index = 0; (index < folderRow.GetSystemFolderRows().Length); index = (index + 1))
            {
                ServerDataModel.SystemFolderRow childSystemFolderRow = folderRow.GetSystemFolderRows()[index];
                SystemFolder.ArchiveChildren(adoTransaction, sqlTransaction, childSystemFolderRow.RowVersion, childSystemFolderRow.SystemFolderId);
            }
            // Increment the row version
            rowVersion = ServerDataModel.RowVersion.Increment();
            // Delete the record in the ADO database.
            folderRow[folderTable.RowVersionColumn] = rowVersion;
            adoTransaction.DataRows.Add(folderRow);
            folderRow.Delete();
            // Archive the record in the SQL database.
            SqlCommand sqlCommand = new SqlCommand("update \"Folder\" set \"IsArchived\" = 1 where \"FolderId\"=@folderId");

            sqlCommand.Connection  = sqlTransaction.Connection;
            sqlCommand.Transaction = sqlTransaction;
            sqlCommand.Parameters.Add(new SqlParameter("@folderId", SqlDbType.Int, 0, ParameterDirection.Input, false, 0, 0, null, DataRowVersion.Current, folderId));
            sqlCommand.ExecuteNonQuery();
        }
Ejemplo 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 static void ArchiveChildren(AdoTransaction adoTransaction)
 {
     // These table lock(s) are required for the 'Archive' operation.
     adoTransaction.LockRequests.Add(new TableWriterRequest(ServerDataModel.Folder));
     SystemFolder.ArchiveChildren(adoTransaction);
 }