Exemple #1
0
 public UserSet(IUserRedis redis, IUserMqSender mqSender) : base(redis)
 {
     _redis    = redis;
     _mqSender = mqSender;
     VirtualRoot.AddCmdPath <UpdateUserRSAKeyMqMessage>(action: message => {
         if (message.AppId == ServerRoot.HostConfig.ThisServerAddress)
         {
             return;
         }
         if (string.IsNullOrEmpty(message.LoginName))
         {
             return;
         }
         if (IsOldMqMessage(message.Timestamp))
         {
             Write.UserOk(_safeIgnoreMessage);
             return;
         }
         if (message.Key != null && _dicByLoginName.TryGetValue(message.LoginName, out UserData userData))
         {
             userData.Update(message.Key);
             redis.SetAsync(userData).ContinueWith(t => {
                 _mqSender.SendUserRSAKeyUpdated(message.LoginName);
             });
         }
     }, this.GetType(), LogEnum.DevConsole);
 }
Exemple #2
0
 public void Add(UserData input)
 {
     if (!IsReadied)
     {
         return;
     }
     if (input == null || string.IsNullOrEmpty(input.LoginName))
     {
         return;
     }
     if (!_dicByLoginName.ContainsKey(input.LoginName))
     {
         _dicByLoginName.Add(input.LoginName, input);
     }
     _redis.SetAsync(input).ContinueWith(t => {
         _mqSender.SendUserAdded(input.LoginName);
     });
 }
Exemple #3
0
 public void Add(UserData input)
 {
     if (!IsReadied)
     {
         return;
     }
     if (input == null || string.IsNullOrEmpty(input.LoginName))
     {
         return;
     }
     if (!_dicByLoginName.ContainsKey(input.LoginName))
     {
         _dicByLoginName.Add(input.LoginName, input);
     }
     if (input.LoginName == Role.RoleEnum.admin.GetName() && !input.IsAdmin())
     {
         AddRole(input, Role.RoleEnum.admin);
     }
     _redis.SetAsync(input).ContinueWith(t => {
         _mqSender.SendUserAdded(input.LoginName);
     });
 }