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()); } }
private void setQueryParameters(CommandSchema cmdSchema, DbCommand cmd) { DatabaseAdmin dbAdmin = DatabaseAdmin.getInstance(_schema.ConnectionName); foreach (ParameterSchema p in cmdSchema.QueryParams) { switch (p.Direction) { case ParameterDirection.Input: case ParameterDirection.InputOutput: string value = p.DefaultValue; if (Request.QueryString.AllKeys.Contains(p.Id)) { value = Request[p.Id]; } if (!string.IsNullOrEmpty(value) && value.StartsWith("(") && value.EndsWith(")")) { value = null; object obj = Umc.invoke(value, null).ToString(); if (obj != null) { value = obj.ToString(); } } break; } } }
public JoapResonse Invoke(JoapRequest joapRequest, string sessionId) { try { object o = Umc.GetObject(joapRequest.ObjName, joapRequest.ObjCls); JoapResonse jr = new JoapResonse(); if (!string.IsNullOrEmpty(joapRequest.Method)) { // jr.RetData.Data = Umc.InvokeMethod(o,joapRequest.ObjCls, joapRequest.Method, joapRequest.Paramates); // jr.RetData.Data = Umc.InvokeMethod(o, joapRequest.Method, joapRequest.Paramates); jr.ObjData.Data = o; } return(jr); } catch (Exception err) { string msg = err.Message; Exception et = err.InnerException; while (et != null) { msg += ",\n" + et.Message; et = et.InnerException; } Exception newErr = new Exception("执行命令" + joapRequest.Method + "时,发生错误" + msg, err); throw newErr; } }
public static string GetValue(string varName, Umc umc) { string name = varName.Remove(0, 2); int fid = name.LastIndexOf('.'); string fieldName = name.Substring(fid + 1); string tableName = name.Substring(0, fid); DataSource table = umc.GetObject <DataSource>(tableName); if (table == null) { throw new ESchemaFileException("不能找到变量定义的字段值," + varName); } Dictionary <string, string> rec = new Dictionary <string, string>();// table.ActiveRecord; if (rec != null && rec.ContainsKey(fieldName)) { string value = rec[fieldName]; if (value == null) { value = "NULL"; } return(value); } else if (rec == null || rec.Count < 1) { return("NULL"); } else { throw new ESchemaFileException("不能找到变量定义的字段值," + varName); } }
public object Invoke(string sessionId, WbdlSchema wbdlSchema, WbapRequest request) { Object[] parameters = new Object[methodSchema.Parameters.Count]; for (int j = 0; j < methodSchema.Parameters.Count; j++) { ParameterSchema paramSchema = methodSchema.Parameters[j]; object paramValue = null; if (string.IsNullOrEmpty(paramSchema.Value)) { parameters[j] = null; continue; } if (paramSchema.Value[0] == '#') { paramValue = request.ElementBinds.GetTable(paramSchema.Value.Remove(0, 1), wbdlSchema); } else if (paramSchema.Value[0] == '$') { paramValue = request.ElementBinds[paramSchema.Value]; } else { paramValue = paramSchema.Value; } parameters[j] = paramValue; } Object invokeRet = Umc.InvokeFunction(sessionId, null, methodSchema.MethodName, parameters); return(invokeRet); }
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); } }
private string getExpressValue(string express) { if (string.IsNullOrEmpty(express)) { return(express); } if (!(express.StartsWith("[") && express.EndsWith("]"))) { return(express); } express = express.Trim('[', ']'); return(Umc.invoke(express, null).ToString()); }
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 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); }
private void OpenDataSource() { dataSources.Clear(); foreach (WbdlDataSchema dss in pageSchema.DataSources) { try { object obj = Umc.GetObject(dss.Name, dss.DataType); if (obj is ISessionWbo) { (obj as ISessionWbo).Session = this.session; } if (obj is ISecurityWbo) { (obj as ISecurityWbo).UserContext = this.security.user; } if (dss.Props != null) { SetObjPropertis(dss.Props, obj); // if (obj is IDataSource) // (obj as IDataSource).RefreshData(); } dataSources.Add(dss.Id, obj); } catch (Exception e) { string s = e.Message; if (e.InnerException != null) { s = s += e.InnerException.Message; } throw new XException(s + "Page在打开数据源" + dss.Name + "是发生错误,数据Id:" + dss.Id); } } }
protected void UmcPager1_PageIndexChanged(object sender, Umc.Core.Web.Controls.PageIndexChangedEventArgs e) { CurrentPage = e.NewPageIndex; bind(); }
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 virtual void setContext(Umc umc) { this.umc = umc; }
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()); } }
private WbapResponse __Execute(WbapResponse response) { //CheckPermissionRetrun ret = _ISec.CheckObjectPermission(sessionId, _ActionSchema.Id, 1); //if (ret != CheckPermissionRetrun.Yes) //{ // response.ErrorNo = Convert.ToInt32(ret); // response.Message = "Access denied:" + ret.ToString(); // return response; //} for (int i = request.Step; i < _ActionSchema.Actions.Count; i++) { ActionSchema methodSchema = _ActionSchema.Actions[i]; #region client action if (methodSchema.IsRunAtClient()) { BuildAction(_ActionSchema.Id, i, response.Action); if (response.Action.Request.ActionId != null && response.Action.Request.ActionId != "") { return(response); } else { break; } } #endregion string retVarName = methodSchema.ReturnValue; //#region Menu //if (methodSchema.MethodName.ToUpper() == GetMenu) //{ // if (methodSchema.Parameters[0].Value[0] == '$') // methodSchema.Parameters[0].Value = (string)request.ElementBinds[methodSchema.Parameters[0].Value]; // XMenuObject xMenu = GetMenuBySession(this.sessionId, methodSchema.Parameters[0].Value); // if (!response.ElementBinds.ContainsKey(retVarName)) // response.ElementBinds.Add(retVarName, xMenu); // else // response.ElementBinds[retVarName] = xMenu; // continue; //} //#endregion #region preocess params Object[] parameters = new Object[methodSchema.Parameters.Count]; for (int j = 0; j < methodSchema.Parameters.Count; j++) { ParameterSchema paramSchema = methodSchema.Parameters[j]; object paramValue = null; if (string.IsNullOrEmpty(paramSchema.Value)) { parameters[j] = null; continue; } if (paramSchema.Value[0] == '#') { paramValue = request.ElementBinds.GetTable(paramSchema.Value.Remove(0, 1), schema); } else if (paramSchema.Value[0] == '$') { paramValue = request.ElementBinds[paramSchema.Value]; } else { paramValue = paramSchema.Value; } //paramValue = GetParamVarValue(paramSchema.Value); if (paramValue == null) { // BuildAction(_ActionSchema.Id, i, response.Action); // return response; } parameters[j] = paramValue; } #endregion #region flow control int idx = DetectFlowCtrlExec(methodSchema.MethodName, parameters); if (idx != -1) { if (idx == BREAK) { return(response); } i = idx - 1; continue; } #endregion #region Invoke Object invokeRet = null; //try //{ invokeRet = Umc.InvokeFunction(sessionId, null, methodSchema.MethodName, parameters); //} //catch (Exception e) //{ // if (e.InnerException != null) // throw e.InnerException; // throw (e); //} #endregion ProcessMethodReturn(invokeRet, response.ElementBinds); if (!string.IsNullOrEmpty(retVarName)) { if (!response.ElementBinds.ContainsKey(retVarName)) { response.ElementBinds.Add(retVarName, invokeRet); } else { response.ElementBinds[retVarName] = invokeRet; } } //临时作废,考虑用GetType()分类型处理的方法 #region process return value //if (retVarName != null && retVarName != "" && retVarName[0] == VAR_TYPES[(int)RealParamFlagType.Element]) //{ // retVarName = retVarName.Remove(0, 1); // if (methodReturnObj is CodeTable) // { // Dictionary<string, string> option = new Dictionary<string, string>(); // foreach (CodeTableData codeTableData in (methodReturnObj as CodeTable).Datas) // { // option.Add(codeTableData.Id, codeTableData.Text); // } // if (!response.ElementBinds.ContainsKey(retVarName)) // response.ElementBinds.Add(retVarName, option); // else // response.ElementBinds[retVarName] = option; // } // else // { // if (!request.ElementBinds.ContainsKey(retVarName)) // { // request.ElementBinds.Add(retVarName, methodReturnObj); // } // else // { // request.ElementBinds[retVarName] = methodReturnObj; // } // if (!response.ElementBinds.ContainsKey(retVarName)) // response.ElementBinds.Add(retVarName, methodReturnObj); // else // response.ElementBinds[retVarName] = methodReturnObj; // } //} //else if (retVarName != null && retVarName != "" && retVarName[0] == VAR_TYPES[(int)RealParamFlagType.Table]) //{ // XTable table = (XTable)methodReturnObj; // response.ElementBinds.ImportTable(table, pageController, retVarName.Remove(0, 1)); //} //else if (retVarName != null && retVarName != "") //{ // if (methodReturnObj is MapTable) // { // WebLookupList lookupList = new WebLookupList(); // lookupList.ImportMapTable(methodReturnObj as MapTable, pageController); // if (!response.ElementBinds.ContainsKey(retVarName)) // response.ElementBinds.Add(retVarName, lookupList); // else // response.ElementBinds[retVarName] = lookupList; // } // else // { // if (!response.ElementBinds.ContainsKey(retVarName)) // response.ElementBinds.Add(retVarName, methodReturnObj); // else // response.ElementBinds[retVarName] = methodReturnObj; // } //} #endregion } //XData xData = Umc.FindObject<XData>(sessionId, null); //if (xData != null) // xData.Commit(); return(response); }