Beispiel #1
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                HttpRequest      hReq  = context.Request;
                HttpResponse     hResp = context.Response;
                HttpSessionState hSes  = context.Session;


                string objType = Path.GetFileNameWithoutExtension(hReq.Url.LocalPath);
                string name    = hReq.QueryString["name"];
                Umc    umc     = Umc.getInstance(context);
                object wbc     = umc.GetObject(name, objType);

                if (!(wbc is IVisualWbo))
                {
                    throw new XException("调用的对象不是可视化对象,不能在页面上展示");
                }
                hResp.Write((wbc as IVisualWbo).Render(""));
            }
            catch (Exception err)
            {
                context.Response.Write(JsonExceptionUtils.ThrowErr(err).Serialize());
            }
        }
Beispiel #2
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                string path   = context.Request.Path;
                string ext    = Path.GetExtension(path);
                string dsName = Path.GetFileNameWithoutExtension(path);

                Dictionary <string, string> postParams  = HandlerUtils.getPostParams(context);
                Dictionary <string, string> queryParams = HandlerUtils.getQueryParams(context);

                Umc umc = Umc.getInstance(context);

                //  object ds = umc.GetObject(dsName, "ds");

                //if (ds is DataSource)
                //    (ds as DataSource).queryParams = HandlerUtils.getQueryParams(context);

                //    foreach (string propName in postParams.Keys)
                //   {
                //        Umc.invoke(ds, "ds", propName, new Dictionary<string, string>() { { "value", postParams[propName] } });
                //   }

                string memberName = ext.TrimStart('.');
                if (ext.EndsWith(".form"))
                {
                    postParams = null;
                }
                object resp    = umc.Invoke("ds", dsName, memberName, postParams);
                string strResp = JsonConvert.SerializeObject(resp);
                context.Response.Write(strResp);
            }
            catch (System.Reflection.TargetInvocationException e1)
            {
                string jsonErr = JsonExceptionUtils.ThrowErr(e1.InnerException).Serialize();
                if (e1.InnerException is PermissionException)
                {
                    jsonErr = JsonExceptionUtils.ThrowErr(SecErrs.NotPemission, (e1.InnerException as PermissionException).LoginUrl).Serialize();
                }
                context.Response.Write(jsonErr);
            }
            catch (PermissionException e2)
            {
                string jsonErr = JsonExceptionUtils.ThrowErr(10, e2.Message, e2.LoginUrl).Serialize();
                context.Response.Write(jsonErr);
            }

            catch (Exception e)
            {
                string jsonErr = JsonExceptionUtils.ThrowErr(e).Serialize();
                context.Response.Write(jsonErr);
            }
        }
Beispiel #3
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());
            }
        }
Beispiel #4
0
        public void ProcessRequest(HttpContext context)
        {
            Request  = context.Request;
            Server   = context.Server;
            Session  = context.Session;
            Response = context.Response;


            parseRequestPath(context.Request.Path);
            //   Dictionary<string, string> jsonNameValues = this.getRequestGetNameValueParams(context.Request);
            //  if (jsonNameValues == null)

            Dictionary <string, string> jsonNameValues = WboHandlerTools.getRequestPostNameValueParams(context.Request);
            Umc    umc = Umc.getInstance(context);
            object obj = umc.GetObject(objName, objType);
            // object resp = Umc.invoke(obj, objType, "getPageRows", jsonNameValues);
        }
