コード例 #1
0
        private void BindRooms()
        {
            string[] myparams = null;
            if (!string.IsNullOrEmpty(localParams))
            {
                myparams = localParams.Split('&');
            }

            if (myparams.Length > 0)
            {
                if (myparams[0] == "cat=1")
                {
                    int cid = Convert.ToInt32(myparams[1].Substring(2));
                    Room rooms = new Room();
                    rooms.GetRoomsByCategoryID(cid);
                    uiRepeaterRooms.DataSource = rooms.DefaultView;
                    uiRepeaterRooms.DataBind();
                }
                else if (myparams[0] == "subcat=1")
                {
                    int scid = Convert.ToInt32(myparams[1].Substring(2));
                    Room rooms = new Room();
                    rooms.GetRoomsBySubCategoryID(scid);
                    uiRepeaterRooms.DataSource = rooms.DefaultView;
                    uiRepeaterRooms.DataBind();
                }
                else if (myparams[0] == "vip=1")
                {
                    Room rooms = new Room();
                    rooms.GetPremiumRooms();
                    uiRepeaterRooms.DataSource = rooms.DefaultView;
                    uiRepeaterRooms.DataBind();
                }
                else if (myparams[0] == "cb=1")
                {
                    Room rooms = new Room();
                    rooms.GetRoomsByCreatorID(BLL.Member.CurrentMember.MemberID);
                    uiRepeaterRooms.DataSource = rooms.DefaultView;
                    uiRepeaterRooms.DataBind();
                }
                else if (myparams[0] == "fav=1")
                {
                    Room rooms = new Room();
                    rooms.GetFavoriteByMemberID(BLL.Member.CurrentMember.MemberID);
                    uiRepeaterRooms.DataSource = rooms.DefaultView;
                    uiRepeaterRooms.DataBind();
                }
                else if (myparams[0] == "s=1") // search rooms
                {
                    string filterText = myparams[1].Substring(3); // st=
                    Room rooms = new Room();
                    rooms.SearchRooms(filterText);
                    uiRepeaterRooms.DataSource = rooms.DefaultView;
                    uiRepeaterRooms.DataBind();
                }

            }
        }
コード例 #2
0
        public void addToRoom(int memberID, int roomid)
        {
            Groups.Add(Context.ConnectionId, roomid.ToString());
            try
            {
                Member member = new Member();
                member.LoadByPrimaryKey(memberID);
                bool isHidden = member.Status == (int)Helper.Enums.MemberStatus.Offline &&
                    Roles.IsUserInRole(member.Name, Helper.Enums.MemberRoles.InvisibleInRoom.ToString());

                RoomMember roomMember = new RoomMember();
                if (!roomMember.LoadByPrimaryKey(memberID, roomid))
                {
                    roomMember.AddNew();
                    roomMember.MemberID = memberID;
                    roomMember.RoomID = roomid;
                }
                roomMember.LastJoinDate = DateTime.Now;
                roomMember.InRoom = !isHidden;
                Room room = new Room();
                room.LoadByPrimaryKey(roomid);
                if (!room.IsColumnNull("CreatedBy"))
                {
                    if (room.CreatedBy == roomMember.MemberID)
                        roomMember.RoomMemberLevelID = (int)Helper.Enums.RoomMemberLevel.Owner;
                }
                roomMember.Save();

                Helper.ChatMember chatMember = roomMember.LoadWithSettings(roomid, roomMember.MemberID, roomMember.MemberID, null).FirstOrDefault();

                if (!isHidden)
                    Clients.Group(roomid.ToString()).addNewMember(roomid.ToString(), chatMember);
                if (roomMember.RoomMemberLevelID > (int)Helper.Enums.RoomMemberLevel.Visitor)
                    Groups.Add(Context.ConnectionId, GetRoomAdminGroupName(roomid));

                BLL.MemberLog log = new BLL.MemberLog();
                Helper.Enums.LogType lgType = Helper.Enums.LogType.EnterRoom;
                if (isHidden)
                    lgType = Helper.Enums.LogType.EnterRoomHidden;
                log.AddNew(memberID, new BLL.Log.EnterRoom() { Type = lgType, RoomID = roomid, RoomName = room.Name }, null, roomid);

                RoomMember onlineroomMember = new RoomMember();
                onlineroomMember.GetAllOnlineMembersByRoomID(roomid);
                Clients.All.updateExistingCount(roomid, onlineroomMember.RowCount);

                var item = ConnectedUsers.FirstOrDefault(m => m.MemberID == memberID);
                if (item == null)
                {
                    var newMember = new Helper.SignalRUser { ConnectionId = Context.ConnectionId, MemberName = member.Name, MemberID = member.MemberID, ProfilePic = member.ProfilePic, MemberTypeSpecID = member.MemberType.MemberTypeSpecDuration.MemberTypeSpecID };
                    ConnectedUsers.Add(newMember);
                }
            }
            catch (Exception ex)
            {

            }
        }
