Beispiel #1
0
        public virtual IExportContainer ConvertToExportContainer(IReportContainer reportContainer)
        {
            var exportContainer = (ExportContainer)reportContainer.CreateExportColumn();

            exportContainer.Location = CurrentLocation;
            return(exportContainer);
        }
        /// <summary>
        /// Creates a report reader.
        /// </summary>
        /// <param name="reportContainer">The report container.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="reportContainer"/> is null.</exception>
        public DefaultReportReader(IReportContainer reportContainer)
        {
            if (reportContainer == null)
                throw new ArgumentNullException(@"reportContainer");

            this.reportContainer = reportContainer;
        }
        public void Init()
        {
            section = new BaseSection()
            {
                Size     = new Size(720, 60),
                Location = new Point(50, 50),
                Name     = "Section"
            };

            var row = new BaseRowItem()
            {
                Name = "Row1"
            };

            row.Items.Add(new BaseTextItem()
            {
                Name     = "Item1",
                Location = new Point(10, 10),
                Size     = new Size(60, 20)
            });


            section.Items.Add(row);
            Bitmap bitmap = new Bitmap(700, 1000);

            graphics = Graphics.FromImage(bitmap);
        }
        public void Init()
        {
            container = new BaseSection(){
                Size = new Size (720,60),
                Location = new Point(50,50),
                Name ="Section"
            };

            var item1 = new BaseTextItem(){
                Name = "Item1",
                Location = new Point(10,10),
                Size = new Size (60,20)
            };

            var item2 = new BaseTextItem(){
                Name = "Item2",
                Location = new Point(80,10),
                Size = new Size (60,20)
            };
            container.Items.Add(item1);
            container.Items.Add(item2);

            var bitmap = new Bitmap(700,1000);
            graphics = Graphics.FromImage(bitmap);
        }
 public SectionEventArgs(IReportContainer section,int pageCount)
 {
     if (section == null)
         throw new ArgumentNullException("section");
     Section = section;
     PageCount = pageCount;
 }
        /// <summary>
        /// Creates the multipart mime report container.
        /// </summary>
        /// <param name="inner">The container to which the archived report should be saved.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="inner"/> is null.</exception>
        public MultipartMimeReportContainer(IReportContainer inner)
        {
            if (inner == null)
                throw new ArgumentNullException("inner");

            this.inner = inner;
        }
        public void Init()
        {
            container = new BaseSection()
            {
                Size     = new Size(720, 60),
                Location = new Point(50, 50),
                Name     = "Section"
            };

            var item1 = new BaseTextItem()
            {
                Name     = "Item1",
                Location = new Point(10, 10),
                Size     = new Size(60, 20)
            };

            var item2 = new BaseTextItem()
            {
                Name     = "Item2",
                Location = new Point(80, 10),
                Size     = new Size(60, 20)
            };

            container.Items.Add(item1);
            container.Items.Add(item2);

            Bitmap bitmap = new Bitmap(700, 1000);

            graphics = Graphics.FromImage(bitmap);
        }
Beispiel #8
0
 public SectionEventArgs(IReportContainer section)
 {
     if (section == null)
     {
         throw new ArgumentNullException("section");
     }
     Section = section;
 }
Beispiel #9
0
 public SectionEventArgs(IReportContainer section, int pageCount)
 {
     if (section == null)
     {
         throw new ArgumentNullException("section");
     }
     Section   = section;
     PageCount = pageCount;
 }
        /// <summary>
        /// Creates the multipart mime report container.
        /// </summary>
        /// <param name="inner">The container to which the archived report should be saved.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="inner"/> is null.</exception>
        public MultipartMimeReportContainer(IReportContainer inner)
        {
            if (inner == null)
            {
                throw new ArgumentNullException("inner");
            }

            this.inner = inner;
        }
