本文整理汇总了C#中WikiFunctions.API.ApiEdit.Login方法的典型用法代码示例。如果您正苦于以下问题:C# ApiEdit.Login方法的具体用法?C# ApiEdit.Login怎么用?C# ApiEdit.Login使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WikiFunctions.API.ApiEdit
的用法示例。
在下文中一共展示了ApiEdit.Login方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: btnLogin_Click
private void btnLogin_Click(object sender, EventArgs e)
{
groupBox2.Enabled = false;
try
{
Editor = new ApiEdit(txtURL.Text);
Editor.Login(txtUsername.Text, txtPassword.Text);
groupBox2.Enabled = true;
txtEdit.Text = "";
btnSave.Enabled = false;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, ex.GetType().Name);
}
}
示例2: ProcessArticle
public string ProcessArticle(IAutoWikiBrowser sender, IProcessArticleEventArgs eventargs)
{
if (!Enabled) return eventargs.ArticleText;
if (username == "" || password == "")
{
MessageBox.Show("Source wiki username and/or password not set. Turning off the plugin.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
disablePlugin();
return eventargs.ArticleText;
}
String linkTitle;
String linkBody;
String sourceText = eventargs.ArticleText;
String url = String.Format("http://{0}.wikipedia.org/w/", SourceLanguage);
ApiEdit sourceWiki = new ApiEdit(url);
try
{
sourceWiki.Login(username, password);
}
catch (LoginException e)
{
MessageBox.Show("Source wiki username and/or password incorrect. Turning off the plugin.", "Info", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
disablePlugin();
return eventargs.ArticleText;
}
#if DEBUG_OUTPUT_DIALOG
DebugOutput dlg = new DebugOutput();
dlg.Show(sender.Form);
#endif
String langCode = Variables.LangCode.ToString();
Regex r = new Regex(String.Format(@"\[\[{0}:([^\]]+)\]\]", langCode));
Match m;
String replaceReg;
String replaceTo;
string[] arr = { eventargs.ArticleTitle };
LinksOnPageListProvider linksProvider = new LinksOnPageListProvider();
List<Article> links = linksProvider.MakeList(arr);
// Message
AWBForm.StartProgressBar();
AWBForm.StatusLabelText = String.Format("Translating {0} links...", links.Count);
#if DEBUG_OUTPUT_DIALOG
dlg.StartSection(string.Format("Article {0}", eventargs.ArticleTitle));
#endif
foreach (Article link in links)
{
#if DEBUG_OUTPUT_DIALOG
dlg.StartSection(string.Format("Link: {0}", link.Name));
#endif
linkTitle = link.Name;
linkBody = sourceWiki.Open(linkTitle);
m = r.Match(linkBody);
if (m.Success)
{
#if DEBUG_OUTPUT_DIALOG
dlg.AddSection("From: ", linkTitle);
dlg.AddSection("To: ", m.Groups[1].ToString());
#endif
replaceReg = String.Format(@"\[\[{0}\]\]", linkTitle);
replaceTo = String.Format("[[{0}|{1}]]", m.Groups[1], linkTitle);
sourceText = Regex.Replace(sourceText, replaceReg, replaceTo, RegexOptions.IgnoreCase);
replaceReg = String.Format(@"\[\[{0}\|([^\]]+)\]\]", linkTitle);
replaceTo = String.Format("[[{0}|$1]]", m.Groups[1], linkTitle);
sourceText = Regex.Replace(sourceText, replaceReg, replaceTo, RegexOptions.IgnoreCase);
}
#if DEBUG_OUTPUT_DIALOG
else {
dlg.AddSection("No match", "");
}
#endif
#if DEBUG_OUTPUT_DIALOG
dlg.EndSection();
#endif
Application.DoEvents();
}
#if DEBUG_OUTPUT_DIALOG
dlg.EndSection();
#endif
AWBForm.StopProgressBar();
AWBForm.StatusLabelText = "";
eventargs.EditSummary = "Automatic translation";
return sourceText;
}