コード例 #3
0
        private void BindRooms()
        {
            string[] myparams = null;
            if (!string.IsNullOrEmpty(localParams))
            {
                myparams = localParams.Split('&');
            }

            if (myparams.Length > 0)
            {
                if (myparams[0] == "cat=1")
                {
                    int cid = Convert.ToInt32(myparams[1].Substring(2));
                    Room rooms = new Room();
                    rooms.GetRoomsByCategoryID(cid);
                    uiRepeaterRooms.DataSource = rooms.DefaultView;
                    uiRepeaterRooms.DataBind();
                }
                else if (myparams[0] == "subcat=1")
                {
                    int scid = Convert.ToInt32(myparams[1].Substring(2));
                    Room rooms = new Room();
                    rooms.GetRoomsBySubCategoryID(scid);
                    uiRepeaterRooms.DataSource = rooms.DefaultView;
                    uiRepeaterRooms.DataBind();
                }
                else if (myparams[0] == "vip=1")
                {
                    Room rooms = new Room();
                    rooms.GetPremiumRooms();
                    uiRepeaterRooms.DataSource = rooms.DefaultView;
                    uiRepeaterRooms.DataBind();
                }
                else if (myparams[0] == "cb=1")
                {
                    Member member = new Member();
                    member.GetMemberByUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString()));

                    Room rooms = new Room();
                    rooms.GetRoomsByCreatorID(member.MemberID);
                    uiRepeaterRooms.DataSource = rooms.DefaultView;
                    uiRepeaterRooms.DataBind();
                }
                else if (myparams[0] == "fav=1")
                {
                    Member member = new Member();
                    member.GetMemberByUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString()));

                    Room rooms = new Room();
                    rooms.GetFavoriteByMemberID(member.MemberID);
                    uiRepeaterRooms.DataSource = rooms.DefaultView;
                    uiRepeaterRooms.DataBind();
                }

            }
        }
コード例 #4
0
 public static void NotifyRoom(Room room, BLL.RoomTypeSpecDuration bllRoomTypeSpecDuration)
 {
     var settings = new
     {
         CamCount = bllRoomTypeSpecDuration.RoomTypeSpec.MicCount,
         MaxMic = bllRoomTypeSpecDuration.RoomTypeSpec.MicCount,
         TypeID = bllRoomTypeSpecDuration.RoomTypeSpec.ID,
         Color = bllRoomTypeSpecDuration.RoomTypeSpec.Color
     };
     Microsoft.AspNet.SignalR.IHubContext _Rcontext = Microsoft.AspNet.SignalR.GlobalHost.ConnectionManager.GetHubContext<Chat2Connect.SRCustomHubs.ChatRoomHub>();
     _Rcontext.Clients.Group(room.RoomID.ToString()).updateRoomType(room.RoomID.ToString(), settings);
 }
コード例 #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Category cats = new Category();
                cats.GetAllCats();
                uiRepeaterCats.DataSource = cats.DefaultView;
                uiRepeaterCats.DataBind();

                Room rooms = new Room();
                rooms.GetRoomsByCreatorID(Member.CurrentMemberID);
                catlink_minecount.Text = rooms.RowCount.ToString();
                rooms.GetFavoriteByMemberID(Member.CurrentMemberID);
                catlink_favcount.Text = rooms.RowCount.ToString();
            }
        }
コード例 #6
0
        protected void uiLinkButtonCreateTempRoom_Click(object sender, EventArgs e)
        {
            if (Request.IsAuthenticated)
            {
                if (uiCheckBoxListFriends.Items.Cast<ListItem>().Where(i => i.Selected).Count() > 0)
                {
                    IHubContext _Ncontext = GlobalHost.ConnectionManager.GetHubContext<NotificationHub>();
                    Member member = new Member();
                    member.GetMemberByUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString()));
                    Room room = new Room();
                    room.AddNew();

                    room.EnableCam = true;
                    room.EnableMic = true;
                    room.RowStatusID = 1;
                    room.CreatedDate = DateTime.Now;
                    room.Save();

                    room.Name = "غرفة مؤقتة - " + room.RoomID.ToString();
                    room.Save();

                    Session["TempRoomCreate"] = room.RoomID;

                    // notify friends with new temp room

                    for (int i = 0; i < uiCheckBoxListFriends.Items.Count; i++)
                    {
                        if (uiCheckBoxListFriends.Items[i].Selected)
                        {
                            Member temp = new Member();
                            temp.LoadByPrimaryKey(Convert.ToInt32(uiCheckBoxListFriends.Items[i].Value));
                            MembershipUser u = Membership.GetUser(temp.UserID);
                            _Ncontext.Clients.Group(u.UserName).inviteToTempRoom(room.RoomID, member.Name);
                        }
                    }

                    IHubContext _Rcontext = GlobalHost.ConnectionManager.GetHubContext<ChatRoomHub>();
                    _Rcontext.Clients.Group(member.UserName).openTempRoom(room.RoomID);
                    //ClientScript.RegisterStartupScript(this.GetType(), "initTempRoom", "self.parent.location='/home.aspx';", true);
                    //Response.Redirect("home.aspx");
                }
                else
                {

                }
            }
        }