Beispiel #11
0
        /// <summary>
        /// Creates a report reader.
        /// </summary>
        /// <param name="reportContainer">The report container.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="reportContainer"/> is null.</exception>
        public DefaultReportReader(IReportContainer reportContainer)
        {
            if (reportContainer == null)
            {
                throw new ArgumentNullException(@"reportContainer");
            }

            this.reportContainer = reportContainer;
        }
        private void HandleQueryReportEvent(object sender, QueryReportEventArgs e)
        {
            IReportContainer reportContainer = ReportDataProvider.ReportsStorage.GetReportContainerByHandle(e.ReportHandle);

            Guard.ArgumentNotNull(reportContainer, "reportContainer");
            XtraReport report = reportContainer.Report;

            reportServiceController.SetupBeforePrint(report, e.ParametersObject, e.Criteria, e.CanApplyCriteria, e.SortProperty, e.CanApplySortProperty);
            e.Report = report;
        }
        public void FormatWritesTheTransformedReport()
        {
            string resourcePath = Path.Combine(Path.GetDirectoryName(AssemblyUtils.GetAssemblyLocalPath(GetType().Assembly)), @"..\Reports");

            IReportWriter    reportWriter    = Mocks.StrictMock <IReportWriter>();
            IReportContainer reportContainer = Mocks.StrictMock <IReportContainer>();
            IProgressMonitor progressMonitor = NullProgressMonitor.CreateInstance();

            string reportPath = SpecialPathPolicy.For <XsltReportFormatter>().CreateTempFileWithUniqueName().FullName;

            using (Stream tempFileStream = File.OpenWrite(reportPath))
            {
                using (Mocks.Record())
                {
                    SetupResult.For(reportWriter.ReportContainer).Return(reportContainer);

                    reportWriter.SerializeReport(null, AttachmentContentDisposition.Link);
                    LastCall.Constraints(Is.NotNull(), Is.Equal(AttachmentContentDisposition.Link))
                    .Do((SerializeReportDelegate) delegate(XmlWriter writer, AttachmentContentDisposition contentDisposition)
                    {
                        XmlDocument doc = new XmlDocument();
                        doc.InnerXml    = "<report>The report.</report>";
                        doc.Save(writer);
                    });

                    SetupResult.For(reportContainer.ReportName).Return("Foo");
                    Expect.Call(reportContainer.OpenWrite("Foo.ext", MimeTypes.PlainText, new UTF8Encoding(false)))
                    .Return(tempFileStream);
                    reportWriter.AddReportDocumentPath("Foo.ext");

                    Expect.Call(reportContainer.OpenWrite(@"Foo\MbUnitLogo.png", MimeTypes.Png, null)).Return(new MemoryStream());

                    reportWriter.SaveReportAttachments(null);
                    LastCall.Constraints(Is.NotNull());
                }

                using (Mocks.Playback())
                {
                    XsltReportFormatter formatter = new XsltReportFormatter("ext", MimeTypes.PlainText, new DirectoryInfo(resourcePath), "Diagnostic.xslt", new string[] { "MbUnitLogo.png" });
                    var reportFormatterOptions    = new ReportFormatterOptions();
                    reportFormatterOptions.AddProperty(XsltReportFormatter.AttachmentContentDispositionOption, AttachmentContentDisposition.Link.ToString());

                    formatter.Format(reportWriter, reportFormatterOptions, progressMonitor);

                    string reportContents = File.ReadAllText(reportPath);
                    TestLog.EmbedXml("Diagnostic report contents", reportContents);
                    Assert.Contains(reportContents, "<resourceRoot>Foo</resourceRoot>");
                    Assert.Contains(reportContents, "The report.");

                    File.Delete(reportPath);
                }
            }
        }
