Beispiel #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;
        }
Beispiel #3
0
        public MasterModule([Import(typeof(IModuleHandler))] IModuleHandler handler)
        {
            window = new M0001_MasterWindow();

            menu = new MasterMenu();

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

            moduleHandler.Initialize();

            base.UseModule(provider);
        }
Beispiel #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.
 }
Beispiel #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;
        }
Beispiel #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);
     }
 }
Beispiel #9
0
 public ClientsMenu([Import(typeof(IModuleHandler))] IModuleHandler moduleHandler_)
 {
     CreateMenu();
     ClientsCommandFacade.ModuleHandler = moduleHandler_;
 }
Beispiel #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);
 }
Beispiel #12
0
 public ModuleHandlerProxy(string handlerKey, IModuleHandler <Q, S> handler)
 {
     _handlerKey = handlerKey;
     _handler    = handler;
 }
Beispiel #13
0
 public AdministrationMenu([Import(typeof(IModuleHandler))] IModuleHandler moduleHandler_)
 {
     CreateMenu();
     AdministrationCommandFacade.ModuleHandler = moduleHandler_;
 }
Beispiel #14
0
 public AdministrationModule([Import(typeof(IModuleHandler))] IModuleHandler moduleHandler_)
 {
     AdministrationCommandFacade.ModuleHandler = moduleHandler_;
     RegisterCommands();
 }
Beispiel #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;
 }
Beispiel #17
0
 public SocketWriter(IAppContext context, IModuleHandler[] modules)
 {
     _context = context;
 }
Beispiel #18
0
 public HandlerFacet(IModuleHandler handler, Facet facet, IView view)
 {
     this.Handler = handler;
     this.Facet   = facet;
     this.View    = view;
 }
Beispiel #19
0
 public HandlerFacet(IModuleHandler handler, Facet facet)
 {
     this.Handler = handler;
     this.Facet   = facet;
 }
Beispiel #20
0
 public ClientsModule([Import(typeof(IModuleHandler))] IModuleHandler moduleHandler_)
 {
     ClientsCommandFacade.ModuleHandler = moduleHandler_;
     RegisterCommands();
 }
Beispiel #21
0
 public PlanningMenu([Import(typeof(IModuleHandler))] IModuleHandler moduleHandler_)
 {
     CreateMenu();
     PlanningCommandFacade.ModuleHandler = moduleHandler_;
 }
Beispiel #22
0
 public HandlerView(IModuleHandler handler, IView view)
 {
     this.Handler = handler;
     this.View    = view;
 }