public static MethodInfo CreateMethodInfo(string controllername, string methodname, AbstractController webController)
        {
            string[] names = controllername.Split(new char[] { '@' });
            if (names.Length != 2)
            {
                throw new Exception("控制器名称错误!");
            }
            string pluginname = names[0];
            string cname      = names[1];

            ModulePlugin mp;
            WebControllerAttributeInfo cattr = AppPluginManage.GetPluginWebControllerAttributeInfo(pluginname, cname, out mp);

            WebMethodAttributeInfo mattr = cattr.MethodList.Find(x => x.methodName == methodname);

            if (mattr == null)
            {
                throw new Exception("控制器中没有此方法名");
            }

            if (mattr.dbkeys != null && mattr.dbkeys.Count > 0)
            {
                webController.BindMoreDb(mp.database, "default");
                foreach (string dbkey in mattr.dbkeys)
                {
                    EFWCoreLib.CoreFrame.DbProvider.AbstractDatabase _Rdb = EFWCoreLib.CoreFrame.DbProvider.FactoryDatabase.GetDatabase(dbkey);
                    _Rdb.WorkId = webController.LoginUserInfo.WorkId;
                    //创建数据库连接
                    webController.BindMoreDb(_Rdb, dbkey);
                }
            }

            return(mattr.methodInfo);
        }
Пример #2
0
        public override MethodInfo CreateMethodInfo(string pluginname, string controllername, string methodname, AbstractController controller)
        {
            string pname = pluginname;
            string cname = controllername;

            ModulePlugin mp;
            WcfControllerAttributeInfo cattr = AppPluginManage.GetPluginWcfControllerAttributeInfo(pname, cname, out mp);

            if (cattr == null)
            {
                throw new Exception("插件中没有此控制器名");
            }
            WcfMethodAttributeInfo mattr = cattr.MethodList.Find(x => x.methodName == methodname);

            if (mattr == null)
            {
                throw new Exception("控制器中没有此方法名");
            }

            if (mattr.dbkeys != null && mattr.dbkeys.Count > 0)
            {
                controller.BindMoreDb(controller.oleDb, "default");
                foreach (string dbkey in mattr.dbkeys)
                {
                    EFWCoreLib.CoreFrame.DbProvider.AbstractDatabase _Rdb = EFWCoreLib.CoreFrame.DbProvider.FactoryDatabase.GetDatabase(dbkey);
                    _Rdb.WorkId = controller.LoginUserInfo.WorkId;
                    //创建数据库连接
                    controller.BindMoreDb(_Rdb, dbkey);
                }
            }

            return(mattr.methodInfo);
        }
        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);
        }
Пример #4
0
        private Type GetWebService(HttpRequest request, string serviceName)
        {
            Type         serviceType = null;
            ModulePlugin mp;

            serviceType = AppPluginManage.GetPluginWebServicesAttributeInfo(serviceName, out mp).ServiceType;
            return(serviceType);
        }
        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);
            }
        }
        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 MethodInfo CreateMethodInfo(string controllername, string methodname)
        {
            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 cattr = AppPluginManage.GetPluginWinformControllerAttributeInfo(pluginname, cname, out mp);

                WinformMethodAttributeInfo mattr = cattr.MethodList.Find(x => x.methodName == methodname);
                if (mattr == null)
                {
                    throw new Exception("控制器中没有此方法名");
                }

                if (mattr.dbkeys != null && mattr.dbkeys.Count > 0)
                {
                    cattr.winformController.BindMoreDb(mp.database, "default");
                    foreach (string dbkey in mattr.dbkeys)
                    {
                        EFWCoreLib.CoreFrame.DbProvider.AbstractDatabase _Rdb = EFWCoreLib.CoreFrame.DbProvider.FactoryDatabase.GetDatabase(dbkey);
                        _Rdb.WorkId = cattr.winformController.LoginUserInfo.WorkId;
                        //创建数据库连接
                        cattr.winformController.BindMoreDb(_Rdb, dbkey);
                    }
                }

                return(mattr.methodInfo);
            }
            catch (Exception err)
            {
                //记录错误日志
                EFWCoreLib.CoreFrame.EntLib.ZhyContainer.CreateException().HandleException(err, "HISPolicy");
                throw new Exception(err.Message);
            }
        }
