private static void AppendSuperStarNominees(HtmlNode content, NominationList nominationList, bool hasSuperStar)
 {
     if (hasSuperStar)
     {
         AppendNominees(content, nominationList, AwardType.SuperStar);
     }
 }
Exemplo n.º 2
0
        private bool FixNomineeEmailAddresses(IGlobalAddressList globalAddressList, NominationList nominationList,
                                              out Exception exception)
        {
            var unrecognizedEmailAddresses = GetUnrecognizedEmailAddresses(globalAddressList, nominationList.Nominees);

            return(FixNomineeEmailAddresses(unrecognizedEmailAddresses, out exception));
        }
Exemplo n.º 3
0
 public SuperStarNominationNotificationsMailMerge(IExcelFileFactory excelFileFactory,
                                                  NominationList nominationList)
     : base(@"StarFisher.Office.Word.MailMergeTemplates.SuperStarNominationNotificationsMailMergeTemplate.docx")
 {
     _excelFileFactory = excelFileFactory ?? throw new ArgumentNullException(nameof(excelFileFactory));
     _nominationList   = nominationList ?? throw new ArgumentNullException(nameof(nominationList));
 }
        private static void BuildWorksheet(ComObjectManager com, NominationList nominationList, Worksheet workSheet)
        {
            var cells = com.Get(() => workSheet.Cells);

            var attendees = nominationList
                            .AwardsLuncheonInvitees
                            .OrderBy(i => i.OfficeLocation.ToString())
                            .ThenBy(i => i.Name.FullName)
                            .ToList();

            cells.NumberFormat = "@"; // Format all cells as text.

            SetCellValue(cells, 1, 1, @"Nominee Name");
            SetCellValue(cells, 1, 2, @"Nominee Office");
            SetCellValue(cells, 1, 3, @"Nominee Email Address");

            for (var i = 0; i < attendees.Count; ++i)
            {
                var rowNumber = i + 2;
                var attendee  = attendees[i];

                SetCellValue(cells, rowNumber, 1, attendee.Name.FullName);
                SetCellValue(cells, rowNumber, 2, attendee.OfficeLocation.ToString());
                SetCellValue(cells, rowNumber, 3, attendee.EmailAddress.ToString());
            }
        }
Exemplo n.º 5
0
        private void SaveRisingStarWinnerMemoMailMerge(WorkingDirectoryPath workingDirectoryPath,
                                                       NominationList nominationList)
        {
            var mailMerge = _mailMergeFactory.GetRisingStarWinnersMemoMailMerge(nominationList);

            SaveAwardWinnerMemoMailMerge(workingDirectoryPath, AwardType.RisingStar, nominationList, mailMerge);
        }
Exemplo n.º 6
0
        private static void BuildWorksheet(ComObjectManager com, NominationList nominationList, Worksheet worksheet)
        {
            var cells = com.Get(() => worksheet.Cells);

            cells.NumberFormat = "@"; // Format all cells as text.

            SetCellValue(cells, 1, 1, @"Quarter");
            SetCellValue(cells, 1, 2, @"Name");
            SetCellValue(cells, 1, 3, @"Office");
            SetCellValue(cells, 1, 4, @"Values");
            SetCellValue(cells, 1, 5, @"WriteUps");

            var rowNumber = 2;

            foreach (var awardWinner in nominationList.StarValuesAwardWinners)
            {
                var companyValues = string.Join("; ",
                                                nominationList.GetCompanyValuesForAwardWinner(awardWinner).Select(cv => cv.ToString()));
                var writeUps = CompileWriteUps(nominationList.GetNominationWriteUpsForAwardWinner(awardWinner));

                SetCellValue(cells, rowNumber, 1, nominationList.AwardsPeriod.Quarter.Abbreviation);
                SetCellValue(cells, rowNumber, 2, awardWinner.Name.FullName);
                SetCellValue(cells, rowNumber, 3, awardWinner.OfficeLocation.Name);
                SetCellValue(cells, rowNumber, 4, companyValues);
                SetCellValue(cells, rowNumber, 5, writeUps);

                ++rowNumber;
            }
        }
 public HumanResourcesNomineeValidationEmail(IEmailConfiguration emailConfiguration,
                                             NominationList nominationList)
     : base((com, mailItem) => BuildEmail(
                mailItem,
                emailConfiguration ?? throw new ArgumentNullException(nameof(emailConfiguration)),
                nominationList ?? throw new ArgumentNullException(nameof(nominationList))))
 {
 }