Beispiel #5
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                umc = Umc.getInstance(context);
                parseRequestPath(context.Request.Path);
                Dictionary <string, string> jsonNameValues = HandlerUtils.getPostParams(context);

                if (ext.Equals(".keep"))
                {
                    umc.keepWbo(
                        this.wboTypeId,
                        this.wboName,
                        jsonNameValues["wboJSON"],
                        jsonNameValues["newName"]
                        );

                    writeToJsonResponse(context.Response, null);
                    return;
                }

                if (ext.Equals(".free"))
                {
                    umc.freeWbo(wboName, wboTypeId);
                    writeToJsonResponse(context.Response, null);
                    return;
                }

                if (ext.Equals(".del"))
                {
                    umc.delWbo(wboName, wboTypeId);
                    writeToJsonResponse(context.Response, null);
                    return;
                }

                if (ext.Equals(".disp", StringComparison.OrdinalIgnoreCase))
                {
                    object ret = umc.GetObject(wboName, this.wboTypeId);
                    if (!(ret is IVisualWbo))
                    {
                        throw new XException(Lang.ObjectIsNotVisualWbo);
                    }
                    string elementName = "";
                    if (jsonNameValues.ContainsKey("elementName"))
                    {
                        elementName = jsonNameValues["elementName"];
                    }
                    string html = (ret as IVisualWbo).Render(elementName);
                    context.Response.Write(html);
                    return;
                }

                if (reqName.EndsWith(".post"))
                {
                    jsonNameValues = null;
                }

                object obj;
                if (ext.Equals(".dir"))
                {
                    obj = Umc.dir(wboTypeId);
                }
                else
                {
                    obj = umc.invoke(reqName, jsonNameValues);
                }

                writeToJsonResponse(context.Response, obj);

                //context.Response.End();
            }
            catch (System.Reflection.TargetInvocationException e1)
            {
                string jsonErr = JsonExceptionUtils.ThrowErr(e1.InnerException).Serialize();
                if (e1.InnerException is PermissionException)
                {
                    jsonErr = JsonExceptionUtils.ThrowErr(SecErrs.NotPemission, (e1.InnerException as PermissionException).LoginUrl).Serialize();
                }
                context.Response.Write(jsonErr);
            }
            catch (PermissionException e2)
            {
                string jsonErr = JsonExceptionUtils.ThrowErr(10, e2.Message, e2.LoginUrl).Serialize();
                context.Response.Write(jsonErr);
            }
            catch (Exception e)
            {
                string jsonErr = JsonExceptionUtils.ThrowErr(e).Serialize();
                context.Response.Write(jsonErr);
            }
        }
Beispiel #6
0
        public void ProcessRequest(HttpContext context)
        {
            if (context.Session == null)
            {
                return;
            }
            log.Debug("wbps ProcessRequest " + context.Session.SessionID);

            this.context = context;
            try
            {
                umc = Umc.getInstance(context);
                string       url         = context.Server.UrlDecode(context.Request.UrlReferrer.PathAndQuery);
                string       pageId      = context.Server.UrlDecode(context.Request.UrlReferrer.AbsolutePath);
                StreamReader reader      = new StreamReader(context.Request.InputStream);
                string       requestText = reader.ReadToEnd();

                string logUri = umc.Security.LoginPageUrl;

                if (!logUri.StartsWith("/"))
                {
                    logUri = "/" + logUri;
                }
                logUri = (XSite.SiteVirPath + logUri).Replace("//", "/");

                if (!pageId.Equals(logUri, StringComparison.OrdinalIgnoreCase))
                {
                    umc.Security.CheckingUrl = context.Request.UrlReferrer.AbsoluteUri;
                }

                if (!umc.Security.CheckObjectPermission("ListData", pageId, PermissionTypes.Read))
                {
                    var s = JsonExceptionUtils.ThrowErr(SecErrs.NotPemission, XSite.SiteVirPath + umc.Security.LoginPageUrl).Serialize();
                    context.Response.Write(s);
                }
                else
                {
                    WbpsResquest req = JsonConvert.DeserializeObject <WbpsResquest>(requestText);

                    req.PageId = pageId;
                    req.Url    = url;
                    req.Query  = context.Request.UrlReferrer.Query;

                    if (!string.IsNullOrEmpty(req.SessionId) && !string.IsNullOrEmpty(req.FlowId) && !HasWbps())
                    {
                        throw new Exceptions.XUserException("会话操作已经过期,请F5重新刷新页面");
                    }

                    Wbps wbps = getSessionWBPS();

                    WbpsResponse resp = wbps.invoke(req, context.Session.SessionID);

                    string respText = JsonConvert.SerializeObject(resp);
                    context.Response.Write(respText);
                }
            }
            catch (Exception err)
            {
                context.Response.Write(JsonExceptionUtils.ThrowErr(err).Serialize());
            }
        }