Esempio n. 1
0
        public AjaxResult DoProcess(AjaxReceive receive)
        {
            AjaxResult result = new AjaxResult {
                IsSuccess = true
            };

            try
            {
                if (string.IsNullOrEmpty(receive.ClassName) || string.IsNullOrEmpty(receive.MethodName))
                {
                    throw AjaxException.ToException(ErrorCode.PErrorCode, "参数解析出错!");
                }
                AjaxMethod method = AjaxServer.GetAjaxMethod(receive.FullClassName, receive.MethodName);
                result.Method = method;
                ParameterInfo[] parameters = method.MethodInfo.GetParameters();
                object[]        objArray   = Ajaxhelper.ParseParams(receive.Data, parameters);
                object          r          = method.MethodInfo.Invoke(AjaxServer.GetInstance(method.FullClassName), objArray);
                if (r != null)
                {
                    result.Data   = r;
                    result.Result = Ajaxhelper.ToJson(r);
                }
            }
            catch (Exception ex)
            {
                result.IsSuccess = false;
                HandleException(ex, result);
            }
            finally
            {
                receive.Clear();
            }
            result.FillResponseText();
            return(result);
        }
Esempio n. 2
0
 public void FillResponseText()
 {
     if (this.IsSuccess)
     {
         this.ResponseText = string.Format("{{\"Result\":{0}}}", this.Result);
     }
     else
     {
         this.ResponseText = string.Format("{{\"ErrorCode\":{0},\"ErrMsg\":{1},\"Success\":{2}}}", this.ErrorCode, Ajaxhelper.ToJson(this.ErrorMsg), IsSuccess);
     }
 }