コード例 #1
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));
        }
コード例 #2
0
        protected override CommandResult <CommandOutput.None> RunCore(CommandInput.None input)
        {
            var nominationList = Context.NominationListContext.NominationList;

            foreach (var awardType in AwardType.ValidAwardTypes)
            {
                if (!nominationList.HasNominationsForAward(awardType))
                {
                    continue;
                }

                var fileName = awardType.GetVotingKeyFileName(Context.AwardsPeriod);

                var filePath = Context.WorkingDirectoryPath.GetFilePathForFileInDirectory(fileName, false, false);
                using (var excelFile = _excelFileFactory.GetVotingKeyExcelFile(awardType, nominationList))
                {
                    excelFile.Save(filePath);
                }
            }

            return(CommandOutput.None.Success);
        }