Showing posts with label report. Show all posts
Showing posts with label report. Show all posts

Friday, March 3, 2017

Generate report of the current page as PDF using itextsharp in WPF

Leave a Comment

I have some details in the wpf page, I want to generate report for that page.

Say for example I am having a page with one image and some text boxes. If i click report button, that page should be popup in a window with Print and PDF options. How to achieve this?The links that i have found regarding pdf creation is not enough to achieve my goal. I need more clear explanation since am a beginner.

0 Answers

Read More

Friday, April 29, 2016

How to make a aspxdocumentviewer direction rtl?

Leave a Comment

My goal is to have a right justified report. So I changed the text align from right to middle center justified because right justified alignment is not supported in document viewer I think. Now my text is justified but the direction is ltr. How to make it rtl?

I tried to set a rtl style for created html from document viewer by css and jquery but it ignores styles.

I am using devexpress report suit 15.2 with asp.net webforms.

How to do it?

1 Answers

Answers 1

Finally I fount it.

By adding the following code to the aspxdocumentviewer I was able to write css codes for it.

<dx:ASPxDocumentViewer ID="ASPxDocumentViewer1" runat="server">     <ToolbarItems>         <dx:ReportToolbarButton ItemKind="Search" />         <dx:ReportToolbarSeparator />     </ToolbarItems>     <SettingsReportViewer UseIFrame="false" /> </dx:ASPxDocumentViewer>  <style type="text/css">     body{         direction:rtl;     } </style> 
Read More

Tuesday, April 26, 2016

JUnit Reports — Test Method Descriptions

Leave a Comment

I am trying to see if there is a way to include "descriptive text" in my junit reports by way of javadocs. JUnit 4 doesnt seem to support the 'description' attribute for the @Test annotation like TestNG does.

