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 { 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); } }