/// <summary> /// 根据相应的Enum类型以及服务器环境返回相应的URL /// </summary> /// <param name="urlEnum"></param> /// <returns></returns> string GetURL(URLEnum urlEnum) { FieldInfo field = urlEnum.GetType().GetField(urlEnum.ToString()); var desc = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute)) as DescriptionAttribute; return(desc.Description); }
/// <summary> /// 根据相应的Enum类型以及服务器环境返回相应的URL /// </summary> /// <param name="urlEnum"></param> /// <returns></returns> string GetURL(URLEnum urlEnum) { string url = ""; switch (urlEnum) { case URLEnum.registerDefend: url = "/child/registerDefend.do"; break; case URLEnum.registerDefendList: url = "/child/queryObservHz.do"; break; case URLEnum.UpdateState: url = "/child/updateLgjl.do"; break; case URLEnum.UpdateVerson: url = ""; break; default: break; } if (url == "") { return(""); } return(url); }
public string Get(URLEnum type, Dictionary <string, string> dic, out string err) { JContainer jContainer; string url = _base.GetServiceUrl(type); return(this.Get(url, dic, out err)); }
public string Post(URLEnum type, Dictionary <string, string> dic, out string err) { JContainer jContainer; string url = _base.GetServiceUrl(type); _httpPostHelper.PostData(url, dic, out jContainer, out err); if (jContainer == null) { return(null); } return(this.ConvertToDataJContainer(jContainer, err)); }
public async Task <NetWorkDataCollection <T> > GetDataBase <T>(URLEnum url) { Dictionary <string, string> keyValuePairs = new Dictionary <string, string>(); keyValuePairs.Add("key", key); return(await Task.Run(() => { string err; var result = this.Post(url, keyValuePairs, out err); if (result == null) { return null; } NetWorkDataCollection <T> model = JsonConvert.DeserializeObject <NetWorkDataCollection <T> >(result); model.message = err; return model; })); }
public string GetServiceUrl(URLEnum urlEnum) { return(this.GetServiceUrl(this.GetURL(urlEnum))); }