Пример #1
0
        private void BindReport()
        {
            BLL.MemberLog log = new BLL.MemberLog();
            log.GetPointsReport(BLL.Member.CurrentMemberID, txtStartDate.Text, txtEndDate.Text);

            grdLog.DataSource = log.DefaultView;
            grdLog.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
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadBalance();
                //LoadFriends();

                // logging
                BLL.MemberLog log = new BLL.MemberLog();
                log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.Log() {Type=Helper.Enums.LogType.ViewBalancePage }, null, null);
            }
        }
Пример #4
0
        protected void uiLinkButtonConfirm_Click(object sender, EventArgs e)
        {
            MembershipUser user = Membership.GetUser();

            if (user.PasswordQuestion == uiDropDownListQuestion.SelectedValue && Member.CurrentMember.Answer == uiTextBoxAnswer.Text.Trim())
            {
                if (!string.IsNullOrEmpty(uiHiddenFieldFriendID.Value))
                {
                    try
                    {
                        int points = Convert.ToInt32(uiHiddenFieldPoints.Value);
                        if (Member.CurrentMember.Credit_Point < points)
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "Error3", @"$(document).ready(function () { notify('error', 'حدث خطأ . رصيدك الحالى لا يسمح لإتمام الشحن.'); });", true);
                            return;
                        }

                        Member ToMember = new Member();
                        ToMember.LoadByPrimaryKey(Convert.ToInt32(uiHiddenFieldFriendID.Value));

                        ToMember.Credit_Point = ToMember.Credit_Point + points;
                        Member.CurrentMember.Credit_Point -= points;
                        ToMember.Save();
                        Member.CurrentMember.Save();

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

                        // logging
                        BLL.MemberLog log = new BLL.MemberLog();
                        log.AddNew(Member.CurrentMemberID, new BLL.Log.RechargePoints() { FromMemberName=BLL.Member.CurrentMember.Name,ToMemberName = ToMember.Name, Points = points }, ToMember.MemberID, null);

                        LoadBalance();
                        uiHiddenFieldPrice.Value = "";
                        uiHiddenFieldPoints.Value = "";
                        uiHiddenFieldFriendID.Value = "";
                    }
                    catch (Exception ex)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "Error11", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك أعد المحاولة.'); });", true);
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Error4", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك أعد المحاولة.'); });", true);
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Error5", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك تأكد من السؤال والإجابة السرى.'); });", true);
                return;
            }
        }
Пример #5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Member member=new Member();
                member.GetMemberByUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString()));
                ctrlMail.MemberName = Membership.GetUser().UserName;
                ctrlMail.MemberID = member.MemberID;

                // logging
                BLL.MemberLog log = new BLL.MemberLog();
                log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.Log() { Type = Helper.Enums.LogType.ViewMailPage }, null, null);
            }
        }
Пример #6
0
        protected void uiLinkButtonAddFriend_Click(object sender, EventArgs e)
        {
            Member member = new Member();
            member.GetMemberByUserId(new Guid(Membership.GetUser().ProviderUserKey.ToString()));

            try
            {
                MemberFriend newfriend = new MemberFriend();
                newfriend.AddNew();
                newfriend.MemberID = member.MemberID;
                newfriend.FriendID = Convert.ToInt32(uiHiddenFieldFriendID.Value);
                newfriend.Save();

                Member memberfriend = new Member();
                memberfriend.LoadByPrimaryKey(newfriend.FriendID);

                // logging
                BLL.MemberLog log = new BLL.MemberLog();
                log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.AddFriend() { FriendID = newfriend.FriendID, FriendName = memberfriend.Name }, newfriend.FriendID, null);
            }
            catch (Exception ex)
            {
                ClientScript.RegisterStartupScript(this.GetType(), "ErrorAddingFriend", "$(document).ready(function (){ notify('error','خطأ. حدث خطأ . من فضلك أعد المحاولة مرة أخرى أو تأكد من وجود الصديق فى قائمة الأصدقاء.');}); ", true);
            }
        }
