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


C# Page.Exists方法代码示例

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


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

示例1: ProcessPage

        protected override void ProcessPage(Page p, EditStatus edit)
        {
            if (p.GetNamespace() != 0)
                return;
            p.Load();

            //Nur Seiten mit Vorlage:Infobox NSC
            if (p.GetAllTemplates().All(t => t.Title.ToLower() != "infobox nsc")) return;

            //Nur Seiten, die eine Unterseite mit Angeboten haben...
            var m = Regex.Match(p.text, "\\{\\{:" + p.title + "/([^}]+)}}");
            if (!m.Success) return;

            var subpageTitle = m.Groups[1].Value;

            var subpage = new Page(p.site, p.title + "/" + subpageTitle);
            subpage.Load();
            if (!subpage.Exists())
            {
                p.text = p.text.Replace(m.Value, "");
                edit.EditComment = "Verweis auf nicht vorhandene Angebots-Unterseite „" + subpage.title + "“ entfernt";
                edit.Save = true;
            }
            else
            {
                var pl2 = new PageList(p.site);
                pl2.FillFromLinksToPage(subpage.title);
                if (pl2.Count() > 1) return;

                var subpageContent = Regex.Replace(subpage.text, "<noinclude>.*?</noinclude>", "").Trim();

                p.text = p.text.Replace(m.Value, subpageContent);

                subpage.text = "{{Löschantrag|[Bot] In den Hauptartikel „[[" + p.title + "]]“ verschoben}}\n" +
                               subpage.text;
                subpage.Save("[Bot] In Hauptartikel „[[" + p.title + "]]“ verschoben", true);

                edit.EditComment = "Angebot von „" + subpage.title + "“ in den Hauptartikel verschoben";
                edit.Save = true;
            }
        }
开发者ID:knabbi,项目名称:GW2WBot,代码行数:41,代码来源:AngebotSubpageToMainarticleJob.cs

示例2: PageIsSchauplatz

        private bool PageIsSchauplatz(string page)
        {
            if (_schauplaetze.Contains(page)) return true;

            //return true if the page doesn't exist
            var p = new Page(Site, page);
            p.Load();
            if(!p.Exists()) _schauplaetze.Add(page);
            return !p.Exists();
        }
开发者ID:knabbi,项目名称:GW2WBot,代码行数:10,代码来源:StandortTemplateJob.cs

示例3: DoStuff

        public static void DoStuff()
        {
            string username = "";
            string password = "";

            Console.WriteLine("Enter wiki username: ");
            username = Console.ReadLine();
            Console.WriteLine("Enter wiki password: ");
            password = Console.ReadLine();
            password = password.Trim();

            newWiki = new Site(WIKI_URL, username, password);

            int count = 0;  // increment this when we actually create a page
            var files = new System.Collections.Generic.List<string>(Directory.GetFiles(@"G:\zkwiki\output\markup"));
            files = files.Shuffle();
            foreach (string path in files)
            {
                string unitname = Path.GetFileNameWithoutExtension(path);
                unitname = unitname.Replace("&#47;", "/");
                var page = new Page(newWiki, unitname);
                page.Load();
                if (page.Exists())
                {
                    // do nothing
                }
                else
                {
                    var text = File.ReadAllText(path);
                    Console.WriteLine("-- Making page {0} --", unitname);
                    page.Save(text, "Created page from unitguide builder export", false);
                    count++;
                    //if (count >= 20) break;
                }
            }

            string[,] toPort = 
            {
                //{"MissionEditorCompatibility", "Mission Editor game compatibility"},
                //{"MissionEditorStartPage", "Mission Editor"},
                //{"MissionEditorWINE", "Mission Editor in WINE"},
                //{"FactoryOrdersTutorial", "Mission Editor Factory Orders Tutorial"},
                //{"MissionEditorTutorial", "Mission Editor Tutorial"},
                //{"MissionEditorCutsceneTutorial", "Mission Editor Cutscenes Tutorial"}
            };
            for (int i=0; i<toPort.GetLength(0); i++)
            {
                ConvertPage(toPort[i, 0], toPort[i, 1], false);
            }

            string[] toReformat =
            {
                //"Mission Editor Cutscenes Tutorial"
            };
            for (int i = 0; i < toReformat.GetLength(0); i++)
            {
                ReformatPage(toReformat[i]);
            }
        }
开发者ID:GoogleFrog,项目名称:Zero-K-Infrastructure,代码行数:59,代码来源:WikiPortingMW.cs

示例4: UploadFile

        private static bool UploadFile(string fileToUpload)
        {
            logger.Info("Logging into Wiki");
            string siteurl = "http://commons.wikimedia.org";
            //string siteurl = "http://vgsales.wikia.com";
            //string siteurl = "http://w3stfa11.limewebs.com/wiki/index.php?title=Main_Page";
            Site wikiSite;
            Page page;
            try
            {
                wikiSite = new Site(siteurl, Configuration.WikiUsername, Configuration.WikiPassword);
                //wikiSite = new Site(siteurl, "abc", "123"); //limewebs
                page = new Page(wikiSite,videoInfo.Title);

            }
            catch (Exception e)
            {
                logger.Error("Unable to login to: " + siteurl + " error:" + e.Message + e.StackTrace + e.Source + e.InnerException + "\n" +e.Data);
                return false;
            }
            string fileNamespace = "6";
            string fileName = Path.GetFileName(fileToUpload);
            page.title = wikiSite.namespaces[fileNamespace] + ":" + fileName;

            StringBuilder sb = new StringBuilder();
            sb.AppendLine("{{Information");
            sb.AppendLine("|Description	= {{en|1=" + videoInfo.Description + "}}");
            sb.AppendFormat("|Source		= originally posted to '''[[Flickr]]''' as [{0} {1}]", videoInfo.SourceUrl,
                            videoInfo.Title);
            sb.AppendLine();
            sb.AppendLine("|Date		= " + videoInfo.Date);
            sb.AppendLine("|Author		= " + videoInfo.Author);
            sb.AppendLine("|Permission	= " + GetLicenseTemplate(videoInfo.License));
            sb.AppendLine("|Other versions		= ");
            sb.AppendLine("}}");

            string wikitext = sb.ToString();
            logger.Info("--------------\n" + wikitext);
            try {
                page.Load();
            }
            catch(Exception ex)
            {
                return false;
            }

            if (page.Exists())
            {
                int x = 0;
                //return false;
            }

            try {
                logger.InfoFormat("Uploading {0} to Wiki", fileToUpload);
                page.UploadImage(fileToUpload, wikitext, "", "", "");

                logger.Info("Complete upload to Wiki");
            }
            catch (Exception ex)
            {
                logger.Error("Error in UploadFile: " + ex.Message + Environment.NewLine + "fileToUpload: " + fileToUpload + ex.GetBaseException());
            }

            return true;
        }
开发者ID:gman1023,项目名称:video-to-wikipedia,代码行数:65,代码来源:VideoDownloader.cs


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