Exemple #1
0
        /// <summary>
        /// Login the specified userName, password and loginSite.
        /// </summary>
        /// <param name="userName">User name.</param>
        /// <param name="password">Password.</param>
        /// <param name="loginSite">Login site.</param>
        /// <returns>cookies string</returns>
        public LoginResult Login(string userName, string password, LoginSite loginSite)
        {
            if (string.IsNullOrEmpty(userName) || string.IsNullOrEmpty(password))
            {
                return new LoginResult()
                       {
                           Result = ResultType.Failed, Msg = "error, username or password can't be null."
                       }
            }
            ;

            ILogin LoginClass = null;

            switch (loginSite)
            {
            case LoginSite.Weibo:
                LoginClass = new WeiboLogin();

                break;

            case LoginSite.WeiboWap:
                LoginClass = new WeiboWapLogin();
                break;
            }

            if (LoginClass == null)
            {
                return new LoginResult()
                       {
                           Result = ResultType.Failed, Msg = "error, can't find the login class."
                       }
            }
            ;

            return(LoginClass.DoLogin(userName, password));
        }
    }
Exemple #2
0
        /// <summary>
        /// Login the specified userName, password and loginSite.
        /// </summary>
        /// <param name="userName">User name.</param>
        /// <param name="password">Password.</param>
        /// <param name="loginSite">Login site.</param>
        /// <returns>cookies string</returns>
        public LoginResult Login(string userName, string password, LoginSite loginSite)
        {
            if (string.IsNullOrEmpty (userName) || string.IsNullOrEmpty (password))
                return new LoginResult (){Result = ResultType.Failed, Msg = "error, username or password can't be null."};

            ILogin LoginClass = null;

            switch (loginSite) {
            case LoginSite.Weibo:
                LoginClass = new WeiboLogin ();
                break;
            case LoginSite.WeiboWap:
                LoginClass = new WeiboWapLogin ();
                break;
            case LoginSite.Baidu:
                LoginClass = new BaiduLogin ();
                break;
            }

            if(LoginClass == null)
                return new LoginResult (){Result = ResultType.Failed, Msg = "error, can't find the login class."};

            return LoginClass.DoLogin (userName, password);
        }