示例#1
0
        /// <summary>
        /// 处理业务逻辑
        /// </summary>
        /// <param name="userToken"></param>
        public override void HttpHandle(IUserToken userToken)
        {
            IHttpResult result = null;

            try
            {
                this.InitSession(userToken);

                switch (Request.Method)
                {
                case ConstHelper.GET:
                case ConstHelper.POST:
                case ConstHelper.PUT:
                case ConstHelper.DELETE:

                    if (Request.Query.Count > 0)
                    {
                        foreach (var item in Request.Query)
                        {
                            Request.Parmas[item.Key] = item.Value;
                        }
                    }
                    if (Request.Forms.Count > 0)
                    {
                        foreach (var item in Request.Forms)
                        {
                            Request.Parmas[item.Key] = item.Value;
                        }
                    }
                    if (OnRequestDelegate != null)
                    {
                        OnRequestDelegate.Invoke(this);
                    }
                    else
                    {
                        result = GetActionResult();
                    }
                    break;

                case ConstHelper.OPTIONS:
                    result = new HttpEmptyResult();
                    break;

                default:
                    result = new HttpContentResult("不支持的请求方式", System.Net.HttpStatusCode.NotImplemented);
                    break;
                }
            }
            catch (Exception ex)
            {
                result = OnException?.Invoke(this, ex);
            }

            if (result != null && !(result is IBigDataResult))
            {
                Response.SetCached(result, this.Session.CacheCalcString);

                Response.End();
            }
        }
示例#2
0
        /// <summary>
        /// 处理业务逻辑
        /// </summary>
        /// <param name="userToken"></param>
        public override void HttpHandle(IUserToken userToken)
        {
            IHttpResult result;

            this.InitSession(userToken);

            switch (this.Request.Method)
            {
            case ConstHelper.GET:
            case ConstHelper.POST:
            case ConstHelper.PUT:
            case ConstHelper.DELETE:

                if (this.Request.Query.Count > 0)
                {
                    foreach (var item in this.Request.Query)
                    {
                        this.Request.Parmas[item.Key] = item.Value;
                    }
                }
                if (this.Request.Forms.Count > 0)
                {
                    foreach (var item in this.Request.Forms)
                    {
                        this.Request.Parmas[item.Key] = item.Value;
                    }
                }
                result = GetActionResult();
                break;

            case ConstHelper.OPTIONS:
                result = new HttpEmptyResult();
                break;

            default:
                result = new HttpContentResult("不支持的请求方式", System.Net.HttpStatusCode.NotImplemented);
                break;
            }

            if (!(result is IBigDataResult))
            {
                Response.SetCached(result, this.Session.CacheCalcString);

                Response.End();
            }
        }
示例#3
0
        /// <summary>
        /// 处理业务逻辑
        /// </summary>
        /// <param name="userToken"></param>
        /// <param name="httpMessage"></param>
        public override void HttpHandle(IUserToken userToken, HttpMessage httpMessage)
        {
            base.HttpHandle(userToken, httpMessage);

            IHttpResult result = null;

            try
            {
                switch (Request.Method)
                {
                case ConstHelper.GET:
                case ConstHelper.POST:
                case ConstHelper.PUT:
                case ConstHelper.DELETE:

                    if (Request.Query.Count > 0)
                    {
                        foreach (var item in Request.Query)
                        {
                            Request.Parmas[item.Key] = item.Value;
                        }
                    }
                    if (Request.Forms.Count > 0)
                    {
                        foreach (var item in Request.Forms)
                        {
                            Request.Parmas[item.Key] = item.Value;
                        }
                    }
                    if (OnRequestDelegate != null)
                    {
                        OnRequestDelegate.Invoke(this);
                    }
                    else
                    {
                        result = GetActionResult();
                    }
                    break;

                case ConstHelper.OPTIONS:
                    result = new HttpEmptyResult();
                    break;

                default:
                    result = new HttpContentResult("不支持的请求方式", System.Net.HttpStatusCode.HttpVersionNotSupported);
                    break;
                }
            }
            catch (Exception ex)
            {
                result = OnException?.Invoke(this, ex);
            }

            if (result != null)
            {
                if (!(result is IBigDataResult))
                {
                    if (result is IFileResult && _webHost.WebConfig.IsStaticsCached)
                    {
                        Response.SetCached(result, "60,60");
                    }
                    else
                    {
                        Response.SetCached(result, this.Session.CacheCalcString);
                    }
                    Response.End();
                }
            }
        }