コード例 #7
0
 private void BindRoomInfo()
 {
     clearFields();
     BLL.Room room = new BLL.Room();
     room.LoadByPrimaryKey(RoomID);
     if (!room.IsColumnNull("CreatedDate"))
         uiLabelCreatedDate.Text = Helper.Date.ToString(room.CreatedDate);
     BLL.Member creator = new BLL.Member ();
     if(!room.IsColumnNull("CreatedBy"))
     {
         creator.LoadByPrimaryKey(room.CreatedBy);
         uiLabelCreator.Text = creator.UserName;
         uiLabelName.Text = room.Name;
         loadAdminTable();
         uiGridViewAdmins.DataSource = AdminsTable;
         uiGridViewAdmins.DataBind();
     }
 }
コード例 #8
0
        protected void uiLinkButtonSaveRoom_Click(object sender, EventArgs e)
        {
            if (Request.IsAuthenticated)
            {
                Member member = BLL.Member.CurrentMember;
                Room room = new Room();
                if (!room.LoadByPrimaryKey(Convert.ToInt32(hdnRoomID.Value)))
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Error3", @"$(document).ready(function () { notify('error', 'حدث خطأ . لا توجد غرفة بهذا الإسم.'); });", true);
                    return;
                }

                room.Name = txtNewName.Text;
                room.Save();

                //delete old records
                BLL.RoomType bllRoomType = new RoomType();
                bllRoomType.DeleteOldType(room.RoomID);

                BLL.RoomTypeSpecDuration bllTypeSpecDuration = new RoomTypeSpecDuration();
                bllTypeSpecDuration.LoadByRoomTypeSpecID(Convert.ToInt32(lstTypes.SelectedValue));
                room.RoomType.RoomTypeSpecDurationID = bllTypeSpecDuration.ID;
                room.RoomType.CreateBy = BLL.Member.CurrentMember.MemberID;
                room.RoomType.StartDate = DateTime.Now;
                room.RoomType.EndDate = DateTime.Now.AddMonths(Convert.ToInt32(lstTypeDuration.SelectedValue));
                room.RoomType.OldName = txtRoomName.Text;
                room.RoomType.Save();

                uiPanelSuccess.Visible = true;
                txtRoomName.Text = "";
                txtNewName.Text = "";

                // log
                BLL.MemberLog log = new BLL.MemberLog();
                log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.ChangeRoomType() { RoomName = room.Name,OldName=txtRoomName.Text, NewTypeName = room.RoomType.RoomTypeSpecDuration.RoomTypeSpec.Name, NewTypeExpiryDate = room.RoomType.EndDate, Points = 0 }, null, room.RoomID);
                Chat2Connect.usercontrols.RoomTypes.NotifyRoom(room, bllTypeSpecDuration);
            }
        }
コード例 #9
0
 public void userStartCam(int rid, int memberid)
 {
     Clients.Group(rid.ToString(), Context.ConnectionId).ShowCamLink(memberid, rid);
     Room room = new Room();
     room.LoadByPrimaryKey(rid);
     if (room.IsColumnNull("OpenCams"))
         room.OpenCams = 1;
     else
         room.OpenCams += 1;
     room.Save();
     RoomMember roomMember = new RoomMember();
     if (roomMember.LoadByPrimaryKey(memberid, rid))
     {
         roomMember.HasCam = true;
         roomMember.Save();
     }
 }
コード例 #10
0
        public void updateRoomTopic(int roomID, string topic)
        {
            try
            {
                Room r = new Room();
                if (r.LoadByPrimaryKey(roomID))
                {
                    r.RoomTopic = topic;
                    r.Save();

                    Clients.Group(roomID.ToString()).updateRoomTopic(roomID, topic);
                }
            }
            catch { }
        }
コード例 #11
0
        public void updateSocialLinks(int roomID, string fbURL, string tURL, string utURL)
        {
            try
            {
                Room r = new Room();
                if (r.LoadByPrimaryKey(roomID))
                {
                    r.FbURL = fbURL;
                    r.TURL = tURL;
                    r.UtURL = utURL;
                    r.Save();

                    Clients.Group(roomID.ToString()).updateSocialLinks(roomID, fbURL, tURL, utURL);
                }
            }
            catch { }
        }
コード例 #12
0
        public bool EnableMic(bool mark, string rid, bool adminsonly)
        {
            Room room = new Room();
            room.LoadByPrimaryKey(Convert.ToInt32(rid));

            try
            {
                if (adminsonly)
                {
                    room.EnableMicForAdminsOnly = mark;
                    room.EnableMic = false;
                }
                else
                {
                    room.EnableMic = mark;
                    room.EnableMicForAdminsOnly = false;
                }
                room.Save();
            }
            catch (Exception ex)
            {
                return false;
            }
            return true;
        }
コード例 #13
0
 public void UpdateRoomSetting(int rid, string setting, bool newValue)
 {
     Room room = new Room();
     if (room.LoadByPrimaryKey(rid))
     {
         room.SetColumn(setting, newValue);
         room.Save();
     }
     Clients.Group(rid.ToString()).updateRoomSetting(rid, setting, newValue);
 }
