Esempio n. 1
0
        /// <summary>
        /// Writes the supplied export files to folders below the supplied folder.
        /// </summary>
        /// <param name="files"> The files to write. </param>
        /// <param name="folderName"> The folder to write to.</param>
        /// <param name="subFolderName">The sub-folder to write to.</param>
        private void WriteExportByteFiles(ExportFiles files, string folderName, string subFolderName)
        {
            // Create the template folder and write files to it
            var folder = Path.Combine(folderName, subFolderName);

            Directory.CreateDirectory(folder);
            foreach (var file in files.Templates)
            {
                File.WriteAllBytes(Path.Combine(folder, file.Key), file.Value);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Writes the supplied export files to folders below the supplied folder.
        /// </summary>
        /// <param name="files"> The files to write. </param>
        /// <param name="folderName"> The folder to write to. </param>
        private void WriteExportTextFiles(ExportFiles files, string folderName, string subFolderName)
        {
            // Create the metadata folder and write files to it
            var folder = Path.Combine(folderName, subFolderName);

            Directory.CreateDirectory(folder);
            foreach (var file in files.Metadata)
            {
                File.WriteAllText(Path.Combine(folder, file.Key), file.Value);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// The generate report method.  This will take the supplied information and use it to generate a report.
        /// </summary>
        /// <param name="exportDataParts">The data which will be rendered into report parts.</param>
        /// <param name="exportMetadataFiles"> The metadata files. </param>
        /// <param name="exportTemplateFiles"> The template files. </param>
        /// <param name="isExcelDocumentMetadataBased"> The is document metadata based. </param>
        /// <returns>A stream which contains the report</returns>
        public MemoryStreamResult GenerateReport(List <ExportDataPart> exportDataParts, ExportFiles exportMetadataFiles, ExportFiles exportTemplateFiles, bool isExcelDocumentMetadataBased = true)
        {
            this.logger.Log(LogType.Trace, this.GetAssemblyName(), "Enter {0}.GenerateReport", this.GetType().Name);

            Guard.IsNotNull(exportDataParts, "exportDataParts");
            Guard.IsNotNull(exportMetadataFiles, "exportMetadataFiles");
            Guard.IsNotNull(exportTemplateFiles, "exportTemplateFiles");

            this.dataParts                = exportDataParts.ConvertAll(dp => new GenericExportDataPart(dp) as IDataPart);
            this.metadataFiles            = exportMetadataFiles;
            this.templateFiles            = exportTemplateFiles;
            this.isExcelDocumentMetaBased = isExcelDocumentMetadataBased;
            this.tempSubFolder            = Path.GetRandomFileName();

            // Write supplied files to disk before we pack them.
            this.WriteExportFiles();

            // Pack the report metadata and template files
            this.metadataPackageName = this.PackSourceMetaDataFolder(this.metadataFolder);
            this.templatePackageName = this.PackSourceTemplatesFolder(this.templateFolder);

            MemoryStreamResult result;

            // Generate the report
            if (this.isExcelDocumentMetaBased)
            {
                // Version 1 way of generating a report
                result = this.GenerateDocumentMetadataBasedReport();
            }
            else
            {
                // Version 2 way of generating a report (as far as I know, not yet completed)
                result = this.GenerateExportMetadataBasedReport();
            }

            this.DeleteExportFiles();

            // Reset memory stream to 0 position for return.
            if (result != null && result.MemoryStream != null)
            {
                result.MemoryStream.Position = 0;
            }

            this.logger.Log(LogType.Trace, this.GetAssemblyName(), "Exit {0}.GenerateReport", this.GetType().Name);

            return(result);
        }