Beispiel #14
0
        /// <summary>
        /// Generates reports of the desired forms.
        /// </summary>
        /// <remarks>
        /// <para>
        /// This method adds the paths of the generated report documents to <see cref="ReportDocumentPaths" />.
        /// </para>
        /// </remarks>
        /// <param name="reportDirectory">The report directory.</param>
        /// <param name="reportName">The report name.</param>
        /// <param name="reportArchive">Determines whether to enclose the resulting test report in a compressed archive file.</param>
        /// <param name="reportFormats">The report formats to generate.</param>
        /// <param name="reportFormatOptions">The report formatter options.</param>
        /// <param name="reportManager">The report manager.</param>
        /// <param name="progressMonitor">A progress monitor for the operation.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="reportDirectory"/>,
        /// <paramref name="reportName"/>, <paramref name="reportFormats"/>, <paramref name="reportFormatOptions"/>,
        /// <paramref name="reportManager"/>, or <paramref name="progressMonitor"/> is null.</exception>
        public void GenerateReports(string reportDirectory, string reportName, ReportArchive reportArchive, IList <string> reportFormats,
                                    ReportFormatterOptions reportFormatOptions, IReportManager reportManager, IProgressMonitor progressMonitor)
        {
            if (reportDirectory == null)
            {
                throw new ArgumentNullException("reportDirectory");
            }
            if (reportName == null)
            {
                throw new ArgumentNullException("reportName");
            }
            if (reportFormats == null)
            {
                throw new ArgumentNullException("reportFormats");
            }
            if (reportFormatOptions == null)
            {
                throw new ArgumentNullException("reportFormatOptions");
            }
            if (reportManager == null)
            {
                throw new ArgumentNullException("reportManager");
            }
            if (progressMonitor == null)
            {
                throw new ArgumentNullException("progressMonitor");
            }

            var factory = new ReportContainerFactory(new FileSystem(), reportDirectory, reportName);

            using (progressMonitor.BeginTask("Generating reports.", reportFormats.Count))
                using (IReportContainer reportContainer = factory.MakeForSaving(reportArchive))
                {
                    IReportWriter reportWriter = reportManager.CreateReportWriter(report, reportContainer);

                    // Delete the report if it exists already.
                    reportContainer.DeleteReport();

                    // Format the report in all of the desired ways.
                    foreach (string reportFormat in reportFormats)
                    {
                        using (IProgressMonitor subProgressMonitor = progressMonitor.CreateSubProgressMonitor(1))
                            reportManager.Format(reportWriter, reportFormat, reportFormatOptions, subProgressMonitor);
                    }

                    // Save the full paths of the documents.
                    foreach (string reportDocumentPath in reportWriter.ReportDocumentPaths)
                    {
                        AddReportDocumentPath(Path.Combine(reportDirectory, reportDocumentPath));
                    }
                }
        }
        public override void CustomShowPreview(
            string reportContainerHandle,
            ReportParametersObjectBase parametersObject,
            DevExpress.Data.Filtering.CriteriaOperator criteria,
            bool canApplyCriteria,
            SortProperty[] sortProperty,
            bool canApplySortProperty,
            ShowViewParameters showViewParameters,
            bool isSinglePage)
        {
            IReportContainer reportContainer = ReportDataProvider.ReportsStorage.GetReportContainerByHandle(reportContainerHandle);

            Guard.ArgumentNotNull(reportContainer, "reportContainer");
            Type dataType = GetReportDataSourceObjectType(reportContainer.Report);

            objectSpace = Application.CreateObjectSpace(dataType);
            DetailView            previewDetailView   = new DetailView((IModelDetailView)Application.Model.Views[ReportsAspNetModuleV2.ReportViewDetailViewWebName], objectSpace, null, Application, false);
            ReportViewerContainer reportViewContainer = new ReportViewerContainer(parametersObject, criteria, canApplyCriteria, sortProperty, canApplySortProperty);

            DevExpress.ExpressApp.ReportsV2.Web.ReportViewerDetailItem reportViewer =
                new DevExpress.ExpressApp.ReportsV2.Web.ReportViewerDetailItem(
                    reportContainerHandle,
                    reportViewContainer,
                    "ReportViewer");
            reportViewer.QueryReport            += this.HandleQueryReportEvent;
            reportViewer.CustomParameterEditors += HandleCustomParameterEditorsEvent;
            previewDetailView.AddItem(reportViewer);
            previewDetailView.Caption = reportContainer.Report.DisplayName;

            if (isSinglePage)
            {
                Namoly.Module.Common.Utility.SinglePageHelper.GenerateSinglePageReport(reportContainer.Report, true, 6);
            }

            PreviewReportDialogController windowController = Application.CreateController <PreviewReportDialogController>();

            windowController.AcceptAction.Active["ReportPreview"] = false;
            if (showViewParameters == null)
            {
                showViewParameters = new ShowViewParameters();
                showViewParameters.Controllers.Add(windowController);
                showViewParameters.CreatedView  = previewDetailView;
                showViewParameters.TargetWindow = TargetWindow.NewWindow;
                Application.ShowViewStrategy.ShowView(showViewParameters, new ShowViewSource(Frame, null));
            }
            else
            {
                showViewParameters.Controllers.Add(windowController);
                showViewParameters.CreatedView  = previewDetailView;
                showViewParameters.TargetWindow = TargetWindow.NewWindow;
            }
        }
		public ContainerConverter(Graphics graphics,IReportContainer reportContainer,Point currentLocation )
		{
			if (graphics == null) {
				throw new ArgumentNullException("graphics");
			}
			if (reportContainer == null) {
				throw new ArgumentNullException("reportContainer");
			}
			
			this.graphics = graphics;
			Container = reportContainer;
			CurrentLocation = currentLocation;
		}
        /// <summary>
        /// Creates a report writer for the specified report.
        /// </summary>
        /// <param name="report">The report.</param>
        /// <param name="reportContainer">The report container.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="report"/> or <paramref name="reportContainer"/> is null.</exception>
        public DefaultReportWriter(Report report, IReportContainer reportContainer)
        {
            if (report == null)
                throw new ArgumentNullException(@"report");
            if (reportContainer == null)
                throw new ArgumentNullException(@"reportContainer");

            this.report = report;
            this.reportContainer = reportContainer;

            reportDocumentPaths = new List<string>();

            attachmentPathResolver = new AttachmentPathResolver(reportContainer);
        }
