示例#1
0
        /// <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);
        }
示例#2
0
        /// <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));
        }
示例#4
0
        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;
            }));
        }
示例#6
0
 public string GetServiceUrl(URLEnum urlEnum)
 {
     return(this.GetServiceUrl(this.GetURL(urlEnum)));
 }