コード例 #14
0
        protected void uiLinkButtonConfirm_Click(object sender, EventArgs e)
        {
            MembershipUser user = Membership.GetUser();
            if (user.PasswordQuestion == uiDropDownListQuestion.SelectedValue && BLL.Member.CurrentMember.Answer == uiTextBoxAnswer.Text.Trim())
            {
                if (!String.IsNullOrEmpty(hdnRoom.Value))
                {
                    Room room = new Room();
                    room.LoadByPrimaryKey(Convert.ToInt32(hdnRoom.Value));

                    try
                    {
                        int durationID = Convert.ToInt32(hdnDuration.Value);
                        int specID = Convert.ToInt32(hdnSpec.Value);
                        BLL.RoomTypeSpecDuration bllRoomTypeSpecDuration = new RoomTypeSpecDuration();
                        bllRoomTypeSpecDuration.Where.TypeDurationID.Value = durationID;
                        bllRoomTypeSpecDuration.Where.RoomTypeSpecID.Value = specID;
                        bllRoomTypeSpecDuration.Query.Load();
                        int points = bllRoomTypeSpecDuration.Points;
                        if (BLL.Member.CurrentMember.Credit_Point < points)
                        {
                            Page.ClientScript.RegisterStartupScript(this.GetType(), "Error3", @"$(document).ready(function () { notify('error', 'حدث خطأ . رصيدك الحالى لا يسمح لإتمام العملية.'); });", true);
                            return;
                        }

                        BLL.Member.CurrentMember.Credit_Point -= points;
                        BLL.Member.CurrentMember.Save();

                        //delete old records
                        BLL.RoomType bllRoomType = new RoomType();
                        bllRoomType.DeleteOldType(room.RoomID);

                        room.RoomType.RoomTypeSpecDurationID = bllRoomTypeSpecDuration.ID;
                        room.RoomType.CreateBy = BLL.Member.CurrentMember.MemberID;
                        room.RoomType.StartDate = DateTime.Now;
                        room.RoomType.EndDate = DateTime.Now.AddMonths(bllRoomTypeSpecDuration.TypeDuration.MonthesNumber);
                        room.RoomType.Save();

                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Success1", @"$(document).ready(function () { notify('success', 'تم ترقية الغرفة بنجاح.'); });", true);

                        BLL.MemberLog log = new BLL.MemberLog();
                        log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.ChangeRoomType() { RoomName = room.Name, NewTypeName = room.RoomType.RoomTypeSpecDuration.RoomTypeSpec.Name, NewTypeExpiryDate = room.RoomType.EndDate, Points = points }, null, room.RoomID);

                        NotifyRoom(room, bllRoomTypeSpecDuration);
                    }
                    catch (Exception ex)
                    {
                        Page.ClientScript.RegisterStartupScript(this.GetType(), "Error11", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك أعد المحاولة.'); });", true);
                    }
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Error4", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك أعد المحاولة.'); });", true);
                }
            }
            else
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Error5", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك تأكد من السؤال والإجابة السرى.'); });", true);
                return;
            }
        }
コード例 #15
0
        private void LoadRoomInfo()
        {
            Room room = new Room();
            room.LoadByPrimaryKey(CurrentRoom);

            if (!room.IsColumnNull("CreatedDate"))
                uiLabelCreatedDate_Edit.Text = room.CreatedDate.ToString("dd/MM/yyyy");
            uiLabelOwnerName.Text = Member.CurrentMember.Name;
            uiLabelRoomName.Text = room.Name;
            if (!room.IsColumnNull("CategoryID"))
            {
                uiDropDownListEdit_Category.SelectedValue = room.CategoryID.ToString();
                BindSubCatsForEdit();
            }
            if (!room.IsColumnNull("SubCategoryID"))
                uiDropDownListEditSubCat.SelectedValue = room.SubCategoryID.ToString();

            BindAdmins();

            if (IsCreated)
            {
                uiLabelsuccess.Text = GetLocalResourceObject("Save").ToString();

            }
            else
            {
                uiLabelsuccess.Text = GetLocalResourceObject("Edit").ToString();

            }
        }
コード例 #16
0
        public bool SendRoomFriendsBotMsg(int roomID, string message)
        {
            BLL.Room bllRoom = new Room();
            if (!bllRoom.LoadByPrimaryKey(roomID))
                return false;
            BLL.RoomMember bllRoomMember = new RoomMember();
            if (!bllRoomMember.GetRoomFriends(roomID))
                return false;
            message.Replace("\r\n", "</br>");
            List<int> recipients = bllRoomMember.DefaultView.Table.AsEnumerable().Select(m => Helper.TypeConverter.ToInt32(m[BLL.RoomMember.ColumnNames.MemberID])).ToList();
            BLL.Message msg = new BLL.Message();
            msg.AddNew();
            msg.Body = message;
            msg.SenderID = BLL.Member.CurrentMemberID;
            msg.Subject = "بوت أصدقاء الغرفة";
            msg.ToMembers = "أصدقاء غرفة -" + bllRoom.Name;
            msg.Save();
            MemberMessage memberMsg = new MemberMessage();
            //add to member sent items
            memberMsg.AddNew();
            memberMsg.MessageID = msg.ID;
            memberMsg.IsRead = true;
            foreach (int recipientID in recipients)
            {
                memberMsg.AddNew();
                memberMsg.MemberID = recipientID;
                memberMsg.MessageID = msg.ID;
            }
            memberMsg.Save();

            //send mail notifications
            NotificationHub notifications = new NotificationHub();
            for (int i = 0; i < recipients.Count; i++)
            {
                notifications.SendMailNotifications(recipients[i]);
            }

            return true;
        }