Exemplo n.º 8
0
 public CertificatesEmail(IEmailConfiguration emailConfiguration, IMailMergeFactory mailMergeFactory,
                          NominationList nominationList)
     : base((com, mailItem) => BuildEmail(
                com,
                mailItem,
                emailConfiguration ?? throw new ArgumentNullException(nameof(emailConfiguration)),
                mailMergeFactory ?? throw new ArgumentNullException(nameof(mailMergeFactory)),
                nominationList ?? throw new ArgumentNullException(nameof(nominationList))))
 {
 }
Exemplo n.º 9
0
 public VotingKeyEmail(IEmailConfiguration emailConfiguration, IExcelFileFactory excelFileFactory,
                       NominationList nominationList)
     : base((com, mailItem) => BuildEmail(
                com,
                mailItem,
                emailConfiguration ?? throw new ArgumentNullException(nameof(emailConfiguration)),
                excelFileFactory ?? throw new ArgumentNullException(nameof(excelFileFactory)),
                nominationList ?? throw new ArgumentNullException(nameof(nominationList))))
 {
 }
Exemplo n.º 10
0
        internal NominationListDto(NominationList nominationList)
        {
            if (nominationList == null)
            {
                throw new ArgumentNullException(nameof(nominationList));
            }

            LastChangeSummary = nominationList.LastChangeSummary;
            AwardsPeriod      = nominationList.AwardsPeriod.Value;
            Nominations       = nominationList.Nominations.Select(n => new NominationDto(n)).ToList();
            AwardWinners      = nominationList.AwardWinners.Select(w => new AwardWinnerDto(w)).ToList();
        }
Exemplo n.º 11
0
        private static void SaveAwardWinnerMemoMailMerge(WorkingDirectoryPath workingDirectoryPath, AwardType awardType,
                                                         NominationList nominationList, IMailMerge mailMerge)
        {
            if (!nominationList.HasWinnersForAward(awardType))
            {
                return;
            }

            var fileName = awardType.GetWinnersForMemoFileName(nominationList.AwardsPeriod);
            var filePath = workingDirectoryPath.GetFilePathForFileInDirectory(fileName, false, false);

            mailMerge.Execute(filePath);
        }
        private static void AppendNomineeCriteria(HtmlNode content, NominationList nominationList, bool hasStarValues,
                                                  bool hasRisingStar, bool hasSuperStar)
        {
            var awardCategory = nominationList.AwardsPeriod.AwardCategory;

            if (awardCategory == AwardCategory.QuarterlyAwards)
            {
                AppendQuarterlyNomineeCriteria(content, hasStarValues, hasRisingStar);
            }
            else if (awardCategory == AwardCategory.SuperStarAwards)
            {
                AppendSuperStarNomineeCriteria(content, hasSuperStar);
            }
        }
        private static void AppendQuarterlyAwardNominees(HtmlNode content, NominationList nominationList,
                                                         bool hasStarValues,
                                                         bool hasRisingStar)
        {
            if (hasStarValues)
            {
                AppendNominees(content, nominationList, AwardType.StarValues);
            }

            if (hasRisingStar)
            {
                AppendNominees(content, nominationList, AwardType.RisingStar);
            }
        }
Exemplo n.º 14
0
        private static void AddCertificatesAttachments(ComObjectManager com, MailItem mailItem,
                                                       IMailMergeFactory mailMergeFactory,
                                                       NominationList nominationList, HtmlNode content)
        {
            var awardCategory = nominationList.AwardsPeriod.AwardCategory;

            if (awardCategory == AwardCategory.QuarterlyAwards)
            {
                AddQuarterlyCertificatesAttachments(com, mailItem, mailMergeFactory, nominationList, content);
            }
            else if (awardCategory == AwardCategory.SuperStarAwards)
            {
                AddSuperStarCertificatesAttachments(com, mailItem, mailMergeFactory, nominationList);
            }
        }
Exemplo n.º 15
0
 public VotingSurveyReviewEmail(IEmailConfiguration emailConfiguration, IMailMergeFactory mailMergeFactory,
                                NominationList nominationList, string votingSurveyWebLink)
     : base((com, mailItem) => BuildEmail(
                com,
                mailItem,
                emailConfiguration ?? throw new ArgumentNullException(nameof(emailConfiguration)),
                mailMergeFactory ?? throw new ArgumentNullException(nameof(mailMergeFactory)),
                nominationList ?? throw new ArgumentNullException(nameof(nominationList)),
                votingSurveyWebLink))
 {
     if (string.IsNullOrWhiteSpace(votingSurveyWebLink))
     {
         throw new ArgumentException(votingSurveyWebLink);
     }
 }
