protected void OnLoginHandler(HandlingResult loginResult) { if (LoginEvnet != null) { LoginEvnet(loginResult); } }
private void _webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { HandlingResult result = new HandlingResult(); result.Successed = false; if (e.Url.AbsoluteUri.Replace("//","/").Replace("http:","http:/").Contains("http://www.scal.com.cn/Web/Html/Home/Special.html")) { _wBrowser.Navigate(new Uri("http://www.scal.com.cn/Web/AirUser/Info")); } if (e.Url.AbsoluteUri.Contains("http://www.scal.com.cn/Web/AirUser/Info")) { //TODO get member infor GetMemberInfo(); if (_loginModel.ContainsCook) { CookieInformation = GetCookieString(e.Url.AbsoluteUri); _wBrowser.DocumentCompleted -= _webBrowser_DocumentCompleted; result.Successed = true; OnLoginHandler(result); } } }
void _webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e) { HandlingResult result=new HandlingResult(); result.Successed = false; if (e.Url.AbsoluteUri.Contains(_loginModel.LoginCondition)) { result.Successed = true; if (_loginModel.ContainsCook) { CookieInformation = GetCookieString(e.Url.AbsoluteUri); XWebClient client = new XWebClient(); client.Headers.Add(HttpRequestHeader.Accept, "application/x-ms-application, image/jpeg, application/xaml+xml, image/gif, image/pjpeg, application/x-ms-xbap, */*"); client.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET4.0C; .NET4.0E)"); client.Headers.Add(HttpRequestHeader.Cookie, CookieInformation); } OnLoginHandler(result); } }