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; }
public MasterModule([Import(typeof(IModuleHandler))] IModuleHandler handler) { window = new M0001_MasterWindow(); menu = new MasterMenu(); Handler = handler; }
/// <summary> /// 使用模块服务 /// </summary> /// <param name="provider"></param> public override void UseModule(IServiceProvider provider) { IModuleHandler moduleHandler = provider.GetService <IModuleHandler>(); moduleHandler.Initialize(); base.UseModule(provider); }
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. }
/// <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; }
/// <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); } }
public ClientsMenu([Import(typeof(IModuleHandler))] IModuleHandler moduleHandler_) { CreateMenu(); ClientsCommandFacade.ModuleHandler = moduleHandler_; }
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); }
public ModuleHandlerProxy(string handlerKey, IModuleHandler <Q, S> handler) { _handlerKey = handlerKey; _handler = handler; }
public AdministrationMenu([Import(typeof(IModuleHandler))] IModuleHandler moduleHandler_) { CreateMenu(); AdministrationCommandFacade.ModuleHandler = moduleHandler_; }
public AdministrationModule([Import(typeof(IModuleHandler))] IModuleHandler moduleHandler_) { AdministrationCommandFacade.ModuleHandler = moduleHandler_; RegisterCommands(); }
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; }
public SocketWriter(IAppContext context, IModuleHandler[] modules) { _context = context; }
public HandlerFacet(IModuleHandler handler, Facet facet, IView view) { this.Handler = handler; this.Facet = facet; this.View = view; }
public HandlerFacet(IModuleHandler handler, Facet facet) { this.Handler = handler; this.Facet = facet; }
public ClientsModule([Import(typeof(IModuleHandler))] IModuleHandler moduleHandler_) { ClientsCommandFacade.ModuleHandler = moduleHandler_; RegisterCommands(); }
public PlanningMenu([Import(typeof(IModuleHandler))] IModuleHandler moduleHandler_) { CreateMenu(); PlanningCommandFacade.ModuleHandler = moduleHandler_; }
public HandlerView(IModuleHandler handler, IView view) { this.Handler = handler; this.View = view; }