Integration of Elixir Client .Net with C++


Elixir Report Server comes with a .Net ERS Client  for invoking generation from Report Server.  This documentation illustrate how this .Net ERS Client can be integration with different programming language as C++ in a window platform

Requirement
1) Elixir Report Server version 5.1 or greater
2) Elixir Report Server .Net Client  ( ERSNetClient)
3) Windows OS
4)  Window Visual Studio 2005 or any other .Net supported IDE , Visual C++ express Edition
5) .Net Frame worked install (optional as this part of  Visual C++ express Edition installation)

Visual C++ express Edition  may be downloaded from microsoft developer tool site.
current link is  http://lab.msdn.microsoft.com/express/visualc/default.aspx

Here are the steps needed to create .Netframe  C++ project

1) Create a new  CLR project 

Create CLR Project

2) Enter the values as Project and Solution Name

 

Enter values

3) Once the Project is created, next step is to add the .Net library of ERSClient to be reference in the project.

 go the the left hand panel under Class View property table select the Project Node. Right click on the right mouse button to launch a popup meni


 Add Reference

4)  At the Reference Property Page

Property Page

5) Add new Reference by click a Add New Reference button and choose the browse tab.

Browse for dll

6) Select the Dlls  by adding the dll ERSClient.dll and Log4j.dll

Locate

7) Select one of the reference and add to the reference.

If the dlls are added then the reference name will appear in ERSClient and log4net.

add

8) You can  return to the main view, at the class view.  You should be able to view the function available in ERSClient.

ERSClient

9)  Code the different reporting functions


a)   Include the namespace of report and log4j

using namespace com::elixirtech::net;
using namespace com::elixirtech::ers2::client;

b) Create a new ERSClient

ERSClient^ ersClient = gcnew ERSClient(L"localhost",7001,L"Anonymous",L"anonymous" );

c) Examples source : links for full source code

Example 1:  List filesystem in the Server repository

array<System::String ^> ^filesystems = ersClient->GetFileSystems();
 for (int i=0;i<filesystems->Length;i++)
{
    System::Console::WriteLine(filesystems[i]);
}

Example 2:  List available reports in file system in Report Server

array<System::String ^> ^reports ;
if (filesystems->Length>1)
{
     reports = ersClient->GetReports(filesystems[1]);
}
if (reports)
{
    for (int j=0;j<reports->Length;j++)
   {
       Console::WriteLine(reports[j]);
    }
}

Example 3: Generate a Report from FileSystem "ReportSamples"

String ^myreport = "/ReportSamples/Components/Rectangle.rml";
String ^mimeType = "application/pdf";
String ^filename = "Rectangle.pdf";
   
FileInfo ^fi1e = gcnew FileInfo(filename);
if (fi1e->Exists)
        fi1e->Delete();
FileStream ^fs = gcnew FileStream(filename, FileMode::CreateNew);

System::Collections::Hashtable ^properties = gcnew System::Collections::Hashtable(); 
// generate report in PDF format       

JobInfo ^jobInfo = ersClient->RenderReport(
            myreport,
            mimeType,
            fs,
            properties,
            "me"
        );   
//print report information
Console::WriteLine("*** Start Report Generated information ***");
Console::WriteLine("Report: "+jobInfo->name);
Console::WriteLine("Report: "+jobInfo->jobowner);
Console::WriteLine("Page Count: "+jobInfo->pageCount);
Console::WriteLine("Byte Count: "+jobInfo->byteCount);
Console::WriteLine();
Console::WriteLine("*** End Report Generated information ***");
//close connection
ersClient->Close();
fs->Close();

Build :

./images/Build

Execute
Execute

Output to command console
result

Preview

preview


View report in PDF viewer

Viewer

Generated report.  (actual pdf doc)