Example #1
0
        public void TicketCommentReplyEmail(Ticket ticket, TicketComment ticketCommentReply)
        {
            string applicationUrl = GetCustomApplicationUrl(true, true, true, "");
            string ticketUrl      = GetCustomApplicationUrl(true, true, true, "/Projects/Ticket/Details/" + ticket.TicketId + ticket.TicketId + "?cid=" + ticketCommentReply.TicketCommentId + "#" + ticketCommentReply.TicketCommentId);

            string emailMsg = ReadTemplateFile("~/Content/Templates/TicketComment.htm");

            emailMsg = emailMsg.Replace("{TicketSubject}", ticket.TicketSubject);
            emailMsg = emailMsg.Replace("{TicketId}", ticket.TicketId.ToString());
            emailMsg = emailMsg.Replace("{TicketCommentDetails}", ticketCommentReply.TicketCommentDetails);
            emailMsg = emailMsg.Replace("{FirstName}", UserHelpers.GetFirstName(ticketCommentReply.TicketCommentSubmitterUserId));
            emailMsg = emailMsg.Replace("{ApplicationUrl}", applicationUrl);
            emailMsg = emailMsg.Replace("{TicketUrl}", ticketUrl);


            MailMessage message = new MailMessage();

            message.From = new MailAddress(NotificationEmailAddressFrom, "Make progress every day");

            // obtain the ticket creator email address
            string ticketCreatorEmailAddress = UserHelpers.GetUserEmailAddress(ticket.TicketCreatorUserId);

            message.To.Add(ticketCreatorEmailAddress);

            // parse the TicketOwnersEmailList and add them to the email message TO field
            if (!string.IsNullOrEmpty(ticket.TicketOwnersEmailList))
            {
                string[] toEmailAddresses = ticket.TicketOwnersEmailList.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (string toEmail in toEmailAddresses)
                {
                    message.To.Add(toEmail);
                }
            }

            // parse the TicketEmailNotificationList and add any record to the CC field of the email
            if (!string.IsNullOrEmpty(ticket.TicketEmailNotificationList))
            {
                string[] ccEmailAddresses = ticket.TicketEmailNotificationList.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (string ccEmail in ccEmailAddresses)
                {
                    message.CC.Add(ccEmail);
                }
            }

            message.Subject      = "#" + ticket.TicketId + " - " + ticket.TicketSubject;
            message.Body         = emailMsg;
            message.BodyEncoding = Encoding.UTF8;
            message.IsBodyHtml   = true;

            SendEmail(message);
        }
        public void ShareNewTicketStream(Ticket ticket)
        {
            StreamRepository streamRepository = new StreamRepository();
            Stream           stream           = new Stream();

            stream.StreamType                 = "STATUS";
            stream.StreamDetails              = "Submitted Ticket #" + ticket.TicketId + ": " + ticket.TicketSubject;
            stream.StreamCreatorUserId        = UserHelpers.GetUserId(HttpContext.Current.User.Identity.Name);
            stream.StreamCreatorFullName      = UserHelpers.GetUserFullName(HttpContext.Current.User.Identity.Name);
            stream.StreamCreatedTimeStamp     = DateTime.UtcNow;
            stream.StreamLastUpdatedTimeStamp = DateTime.UtcNow;

            streamRepository.Add(stream);
            streamRepository.Save();
        }
Example #3
0
        //**********************************************************
        // Ticket notifications
        //**********************************************************

        public void NewTicketEmail(Ticket ticket)
        {
            string applicationUrl = GetCustomApplicationUrl(true, true, true, "");
            string ticketUrl      = GetCustomApplicationUrl(true, true, true, "/Projects/Ticket/Details/" + ticket.TicketId);

            string emailMsg = ReadTemplateFile("~/Content/Templates/NewTicket.htm");

            emailMsg = emailMsg.Replace("{TicketId}", ticket.TicketId.ToString());
            emailMsg = emailMsg.Replace("{TicketSubject}", ticket.TicketSubject);
            emailMsg = emailMsg.Replace("{TicketDescription}", ticket.TicketDescription);
            emailMsg = emailMsg.Replace("{FullName}", UserHelpers.GetUserFullName(ticket.TicketCreatorUserId));
            emailMsg = emailMsg.Replace("{ApplicationUrl}", applicationUrl);
            emailMsg = emailMsg.Replace("{TicketUrl}", ticketUrl);



            MailMessage message = new MailMessage();

            message.From = new MailAddress(NotificationEmailAddressFrom, "Make progress every day");

            if (!string.IsNullOrEmpty(ticket.TicketOwnersEmailList))
            {
                // parse the list of email addresses in the TO field
                string[] toEmailAddresses = ticket.TicketOwnersEmailList.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (string emailAddress in toEmailAddresses)
                {
                    message.To.Add(emailAddress);
                }
            }

            if (!string.IsNullOrEmpty(ticket.TicketEmailNotificationList))
            {
                // parse the list of email address in the CC field
                string[] ccEmailAddresses = ticket.TicketEmailNotificationList.Split(";".ToCharArray(), StringSplitOptions.RemoveEmptyEntries);
                foreach (string ccEmailAddress in ccEmailAddresses)
                {
                    message.CC.Add(ccEmailAddress);
                }
            }

            message.Subject      = "#" + ticket.TicketId + " - " + ticket.TicketSubject;
            message.Body         = emailMsg;
            message.BodyEncoding = Encoding.UTF8;
            message.IsBodyHtml   = true;

            SendEmail(message);
        }
Example #4
0
        public void StatusPostComment(string currentUserUserName, long streamId, string statusCommentMessage)
        {
            // Below we
            // 1. Notify the stream creator of the comment
            // 2. Notify those that have commented already on the stream (exclude the current comment submitter)

            //Grab the UserId of the stream creator
            var stream = new StreamRepository().GetStream(streamId);

            // Get the stream owner firstname & email address
            string statusOwnerFirstName    = UserHelpers.GetFirstName(stream.StreamCreatorUserId);
            string statusOwnerEmailAddress = UserHelpers.GetUserEmailAddress(stream.StreamCreatorUserId);

            // Get a list of users who have commented on this status
            var commentatorsAdresses = new StreamCommentRepository().GetStatusCommentatorsEmailAddresses(streamId);

            // remove the current user from the list of commentatos since notifiying him would be redundant
            commentatorsAdresses.Remove(currentUserUserName); //FYI: EmailAddress is reused as the username in this app.

            string commenterFirstName = UserHelpers.GetFirstName(currentUserUserName);

            // Compose email
            string applicationUrl = GetCustomApplicationUrl(true, true, true, "");

            string emailMsg = ReadTemplateFile("~/Content/Templates/StatusPostComment.htm");

            emailMsg = emailMsg.Replace("{StatusCommenterFirstName}", commenterFirstName);
            emailMsg = emailMsg.Replace("{StatusMessage}", statusCommentMessage);
            emailMsg = emailMsg.Replace("{StreamId}", streamId.ToString());
            emailMsg = emailMsg.Replace("{ApplicationUrl}", applicationUrl);

            MailMessage message = new MailMessage();

            message.From = new MailAddress(NotificationEmailAddressFrom, "Make progress every day");

            foreach (string emailAddress in commentatorsAdresses)
            {
                message.To.Add(emailAddress);
            }

            message.Subject      = commenterFirstName + "- commented on status";
            message.Body         = emailMsg;
            message.BodyEncoding = Encoding.UTF8;
            message.IsBodyHtml   = true;

            SendEmail(message);
        }