Exemplo n.º 1
0
        public static RequestResult <dynamic> PostCallApi <T>(string address, T t)
        {
            var result = WebApiVisitor.PostAccessApi <T, string>(address, t);

            if (result.Result == ResultStatus.Success)
            {
                return(result);
            }
            else
            {
                throw new Exception(result.Message);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// POST方式访问WebApi
        /// </summary>
        /// <typeparam name="T_Request">参数类型</typeparam>
        /// <typeparam name="T_Result">返回类型</typeparam>
        /// <param name="address">URL</param>
        /// <param name="parameter">参数</param>
        /// <returns><![CDATA[RequestResult<T_Result>]]></returns>
        public RequestResult <dynamic> PostAccessApi <T_Request, T_Result>(string address, T_Request parameter)
        {
            RequestResult <dynamic> obj = null;

            try
            {
                obj = WebApiVisitor.PostAccessApi <T_Request, T_Result>(address, parameter);
            }
            catch (Exception)
            {
                obj = new RequestResult <dynamic>()
                {
                    Result  = ResultStatus.Exception,
                    Data    = default(T_Result),
                    Message = "WebApi访问失败"
                };
            }
            return(obj);
        }