Example #1
0
        private string DoExecute(VenusServiceResponse response)
        {
            try
            {
                //提前检查业务参数
                response.Validate();
                return(response.ResultGet());
            }
            catch (VenusException e)
            {
                return(response.ErrorResponse(e.ErrorCode, e.ErrorMsg));
            }
            catch (System.Exception ex)
            {
                NameValueCollection nv = response.NvParams;
                StringBuilder       sb = new StringBuilder();
                foreach (String s in nv.AllKeys)
                {
                    sb.Append(string.Format("{0}={1}", s, nv[s]));
                }

                VenusLogger.Error(string.Format("参数:{0},结果:{1}", sb.ToString(), ex.Message));
                sb.Remove(0, sb.Length);
                nv.Clear();

                return(response.ErrorResponse("1000", ex.Message));
            }
        }
        public HttpResponseMessage Post()
        {
            VenusServiceResponse response = null;
            var    context = HttpContext.Current.Request;
            string method  = context.Form["method"].ToString();

            switch (method)
            {
            case "jxdyf.logistics.list.get":
                response = new Logistics.ListService();
                break;
            }

            IVenusService service = new DefaultJXService();

            if (response != null)
            {
                response.ClientIP = context.UserHostAddress;
                response.NvParams = context.Form;
                return(new HttpResponseMessage(HttpStatusCode.OK)
                {
                    Content = new StringContent(service.Execute(response), Encoding.UTF8, "text/javascript")
                });
            }
            else
            {
                return(Request.CreateResponse(HttpStatusCode.OK));
            }
        }
Example #3
0
 public string Execute(VenusServiceResponse response)
 {
     return(DoExecute(response));
 }