Example #1
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                if (context.Session == null)
                {
                    return;
                }
                log.Debug("wbos ProcessRequest " + context.Session.SessionID);

                string sitePath = context.Request.ApplicationPath;
                if (sitePath.EndsWith("/"))
                {
                    sitePath = sitePath.TrimEnd('/');
                }

                StreamReader reader      = new StreamReader(context.Request.InputStream);
                string       requestText = reader.ReadToEnd();
                reader.Close();
                umc = Umc.getInstance(context);
                ISecurity security = umc.Security;
                Wjs       wjs      = new Wjs();
                wjs.setContext(umc);

                JoapRequest req = JsonToJoapRequest(requestText);

                JoapResonse resp = new JoapResonse();

                if (!security.CheckObjectPermission(req.ObjCls, req.ObjName, PermissionTypes.Read))
                {
                    security.CheckingUrl = context.Request.UrlReferrer.AbsoluteUri;
                    resp.Err             = JsonExceptionUtils.ThrowErr(SecErrs.NotPemission, sitePath + security.LoginPageUrl).Err;
                }
                else
                {
                    resp = wjs.Invoke(req, context.Session.SessionID);
                }
                //  string jsonResp = JsonConvert.SerializeObject(resp);
                //            string jsonResp = JsonConvert.SerializeObject(resp);

                System.Web.Script.Serialization.JavaScriptSerializer serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
                string jsonResp = serializer.Serialize(resp);


                context.Response.Write(jsonResp);
            }
            catch (Exception err)
            {
                context.Response.Write(JsonExceptionUtils.ThrowErr(err).Serialize());
            }
        }
Example #2
0
        public WbpsResponse invoke(WbpsResquest request, string sessionId)
        {
            WbpsResponse ret = new WbpsResponse();

            //    if (string.IsNullOrEmpty(request.FlowId))
            //        this.page = null;

            Page page = getPage(request, sessionId);

            if (!security.CheckObjectPermission("ListData", request.PageId, PermissionTypes.Read))
            {
                ret.Err = JsonExceptionUtils.ThrowErr(SecErrs.NotLogin, security.LoginPageUrl).Err;
                return(ret);
            }

            ret = page.InvokeRequest(request);

            return(ret);
        }
Example #3
0
        /// <summary>
        /// 执行一个Wbps请求
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public WbpsResponse InvokeRequest(WbpsResquest request)
        {
            WbpsResponse ret = new WbpsResponse();

            if (pageSchema == null)
            {
                return(ret);
            }
            string flowId = request.FlowId;

            ActionFlowSchema fs = null;

            if (!string.IsNullOrEmpty(flowId))
            {
                fs = pageSchema.ActionFlows.FindItem(flowId);
                if (fs == null)
                {
                    throw new XException("不能发现流程配置" + flowId);
                }
            }

            if (request.Step > 0)
            {
                this.nextStep  = request.Step;
                request.Sender = this.request.Sender;
            }

            this.request = request;

            bool isEnd = true;

            if (!security.CheckObjectPermission("ListData", request.PageId, PermissionTypes.Read))
            {
                ret.Err = JsonExceptionUtils.ThrowErr(SecErrs.NotPemission, security.LoginPageUrl).Err;
                return(ret);
            }

            if (request.ElementDatas != null)
            {
                if (fs != null && FlowNeedValid(fs))
                {
                    ValidateRequestData(request.ElementDatas);
                }
                ReceiveRequestData(request.ElementDatas);
            }


            if (fs != null)
            {
                isEnd = InvokeFlow(fs, request.FlowVars);
            }

            ret.ElementDatas = GetChangedElements();

            if (!isEnd)
            {
                ret.BackRequest           = new WbpsResquest();
                ret.BackRequest.PageId    = request.PageId;
                ret.BackRequest.FlowId    = request.FlowId;
                ret.BackRequest.Step      = this.nextStep;
                ret.BackRequest.SessionId = this.sessionId;

                for (int i = 0; i < NeedDatas.Count; i++)
                {
                    ret.BackRequest.ElementDatas.Add(NeedDatas[i], null);
                }

                this.executingFlow = request.FlowId;
            }
            else
            {
                this.executingFlow = null;
            }

            if (!string.IsNullOrEmpty(this.clientScript))
            {
                ret.ClientScript = CheckValueVar(this.clientScript).ToString();
            }

            this.clientScript = "";


            if (fs == null)
            {
                ret.Events = getWbapEvents();
            }

            return(ret);
        }