Example #1
0
        public string[] GetAuthInfo()
        {
            IServiceProvider       provider              = HttpContext.RequestServices;
            IModuleHandler         moduleHandler         = provider.GetRequiredService <IModuleHandler>();
            IFunctionAuthorization functionAuthorization = provider.GetService <IFunctionAuthorization>();

            ModuleInfo[] moduleInfos = moduleHandler.ModuleInfos;

            //先查找出所有有权限的模块
            List <ModuleInfo> authModules = new List <ModuleInfo>();

            foreach (ModuleInfo moduleInfo in moduleInfos)
            {
                bool hasAuth = moduleInfo.DependOnFunctions.All(m => functionAuthorization.Authorize(m, User).IsOk);
                if (moduleInfo.DependOnFunctions.Length == 0 || hasAuth)
                {
                    authModules.Add(moduleInfo);
                }
            }

            List <string> codes = new List <string>();

            foreach (ModuleInfo moduleInfo in authModules)
            {
                string fullCode = moduleInfo.FullCode;
                //模块下边有功能,或者拥有子模块
                if (moduleInfo.DependOnFunctions.Length > 0 ||
                    authModules.Any(m => m.FullCode.Length > fullCode.Length && m.FullCode.Contains(fullCode) && m.DependOnFunctions.Length > 0))
                {
                    codes.AddIfNotExist(fullCode);
                }
            }
            return(codes.ToArray());
        }
        /// <summary>
        /// 应用模块服务
        /// </summary>
        /// <param name="provider">服务提供者</param>
        public override void UsePack(IServiceProvider provider)
        {
            IModuleHandler moduleHandler = provider.GetService <IModuleHandler>();

            moduleHandler.Initialize();

            //初始化各种缓存
            IFunctionHandler functionHandler = provider.GetService <IFunctionHandler>();

            functionHandler.RefreshCache();

            IEntityInfoHandler entityInfoHandler = provider.GetService <IEntityInfoHandler>();

            entityInfoHandler.RefreshCache();

            IFunctionAuthCache functionAuthCache = provider.GetService <IFunctionAuthCache>();

            functionAuthCache.BuildRoleCaches();

            IDataAuthCache dataAuthCache = provider.GetService <IDataAuthCache>();

            dataAuthCache.BuildCaches();

            IsEnabled = true;
        }
Example #3
0
        public MasterModule([Import(typeof(IModuleHandler))] IModuleHandler handler)
        {
            window = new M0001_MasterWindow();

            menu = new MasterMenu();

            Handler = handler;
        }
Example #4
0
        /// <summary>
        /// 使用模块服务
        /// </summary>
        /// <param name="provider"></param>
        public override void UseModule(IServiceProvider provider)
        {
            IModuleHandler moduleHandler = provider.GetService <IModuleHandler>();

            moduleHandler.Initialize();

            base.UseModule(provider);
        }
Example #5
0
 public SocketListener(ITypeTranslator translator, IModuleHandler[] modules, IAppContext context, IConnTimeoutHandler timeout)
 {
     _modules = modules.ToList();
     _translator = translator;
     _context = context;
     _timeouthandler = timeout;
     System.Timers.Timer _timer = new System.Timers.Timer();
     Timer time = new Timer();
     TimerCallback.
 }
Example #6
0
        /// <summary>
        /// 应用功能权限授权
        /// </summary>
        public static IApplicationBuilder UseFunctionAuthorization(this IApplicationBuilder app)
        {
            app.UseAuthorization();

            IServiceProvider provider = app.ApplicationServices;

            IModuleHandler moduleHandler = provider.GetService <IModuleHandler>();

            moduleHandler.Initialize();

            IFunctionHandler functionHandler = provider.GetService <IFunctionHandler>();

            functionHandler.RefreshCache();

            return(app);
        }
        /// <summary>
        /// 应用AspNetCore的服务业务
        /// </summary>
        /// <param name="app">Asp应用程序构建器</param>
        public override void UsePack(IApplicationBuilder app)
        {
            app.UseAuthorization();
            app.UseCookiePolicy();

            IServiceProvider provider = app.ApplicationServices;

            IModuleHandler moduleHandler = provider.GetService <IModuleHandler>();

            moduleHandler.Initialize();

            IFunctionHandler functionHandler = provider.GetService <IFunctionHandler>();

            functionHandler.RefreshCache();

            IsEnabled = true;
        }
