本文整理汇总了C#中DotNetWikiBot.Page.Load方法的典型用法代码示例。如果您正苦于以下问题:C# Page.Load方法的具体用法?C# Page.Load怎么用?C# Page.Load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DotNetWikiBot.Page
的用法示例。
在下文中一共展示了Page.Load方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ProcessPage
protected override void ProcessPage(Page p, EditStatus edit)
{
if (p.GetNamespace() != 0) return;
p.Load();
var changes = new List<string>();
p.InsertPlaceholders(GeneralExtensions.Placeholder.Default);
foreach (var replacement in Replacements.Where(replacement => p.text.Contains(replacement.Key)))
{
p.text = p.text.Replace(replacement.Key, replacement.Value);
changes.Add(replacement.Key + " → " + replacement.Value);
}
foreach (var replacement in RegexReplacements)
{
var pattern = replacement.Key;
var replace = replacement.Value;
pattern.Replace(p.text, match =>
{
var replaceWith = RegexParseReplaceWithString(match, replace);
changes.Add(match.Value + " → " + replaceWith);
return replaceWith;
});
}
p.RemovePlaceholders();
if (changes.Count > 0)
{
edit.Save = true;
edit.EditComment = "Ersetzt: " + string.Join(", ", changes);
}
}
示例2: ProcessPage
protected override void ProcessPage(Page p, EditStatus edit)
{
if (p.GetNamespace() != 0) return;
p.Load();
var before = p.text;
var changes = new List<string>();
Match m;
while ((m = MuenzenRegex.Match(p.text)).Success)
{
var kupfer = 0;
var silber = 0;
var gold = 0;
int.TryParse(m.Groups["kupfer"].Value, out kupfer);
int.TryParse(m.Groups["silber"].Value, out silber);
int.TryParse(m.Groups["gold"].Value, out gold);
var muenzen = kupfer + 100*silber + 10000*gold;
p.text = p.text.Replace(m.Value.Trim(), "{{Münzen|" + muenzen + "}}");
changes.Add(string.Format("{0}g {1}s {2}k → {3}", gold, silber, kupfer, muenzen));
}
if (changes.Count > 0)
{
edit.EditComment = string.Format("Münzen ({0}x): {1}", changes.Count, string.Join(", ", changes));
edit.Save = true;
}
}
示例3: ConvertPage
public static void ConvertPage(string pageName, string newName, bool overwrite = false)
{
var db = new ZkDataContext();
ForumThread thread = db.ForumThreads.FirstOrDefault(x=> x.WikiKey == pageName);
if (thread == null)
{
Console.WriteLine("No ZK wiki page with name {0} found", pageName);
return;
}
string text = thread.ForumPosts.First().Text;
text = BBCodeToMediaWiki(text);
Page page = new Page(newWiki, newName);
page.Load();
bool update = false;
if (!page.IsEmpty())
{
if (!overwrite)
{
Console.WriteLine("Page already exists, exiting");
return;
}
else update = true;
}
if (newName.StartsWith("Mission Editor", true, System.Globalization.CultureInfo.CurrentCulture))
page.AddToCategory("Mission Editor");
page.Save(text, update ? "" : "Ported from ZK wiki by DotNetWikiBot", update);
}
示例4: exec
public static void exec()
{
string[] line = System.IO.File.ReadAllLines("list");
List<string> ignorelist = new List<string>();
if (System.IO.File.Exists("resultsig"))
{
ignorelist.AddRange (System.IO.File.ReadAllLines("resultsig"));
}
if (System.IO.File.Exists("results"))
{
ignorelist.AddRange (System.IO.File.ReadAllLines("results"));
}
int processed = 1;
foreach (string c in line)
{
if (ignorelist.Contains(c))
{
continue;
}
try
{
Page afc = new Page(MainClass.en, "Wikipedia talk:" + c);
afc.Load();
if ( afc.text == null ||
afc.text.Contains("REDIRECT") ||
afc.text.Contains("{{AFC") ||
afc.text.Contains("{{WPAFC") ||
afc.text == "" ||
afc.text.Contains("[[Category:AfC_submissions_with_missing_AfC_template]]")
)
{
MainClass.DebugLog("OK:" + c);
System.IO.File.AppendAllText("resultsig", c + "\n");
}
else
{
MainClass.DebugLog("Category missing:" + c);
afc.text = afc.text + "\n[[Category:AfC_submissions_with_missing_AfC_template]]";
afc.Save(afc.text, "Bot: inserting [[Category:AfC_submissions_with_missing_AfC_template]]", false);
processed++;
System.IO.File.AppendAllText("results", c + "\n");
if (processed > 100)
{
MainClass.DebugLog("Finished for today");
return;
}
}
}
catch (Exception fail)
{
Console.WriteLine(fail.ToString());
System.IO.File.AppendAllText("errors", c + Environment.NewLine);
}
}
MainClass.Log("end");
}
示例5: ProcessPage
protected override void ProcessPage(Page p, EditStatus edit)
{
if (p.GetNamespace() != 0) return;
p.Load();
var templates = p.GetAllTemplates().Where(t => t.Title.ToLower() == "infobox gegenstand");
foreach (var template in templates)
{
if (template.Parameters.ContainsKey("beschreibung") && _regex.IsMatch(template.Parameters["beschreibung"]))
{
template.Parameters["beschreibung"] = _regex.Replace(template.Parameters["beschreibung"], "[[$1]]");
template.Save();
edit.Save = true;
edit.EditComment = "Attribute in Gegenstandsbeschreibung verlinkt";
}
}
}
示例6: ProcessPage
protected override void ProcessPage(Page p, Job.EditStatus edit)
{
if(p.GetNamespace() != 0) return;
p.Load();
foreach (var template in p.GetAllTemplates().Where(
template => (template.Title.Equals("Ausrüstungswerte", StringComparison.OrdinalIgnoreCase)
|| template.Title.Equals("Rezept", StringComparison.OrdinalIgnoreCase)) &&
(template.Parameters.HasValueIgnoreCase("seltenheit", "Aufgestiegen") &&
!template.Parameters.ContainsKey("aufwertung"))))
{
template.InsertParameterAfter("aufwertung", "nein", "infusion2", "infusion");
template.Save();
edit.EditComment = "'aufwertung = nein' hinzugefügt";
edit.Save = true;
}
}
示例7: 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;
}
}
示例8: exec
public static void exec()
{
string[] line = System.IO.File.ReadAllLines("list");
List<string> ignorelist = new List<string>();
if (System.IO.File.Exists("resultsig"))
{
ignorelist.AddRange (System.IO.File.ReadAllLines("resultsig"));
}
if (System.IO.File.Exists("results"))
{
ignorelist.AddRange (System.IO.File.ReadAllLines("results"));
}
foreach (string c in line)
{
if (ignorelist.Contains(c))
{
continue;
}
try
{
Page afc = new Page(MainClass.en, "Wikipedia talk:" + c);
afc.Load();
if (afc.text.Contains("REDIRECT") || afc.text.Contains("{{AFC"))
{
MainClass.DebugLog("OK:" + c);
System.IO.File.AppendAllText("resultsig", c + "\n");
}
else
{
MainClass.DebugLog("Template missing:" + c);
System.IO.File.AppendAllText("results", c + "\n");
}
}
catch (Exception fail)
{
Console.WriteLine(fail.ToString());
System.IO.File.AppendAllText("errors", c + "." + Environment.NewLine);
}
}
MainClass.Log("end");
}
示例9: WikiPage
public WikiPage(Page pg)
{
page = pg;
if (page.text == null || page.text == "")
{
page.Load();
}
title = page.text;
ns = 0;
id = long.Parse(page.pageID);
//revid = long.Parse(page.lastRevisionID);
//try { parentid = long.Parse(page.lastUserID); }
//catch { }
timestamp = page.timestamp;
text = page.text;
tf_IDF_Vec = new TF_IDF_Vector();
}
示例10: ProcessPage
protected override void ProcessPage(Page p, EditStatus edit)
{
if (p.GetNamespace() != 0)
return;
p.Load();
var before = p.text;
foreach (var template in p.GetAllTemplates())
{
if (template.Title == "#dpl:" && template.Parameters.ContainsKey("category") &&
template.Parameters.ContainsKey("linksto") && template.Parameters.ContainsKey("format"))
{
var linksTo = template.Parameters["linksto"];
linksTo = linksTo == p.title ? "{{PAGENAME}}" : linksTo;
if (template.Parameters["category"].ToLower() == "trophäe")
p.text = p.text.Replace(template.Text, "Beschaffung|gegenstand=" + linksTo + "|kategorie=Trophäe");
else if (template.Parameters["category"].ToLower() == "behälter")
p.text = p.text.Replace(template.Text, "Beschaffung|gegenstand=" + linksTo + "|kategorie=Behälter");
}
}
if (p.text.Contains("#dpl:") && p.text.Contains("Behälter"))
{
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine("{0} still contains dpl", p.title);
Console.ResetColor();
}
if (p.text != before)
{
edit.Save = true;
edit.EditComment = "DPL durch {{Beschaffung}} ersetzt";
}
}
示例11: ProcessPage
protected override void ProcessPage(Page p, EditStatus edit)
{
if (p.GetNamespace() != 0) return;
p.Load();
var allChanges = new List<string>();
var before = p.text;
foreach (var template in p.GetAllTemplates())
{
var templateChanges = new List<string>();
if (Replacements.ContainsKey(template.Title))
{
foreach (var parameter in template.Parameters)
{
if (Replacements[template.Title].ContainsKey(parameter.Key))
{
template.ChangeParametername(parameter.Key, Replacements[template.Title][parameter.Key]);
templateChanges.Add(parameter.Key + " → " + Replacements[template.Title][parameter.Key]);
}
}
}
if (templateChanges.Count > 0)
{
template.Save();
allChanges.Add(template.Title + ": " + string.Join(", ", templateChanges));
}
}
if (allChanges.Count > 0)
{
edit.Save = true;
edit.EditComment = "Parameter umbenannt: " + string.Join("; ", allChanges);
}
}
示例12: UploadButtonClick
void UploadButtonClick( object sender, EventArgs ea )
{
if ( string.IsNullOrEmpty( siteTextBox.Text ) ||
string.IsNullOrEmpty( userNameTextBox.Text ) ||
string.IsNullOrEmpty( passwordTextBox.Text ) ||
string.IsNullOrEmpty( folderTextBox.Text ) ||
string.IsNullOrEmpty( filesDescrTextBox.Text ) )
{
MessageBox.Show( "Fill in all required data fileds, please." );
return;
}
this.Cursor = Cursors.WaitCursor;
if ( site == null )
{
try
{
site = new Site(
siteTextBox.Text.Trim(),
userNameTextBox.Text.Trim(),
passwordTextBox.Text.Trim(),
userDomainTextBox.Text.Trim()
);
}
catch ( Exception e )
{
this.Cursor = Cursors.Default;
MessageBox.Show( e.Message );
return;
}
}
if ( !Directory.Exists( folderTextBox.Text ) )
{
this.Cursor = Cursors.Default;
MessageBox.Show( "Specified folder doesn't exist." );
return;
}
Regex allowedFileTypes;
if ( !string.IsNullOrEmpty( fileTypesTextBox.Text ) )
{
allowedFileTypes = new Regex( String.Format( "(?i)\\.({0})$",
fileTypesTextBox.Text.Replace( " ", "" ).Replace( ",", "|" ) ) );
}
else
{
allowedFileTypes = new Regex( "." );
}
string[] filenames =
Array.FindAll( Directory.GetFiles( folderTextBox.Text ), allowedFileTypes.IsMatch );
if ( filenames.Length == 0 )
{
this.Cursor = Cursors.Default;
MessageBox.Show( "Specified folder doesn't contain files, that could be uploaded." );
return;
}
UploadProgressBar.Visible = true;
UploadProgressBar.Minimum = 0;
UploadProgressBar.Maximum = filenames.Length;
UploadProgressBar.Value = 0;
UploadProgressBar.Step = 1;
Page p = new Page( site );
string filename;
for ( int i = 0; i < filenames.Length; UploadProgressBar.PerformStep(), i++ )
{
filename = Path.GetFileName( filenames[i] );
p.title = site.namespaces["6"] + ":" + filename;
try
{
p.Load();
}
catch ( Exception e )
{
MessageBox.Show( e.Message );
continue;
}
if ( p.Exists() && MessageBox.Show(
String.Format( "File \"{0}\" already exists. Overwrite?", filename ),
"Вопрос",
MessageBoxButtons.YesNo,
MessageBoxIcon.Question ) != DialogResult.Yes )
{
continue;
}
try
{
p.UploadImage( filenames[i], filesDescrTextBox.Text, "", "", "" );
}
catch ( Exception e )
{
MessageBox.Show( e.Message );
continue;
}
File.AppendAllText("UploadedFiles.txt", filenames[i] + "\r\n");
}
//.........这里部分代码省略.........
示例13: ReformatPage
public static void ReformatPage(string pageName)
{
Page page = new Page(newWiki, pageName);
page.Load();
string text = BBCodeToMediaWiki(page.text);
if (pageName.StartsWith("Mission Editor", true, System.Globalization.CultureInfo.CurrentCulture))
page.AddToCategory("Mission Editor");
page.Save(text, "Cleanup by DotNetWikiBot", false);
}
示例14: AddNavbox
public static void AddNavbox(string pageName, string template)
{
Page page = new Page(newWiki, pageName);
page.Load();
AddNavbox(page, template);
}
示例15: 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();
}