Ejemplo n.º 1
0
 public async Task <byte[]> SubmitAsync(SubmitHandler sh, string url = SubmitUrl)
 {
     return(await Task.Run(() =>
     {
         lock (_client)
         {
             using (new ClientEngagedAsyncKeeper(this))
             {
                 try
                 {
                     _client.Headers.Add(HttpRequestHeader.Referer, sh.RefPage.PageUrl);
                     var t = _client.UploadValuesTaskAsync(url, "POST", sh.KeyValues);
                     t.Wait();
                     return t.Result;
                 }
                 catch (AggregateException e)
                 {
                     if (e.InnerException is WebException we && we.Status == WebExceptionStatus.RequestCanceled)
                     {
                         throw new RequestCancelled();
                     }
                     throw e;
                 }
             }
         }
     }));
 }
Ejemplo n.º 2
0
 public byte[] Submit(SubmitHandler sh, string url = SubmitUrl)
 {
     lock (_client)
     {
         _client.Headers.Add(HttpRequestHeader.Referer, sh.RefPage.PageUrl);
         return(_client.UploadValues(url, "POST", sh.KeyValues));
     }
 }
Ejemplo n.º 3
0
        public static SubmitHandler CreateSubmit(PageInfo pi, Question.Choice c)
        {
            var sh = new SubmitHandler()
            {
                RefPage = pi
            };

            sh.Process(pi.PageContent);
            sh.KeyValues["answer"]          = c.Value;
            sh.KeyValues[ExpectedRadioName] = pi.Id;
            sh.KeyValues["page"]            = pi.PageId.ToString();
            return(sh);
        }