コード例 #17
0
ファイル: Home2.aspx.cs プロジェクト: menasbeshay/ivalley-svn
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.IsAuthenticated)
            {
                if (!IsPostBack)
                {
                    Member member = new Member();
                    member.GetMemberByUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString()));
                    uiHiddenFieldCurrent.Value = member.MemberID.ToString();
                    uiHiddenFieldCurrentName.Value = member.Name;
                    uiHiddenFieldOpenedCams.Value = 0.ToString();
                    uiHiddenFieldOpenedRooms.Value = 0.ToString();
                    int membertype = 0;
                    if (!member.IsColumnNull("MemberTypeID"))
                        membertype = member.MemberType.MemberTypeSpecDuration.MemberTypeSpecID;
                    switch (membertype)
                    {
                        case 1: // black
                            uiHiddenFieldMaxCams.Value = 1.ToString();
                            uiHiddenFieldMaxNoOfRooms.Value = 2.ToString();
                            break;
                        case 2: // zety
                            uiHiddenFieldMaxCams.Value = 4.ToString();
                            uiHiddenFieldMaxNoOfRooms.Value = 4.ToString();
                            break;
                        case 3: // purple
                            uiHiddenFieldMaxCams.Value = 100.ToString();
                            uiHiddenFieldMaxNoOfRooms.Value = 6.ToString();
                            break;
                        case 4: // premium
                            uiHiddenFieldMaxCams.Value = 100.ToString();
                            uiHiddenFieldMaxNoOfRooms.Value = 8.ToString();
                            break;
                        default:
                            uiHiddenFieldMaxCams.Value = 1.ToString();
                            uiHiddenFieldMaxNoOfRooms.Value = 2.ToString();
                            break;
                    }

                    if (Session["TempRoomCreate"] != null)
                    {
                        Room room = new Room();
                        room.LoadByPrimaryKey(Convert.ToInt32(Session["TempRoomCreate"].ToString()));
                        ClientScript.RegisterStartupScript(this.GetType(), "temproom", "$(document).ready(function (){ addTempTab('#MainTabs', 'room_" + room.RoomID.ToString() + "', " + room.Name + ", true," + room.RoomID.ToString() + @");});", true);
                        Session["TempRoomCreate"] = null;

                    }
                    else if (Request.QueryString["t"] != null)
                    {
                        try
                        {
                            Room room = new Room();
                            room.LoadByPrimaryKey(Convert.ToInt32(Request.QueryString["t"].ToString()));
                            ClientScript.RegisterStartupScript(this.GetType(), "temproom", "$(document).ready(function (){ addTempTab('#MainTabs', 'room_" + room.RoomID.ToString() + "', " + room.Name + ", true," + room.RoomID.ToString() + @");});", true);
                        }
                        catch (Exception ex)
                        {
                        }
                    }

                }
            }
            else
            {
                Response.Redirect("default.aspx");
            }
        }
コード例 #18
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;
        }
コード例 #19
0
        private static bool IsValideRoom(int id, bool isTemp, out Room room, out string message)
        {
            message = "";
            room = new Room();
            if (!isTemp)
            {
                RoomMemberBanning ban = new RoomMemberBanning();
                if (ban.LoadByPrimaryKey(id, BLL.Member.CurrentMemberID))
                {
                    if (ban.IsColumnNull(RoomMemberBanning.ColumnNames.EndDate) || ban.EndDate > DateTime.Now)
                    {
                        message = "تم طردك من هذه الغرفة ";
                        if (ban.IsColumnNull(RoomMemberBanning.ColumnNames.EndDate))
                            message = message + "نهائيا ولن تتمكن من الدخول مرة أخرى";
                        else
                            message = message + "لن تتمكن من دحول هذه الغرفة قبل هذا الوفت: " + Helper.Date.ToDateTimeString(ban.EndDate);

                        return false;
                    }
                }
            }
            //Room Info
            if (!room.LoadByPrimaryKey(id))
            {
                message = "غرفة غير متاحة";
                return false;
            }
            if (room.RowStatusID != (int)Helper.Enums.RowStatus.Enabled)
            {
                message = "هذه الغرفة مغلقة حاليا";
                return false;
            }

            if (!isTemp)
            {
                if (room.CreatedBy != BLL.Member.CurrentMember.MemberID)
                {
                    //check member type bot
                    string acceptedType;
                    if (!ValidateMemberLoginTypeBot(id, out acceptedType))
                    {
                        message = "عفوا هذه الغرفة تقبل الأعضاء من الفئات (" + acceptedType + ") فقط";
                        return false;
                    }
                }

                if (room.IsColumnNull("CreatedBy"))
                {
                    message = "حدث خطأ. الغرفة غير متاحة الأن";
                    return false;
                }

                RoomMember owner = new RoomMember();
                if (!room.IsColumnNull("CreatedBy"))
                {
                    if (!owner.LoadByPrimaryKey(room.CreatedBy, id))
                    {
                        message = "حدث خطأ. الغرفة غير متاحة الأن";
                        return false;
                    }
                }
            }
            return true;
        }
