/// <summary> /// Creates an instance of the class /// </summary> public SiteInfo(IApiEdit editor) { Editor = editor; ScriptPath = editor.URL; uri = new Uri(ScriptPath); try { if (!LoadSiteInfo()) { var ret = ParseErrorFromSiteInfoOutput(); if (ret is bool && !(bool)ret) { throw new WikiUrlException(); } var ex = ret as Exception; if (ex != null) { throw ex; } } } catch (WikiException) { throw; } catch (WebException) { throw; } catch (Exception ex) { throw new WikiUrlException(ex); } }
/// <summary> /// Creates an instance of the class /// </summary> public SiteInfo(IApiEdit editor) { Editor = editor; ScriptPath = editor.URL; try { if (!LoadSiteInfo()) { var ret = ParseErrorFromSiteInfoOutput(); if (ret is bool && !(bool)ret) { throw new WikiUrlException(); } if (ret is Exception) { Exception ex = (Exception)ret; throw ex; } } } catch (WikiException) { throw; } catch (Exception ex) { throw new WikiUrlException(ex); } }
/// <summary> /// Creates an instance of the class /// </summary> public SiteInfo(IApiEdit editor) { Editor = editor; ScriptPath = editor.URL; try { if (!LoadSiteInfo()) { var ret = ParseErrorFromSiteInfoOutput(); if (ret is bool && !(bool)ret) { throw new WikiUrlException(); } if ( ret is Exception ) { Exception ex = (Exception) ret; throw ex; } } } catch (WikiException) { throw; } catch (Exception ex) { throw new WikiUrlException(ex); } }
public AWBProfilesForm(IApiEdit editor) { InitializeComponent(); loginAsThisAccountToolStripMenuItem.Visible = true; loginAsThisAccountToolStripMenuItem.Click += lvAccounts_DoubleClick; Editor = editor; }
public static SiteInfo CreateOrLoad(IApiEdit editor) { SiteInfo si = (SiteInfo)ObjectCache.Global.Get<SiteInfo>(Key(editor.URL)); if (si != null) return si; si = new SiteInfo(editor); ObjectCache.Global[Key(editor.URL)] = si; return si; }
/// <summary> /// Bypasses all redirects in the article /// </summary> public void BypassRedirects(string article, IApiEdit editor) { Result = StrParam = article; ObjParam1 = editor; if (HasUI) { UI = new PleaseWait(); UI.Show(Variables.MainForm as Form); } InitThread(BypassRedirectsFunc); }
public static SiteInfo CreateOrLoad(IApiEdit editor) { SiteInfo si = (SiteInfo)ObjectCache.Global.Get<SiteInfo>(Key(editor.URL)); if (si != null && Namespace.VerifyNamespaces(si.Namespaces)) { return si; } si = new SiteInfo(editor); ObjectCache.Global[Key(editor.URL)] = si; return si; }
public static SiteInfo CreateOrLoad(IApiEdit editor) { SiteInfo si = (SiteInfo)ObjectCache.Global.Get <SiteInfo>(Key(editor.URL)); if (si != null) { return(si); } si = new SiteInfo(editor); ObjectCache.Global[Key(editor.URL)] = si; return(si); }
private void btnLogin_Click(object sender, EventArgs e) { groupBox2.Enabled = false; try { Editor = new AsyncApiEdit(txtURL.Text, this);//ApiEdit(txtURL.Text); Editor.Login(txtUsername.Text, txtPassword.Text); Editor.Wait(); txtEdit.Text = ""; groupBox2.Enabled = Editor.User.IsRegistered; btnSave.Enabled = false; } catch (Exception ex) { MessageBox.Show(ex.Message, ex.GetType().Name); } }
/// <summary> /// Creates an instance of the class /// </summary> public SiteInfo(IApiEdit editor) { Editor = editor; ScriptPath = editor.URL; try { if (!LoadSiteInfo()) throw new WikiUrlException(); } catch (WikiUrlException) { throw; } catch (Exception ex) { throw new WikiUrlException(ex); } }
/// <summary> /// Creates an instance of the class /// </summary> public SiteInfo(IApiEdit editor) { Editor = editor; ScriptPath = editor.URL; try { if (!LoadSiteInfo()) { throw new WikiUrlException(); } } catch (WikiUrlException) { throw; } catch (Exception ex) { throw new WikiUrlException(ex); } }
/// <summary> /// checks wikilinks to make them bypass redirects /// </summary> private void BypassRedirectsFunc() { // checks links to make them bypass redirects and (TODO) disambigs Dictionary <string, string> knownLinks = new Dictionary <string, string>(); if (HasUI) { UI.Worker = Thread.CurrentThread; } IApiEdit editor = ObjParam1 as IApiEdit; if (editor == null) { Result = ""; InvokeOnError(); return; } try { if (HasUI) { UI.Status = "Loading links"; } MatchCollection links = WikiRegexes.WikiLinksOnlyPossiblePipe.Matches(StrParam); if (HasUI) { UI.Status = "Processing links"; UI.SetProgress(0, links.Count); } int n = 0; foreach (Match m in links) { string link = m.Value; string article = m.Groups[1].Value.TrimStart(new[] { ':' }); // if the link is unpiped, use the target as the new link's pipe text string linkText = (!string.IsNullOrEmpty(m.Groups[2].Value)) ? m.Groups[2].Value : article; string ftu = Tools.TurnFirstToUpper(article); string value; if (!knownLinks.TryGetValue(ftu, out value)) { // get text string text; try { text = editor.Open(article, false); //TODO:Resolve redirects betterer } catch { continue; } string dest = article; // test if redirect if (Tools.IsRedirect(text)) { dest = HttpUtility.UrlDecode(Tools.RedirectTarget(text).Replace("_", " ")); string directLink = "[[" + dest + "|" + linkText + "]]"; StrParam = StrParam.Replace(link, directLink); } knownLinks.Add(ftu, Tools.TurnFirstToUpper(dest)); } else if (value != ftu) { string directLink = "[[" + value + "|" + linkText + "]]"; StrParam = StrParam.Replace(link, directLink); } n++; if (HasUI) { UI.SetProgress(n, links.Count); } } Result = StrParam; InvokeOnComplete(); // UI.Close(); } catch (Exception e) { // UI.Close(); ErrorException = e; InvokeOnError(); } }