public void AddUser(Entity.UserEntity user) { long id = _AddUser(user); UserUpdateEvent.Notify(this, new UserAddedEventArgs() { User = GetUserById(id) }); }
public void HandleEvent(object sender, IEvent evt) { lock (Sync) { IEnumerable <IUser> targets = null; switch (evt) { case UserUpdateEvent uue: // fetch up to date user info GetChannels(evt.User, channels => GetUsers(channels, users => targets = users)); IUser uueUser = Users.GetUser(uue.User); if (uueUser != null) { evt = new UserUpdateEvent(uueUser, uue); } break; case ChannelUserJoinEvent cje: // THIS DOES NOT DO WHAT YOU WANT IT TO DO // I THINK // it really doesn't, figure out how to leave channels when MCHAN isn't active for the session //if((Sessions.GetCapabilities(cje.User) & ClientCapability.MCHAN) == 0) // LeaveChannel(cje.Channel, cje.User, UserDisconnectReason.Leave); break; case ChannelUserLeaveEvent cle: // Should ownership just be passed on to another user instead of Destruction? IChannel channel = Channels.GetChannel(evt.Channel); if (channel.IsTemporary && evt.User.Equals(channel.Owner)) { Channels.Remove(channel); } break; case MessageUpdateEvent mue: // there should be a v2cap that makes one packet, this is jank IMessage msg = Messages.GetMessage(mue.MessageId); evt = msg == null ? new MessageDeleteEvent(mue) : new MessageUpdateEventWithData(mue, msg); break; } if (targets == null && evt.Channel != null) { GetUsers(evt.Channel, users => targets = users); } if (targets != null) { Sessions.GetSessions(targets, sessions => { foreach (ISession session in sessions) { session.HandleEvent(sender, evt); } }); } } }
private void OnUpdate(object sender, UserUpdateEvent uue) { lock (Sync) { IUser user = GetUser(uue.User.UserId); if (user is IEventHandler ueh) { ueh.HandleEvent(sender, uue); } } }
public IActionResult Index() { UserUpdateEvent userUpdateEvent = new UserUpdateEvent() { Id = Guid.NewGuid(), Name = "zhangsan " }; _eventBus.Publish(userUpdateEvent); return(View()); }
public void HandleEvent(UserUpdateEvent e) { this.DisplayName = e.DisplayName; this.Email = e.Email; this.ContactPhone = e.ContactPhone; this.Address_Country = e.Address_Country; this.Address_City = e.Address_City; this.Address_State = e.Address_State; this.Address_Street = e.Address_Street; this.Address_Zip = e.Address_Zip; }
private void OnUpdate(object sender, UserUpdateEvent uue) { GetUser(uue.UserId, user => { if (user == null) { return; } if (user is IEventHandler ueh) { ueh.HandleEvent(sender, uue); } }); }
private void HandleEvent(UserUpdateEvent domainEvent) { using (QueryDBEntities _dbContext = new QueryDBEntities()) { User user = _dbContext.User.FirstOrDefault(t => t.AggregateRootId == domainEvent.AggregateRootId); user.DisplayName = domainEvent.DisplayName; user.Email = domainEvent.Email; user.ContactPhone = domainEvent.ContactPhone; user.Address_Country = domainEvent.Address_Country; user.Address_State = domainEvent.Address_State; user.Address_Street = domainEvent.Address_Street; user.Address_City = domainEvent.Address_City; user.Address_Zip = domainEvent.Address_Zip; _dbContext.Entry(user).State = EntityState.Modified; _dbContext.SaveChanges(); } }
public static string GetDisplayName(this UserUpdateEvent uue) { StringBuilder sb = new StringBuilder(); if ((uue.NewStatus ?? uue.OldStatus) == UserStatus.Away) { sb.Append((uue.NewStatusMessage ?? uue.OldStatusMessage).ToAFKString()); } if (string.IsNullOrWhiteSpace(uue.NewNickName ?? uue.OldNickName)) { sb.Append(uue.NewUserName ?? uue.OldUserName); } else { sb.Append('~'); sb.Append(uue.NewNickName ?? uue.OldNickName); } return(sb.ToString()); }
public void TestSetup() { _fakeEventAggregator = Substitute.For <IEventAggregator>(); _fakeApplication = Substitute.For <IApplication>(); _fakeSearchEvent = Substitute.For <SearchEvent>(); _fakeDatabaseQuery = Substitute.For <IQueryDatabase>(); _fakeUserUpdateEvent = Substitute.For <UserUpdateEvent>(); _fakeUpdateEvent = Substitute.For <NotificationMessagesUpdateEvent>(); _fakeDatabasePollingLoopEvent = Substitute.For <DatabasePollingLoop>(); _fakeEventAggregator.GetEvent <SearchEvent>().Returns(_fakeSearchEvent); _fakeEventAggregator.GetEvent <NotificationMessagesUpdateEvent>().Returns(_fakeUpdateEvent); _fakeEventAggregator.GetEvent <UserUpdateEvent>().Returns(_fakeUserUpdateEvent); _fakeEventAggregator.GetEvent <DatabasePollingLoop>().Returns(_fakeDatabasePollingLoopEvent); _uut = new HeaderBarViewModel(_fakeEventAggregator, _fakeApplication, _fakeDatabaseQuery); _fakeApplication.CurrentUser.Returns(TestModelFactory.CreateUserModel()); _fakeDatabaseQuery.GetUserMessagesTask(Arg.Any <UserModel>(), Arg.Any <int>()).Returns( new List <MessageModel>() { TestModelFactory.CreateMessageModel("TestMsg", MessageType.LessorMessage) }); _fakeDatabaseQuery.GetUserTask(Arg.Any <UserModel>()).Returns(TestModelFactory.CreateUserModel()); }
public UserUpdatePacket(UserUpdateEvent uue) { Update = uue ?? throw new ArgumentNullException(nameof(uue)); }
private void DT_Tick(object sender, EventArgs e) { UserUpdateEvent?.Invoke(cts.GetServerInChatData(1)); }
public void Dispose() { UserUpdateEvent.Dispose(); ModelUpdateEvent.Dispose(); }