Пример #7
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(hdnMember.Value))
                {
                    Member upgrademember = new Member();
                    upgrademember.LoadByPrimaryKey(Convert.ToInt32(hdnMember.Value));

                    try
                    {
                        int durationID = Convert.ToInt32(hdnDuration.Value);
                        int specID = Convert.ToInt32(hdnSpec.Value);
                        BLL.MemberTypeSpecDuration bllMemberTypeSpecDuration = new MemberTypeSpecDuration();
                        bllMemberTypeSpecDuration.Where.TypeDurationID.Value = durationID;
                        bllMemberTypeSpecDuration.Where.MemberTypeSpecID.Value = specID;
                        bllMemberTypeSpecDuration.Query.Load();
                        int points = bllMemberTypeSpecDuration.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.MemberType bllMemberType = new MemberType();
                        bllMemberType.DeleteMemberTypes(upgrademember.MemberID);

                        upgrademember.MemberType.MemberTypeSpecDurationID = bllMemberTypeSpecDuration.ID;
                        upgrademember.MemberType.CreateBy = BLL.Member.CurrentMember.MemberID;
                        upgrademember.MemberType.StartDate = DateTime.Now;
                        upgrademember.MemberType.EndDate = DateTime.Now.AddMonths(bllMemberTypeSpecDuration.TypeDuration.MonthesNumber);
                        upgrademember.MemberType.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.ChangeMemberType() { MemberName = upgrademember.Name, NewTypeName = upgrademember.MemberType.MemberTypeSpecDuration.MemberTypeSpec.Name, NewTypeExpiryDate = upgrademember.MemberType.EndDate, Points = points }, upgrademember.MemberID, null);

                        lblPoints.Text = BLL.Member.CurrentMember.Credit_Point.ToString();

                        NotifyMember(upgrademember.MemberID, bllMemberTypeSpecDuration.MemberTypeSpecID);

                        LoadBalance();
                    }
                    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;
            }
        }
Пример #8
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 { }
        }
Пример #9
0
 /// <summary>
 /// Eskat or Cancel Eskat of room member
 /// </summary>
 /// <param name="rid"></param>
 /// <param name="isMarked"></param>
 /// <param name="memberid"></param>
 public void ToggleUserMark(int rid, bool isMarked, int memberid)
 {
     if (isMarked)
         Clients.Group(rid.ToString()).UserMarked(rid, memberid);
     else
         Clients.Group(rid.ToString()).UserUnMarked(rid, memberid);
     try
     {
         BLL.Member member = new Member();
         member.LoadByPrimaryKey(memberid);
         BLL.MemberLog log = new BLL.MemberLog();
         if (isMarked)
         {
             log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.MarkRoomMember() { MemberID = memberid, MemberName = member.Name }, memberid, rid);
         }
         else
         {
             log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.UnMarkRoomMember() { MemberID = memberid, MemberName = member.Name }, memberid, rid);
         }
         RoomMember rm = new RoomMember();
         if (rm.LoadByPrimaryKey(memberid, rid))
         {
             rm.IsMarked = isMarked;
             rm.CanAccessMic = !isMarked;
             rm.Save();
         }
     }
     catch { }
 }
Пример #10
0
 // logging
 public void enterPrivateChatLog(int FriendID, string FriendName)
 {
     BLL.MemberLog log = new BLL.MemberLog();
     log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.EnterPrivateChate() { FriendID = FriendID, FriendName = FriendName }, FriendID, null);
 }
Пример #11
0
        protected void btnRegister_Click(object sender, EventArgs e)
        {
            int type = Convert.ToInt32(lstTypes.SelectedValue);
            BLL.MemberTypeSpecDuration bllSpec = new MemberTypeSpecDuration();
            if (!bllSpec.LoadByMemberTypeSpecID(type))
                return;
            int val = 0;//Convert.ToInt32(bllSpec.Points);
            if (BLL.Member.CurrentMember.Credit_Point < val)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "Error3", @"$(document).ready(function () { notify('error', 'حدث خطأ . رصيدك الحالى لا يسمح لإتمام العملية.'); });", true);
                return;
            }
            MembershipCreateStatus objstatus;
            MembershipUser objUser = Membership.CreateUser(UserName.Text, Password.Text, Email.Text, Question.Text, Answer.Text.Trim(), true, out objstatus);
            bool success = true;
            switch (objstatus)
            {
                case MembershipCreateStatus.DuplicateUserName:
                    ErrorMessage.Text = GetLocalResourceObject("duplicateUsername").ToString();
                    ErrorMessage.Visible = true;
                    success = false;
                    break;
                case MembershipCreateStatus.InvalidPassword:
                    ErrorMessage.Text = GetLocalResourceObject("invalidPass").ToString();
                    ErrorMessage.Visible = true;
                    success = false;
                    break;
                case MembershipCreateStatus.ProviderError:
                case MembershipCreateStatus.UserRejected:
                    ErrorMessage.Text = GetLocalResourceObject("generalError").ToString();
                    ErrorMessage.Visible = true;
                    success = false;
                    break;
                default:
                    break;
            }
            if (success)
            {
                Member member = new Member();
                member.AddNew();
                member.Answer = Answer.Text.Trim();
                member.UserID = new Guid(objUser.ProviderUserKey.ToString());
                member.Name = objUser.UserName;
                member.IsOnLine = false;
                member.Status = 1;
                member.Save();
                try
                {
                    MailMessage msg = new MailMessage();
                    string body = GetLocalResourceObject("body").ToString();
                    string mail = GetLocalResourceObject("mail").ToString();

                    member.ActivationCode = Guid.NewGuid();
                    member.Save();
                    string mailto = objUser.Email;
                    msg.To.Add(mailto);
                    msg.From = new MailAddress(mail);
                    msg.Subject = GetLocalResourceObject("subject").ToString();
                    msg.IsBodyHtml = true;
                    msg.BodyEncoding = System.Text.Encoding.Unicode;

                    msg.Body = string.Format(body, objUser.UserName, member.ActivationCode.ToString());

                    SmtpClient client = new SmtpClient(GetLocalResourceObject("mailserver").ToString(), 25);

                    client.UseDefaultCredentials = false;

                    client.Credentials = new System.Net.NetworkCredential(mail, GetLocalResourceObject("mailpass").ToString());
                    client.Send(msg);

                    member.MemberType.MemberTypeSpecDurationID = bllSpec.ID;
                    member.MemberType.CreateBy = BLL.Member.CurrentMember.MemberID;
                    member.MemberType.StartDate = DateTime.Now;
                    member.MemberType.EndDate = DateTime.Now.AddMonths(Convert.ToInt32(lstTypeDuration.SelectedValue));
                    member.MemberType.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.ChangeMemberType() { MemberName = member.Name, NewTypeName = member.MemberType.MemberTypeSpecDuration.MemberTypeSpec.Name, NewTypeExpiryDate = member.MemberType.EndDate, Points = val }, member.MemberID, null);
                }
                catch (Exception)
                {

                }

                uiPanelDone.Visible = true;
                uiPanelRegister.Visible = false;
                ClearFields();
            }
        }
