protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (!String.IsNullOrEmpty(Request.Form["message"]))
                {
                    int msgID = 0;
                    int.TryParse(Request.Form["message"], out msgID);

                    BLL.MemberMessage msg = new BLL.MemberMessage();
                    if (msg.LoadFullInfoByID(msgID))
                    {
                        if (!msg.IsRead && !msg.IsColumnNull(BLL.MemberMessage.ColumnNames.MemberID))
                        {
                            msg.IsRead = true;
                            msg.Save();
                            Chat2Connect.SRCustomHubs.NotificationHub notification = new SRCustomHubs.NotificationHub();
                            notification.SendMailNotifications(msg.MemberID);
                        }

                        dvFrom.InnerHtml = Helper.TypeConverter.ToString(msg.GetColumn("FromMember"));
                        dvToMembers.InnerHtml = Helper.TypeConverter.ToString(msg.GetColumn("ToMembers"));
                        dvSubject.InnerHtml = Helper.TypeConverter.ToString(msg.GetColumn("Subject"));
                        dvBody.InnerHtml = Helper.TypeConverter.ToString(msg.GetColumn("Body"));
                    }
                }
            }
        }
Esempio n. 2
0
 public void sendMailNotifications()
 {
     NotificationHub hup = new NotificationHub();
     hup.SendMailNotifications(null);
 }
Esempio n. 3
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;
        }
Esempio n. 4
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;
        }
Esempio n. 5
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;
            }
        }