示例#1
0
 private static void Load()
 {
     using (var uow = UnitOfWorkFactory.CreateForRoot <User>(QSMain.User.Id))
     {
         warehouse = new PermissionMatrix <WarehousePermissions, Domain.Store.Warehouse>();
         warehouse.Init();
         warehouse.ParseJson(uow.Root.WarehouseAccess);
     }
 }
        public IWarehousePermissionValidator CreateValidator(int userId)
        {
            PermissionMatrix <WarehousePermissions, Warehouse> permissionMatrix;

            using (var uow = UnitOfWorkFactory.CreateForRoot <User>(userId)) {
                permissionMatrix = new PermissionMatrix <WarehousePermissions, Warehouse>();
                permissionMatrix.Init();
                permissionMatrix.ParseJson(uow.Root.WarehouseAccess);
            }
            return(new WarehousePermissionValidator(permissionMatrix));
        }
示例#3
0
        static partial void ExtendWarlockProtocol()
        {
            WarlockAPI.ApiMessages = WarlockAPI.ApiMessages.Concat(PrivateApiMessages)
                                     .Concat(AdvancedApiMessages)
                                     .ToArray();
            //extend api msg names
            WarlockAPI.ApiMsgNames.AddFromSource(new Dictionary <Type, string>()
            {
                { typeof(LiveKeysAddMsg), s_LiveKeysAddMsg },
                { typeof(LiveKeysDelMsg), s_LiveKeysDelMsg },
                { typeof(RegisterUserKeyReq), s_RegisterUserKeyReq },
                { typeof(RegisterUserKeyRsp), s_RegisterUserKeyRsp },
                { typeof(UnRegisterUserKey), s_UnRegisterUserKey },
                { typeof(EmailRequest), s_EmailRequest },
                { typeof(UserLoginReq), s_UserLoginReq },
                { typeof(UserLoginRsp), s_UserLoginRsp },
                { typeof(ShareNotifyMsg), s_ShareNotifyMsg },
                { typeof(LiveExecutionEvent), s_LiveExecutionEvent },
                { typeof(LiveExecutionAddListeners), s_LiveExecutionAddListeners },
                { typeof(LiveExecutionRemoveListeners), s_LiveExecutionRemoveListeners },
                { typeof(WorkerEventNotification), s_WorkerEventNotification },
                { typeof(EvNewNotification), s_EvNewNotification },
                { typeof(EvNewBackendNotification), s_EvNewBackendNotification },
                { typeof(EvNewFrontendNotification), s_EvNewFrontendNotification },
                { typeof(LiveValuesMsg), s_LiveValuesMsg },
                { typeof(CreateValueTriggerGraphEvent), s_CreateValueTriggerGraphEvent },
                { typeof(CreateWatchdogGraphEvent), s_CreateWatchdogGraphEvent },
                { typeof(CreateGraphRsp), s_CreateGraphRsp }
            });

            //extend permission matrix
            PermissionMatrix.AddFromSource(new Dictionary <Type, eNodePermissions>()
            {
                { typeof(ShareNotifyMsg), eNodePermissions.AllowSharingCtrl }
            });
            //look up
            ApiMsgNamesToTypes = ApiMsgNames.Select(e => new KeyValuePair <string, Type>(e.Value, e.Key)).ToDictionary();
        }
 public WarehousePermissionValidator(PermissionMatrix <WarehousePermissions, Warehouse> permissionMatrix)
 {
     this.permissionMatrix = permissionMatrix ?? throw new ArgumentNullException(nameof(permissionMatrix));
 }