当前位置: 首页>>代码示例>>C#>>正文


C# Page.GetEditSessionData方法代码示例

本文整理汇总了C#中DotNetWikiBot.Page.GetEditSessionData方法的典型用法代码示例。如果您正苦于以下问题:C# Page.GetEditSessionData方法的具体用法?C# Page.GetEditSessionData怎么用?C# Page.GetEditSessionData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DotNetWikiBot.Page的用法示例。


在下文中一共展示了Page.GetEditSessionData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RenameTo

 /// <summary>Renames the page.</summary>
 /// <param name="newTitle">New title of that page.</param>
 /// <param name="reason">Reason for renaming.</param>
 public void RenameTo(string newTitle, string reason)
 {
     if (string.IsNullOrEmpty(newTitle))
         throw new ArgumentNullException("newTitle");
     if (string.IsNullOrEmpty(title))
         throw new WikiBotException(Bot.Msg("No title specified for page to rename."));
     //Page mp = new Page(site, "Special:Movepage/" + HttpUtility.UrlEncode(title));
     Page mp = new Page(site, "Special:Movepage/" + title);
     mp.GetEditSessionData();
     if (string.IsNullOrEmpty(mp.editSessionToken))
         throw new WikiBotException(string.Format(
             Bot.Msg("Unable to rename page \"{0}\" to \"{1}\"."), title, newTitle));
     string postData = string.Format("wpNewTitle={0}&wpOldTitle={1}&wpEditToken={2}" +
         "&wpReason={3}", HttpUtility.UrlEncode(newTitle), HttpUtility.UrlEncode(title),
         HttpUtility.UrlEncode(mp.editSessionToken), HttpUtility.UrlEncode(reason));
     string respStr = site.PostDataAndGetResultHTM(site.indexPath +
         "index.php?title=Special:Movepage&action=submit", postData);
     if (site.editSessionTokenRE2.IsMatch(respStr))
         throw new WikiBotException(string.Format(
             Bot.Msg("Failed to rename page \"{0}\" to \"{1}\"."), title, newTitle));
     Bot.LogEvent(
         Bot.Msg("Page \"{0}\" was successfully renamed to \"{1}\"."), title, newTitle);
     title = newTitle;
 }
开发者ID:wikigit,项目名称:Picasa-Review-Bot,代码行数:27,代码来源:DotNetWikiBot.cs

示例2: RenameTo

 /// <summary>Renames the page.</summary>
 /// <param name="newTitle">New title of that page.</param>
 /// <param name="reason">Reason for renaming.</param>	
 public void RenameTo(string newTitle, string reason)
 {
     Page mp = new Page(site, "Special:Movepage/" + HttpUtility.UrlEncode(title));
     mp.GetEditSessionData();
     if (String.IsNullOrEmpty(mp.editSessionToken)) {
         Console.WriteLine("Unable to rename page \"" + title + "\" to \"" +
             newTitle + "\".");
         return;
     }
        		HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(site.site +
         site.indexPath + "index.php?title=Special:Movepage&action=submit");
     webReq.Proxy.Credentials = CredentialCache.DefaultCredentials;
     webReq.Method = "POST";
     webReq.ContentType = Bot.webContentType;
     webReq.UserAgent = Bot.botVer;
     webReq.CookieContainer = new CookieContainer();
     string postData = string.Format("wpNewTitle={0}&wpOldTitle={1}&wpEditToken={2}" +
         "&wpReason={3}", HttpUtility.UrlEncode(newTitle), HttpUtility.UrlEncode(title),
         mp.editSessionToken, HttpUtility.UrlEncode(reason));
     foreach (Cookie cookie in site.cookies)
         webReq.CookieContainer.Add(cookie);
     byte[] postBytes = Encoding.UTF8.GetBytes(postData);
     webReq.ContentLength = postBytes.Length;
     Stream reqStrm = webReq.GetRequestStream();
     reqStrm.Write(postBytes, 0, postBytes.Length);
     reqStrm.Close();
     HttpWebResponse webResp = (HttpWebResponse) webReq.GetResponse();
     StreamReader strmReader = new StreamReader(webResp.GetResponseStream());
     string respStr = strmReader.ReadToEnd();
     strmReader.Close();
     webResp.Close();
     if (site.editSessionTokenRE2.IsMatch(respStr)) {
         Console.WriteLine("Failed to rename page \"" + title + "\" to \"" +
             newTitle + "\".");
         return;
     }
     Console.WriteLine("Page \"" + title + "\" was successfully renamed to \"" +
         newTitle + "\".");
     title = newTitle;
 }
