Пример #1
0
        private string copyTemplateToOutputDirectory(ReportSettings settings, string workingDir, string fileName)
        {
            //copy all files
            foreach (var templateFile in Directory.GetFiles(settings.TemplateFolder))
            {
                var destName = Path.GetFileName(templateFile);
                if (string.IsNullOrEmpty(destName))
                {
                    continue;
                }

                //We rename the actual template to the name of the pdf file.
                if (string.Equals(destName, settings.TemplateName))
                {
                    destName = fileName;
                }

                File.Copy(templateFile, Path.Combine(workingDir, destName), true);
            }

            //we return the path of the template file in the working folder
            return(Path.Combine(workingDir, fileName));
        }
Пример #2
0
 public Task ReportToPDF(string pdfReportFullPath, ReportSettings settings, params object[] objectsToReport)
 {
     return(ReportToPDF(pdfReportFullPath, settings, new ReadOnlyCollection <object>(objectsToReport)));
 }
Пример #3
0
        /// <summary>
        ///    This methods brings all information together to compile the generated TEX code with the predefined template to given
        ///    pdf file path.
        /// </summary>
        /// <param name="texContent">The generated TEX Content to be written</param>
        /// <param name="attachements">List of attachements that will be added to the report</param>
        /// <param name="settings">settings used to configure the report</param>
        /// <param name="buildTracker">The current build tracker used to compile the report</param>
        public async Task CompileReport(StringBuilder texContent, IEnumerable <Attachement> attachements, ReportSettings settings, BuildTracker buildTracker)
        {
            checkThatOutputFileIsWritable(buildTracker);

            //copy content of template folder into working directory
            var texFilePath = copyTemplateToOutputDirectory(settings, buildTracker.WorkingDirectory, buildTracker.ReportFileName + ".tex");

            //copy content file to working dir
            var workingContentFile = Path.Combine(buildTracker.WorkingDirectory, settings.ContentFileName + ".tex");

            File.WriteAllText(workingContentFile, texContent.ToString());

            //copy attachments
            attachements.Each(x => x.CopyToWorkingDirectory(buildTracker.WorkingDirectory));

            settings.Implement(texFilePath);

            var createdPDF = await _texCompiler.CompileTex(texFilePath, settings.NumberOfCompilations);

            //Report could not be found. Something went wrong during the creation process. Throw an exception
            if (!FileHelper.FileExists(createdPDF))
            {
                throw new TeXReportCompilerException(buildTracker.WorkingDirectory);
            }

            //creation successful: Copy to final location
            copyCreatedToPdfToDesiredLocation(createdPDF, buildTracker);
        }
Пример #4
0
        public Task ReportToPDF(string pdfReportFullPath, ReportSettings settings, IReadOnlyCollection <object> objectsToReport)
        {
            var tracker = _buildTrackerFactory.CreateFor <BuildTracker>(pdfReportFullPath);

            return(ReportToPDF(tracker, settings, objectsToReport));
        }