Beispiel #18
0
        /// <summary>
        /// Saves the specified report.
        /// </summary>
        /// <param name="report"></param>
        /// <param name="reportArchive"></param>
        /// <param name="formatterName"></param>
        /// <param name="outputPath"></param>
        /// <param name="getOutputName"></param>
        /// <param name="options"></param>
        /// <returns></returns>
        protected bool SaveReport(Report report, ReportArchive reportArchive, string formatterName, string outputPath, Func <string> getOutputName, ReportFormatterOptions options)
        {
            return(CaptureFileException(() => "The specified output directory is not a valid file path.", () =>
            {
                var factory = new ReportContainerFactory(new FileSystem(), outputPath, getOutputName());

                using (IReportContainer outputContainer = factory.MakeForSaving(reportArchive))
                {
                    IReportWriter reportWriter = reportManager.CreateReportWriter(report, outputContainer);
                    Context.ProgressMonitorProvider.Run(pm => reportManager.Format(reportWriter, formatterName, options, pm));
                    return true;
                }
            }));
        }
 /// <summary>
 /// Recursively copies files and folders from the source path in the native
 /// file system to the destination path within the report container.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="sourcePathInFileSystem">The source file or directory path in the native file system.</param>
 /// <param name="destPathInContainer">The destination file or directory path in the report container.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="container" />,
 /// <paramref name="sourcePathInFileSystem"/> or <paramref name="destPathInContainer"/> is null.</exception>
 public static void CopyToReport(IReportContainer container, string sourcePathInFileSystem, string destPathInContainer)
 {
     FileUtils.CopyAllIndirect(sourcePathInFileSystem, destPathInContainer, null,
         delegate(string sourceFilePath, string destFilePath)
         {
             using (Stream sourceStream = File.OpenRead(sourceFilePath))
             {
                 using (Stream destStream = container.OpenWrite(destFilePath, MimeTypes.GetMimeTypeByExtension(Path.GetExtension(sourceFilePath)), null))
                 {
                     FileUtils.CopyStreamContents(sourceStream, destStream);
                 }
             }
         });
 }
 /// <summary>
 /// Recursively copies files and folders from the source path in the native
 /// file system to the destination path within the report container.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="sourcePathInFileSystem">The source file or directory path in the native file system.</param>
 /// <param name="destPathInContainer">The destination file or directory path in the report container.</param>
 /// <exception cref="ArgumentNullException">Thrown if <paramref name="container" />,
 /// <paramref name="sourcePathInFileSystem"/> or <paramref name="destPathInContainer"/> is null.</exception>
 public static void CopyToReport(IReportContainer container, string sourcePathInFileSystem, string destPathInContainer)
 {
     FileUtils.CopyAllIndirect(sourcePathInFileSystem, destPathInContainer, null,
                               delegate(string sourceFilePath, string destFilePath)
     {
         using (Stream sourceStream = File.OpenRead(sourceFilePath))
         {
             using (Stream destStream = container.OpenWrite(destFilePath, MimeTypes.GetMimeTypeByExtension(Path.GetExtension(sourceFilePath)), null))
             {
                 FileUtils.CopyStreamContents(sourceStream, destStream);
             }
         }
     });
 }