Пример #8
0
        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);
        }
        public void GetLoginModuleData_Debug()
        {
            string filepath = AppPluginManage.getbaseinfoDataValue(_pluginName, "menuconfig");

            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            xmlDoc.Load(AppGlobal.AppRootPath + filepath);

            XmlNodeList       nl     = xmlDoc.DocumentElement.SelectNodes("modules/module");
            List <BaseModule> mdlist = new List <BaseModule>();

            foreach (XmlNode n in nl)
            {
                BaseModule bmd = new BaseModule();
                bmd.ModuleId = Convert.ToInt32(n.Attributes["ModuleId"].Value);
                bmd.Name     = n.Attributes["Name"].Value;
                mdlist.Add(bmd);
            }

            DataTable dt = ConvertExtend.ToDataTable(mdlist);

            JsonResult = RetSuccess("", JavaScriptConvert.SerializeObject(dt));
        }
Пример #10
0
        //每次请求的身份验证,分布式情况下验证麻烦
        private static bool IsAuth(string pname, string cname, string methodname, string token)
        {
            ModulePlugin mp;
            WcfControllerAttributeInfo cattr = AppPluginManage.GetPluginWcfControllerAttributeInfo(pname, cname, out mp);

            if (cattr == null)
            {
                throw new Exception("插件中没有此控制器名");
            }
            WcfMethodAttributeInfo mattr = cattr.MethodList.Find(x => x.methodName == methodname);

            if (mattr == null)
            {
                throw new Exception("控制器中没有此方法名");
            }

            if (mattr.IsAuthentication)
            {
                if (token == null)
                {
                    throw new Exception("no token");
                }

                AuthResult result = SsoHelper.ValidateToken(token);
                if (result.ErrorMsg != null)
                {
                    throw new Exception(result.ErrorMsg);
                }

                SysLoginRight loginInfo = new SysLoginRight();
                loginInfo.UserId  = Convert.ToInt32(result.User.UserId);
                loginInfo.EmpName = result.User.UserName;

                //clientinfo.LoginRight = loginInfo;
            }

            return(true);
        }
 public string GetLoginBackgroundImage()
 {
     return(AppGlobal.AppRootPath + AppPluginManage.getbaseinfoDataValue(_pluginName, "LoginBackgroundImage"));
 }
        public string GetSysName()
        {
            string val = AppPluginManage.getbaseinfoDataValue(_pluginName, "SystemName");

            return(val ?? "");
        }
        public void UserLogin()
        {
            User user    = NewObject <User>();
            bool islogin = user.UserLogin(frmlogin.usercode, frmlogin.password);

            if (islogin)
            {
                BaseUser      EbaseUser = user.GetUser(frmlogin.usercode);
                SysLoginRight right     = new SysLoginRight();
                right.UserId = EbaseUser.UserId;
                right.EmpId  = EbaseUser.EmpId;
                right.WorkId = EbaseUser.WorkId;

                Dept     dept      = NewObject <Dept>();
                BaseDept EbaseDept = dept.GetDefaultDept(EbaseUser.EmpId);
                if (EbaseDept != null)
                {
                    right.DeptId   = EbaseDept.DeptId;
                    right.DeptName = EbaseDept.Name;
                }

                BaseEmployee EbaseEmp = (BaseEmployee)NewObject <BaseEmployee>().getmodel(EbaseUser.EmpId);
                right.EmpName = EbaseEmp.Name;

                BaseWorkers EbaseWork = (BaseWorkers)NewObject <BaseWorkers>().getmodel(EbaseUser.WorkId);
                right.WorkName = EbaseWork.WorkName;

                if (EbaseWork.DelFlag == 0)
                {
                    string       regkey = EbaseWork.RegKey;
                    DESEncryptor des    = new DESEncryptor();
                    des.InputString = regkey;
                    des.DesDecrypt();
                    string[] ret = (des.OutString == null ? "" : des.OutString).Split(new char[] { '|' });
                    if (ret.Length == 2 && ret[0] == EbaseWork.WorkName && Convert.ToDateTime(ret[1]) > DateTime.Now)
                    {
                        AppGlobal.cache.Add("RoleUser", right);

                        //调用单点登录
                        //Guid TokenKey;
                        //EFWCoreLib.CoreFrame.SSO.SsoHelper.SignIn(right.UserId.ToString(), right.EmpName, out TokenKey);
                        //AppGlobal.cache.Add("TokenKey", TokenKey);

                        frmmain.UserName = right.EmpName;
                        frmmain.DeptName = right.DeptName;
                        frmmain.WorkName = right.WorkName;

                        frmmain.modules = NewObject <Module>().GetModuleList(right.UserId).OrderBy(x => x.SortId).ToList();
                        frmmain.menus   = NewObject <WinMainUIFrame.ObjectModel.RightManager.Menu>().GetMenuList(right.UserId);
                        frmmain.depts   = NewObject <Dept>().GetHaveDept(right.EmpId);

                        frmmain.showSysMenu();
                        ShowWeclomeForm();
                        ((System.Windows.Forms.Form)frmmain).ShowIcon = true;
                        ((System.Windows.Forms.Form)frmmain).Icon     = System.Drawing.Icon.ExtractAssociatedIcon(EFWCoreLib.CoreFrame.Init.AppGlobal.AppRootPath + @"images\msn.ico");
                        ((System.Windows.Forms.Form)frmmain).Show();

                        AppGlobal.winfromMain.MainForm = (System.Windows.Forms.Form)frmmain;
                        //InitMessageForm();//?

                        //登录完成后执行扩展的插件方法
                        string val = AppPluginManage.getbaseinfoDataValue(_pluginName, "LoginCompleted");
                        if (val != null && val.Split('@').Length == 3)
                        {
                            string pluginName     = val.Split('@')[0];
                            string controllerName = val.Split('@')[1];
                            string methodName     = val.Split('@')[2];
                            InvokeController(pluginName, controllerName, methodName, right);
                        }

                        CustomConfigManager.xmlDoc = null;
                    }
                    else
                    {
                        throw new Exception("登录用户的当前机构注册码不正确!");
                    }
                }
                else
                {
                    throw new Exception("登录用户的当前机构还未启用!");
                }
            }
            else
            {
                throw new Exception("输入的用户名密码不正确!");
            }
        }
        public void GetLoginFirstMenu_Debug()
        {
            int ModuleId = Convert.ToInt32(ParamsData["ModuleId"]);

            string filepath = AppPluginManage.getbaseinfoDataValue(_pluginName, "menuconfig");

            System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
            xmlDoc.Load(AppGlobal.AppRootPath + filepath);
            XmlNodeList     nl       = xmlDoc.DocumentElement.SelectNodes("menus/menu");
            List <BaseMenu> menulist = new List <BaseMenu>();

            foreach (XmlNode n in nl)
            {
                BaseMenu bmenu = new BaseMenu();
                bmenu.MenuId   = Convert.ToInt32(n.Attributes["MenuId"].Value);
                bmenu.ModuleId = Convert.ToInt32(n.Attributes["ModuleId"].Value);
                bmenu.PMenuId  = Convert.ToInt32(n.Attributes["PMenuId"].Value);
                bmenu.Name     = n.Attributes["Name"].Value;
                bmenu.Image    = n.Attributes["Image"].Value;
                bmenu.DllName  = n.Attributes["DllName"].Value;
                bmenu.FunName  = n.Attributes["FunName"].Value;
                bmenu.UrlName  = n.Attributes["UrlName"].Value;
                menulist.Add(bmenu);
            }

            List <BaseMenu> menuList = menulist;
            //List<BaseMenu> AllmenuList = menulist;
            List <BaseMenu> _menuList = new List <BaseMenu>();

            for (int i = 0; i < menuList.Count; i++)
            {
                if (menuList[i].PMenuId != -1)
                {
                    BaseMenu _menu = menuList.Find(x => x.MenuId == menuList[i].PMenuId);
                    if (_menuList.FindIndex(x => x.MenuId == _menu.MenuId) == -1 && menuList.FindIndex(x => x.MenuId == _menu.MenuId) == -1)
                    {
                        _menuList.Add(_menu);
                    }
                }
            }
            menuList.AddRange(_menuList);


            List <BaseMenu> menus = menuList.FindAll(x => (x.ModuleId == ModuleId && x.PMenuId == -1)).OrderBy(x => x.SortId).ToList();
            string          ret   = "";//"[{\"FirstMenu\":{},\"SecondMenu\":[]}]";

            for (int i = 0; i < menus.Count; i++)
            {
                string FirstMenu  = "{}";
                string SecondMenu = "[]";

                FirstMenu = JavaScriptConvert.SerializeObject(menus[i]);
                List <BaseMenu> secondmenus = menuList.FindAll(x => x.PMenuId == menus[i].MenuId).OrderBy(x => x.SortId).ToList();
                SecondMenu = secondmenus.Count > 0 ? JavaScriptConvert.SerializeObject(secondmenus) : "[]";
                if (ret == "")
                {
                    ret += "{\"FirstMenu\":" + FirstMenu + ",\"SecondMenu\":" + SecondMenu + "}";
                }
                else
                {
                    ret += ",{\"FirstMenu\":" + FirstMenu + ",\"SecondMenu\":" + SecondMenu + "}";
                }
            }
            JsonResult = RetSuccess("", "[" + ret + "]");
        }
        public string GetWebserverUrl()
        {
            string val = AppPluginManage.getbaseinfoDataValue(_pluginName, "WEB_serverUrl");

            return(val ?? "");
        }
        //调试免登录
        private void DebugLogin()
        {
            #region 进入调试模式

            if (AppPluginManage.getbaseinfoDataValue(_pluginName, "isdebug") == "true")
            {
                //进入调试模式
                DefaultView = frmmain as IBaseViewBusiness;

                SysLoginRight right = new SysLoginRight();
                right.UserId   = 1;
                right.EmpId    = 1;
                right.WorkId   = 1;
                right.DeptId   = 1;
                right.DeptName = "调试科室";
                right.EmpName  = "调试用户";
                right.WorkName = "调试机构";
                AppGlobal.cache.Add("RoleUser", right);

                frmmain.UserName = right.EmpName;
                frmmain.DeptName = right.DeptName;
                frmmain.WorkName = right.WorkName;
                if (AppPluginManage.getbaseinfoDataValue(_pluginName, "menuconfig") != null)
                {
                    string filepath = AppPluginManage.getbaseinfoDataValue(_pluginName, "menuconfig");
                    System.Xml.XmlDocument xmlDoc = new System.Xml.XmlDocument();
                    xmlDoc.Load(filepath);

                    XmlNodeList       nl     = xmlDoc.DocumentElement.SelectNodes("modules/module");
                    List <BaseModule> mdlist = new List <BaseModule>();
                    foreach (XmlNode n in nl)
                    {
                        BaseModule bmd = new BaseModule();
                        bmd.ModuleId = Convert.ToInt32(n.Attributes["ModuleId"].Value);
                        bmd.Name     = n.Attributes["Name"].Value;
                        mdlist.Add(bmd);
                    }
                    nl = xmlDoc.DocumentElement.SelectNodes("menus/menu");
                    List <BaseMenu> menulist = new List <BaseMenu>();
                    foreach (XmlNode n in nl)
                    {
                        BaseMenu bmenu = new BaseMenu();
                        bmenu.MenuId   = Convert.ToInt32(n.Attributes["MenuId"].Value);
                        bmenu.ModuleId = Convert.ToInt32(n.Attributes["ModuleId"].Value);
                        bmenu.PMenuId  = Convert.ToInt32(n.Attributes["PMenuId"].Value);
                        bmenu.Name     = n.Attributes["Name"].Value;
                        bmenu.Image    = n.Attributes["Image"].Value;
                        bmenu.DllName  = n.Attributes["DllName"].Value;
                        bmenu.FunName  = n.Attributes["FunName"].Value;
                        menulist.Add(bmenu);
                    }
                    frmmain.modules = mdlist;
                    frmmain.menus   = menulist;
                    //frmmain.depts = NewObject<Dept>().GetHaveDept(right.EmpId);
                }
                frmmain.showSysMenu();
                ShowWeclomeForm();

                ((System.Windows.Forms.Form)frmmain).ShowIcon = true;
                ((System.Windows.Forms.Form)frmmain).Icon     = System.Drawing.Icon.ExtractAssociatedIcon(EFWCoreLib.CoreFrame.Init.AppGlobal.AppRootPath + @"images\msn.ico");
            }
            #endregion
        }
Пример #17
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);
            }
        }