示例#1
0
        private async Task AddParticipants(IEnumerable <InteractiveParticipantModel> participants)
        {
            if (participants != null && participants.Count() > 0)
            {
                List <InteractiveParticipantModel> participantsToUpdate = new List <InteractiveParticipantModel>();
                foreach (InteractiveParticipantModel participant in participants)
                {
                    UserViewModel user = await ChannelSession.ActiveUsers.AddOrUpdateUser(participant);

                    if (user != null)
                    {
                        if (this.Client.InteractiveGame != null && ChannelSession.Settings.InteractiveUserGroups.ContainsKey(this.Client.InteractiveGame.id))
                        {
                            InteractiveUserGroupViewModel group = ChannelSession.Settings.InteractiveUserGroups[this.Client.InteractiveGame.id].FirstOrDefault(g => g.AssociatedUserRole == user.PrimaryRole);
                            if (group != null && !string.IsNullOrEmpty(group.DefaultScene))
                            {
                                bool updateParticipant = !group.DefaultScene.Equals(user.InteractiveGroupID);
                                user.InteractiveGroupID = group.GroupName;
                                if (updateParticipant)
                                {
                                    participantsToUpdate.Add(user.GetParticipantModel());
                                }
                            }
                        }
                    }
                }

                if (participantsToUpdate.Count > 0)
                {
                    await ChannelSession.Interactive.UpdateParticipants(participantsToUpdate);
                }
            }
        }
        private async Task AddParticipants(IEnumerable <InteractiveParticipantModel> participants)
        {
            foreach (InteractiveParticipantModel participant in participants)
            {
                if (!string.IsNullOrEmpty(participant.sessionID))
                {
                    this.InteractiveUsers[participant.sessionID] = participant;

                    if (ChannelSession.Chat.ChatUsers.ContainsKey(participant.userID))
                    {
                        UserRole role = ChannelSession.Chat.ChatUsers[participant.userID].PrimaryRole;
                        InteractiveUserGroupViewModel group = ChannelSession.Settings.InteractiveUserGroups[this.Client.InteractiveGame.id].FirstOrDefault(g => g.AssociatedUserRole == role);
                        if (group != null)
                        {
                            participant.groupID = group.GroupName;
                        }
                    }
                }
            }

            if (participants.Any(p => !p.groupID.Equals(InteractiveUserGroupViewModel.DefaultName)))
            {
                await ChannelSession.Interactive.UpdateParticipants(participants);
            }
        }
示例#3
0
        private async Task AddParticipants(IEnumerable <InteractiveParticipantModel> participants)
        {
            if (participants != null && participants.Count() > 0)
            {
                List <InteractiveParticipantModel> participantsToUpdate = new List <InteractiveParticipantModel>();

                await ChannelSession.ActiveUsers.AddOrUpdateUsers(participants);

                List <InteractiveUserGroupViewModel> gameGroups = new List <InteractiveUserGroupViewModel>();
                if (this.Client != null && this.Client.InteractiveGame != null && ChannelSession.Settings.InteractiveUserGroups.ContainsKey(this.Client.InteractiveGame.id))
                {
                    gameGroups = new List <InteractiveUserGroupViewModel>(ChannelSession.Settings.InteractiveUserGroups[this.Client.InteractiveGame.id].OrderByDescending(g => g.AssociatedUserRole));
                }

                foreach (InteractiveParticipantModel participant in participants)
                {
                    if (participant != null && !string.IsNullOrEmpty(participant.sessionID))
                    {
                        this.Participants[participant.sessionID] = participant;

                        UserViewModel user = await ChannelSession.ActiveUsers.GetUserByID(participant.userID);

                        if (user != null)
                        {
                            InteractiveUserGroupViewModel group = gameGroups.FirstOrDefault(g => user.HasPermissionsTo(g.AssociatedUserRole));
                            if (group != null && !string.IsNullOrEmpty(group.DefaultScene))
                            {
                                bool updateParticipant = !group.DefaultScene.Equals(user.InteractiveGroupID);
                                user.InteractiveGroupID = group.GroupName;
                                if (updateParticipant)
                                {
                                    participantsToUpdate.AddRange(user.GetParticipantModels());
                                }
                            }
                        }
                    }
                }

                if (participantsToUpdate.Count > 0)
                {
                    await ChannelSession.Interactive.UpdateParticipants(participantsToUpdate);
                }
            }
        }
        private void AddGroupButton_Click(object sender, RoutedEventArgs e)
        {
            if (!string.IsNullOrEmpty(this.GroupNameTextBox.Text))
            {
                if (this.UserGroups.Count(ug => this.GroupNameTextBox.Text.Equals(ug.GroupName)) > 0)
                {
                    return;
                }

                InteractiveUserGroupViewModel userGroup = new InteractiveUserGroupViewModel(this.GroupNameTextBox.Text);
                GroupListItem group = new GroupListItem(userGroup);

                if (group.DefaultScene.Equals(this.scene.sceneID))
                {
                    group.MatchesCurrentScene = true;
                }

                this.UserGroups.Add(group);
                ChannelSession.Settings.InteractiveUserGroups[this.game.id].Add(group.Group);

                this.GroupNameTextBox.Clear();
            }
        }
 public GroupListItem(InteractiveUserGroupViewModel group, InteractiveSceneModel scene)
 {
     this.Group        = group;
     this.Scene        = scene;
     this.SetAsDefault = this.Group.DefaultScene.Equals(this.Scene.sceneID);
 }
 public GroupListItem(InteractiveUserGroupViewModel group)
 {
     this.Group = group;
 }