コード例 #20
0
        public bool MarkMemberOnLogin(string rid, bool CanWrite, bool mark)
        {
            Room room = new Room();
            room.LoadByPrimaryKey(Convert.ToInt32(rid));

            try
            {
                if (CanWrite)
                    room.MarkOnLoginWithWrite = mark;
                else
                    room.MarkOnLoginWithoutWrite = mark;
                room.Save();
            }
            catch (Exception ex)
            {
                return false;
            }
            return true;
        }
コード例 #21
0
        public void HandleClose()
        {
            Member user = new Member();
            user.GetMemberByUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString()));
            user.IsOnLine = false;
            user.Status = 4;
            user.Save();

            RoomMember rooms = new RoomMember();
            rooms.GetAllRoomsByMemberID(user.MemberID);
            if (rooms.RowCount > 0)
            {
                rooms.InRoom = false;
                if (rooms.HasCam)
                {
                    rooms.HasCam = false;
                    Room room = new Room();
                    room.LoadByPrimaryKey(rooms.RoomID);
                    room.OpenCams -= 1;
                    if (room.OpenCams < 0)
                        room.OpenCams = 0;
                    room.Save();
                    IHubContext _Rcontext = GlobalHost.ConnectionManager.GetHubContext<ChatRoomHub>();
                    _Rcontext.Clients.Group(rooms.RoomID.ToString()).HideCamLink(rooms.MemberID, rooms.RoomID);
                }
                rooms.Save();

            }

            MemberFriend friends = new MemberFriend();
            friends.GetAllMemberFriends(user.MemberID);
            for (int i = 0; i < friends.RowCount; i++)
            {
                Member temp = new Member();
                temp.LoadByPrimaryKey(friends.FriendID);
                MembershipUser u = Membership.GetUser(temp.UserID);
                IHubContext _Ncontext = GlobalHost.ConnectionManager.GetHubContext<NotificationHub>();
                _Ncontext.Clients.Group(u.UserName).friendStatusChanged(user.MemberID, user.StatusMsg, "offline");
            }

            // clear all session vars
            Session.Abandon();
        }