Beispiel #21
0
        /// <summary>
        /// Loads the specified report.
        /// </summary>
        /// <param name="inputPath"></param>
        /// <param name="inputName"></param>
        /// <param name="report"></param>
        /// <returns></returns>
        protected bool LoadReport(string inputPath, string inputName, out Report report)
        {
            report = CaptureFileException(() => "The specified report is not a valid file path.", () =>
            {
                var factory = new ReportContainerFactory(new FileSystem(), inputPath, inputName);

                using (IReportContainer inputContainer = factory.MakeForReading())
                {
                    IReportReader reportReader = reportManager.CreateReportReader(inputContainer);
                    return(Context.ProgressMonitorProvider.Run(pm => reportReader.LoadReport(true, pm)));
                }
            });

            return(report != null);
        }
        public void GetProperties_ReturnsIReportContainer_GivenValidInput()
        {
            //Arrange
            string[]         props           = { "someProp" };
            string[]         vals            = { "someVal" };
            IReportContainer reportContainer = new Dummy_ReportContainer(props, vals);
            CSVReportReader  reportReader    = new CSVReportReader(reportContainer, new Dummy_UniqueNameProvider());

            reportReader.Read(_csvText);

            //Act
            IReportContainer actual = reportReader.GetProperties();

            //Assert
            Assert.IsNotNull(actual);
        }
        public void GetProperties_CreatesReportContainer_GivenInvalidInput()
        {
            //Arrange
            string[]         props           = { "" };
            string[]         vals            = { "" };
            IReportContainer reportContainer = new Dummy_ReportContainer(props, vals);
            CSVReportReader  reportReader    = new CSVReportReader(null, new Dummy_UniqueNameProvider());

            reportReader.Read("");

            //Act
            IReportContainer actual = reportReader.GetProperties();

            //Assert
            Assert.IsNotNull(actual);
        }
Beispiel #24
0
        protected IExportContainer CreateSection(IReportContainer container, Point location)
        {
            var sea = new SectionEventArgs(container);

            Raise <SectionEventArgs> (SectionRendering, this, sea);
            var containerConverter = new ContainerConverter(location);
            var convertedContainer = containerConverter.ConvertToExportContainer(container);

            var list = containerConverter.CreateConvertedList(container.Items);

            containerConverter.SetParent(convertedContainer, list);
            convertedContainer.ExportedItems.AddRange(list);

            convertedContainer.DesiredSize = MeasureElement(convertedContainer);
            ArrangeContainer(convertedContainer);
            return(convertedContainer);
        }
        /// <summary>
        /// Creates a report writer for the specified report.
        /// </summary>
        /// <param name="report">The report.</param>
        /// <param name="reportContainer">The report container.</param>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="report"/> or <paramref name="reportContainer"/> is null.</exception>
        public DefaultReportWriter(Report report, IReportContainer reportContainer)
        {
            if (report == null)
            {
                throw new ArgumentNullException(@"report");
            }
            if (reportContainer == null)
            {
                throw new ArgumentNullException(@"reportContainer");
            }

            this.report          = report;
            this.reportContainer = reportContainer;

            reportDocumentPaths = new List <string>();

            attachmentPathResolver = new AttachmentPathResolver(reportContainer);
        }
        protected IExportContainer CreateSection(IReportContainer container, Point location)
        {
            var sea = new SectionEventArgs(container);

            Raise <SectionEventArgs> (SectionRendering, this, sea);
            var containerConverter = new ContainerConverter(location);
            var convertedContainer = containerConverter.ConvertToExportContainer(container);

            var list = containerConverter.CreateConvertedList(container.Items);

            containerConverter.SetParent(convertedContainer, list);
            convertedContainer.ExportedItems.AddRange(list);
            //Run ExpressionEvaluator for every section, otherwise measure don't work
            ExpressionRunner.Visitor.Visit(convertedContainer as ExportContainer);
            convertedContainer.DesiredSize = MeasureElement(convertedContainer);
            ArrangeContainer(convertedContainer);
            return(convertedContainer);
        }
        public void Run()
        {
            try
            {
                _reportReader.Read(File.ReadAllText(_switchArgs.TargetFilePath, Encoding.GetEncoding(1252)));
                IReportContainer reportContainer = _reportReader.GetProperties();

                if (_switchArgs.OutputFile != string.Empty)
                {
                    _outputHandler.PrintToFile(reportContainer.ToJSON(), _switchArgs.OutputFile);
                }

                _outputHandler.ToOutputStream(reportContainer.ToJSON());
            }
            catch (Exception ex)
            {
                _outputHandler.OutputError($"{_switchArgs.TargetFilePath}\n\n{ex.Message}\n\n{ex.StackTrace}");
            }
        }
        public void Init()
        {
            section = new BaseSection(){
                Size = new Size (720,60),
                Location = new Point(50,50),
                Name ="Section"
            };

            var row = new BaseRowItem(){
                Name = "Row1"
            };

                row.Items.Add(new BaseTextItem(){
                              	Name = "Item1",
                              	Location = new Point(10,10),
                              	Size = new Size (60,20)
                              });

            section.Items.Add(row);
            Bitmap bitmap = new Bitmap(700,1000);
            graphics = Graphics.FromImage(bitmap);
        }