Example #8
0
 /// <summary>
 /// ×¢²áµ¥Àý²Ö´¢£¬ÇëÈ·±£<paramref name="repository"/>Êǵ¥ÀýµÄ
 /// </summary>
 /// <typeparam name="TRepository"></typeparam>
 /// <param name="repository"></param>
 public static void RegisterHandler <Q, S>(string handlerKey, IModuleHandler <Q, S> handler)
     where Q : class
     where S : class
 {
     if (_singletons.ContainsKey(handlerKey))
     {
         throw new ModuleException("Öظ´×¢²áÄ£¿é´¦ÀíÆ÷" + handlerKey);
     }
     lock (_syncObject)
     {
         if (_singletons.ContainsKey(handlerKey))
         {
             throw new ModuleException("Öظ´×¢²áÄ£¿é´¦ÀíÆ÷" + handlerKey);
         }
         SafeAccessAttribute.CheckUp(handler.GetType());
         _singletons.Add(handlerKey, handler);
     }
 }
Example #9
0
 public ClientsMenu([Import(typeof(IModuleHandler))] IModuleHandler moduleHandler_)
 {
     CreateMenu();
     ClientsCommandFacade.ModuleHandler = moduleHandler_;
 }
Example #10
0
 public PlanningModule([Import(typeof(IModuleHandler))] IModuleHandler moduleHandler_)
 {
     PlanningCommandFacade.ModuleHandler = moduleHandler_;
     RegisterCommands();
 }
 public static void RegisterHandler <Q, S>(string handlerKey, IModuleHandler <Q, S> handler)
     where Q : class
     where S : class
 {
     ModuleHandlerRegistrar.RegisterHandler <Q, S>(handlerKey, handler);
 }
Example #12
0
 public ModuleHandlerProxy(string handlerKey, IModuleHandler <Q, S> handler)
 {
     _handlerKey = handlerKey;
     _handler    = handler;
 }
Example #13
0
 public AdministrationMenu([Import(typeof(IModuleHandler))] IModuleHandler moduleHandler_)
 {
     CreateMenu();
     AdministrationCommandFacade.ModuleHandler = moduleHandler_;
 }
Example #14
0
 public AdministrationModule([Import(typeof(IModuleHandler))] IModuleHandler moduleHandler_)
 {
     AdministrationCommandFacade.ModuleHandler = moduleHandler_;
     RegisterCommands();
 }
Example #15
0
 public static void RegisterHandler(string handlerKey, IModuleHandler <DTObject, DTObject> handler)
 {
     RegisterHandler <DTObject, DTObject>(handlerKey, handler);
 }
 public GeneralModule([Import(typeof(IModuleHandler))] IModuleHandler handler)
 {
     window  = new G0001_GeneralWindow();
     menu    = new GeneralMenu();
     Handler = handler;
 }
Example #17
0
 public SocketWriter(IAppContext context, IModuleHandler[] modules)
 {
     _context = context;
 }
Example #18
0
 public HandlerFacet(IModuleHandler handler, Facet facet, IView view)
 {
     this.Handler = handler;
     this.Facet   = facet;
     this.View    = view;
 }
Example #19
0
 public HandlerFacet(IModuleHandler handler, Facet facet)
 {
     this.Handler = handler;
     this.Facet   = facet;
 }
Example #20
0
 public ClientsModule([Import(typeof(IModuleHandler))] IModuleHandler moduleHandler_)
 {
     ClientsCommandFacade.ModuleHandler = moduleHandler_;
     RegisterCommands();
 }
Example #21
0
 public PlanningMenu([Import(typeof(IModuleHandler))] IModuleHandler moduleHandler_)
 {
     CreateMenu();
     PlanningCommandFacade.ModuleHandler = moduleHandler_;
 }
Example #22
0
 public HandlerView(IModuleHandler handler, IView view)
 {
     this.Handler = handler;
     this.View    = view;
 }