Exemplo n.º 16
0
        public void SaveArtifacts(WorkingDirectoryPath workingDirectoryPath, NominationList nominationList)
        {
            if (workingDirectoryPath == null)
            {
                throw new ArgumentNullException(nameof(workingDirectoryPath));
            }
            if (nominationList == null)
            {
                throw new ArgumentNullException(nameof(nominationList));
            }

            SaveMemoSkeleton(workingDirectoryPath);
            SaveStarValuesWinnersMemoMailMerge(workingDirectoryPath, nominationList);
            SaveNomineeListExcelFile(workingDirectoryPath, nominationList, AwardType.StarValues);
            SaveRisingStarWinnerMemoMailMerge(workingDirectoryPath, nominationList);
            SaveNomineeListExcelFile(workingDirectoryPath, nominationList, AwardType.RisingStar);
        }
Exemplo n.º 17
0
        private static void BuildEmail(ComObjectManager com, MailItem mailItem, IEmailConfiguration emailConfiguration,
                                       IMailMergeFactory mailMergeFactory, NominationList nominationList)
        {
            var certificatePrinter = emailConfiguration.CertificatePrinterPerson;
            var awardsName         = nominationList.AwardsPeriod.AwardsName;

            mailItem.To      = certificatePrinter.EmailAddress.Value;
            mailItem.CC      = string.Join(";", emailConfiguration.EiaCoChair1.EmailAddress, emailConfiguration.EiaCoChair2.EmailAddress);
            mailItem.Subject = $@"EIA: {awardsName} winner certificates";

            var content = CreateContentNode();

            AppendIntroduction(content, certificatePrinter, awardsName);
            AddCertificatesAttachments(com, mailItem, mailMergeFactory, nominationList, content);
            AppendThanks(content);

            WriteMailItemBody(mailItem, content);
        }
Exemplo n.º 18
0
        private static void BuildEmail(ComObjectManager com, MailItem mailItem, IEmailConfiguration emailConfiguration,
                                       IExcelFileFactory excelFileFactory, NominationList nominationList)
        {
            var luncheonPlanners = emailConfiguration.LuncheonPlannerPeople;
            var awardsName       = nominationList.AwardsPeriod.AwardsName;

            mailItem.To      = string.Join(";", luncheonPlanners.Select(p => p.EmailAddress));
            mailItem.CC      = string.Join(";", emailConfiguration.EiaCoChair1.EmailAddress, emailConfiguration.EiaCoChair2.EmailAddress);
            mailItem.Subject = $@"EIA: {awardsName} luncheon invitee list";

            var content = CreateContentNode();

            AppendRequest(content, luncheonPlanners, awardsName);
            AppendThanks(content);
            WriteMailItemBody(mailItem, content);

            AddAwardLuncheonInviteeListAttachment(com, mailItem, excelFileFactory, nominationList);
        }
Exemplo n.º 19
0
        public IExcelFile GetNomineeListExcelFile(AwardType awardType, NominationList nominationList)
        {
            if (awardType == null)
            {
                throw new ArgumentNullException(nameof(awardType));
            }

            if (awardType == AwardType.StarValues)
            {
                return(new StarValuesNomineeListExcelFile(nominationList));
            }
            if (awardType == AwardType.RisingStar)
            {
                return(new RisingStarNomineeListExcelFile(nominationList));
            }

            throw new NotSupportedException(awardType.Value);
        }
Exemplo n.º 20
0
        private static void AddVotingGuideAttachment(ComObjectManager com, MailItem mailItem,
                                                     IMailMergeFactory mailMergeFactory,
                                                     NominationList nominationList, AwardType awardType)
        {
            var attachments = com.Get(() => mailItem.Attachments);
            var fileName    = awardType.GetVotingGuideFileName(nominationList.AwardsPeriod);
            var filePath    = FilePath.Create(Path.Combine(Path.GetTempPath(), fileName), false);

            if (File.Exists(filePath.Value))
            {
                File.Delete(filePath.Value);
            }

            var mailMerge = mailMergeFactory.GetVotingGuideMailMerge(awardType, nominationList);

            mailMerge.Execute(filePath);

            com.Get(() => attachments.Add(filePath.Value));
        }