Beispiel #29
0
 /// <inheritdoc />
 public IReportReader CreateReportReader(IReportContainer reportContainer)
 {
     return(new DefaultReportReader(reportContainer));
 }
 /// <inheritdoc />
 public IReportWriter CreateReportWriter(Report report, IReportContainer reportContainer)
 {
     return new DefaultReportWriter(report, reportContainer);
 }
 /// <inheritdoc />
 public IReportReader CreateReportReader(IReportContainer reportContainer)
 {
     return new DefaultReportReader(reportContainer);
 }
Beispiel #32
0
        public void FormatWritesTheArchivedReport()
        {
            IReportWriter    reportWriter        = Mocks.StrictMock <IReportWriter>();
            IReportContainer reportContainer     = Mocks.StrictMock <IReportContainer>();
            IReportFormatter htmlReportFormatter = Mocks.StrictMock <IReportFormatter>();
            IProgressMonitor progressMonitor     = NullProgressMonitor.CreateInstance();
            var reportFormatterOptions           = new ReportFormatterOptions();

            string reportPath = SpecialPathPolicy.For <MHtmlReportFormatterTest>().CreateTempFileWithUniqueName().FullName;

            using (Stream tempFileStream = File.OpenWrite(reportPath))
            {
                using (Mocks.Record())
                {
                    SetupResult.For(reportWriter.ReportContainer).Return(reportContainer);
                    SetupResult.For(reportWriter.Report).Return(new Report());

                    Expect.Call(reportContainer.EncodeFileName(null))
                    .Repeat.Any()
                    .IgnoreArguments()
                    .Do((Gallio.Common.GallioFunc <string, string>) delegate(string value) { return(value); });

                    SetupResult.For(reportContainer.ReportName).Return("Foo");
                    Expect.Call(reportContainer.OpenWrite("Foo.mht", MimeTypes.MHtml, new UTF8Encoding(false)))
                    .Return(tempFileStream);
                    reportWriter.AddReportDocumentPath("Foo.mht");

                    Expect.Call(delegate { htmlReportFormatter.Format(null, null, null); })
                    .Constraints(Is.NotNull(), Is.Same(reportFormatterOptions), Is.NotNull())
                    .Do((FormatDelegate) delegate(IReportWriter innerReportWriter, ReportFormatterOptions innerFormatterOptions, IProgressMonitor innerProgressMonitor)
                    {
                        using (StreamWriter contentWriter = new StreamWriter(innerReportWriter.ReportContainer.OpenWrite("Foo.html", MimeTypes.Html, Encoding.UTF8)))
                            contentWriter.Write("<html><body>Some HTML</body></html>");

                        using (StreamWriter contentWriter = new StreamWriter(innerReportWriter.ReportContainer.OpenWrite(
                                                                                 innerReportWriter.ReportContainer.EncodeFileName("Foo\\Attachment 1%.txt"), MimeTypes.PlainText, Encoding.UTF8)))
                            contentWriter.Write("An attachment.");

                        using (StreamWriter contentWriter = new StreamWriter(innerReportWriter.ReportContainer.OpenWrite("Foo.css", null, null)))
                            contentWriter.Write("#Some CSS.");
                    });
                }

                using (Mocks.Playback())
                {
                    MHtmlReportFormatter formatter = new MHtmlReportFormatter(htmlReportFormatter);

                    formatter.Format(reportWriter, reportFormatterOptions, progressMonitor);

                    string reportContents = File.ReadAllText(reportPath);
                    TestLog.AttachPlainText("MHTML Report", reportContents);

                    Assert.Contains(reportContents, "MIME-Version: 1.0");
                    Assert.Contains(reportContents, "Content-Type: multipart/related; type=\"text/html\"; boundary=");
                    Assert.Contains(reportContents, "This is a multi-part message in MIME format.");

                    Assert.Contains(reportContents, "text/html");
                    Assert.Contains(reportContents, "Content-Location: file:///Foo.html");
                    Assert.Contains(reportContents, Convert.ToBase64String(Encoding.UTF8.GetBytes("<html><body>Some HTML</body></html>"), Base64FormattingOptions.InsertLineBreaks));

                    Assert.Contains(reportContents, "text/plain");
                    Assert.Contains(reportContents, "Content-Location: file:///Foo/Attachment_1%25.txt");
                    Assert.Contains(reportContents, Convert.ToBase64String(Encoding.UTF8.GetBytes("An attachment."), Base64FormattingOptions.InsertLineBreaks));

                    Assert.Contains(reportContents, "text/css");
                    Assert.Contains(reportContents, "Content-Location: file:///Foo.css");
                    Assert.Contains(reportContents, Convert.ToBase64String(Encoding.UTF8.GetBytes("#Some CSS."), Base64FormattingOptions.InsertLineBreaks));

                    File.Delete(reportPath);
                }
            }
        }
 void BuildDetail()
 {
     CurrentSection = ReportModel.DetailSection;
     if(DataSourceContainsData()) {
         CurrentLocation = DetailStart;
         var converter = new ContainerConverter(DetailStart);
         if (IsGrouped()) {
             BuildGroupedDetails(converter,DetailStart);
         } else {
             BuildSortedDetails(converter,DetailStart);
         }
     }
 }
