Today we will talk about the new library FastReport.Service.dll which appeared in FastReport.Net 2013.3. This library is a WCF Service Library and is intended for use in custom services.
Now library contains the following features:
List<ReportItem> GetReportsList(); List<ReportItem> GetReportsListByPath(string path); List<GearItem> GetGearList(); Stream GetReport(ReportItem report, GearItem gear);
List<ReportItem> GetReportsList() – returns a list of available reports. Each item presens as ReportItem object. Reports are stored on a hard drive on a server that is running the service. Files are sorted in alphabetical order.
List<ReportItem> GetReportsListByPath(string path) – returns a list of available reports by path. Files are sorted in alphabetical order.
List<GearItem> GetGearList() Â - returns a list of available formats that can generate service reports as elements GearItem.
Stream GetReport(ReportItem report, GearItem gear) – returns a stream of result of building a report. Parameters report and gear can be used from the list of previously obtained, or create new objects with the required properties. The returned stream does not support positioning.
Â
ReportItem
public class ReportItem { public string Path; public string Name; public string Description; public Dictionary<string, string> Parameters; }
Path – the path to the report file on the server, relative to the root folder for storing reports. The file extension of the report can only be *.frx. This property is used to identify a specific report with further queries.
Name – name of the report is taken from the metadata of the report. If the metadata of the report contain an empty name then prperty contain a filename without an extension. This property can be used to build an interactive list of available reports in your application (such as ListBox).
Description – description of the report is taken from the metadata of the report.
Dictionary<string, string> Parameters – Dictionary of report parameters maybe filling parameters, which will be subsequently transferred to the report. It supports only the string values that must be considered when designing a report template.
Â
GearItem
public class GearItem { public string Name; public Dictionary<string, string> Properties; }
Name – the name of the format. May contain one of the following strings:
Name |
Description |
|
File of Adobe Acrobat |
DOCX |
File of Microsoft Word 2007 |
XLSX |
File of Microsoft Excel 2007 |
PPTX |
File of Microsoft PowerPoint 2007 |
RTF |
File of Rich Text – supported by many text editors |
ODS |
File of Open Office Spreadsheet |
ODT |
File of Open Office Text |
MHT |
Compressed HTML file together with the images can be opened in Internet Explorer |
CSV |
Comma separated values |
DBF |
File of dBase |
XML |
XML table of Excel – without images |
TXT |
Text file |
FPX |
Prepared report of FastReport.Net, maybe loaded in Viewer.exe or in report object from your code Report.LoadPrepared(stream); Report.ShowPrepared() |
Dictionary<string, string> Properties – Dictionary of parameters of a report. A complete list of supported parameters with default values is available upon request from the server to the list of formats.
Â
You need to add the following lines in your App.config or Web.config.
<appSettings> <add key="FastReport.ReportsPath" value="C:\Program files\FastReports\FastReport.Net\Demos\WCF" /> <add key="FastReport.ConnectionStringName" value="FastReportDemo" /> <add key="FastReport.Gear" value="PDF,DOCX,XLSX,PPTX,RTF,ODS,ODT,MHT,CSV,DBF,XML,TXT,FPX" /> </appSettings>
FastReport.ReportsPath – specifies the path to the folder with the reports, a list of which will be transmitted to the client.
FastReport.ConnectionStringName – the name of the connection string to the database, which is stored in the configuration section <connectionStrings>. Used to replace the internal connection string in the report template.
FastReport.Gear – a list of available formats. You can select only the necessary and change the order of the names.
Schematic a use of FastReport.Service:
Â
Â
If you know exactly what to report and what format you want to receive (it will reduce the number of queries to the service):
Â
Important points when you create report templates for use in the services:
Examples of use FastReport.Service.dll can be found in the folders \Demos\C#\WCFWebService , \Demos\C#\WCFWindowsService , \Demos\C#\WCFWebClient , \Demos\C#\WCFClient. An example configuration file service - FastReport.Service.dll.config.
I'll talk more about specific examples of the use of FastReport.Service.dll in future articles.
To be continued.