public static WebHttpController CreateController(string controllername) { string[] names = controllername.Split(new char[] { '@' }); if (names.Length != 2) { throw new Exception("控制器名称错误!"); } string pluginname = names[0]; string cname = names[1]; ModulePlugin mp; WebControllerAttributeInfo webcAttr = AppPluginManage.GetPluginWebControllerAttributeInfo(pluginname, cname, out mp); WebHttpController iController = null; if (webcAttr.webController == null) { iController = (WebHttpController)EFWCoreLib.CoreFrame.Business.FactoryModel.GetObject(webcAttr.webControllerType, mp.database, mp.container, mp.cache, mp.plugin.name, null); } iController.BindDb(mp.database, mp.container, mp.cache, mp.plugin.name); iController.ClearKey = null; iController.FormData = null; iController.ParamsData = null; iController.PutOutData = null; iController.sessionData = null; iController.JsonResult = ""; iController.ViewResult = ""; iController.ViewData = null; return(iController); }
public static void ControllerWrite(WebHttpController controller) { if (string.IsNullOrEmpty(controller.JsonResult)==false) { controller.context.Response.Charset = "UTF-8"; controller.context.Response.Write(controller.JsonResult); } else if (string.IsNullOrEmpty(controller.ViewResult) == false) { controller.context.Response.Write(controller.ViewResult); } }
public static void ControllerWrite(WebHttpController controller) { if (string.IsNullOrEmpty(controller.JsonResult) == false) { controller.context.Response.Charset = "UTF-8"; controller.context.Response.Write(controller.JsonResult); } else if (string.IsNullOrEmpty(controller.ViewResult) == false) { controller.context.Response.Write(controller.ViewResult); } }
public static void ControllerWrite(WebHttpController controller) { controller.context.Response.AddHeader("Access-Control-Allow-Origin", "*"); if (string.IsNullOrEmpty(controller.JsonResult) == false) { controller.context.Response.Charset = "UTF-8"; controller.context.Response.Write(controller.JsonResult); } else if (string.IsNullOrEmpty(controller.ViewResult) == false) { controller.context.Response.Write(controller.ViewResult); } }
private void BeginInvoke(HttpContext context, WebHttpController iController) { //界面传值到后台 iController.ViewResult = ""; iController.JsonResult = ""; iController.sessionData = new System.Collections.Generic.Dictionary<string, object>(); iController.PutOutData = new System.Collections.Generic.Dictionary<string, object>(); iController.ClearKey = new System.Collections.Generic.List<string>(); iController.ParamsData = new System.Collections.Generic.Dictionary<string, string>(); iController.FormData = new System.Collections.Generic.Dictionary<string, string>(); iController.ViewData = new Dictionary<string, object>(); if (context.Request.Params != null)//获取Param值 { for (int i = 0; i < context.Request.Params.Count; i++) { string key = context.Request.Params.Keys[i]; if (key != null && key != "") iController.ParamsData.Add(key, context.Request.Params[key].ToString()); if (key == "ASP.NET_SessionId")//过滤Web应用服务参数 break; } } if (context.Request.Form != null)//获取Form值 { for (int i = 0; i < context.Request.Form.Count; i++) { string key = context.Request.Form.Keys[i]; if (key != null && key != "") iController.FormData.Add(key, context.Request.Form[key].ToString()); } } if (context.Session.Count > 0)//Session数据传入后台 { for (int i = 0; i < context.Session.Count; i++) { if (iController.sessionData.ContainsKey(context.Session.Keys[i].ToString())) { iController.sessionData.Remove(context.Session.Keys[i].ToString()); } iController.sessionData.Add(context.Session.Keys[i].ToString(), context.Session[i]); } } }
private void EndInvoke(HttpContext context, WebHttpController iController) { //后台传出的数据重新绑定给Session if (iController.PutOutData != null && iController.PutOutData.Count > 0) { //Session.Clear();//清除所有Session for (int i = 0; i < iController.PutOutData.Count; i++) { context.Session[iController.PutOutData.ToArray()[i].Key] = iController.PutOutData.ToArray()[i].Value; } } //后台传出要清除的Session if (iController.ClearKey != null) { for (int i = 0; i < iController.ClearKey.Count; i++) { context.Session.Remove(iController.ClearKey[i]); } } }