public static WinformController CreateController(string controllername)
        {
            try
            {
                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)
                {
                    WinformController iController = wattr.winformController as WinformController;
                    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);
                }
            }
            catch (Exception err)
            {
                //记录错误日志
                EFWCoreLib.CoreFrame.EntLib.ZhyContainer.CreateException().HandleException(err, "HISPolicy");
                throw new Exception(err.Message);
            }
        }
示例#2
0
        public static WinformController CreateController(string controllername)
        {
            try
            {
                WinformControllerAttributeInfo wattr = WinformControllerManager.GetControllerAttributeInfo(controllername);
                if (wattr != null)
                {
                    WinformController iController = wattr.winformController as WinformController;
                    if (iController.InitFinish == false)
                    {
                        //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 = System.Activator.CreateInstance(wattr.ViewList[i].ViewType) as IBaseViewBusiness;
                            //IBaseViewBusiness view = (IBaseViewBusiness)(CreateInstance(wattr.ViewList[i].ViewType)());
                            view.frmName = wattr.ViewList[i].Name;
                            viewDic.Add(wattr.ViewList[i].Name, view);

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


                        iController.Init();
                        List <IntPtr> ptrlist = new List <IntPtr>();
                        foreach (var frm in iController.iBaseView)
                        {
                            ptrlist.Add((frm.Value as Form).Handle);
                        }
                        //异步执行数据初始化
                        var asyn = new Func <IntPtr[]>(delegate()
                        {
                            iController.AsynInit();
                            return(ptrlist.ToArray());
                        });
                        IAsyncResult asynresult = asyn.BeginInvoke(new System.AsyncCallback(CallbackHandler), null);
                        iController.InitFinish = true;
                    }

                    return(iController);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception err)
            {
                throw new Exception(err.Message);
            }
        }
示例#3
0
        public static WinformController CreateController(string controllername)
        {
            try
            {
                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)
                {
                    WinformController iController = wattr.winformController as WinformController;
                    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 = System.Activator.CreateInstance(wattr.ViewList[i].ViewType) as IBaseViewBusiness;
                            //IBaseViewBusiness view = (IBaseViewBusiness)(CreateInstance(wattr.ViewList[i].ViewType)());
                            view.frmName = wattr.ViewList[i].Name;
                            viewDic.Add(wattr.ViewList[i].Name, view);

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


                        iController.Init();
                        List <IntPtr> ptrlist = new List <IntPtr>();
                        foreach (var frm in iController.iBaseView)
                        {
                            ptrlist.Add((frm.Value as Form).Handle);
                        }
                        //异步执行数据初始化
                        var asyn = new Func <IntPtr[]>(delegate()
                        {
                            iController.AsynInit();
                            return(ptrlist.ToArray());
                        });
                        IAsyncResult asynresult = asyn.BeginInvoke(new System.AsyncCallback(CallbackHandler), null);
                        iController.InitFinish = true;
                    }

                    return(iController);
                }
                else
                {
                    return(null);
                }
            }
            catch (Exception err)
            {
                //记录错误日志
                EFWCoreLib.CoreFrame.EntLib.ZhyContainer.CreateException().HandleException(err, "HISPolicy");
                throw new Exception(err.Message);
            }
        }