Exemplo n.º 21
0
        public VotingCallToActionEmail(IMailMergeFactory mailMergeFactory, NominationList nominationList,
                                       string votingSurveyWebLink, DateTime votingDeadline)
            : base((com, mailItem) => BuildEmail(
                       com,
                       mailItem,
                       mailMergeFactory ?? throw new ArgumentNullException(nameof(mailMergeFactory)),
                       nominationList ?? throw new ArgumentNullException(nameof(nominationList)),
                       votingSurveyWebLink,
                       votingDeadline))
        {
            if (string.IsNullOrWhiteSpace(votingSurveyWebLink))
            {
                throw new ArgumentException(nameof(votingSurveyWebLink));
            }

            if (votingDeadline == default(DateTime))
            {
                throw new ArgumentException(nameof(votingDeadline));
            }
        }
        private static void BuildWorksheet(ComObjectManager com, NominationList nominationList, Worksheet worksheet)
        {
            var cells = com.Get(() => worksheet.Cells);

            var awardWinners = nominationList.RisingStarAwardWinners;

            cells.NumberFormat = "@"; // Format all cells as text.

            SetCellValue(cells, 1, 1, @"Nominee Name");
            SetCellValue(cells, 1, 2, @"Nominee Office");

            for (var i = 0; i < awardWinners.Count; ++i)
            {
                var rowNumber   = i + 2;
                var awardWinner = awardWinners[i];

                SetCellValue(cells, rowNumber, 1, awardWinner.Name.FullName);
                SetCellValue(cells, rowNumber, 2, awardWinner.OfficeLocation.Name);
            }
        }
Exemplo n.º 23
0
        private static void AddVotingKeyAttachment(ComObjectManager com, MailItem mailItem,
                                                   IExcelFileFactory excelFileFactory,
                                                   NominationList nominationList, AwardType awardType)
        {
            var attachments = com.Get(() => mailItem.Attachments);
            var fileName    = awardType.GetVotingKeyFileName(nominationList.AwardsPeriod);
            var filePath    = FilePath.Create(Path.Combine(Path.GetTempPath(), fileName), false);

            if (File.Exists(filePath.Value))
            {
                File.Delete(filePath.Value);
            }

            using (var excelFile = excelFileFactory.GetVotingKeyExcelFile(awardType, nominationList))
            {
                excelFile.Save(filePath);
            }

            com.Get(() => attachments.Add(filePath.Value));
        }
Exemplo n.º 24
0
        private bool ReviewNomination(Nomination nomination, NominationList nominationList)
        {
            if (!GetNominationWriteUpAction(nomination, out WriteUpActionParameter.Action action))
            {
                return(false);
            }

            if (action == WriteUpActionParameter.Action.Continue)
            {
                return(true);
            }

            var changedWriteUp = TryGetNewNominationWriteUp(nomination, out NominationWriteUp newWriteUp);

            if (changedWriteUp)
            {
                nominationList.UpdateNominationWriteUp(nomination.Id, newWriteUp);
            }

            return(true);
        }
        private static void BuildEmail(MailItem mailItem, IEmailConfiguration emailConfiguration,
                                       NominationList nominationList)
        {
            mailItem.To = string.Join(";", emailConfiguration.HrPeople.Select(p => p.EmailAddress));
            mailItem.CC = string.Join(";", emailConfiguration.EiaCoChair1.EmailAddress, emailConfiguration.EiaCoChair2.EmailAddress);

            var hasStarValues = nominationList.HasNominationsForAward(AwardType.StarValues);
            var hasRisingStar = nominationList.HasNominationsForAward(AwardType.RisingStar);
            var hasSuperStar  = nominationList.HasNominationsForAward(AwardType.SuperStar);
            var awardsName    = nominationList.AwardsPeriod.AwardsName;

            mailItem.Subject = $@"Need: {awardsName} nominee eligibility check";

            var content = CreateContentNode();

            AppendIntroduction(content, emailConfiguration.HrPeople, awardsName);
            AppendNomineeCriteria(content, nominationList, hasStarValues, hasRisingStar, hasSuperStar);
            AppendThanks(content);
            AppendNominees(content, nominationList, hasStarValues, hasRisingStar, hasSuperStar);
            WriteMailItemBody(mailItem, content);
        }
Exemplo n.º 26
0
        private static void AddAwardLuncheonInviteeListAttachment(ComObjectManager com, MailItem mailItem,
                                                                  IExcelFileFactory excelFileFactory,
                                                                  NominationList nominationList)
        {
            var attachments = com.Get(() => mailItem.Attachments);
            var fileName    =
                $@"{nominationList.AwardsPeriod.FileNamePrefix}_StarAwards_LuncheonInvitees.xlsx";
            var filePath = FilePath.Create(Path.Combine(Path.GetTempPath(), fileName), false);

            if (File.Exists(filePath.Value))
            {
                File.Delete(filePath.Value);
            }

            using (var excelFile = excelFileFactory.GetAwardsLuncheonInviteeListExcelFile(nominationList))
            {
                excelFile.Save(filePath);
            }

            com.Get(() => attachments.Add(filePath.Value));
        }
