Esempio n. 1
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;
        }
Esempio n. 2
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");
            }
        }
Esempio n. 3
0
        public void GetGifts()
        {
            List<dynamic> gifts = new List<dynamic>();
            Gift allgifts = new Gift();
            allgifts.LoadAll();
            if (allgifts.RowCount > 0)
            {
                for (int i = 0; i < allgifts.RowCount; i++)
                {
                    gifts.Add(new { giftid = allgifts.GiftID, name = allgifts.Name, price = allgifts.IsColumnNull("Price_Point") ? "0" : allgifts.Price_Point.ToString(), picPath = allgifts.PicPath, AudioPath = allgifts.AudioPath });
                    allgifts.MoveNext();
                }
            }

            string result = Newtonsoft.Json.JsonConvert.SerializeObject(gifts);
            HttpContext.Current.Response.ContentType = "application/json; charset=utf-8";
            HttpContext.Current.Response.Write(result);
            //return result;
        }