Esempio n. 1
0
 public ReviewerData(ReviewObject ro)
 {
     ReviewerEmployeeId = ro.ReviewerEmployeeId;
     ReviewerName       = ro.ReviewerName;
     ReviewerType       = ro.ReviewerType;
     ReviewDate         = ro.ReviewDate;
     Status             = ro.Status;
 }
Esempio n. 2
0
        private static string ConstructBody(MainObject main, ReviewObject review, string comment, EmailTemplateObject template)
        {
            if (template != null)
            {
                return(template.Body
                       .Replace("{STI_Number}", main.StiNumber ?? string.Empty)
                       .Replace("{Title}", main.Title ?? string.Empty)
                       .Replace("{Authors}", string.Join(", ", main.Authors.Select(n => n.Name)) ?? string.Empty)
                       //.Replace("{DueDate}", $"{main.DueDate:d}")
                       .Replace("{ReviewStatus}", main.ReviewStatus ?? string.Empty)
                       .Replace("{ReviewProgress}", $"{main.ReviewProgress:P}" ?? string.Empty)
                       .Replace("{ReviewerName}", review?.ReviewerName ?? string.Empty)
                       .Replace("{Comment}", comment ?? string.Empty)
                       .Replace("{ReviewType}", review?.ReviewerTypeDisplayName ?? string.Empty)
                       .Replace("{Url}", $"<a href=\"{Config.SiteUrl.TrailingSlash()}Artifact/Index/{main.MainId}\">LRS Artifact</a>")
                       .Replace("{OUO-FOIA}", main.OuoEmailText ?? string.Empty)
                       .Replace("{FundingOrg}", string.Join(", ", main?.Funding?.Where(m => !string.IsNullOrWhiteSpace(m.FundingOrgName)).Select(n => n.FundingOrgName)) ?? string.Empty));
            }

            return(string.Empty);
        }
Esempio n. 3
0
        public static bool SendEmail(MainObject main, ReviewObject review, EmailTypeEnum emailType, string comment, ref string errorMsg)
        {
            try
            {
                var template = EmailTemplateObject.GetEmailTemplate(emailType);
                if (template != null)
                {
                    string subject = template.Header.Replace("{STI_Number}", main.StiNumber ?? string.Empty).Replace("{Title}", main.Title ?? string.Empty);
                    string body    = ConstructBody(main, review, comment, template);
                    switch (emailType)
                    {
                    case EmailTypeEnum.ReleaseOfficerComplete:
                        return(SendReleaseOfficerEmail(subject, body, ref errorMsg));

                    case EmailTypeEnum.ClassReviewer:
                    case EmailTypeEnum.ExportReviewer:
                    case EmailTypeEnum.ManagerReviewer:
                    case EmailTypeEnum.PeerReviewer:
                    case EmailTypeEnum.TechReviewer:
                    case EmailTypeEnum.ReviewReminder:
                        return(review != null?SendReviewerEmail(review, subject, body, ref errorMsg) : SendReviewersEmail(main, subject, body, emailType, ref errorMsg));

                    default:
                        return(SendOwnerEmail(main, subject, body, template.IncludeAuthors, template.IncludeContacts, ref errorMsg));
                    }
                }

                errorMsg = $"Unable to find the Template for Email Type: {emailType}";
            }
            catch (Exception ex)
            {
                errorMsg = $"Exception Caught while attempting to send an email: {ex.Message}";
            }

            return(false);
        }
Esempio n. 4
0
 public void Save()
 {
     repo.SaveReviewComment(this);
     Email.SendEmail(MainObject.GetMain(MainId), ReviewObject.GetReview(ReviewId), EmailTypeEnum.ReviewerCommented, Comment);
     MainObject.UpdateActivityDateToNow(MainId);
 }
Esempio n. 5
0
        public static bool SendEmail(MainObject main, ReviewObject review, EmailTypeEnum emailType, string comment)
        {
            string errorMsg = string.Empty;

            return(SendEmail(main, review, emailType, comment, ref errorMsg));
        }
Esempio n. 6
0
        private static bool SendReviewerEmail(ReviewObject review, string subject, string body, ref string errorMsg)
        {
            bool          allMailSent    = false;
            List <string> recipientNames = new List <string>();

            try
            {
                Email  email   = new Email();
                string addInfo = string.Empty;
                email.SendTo  = new List <string>();
                email.Subject = subject;
                if (review.SystemReviewer)
                {
                    if ((MemoryCache.GetGenericReviewData(review.ReviewerTypeEnum)?.Count ?? 0) > 0)
                    {
                        MemoryCache.GetGenericReviewData(review.ReviewerTypeEnum).ForEach(n => email.SendTo.Add(n.GenericEmail));

                        switch (review.ReviewerTypeEnum)
                        {
                        case ReviewerTypeEnum.Classification:
                            recipientNames.Add("Classification Reviewer");
                            break;

                        case ReviewerTypeEnum.ExportControl:
                            recipientNames.Add("Export Compliance Reviewer");
                            break;

                        case ReviewerTypeEnum.TechDeployment:
                            recipientNames.Add("Technical Deployment Reviewer");
                            break;
                        }
                    }
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(review.Email))
                    {
                        email.SendTo.Add(review.Email);
                        recipientNames.Add(review.ReviewerName);
                    }
                }

                if (email.SendTo.Count == 0)
                {
                    return(false);
                }

                review.LastEmailDate = DateTime.Now;
                review.Save();

                email.Body = addInfo + body.Replace("{RecipientsName}", string.Join(" : ", recipientNames));
                AddContactInfo(ref email);
                email.Send();

                allMailSent = true;
            }
            catch (Exception ex)
            {
                errorMsg = $"Exeption Caught on sending Email: {ex.Message}";
            }
            return(allMailSent);
        }