GetUrlFor() static private method

static private GetUrlFor ( string action ) : string
action string
return string
        /// <summary>
        ///
        /// </summary>
        private static void UploadFinishedArticlesToServer()
        {
            if (isUploading || EditAndIgnoredPages == 0)
            {
                return;
            }

            isUploading = true;

            editsAndIgnored = EditAndIgnoredPages;

            AWB.StartProgressBar();
            AWB.StatusLabelText = "Uploading " + editsAndIgnored + " TypoScan articles to server...";

            NameValueCollection postVars = new NameValueCollection();

            postVars.Add("articles", string.Join(",", SavedPages.ToArray()));
            postVars.Add("skipped", string.Join(",", SkippedPages.ToArray()));
            postVars.Add("skipreason", string.Join(",", SkippedReasons.ToArray()));

            postVars.Add("user", AWB.Privacy ? "[withheld]" : Variables.User.Name);

            if (!AWB.Shutdown)
            {
                thread.PostData(Common.GetUrlFor("finished"), postVars);
            }
            else
            {
                UploadResult(Tools.PostData(postVars, Common.GetUrlFor("finished")));
            }
        }
Example #2
0
        public List <Article> MakeList(params string[] searchCriteria)
        {
            List <Article> articles = new List <Article>();

            // TODO: must support other wikis
            if (Variables.Project != ProjectEnum.wikipedia || Variables.LangCode != LangCodeEnum.en)
            {
                MessageBox.Show("This plugin currently supports only English Wikipedia",
                                "TypoScan", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                return(articles);
            }

            string html = Tools.GetHTML(Common.GetUrlFor("displayarticles"));

            using (XmlTextReader reader = new XmlTextReader(new StringReader(html)))
            {
                while (reader.Read())
                {
                    if (reader.Name.Equals("article"))
                    {
                        reader.MoveToAttribute("id");
                        int    id    = int.Parse(reader.Value);
                        string title = reader.ReadString();
                        articles.Add(new Article(title));
                        if (!TypoScanAWBPlugin.PageList.ContainsKey(title))
                        {
                            TypoScanAWBPlugin.PageList.Add(title, id);
                        }
                    }
                }
            }
            TypoScanAWBPlugin.CheckoutTime = DateTime.Now;
            return(articles);
        }
        //TODO:No point passing a number of literal strings for the skip reasons... We should use an ID or something, and pass it once
        /// <summary>
        ///
        /// </summary>
        private static void UploadFinishedArticlesToServer()
        {
            if (IsUploading || EditAndIgnoredPages == 0)
            {
                return;
            }

            IsUploading = true;

            EditsAndIgnored = EditAndIgnoredPages;

            AWB.StartProgressBar();
            AWB.StatusLabelText = "Uploading " + EditsAndIgnored + " TypoScan articles to server...";

            CurrentlyUploadingSaved.AddRange(SavedPages);
            CurrentlyUploadingSkipped.AddRange(SkippedPages);
            CurrentlyUploadingReasons.AddRange(SkippedReasons);

            NameValueCollection postVars = new NameValueCollection
            {
                { "articles", string.Join(",", CurrentlyUploadingSaved.ToArray()) },
                { "skipped", string.Join(",", CurrentlyUploadingSkipped.ToArray()) },
                { "skipreason", string.Join(",", CurrentlyUploadingReasons.ToArray()) },
                { "user", AWB.Privacy ? "[withheld]" : AWB.TheSession.User.Name }
            };

            if (!AWB.Shutdown)
            {
                Thread.PostData(Common.GetUrlFor("finished"), postVars);
            }
            else
            {
                UploadResult(Tools.PostData(postVars, Common.GetUrlFor("finished")));
            }
        }
Example #4
0
        private static void UploadFinishedArticlesToServer()
        {
            int editsAndIgnored = EditAndIgnoredPages;

            if (editsAndIgnored == 0)
            {
                return;
            }

            AWB.StartProgressBar();
            AWB.StatusLabelText = "Uploading " + editsAndIgnored + " TypoScan articles to server...";

            NameValueCollection postVars = new NameValueCollection();

            postVars.Add("articles", string.Join(",", SavedPages.ToArray()));
            postVars.Add("skipped", string.Join(",", SkippedPages.ToArray()));
            postVars.Add("skipreason", string.Join(",", SkippedReasons.ToArray()));

            if (!AWB.Privacy)
            {
                postVars.Add("user", Variables.User.Name);
            }
            else
            {
                postVars.Add("user", "[withheld]");
            }

            try
            {
                string result = Tools.PostData(postVars, Common.GetUrlFor("finished"));
                if (string.IsNullOrEmpty(Common.CheckOperation(result)))
                {
                    UploadedThisSession += editsAndIgnored;
                    SavedPages.Clear();
                    SkippedPages.Clear();
                    SkippedReasons.Clear();

                    if ((UploadedThisSession % 100) == 0)
                    {
                        CheckoutTime = new DateTime();
                    }
                }
            }
            catch (System.IO.IOException ex)
            {
                Tools.WriteDebug("TypoScanAWBPlugin", ex.Message);
            }
            catch (System.Net.WebException we)
            {
                Tools.WriteDebug("TypoScanAWBPlugin", we.Message);
            }
            AWB.StopProgressBar();
            AWB.StatusLabelText = "";
        }
Example #5
0
        public List <Article> MakeList(params string[] searchCriteria)
        {
            List <Article> articles = new List <Article>();

            using (
                XmlTextReader reader =
                    new XmlTextReader(new StringReader(Tools.GetHTML(Common.GetUrlFor("displayarticles") + "&count=" + Count))))
            {
                while (reader.Read())
                {
                    if (reader.Name.Equals("site"))
                    {
                        reader.MoveToAttribute("address");
                        string site = reader.Value;

                        if (site != Common.GetSite())
                        //Probably shouldnt get this as the wanted site was sent to the server
                        {
                            MessageBox.Show("Wrong Site");
                            return(articles);
                        }
                    }
                    else if (reader.Name.Equals("article"))
                    {
                        reader.MoveToAttribute("id");
                        int    id    = int.Parse(reader.Value);
                        string title = reader.ReadString();
                        articles.Add(new Article(title));
                        if (!TypoScanBasePlugin.PageList.ContainsKey(title))
                        {
                            TypoScanBasePlugin.PageList.Add(title, id);
                        }
                    }
                }
            }
            TypoScanBasePlugin.CheckoutTime = DateTime.Now;
            return(articles);
        }
Example #6
0
 private void linkStats_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     linkStats.LinkVisited = true;
     Tools.OpenURLInBrowser(Common.GetUrlFor("stats"));
 }