Exemplo n.º 1
0
        protected void SendMessageClicked(object o, EventArgs e)
        {
            if (tbTo.Entries.Count > 0 || cbSendToEveryone.Checked)
            {
                var m = new HRR.Core.Domain.Message();
                m.Body          = reContent.Content;
                m.DateCreated   = DateTime.Now;
                m.MessageTypeID = (int)MessageType.MESSAGE;
                m.SentBy        = SecurityContextManager.Current.CurrentUser.ID;
                m.Subject       = tbSubject.Text;
                new MessageServices().Save(m);

                //save to sent folder
                var sentby = new MessageRecipient();
                sentby.MessageFolderID     = (int)MessageFolder.SENT;
                sentby.MessageID           = m.ID;
                sentby.MessageStatusTypeID = (int)MessageStatusType.UNREAD;
                sentby.RecipientID         = m.SentBy;
                sentby.RecipientTypeID     = (int)RecipientType.TO;
                new MessageRecipientServices().Save(sentby);

                if (!cbSendToEveryone.Checked)
                {
                    BuildRecipientList(m);
                }
                else
                {
                    BuildAllRecipients(m);
                }
                Response.Redirect("/Polls");
            }
        }
Exemplo n.º 2
0
 private void BuildRecipients(AutoCompleteBoxEntryCollection entries, HRR.Core.Domain.Message msg, int recipientType)
 {
     for (int i = 0; i < entries.Count; i++)
     {
         if (entries[i].Value.StartsWith("team:"))
         {
             var t = new TeamServices().GetByID(Convert.ToInt32(entries[i].Value.Replace("team:", "")));
             foreach (var m in t.Members)
             {
                 var r = new MessageRecipient();
                 r.MessageFolderID     = (int)MessageFolder.INBOX;
                 r.MessageStatusTypeID = (int)MessageStatusType.UNREAD;
                 r.RecipientID         = m.PersonID;
                 r.RecipientTypeID     = recipientType;
                 r.MessageID           = msg.ID;
                 new MessageRecipientServices().Save(r);
                 var sentby = new PersonServices().GetByID(msg.SentBy);
                 EmailHelper.SendMessageNotification(msg, m.PersonRef);
             }
         }
         else
         {
             var p = new PersonServices().GetByEmail(entries[i].Value);
             var r = new MessageRecipient();
             r.MessageFolderID     = (int)MessageFolder.INBOX;
             r.MessageStatusTypeID = (int)MessageStatusType.UNREAD;
             r.RecipientID         = p.ID;
             r.RecipientTypeID     = recipientType;
             r.MessageID           = msg.ID;
             new MessageRecipientServices().Save(r);
             var sentby = new PersonServices().GetByID(msg.SentBy);
             EmailHelper.SendMessageNotification(msg, p);
         }
     }
 }
Exemplo n.º 3
0
        private void BuildAllRecipients(HRR.Core.Domain.Message msg)
        {
            int total = 0;

            foreach (var p in new PersonServices().GetByAccountID(SecurityContextManager.Current.CurrentUser.AccountID))
            {
                if (p.ReceiveCommentNotifications)
                {
                    var r = new MessageRecipient();
                    r.MessageFolderID     = (int)MessageFolder.INBOX;
                    r.MessageStatusTypeID = (int)MessageStatusType.UNREAD;
                    r.RecipientID         = p.ID;
                    r.RecipientTypeID     = (int)RecipientType.TO;
                    r.MessageID           = msg.ID;
                    new MessageRecipientServices().Save(r);
                    var sentby = new PersonServices().GetByID(msg.SentBy);
                    EmailHelper.SendPollNotification(msg, p);
                    total++;
                }
            }
            var poll = new PollServices().GetByID(CurrentPoll.ID);

            poll.TotalPolled = total;
            new PollServices().Save(poll);
        }
Exemplo n.º 4
0
        private void BuildRecipientList(HRR.Core.Domain.Message msg)
        {
            BuildRecipients(this.tbTo.Entries, msg, (int)RecipientType.TO);
            BuildRecipients(this.tbCc.Entries, msg, (int)RecipientType.CC);
            BuildRecipients(this.tbBcc.Entries, msg, (int)RecipientType.BCC);


            //entries = this.tbCc.Entries;
            //for (int i = 0; i < entries.Count; i++)
            //{
            //    var p = new PersonServices().GetByEmail(entries[i].Value);
            //    var r = new MessageRecipient();
            //    r.MessageFolderID = (int)MessageFolder.INBOX;
            //    r.MessageStatusTypeID = (int)MessageStatusType.UNREAD;
            //    r.RecipientID = p.ID;
            //    r.RecipientTypeID = (int)RecipientType.CC;
            //    r.MessageID = msg.ID;
            //    new MessageRecipientServices().Save(r);
            //    var sentby = new PersonServices().GetByID(msg.SentBy);
            //    EmailHelper.SendMessageNotification(msg, p);
            //}

            //entries = this.tbBcc.Entries;
            //for (int i = 0; i < entries.Count; i++)
            //{
            //    var p = new PersonServices().GetByEmail(entries[i].Value);
            //    var r = new MessageRecipient();
            //    r.MessageFolderID = (int)MessageFolder.INBOX;
            //    r.MessageStatusTypeID = (int)MessageStatusType.UNREAD;
            //    r.RecipientID = p.ID;
            //    r.RecipientTypeID = (int)RecipientType.BCC;
            //    r.MessageID = msg.ID;
            //    new MessageRecipientServices().Save(r);
            //    var sentby = new PersonServices().GetByID(msg.SentBy);
            //    EmailHelper.SendMessageNotification(msg, p);
            //}
        }
Exemplo n.º 5
0
 private void BuildRecipientList(HRR.Core.Domain.Message msg)
 {
     BuildRecipients(this.tbTo.Entries, msg, (int)RecipientType.TO);
 }