Beispiel #1
0
            public async Task Export(ImportArguments arguments)
            {
                var session = configuration.StartSession(arguments.App);

                var assets = session.Assets;

                using (var fs = await FileSystems.CreateAsync(arguments.Path, session.WorkingDirectory))
                {
                    var folderTree  = new FolderTree(session);
                    var folderNames = new HashSet <string>();

                    var parentId = await folderTree.GetIdAsync(arguments.TargetFolder);

                    var downloadPipeline = new DownloadPipeline(session, log, fs)
                    {
                        FilePathProviderAsync = async asset =>
                        {
                            var assetFolder = await folderTree.GetPathAsync(asset.ParentId);

                            var assetPath = asset.FileName;

                            if (!string.IsNullOrWhiteSpace(assetFolder))
                            {
                                assetPath = Path.Combine(assetFolder, assetPath);
                            }

                            if (!folderNames.Add(assetPath))
                            {
                                assetPath = Path.Combine(assetFolder !, $"{asset.Id}_{asset.FileName}");
                            }

                            return(FilePath.Create(assetPath));
                        }
                    };

                    try
                    {
                        await assets.GetAllByQueryAsync(session.App, async asset =>
                        {
                            await downloadPipeline.DownloadAsync(asset);
                        },
                                                        new AssetQuery
                        {
                            ParentId = parentId
                        });
                    }
                    finally
                    {
                        await downloadPipeline.CompleteAsync();
                    }

                    log.WriteLine("> Export completed");
                }
            }
Beispiel #2
0
        private FilePath GetDataSourcePath()
        {
            var dataSourcePath = FilePath.Create(Path.GetTempFileName() + ".xlsx", false);

            using (var excelFile = GetDataSourceExcelFile())
            {
                excelFile.Save(dataSourcePath);
            }

            return(dataSourcePath);
        }
        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));
        }
Beispiel #4
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));
        }
        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));
        }
Beispiel #6
0
        private static void AddVotingGuideAttachmentAndInstructions(ComObjectManager com, MailItem mailItem,
                                                                    HtmlNode content, IMailMergeFactory mailMergeFactory, NominationList nominationList, AwardType awardType,
                                                                    string instructions)
        {
            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));

            AppendSection(content, $@"<b><i>{awardType.PrettyName} Nominees:</i></b> {fileName} -- {instructions}");
        }
Beispiel #7
0
 /// <summary>
 /// インスタンス取得
 /// </summary>
 /// <param name="mode">出力モード</param>
 /// <param name="inputCSRoot">入力:C#のルートパス</param>
 /// <param name="outputTSRoot">出力:TypeScriptのルートパス</param>
 /// <param name="inputFile">出力:TypeScriptのルートパス</param>
 /// <returns></returns>
 public static Config Create(OutputMode.Mode mode, string inputCSRoot, string outputTSRoot, string inputFile = null)
 {
     return(new Config(OutputMode.Create(mode), RootPath.Create(inputCSRoot), RootPath.Create(outputTSRoot), FilePath.Create(inputFile)));
 }