Пример #12
0
        protected void uiLinkButtonSaveMember_Click(object sender, EventArgs e)
        {
            int type = Convert.ToInt32(uiRadioButtonListTypes.SelectedValue);
            BLL.MemberTypeSpecDuration bllSpec = new MemberTypeSpecDuration();
            if (!bllSpec.LoadByMemberTypeSpecID(type))
                return;
            int val = 0;//Convert.ToInt32(bllSpec.Points);
            if (BLL.Member.CurrentMember.Credit_Point < val)
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "balanceError", @"$(document).ready(function () { notify('error', 'حدث خطأ . رصيدك الحالى لا يسمح لإتمام العملية.'); });", true);
                return;
            }

            Member member = new Member();
            if (!member.LoadByPrimaryKey(Convert.ToInt32(hdnMember.Value)))
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "NoacountError", @"$(document).ready(function () { notify('error', 'حدث خطأ . لا يوجد حساب بهذا الإسم.'); });", true);
                return;
            }

            BLL.MembershipBLL membership = new BLL.MembershipBLL();
            string msg;
            string oldname = member.Name;
            if (!string.IsNullOrEmpty(uiTextBoxNewName.Text))
            {
                if (membership.ChangeUsername(oldname, uiTextBoxNewName.Text, Membership.ApplicationName, out msg))
                {
                    member.Name = uiTextBoxNewName.Text;
                    member.Save();
                }
                else
                {
                    uiTextBoxNewName.Text = oldname;
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "changeName", @"$(document).ready(function () { notify('error', 'حدث خطأ ." + msg + ".'); });", true);
                    return;
                }
            }
            member.MemberType.MemberTypeSpecDurationID = bllSpec.ID;
            member.MemberType.CreateBy = BLL.Member.CurrentMember.MemberID;
            member.MemberType.StartDate = DateTime.Now;
            member.MemberType.EndDate = DateTime.Now.AddMonths(Convert.ToInt32(uiDropDownListTypeDuration.SelectedValue));
            member.MemberType.OldName = oldname;
            member.MemberType.Save();

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

            uiPanelUpgradeSuccess.Visible = true;
            uiPanelUpgrade.Visible = false;
            clearUpgradeFields();

            BLL.MemberLog log = new BLL.MemberLog();
            log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.ChangeMemberType() { MemberName = member.Name,OldName=oldname, NewTypeName = member.MemberType.MemberTypeSpecDuration.MemberTypeSpec.Name, NewTypeExpiryDate = member.MemberType.EndDate, Points = val }, member.MemberID, null);

            Chat2Connect.usercontrols.MemberTypes.NotifyMember(member.MemberID, type);
            Chat2Connect.usercontrols.MemberTypes.NotifyMember(member.MemberID, member.UserName);
        }