コード例 #22
0
        public static Helper.ChatRoom GetRoomInfo(int id, bool isTemp, Room room)
        {
            Helper.ChatRoom roomObject = new Helper.ChatRoom();
            roomObject.ID = id;
            roomObject.Type = "Room";
            roomObject.IsTemp = isTemp;
            roomObject.Message = "";
            roomObject.AdminMessage = "";

            //Room info
            roomObject.Name = room.Name;
            roomObject.RoomTopic = room.RoomTopic;
            roomObject.fbURL = room.FbURL;
            roomObject.tURL = room.TURL;
            roomObject.utURL = room.UtURL;
            roomObject.OpenCams = room.OpenCams;
            if (!room.IsColumnNull("CreatedBy"))
                roomObject.CreatedBy = room.CreatedBy;

            RoomBot Allbots = new RoomBot();
            roomObject.RoomBots = Allbots.GetByRoomID(id);

            if (!room.IsColumnNull("CreatedDate"))
                roomObject.CreatedDate = room.CreatedDate;

            //Room settings
            roomObject.Settings.EnableCam = room.EnableCam;
            roomObject.Settings.EnableMic = room.EnableMic;
            roomObject.Settings.MarkOnLoginWithoutWrite = room.MarkOnLoginWithoutWrite;
            roomObject.Settings.MarkOnLoginWithWrite = room.MarkOnLoginWithWrite;
            roomObject.Settings.EnableMicForAdminsOnly = room.EnableMicForAdminsOnly;
            if (room.RoomType.RoomTypeSpecDuration.RoomTypeSpecID > 1) // not a free room
                roomObject.Settings.CamCount = 8;
            else
                roomObject.Settings.CamCount = 4;
            roomObject.Settings.MaxMic = room.RoomType.RoomTypeSpecDuration.RoomTypeSpec.MicCount;
            roomObject.Settings.TypeID = room.RoomType.RoomTypeSpecDuration.RoomTypeSpecID;
            roomObject.Settings.Color = room.RoomType.RoomTypeSpecDuration.RoomTypeSpec.Color;
            //Room Members
            RoomMember roomMember = new RoomMember();
            if (!roomMember.LoadByPrimaryKey(BLL.Member.CurrentMember.MemberID, id))
            {
                roomMember.AddNew();
                roomMember.MemberID = BLL.Member.CurrentMember.MemberID;
                roomMember.RoomID = id;
            }
            roomMember.InRoom = true;
            roomMember.LastJoinDate = DateTime.Now;
            if (BLL.Member.CurrentMember.Status == (int)Helper.Enums.MemberStatus.Offline && Helper.Admin.HasRole(Helper.Enums.MemberRoles.InvisibleInRoom.ToString()))
                roomMember.InRoom = false;
            if (!room.IsColumnNull("CreatedBy"))
            {
                if (roomMember.MemberID == room.CreatedBy)
                    roomMember.RoomMemberLevelID = (int)Helper.Enums.RoomMemberLevel.Owner;
            }
            roomMember.Save();
            roomObject.CurrentMemberID = BLL.Member.CurrentMemberID;

            List<int> connectedIDs = ChatRoomHub.ConnectedUsers.Select(m => m.MemberID).ToList();
            roomObject.Members = roomMember.LoadWithSettings(id, roomObject.CurrentMemberID, null, connectedIDs);
            var currentMemberSettings = roomObject.Members.First(m => m.MemberID == roomObject.CurrentMemberID);
            if (currentMemberSettings != null)
            {
                if (room.MarkOnLoginWithWrite)
                {
                    currentMemberSettings.IsMarked = true;
                    currentMemberSettings.CanWrite = true;
                }
                if (room.MarkOnLoginWithoutWrite)
                {
                    currentMemberSettings.IsMarked = true;
                    currentMemberSettings.CanWrite = false;
                }
            }
            // load owner / admins
            //roomObject.Admins = roomMember.GetAdminsMembersByRoomID(id);

            // load cat & subcat

            Category cat = new Category();
            if (!room.IsColumnNull("CategoryID"))
            {
                cat.LoadByPrimaryKey(room.CategoryID);
                roomObject.CategoryName = cat.Name;
            }

            SubCategory scat = new SubCategory();
            if (!room.IsColumnNull("SubCategoryID"))
            {
                scat.LoadByPrimaryKey(room.SubCategoryID);
                roomObject.SubCategoryName = scat.Name;
            }
            else
            {
                roomObject.SubCategoryName = "لا يوجد";
            }

            //member level change
            roomObject.MemberLevels = Helper.EnumUtil.GetValues<Helper.Enums.RoomMemberLevel>().Where(l => (int)l < currentMemberSettings.MemberLevelID).Select(l => new
            {
                ID = (int)l,
                Name = Helper.StringEnum.GetStringValue(l)
            }).ToList();

            //messages
            //roomObject.MessageHistory = new RoomMessages().GetLatestMessags(id, 0);
            roomObject.MessageHistory = new List<Helper.ChatMessage>() { };
            ///////////////////////////

            Gift allgifts = new Gift();
            allgifts.LoadAll();
            roomObject.Gifts = allgifts.DefaultView.Table.AsEnumerable().Select(m => new { giftid = m["GiftID"], name = m["Name"], price = m["Price_Point"], picPath = m["PicPath"], AudioPath = m["AudioPath"] }).ToList();

            //bots
            RoomBot bllRoomBot = new BLL.RoomBot();
            //welcome bot
            List<Info.RoomBot> bots = bllRoomBot.GetByRoomIDandBotID(id, Helper.Enums.Bot.Welcome);
            if (bots.Count > 0)
            {
                Info.WelcomeBot infoWelcomeBot = (Info.WelcomeBot)bots.First().Settings;
                roomObject.WelcomeBot = infoWelcomeBot;
            }

            return roomObject;
        }
コード例 #23
0
 public void userStopCam(int rid, int memberid)
 {
     Clients.Group(rid.ToString(), Context.ConnectionId).HideCamLink(memberid, rid);
     Room room = new Room();
     room.LoadByPrimaryKey(rid);
     if (room.IsColumnNull("OpenCams"))
         room.OpenCams = 0;
     else
         room.OpenCams -= 1;
     if (room.OpenCams < 0)
         room.OpenCams = 0;
     RoomMember roomMember = new RoomMember();
     if (roomMember.LoadByPrimaryKey(memberid, rid))
     {
         roomMember.HasCam = false;
         roomMember.Save();
     }
     room.Save();
 }
コード例 #24
0
 public void closeRoom(int roomID, int adminID, string adminName)
 {
     RoomMember roomMember = new RoomMember();
     if (!roomMember.HasExisitingMembersExceedCurrentMemberLevel(roomID, adminID))
     {
         Room r = new Room();
         if (r.LoadByPrimaryKey(roomID))
         {
             r.RowStatusID = (byte)Helper.Enums.RowStatus.TemporaryDisabled;
             r.Save();
             roomMember.OutRoomMembers(roomID);
             Clients.Group(roomID.ToString()).closeRoom(roomID, adminName);
         }
     }
     else
     {
         throw new UnauthorizedAccessException("لا يمكن غلق الغرفة فى وجود " + Helper.TypeConverter.ToString(roomMember.GetColumn("MemberName")));
     }
 }
コード例 #25
0
 public void SearchRoomsForTypes(string q)
 {
     Room bllRooms = new Room();
     int? createdBy;
     if (Helper.Admin.IsAdmin() && (Helper.Admin.HasRole(Helper.Enums.AdminRoles.Admin_RoomType.ToString()) || Helper.Admin.HasRole(Helper.Enums.AdminRoles.Admin_AddVIPRoom.ToString())))
     {
         createdBy = null;
     }
     else
     {
         createdBy = BLL.Member.CurrentMemberID;
     }
     bllRooms.SearchRooms(q, createdBy);
     var rooms = bllRooms.DefaultView.Table.AsEnumerable().Select(m => new { id = m[BLL.Room.ColumnNames.RoomID], name = m[BLL.Room.ColumnNames.Name] }).ToList();
     string result = Newtonsoft.Json.JsonConvert.SerializeObject(rooms);
     HttpContext.Current.Response.ContentType = "application/json; charset=utf-8";
     HttpContext.Current.Response.Write(result);
     //return result;
 }
