Пример #1
0
 public void SetInternetExplorerCookies()
 {
     if (_session != null)
     {
         foreach (WebClientCookie cookie in _session.Cookies)
         {
             EssentialUtil.SetWinINETCookieString(_ticketUri.GetDomain(), null, cookie.Key + "=" + cookie.Value);
         }
     }
 }
Пример #2
0
        private bool Login(string userName, string password, out string errorMessage)
        {
            errorMessage = "";
            try
            {
                ClearSession();
                string session = _httpClient.CreateSession(_gameUri.GetLoginViaPostMethodUri(), GamePostData.GetLogin(userName, password), "");

                if (!string.IsNullOrEmpty(session) && session.Equals(Constants.LOGIN_FAILED))
                {
                    errorMessage = Constants.LOGIN_FAILED;
                    OnLoginFailed();
                    return(false);
                }
                else if (!string.IsNullOrEmpty(session) && !session.Equals(Constants.ERROR))
                {
                    SetSession(session, _httpClient.GetCookies(_gameUri.GetDomain()), (int)Enums.SESSION_STATUS.VALID);
                    foreach (WebClientCookie cookie in _session.Cookies)
                    {
                        EssentialUtil.SetWinINETCookieString(_gameUri.GetDomain(), null, cookie.Key + "=" + cookie.Value);
                    }
                    OnLoggedIn();
                    return(true);
                }
                errorMessage = Constants.ERROR;
                OnErrorOccurred("Error occurred during Login.");
                return(false);
            }
            catch (Exception ex)
            {
                ClearSession();
                errorMessage = Constants.ERROR;
                OnErrorOccurred(ex.Message);
                return(false);
            }
        }