Exemplo n.º 1
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);
            }
        }
        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);
            }
        }
Exemplo n.º 3
0
 /// <summary>
 /// 执行控制器
 /// </summary>
 /// <returns></returns>
 public Object InvokeController(string controllerName, string methodName, params object[] objs)
 {
     try
     {
         WinformController icontroller = ControllerHelper.CreateController(controllerName);
         MethodInfo        meth        = ControllerHelper.CreateMethodInfo(controllerName, methodName);
         return(meth.Invoke(icontroller, objs));
     }
     catch (Exception err)
     {
         throw new Exception(err.Message);
     }
 }
Exemplo n.º 4
0
        static bool AppGlobal_Init()
        {
            try
            {
                AppGlobal.AppStart();

                if (missingDll.Count > 0)
                {
                    string msg = "缺失的程序集:\r";
                    for (int i = 0; i < missingDll.Count; i++)
                    {
                        msg += missingDll[i] + "\r";
                    }
                    MessageBox.Show(msg, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }

                string entryplugin;
                string entrycontroller;
                switch (appType)
                {
                case AppType.Winform:
                    PluginSysManage.GetWinformEntry(out entryplugin, out entrycontroller);
                    EFWCoreLib.WinformFrame.Controller.WinformController controller = EFWCoreLib.WinformFrame.Controller.ControllerHelper.CreateController(entryplugin + "@" + entrycontroller);
                    //controller.Init();
                    if (controller == null)
                    {
                        throw new Exception("插件配置的启动项(插件名或控制器名称)不正确!");
                    }
                    ((System.Windows.Forms.Form)controller.DefaultView).Show();
                    winfromMain.MainForm = ((System.Windows.Forms.Form)controller.DefaultView);
                    break;
                }

                return(true);
            }
            catch (Exception err)
            {
                //记录错误日志
                ZhyContainer.CreateException().HandleException(err, "HISPolicy");
                //Application.Exit();
                //throw new Exception(err.Message + "\n\n请联系管理员!");
                MessageBox.Show(err.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
                //AppExit();
                return(false);
            }
        }
Exemplo n.º 5
0
 /// <summary>
 /// 执行控制器
 /// </summary>
 /// <returns></returns>
 public Object InvokeController(string puginName, string controllerName, string methodName, params object[] objs)
 {
     try
     {
         WinformController icontroller = ControllerHelper.CreateController(puginName + "@" + controllerName);
         MethodInfo        meth        = ControllerHelper.CreateMethodInfo(puginName + "@" + controllerName, methodName);
         if (meth == null)
         {
             throw new Exception("调用的方法名不存在");
         }
         return(meth.Invoke(icontroller, objs));
     }
     catch (Exception err)
     {
         //记录错误日志
         ZhyContainer.CreateException().HandleException(err, "HISPolicy");
         throw new Exception(err.Message);
     }
 }
Exemplo n.º 6
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);
            }
        }