예제 #1
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);
        }
예제 #2
0
        public static MethodInfo CreateMethodInfo(string controllername, string methodname, AbstractController controller)
        {
            string[] names = controllername.Split(new char[] { '@' });
            if (names.Length != 2)
            {
                throw new Exception("控制器名称错误!");
            }
            string pluginname = names[0];
            string cname      = names[1];

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

            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(mp.database, "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 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);
        }
예제 #4
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);
        }
예제 #5
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);
        }