当前位置: 首页>>代码示例>>C#>>正文


C# PageBE.SetText方法代码示例

本文整理汇总了C#中MindTouch.Deki.Data.PageBE.SetText方法的典型用法代码示例。如果您正苦于以下问题:C# PageBE.SetText方法的具体用法?C# PageBE.SetText怎么用?C# PageBE.SetText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MindTouch.Deki.Data.PageBE的用法示例。


在下文中一共展示了PageBE.SetText方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: BuildDeletedPageContents

        public static DreamMessage BuildDeletedPageContents(uint pageid) {
            ArchiveBE page = DbUtils.CurrentSession.Archive_GetPageHeadById(pageid);
            if (page == null) {
                throw new DreamAbortException(DreamMessage.NotFound(string.Format(DekiResources.RESTORE_PAGE_ID_NOT_FOUND, pageid)));
            }

            //HACKHACKHACK MaxM: Copy data to a PageBE object since parser will not work on an ArchiveBE. ArchiveBE needs to go away.
            PageBE tempP = new PageBE();
            tempP.Title = page.Title;
            tempP.SetText(page.Text);
            tempP.ContentType = page.ContentType;

            ParserResult parserResult = DekiXmlParser.Parse(tempP, ParserMode.VIEW_NO_EXECUTE);

            // TODO (steveb): this code is almost identical to the one in "GET:pages/{pageid}/contents"; consider merging

            // post process tail
            DekiXmlParser.PostProcessParserResults(parserResult);

            // wrap the result in a content tag and return it to the user
            XDoc result = new XDoc("content").Attr("type", parserResult.ContentType);
            foreach (XDoc entry in parserResult.Content.Elements) {
                if (entry.HasName("body")) {
                    result.Start("body").Attr("target", entry["@target"].AsText).Value(entry.ToInnerXHtml()).End();
                } else {
                    result.Elem(entry.Name, entry.ToInnerXHtml());
                }
            }
            // check if we hit a snag, which is indicated by a plain-text response
            if ((parserResult.ContentType == MimeType.TEXT.FullType) && (page.ContentType != MimeType.TEXT.FullType)) {

                // something happened during parsing
                return new DreamMessage(DreamStatus.NonAuthoritativeInformation, null, result);
            } else {
                return DreamMessage.Ok(result);
            }
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:37,代码来源:PageArchiveBL.cs

示例2: ConvertPages

        /// <summary>
        /// Convert MediaWiki pages to MindTouch pages
        /// </summary>
        public void ConvertPages(out Title[] titles, out Dictionary<Title, List<PageBE>> oldTitleToPageMap) {
            Console.Out.Write("Migrating pages...  ");

            if (!MediaWikiConverterContext.Current.Merge) {
                MediaWikiDA.DeleteDWLinks();
                MediaWikiDA.DeleteDWPages();
            }

            Dictionary<Site, List<PageBE>> pagesBySite = MediaWikiDA.GetPagesBySite();
            oldTitleToPageMap = new Dictionary<Title, List<PageBE>>();

            foreach (Site site in pagesBySite.Keys) {

                // group by pages having the same title
                foreach (PageBE page in pagesBySite[site]) {

                    // convert from MediaWiki to MindTouch content
                    MWToDWContent(site, page, false);
                    Title oldTitle = MWToDWTitle(site, page.Title, false);
                    page.Title = MWToDWTitle(site, page.Title);
                    List<PageBE> pagesByTitle;
                    oldTitleToPageMap.TryGetValue(oldTitle, out pagesByTitle);
                    if (null == pagesByTitle) {
                        pagesByTitle = new List<PageBE>();
                        pagesByTitle.Add(page);
                        oldTitleToPageMap.Add(oldTitle, pagesByTitle);
                    } else {
                        pagesByTitle.Add(page);
                    }
                }

                // create a media gallery page to hold images
                PageBE mediaGalleryPage = new PageBE();
                mediaGalleryPage.Title = DWMediaGalleryTitle(site);
                mediaGalleryPage.ContentType = DekiMimeType.DEKI_TEXT;
                mediaGalleryPage.Comment = mediaGalleryPage.TIP = String.Empty;
                mediaGalleryPage.TimeStamp = mediaGalleryPage.Touched = DateTime.Now;
                mediaGalleryPage.Language = site.Language;
                mediaGalleryPage.SetText(String.Empty);
                oldTitleToPageMap.Add(mediaGalleryPage.Title, new List<PageBE>(new PageBE[] { mediaGalleryPage }));
            }

            // order by new title length so that parent pages are created before their children
            titles = new Title[oldTitleToPageMap.Keys.Count];
            int[] titleLengths = new int[titles.Length];
            oldTitleToPageMap.Keys.CopyTo(titles, 0);
            for (int i = 0; i < titles.Length; i++) {
                titleLengths[i] = GetPredominantPage(oldTitleToPageMap[titles[i]]).Title.AsUnprefixedDbPath().Length;
            }
            Array.Sort(titleLengths, titles);

            // save the pages
            foreach (Title title in titles) {
                List<PageBE> pagesByTitle = oldTitleToPageMap[title];
                PageBE predominantPage = GetPredominantPage(pagesByTitle);
                ulong oldID = predominantPage.ID;
                string oldLanguage = predominantPage.Language;

                // ensure the parent exists and set the parent id
                PageBE parentPage = EnsureParent(predominantPage.IsRedirect, predominantPage);
                if (null != parentPage) {
                    predominantPage.ParentID = parentPage.Title.IsRoot ? 0 : parentPage.ID;
                }

                // detect conflicts
                List<PageBE> conflictedPages = new List<PageBE>();
                bool differsByLanguage = true;
                foreach (PageBE page in pagesByTitle) {
                    if ((predominantPage != page) && (page.GetText(DbUtils.CurrentSession).Trim() != predominantPage.GetText(DbUtils.CurrentSession).Trim()) && !page.IsRedirect) {
                        conflictedPages.Add(page);
                        if (page.Language == predominantPage.Language) {
                            differsByLanguage = false;
                        } 
                    }
                }

                // detect if a page with the same title already exists
                PageBE pageWithMatchingName = PageBL.GetPageByTitle(predominantPage.Title);
                if ( ( null != pageWithMatchingName ) && ( 0 != pageWithMatchingName.ID ) ) {
                    conflictedPages.Add(predominantPage);
                    predominantPage = pageWithMatchingName;
                } else {

                    // for templates, add each language version in a localized section
                    if (predominantPage.Title.IsTemplate) {
                        List<string> languages = new List<string>();
                        if (!File.Exists(Path.Combine(OverrideTemplateDir, GetTemplateFilename(predominantPage.Title)))) {
                            String pageText = String.Empty;
                            foreach (PageBE page in pagesByTitle) {
                                if (page.IsRedirect) {
                                    ParserResult result = DekiXmlParser.Parse(page, ParserMode.SAVE, -1, false);
                                    languages.Add(page.Language);
                                    if(result.RedirectsToTitle != null) {
                                        pageText = String.Format("{0}<span lang='{1}' class='lang lang-{1}'>{{{{wiki.template('{2}', args)}}}}</span>", pageText, page.Language, result.RedirectsToTitle.AsPrefixedDbPath());
                                        if ("en" == page.Language || 1 == pagesByTitle.Count) {
                                            pageText = String.Format("{0}<span lang='{1}' class='lang lang-{1}'>{{{{wiki.template('{2}', args)}}}}</span>", pageText, "*", result.RedirectsToTitle.AsPrefixedDbPath());
                                        }
//.........这里部分代码省略.........
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:101,代码来源:MediaWikiConverterService.cs

示例3: MWToDWContent

        public void MWToDWContent(Site site, PageBE page, bool isOld) {
            try {

                // check for template content overrides
                if (OverrideTemplate(site, page)) {
                    return;
                }

                Plug converterUri = MediaWikiConverterContext.Current.MWConverterUri;
                if (null != converterUri) {
                    string interwikiInfo = String.Empty;
                    if (null != _MWInterwikiBySite) {
                        _MWInterwikiBySite.TryGetValue(site, out interwikiInfo);
                    }
                    XDoc xml = converterUri.With("title", page.Title.AsPrefixedDbPath()).With("lang", site.Language).With("site", site.Name).With("interwiki", interwikiInfo).With("text", page.GetText(DbUtils.CurrentSession)).PostAsForm().ToDocument();
                    xml.UsePrefix("mediawiki", "#mediawiki");

                    // if this is a redirect, set the page text accordingly]
                    if (page.IsRedirect) {
                        ParserResult result = DekiXmlParser.Parse(page, ParserMode.SAVE, -1, false);
                        if (result.RedirectsToTitle != null) {
                            page.SetText(String.Format(REDIRECT_TEXT, MWToDWTitle(site, Title.FromUIUri(null, xml["//mediawiki:link/@href"].Contents, true)).AsPrefixedDbPath().Replace("&", "&amp;")));
                        } else {
                            page.SetText(String.Format(REDIRECT_TEXT, xml["//mediawiki:link/@href"].Contents.Replace("&", "&amp;"), true));
                        }
                        page.ContentType = DekiMimeType.DEKI_XML0805;
                        return;
                    }

                    // remove extra paragraph tags from templates
                    if (page.Title.IsTemplate) {
                        List<XDoc> topLevelParagraphs = xml["/html/body/p"].ToList();
                        if (1 == topLevelParagraphs.Count) {
                            topLevelParagraphs[0].ReplaceWithNodes(topLevelParagraphs[0]);
                        }
                    }

                    // Map MediaWiki titles to MindTouch
                    MWToDWTitles(site, page, isOld, xml);

                    // Convert from MediaWiki output to MindTouch
                    WikiTextProcessor.Convert(site, xml, page.Title.IsTemplate);

                    // If the page is available in other languages, insert wiki.languages 
                    List<XDoc> languageList = xml["//mediawiki:meta[@type='language']"].ToList();
                    if (0 < languageList.Count) {
                        StringBuilder languageData = new StringBuilder("{{ wiki.languages( { ");
                        for (int i = 0; i < languageList.Count; i++) {
                            if (0 < i) {
                                languageData.Append(", ");
                            }
                            string relatedLanguage = languageList[i]["@language"].AsText;
                            Title relatedTitle = Title.FromUIUri(null, languageList[i].Contents, false);
                            Site relatedSite = MediaWikiConverterContext.Current.GetMWSite(relatedLanguage);
                            languageData.AppendFormat("{0}: {1}", StringUtil.QuoteString(relatedLanguage), StringUtil.QuoteString(MWToDWTitle(relatedSite, relatedTitle).AsPrefixedDbPath()));
                            languageList[i].Remove();
                        }
                        languageData.Append(" } ) }}");
                        xml["//body"].Value(languageData.ToString());
                    }

                    string contents = xml.ToString();
                    int first = contents.IndexOf("<body>");
                    int last = contents.LastIndexOf("</body>");
                    if ((first >= 0) && (last >= 0)) {
                        page.SetText(contents.Substring(first + 6, last - (first + 6)));
                        page.ContentType = DekiMimeType.DEKI_TEXT;
                    }
                }
            } catch (Exception e) {
                Console.Out.WriteLine("An unexpected exception has occurred:");
                Console.Out.WriteLine(e.GetCoroutineStackTrace());
                Console.Out.WriteLine("MediaWiki page text that produced the exception:");
                Console.Out.WriteLine(page.GetText(DbUtils.CurrentSession));
            }
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:76,代码来源:MediaWikiConverterService.cs

示例4: OverrideTemplate

        public bool OverrideTemplate(Site site, PageBE page) {
            if (page.Title.IsTemplate && !String.IsNullOrEmpty(MediaWikiConverterContext.Current.MWTemplatePath)) {
                string templateFilename = GetTemplateFilename(page.Title);
                string templateOriginal = Path.Combine(OriginalTemplateDir, site.Language + "-" + templateFilename);

                // check the template against its base version to see if it's changed
                if (!File.Exists(templateOriginal)) {
                    #region logging
                    if (MediaWikiConverterContext.Current.LoggingEnabled) {
                        log["/html/body/table[@id='outdatedtemplates']"].Add(new XDoc("tr").Elem("td", MWToDWTitle(site, page.Title).AsPrefixedDbPath()));
                    }
                    #endregion
                    File.WriteAllLines(templateOriginal, new string[] { page.TimeStamp.ToString() });
                    File.AppendAllText(templateOriginal, page.GetText(DbUtils.CurrentSession));
                } else {
                    DateTime baseTimestamp = DateTime.MinValue;
                    string[] lines = File.ReadAllLines(templateOriginal);
                    if (0 < lines.Length) {
                        DateTime.TryParse(lines[0], out baseTimestamp);
                    }
                    if (DateTime.MinValue == baseTimestamp || baseTimestamp < page.TimeStamp) {
                        #region logging
                        if (MediaWikiConverterContext.Current.LoggingEnabled) {
                            log["/html/body/table[@id='outdatedtemplates']"].Add(new XDoc("tr").Elem("td", MWToDWTitle(site, page.Title).AsPrefixedDbPath()));
                        }
                        #endregion
                        File.WriteAllLines(templateOriginal, new string[] { page.TimeStamp.ToString() });
                        File.AppendAllText(templateOriginal, page.GetText(DbUtils.CurrentSession));

                    }
                }

                // check if the template's content has been overriden
                string templateOverride = Path.Combine(OverrideTemplateDir, templateFilename);
                if (File.Exists(templateOverride)) {
                    page.SetText(File.ReadAllText(templateOverride));
                    page.ContentType = DekiMimeType.DEKI_TEXT;
                    ParserResult parserResult = DekiXmlParser.Parse(page, ParserMode.SAVE, -1, false);
                    page.IsRedirect = (null != parserResult.RedirectsToTitle) || (null != parserResult.RedirectsToUri);
                    return true;
                }
            }
            return false;
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:44,代码来源:MediaWikiConverterService.cs

示例5: RestorePageRevisionsForPage

        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, String.Format(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);
                }
            }
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:37,代码来源:PageArchiveBL.cs

示例6: Save

        public static OldBE Save(PageBE page, OldBE previous, string userComment, string text, string contentType, string displayName, string language, int section, string xpath, DateTime timeStamp, ulong restoredPageId, bool loggingEnabled, bool removeIllegalElements, Title relToTitle, bool overwrite, uint authorId, out bool conflict) {

            // NOTE (steveb):
            //  page: most recent page about to be overwritten
            //  previous: (optional) possible earlier page on which the current edit is based upon

            conflict = false;
            bool isNewForEventContext = page.ID == 0 || page.IsRedirect;

            // check save permissions
            IsAccessAllowed(page, 0 == page.ID ? Permissions.CREATE : Permissions.UPDATE, false);

            // validate the save
            if((0 == page.ID) && ((-1 != section) || (null != xpath))) {
                throw new ArgumentException(DekiResources.SECTION_EDIT_EXISTING_PAGES_ONLY);
            }

            // displaynames entered by user are trimmed
            if(displayName != null) {
                displayName = displayName.Trim();
            }

            if(!Title.FromDbPath(page.Title.Namespace, page.Title.AsUnprefixedDbPath(), displayName).IsValid) {
                throw new DreamAbortException(DreamMessage.Conflict(DekiResources.INVALID_TITLE));
            }

            // load old contents into current page when a section is edited
            ParserResult alternate = new ParserResult();
            ParserResult original = new ParserResult();
            if(previous != null) {

                // parse most recent version as alternate
                alternate = DekiXmlParser.Parse(page, ParserMode.RAW);

                // parse base version for three way diff
                string pageContentType = page.ContentType;
                string pageText = page.GetText(DbUtils.CurrentSession);
                page.ContentType = previous.ContentType;
                page.SetText(previous.Text);
                original = DekiXmlParser.Parse(page, ParserMode.RAW);
                page.ContentType = pageContentType;
                page.SetText(pageText);
            }

            // ensure the parent exists
            PageBE parent = EnsureParent(DekiXmlParser.REDIRECT_REGEX.IsMatch(text), page.Title);
            if(null != parent) {
                page.ParentID = parent.Title.IsRoot ? 0 : parent.ID;
            }

            // Explicitly setting the language of a talk page is not valid
            if(page.Title.IsTalk && !string.IsNullOrEmpty(language)) {
                throw new Exceptions.TalkPageLanguageCannotBeSet();
            }

            // Language is set in this order: explicitly given, already set, language of parent
            language = language ?? page.Language ?? (null != parent ? parent.Language : String.Empty);

            // talk pages always get their language from their corresponding front page
            if(page.Title.IsTalk) {
                PageBE frontPage = PageBL.GetPageByTitle(page.Title.AsFront());
                if(frontPage != null && frontPage.ID != 0) {
                    language = frontPage.Language;
                }
            }

            string nativeName = ValidatePageLanguage(language);

            // parse the content
            ParserResult parserResult = DekiXmlParser.ParseSave(page, contentType, language, text, section, xpath, removeIllegalElements, relToTitle);
            OldBE old = null;
            string comment = userComment ?? string.Empty;

            // check if this is a new page
            if(0 == page.ID) {
                AuthorizePage(DekiContext.Current.User, Permissions.CREATE, parent, false);

                if(0 == restoredPageId) {
                    if(!string.IsNullOrEmpty(comment)) {
                        comment += "; ";
                    }
                    comment += string.Format(DekiResources.PAGE_CREATED);
                    if((null == parserResult.RedirectsToTitle) && (null == parserResult.RedirectsToUri)) {
                        comment += string.Format(", " + DekiResources.PAGE_DIFF_SUMMARY_ADDED, Utils.GetPageWordCount(parserResult.MainBody));
                    }
                    page.MinorEdit = false;
                    page.IsNew = true;
                }
            }

            // if this is an existing page, ensure the content has changed and save the current page information 
            else {

                // prevent creating a redirect on a page that has non-redirect children
                if((null != parserResult.RedirectsToTitle) || (null != parserResult.RedirectsToUri)) {
                    IList<PageBE> children = DbUtils.CurrentSession.Pages_GetChildren((uint)page.ID, page.Title.Namespace, true);
                    if(0 < children.Count) {
                        throw new DreamAbortException(DreamMessage.Conflict(DekiResources.INVALID_REDIRECT));
                    }
                }
//.........这里部分代码省略.........
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:101,代码来源:PageBL.cs

示例7: CopyOldToPage

 public static void CopyOldToPage(OldBE old, PageBE page, Title pageTitle) {
     page.SetText(old.Text);
     page.ContentType = old.ContentType;
     page.UserID = old.UserID;
     page.TimeStamp = old.TimeStamp;
     page.MinorEdit = old.MinorEdit;
     page.Comment = old.Comment;
     page.Language = old.Language;
     page.IsHidden = old.IsHidden;
     page.Meta = old.Meta;
     page.Revision = old.Revision;
     page.ID = old.PageID;
     page.Title = pageTitle;
 }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:14,代码来源:PageBL.cs

示例8: MovePageProcessRedirects

        private static void MovePageProcessRedirects(List<PageBE> pagesToMove, Dictionary<ulong, Title> newTitlesByPageId, List<PageBE> childRedirectsToRecreate) {

            //Update redirects pointing to the old locations to point to the new
            Dictionary<ulong, IList<PageBE>> redirectsByPages =
                DbUtils.CurrentSession.Pages_GetRedirects(new List<ulong>(from p in pagesToMove select p.ID));

            foreach(PageBE pageToMove in pagesToMove) {
                IList<PageBE> redirects = null;
                if(redirectsByPages.TryGetValue(pageToMove.ID, out redirects)) {
                    foreach(PageBE redirect in redirects) {
                        redirect.SetText("#REDIRECT [[" + newTitlesByPageId[pageToMove.ID].AsPrefixedDbPath() + "]]");
                        DbUtils.CurrentSession.Pages_Update(redirect);
                    }
                }
            }

            // redirects that are children of the moved root page are deleted by Pages_UpdateTitlesForMove and need to be recreated
            pagesToMove.AddRange(childRedirectsToRecreate);

            //NOTE: Pages are sorted before creating redirects to intermediate parent pages arent automatically created
            pagesToMove = pagesToMove.OrderBy(p => p.Title).ToList();
 
            foreach(PageBE movedPage in pagesToMove) {
                string text = string.Empty;
                if(movedPage.IsRedirect) {
                    //This redirect is simply recreated any may be a direct link or in the case when it's pointing to a page that was just moved,
                    //it will point to the previous title for which there's a new redirect.
                    text = movedPage.GetText(DbUtils.CurrentSession);
                } else {
                    text = "#REDIRECT [[" + newTitlesByPageId[movedPage.ID].AsPrefixedDbPath() + "]]";
                }
                PageBE oldPageRedirect = new PageBE();
                oldPageRedirect.Title = movedPage.Title;
                oldPageRedirect.SetText(text);
                PageBL.Save(oldPageRedirect, oldPageRedirect.GetText(DbUtils.CurrentSession), DekiMimeType.DEKI_TEXT, null);
                DbUtils.CurrentSession.Grants_CopyToPage(movedPage.ID, oldPageRedirect.ID);
                DekiContext.Current.Instance.EventSink.PageAliasCreate(DreamContext.Current.StartTime, oldPageRedirect, DekiContext.Current.User);
            }
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:39,代码来源:PageBL.cs

示例9: PopulateOld

        private static PageBE PopulateOld(IDataRecord dr) {
            PageBE old = new PageBE();
            old.ID = DbUtils.Convert.To<ulong>(dr["rev_id"]).Value;
            old._Namespace = DbUtils.Convert.To<ushort>(dr["page_namespace"]).Value;
            old._Title = GetUTF8String(dr, "page_title");
            old.SetText(GetUTF8String(dr, "old_text"));
            old.Comment = GetUTF8String(dr, "rev_comment");
            if (MediaWikiConverterContext.Current.Merge) {
                old.UserID = MediaWikiConverterContext.Current.MergeUserId;
            } else {
                old.UserID = DbUtils.Convert.To<uint>(dr["rev_user"]).Value;
            }
            old.TimeStamp = DbUtils.ToDateTime(GetUTF8String(dr, "rev_timestamp"));
            old.MinorEdit = DbUtils.Convert.To<bool>(dr["rev_minor_edit"]).Value;
            old.ContentType = DekiMimeType.MEDIAWIKI_TEXT;
            if(MediaWikiConverterContext.Current.AttributeViaPageRevComment) {

                //Add the original revision username to the comment
                string username = GetUTF8String(dr, "rev_user_text");
                if(!string.IsNullOrEmpty(username)) {
                    old.Comment = string.Format(MediaWikiConverterContext.Current.AttributeViaPageRevCommentPattern, old.Comment, username);
                }
            }

            return old;
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:26,代码来源:MediaWikiDA.cs

示例10: PopulatePage

        private static PageBE PopulatePage(IDataRecord dr) {
            PageBE page = new PageBE();
            page.ID = DbUtils.Convert.To<ulong>(dr["page_id"]).Value;
            page._Namespace = DbUtils.Convert.To<ushort>(dr["page_namespace"]).Value;
            page._Title = GetUTF8String(dr, "page_title");
            string restrictions = GetUTF8String(dr, "page_restrictions");
            if ((restrictions == "sysop") || (restrictions == "move=sysop:edit=sysop")) {
                page.RestrictionID = 2;
            }
            page.Counter = DbUtils.Convert.To<uint>(dr["page_counter"]).Value;
            page.IsRedirect = DbUtils.Convert.To<bool>(dr["page_is_redirect"]).Value;
            page.IsNew = DbUtils.Convert.To<bool>(dr["page_is_new"]).Value;
            page.Touched = DbUtils.ToDateTime(GetUTF8String(dr, "page_touched"));

            if (MediaWikiConverterContext.Current.Merge) {
                page.UserID = MediaWikiConverterContext.Current.MergeUserId;
            } else {
                page.UserID = DbUtils.Convert.To<uint>(dr["rev_user"]).Value;
            }
            page.TimeStamp = DbUtils.ToDateTime(GetUTF8String(dr, "rev_timestamp"));
            page.MinorEdit = DbUtils.Convert.To<bool>(dr["rev_minor_edit"]).Value;
            page.Comment = GetUTF8String(dr, "rev_comment");
            page.SetText(GetUTF8String(dr, "old_text"));
            page.ContentType = DekiMimeType.MEDIAWIKI_TEXT;  
            page.TIP = String.Empty;

            if(MediaWikiConverterContext.Current.AttributeViaPageRevComment) {

                //Add the original revision username to the comment
                string username = GetUTF8String(dr, "rev_user_text");
                if(!string.IsNullOrEmpty(username)) {
                    page.Comment = string.Format(MediaWikiConverterContext.Current.AttributeViaPageRevCommentPattern, page.Comment, username);
                }
            }

            return page;
        }
开发者ID:StackableRegiments,项目名称:metl2011,代码行数:37,代码来源:MediaWikiDA.cs


注:本文中的MindTouch.Deki.Data.PageBE.SetText方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。