コード例 #26
0
 public bool SendEmailOwnerBotMsg(int roomID, string message)
 {
     BLL.Room bllRoom = new Room();
     if (!bllRoom.LoadByPrimaryKey(roomID))
         return false;
     message = message.Replace("\r\n", "</br>");
     return SendMsg(BLL.Member.CurrentMemberID, bllRoom.s_CreatedBy, "بوت بريد المالك", "مالك الغرفة", message);
 }
コード例 #27
0
        private void LoadRooms()
        {
            Member member = new Member();
            member.GetMemberByUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString()));
            Room myrooms = new Room();
            myrooms.GetRoomsByCreatorID(member.MemberID);

            uiRepeaterMyRooms.DataSource = myrooms.DefaultView;
            uiRepeaterMyRooms.DataBind();
        }
コード例 #28
0
 public void updateFavRoomCount(int mid)
 {
     Room rooms = new Room();
     rooms.GetFavoriteByMemberID(mid);
     Clients.Caller.updateRoomCount(0, 0, rooms.RowCount, false, true);
 }
コード例 #29
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.IsAuthenticated)
            {
                if (!IsPostBack)
                {
                    Member member = BLL.Member.CurrentMember;
                    uiHiddenFieldCurrent.Value = member.MemberID.ToString();
                    uiHiddenFieldCurrentName.Value = member.Name;
                    uiHiddenFieldCreditPoints.Value = (!member.IsColumnNull("Credit_Point")) ? member.Credit_Point.ToString() : "0";
                    uiHiddenFieldOpenedCams.Value = 0.ToString();
                    uiHiddenFieldOpenedRooms.Value = 0.ToString();
                    uiHiddenFieldProfilePic.Value = member.s_ProfilePic;
                    int membertype = 0;
                    membertype = member.MemberType.MemberTypeSpecDuration.MemberTypeSpecID;
                    uiHiddenFieldMemberType.Value = membertype.ToString();
                    uiHiddenFieldMaxCams.Value = member.MemberType.MemberTypeSpecDuration.MemberTypeSpec.OpenedCamCount.ToString();
                    uiHiddenFieldMaxNoOfRooms.Value = member.MemberType.MemberTypeSpecDuration.MemberTypeSpec.OpenRoomCount.ToString();

                    // init friends & gifts for general gift modal
                    MemberFriend friends = new MemberFriend();
                    friends.GetAllMemberFriends(member.MemberID);
                    uiRepeaterGiftFriends.DataSource = friends.DefaultView;
                    uiRepeaterGiftFriends.DataBind();

                    Gift gifts = new Gift();
                    gifts.LoadAll();
                    uiRepeaterGeneralGifts.DataSource = gifts.DefaultView;
                    uiRepeaterGeneralGifts.DataBind();

                    Room room = new Room();
                    if (Session["TempRoomCreate"] != null)
                    {
                        room.LoadByPrimaryKey(Convert.ToInt32(Session["TempRoomCreate"].ToString()));
                        ClientScript.RegisterStartupScript(this.GetType(), "temproom", "$(document).ready(function (){ setTimeout( function(){ addChatRoom(" + room.RoomID.ToString() + ", 'غرفة مؤقتة', 'Room', true);" + @"},1500)}); ", true);
                        Session["TempRoomCreate"] = null;

                    }
                    // temp room invitation
                    else if (Request.QueryString["t"] != null)
                    {
                        try
                        {
                            room.LoadByPrimaryKey(Convert.ToInt32(Request.QueryString["t"].ToString()));
                            ClientScript.RegisterStartupScript(this.GetType(), "temproom", "$(document).ready(function (){ setTimeout( function(){ addChatRoom(" + room.RoomID.ToString() + ", 'غرفة مؤقتة', 'Room', true);" + @"},1500)}); ", true);

                        }
                        catch (Exception ex)
                        {
                        }
                    }

                    List<Helper.ChatRoom> openedRooms = new List<Helper.ChatRoom>();
                    foreach (var sessionInfo in Helper.Sessions.OpenedRooms)
                    {
                        if (room.LoadByPrimaryKey(sessionInfo.ID))
                        {
                            openedRooms.Add(Chat2Connect.services.Services.GetRoomInfo(sessionInfo.ID, sessionInfo.IsTemp, room));
                        }
                    }
                    OpenedRooms = Helper.JsonConverter.Serialize(openedRooms);
                }
            }
            else
            {
                Response.Redirect("default.aspx");
            }
        }
コード例 #30
0
        public bool DisableCams(bool mark, string rid)
        {
            Room room = new Room();
            room.LoadByPrimaryKey(Convert.ToInt32(rid));

            try
            {
                room.EnableCam = !mark;
                room.Save();
            }
            catch (Exception ex)
            {
                return false;
            }
            return true;
        }