Exemplo n.º 1
0
 public void request(IRequestMonitor monitor, WebPageModel page, HandWebDataTask handTask, RepeatInfo repeat, string passingData = null)
 {
     request(monitor, page, handTask, repeat, new PassingData()
     {
         Data = passingData
     });
 }
Exemplo n.º 2
0
        public void formatRequest(IRequestMonitor monitor, WebPageModel page, HandWebDataTask handTask, object[] addition, RepeatInfo repeat, params string[] datas)
        {
            string data = string.Empty;

            data = string.Format(page.PostDataFormat, datas);
            request(monitor, page, handTask, repeat, new PassingData()
            {
                Data = data, Addition = addition
            });
        }
Exemplo n.º 3
0
        public void request(IRequestMonitor monitor, WebPageModel page, HandWebDataTask handTask, RepeatInfo repeatInfo, PassingData data)
        {
            if (page == null)
            {
                return;
            }
            //Cancel Previous
            ensureCancelCTS();
            cacheCTS = new CancellationTokenSource();
            var token = cacheCTS.Token;

            //Create Monitor
            if (monitor == null)
            {
                monitor = new RequestMonitor();
            }
            //Request
            var httpRequest = provideRequestTask(page.IsPost);
            var requestInfo = new HttpRequestInfo()
            {
                RequestTask       = httpRequest,
                HttpRequestConfig = httpConfig,
                RequestMonitor    = monitor,
                HandDataTask      = handTask,
                Page       = page,
                Passing    = data,
                RepeatInfo = repeatInfo,
                Token      = token
            };

            monitor.IsTaskEmpty   = false;
            monitor.IsTaskWaiting = false;
            Task.Run(() => loopingRequest(requestInfo).ContinueWith(task =>
            {
                ensureCancelCTS();
                monitor.IsTaskWaiting = false;
                monitor.IsTaskEmpty   = true;
                monitor.IsRequesting  = false;
                if (task.IsCanceled)
                {
                    monitor.OnTaskCanceled();
                }
                else if (task.IsFaulted)
                {
                    if (task.Exception.GetBaseException() != null)
                    {
                        monitor.OnFaulted(task.Exception.GetBaseException());
                    }
                }
            }));
        }
Exemplo n.º 4
0
 public void request(IRequestMonitor monitor, WebPageModel page, HandWebDataTask handTask, PassingData data)
 {
     request(monitor, page, handTask, RepeatInfo.Once, data);
 }
Exemplo n.º 5
0
 public void formatRequest(IRequestMonitor monitor, WebPageModel page, HandWebDataTask handTask, object[] addition, params string[] datas)
 {
     formatRequest(monitor, page, handTask, addition, RepeatInfo.Once, datas);
 }