So far from what I have researched there is only one tool out there called javadoc-junit (http://javadoc-junit.sourceforge.net/). However I could not get this to work since it seems to be incompatible with Junit 4.

What I want is some way to provide a sentence or two of text with my each test method in the JUnit report. JavaDoc is no good since the target audience will have to swtich between JavaDoc and the Junit Report to see documentation and/or test stats.

Anyone know of anything else I could use with minimal effort?

Best, Ray J

4 Answers

Answers 1

There's also rather recent solution called Allure. That's a Java-based test execution report mainly based on adding supplementary annotations to the code. Existing annotations include:

  • custom description: @Description("A cool test")
  • grouping by features or stories: @Features({"feature1", "feature2"}), @Stories({"story1", "story2" })
  • marking methods executed inside test case as steps: @Step (works even for private methods)
  • attachments: @Attachment(name = "Page screenshot", type = "image/png")

See their wiki and example project for more details.

Answers 2

I don't put javadocs in JUnit tests. I usually make the name of the method descriptive enough so it's as good as or better than any comment I could come up with.

Answers 3

In JUnit 5 there is a way to annotate every test with a @DisplayName. The declared test classes can have text, special characters and emojis.

The declared text on each test is visible by test runners and test reports.


The Javadoc says:

public @interface DisplayName

@DisplayName is used to declare a custom display name for the annotated test class or test method. Display names are typically used for test reporting in IDEs and build tools and may contain spaces, special characters, and even emoji.

And the User Guide:

import org.junit.gen5.api.DisplayName; import org.junit.gen5.api.Test;  @DisplayName("A special test case") class DisplayNameDemo {      @Test     @DisplayName("Custom test name containing spaces")     void testWithDisplayNameContainingSpaces() {     }      @Test     @DisplayName("╯°□°)╯")     void testWithDisplayNameContainingSpecialCharacters() {     }      @Test     @DisplayName("😱")     void testWithDisplayNameContainingEmoji() {     } } 

Answers 4

I could imagine, that the Framework for Integrated Tests (FIT) would be a nice and clean solution.

What does FIT do?
FIT is a framework that allows to write tests via a table in a Word document, a wiki table or an html table.
Every character outside of a table is ignored by FIT and let you enter documentation, description, requirements and so on.

How does on of these tables look like?

Imagine a function MyMath.square(int) that squares it's input parameter. You have to build a so called Fixture, being an adapter between your MyMath and the following table:

class.with.Fixture.Square x    square() 2    4 5    25 

The first column describes input values, the second the expected result. If it's not equal, this field is marked as red.

How does a Fixture look like?
For the given example, this would be the correct fixture:

package class.with.Fixture // Must be the same as in the fist row of the table  public class Square extends Fixture {     public int x; // Must be the same as in the second row     public int square() { // Must be the same as in the second row         return MyMath.square(x);     } } 

Probably, you can use FIT for your requirements.
Feel free to comment my answer or edit your question for more information!

Read More

Friday, April 1, 2016

Pass a sql parameter value to devexpress report?

Leave a Comment

I want to pass a sql parameter from user form to my report class but it is not working and it does not create the report and when I open the report designer tab again after adding ID argument to the report class it refresh the report and delete my components.

What is the problem?

Here is my report class:

public SodoorZemanatName(long ID)     {         InitializeComponent(ID);     }      protected override void Dispose(bool disposing)     {         if (disposing && (components != null))         {             components.Dispose();         }         base.Dispose(disposing);     }      #region Designer generated code     private void InitializeComponent(long ID)     {             this.components = new System.ComponentModel.Container();             DevExpress.DataAccess.Sql.CustomSqlQuery customSqlQuery1 = new DevExpress.DataAccess.Sql.CustomSqlQuery();             DevExpress.DataAccess.Sql.QueryParameter queryParameter1 = new DevExpress.DataAccess.Sql.QueryParameter();             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(SodoorZemanatName));             this.topMarginBand1 = new DevExpress.XtraReports.UI.TopMarginBand();             this.detailBand1 = new DevExpress.XtraReports.UI.DetailBand();             this.bottomMarginBand1 = new DevExpress.XtraReports.UI.BottomMarginBand();             this.sqlDataSource2 = new DevExpress.DataAccess.Sql.SqlDataSource(this.components);             ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();             this.topMarginBand1.HeightF = 100F;             this.topMarginBand1.Name = "topMarginBand1";             this.detailBand1.HeightF = 100F;             this.detailBand1.Name = "detailBand1";             this.bottomMarginBand1.HeightF = 100F;             this.bottomMarginBand1.Name = "bottomMarginBand1";             this.sqlDataSource2.ConnectionName = "Context";             this.sqlDataSource2.Name = "sqlDataSource2";             customSqlQuery1.Name = "Query";             queryParameter1.Name = "ID";             queryParameter1.Type = typeof(long);             queryParameter1.ValueInfo = "0";             queryParameter1.Value = ID;             customSqlQuery1.Parameters.Add(queryParameter1);             customSqlQuery1.Sql = "select * from LG_Garanti where ID=@ID";             this.sqlDataSource2.Queries.AddRange(new DevExpress.DataAccess.Sql.SqlQuery[] {             customSqlQuery1});             this.sqlDataSource2.ResultSchemaSerializable = resources.GetString("sqlDataSource2.ResultSchemaSerializable");     this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {     this.topMarginBand1,     this.detailBand1,     this.bottomMarginBand1});     this.ComponentStorage.AddRange(new System.ComponentModel.IComponent[] {     this.sqlDataSource2});     this.DataSource = this.sqlDataSource2;     this.Version = "15.2";     ((System.ComponentModel.ISupportInitialize)(this)).EndInit(); } #endregion 

And here is my calling:

SodoorZemanatName report = new SodoorZemanatName(1); ASPxDocumentViewer1.ReportTypeName = "SodoorZemanatName"; ASPxDocumentViewer1.Report = report; 

1 Answers

Answers 1

I guess you want to (1) click the button, (2) pass an ID then (3) open the report has content depends on that ID. So this is the way I did it, (I'm not sure is there any other way because devexpress is not open source):

  1. Design your dataset, it contains only the info you want to show using the dataset tool of Visual Studio. i.e. id, name, address, ..... Name that dataset = ReportDataset. That dataset has 1 table named MyTable.
  2. Design your report named MyReport using the GUI tool (remember to choose XtraReport), and select the datasource = that ReportDataset, do not edit the code generated by the GUI tool. Just use the GUI, click & click to add labels, add value from the ReportDataset.
  3. In you form, window form or whatever, the below should be inside the function triggered by button_click event (your "calling" in the last snippet of your question):

    DataSet new_ds = new DataSet(); ReportDataset.MyTable runtime_data = new ReportDataset.MyTable(); //get data from your database according to ID, Row by row  //then add them to the runtime_data table //in your case, add all the result of "select * from LG_Garanti where ID=@ID"; runtime_data.Rows.Add(new object[] {.blah blah..});// just add row, use whatever method you like new_ds.Tables.Add(runtime_data); //from this point, new_ds contains runtime data of the row(s) you want ID. //now just link that dynamic dataset to your designed report MyReport my_report = new MyReport(); my_report.DataSource = new_ds; // Show the print preview or do whatever you want  ReportPrintTool printTool = new ReportPrintTool(my_report); printTool.ShowRibbonPreviewDialog(); 

The above is to make it more flexible since the report can use its own dataset with the mixture of different tables,.... You can make it easier by reuse your own dataset in step 1. Hope this helps.

Read More