예제 #1
0
        /// <summary>
        /// Uses the provided credentials to execute a login and will set cookies. This can be used to make authenticated requests afterwards.
        /// </summary>
        /// <param name="login"></param>
        /// <param name="passwd"></param>
        /// <returns>Boolean</returns>
        public bool DokuAuth(string login = null, string passwd = null)
        {
            try
            {
                this._cookie = new CookieContainer();

                Data.XMLMethodBool ma = this.Get <Data.XMLMethodBool>(
                    XmlRpcRequest.dokuwiki_login,
                    ((string.IsNullOrWhiteSpace(login)) ? this._login : login),
                    ((string.IsNullOrWhiteSpace(passwd)) ? this._passwd : passwd)
                    );
                if (ma == null)
                {
                    throw new ArgumentNullException();
                }
                int result = 0;
                if (Int32.TryParse(ma.Params.Param.Value.Boolean, out result))
                {
                    return(this._isAuth = ((result == 1) ? true : false));
                }
                throw new ArgumentNullException();
            }
            catch (RpcXmlException e)
            {
                this._isAuth = false;
                throw e;
            }
            catch (Exception)
            {
                return(this._isAuth = false);
            }
        }
예제 #2
0
 /// <summary>
 /// Create or update Wiki Page.
 /// </summary>
 /// <param name="pagename">page name</param>
 /// <param name="rawtxt">raw Wiki text</param>
 /// <param name="sum">change summary</param>
 /// <param name="minor">minor</param>
 /// <returns>bool</returns>
 public bool DokuPagePut(string pagename, string rawtxt, string sum = null, bool minor = false)
 {
     try
     {
         // TODO: add attr
         this._CheckAuth();
         if (
             (string.IsNullOrWhiteSpace(pagename)) ||
             (string.IsNullOrWhiteSpace(rawtxt))
             )
         {
             throw new ArgumentNullException();
         }
         Data.XMLMethodBool ma = this.Get <Data.XMLMethodBool>(
             XmlRpcRequest.wiki_putPage,
             pagename,
             rawtxt,
             String.Empty
             );
         if (ma == null)
         {
             throw new ArgumentNullException();
         }
         int result = 0;
         if (Int32.TryParse(ma.Params.Param.Value.Boolean, out result))
         {
             return((result == 1) ? true : false);
         }
         throw new ArgumentNullException();
     }
     catch (Exception e)
     {
         throw new RpcXmlException(
                   className + e.Message,
                   5024
                   );
     }
 }