public static string[] GetFilePaths( ExcelExportInformation information) { var raw = information.DestinationFilePath; if (raw.Contains(@"{")) { var result = new HashSet <string>(); foreach (var fileGroup in information.FileGroups) { var raw1 = replacePlaceholders(raw, fileGroup); foreach (var destinationLanguageCode in information.DestinationLanguageCodes) { var raw2 = replacePlaceholders(raw1, destinationLanguageCode); result.Add(raw2); } } return(result.ToArray()); } else { return(new[] { raw }); } }
public static string[] GetDirectoryPaths( ExcelExportInformation information) { var raw = information.DestinationFilePath; var rawDir = raw.Substring(0, raw.LastIndexOf(@"\", StringComparison.Ordinal)); if (rawDir.Contains(@"{")) { var result = new HashSet <string>(); foreach (var fileGroup in information.FileGroups) { var raw1 = replacePlaceholders(rawDir, fileGroup); foreach (var destinationLanguageCode in information.DestinationLanguageCodes) { var raw2 = replacePlaceholders(raw1, destinationLanguageCode); result.Add(raw2); } } return(result.ToArray()); } else { return(new[] { rawDir }); } }
public void Prepare( ExcelExportInformation information) { var preparedInformations = new PreparedInformationCollection(information); // -- var oneExcelFilePerGroup = information.ExportAllGroupsMode == ExcelExportInformation.ExportFileGroupMode.OneExcelFilePerGroup; var oneExcelFilePerLanguage = information.ExportEachLanguageIntoSeparateExcelFile; if (oneExcelFilePerGroup || oneExcelFilePerLanguage) { // Multiple files. if (oneExcelFilePerGroup && oneExcelFilePerLanguage) { // ReSharper disable LoopCanBeConvertedToQuery foreach (var fileGroup in information.FileGroups) // ReSharper restore LoopCanBeConvertedToQuery { // ReSharper disable LoopCanBeConvertedToQuery foreach (var destinationLanguageCode in information.DestinationLanguageCodes) // ReSharper restore LoopCanBeConvertedToQuery { preparedInformations.Add( new PreparedInformation { DestinationFilePath = replacePlaceholders( replacePlaceholders(information.DestinationFilePath, destinationLanguageCode), fileGroup), DestinationLanguageCodes = new[] { destinationLanguageCode }, EliminateDuplicateRows = information.EliminateDuplicateRows, ExportAllGroups = information.ExportAllGroupsMode == ExcelExportInformation.ExportFileGroupMode.AllGroupsIntoOneWorksheet, ExportNameColumn = information.ExportNameColumn, ExportCommentColumn = information.ExportCommentColumn, ExportReferenceLanguageColumn = information.ExportReferenceLanguageColumn, ExportFileGroupColumn = information.ExportFileGroupColumn, UseCrypticExcelExportSheetNames = information.UseCrypticExcelExportSheetNames, FileGroups = new[] { fileGroup }, OnlyExportRowsWithNoTranslation = information.OnlyExportRowsWithNoTranslation, ExportCompletelyEmptyRows = information.ExportCompletelyEmptyRows, OnlyExportRowsWithChangedTexts = information.OnlyExportRowsWithChangedTexts, Project = information.Project, ReferenceLanguageCode = information.ReferenceLanguageCode }); } } } else if (oneExcelFilePerGroup) { // ReSharper disable LoopCanBeConvertedToQuery foreach (var fileGroup in information.FileGroups) // ReSharper restore LoopCanBeConvertedToQuery { preparedInformations.Add( new PreparedInformation { DestinationFilePath = replacePlaceholders( replacePlaceholders(information.DestinationFilePath, information.DestinationLanguageCodes[0]), fileGroup), DestinationLanguageCodes = information.DestinationLanguageCodes, EliminateDuplicateRows = information.EliminateDuplicateRows, ExportAllGroups = information.ExportAllGroupsMode == ExcelExportInformation.ExportFileGroupMode.AllGroupsIntoOneWorksheet, ExportFileGroupColumn = information.ExportFileGroupColumn, ExportNameColumn = information.ExportNameColumn, ExportCommentColumn = information.ExportCommentColumn, ExportReferenceLanguageColumn = information.ExportReferenceLanguageColumn, UseCrypticExcelExportSheetNames = information.UseCrypticExcelExportSheetNames, FileGroups = new[] { fileGroup }, OnlyExportRowsWithNoTranslation = information.OnlyExportRowsWithNoTranslation, ExportCompletelyEmptyRows = information.ExportCompletelyEmptyRows, OnlyExportRowsWithChangedTexts = information.OnlyExportRowsWithChangedTexts, Project = information.Project, ReferenceLanguageCode = information.ReferenceLanguageCode }); } } else // oneExcelFilePerLanguage. { // ReSharper disable LoopCanBeConvertedToQuery foreach (var destinationLanguageCode in information.DestinationLanguageCodes) // ReSharper restore LoopCanBeConvertedToQuery { preparedInformations.Add( new PreparedInformation { DestinationFilePath = replacePlaceholders( replacePlaceholders(information.DestinationFilePath, destinationLanguageCode), information.FileGroups[0]), DestinationLanguageCodes = new[] { destinationLanguageCode }, EliminateDuplicateRows = information.EliminateDuplicateRows, ExportAllGroups = information.ExportAllGroupsMode == ExcelExportInformation.ExportFileGroupMode.AllGroupsIntoOneWorksheet, ExportFileGroupColumn = information.ExportFileGroupColumn, ExportNameColumn = information.ExportNameColumn, ExportCommentColumn = information.ExportCommentColumn, ExportReferenceLanguageColumn = information.ExportReferenceLanguageColumn, UseCrypticExcelExportSheetNames = information.UseCrypticExcelExportSheetNames, FileGroups = information.FileGroups, OnlyExportRowsWithNoTranslation = information.OnlyExportRowsWithNoTranslation, ExportCompletelyEmptyRows = information.ExportCompletelyEmptyRows, OnlyExportRowsWithChangedTexts = information.OnlyExportRowsWithChangedTexts, Project = information.Project, ReferenceLanguageCode = information.ReferenceLanguageCode }); } } ensureFileNamesUnique(preparedInformations); } else { // Only one. preparedInformations.Add( new PreparedInformation { DestinationFilePath = replacePlaceholders( replacePlaceholders(information.DestinationFilePath, information.DestinationLanguageCodes[0]), information.FileGroups[0]), DestinationLanguageCodes = information.DestinationLanguageCodes, EliminateDuplicateRows = information.EliminateDuplicateRows, ExportAllGroups = information.ExportAllGroupsMode == ExcelExportInformation.ExportFileGroupMode.AllGroupsIntoOneWorksheet, ExportFileGroupColumn = information.ExportFileGroupColumn, ExportNameColumn = information.ExportNameColumn, ExportCommentColumn = information.ExportCommentColumn, ExportReferenceLanguageColumn = information.ExportReferenceLanguageColumn, UseCrypticExcelExportSheetNames = information.UseCrypticExcelExportSheetNames, FileGroups = information.FileGroups, OnlyExportRowsWithNoTranslation = information.OnlyExportRowsWithNoTranslation, ExportCompletelyEmptyRows = information.ExportCompletelyEmptyRows, OnlyExportRowsWithChangedTexts = information.OnlyExportRowsWithChangedTexts, Project = information.Project, ReferenceLanguageCode = information.ReferenceLanguageCode }); } // -- _preparedInformations = preparedInformations; }
public PreparedInformationCollection( ExcelExportInformation originalInformation) { OriginalInformation = originalInformation; }