Пример #13
0
        public void AddRemoveFriend(int mid, int fid, bool isFriend)
        {
            try
            {
                BLL.MemberFriend friend = new MemberFriend();
                Member friendMember = new Member();
                friendMember.LoadByPrimaryKey(fid);

                if (!isFriend)
                {
                    friend.AddNew();
                    friend.MemberID = mid;
                    friend.FriendID = fid;
                    friend.Save();
                    // logging
                    BLL.MemberLog log = new BLL.MemberLog();
                    log.AddNew(mid, new BLL.Log.AddFriend() { FriendID = fid, FriendName = friendMember.Name }, fid, null);

                    var resultFriend = new
                    {
                        MemberID = friendMember.MemberID,
                        Name = friendMember.Name,
                        TypeSpecID = friendMember.MemberType.MemberTypeSpecDuration.MemberTypeSpecID,
                        ProfilePic = (friendMember.IsColumnNull(Member.ColumnNames.ProfilePic) ? "images/defaultavatar.png" : friendMember.ProfilePic),
                        IsOnline = friendMember.IsOnLine,
                        StatusMsg = friendMember.s_StatusMsg,
                        Status = Helper.EnumUtil.ParseEnum<Helper.Enums.MemberStatus>(Helper.TypeConverter.ToInt32(friendMember.s_Status)).ToString().ToLower(),
                        IsSelected = false
                    };
                    SetContentResult(resultFriend);
                }
                else
                {
                    friend.DeleteFriend(mid, fid);
                    // logging
                    BLL.MemberLog log = new BLL.MemberLog();
                    log.AddNew(mid, new BLL.Log.DeleteFriend() { FriendID = fid, FriendName = friendMember.Name }, fid, null);
                }

            }
            catch { }
        }
Пример #14
0
        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);

            }
        }
Пример #15
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);
            }
        }
Пример #16
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 (uiHiddenFieldFriendID.Value != "")
                {

                    if (string.IsNullOrEmpty(uiTextBoxAmount.Text))
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "Error2", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك أدخل قيمة التحويل.'); });", true);
                        return;
                    }
                    try
                    {
                        int points = Convert.ToInt32(uiTextBoxAmount.Text);
                        if (BLL.Member.CurrentMember.Credit_Point < points)
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "Error3", @"$(document).ready(function () { notify('error', 'حدث خطأ . رصيدك الحالى لا يسمح لإتمام التحويل.'); });", true);
                            return;
                        }

                        Member ToMember = new Member();
                        if (uiHiddenFieldFriendID.Value != "0" && uiHiddenFieldFriendID.Value != "")
                        {
                            ToMember.LoadByPrimaryKey(Convert.ToInt32(uiHiddenFieldFriendID.Value));
                        }
                        else
                        {
                            ClientScript.RegisterStartupScript(this.GetType(), "Error7", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك أختر صديق للتحويل.'); });", true);
                            return;
                        }

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

                        BLL.Message msg = new BLL.Message();
                        msg.AddNew();
                        msg.Body = string.Format(GetLocalResourceObject("ConfirmMsgBody").ToString(),BLL.Member.CurrentMember.UserName, points.ToString());
                        msg.SenderID = BLL.Member.CurrentMemberID;
                        msg.Subject = GetLocalResourceObject("ConfirmMsgSubject").ToString();
                        msg.ToMembers = ToMember.UserName;
                        msg.Save();

                        MemberMessage memberMsg = new MemberMessage();
                        memberMsg.AddNew();
                        memberMsg.MemberID = ToMember.MemberID;
                        memberMsg.MessageID = msg.ID;
                        memberMsg.Save();

                        NotificationHub notifications = new NotificationHub();
                        notifications.SendMailNotifications(ToMember.MemberID);

                        IHubContext roomHub = GlobalHost.ConnectionManager.GetHubContext<ChatRoomHub>();
                        roomHub.Clients.Group(ToMember.UserName).updateBalance(ToMember.Credit_Point);

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

                        // logging
                        BLL.MemberLog log = new BLL.MemberLog();
                        log.AddNew(BLL.Member.CurrentMemberID, new BLL.Log.TransferPoints() { FromMemberName=BLL.Member.CurrentMember.Name, ToMemberName = ToMember.Name, Points = points }, ToMember.MemberID, null);

                        LoadBalance();
                        uiTextBoxAmount.Text = "";
                    }
                    catch (Exception ex)
                    {
                        ClientScript.RegisterStartupScript(this.GetType(), "Error11", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك أعد المحاولة.'); });", true);
                    }
                }
                else
                {
                    ClientScript.RegisterStartupScript(this.GetType(), "Error7", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك أختر صديق للتحويل.'); });", true);
                }
            }
            else
            {
                ClientScript.RegisterStartupScript(this.GetType(), "Error5", @"$(document).ready(function () { notify('error', 'حدث خطأ . من فضلك تأكد من السؤال والإجابة السرى.'); });", true);
                return;
            }
        }