public override AbstractController CreateController(string pluginname, string controllername) { string pname = pluginname; string cname = controllername; ModulePlugin mp; WcfControllerAttributeInfo wattr = AppPluginManage.GetPluginWcfControllerAttributeInfo(pname, cname, out mp); WcfServerController iController = (WcfServerController)EFWCoreLib.CoreFrame.Business.FactoryModel.GetObject(wattr.wcfControllerType, mp.database, mp.container, mp.cache, mp.plugin.name, null); iController.BindDb(mp.database, mp.container, mp.cache, mp.plugin.name); iController.requestData = null; iController.responseData = null; return(iController); }
public static string ProcessRequest(string clientId, string controller, string method, string jsondata) { try { if (IsDebug == true) { ShowHostMsg(DateTime.Now, "客户端[" + clientId + "]正在执行:" + controller + "." + method + "(" + jsondata + ")"); } object[] paramValue = null;//jsondata? string retJson = null; WcfServerController wscontroller = ControllerHelper.CreateController(controller); lock (wscontroller) { wscontroller.ParamJsonData = jsondata; wscontroller.ClientInfo = wcfClientDic[clientId]; MethodInfo methodinfo = ControllerHelper.CreateMethodInfo(controller, method, wscontroller); Object retObj = methodinfo.Invoke(wscontroller, paramValue); //带参数方法的调用并返回值 if (retObj != null) { retJson = retObj.ToString(); } } return("{\"flag\":0,\"msg\":" + "\"\"" + ",\"data\":" + retJson + "}"); } catch (Exception err) { //记录错误日志 EFWCoreLib.CoreFrame.EntLib.ZhyContainer.CreateException().HandleException(err, "HISPolicy"); if (err.InnerException == null) { ShowHostMsg(DateTime.Now, "客户端[" + clientId + "]执行失败:" + controller + "." + method + "(" + jsondata + ")\n错误原因:" + err.Message); return("{\"flag\":1,\"msg\":" + "\"" + err.Message + "\"" + "}"); } else { ShowHostMsg(DateTime.Now, "客户端[" + clientId + "]执行失败:" + controller + "." + method + "(" + jsondata + ")\n错误原因:" + err.InnerException.Message); return("{\"flag\":1,\"msg\":" + "\"" + err.InnerException.Message + "\"" + "}"); } } }
public static WcfServerController 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; WcfControllerAttributeInfo wattr = AppPluginManage.GetPluginWcfControllerAttributeInfo(pluginname, cname, out mp); //WcfServerController iController = wattr.wcfController as WcfServerController; WcfServerController iController = (WcfServerController)EFWCoreLib.CoreFrame.Business.FactoryModel.GetObject(wattr.wcfControllerType, mp.database, mp.container, mp.cache, mp.plugin.name, null); iController.BindDb(mp.database, mp.container, mp.cache, mp.plugin.name); iController.ParamJsonData = null; iController.ClientInfo = null; return(iController); }