/// <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")));
            }
        }
        //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")));
            }
        }
Ejemplo n.º 3
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 = "";
        }