public async void Check() { try { client = new S1WebClient(); var result = await client.DownloadStringTaskAsync(Addr + ParserFactory.Path); if (result.Length > 0) { var data = ParserFactory.ParseMainListData(result); if (NotifySuccess != null /*&& data.Count > 0*/) { System.Diagnostics.Debug.WriteLine("NotifySuccess " + Addr); NotifySuccess(this); return; } } } catch (S1UserException e) { if(e.Message != null ) UserException = e; } catch (Exception) { } finally { if (NotifyComplete != null) NotifyComplete(this); } }
public async void Check() { try { client = new S1WebClient(); var result = await client.DownloadStringTaskAsync(Addr + ParserFactory.Path + "?module=forumnav"); if (result.Length > 0) { var data = ParserFactory.ParseMainListData(result); if (NotifySuccess != null /*&& data.Count > 0*/) { System.Diagnostics.Debug.WriteLine("NotifySuccess " + Addr); NotifySuccess(this); return; } } } catch (S1UserException e) { if (e.Message != null) { UserException = e; } } catch (Exception) { } finally { if (NotifyComplete != null) { NotifyComplete(this); } } }
public static async Task <string> GetVerifyString(this S1WebClient client) { string verify = ""; //use DownloadString will just return cached data, which is not what i want //post dummy data to disable cache var privacyPage = await client.PostDataTaskAsync(new Uri(UserAction.PrivacyUrl)); var root = new HtmlDoc(privacyPage).RootElement; var input = root.FindFirst("input", (e) => e.Attributes["name"] == "verify"); if (input != null) { verify = input.Attributes["value"]; } else { throw new S1UserException(ErrorParser.Parse(root)); } return(verify); }
private async void DoLogin() { client = new S1WebClient(); client.AddPostParam(stepKey, 2); client.AddPostParam(loginTypeKey, loginType); client.AddPostParam(userKey, testUser); client.AddPostParam(passKey, testPass); client.AddPostParam(cktimeKey, cktime); Result = await client.PostDataTaskAsync(new Uri(loginUrl)); foreach (Cookie c in client.Cookies) if (c.Name.Contains("uid")) Uid = c.Value; if (OnUpdateView != null) OnUpdateView(Result); }
private async void DoTest() { client = new S1WebClient(); int fid = 2; //client.Headers[HttpRequestHeader.Referer] = "http://192.168.0.113:8080/phpwind/read.php?tid=1"; //client.AddPostParam("replytouser", "asdf"); //client.AddPostParam("cyid", "1"); //client.AddPostParam("iscontinue", "0"); //client.AddPostParam("atc_desc1", ""); //client.AddPostParam("_hexie", "36c309f2"); client.AddPostParam("atc_title", "12345"); client.AddPostParam("verify", verify); client.AddPostParam("atc_usesign", "1"); client.AddPostParam("atc_convert", "1"); client.AddPostParam("atc_autourl", "1"); client.AddPostParam("stylepath", "wind"); client.AddPostParam(stepKey, 2); client.AddPostParam("action", "reply"); client.AddPostParam("fid", fid); client.AddPostParam("tid", "1"); client.AddPostParam("ajax", "1"); client.AddPostParam("atc_content", "[s:13] test from client @" + DateTime.Now.ToShortTimeString() + deviceInfo); Result = await client.PostDataTaskAsync(new Uri(postFormatString + fid)); //Result = await client.PostMultipartTaskAsync(new Uri(postUrl)); string error = ""; var match =resultPattern.Match(Result); if (match.Success) error = match.Groups["data"].Value; if (error.Length < 200) Debug.WriteLine(error); if (OnUpdateView != null) OnUpdateView(Result + ConvertExtendedASCII(error)); }
public async void TestServer() { Status = "Connecting"; try{ client = new S1WebClient(); var result = await client.DownloadStringTaskAsync(Addr + path); Status = "Wrong Data"; if (result.Length > 0) { var root = new HtmlDoc(result).RootElement; var serverDownTitle = ServerListViewModel.ServerDownTitle; if (serverDownTitle != null && root.FindFirst("title").InnerHtml.Contains(serverDownTitle)) { Status = "Server Down"; if (NotifySuccess != null) NotifySuccess(); } else { if (NotifySuccess != null) NotifySuccess(); Status = "Success"; } } } catch (TaskCanceledException) { Status = "Cancled"; } catch(Exception) { Status = "Failed"; } }