Exemplo n.º 1
0
 private static void SendMailNotication(int memberID, IHubContext context)
 {
     BLL.MemberMessage messages = new MemberMessage();
     int unReadCount = 0;
     messages.LoadReceivedMessages(memberID);
     if (messages.RowCount > 0)
     {
         do
         {
             if (messages.IsColumnNull(MemberMessage.ColumnNames.IsRead) || messages.IsRead == false)
                 unReadCount++;
         } while (messages.MoveNext());
     }
     //return context.Clients.Group("gherbas").RecieveNotification(totalNewMessages);
     context.Clients.All.RecieveMailNotification(memberID, unReadCount);
 }
Exemplo n.º 2
0
 protected void btnSaveHelpRequest_Click(object sender, EventArgs e)
 {
     BLL.Message msg = new BLL.Message();
     msg.AddNew();
     msg.Body = txtBody.Text;
     msg.SenderID = BLL.Member.CurrentMemberID;
     msg.Subject = txtSubject.Text;
     msg.ToMembers = lstHelpRequests.SelectedItem.Text;
     msg.Save();
     MemberMessage memberMsg = new MemberMessage();
     //add to member sent items
     memberMsg.AddNew();
     memberMsg.MessageID = msg.ID;
     memberMsg.IsRead = true;
     //add to receipent folder
     Helper.Enums.SiteMembers siteMember = Helper.EnumUtil.ParseEnum<Helper.Enums.SiteMembers>(Convert.ToInt32(lstHelpRequests.SelectedValue));
     int recipientID = BLL.Member.SiteMembers.Where(s => String.Equals(s.Name, Helper.StringEnum.GetStringValue(siteMember))).FirstOrDefault().MemberID;
     memberMsg.AddNew();
     memberMsg.MemberID = recipientID;
     memberMsg.MessageID = msg.ID;
     memberMsg.Save();
 }
Exemplo n.º 3
0
        protected void btnDeleteMessages_Click(object sender, EventArgs e)
        {
            MemberMessage message = new MemberMessage();
            List<int> selectedMessages = GetSelectedMessages();
            if (selectedMessages.Count > 0)
            {
                if (CurrentFolder == (int)Folders.Deleted)
                {
                    message.Delete(selectedMessages);
                }
                else
                {
                    message.MoveToTrash(selectedMessages);
                }

                BindMessages();

                Chat2Connect.SRCustomHubs.NotificationHub notification = new SRCustomHubs.NotificationHub();
                notification.SendMailNotifications(MemberID);
            }
        }
Exemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindFolders();

                int friendId = 0;
                string friendname = "";
                if (!string.IsNullOrEmpty(Request.QueryString["t"]) && Request.QueryString["t"].ToString() == "createmsg")
                {
                    if (!String.IsNullOrEmpty(Request.QueryString["u"]))
                    {
                        int.TryParse(Request.QueryString["u"].ToString(), out friendId);
                        friendname = Request.QueryString["un"].ToString();
                    }
                    if (friendId != 0 && !string.IsNullOrEmpty(friendname))
                    {
                        Page.ClientScript.RegisterStartupScript(Page.GetType(), "sendmsg", "$(document).ready(function (){  $('#txtTo').tokenInput('add', { id: " + friendId + ", name: '" + friendname + "' }); });", true);
                    }
                    pnlSendMessage.Visible = true;
                    pnlCreateFolder.Visible = false;
                    pnlViewMessages.Visible = false;
                }

                if (!String.IsNullOrEmpty(Request.QueryString["reply"]))
                {
                    int msgID = Convert.ToInt32(Request.QueryString["reply"]);
                    pnlSendMessage.Visible = true;
                    pnlCreateFolder.Visible = false;
                    pnlViewMessages.Visible = false;
                    BLL.MemberMessage msg = new BLL.MemberMessage();
                    if (msg.LoadFullInfoByID(msgID))
                    {
                        ctrlSendMail.MessageBody = Helper.TypeConverter.ToString(msg.GetColumn("Body"));
                        ctrlSendMail.MessageSubject = "رد " + Helper.TypeConverter.ToString(msg.GetColumn("Subject"));
                        ctrlSendMail.ToMemberID = Helper.TypeConverter.ToString(msg.GetColumn("SenderID"));
                        ctrlSendMail.ToMemberName = Helper.TypeConverter.ToString(msg.GetColumn("FromMember"));
                    }
                }

            }
        }
