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()); } }
public void ProcessRequest(HttpContext context) { //ISecurity sec = SecurityFactory.GetSecurity(Session.SessionID); // _userId = sec.UserContext.UserId; Request = context.Request; Server = context.Server; Session = context.Session; Response = context.Response; isUploaded = false; try { if (Request.Files.Count < 1) { throw new XUserException(Lang.NoUploadFile); } HttpPostedFile file = Request.Files[0]; string virPath = "/upload-files/" + context.Session.SessionID; if (!string.IsNullOrEmpty(Request.QueryString[PATH])) { virPath = Request.QueryString[PATH]; } if (!virPath.EndsWith("/")) { virPath = virPath + "/"; } virPath = virPath + Path.GetFileName(file.FileName); string diskPath = Server.MapPath(virPath); string dir = Path.GetDirectoryName(diskPath); if (!Directory.Exists(dir)) { Directory.CreateDirectory(dir); } file.SaveAs(diskPath); url = virPath; isUploaded = true; Response.Write(RetHtml); } catch (Exception e) { string jsonErr = JsonExceptionUtils.ThrowErr(e).Serialize(); err = e.Message; context.Response.Write(jsonErr); return; } }
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); } }
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()); } }
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); }
/// <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); }
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); } }
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()); } }