Exemple #1
0
        public static WcfClientController 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;
            WinformControllerAttributeInfo wattr = AppPluginManage.GetPluginWinformControllerAttributeInfo(pluginname, cname, out mp);

            if (wattr != null)
            {
                WcfClientController iController = wattr.winformController as WcfClientController;
                if (iController.InitFinish == false)
                {
                    iController.BindDb(mp.database, mp.container, mp.cache, mp.plugin.name);


                    //IBaseView deview = (IBaseView)System.Activator.CreateInstance(wattr.ViewList.Find(x => x.IsDefaultView).ViewType);
                    //iController._defaultView = deview;

                    Dictionary <string, IBaseViewBusiness> viewDic = new Dictionary <string, IBaseViewBusiness>();
                    for (int i = 0; i < wattr.ViewList.Count; i++)
                    {
                        IBaseViewBusiness view = (IBaseViewBusiness)System.Activator.CreateInstance(wattr.ViewList[i].ViewType);
                        viewDic.Add(wattr.ViewList[i].Name, view);

                        if (wattr.ViewList[i].IsDefaultView)
                        {
                            iController._defaultView = view;
                        }
                    }
                    iController.iBaseView = viewDic;


                    iController.Init();
                    iController.InitFinish = true;
                }

                return(iController);
            }
            else
            {
                return(null);
            }
        }
Exemple #2
0
 /// <summary>
 /// 执行控制器
 /// </summary>
 /// <returns></returns>
 public Object InvokeController(string puginName, string controllerName, string methodName, params object[] objs)
 {
     try
     {
         WcfClientController icontroller = ControllerHelper.CreateController(puginName + "@" + controllerName);
         MethodInfo          meth        = ControllerHelper.CreateMethodInfo(puginName + "@" + controllerName, methodName);
         return(meth.Invoke(icontroller, objs));
     }
     catch (Exception err)
     {
         //记录错误日志
         EFWCoreLib.CoreFrame.EntLib.ZhyContainer.CreateException().HandleException(err, "HISPolicy");
         throw new Exception(err.Message);
     }
 }