public void AsyncCallbackImpl(IAsyncResult ar) { setuInfo re = fh.EndInvoke(ar); if (!string.IsNullOrEmpty(re.msg) && re.msg != "success") { MessageBox.Show(re.msg); } if (re != null && re.data != null && re.data.Any() && !string.IsNullOrEmpty(re.data.First().title)) { this.Text = re.data[0].title + " by " + re.data[0].author + "(" + re.data[0].uid + ") | tags: "; foreach (string s in re.data[0].tags) { this.Text = this.Text + s + " "; } currTitle = this.Text; currSetuInfo = re; lblStatus.Text = "色图原始分辨率:" + re.data[0].width + "X" + re.data[0].height + ";是否R-18:" + (re.data[0].r18 == "true" ? "是" : "否"); //btnGKD.Text = "太慢🌶,给👴停下,下一张"; var getParam = new ReqParams() { Timeout = 10000 }; if (!string.IsNullOrEmpty(txtProxy.Text)) { getParam.ProxyToUse = new WebProxy(txtProxy.Text); } var task = Requests.GetAsync(re.data[0].url, getParam) .ContinueWith((resp) => { btnGKD.Enabled = true; if (resp.IsCompleted) { Image res = Image.FromStream(resp.Result.RawStream); picSetu.Image = res; } }); //picSetu.LoadAsync(); comStyle.Enabled = true; } else { MessageBox.Show("色图加载失败咯,请重试"); comStyle.Enabled = true; btnGKD.Enabled = true; } }
private IEnumerator fetch(string _bucket, string _channel, OnSuccessCallback _onSuccess, OnErrorCallback _onError) { ReqParams reqParams = new ReqParams(); reqParams.bucket = _bucket; reqParams.channel = _channel; string url = string.Format("{0}/fetch", config.domain); string json = JsonMapper.ToJson(reqParams); Dictionary <string, string> header = new Dictionary <string, string>(); header.Add("Content-Type", "application/json"); WWW www = new WWW(url, Encoding.UTF8.GetBytes(json), header); yield return(www); if (null != www.error) { _onError(www.error); yield break; } string manifest = www.text; try { Parser parser = new Parser(); Task[] tasks = parser.ParseJSON(manifest); List <Task> taskList = new List <Task>(); foreach (Task task in tasks) { if (null == task) { continue; } if (!compareMD5(task)) { taskList.Add(task); } } _onSuccess(taskList); } catch (System.Exception e) { _onError(e.Message); } }
private setuInfo loadData() { string r18type = ""; this.Text = "每日涩图 - 加载信息中..."; switch (comSetuType.Text) { case "健康涩图": r18type = "0"; break; case "R18-健康混合": r18type = "2"; break; case "纯R18涩图": r18type = "1"; break; } var getParam = new ReqParams() { Timeout = 10000 }; if (!string.IsNullOrEmpty(txtProxy.Text)) { getParam.ProxyToUse = new WebProxy(txtProxy.Text); } string ret = Requests.Get(setuDomain + "/setu?r18=" + r18type, getParam).ToString(); if (ret != "") { setuInfo rt = JsonConvert.DeserializeObject <setuInfo>(ret); return(rt); } else { return(null); } }
public RequestBuilder SetParams(ReqParams newParams) { Params = newParams; return(this); }
public RequestBuilder Method(string method, ReqParams args) { _reqData["method"] = method; SetParams(args); return(this); }
public T CallMethod <T>(string apiName, string method, ReqParams param) { return(Call <T>(apiName, (new RequestBuilder(Sid)).Method(method, param))); }