Пример #1
0
        public void updateRoomMemberSettings(int roomid, int memberid, bool canWrite, bool canAccessMic, bool canAccessCam, string banDays)
        {
            try
            {
                RoomMemberBanning banning = new RoomMemberBanning();
                if (!banning.LoadByPrimaryKey(roomid, memberid))
                {
                    banning.AddNew();
                    banning.RoomID = roomid;
                    banning.MemberID = memberid;
                }
                if (String.IsNullOrEmpty(banDays))
                {
                    banning.MarkAsDeleted();
                    try
                    {
                        if (banning.RowState() != System.Data.DataRowState.Added)
                        {
                            //deleted ban from member
                            BLL.Member member = new Member();
                            member.LoadByPrimaryKey(memberid);
                            BLL.MemberLog log = new BLL.MemberLog();
                            log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.UnBanRoomMember() { MemberName = member.Name }, member.MemberID, roomid);
                        }
                    }
                    catch { }
                }
                else
                {
                    int days = Convert.ToInt32(banDays);
                    if (days == 0)
                    {
                        banning.SetColumnNull(RoomMemberBanning.ColumnNames.EndDate);
                    }
                    else
                    {
                        banning.EndDate = DateTime.Now.AddDays(days);
                    }

                    try
                    {
                        BLL.Member member = new Member();
                        member.LoadByPrimaryKey(memberid);
                        BLL.MemberLog log = new BLL.MemberLog();
                        BLL.Log.BanRoomMember infoLog = new BLL.Log.BanRoomMember() { MemberName = member.Name };
                        if (days > 0)
                        {
                            infoLog.BanningDays = days;
                            infoLog.EndDate = banning.EndDate;
                        }
                        log.AddNew(BLL.Member.CurrentMemberID, infoLog, member.MemberID, roomid);
                    }
                    catch { }
                }
                banning.Save();
                //room member settings
                RoomMember rm = new RoomMember();
                if (!rm.LoadByPrimaryKey(memberid, roomid))
                {
                    rm.AddNew();
                    rm.RoomID = roomid;
                    rm.MemberID = memberid;
                }
                rm.CanAccessCam = canAccessCam;
                rm.CanAccessMic = canAccessMic;
                rm.CanWrite = canWrite;
                if (!String.IsNullOrEmpty(banDays))
                    rm.InRoom = false;
                rm.Save();
                //update clients
                Clients.Group(roomid.ToString()).updateRoomMemberSettings(roomid, memberid, canWrite, canAccessMic, canAccessCam, banDays);

            }
            catch { }
        }
Пример #2
0
        public void BanRoomMember(int memberID, int roomID, int type, int adminID)
        {
            RoomMemberBanning ban = new RoomMemberBanning();
            if (!ban.LoadByPrimaryKey(roomID, memberID))
            {
                ban.AddNew();
                ban.RoomID = roomID;
                ban.MemberID = memberID;
            }

            ban.CreatedByMemberID = adminID;
            ban.CreateDate = DateTime.Now;
            ban.StartDate = DateTime.Now;
            switch (type)
            {
                case (int)Helper.Enums.BanningType.Day:
                    ban.EndDate = DateTime.Now.AddDays(1);
                    break;
                case (int)Helper.Enums.BanningType.Month:
                    ban.EndDate = DateTime.Now.AddMonths(1);
                    break;
                case (int)Helper.Enums.BanningType.Week:
                    ban.EndDate = DateTime.Now.AddDays(7);
                    break;
                case (int)Helper.Enums.BanningType.Permanent:
                    ban.SetColumnNull(RoomMemberBanning.ColumnNames.EndDate);
                    break;
            }

            ban.Save();
        }