Exemplo n.º 27
0
        public IExcelFile GetCertificatesSourceExcelFile(AwardType awardType, NominationList nominationList)
        {
            if (awardType == null)
            {
                throw new ArgumentNullException(nameof(awardType));
            }

            if (awardType == AwardType.StarValues)
            {
                return(new StarValuesCertificatesSourceExcelFile(nominationList));
            }
            if (awardType == AwardType.RisingStar)
            {
                return(new RisingStarCertificatesSourceExcelFile(nominationList));
            }
            if (awardType == AwardType.SuperStar)
            {
                return(new SuperStarCertificatesSourceExcelFile(nominationList));
            }

            throw new NotSupportedException(awardType.Value);
        }
Exemplo n.º 28
0
        public IMailMerge GetNominationNotificationsMailMerge(AwardType awardType, NominationList nominationList)
        {
            if (awardType == null)
            {
                throw new ArgumentNullException(nameof(awardType));
            }

            if (awardType == AwardType.StarValues)
            {
                return(new StarValuesNominationNotificationsMailMerge(_excelFileFactory, nominationList));
            }
            if (awardType == AwardType.RisingStar)
            {
                return(new RisingStarNominationNotificationsMailMerge(_excelFileFactory, nominationList));
            }
            if (awardType == AwardType.SuperStar)
            {
                return(new SuperStarNominationNotificationsMailMerge(_excelFileFactory, nominationList));
            }

            throw new NotSupportedException(awardType.Value);
        }
Exemplo n.º 29
0
        private static void BuildEmail(ComObjectManager com, MailItem mailItem, IEmailConfiguration emailConfiguration,
                                       IMailMergeFactory mailMergeFactory, NominationList nominationList, string votingSurveyWebLink)
        {
            var awardsName    = nominationList.AwardsPeriod.AwardsName;
            var hasStarValues = nominationList.HasNominationsForAward(AwardType.StarValues);
            var hasRisingStar = nominationList.HasNominationsForAward(AwardType.RisingStar);
            var hasSuperStar  = nominationList.HasNominationsForAward(AwardType.SuperStar);

            mailItem.To      = string.Join(";", emailConfiguration.EiaCoChair1.EmailAddress, emailConfiguration.EiaCoChair2.EmailAddress);
            mailItem.Subject = $@"EIA: {awardsName} voting survey review request";

            var content = CreateContentNode();

            AppendRequest(content, emailConfiguration.EiaCoChair1, emailConfiguration.EiaCoChair2, awardsName,
                          hasStarValues, hasRisingStar);

            AddVotingGuideAttachments(com, mailItem, content, mailMergeFactory, nominationList, hasStarValues,
                                      hasRisingStar, hasSuperStar);

            AppendVotingSurveyWebLink(votingSurveyWebLink, content);
            AppendThanks(content);
            WriteMailItemBody(mailItem, content);
        }
Exemplo n.º 30
0
        private static void BuildEmail(ComObjectManager com, MailItem mailItem, IEmailConfiguration emailConfiguration,
                                       IExcelFileFactory excelFileFactory, NominationList nominationList)
        {
            var awardsName = nominationList.AwardsPeriod.AwardsName;

            mailItem.To      = string.Join(";", emailConfiguration.EiaCoChair1.EmailAddress, emailConfiguration.EiaCoChair2.EmailAddress);
            mailItem.Subject = $@"EIA: {awardsName} voting key";

            var hasStarValues = nominationList.HasNominationsForAward(AwardType.StarValues);
            var hasRisingStar = nominationList.HasNominationsForAward(AwardType.RisingStar);
            var hasSuperStar  = nominationList.HasNominationsForAward(AwardType.SuperStar);

            var content = HtmlNode.CreateNode(@"<div class=WordSection1>");

            AppendRequest(hasRisingStar, hasStarValues, content, emailConfiguration.EiaCoChair1,
                          emailConfiguration.EiaCoChair2, awardsName);

            AddVotingKeyAttachments(com, mailItem, content, excelFileFactory, nominationList, hasStarValues,
                                    hasRisingStar, hasSuperStar);

            AppendThanks(content);
            WriteMailItemBody(mailItem, content);
        }