Beispiel #34
0
		public SectionEventArgs(IReportContainer section){
			if (section == null)
				throw new ArgumentNullException("section");
			Section = section;
		}
 public virtual IExportContainer ConvertToExportContainer(IReportContainer reportContainer)
 {
     var exportContainer = (ExportContainer)reportContainer.CreateExportColumn();
     exportContainer.Location = CurrentLocation;
     return exportContainer;
 }
Beispiel #36
0
 public Dummy_CSVReportReader(IReportContainer properties)
 {
     _properties = properties;
 }
 public AttachmentPathResolver(IReportContainer reportContainer)
 {
     this.reportContainer = reportContainer;
 }
Beispiel #38
0
 /// <inheritdoc />
 public IReportWriter CreateReportWriter(Report report, IReportContainer reportContainer)
 {
     return(new DefaultReportWriter(report, reportContainer));
 }
 public CSVReportReader(IReportContainer reportContainer, IUniqueNameProvider nameProvider)
 {
     _reportContainer = reportContainer == null ? new ReportContainer(nameProvider): reportContainer;
     _nameProvider    = nameProvider;
 }
 public void SetUp()
 {
     reportContainer = MockRepository.GenerateStub<IReportContainer>();
     reportContainer.Stub(rc => rc.EncodeFileName(Arg<string>.Is.Anything)).Do(new Func<string, string>(s => s));
     attachmentPathResolver = new AttachmentPathResolver(reportContainer);
 }
 public void SetUp()
 {
     reportContainer = MockRepository.GenerateStub <IReportContainer>();
     reportContainer.Stub(rc => rc.EncodeFileName(Arg <string> .Is.Anything)).Do(new Func <string, string>(s => s));
     attachmentPathResolver = new AttachmentPathResolver(reportContainer);
 }
 public AttachmentPathResolver(IReportContainer reportContainer)
 {
     this.reportContainer = reportContainer;
 }
Beispiel #43
0
		protected IExportContainer CreateSection(IReportContainer section,Point location)
		{
			var containerConverter = new ContainerConverter(graphics, section, location);
			var header = containerConverter.Convert();
			return header;
		}