开发者ID:BackupTheBerlios,项目名称:wikifighter-svn,代码行数:43,代码来源:DotNetWikiBot.cs

示例3: RenameTo

 /// <summary>Renames the page.</summary>
 /// <param name="newTitle">New title of that page.</param>
 /// <param name="reason">Reason for renaming.</param>
 public void RenameTo(string newTitle, string reason, bool leaveRedirect)
 {
     if (string.IsNullOrEmpty(newTitle))
         throw new ArgumentNullException("newTitle");
     if (string.IsNullOrEmpty(title))
         throw new WikiBotException(Bot.Msg("No title specified for page to rename."));
     //Page mp = new Page(site, "Special:Movepage/" + HttpUtility.UrlEncode(title));
     Page mp = new Page(site, "Special:Movepage/" + title);
     mp.GetEditSessionData();
     if (string.IsNullOrEmpty(mp.editSessionToken))
         throw new WikiBotException(string.Format(
             Bot.Msg("Unable to rename page \"{0}\" to \"{1}\"."), title, newTitle));
     if (Bot.askConfirm) {
         Console.Write("\n\n" +
             Bot.Msg("The page \"{0}\" is going to be renamed to \"{1}\".\n"),
             title, newTitle);
         if(!Bot.UserConfirms())
             return;
     }
     string postData = string.Format("wpNewTitle={0}&wpOldTitle={1}&wpEditToken={2}" +
         "&wpReason={3}", HttpUtility.UrlEncode(newTitle), HttpUtility.UrlEncode(title),
         HttpUtility.UrlEncode(mp.editSessionToken), HttpUtility.UrlEncode(reason));
     if (leaveRedirect)
         postData += "&wpLeaveRedirect=1";
     string respStr = site.PostDataAndGetResultHTM(site.indexPath +
         "index.php?title=Special:Movepage&action=submit", postData);
     if (Site.editSessionTokenRE2.IsMatch(respStr))
         throw new WikiBotException(string.Format(
             Bot.Msg("Failed to rename page \"{0}\" to \"{1}\"."), title, newTitle));
     Console.WriteLine(
         Bot.Msg("Page \"{0}\" was successfully renamed to \"{1}\"."), title, newTitle);
     title = newTitle;
 }
开发者ID:knabbi,项目名称:GW2WBot,代码行数:36,代码来源:DotNetWikiBot.cs

示例4: LogIn

 /// <summary>Logs in and retrieves cookies.</summary>    	  	
 private void LogIn()
 {
     HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(site + indexPath +
         "index.php?title=Special:Userlogin&action=submitlogin&type=login");
     String postData = String.Format("wpName=+{0}&wpPassword={1}&wpRemember=1&wpLoginattempt=Log+in",
         new string[] {userName, userPass});
     webReq.Method = "POST";
     webReq.ContentType = Bot.webContentType;
     webReq.UserAgent = Bot.botVer;
     webReq.Proxy.Credentials = CredentialCache.DefaultCredentials;
     webReq.CookieContainer = new CookieContainer();
     webReq.AllowAutoRedirect = false;
     byte[] postBytes = Encoding.UTF8.GetBytes(postData);
     webReq.ContentLength = postBytes.Length;
     Stream reqStrm = webReq.GetRequestStream();
     reqStrm.Write(postBytes, 0, postBytes.Length);
     reqStrm.Close();
     try {
         HttpWebResponse webResp = (HttpWebResponse)webReq.GetResponse();
         cookies = webResp.Cookies;
         webResp.Close();
     }
     catch (WebException) {
         if (indexPath == "/wiki/")
             throw new WikiBotException("\n\nLogin failed. Check your username and password.\n");
         indexPath = "/wiki/";
         wikiPath = "/wiki/index.php?title=";
         LogIn();
         return;
     }
     Page testLogin = new Page(this, "Non-existing-page");
     testLogin.GetEditSessionData();
     if (String.IsNullOrEmpty(testLogin.editSessionToken)) {
         throw new WikiBotException("\n\nLogin failed. Check your username and password.\n");
     }
     Console.WriteLine("Logged in as " + userName);
 }
开发者ID:BackupTheBerlios,项目名称:wikifighter-svn,代码行数:38,代码来源:DotNetWikiBot.cs


注:本文中的DotNetWikiBot.Page.GetEditSessionData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。