예제 #1
0
 private void loadAdminTable()
 {
     AdminsTable.Clear();
     RoomMember roomAdmins = new RoomMember();
     roomAdmins.GetAllAdminMembersByRoomID(RoomID);
     Helper.Enums.RoomMemberLevel adminType;
     for (int i = 0; i < roomAdmins.RowCount; i++)
     {
         adminType=Helper.EnumUtil.ParseEnum<Helper.Enums.RoomMemberLevel>(roomAdmins.RoomMemberLevelID);
         AdminsTable.Rows.Add(roomAdmins.MemberID, roomAdmins.GetColumn("MemberName"), roomAdmins.RoomMemberLevelID, Helper.StringEnum.GetStringValue(adminType));
         roomAdmins.MoveNext();
     }
 }
예제 #2
0
        public override System.Threading.Tasks.Task OnDisconnected(bool stopCalled)
        {
            Helper.SignalRUser item = ConnectedUsers.FirstOrDefault(x => x.ConnectionId == Context.ConnectionId);
            if (item == null)
            {
                item = ConnectedUsers.FirstOrDefault(x => x.MemberName == Context.User.Identity.Name);
            }
            if (item != null)
            {
                RoomMember bllRoomMember = new RoomMember();
                if (bllRoomMember.LoadOpenedRoomsByMember(item.MemberID))
                {
                    do
                    {
                        removeFromRoom(item.MemberID, bllRoomMember.RoomID);
                    }
                    while (bllRoomMember.MoveNext());
                }
                ConnectedUsers.Remove(item);

                updateMemberOnlineStatus(item, false);
            }
            // remove user from his group by his user name
            Groups.Remove(Context.ConnectionId, Context.User.Identity.Name);

            return base.OnDisconnected(stopCalled);
        }
예제 #3
0
        public bool MarkMembers(string rid, bool CanWrite, bool mark)
        {
            Room room = new Room();
            room.LoadByPrimaryKey(Convert.ToInt32(rid));

            RoomMember members = new RoomMember();
            members.GetAllMembersByRoomID(room.RoomID);

            try
            {
                for (int i = 0; i < members.RowCount; i++)
                {
                    members.IsMarked = mark;
                    members.CanWrite = CanWrite;
                    members.Save();

                    Member m = new Member();
                    m.LoadByPrimaryKey(members.MemberID);
                    MembershipUser u = Membership.GetUser(m.UserID);

                    IHubContext _Rcontext = GlobalHost.ConnectionManager.GetHubContext<ChatRoomHub>();
                    if (mark)
                        _Rcontext.Clients.Group(room.RoomID.ToString()).UserMarked(room.RoomID, members.MemberID, CanWrite);
                    else
                        _Rcontext.Clients.Group(room.RoomID.ToString()).UserUnMarked(room.RoomID, members.MemberID, CanWrite);
                    members.MoveNext();
                }
            }
            catch (Exception ex)
            {
                return false;
            }
            return true;
        }