Exemplo n.º 5
0
        private void BindMessages()
        {
            pnlViewMessages.Visible = true;
            pnlSendMessage.Visible = false;
            pnlCreateFolder.Visible = false;
            MemberMessage messages = new MemberMessage();
            btnDeleteMessages.OnClientClick = "";
            var memberField = grdMessages.Columns[1] as BoundField;
            memberField.HeaderText = "الراسل";
            memberField.DataField = "FromMember";
            if (MemberID > 0)
            {
                switch (CurrentFolder)
                {
                    case (int)Folders.Inbox:
                        messages.LoadReceivedMessages(MemberID);
                        break;
                    case (int)Folders.Sent:
                        messages.LoadSentMessages(MemberID);
                        memberField.DataField = Message.ColumnNames.ToMembers;
                        memberField.HeaderText = "إلى";
                        break;
                    case (int)Folders.Deleted:
                        messages.LoadTrashMessages(MemberID);
                        btnDeleteMessages.OnClientClick = "return confirm('سيتم الحذف نهائياهل تريد الإستمرار؟');";
                        break;
                    default:
                        messages.LoadByFolderID(CurrentFolder);
                        break;
                }
            }

            grdMessages.DataSource = messages.DefaultView;
            grdMessages.DataBind();
        }
Exemplo n.º 6
0
 protected void lnkMoveMessagesToFolder_Click(object sender, EventArgs e)
 {
     int folderID = Convert.ToInt32(((LinkButton)sender).CommandArgument.ToString());
     MemberMessage message = new MemberMessage();
     List<int> selectedMessages = GetSelectedMessages();
     if (selectedMessages.Count>0)
     {
         message.MoveToFolder(selectedMessages,folderID);
         BindMessages();
     }
 }
Exemplo n.º 7
0
        protected void grdFolders_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "EditFolder")
            {
                MessageFolder folder = new MessageFolder();
                folder.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
                txtFolderName.Text = folder.Name;
                folderID.Value = e.CommandArgument.ToString();
            }
            else if (e.CommandName == "DeleteFolder")
            {
                MessageFolder folders = new MessageFolder();
                folders.LoadByPrimaryKey(Convert.ToInt32(e.CommandArgument.ToString()));
                MemberMessage msg = new MemberMessage();
                msg.LoadByFolderID(folders.MessageFolderID);

                if (!(msg.RowCount > 0))
                {
                    folders.MarkAsDeleted();
                    folders.Save();
                    BindFolders();
                }
                else
                {
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "Notify_error_del_folder", @"$.pnotify({
                                                                                                        text: 'حذث خطأ .يوجد رسائل تحت هذا التصميف.',
                                                                                                        type: 'error',
                                                                                                        history: false,
                                                                                                        closer_hover: false,
                                                                                                        delay: 5000,
                                                                                                        sticker: false
                                                                                                    });", true);
                }
            }
        }
Exemplo n.º 8
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;
        }
Exemplo n.º 9
0
        public bool SendMsg(int sender, string ToMember, string subject, string toName, string content)
        {
            List<int> recipients = new List<int>();
            string[] ToMembers = ToMember.Split(',');
            BLL.Message msg = new BLL.Message();
            msg.AddNew();
            msg.Body = content;
            msg.SenderID = sender;
            msg.Subject = subject;
            msg.ToMembers = toName;
            msg.Save();
            MemberMessage memberMsg = new MemberMessage();
            //add to member sent items
            memberMsg.AddNew();
            memberMsg.MessageID = msg.ID;
            memberMsg.IsRead = true;
            foreach (string item in ToMembers)
            {
                if (!string.IsNullOrEmpty(item))
                {
                    int recipientID = Convert.ToInt32(item);
                    // check if friend don't block sender
                    BlockedMembers bllBlocked = new BlockedMembers();
                    bllBlocked.Where.MemberID.Value = recipientID;
                    bllBlocked.Where.BlockID.Value = sender;
                    bllBlocked.Query.Load();
                    bool cansend = !(bllBlocked.RowCount > 0);

                    if (recipientID > 0 && !recipients.Contains(recipientID) && cansend) // cansend - check if friend don't block sender
                    {
                        recipients.Add(recipientID);
                        memberMsg.AddNew();
                        memberMsg.MemberID = recipientID;
                        memberMsg.MessageID = msg.ID;
                    }
                    else
                    {
                        recipientID = recipientID * -1;
                        if (Enum.IsDefined(typeof(Helper.Enums.AdminMailAddressAlias), recipientID))
                        {
                            Member aliasMembers = new Member();
                            aliasMembers.GetByAliase((Helper.Enums.AdminMailAddressAlias)recipientID);
                            do
                            {
                                if (!recipients.Contains(aliasMembers.MemberID))
                                {
                                    recipients.Add(aliasMembers.MemberID);
                                    memberMsg.AddNew();
                                    memberMsg.MemberID = aliasMembers.MemberID;
                                    memberMsg.MessageID = msg.ID;
                                }
                            } while (aliasMembers.MoveNext());
                        }
                    }
                }
            }

            memberMsg.Save();
            if (recipients.Count > 0)
            {
                NotificationHub notifications = new NotificationHub();
                for (int i = 0; i < recipients.Count; i++)
                {
                    notifications.SendMailNotifications(recipients[i]);
                }
            }
            return true;
        }
Exemplo n.º 10
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;
            }
        }