Esempio n. 1
0
 public string Save(string title,
                    string section,
                    string text,
                    string summary,
                    MinorFlags minor,
                    CreateFlags create,
                    WatchFlags watch,
                    SaveFlags mode,
                    bool bot)
 {
     ParameterCollection parameters = new ParameterCollection
     {
         { "prop", "info" },
         { "intoken", "edit" }
     };
     XmlDocument doc = Query(QueryBy.Titles, parameters, title);
     XmlNode pageNode = doc.SelectSingleNode("//page");
     string token = pageNode != null ? pageNode.Attributes["edittoken"].Value : "";
     return Save(title,
                 section,
                 text,
                 summary,
                 minor,
                 create,
                 watch,
                 mode,
                 bot,
                 "",
                 "",
                 token);
 }
Esempio n. 2
0
        public string Save(string title,
                           string section,
                           string text,
                           string summary,
                           MinorFlags minor,
                           CreateFlags create,
                           WatchFlags watch,
                           SaveFlags mode,
                           bool bot,
                           string basetimestamp,
                           string starttimestamp,
                           string token)
        {
            if (string.IsNullOrEmpty(title))
            {
                throw new ArgumentException("Title shouldn't be empty.", "title");
            }
            if (string.IsNullOrEmpty(token))
            {
                throw new ArgumentException("Token shouldn't be empty.", "token");
            }

            ParameterCollection parameters = new ParameterCollection
            {
                { "title", title },
                { "token", token }
            };
            if (mode == SaveFlags.Replace && !string.IsNullOrEmpty(section))
            {
                parameters.Add("section", section);
            }
            if (minor != MinorFlags.None)
            {
                parameters.Add(minor.ToString().ToLower());
            }
            if (create != CreateFlags.None)
            {
                parameters.Add(create.ToString().ToLower());
            }
            if (watch != WatchFlags.None)
            {
                parameters.Add("watchlist", watch.ToString().ToLower());
            }
            if (mode == SaveFlags.Append)
            {
                parameters.Add("appendtext", text);
            }
            else if (mode == SaveFlags.Prepend)
            {
                parameters.Add("prependtext", text);
            }
            else
            {
                parameters.Add("text", text);
            }
            if (bot)
            {
                parameters.Add("bot");
            }
            if (!string.IsNullOrEmpty(basetimestamp))
            {
                parameters.Add("basetimestamp", basetimestamp);
            }
            if (!string.IsNullOrEmpty(starttimestamp))
            {
                parameters.Add("starttimestamp", starttimestamp);
            }
            if (!string.IsNullOrEmpty(summary))
            {
                parameters.Add("summary", summary);
            }

            try
            {
                XmlDocument xml = MakeRequest(Action.Edit, parameters);
                XmlNode result = xml.SelectSingleNode("//edit[@newrevid]");
                if (result != null)
                {
                    return result.Attributes["newrevid"].Value;
                }
            }
            catch (WebException e)
            {
                throw new WikiException("Saving failed", e);
            }
            return null;
        }
Esempio n. 3
0
 public string Save(string title, string text, string summary, MinorFlags minor, bool botEdit)
 {
     return Save(title,
                 "",
                 text,
                 summary,
                 minor,
                 CreateFlags.None,
                 WatchFlags.None,
                 SaveFlags.Replace,
                 botEdit);
 }