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 { } } }
protected void uiLinkButtonSaveRoom_Click(object sender, EventArgs e) { // check member type // check number of created rooms string querystring = ""; if (Request.IsAuthenticated) { Member member = new Member(); member.GetMemberByUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString())); Room room = new Room(); if (!IsEdit) { // check no room exists with the same name room.Where.Name.Value = uiTextBoxADD_Name.Text; room.Where.Name.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal; room.Query.Load(); if (room.RowCount > 0) { ClientScript.RegisterStartupScript(this.GetType(), "error_roomnameexists", "$(document).ready(function (){ notify('error','حدث خطأ. إسم الغرفة موجود من قبل.');}); ", true); return; } // max no of created room = 2 room.Where.WhereClauseReset(); room.Where.CreatedBy.Value = member.MemberID; room.Where.CreatedBy.Operator = MyGeneration.dOOdads.WhereParameter.Operand.Equal; room.Query.Load(); if (room.RowCount >= 2) { ClientScript.RegisterStartupScript(this.GetType(), "error_roomnameexists", "$(document).ready(function (){ notify('error','عفواً ، تم تخطى العدد المسموح للغرف الخاصة بك.');}); ", true); return; } room.AddNew(); room.Name = uiTextBoxADD_Name.Text; querystring = "c=true"; } else { room.LoadByPrimaryKey(CurrentRoom); querystring = "e=true"; } if (!IsEdit) { room.CreatedDate = DateTime.Now; room.CreatedBy = member.MemberID; if (uiDropDownListADD_Category.SelectedIndex != -1) room.CategoryID = Convert.ToInt32(uiDropDownListADD_Category.SelectedValue); if (uiDropDownListADD_SubCategory.SelectedIndex != 0) room.SubCategoryID = Convert.ToInt32(uiDropDownListADD_SubCategory.SelectedValue); } else { if (uiDropDownListEdit_Category.SelectedIndex != -1) room.CategoryID = Convert.ToInt32(uiDropDownListEdit_Category.SelectedValue); if (uiDropDownListEditSubCat.SelectedIndex != 0) room.SubCategoryID = Convert.ToInt32(uiDropDownListEditSubCat.SelectedValue); } if (uiFileUploadRoomPic.HasFile) { string path = "~/" + ConfigurationManager.AppSettings["roomspics"].ToString(); DirectoryInfo dir = new DirectoryInfo(Server.MapPath(path + "/" + Membership.GetUser().ProviderUserKey.ToString())); if (!dir.Exists) dir.Create(); path += "/" + Membership.GetUser().ProviderUserKey.ToString() + "/" + DateTime.Now.ToString("ddMMyyyyhhmmss") + "_" + uiFileUploadRoomPic.FileName; uiFileUploadRoomPic.SaveAs(Server.MapPath(path)); room.IconPath = path; } room.RoomPassword = uiTextBoxPassword.Text; room.RoomAdminPassword = uiTextBoxAdminPass.Text; room.RoomPasswordenabled = uiCheckBoxPasswordEnable.Checked; room.EnableCam = true; room.EnableMic = true; /* room.EnableCam = uiCheckBoxEnableCam.Checked; room.EnableOneMic = uiCheckBoxEnableOneMic.Checked; room.EnableTwoMic = uiCheckBoxEnableTwoMic.Checked; room.EnableThreeMic = uiCheckBoxEnableThreeMic.Checked;*/ room.RowStatusID = 1; room.Save(); // update room count for cats & subcats IHubContext _Rcontext = GlobalHost.ConnectionManager.GetHubContext<ChatRoomHub>(); Room rooms = new Room(); rooms.GetRoomsByCreatorID(Member.CurrentMemberID); _Rcontext.Clients.Group(member.UserName).updateRoomCount(0, 0, rooms.RowCount, true); rooms.GetRoomsByCategoryID(room.CategoryID); _Rcontext.Clients.All.updateRoomCount(room.CategoryID, 0, rooms.RowCount, false); if (!room.IsColumnNull(Room.ColumnNames.SubCategoryID)) { rooms.GetRoomsBySubCategoryID(room.SubCategoryID); _Rcontext.Clients.All.updateRoomCount(0, room.SubCategoryID, rooms.RowCount, false); } /* add room owner */ RoomMember roommember = new RoomMember(); roommember.AddNew(); roommember.RoomID = room.RoomID; roommember.MemberID = room.CreatedBy; roommember.RoomMemberLevelID = (int)Helper.Enums.RoomMemberLevel.Owner; roommember.Save(); uiPanelSuccess.Visible = true; uiTextBoxADD_Name.Text = ""; uiDropDownListADD_Category.SelectedIndex = 0; uiDropDownListADD_SubCategory.SelectedIndex = 0; uiTextBoxPassword.Text = ""; uiTextBoxAdminPass.Text = ""; uiCheckBoxPasswordEnable.Checked = false; // log if (!IsEdit) { BLL.MemberLog log = new BLL.MemberLog(); log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.CreateRoom() { RoomID = room.RoomID, RoomName = room.Name }, null, room.RoomID); } /* if (AdminsTable.Rows.Count > 0) { RoomMember roommember = new RoomMember(); roommember.GetAllAdminMembersByRoomID(room.RoomID); roommember.DeleteAll(); roommember.Save(); RoomMember toAdd = new RoomMember(); for (int i = 0; i < AdminsTable.Rows.Count; i++) { if (Convert.ToInt32(AdminsTable.Rows[i]["MemberID"].ToString()) == room.CreatedBy) continue; toAdd.AddNew(); toAdd.RoomID = room.RoomID; toAdd.MemberID = Convert.ToInt32(AdminsTable.Rows[i]["MemberID"].ToString()); toAdd.RoomMemberLevelID = Convert.ToInt32(AdminsTable.Rows[i]["AdminTypeID"].ToString()); } toAdd.Save(); } else { RoomMember roommember = new RoomMember(); roommember.AddNew(); roommember.RoomID = room.RoomID; roommember.MemberID = room.CreatedBy; roommember.RoomMemberLevelID = (int)Helper.Enums.RoomMemberLevel.Owner; roommember.Save(); } */ CurrentRoom = room.RoomID; Response.Redirect("createRoom.aspx?IsEdit=true&" +querystring); } }