Пример #1
0
        protected void btnSacuvaj_Click(object sender, EventArgs e)
        {
            ekogradnjaBE.Page page = new ekogradnjaBE.Page();
            page.IdPage      = int.Parse(txtIdPage.Text);
            page.Title       = txtTitle.Text;
            page.Description = txtDescription.Text;
            page.Keywords    = txtKeywords.Text;
            page.Content     = txtContent.Text;
            page.Url         = txtUrl.Text;

            PageBL.Save(page, true);
        }
Пример #2
0
        public void RestoreAttachment(ResourceBE attachmentToRestore, PageBE toPage, DateTime timestamp, uint transactionId)
        {
            if (toPage == null || toPage.ID == 0)
            {
                ArchiveBE archivesMatchingPageId = _session.Archive_GetPageHeadById(attachmentToRestore.ParentPageId.Value);
                if (archivesMatchingPageId == null)
                {
                    throw new AttachmentRestoreFailedNoParentFatalException();
                }
                else
                {
                    toPage = PageBL.GetPageByTitle(archivesMatchingPageId.Title);
                    if (0 == toPage.ID)
                    {
                        PageBL.Save(toPage, _resources.Localize(DekiResources.RESTORE_ATTACHMENT_NEW_PAGE_TEXT()), DekiMimeType.DEKI_TEXT, null);
                    }
                }
            }

            string filename = attachmentToRestore.Name;

            //Check for name conflicts on target page
            ResourceBE conflictingFile = GetPageAttachment(toPage.ID, filename);

            if (conflictingFile != null)
            {
                //rename the restored file
                filename        = string.Format("{0}(restored {1}){2}", attachmentToRestore.FilenameWithoutExtension, DateTime.Now.ToString("g"), string.IsNullOrEmpty(attachmentToRestore.FilenameExtension) ? string.Empty : "." + attachmentToRestore.FilenameExtension);
                conflictingFile = GetPageAttachment(toPage.ID, filename);
                if (conflictingFile != null)
                {
                    throw new AttachmentRestoreNameConflictException();
                }
            }

            //Build new revision for restored file
            attachmentToRestore = BuildRevForRestore(attachmentToRestore, toPage, filename, transactionId);

            //Insert new revision into DB
            attachmentToRestore = SaveResource(attachmentToRestore);

            //Recent Changes
            RecentChangeBL.AddFileRecentChange(_dekiContext.Now, toPage, _dekiContext.User, DekiResources.FILE_RESTORED(attachmentToRestore.Name), transactionId);
            _dekiContext.Instance.EventSink.AttachmentRestore(_dekiContext.Now, attachmentToRestore, _dekiContext.User);
        }
Пример #3
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);
                }
            }
        }