Esempio n. 1
0
        private static void RestorePageRevisionsForPage(ArchiveBE[] archivedRevs, Title newTitle, uint transactionId, bool minorChange, DateTime utcTimestamp)
        {
            // add the most recent archive entry to the pages table
            // NOTE:  this will preserve the page id if it was saved with the archive or create a new page id if it is not available
            ArchiveBE mostRecentArchiveRev = archivedRevs[archivedRevs.Length - 1];
            PageBE    restoredPage         = null;

            if (0 < archivedRevs.Length)
            {
                restoredPage           = new PageBE();
                restoredPage.Title     = newTitle;
                restoredPage.Revision  = mostRecentArchiveRev.Revision;
                restoredPage.MinorEdit = mostRecentArchiveRev.MinorEdit;
                bool conflict;
                PageBL.Save(restoredPage, null, mostRecentArchiveRev.Comment, mostRecentArchiveRev.Text, mostRecentArchiveRev.ContentType, mostRecentArchiveRev.Title.DisplayName, mostRecentArchiveRev.Language, -1, null, mostRecentArchiveRev.TimeStamp, mostRecentArchiveRev.LastPageId, false, false, null, false, out conflict);
                RecentChangeBL.AddRestorePageRecentChange(utcTimestamp, restoredPage, DekiContext.Current.User, DekiResources.UNDELETED_ARTICLE(restoredPage.Title.AsPrefixedUserFriendlyPath()), minorChange, transactionId);
            }

            // add all other archive entries to the old table
            // NOTE:  this will preserve the old ids if they were saved with the archive or create new old ids if not available
            for (int i = 0; i < archivedRevs.Length - 1; i++)
            {
                ArchiveBE archivedRev = archivedRevs[i];
                PageBE    currentPage = new PageBE();
                currentPage.Title = newTitle;
                if (i < archivedRevs.Length - 1)
                {
                    ParserResult parserResult = DekiXmlParser.ParseSave(currentPage, archivedRev.ContentType, currentPage.Language, archivedRev.Text, -1, null, false, null);
                    currentPage.SetText(parserResult.BodyText);
                    currentPage.ContentType = parserResult.ContentType;
                    currentPage.UserID      = archivedRev.UserID;
                    currentPage.TimeStamp   = archivedRev.TimeStamp;
                    currentPage.MinorEdit   = archivedRev.MinorEdit;
                    currentPage.Comment     = archivedRev.Comment;
                    currentPage.Language    = archivedRev.Language;
                    currentPage.IsHidden    = archivedRev.IsHidden;
                    currentPage.Revision    = archivedRev.Revision;
                    currentPage.ID          = restoredPage.ID;
                    PageBL.InsertOld(currentPage, archivedRev.OldId);
                }
            }
        }