本文整理汇总了C#中WikiFunctions.Background.BackgroundRequest类的典型用法代码示例。如果您正苦于以下问题:C# BackgroundRequest类的具体用法?C# BackgroundRequest怎么用?C# BackgroundRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BackgroundRequest类属于WikiFunctions.Background命名空间,在下文中一共展示了BackgroundRequest类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Update
/// <summary>
/// Checks to see if AWBUpdater.exe.new exists, if it does, replace it.
/// If not, see if the version of AWB Updater is older than the version on the checkpage, and run AWBUpdater if so
/// </summary>
public static void Update()
{
request = new BackgroundRequest();
request.Execute(UpdateFunc);
}
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:9,代码来源:Updater.cs
示例2: LoadUnderscores
public static void LoadUnderscores(params string[] templates)
{
BackgroundRequest r = new BackgroundRequest(UnderscoresLoaded);
r.HasUI = false;
DelayedRequests.Add(r);
r.GetList(new Lists.WhatTranscludesPageListProvider(), templates);
}
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:7,代码来源:Variables.cs
示例3: RegExTypoFix
/// <summary>
/// Default constructor, typos being loaded on separate thread is optional
/// </summary>
/// <param name="loadThreaded">Whether to load typos on a new thread</param>
/// <param name="provider">Typos provider to use</param>
public RegExTypoFix(bool loadThreaded, ITyposProvider provider)
{
Source = provider;
if (!loadThreaded)
{
MakeRegexes();
return;
}
TypoThread = new BackgroundRequest(Complete);
TypoThread.Execute(MakeRegexes);
}
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:17,代码来源:RegExTypoFix.cs
示例4: bypassAllRedirectsToolStripMenuItem_Click
private void bypassAllRedirectsToolStripMenuItem_Click(object sender, EventArgs e)
{
#if !DEBUG
if (MessageBox.Show("Replacement of links to redirects with direct links is strongly discouraged, " +
"however it could be useful in some circumstances. Are you sure you want to continue?",
"Bypass redirects", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
return;
#endif
BackgroundRequest r = new BackgroundRequest();
Enabled = false;
r.BypassRedirects(txtEdit.Text, TheSession.Editor.SynchronousEditor.Clone());
r.Wait();
Enabled = true;
txtEdit.Text = (string)r.Result;
}
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:18,代码来源:Main.cs
示例5: UploadFinishedArticlesToServerErrored
private static void UploadFinishedArticlesToServerErrored(BackgroundRequest req)
{
AWB.StopProgressBar();
AWB.StatusLabelText = "TypoScan reporting failed";
IsUploading = false;
if (req.ErrorException is System.IO.IOException || req.ErrorException is System.Net.WebException)
{
Tools.WriteDebug("TypoScanAWBPlugin", req.ErrorException.Message);
}
}
开发者ID:svn2github,项目名称:awb,代码行数:11,代码来源:TypoScanBasePlugin.cs
示例6: ReparseEditBoxComplete
/// <summary>
/// Called by ReparseEditBox complete event
/// Calls ReparseEditBoxPart2 to update alerts etc. after re-processing page
/// </summary>
/// <param name="req"></param>
private void ReparseEditBoxComplete(BackgroundRequest req)
{
// must use Invoke so that ReparseEditBoxPart2 is done on main GUI thread
if (InvokeRequired)
{
Invoke(new GenericDelegate(ReparseEditBoxPart2));
return;
}
ReparseEditBoxPart2();
}
开发者ID:svn2github,项目名称:awb,代码行数:15,代码来源:Main.cs
示例7: UnderscoresLoaded
private static void UnderscoresLoaded(BackgroundRequest req)
{
DelayedRequests.Remove(req);
UnderscoredTitles.Clear();
foreach (Article a in (List<Article>)req.Result)
{
UnderscoredTitles.Add(a.Name);
}
}
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:9,代码来源:Variables.cs
示例8: AutomaticallyDoAnythingComplete
/// <summary>
/// Event that fires when ProcessPage background thread finishes
/// </summary>
/// <param name="req"></param>
private void AutomaticallyDoAnythingComplete(BackgroundRequest req)
{
// must use Invoke so that SkipChecks and CompleteProcessPage are done on main GUI thread
if (InvokeRequired)
{
Invoke(new GenericDelegate(RunSkipChecks));
return;
}
RunSkipChecks();
}
开发者ID:svn2github,项目名称:awb,代码行数:14,代码来源:Main.cs
示例9: ReparseEditBox
// run process page step of reparse edit box in a background thread
// use .Complete event to do rest of processing (alerts etc.) once thread finished
private void ReparseEditBox()
{
if (TheArticle == null)
return;
if((RunProcessPageBackground != null && (RunProcessPageBackground.ThreadStatus() == System.Threading.ThreadState.Running
|| RunProcessPageBackground.ThreadStatus() == System.Threading.ThreadState.Background)) ||
(RunReparseEditBoxBackground != null && (RunReparseEditBoxBackground.ThreadStatus() == System.Threading.ThreadState.Running
|| RunReparseEditBoxBackground.ThreadStatus() == System.Threading.ThreadState.Background)))
{
StatusLabelText = "Background process running";
return;
}
StatusLabelText = "Processing page";
StartProgressBar();
// refresh text from text box to pick up user changes
TheArticle.AWBChangeArticleText("Reparse", txtEdit.Text, false);
RunReparseEditBoxBackground = new BackgroundRequest(ReparseEditBoxBackgroundComplete);
RunReparseEditBoxBackground.Execute(ReparseEditBoxBackground);
RunReparseEditBoxBackground.Complete += ReparseEditBoxComplete;
return;
}
开发者ID:svn2github,项目名称:awb,代码行数:27,代码来源:Main.cs
示例10: Update
/// <summary>
/// Checks to see if AWBUpdater.exe.new exists, if it does, replace it.
/// If not, see if the version of AWB Updater is older than the version on the checkpage, and run AWBUpdater if so
/// </summary>
public static void Update()
{
request = new BackgroundRequest();
request.Execute(new ExecuteFunctionDelegate(UpdateFunc));
}
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:9,代码来源:Updater.cs
示例11: UpdateWikiStatus
/// <summary>
/// Checks log in status, registered and version.
/// </summary>
private WikiStatusResult UpdateWikiStatus()
{
try
{
string typoPostfix = "";
IsBot = false;
//TODO: login?
Site = new SiteInfo(Editor);
//load version check page
BackgroundRequest versionRequest = new BackgroundRequest();
versionRequest.GetHTML(
"http://en.wikipedia.org/w/index.php?title=Wikipedia:AutoWikiBrowser/CheckPage/Version&action=raw");
//load check page
string url;
if (Variables.IsWikia)
url = "http://www.wikia.com/wiki/index.php?title=Wikia:AutoWikiBrowser/CheckPage&action=edit";
else if ((Variables.Project == ProjectEnum.wikipedia) && (Variables.LangCode == LangCodeEnum.ar))
url = "http://ar.wikipedia.org/w/index.php?title=%D9%88%D9%8A%D9%83%D9%8A%D8%A8%D9%8A%D8%AF%D9%8A%D8%A7:%D8%A7%D9%84%D8%A3%D9%88%D8%AA%D9%88%D9%88%D9%8A%D9%83%D9%8A_%D8%A8%D8%B1%D8%A7%D9%88%D8%B2%D8%B1/%D9%85%D8%B3%D9%85%D9%88%D8%AD&action=edit";
else
url = Variables.URLIndex + "?title=Project:AutoWikiBrowser/CheckPage&action=edit";
string strText = Editor.SynchronousEditor.HttpGet(url);
Variables.RTL = Site.IsRightToLeft;
if (Variables.IsCustomProject || Variables.IsWikia)
{
try
{
Variables.LangCode =
Variables.ParseLanguage(Site.Language);
}
catch
{
// use English if language not recognized
Variables.LangCode = LangCodeEnum.en;
}
}
if (Variables.IsWikia)
{
//this object loads a local checkpage on Wikia
//it cannot be used to approve users, but it could be used to set some settings
//such as underscores and pages to ignore
AsyncApiEdit editWikia = (AsyncApiEdit)Editor.Clone();
SiteInfo wikiaInfo = new SiteInfo();
string s = editWikia.SynchronousEditor.Open("Project:AutoWikiBrowser/CheckPage");
typoPostfix = "-" + Variables.LangCode;
// selectively add content of the local checkpage to the global one
strText += Message.Match(s).Value
/*+ Underscores.Match(s).Value*/
+ WikiRegexes.NoGeneralFixes.Match(s);
}
versionRequest.Wait();
string strVersionPage = (string)versionRequest.Result;
//see if this version is enabled
if (!strVersionPage.Contains(AWBVersion + " enabled"))
return WikiStatusResult.OldVersion;
//TODO:
// else
//if (!WeAskedAboutUpdate && strVersionPage.Contains(AWBVersion + " enabled (old)"))
//{
// WeAskedAboutUpdate = true;
// if (
// MessageBox.Show(
// "This version has been superceeded by a new version. You may continue to use this version or update to the newest version.\r\n\r\nWould you like to automatically upgrade to the newest version?",
// "Upgrade?", MessageBoxButtons.YesNo) == DialogResult.Yes)
// {
// Match version = Regex.Match(strVersionPage, @"<!-- Current version: (.*?) -->");
// if (version.Success && version.Groups[1].Value.Length == 4)
// {
// System.Diagnostics.Process.Start(Path.GetDirectoryName(Application.ExecutablePath) +
// "\\AWBUpdater.exe");
// }
// else if (
// MessageBox.Show("Error automatically updating AWB. Load the download page instead?",
// "Load download page?", MessageBoxButtons.YesNo) == DialogResult.Yes)
// {
// Tools.OpenURLInBrowser("http://sourceforge.net/project/showfiles.php?group_id=158332");
// }
// }
//}
CheckPageText = strText;
// don't run GetInLogInStatus if we don't have the username, we sometimes get 2 error message boxes otherwise
bool loggedIn = Editor.User.IsRegistered;
//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:101,代码来源:Session.cs
示例12: UpdateWikiStatus
/// <summary>
/// Checks log in status, registered and version.
/// </summary>
public WikiStatusResult UpdateWikiStatus()
{
try
{
string typoPostfix = "";
string userGroups;
Groups.Clear();
//load version check page
BackgroundRequest br = new BackgroundRequest();
br.GetHTML(
"http://en.wikipedia.org/w/index.php?title=Wikipedia:AutoWikiBrowser/CheckPage/Version&action=raw");
//load check page
if (Variables.IsWikia)
webBrowserLogin.Navigate(
"http://www.wikia.com/wiki/index.php?title=Wikia:AutoWikiBrowser/CheckPage&action=edit");
else if ((Variables.Project == ProjectEnum.wikipedia) && (Variables.LangCode == LangCodeEnum.ar))
webBrowserLogin.Navigate(
"http://ar.wikipedia.org/w/index.php?title=%D9%88%D9%8A%D9%83%D9%8A%D8%A8%D9%8A%D8%AF%D9%8A%D8%A7:%D8%A7%D9%84%D8%A3%D9%88%D8%AA%D9%88%D9%88%D9%8A%D9%83%D9%8A_%D8%A8%D8%B1%D8%A7%D9%88%D8%B2%D8%B1/%D9%85%D8%B3%D9%85%D9%88%D8%AD&action=edit");
else
webBrowserLogin.Navigate(Variables.URLIndex + "?title=Project:AutoWikiBrowser/CheckPage&action=edit");
//wait for both pages to load
webBrowserLogin.Wait();
string strText = webBrowserLogin.GetArticleText();
Variables.RTL = HeadRTL.IsMatch(webBrowserLogin.ToString());
if (Variables.IsWikia)
{
//this object loads a local checkpage on Wikia
//it cannot be used to approve users, but it could be used to set some settings
//such as underscores and pages to ignore
WebControl webBrowserWikia = new WebControl();
webBrowserWikia.Navigate(Variables.URLIndex + "?title=Project:AutoWikiBrowser/CheckPage&action=edit");
webBrowserWikia.Wait();
try
{
Variables.LangCode = Variables.ParseLanguage(webBrowserWikia.GetScriptingVar("wgContentLanguage"));
}
catch
{
// use English if language not recognized
Variables.LangCode = LangCodeEnum.en;
}
typoPostfix = "-" + Variables.ParseLanguage(webBrowserWikia.GetScriptingVar("wgContentLanguage"));
string s = webBrowserWikia.GetArticleText();
// selectively add content of the local checkpage to the global one
strText += Message.Match(s).Value
/*+ Underscores.Match(s).Value*/
+ WikiRegexes.NoGeneralFixes.Match(s);
userGroups = webBrowserWikia.GetScriptingVar("wgUserGroups");
}
else
userGroups = webBrowserLogin.GetScriptingVar("wgUserGroups");
bLoaded = true;
if (Variables.IsCustomProject)
{
try
{
Variables.LangCode =
Variables.ParseLanguage(webBrowserLogin.GetScriptingVar("wgContentLanguage"));
}
catch
{
// use English if language not recognized
Variables.LangCode = LangCodeEnum.en;
}
}
br.Wait();
string strVersionPage = (string)br.Result;
//see if this version is enabled
if (!strVersionPage.Contains(AWBVersion + " enabled"))
{
IsBot = IsAdmin = WikiStatus = false;
return WikiStatusResult.OldVersion;
}
// else
if (!WeAskedAboutUpdate && strVersionPage.Contains(AWBVersion + " enabled (old)"))
{
WeAskedAboutUpdate = true;
if (
MessageBox.Show(
"This version has been superceeded by a new version. You may continue to use this version or update to the newest version.\r\n\r\nWould you like to automatically upgrade to the newest version?",
"Upgrade?", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
Match m_version = Regex.Match(strVersionPage, @"<!-- Current version: (.*?) -->");
if (m_version.Success && m_version.Groups[1].Value.Length == 4)
//.........这里部分代码省略.........
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:101,代码来源:Variables.cs
示例13: PageLoaded
//.........这里部分代码省略.........
bool articleIsRedirect = PageInfo.WasRedirected(page);
// check for redirects when 'follow redirects' is off
if (chkSkipIfRedirect.Checked && Tools.IsRedirect(page.Text))
{
SkipPage("Page is a redirect");
return;
}
//check for redirect
if (followRedirectsToolStripMenuItem.Checked && articleIsRedirect && !PageReload)
{
if ((page.TitleChangedStatus & PageTitleStatus.RedirectLoop) == PageTitleStatus.RedirectLoop)
{
//ignore recursive redirects
SkipRedirect("Recursive redirect");
return;
}
//No double redirects, API should've resolved it
if (filterOutNonMainSpaceToolStripMenuItem.Checked
&& (Namespace.Determine(page.Title) != Namespace.Article))
{
SkipRedirect("Page redirects to non-mainspace");
return;
}
if (ArticleWasRedirected != null)
ArticleWasRedirected(page.OriginalTitle, page.Title);
listMaker.ReplaceArticle(new Article(page.OriginalTitle), TheArticle);
}
/* check for normalized page: since we canonicalize title before API read is requested,
this shouldn't normally be the case: will be the case for female user page normalization
example https://de.wikipedia.org/w/api.php?action=query&prop=info|revisions&intoken=edit&titles=Benutzer%20Diskussion:MarianneBirkholz&rvprop=timestamp|user|comment|content
see the <normalized> block */
if (page.TitleChangedStatus == PageTitleStatus.Normalised)
{
listMaker.ReplaceArticle(new Article(page.OriginalTitle), TheArticle);
}
ErrorHandler.CurrentRevision = page.RevisionID;
if (PageReload)
{
PageReload = false;
GetDiff();
return;
}
if (SkipChecks(!chkSkipAfterProcessing.Checked)) // pre-processing of article
return;
//check not in use
if (TheArticle.IsInUse)
{
if (chkSkipIfInuse.Checked)
{
SkipPage("Page contains {{inuse}}");
return;
}
if (!BotMode && !preParseModeToolStripMenuItem.Checked)
{
MessageBox.Show("This page has the \"Inuse\" tag, consider skipping it");
}
}
/* skip pages containing any Unicode character in Private Use Area as RichTextBox seems to break these
* not exactly wrong as PUA characters won't be found in standard text, but not exactly right to break them either
* Reference: [[Unicode#Character General Category]] PUA is U+E000 to U+F8FF */
Match uPUA = UnicodePUA.Match(page.Text);
if (uPUA.Success)
{
if (!_userWarnedAboutUnicodePUA && !preParseModeToolStripMenuItem.Checked && !BotMode)
{
// provide text around PUA character so user can find it
string uPUAText = page.Text.Substring(uPUA.Index-Math.Min(25, uPUA.Index), Math.Min(25, uPUA.Index) + Math.Min(25, page.Text.Length-uPUA.Index));
MessageBox.Show("This page has character(s) in the Unicode Private Use Area so unfortunately can't be edited with AWB. The page will now be skipped. Surrounding text of first PUA character is: " + uPUAText);
_userWarnedAboutUnicodePUA = true;
}
SkipPage("Page has character in Unicode Private Use Area");
return;
}
// run process page in a background thread
// use .Complete event to do rest of processing (skip checks, alerts etc.) once thread finished
if (automaticallyDoAnythingToolStripMenuItem.Checked)
{
RunProcessPageBackground = new BackgroundRequest(RunProcessPageBackgroundComplete);
RunProcessPageBackground.Execute(ProcessPageBackground);
RunProcessPageBackground.Complete += AutomaticallyDoAnythingComplete;
return;
}
CompleteProcessPage();
}
开发者ID:svn2github,项目名称:awb,代码行数:101,代码来源:Main.cs
示例14: LoadUnderscores
public static void LoadUnderscores(params string[] cats)
{
BackgroundRequest r = new BackgroundRequest(UnderscoresLoaded);
r.HasUI = false;
DelayedRequests.Add(r);
r.GetList(new Lists.CategoryListProvider(), cats);
}
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:7,代码来源:Variables.cs
示例15: bypassAllRedirectsToolStripMenuItem_Click
private void bypassAllRedirectsToolStripMenuItem_Click(object sender, EventArgs e)
{
if (MessageBox.Show("Replacement of links to redirects with direct links is strongly discouraged, " +
"however it could be useful in some circumstances. Are you sure you want to continue?",
"Bypass redirects", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) != DialogResult.Yes)
return;
BackgroundRequest r = new BackgroundRequest();
Enabled = false;
r.BypassRedirects(txtEdit.Text);
while (!r.Done) Application.DoEvents();
Enabled = true;
txtEdit.Text = (string)r.Result;
}
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:17,代码来源:Main.cs
示例16: btnOk_Click
private void btnOk_Click(object sender, EventArgs e)
{
try
{
timer.Enabled = false;
RefreshImgs();
txtBacklog.Text = txtBacklog.Text.Replace("_", " ");
ToDo.Clear();
foreach (DataGridViewRow r in Grid.Rows)
{
if (!r.IsNewRow && !string.IsNullOrEmpty((string)r.Cells[0].Value)
&& !ToDo.ContainsKey((string)r.Cells[0].Value))
ToDo.Add((string)r.Cells[0].Value, (string)r.Cells[1].Value);
}
BackgroundRequest req = new BackgroundRequest();
if (ToDo.Count > 0)
{
string[] imgs = new string[ToDo.Count];
ToDo.Keys.CopyTo(imgs, 0);
Enabled = false;
req.GetList(new ImageFileLinksListProvider(), imgs);
req.Wait();
Enabled = true;
if (req.Result != null && req.Result is List<Article>)
IfdAWBPlugin.AWB.ListMaker.Add((List<Article>)req.Result);
}
}
catch (Exception ex)
{
ErrorHandler.HandleException(ex);
}
DialogResult = DialogResult.OK;
}
开发者ID:reedy,项目名称:AutoWikiBrowser,代码行数:38,代码来源:IfdOptions.cs
示例17: CheckForUpdates
/// <summary>
/// Background request to check enabled state of AWB
/// </summary>
public static void CheckForUpdates()
{
if (_request != null) return;
_request = new BackgroundRequest();
_request.Execute(UpdateFunc);
}
开发者ID:svn2github,项目名称:awb,代码行数:10,代码来源:Updater.cs
示例18: RegexTyposComplete
private void RegexTyposComplete(BackgroundRequest req)
{
if (InvokeRequired)
{
Invoke(new BackgroundRequestComplete(RegexTyposComplete), new object[] { req });
return;
}
chkRegExTypo.Checked = chkSkipIfNoRegexTypo.Enabled = RegexTypos.TyposLoaded;
if (RegexTypos.TyposLoaded)
{
StatusLabelText = RegexTypos.TypoCount + " typos loaded";
if (!EditBoxTab.TabPages.Contains(tpTypos)) EditBoxTab.TabPages.Add(tpTypos);
ResetTypoStats();
}
else
{
RegexTypos = null;
if (EditBoxTab.TabPages.Contains(tpTypos)) EditBoxTab.TabPages.Remove(tpTypos);
}
_loadingTypos = false;
}
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:24,代码来源:Main.cs
示例19: LoadUnderscores
public static void LoadUnderscores(params string[] templates)
{
BackgroundRequest r = new BackgroundRequest(new BackgroundRequestComplete(UnderscoresLoaded));
r.HasUI = false;
DelayedRequests.Add(r);
r.GetList(new WikiFunctions.Lists.WhatTranscludesPageListMakerProvider(), templates);
}
开发者ID:svn2github,项目名称:autowikibrowser,代码行数:7,代码来源:Variables.cs
示例20: UploadFinishedArticlesToServerFinished
private static void UploadFinishedArticlesToServerFinished(BackgroundRequest req)
{
UploadResult(req.Result.ToString());
}
开发者ID:svn2github,项目名称:awb,代码行数:4,代码来源:TypoScanBasePlugin.cs
注:本文中的WikiFunctions.Background.BackgroundRequest类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论