Ejemplo n.º 1
0
        public async Task <int> UpdateToCurrent(ProjectViewModel pvm)
        {
            Model.ProjectID    = pvm.ProjectID.Value;
            Model.ProjectName  = pvm.ProjectName.Value;
            Model.StartDate    = pvm.StartDate.Value;
            Model.EndDate      = pvm.EndDate.Value;
            Model.AlertDate    = pvm.AlertDate.Value;
            Model.Status       = pvm.Status.Value;
            Model.Division     = pvm.Division.Value;
            Model.Priority     = pvm.Priority.Value;
            Model.Comments     = pvm.Comments.Value;
            Model.Value        = pvm.Value.Value;
            Model.Description  = pvm.Description.Value;
            Model.Url          = pvm.Url.Value;
            Model.Color        = pvm.Color.Value;
            Model.Attachment   = pvm.Attachment.Value;
            Model.CurrentValue = pvm.CurrentValue.Value;
            Model.Category     = pvm.Category.Value;

            Model.Assignees = string.Join(" ", Assignees.Select(x => x.ID));
            Model.Assigners = string.Join(" ", Assigners.Select(x => x.ID));
            int id = await Model.InsertOrUpdate();

            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Model)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(Col1)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(AssigneesView)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(AssignersView)));
            PropertyChanged.Invoke(this, new PropertyChangedEventArgs(nameof(DaysOpen)));
            return(id);
        }
Ejemplo n.º 2
0
        public void NotifyByEmail()
        {
            //get list of recipients to see if we actually have someone to email
            List <string> recips = new List <string>();

            if (Assignees.Any(x => x.Name == "DATA"))
            {
                recips = new List <string> {
                    "Nils.Bergmann @lenderlive.com",
                    "Dallin.Beutler @lenderlive.com",
                    "Cameron.Thibeaux @lenderlive.com",
                    "Robert.Cerami @lenderlive.com",
                    "Mike.Auyeung @lenderlive.com",
                    "Bradley.Gill @lenderlive.com",
                    "nils.bergmann @lenderlive.com",
                    "Andrew.Matel @lenderlive.com",
                    "wesley.rollings @lenderlive.com",
                    "luke.stanley @lenderlive.com",
                    "Wesley.Hamilton @lenderlive.com",
                    "britney.clark @lenderlive.com",
                    "*****@*****.**"
                };
            }
            recips.AddRange(Assignees.Select(x => x.Value).Where(x => !string.IsNullOrEmpty(x)));
            if (recips.Count <= 0)
            {
                return;
            }
            string build   = VersionSelector.SelectedVersionEnum.Name;
            string Subject = "EMS- " + build + " Notification: " + Model.ProjectName;

            // simplest html table showing relevant info
            string HTMLBody = $@"<table>
                           <tr><td><b>Project:     </b></td><td>  { Model.ProjectName }<td/></tr>
                           <tr><td><b>Description: </b></td><td>  { Model.Description}<td/></tr>"
                              + (Model.EndDate.HasValue ? ($@"<tr><td><b>End Date:    </b></td><td>  { Model.EndDate.Value.ToShortDateString()} <td/></tr>)") : "") +
                              $@"<tr><td><b>Status:      </b></td><td>  { Model.Status}<td/></tr>
                           <tr><td><b>Division:    </b></td><td>  { Model.Division}<td/></tr>
                           <tr><td><b>Division:    </b></td><td>  { Model.Category}<td/></tr>
                           <tr><td><b>Assigned To: </b></td><td>  { string.Join(", ", recips)}<td/></tr>
                           <tr><td><b>Comments:    </b></td><td>  { EMS2.Utility.RtfToHtmlConverter.ConvertRtfToHtml(Model.Comments)}<td/></tr>
                            </table> ";

            //SMTP is a server service thing for sending mail. Quite relaxed
            SMTP smtp = new SMTP();


            List <string> emails    = recips;
            List <string> assigners = Assigners.Select(x => x.Value).ToList();


            smtp.Recipients   = emails;
            smtp.CCRecipients = assigners;
            smtp.bodyMessage  = HTMLBody;
            smtp.subject      = Subject;
            smtp.from         = "EMS " + build + " <*****@*****.**>";


            //Don't send a prompt to robert, but yes to everyone else. talk about customization!
            //if (!EMSSession.IsAdmin)
            //{
            //   var result = MessageBox.Show("Do you want to send an email to " + string.Join(", ", emails) + "\n" + "with " + string.Join(", ", assigners) + " CC'd?", "Confirm Email", MessageBoxButton.YesNo);
            //   if (result != MessageBoxResult.Yes) return;
            //}

            // send the email on a separate thread so that we don't have to wait for the SMTP server.
            new Thread(() =>
            {
                try
                {
                    Thread.CurrentThread.IsBackground = true;
                    /* run your code here */

                    smtp.SendEmail();
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message).ToString();
                }
            }).Start();
            //mail.Send();
        }//butNotify_Click