本文整理汇总了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;
}
}
示例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();
}
示例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("/", "/");
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]);
}
}
示例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;
}