Scroll

SOAP API: C# Sample Code

The following examples demonstrate the capabilities of the Web Service Api using C#.

It is important that the first call instantiate an Api object. After making all the desired changes the final call should be GetUrlParamString. Then redirect the user to Exago’ Url concatenated with  the string GetUrlParamString returns.

In all of the examples below the return value should be checked for validity.  The examples below have omitted these checks for clarity.

Create Api object and initialize

// create an instance of the web service

//(web service needs to have been discovered in your application)

ExagoWebService.Api api = new ExagoWebService.Api();

 

// initialize API; returns an ID which is used in subsequent calls

string apiId = api.InitializeApi();

 

Adding/modifying a Role

// create a new runtime Role (is automatically made active)

api.Role_Add(apiId, true, false, true, true);

// -- OR --

// accessing a pre-created Role and making it active

api.Role_Activate(apiId, "Admin");

 

Adding Folder security to role

// disallow access to folder 'Stew's Reports' (and any subfolders)

api.Role_AddFolder(apiId, "Stew's Reports", false);

 

// make folder 'Summary Reports' (and any subfolders) read only

api.Role_AddFolder(apiId, "Summary Reports", true);

 

Adding Data Object security to role

// disallow access to data object ‘vw_cancellation’

api.Role_AddDataObject(apiId, "vw_cancellation");

 

Adding Data Object Row security to role

// don’t allow this user to view rows from the ‘vw_grant’ object with a

// ‘Grant Date’ value of ‘2000-01-01’

api.Role_AddDataObjectRow(apiId, "vw_grant", @"""Grant Date"" <> '2000-01-01'");

 

Setting up general user session parameters for a role

// overrides individual global general parameters

// set global date format for this user

api.Role_SetDateFormat(apiId, "dd/MM/yyyy");

 

// set currency symbol for this user

api.Role_SetCurrencySymbol(apiId, "kr");

 

Modifying the data connection string of a specific data source

// set data connection string for a specific datasource

api.DataSource_Modify(apiId, "MyDb", "Server=SVR;Database=db1;uid=sa;pwd=dba;");

 

Modifying a parameter value

// modify a parameter value

api.Parameter_Modify(apiId, "asOfDate", "2007-06-01");

 

Adding a data object

api.DataObject_Add(apiId, "eowin", 0, "optionee", "Optionee Dynamic", "OPT_NUM", "Dynamic", null, null, null));

 

Setting data column alias

api.DataObject_SetColumnAlias(apiId, "vw_webrpt_optionee", "Hire Date", "Date of Hire"));

 

Adding a data object join

api.Join_Add(apiId, "optionee", "OPT_NUM", "fn_webrpt_grant", "Optionee Number", 1, 10));

 

Starting Exago

// setup URL

string url = "http://MyDomainServer/Exago/" + api.GetUrlParamString(apiId);

Response.Redirect(url);

 

// or you can redirect any control that can be set to a URL

this.ReportIFrame.Attributes["src"] = url;

 

Executing a report directly from the host application

//  – You can combine setting user session information as above with report execution.  To do that, just omit the redirect above and do the following:

// activate specific report

api.ReportObject_Activate(apiId, @"Stew Meyers' Reports\My Report")

// add a sort

api.Report_AddSort(apiId, "vw_optionee.First Name", 0);

// add a filter

api.Report_AddFilter(apiId, "vw_grant.Grant Date", 1, "20070501", 0, false, true); 

// set other execution params

api.Report_SetParams(apiId, 0, false, false);

Start report execution

// setup URL

string url = "http://MyServer/Exago/" + api.GetUrlParamString(apiId);

Response.Redirect(url);

 

// or you can redirect any control that can be set to a URL

this.ReportIFrame.Attributes["src"] = url;

 

Scheduler Examples

Api api = new Api(apiPath, "AdventureWorks.XML");

api.Report.Load(@"DevReports\Adventure Works\Product Locations and Inventory");

api.Report.ExportType = wrExportType.Pdf;

 

ReportScheduler scheduler = api.ReportScheduler;

 

List<string> toAddrs = new List<string>();

toAddrs.Add("foo@bar.com");

List<string> ccAddrs = new List<string>();

ccAddrs.Add("foo@bar.com");

List<string> bccAddrs = new List<string>();

bccAddrs.Add("foo@bar.com");

 

DateTime dt = new DateTime(2013, 5, 16, 11, 00, 0);

DateTime dt2 = new DateTime(2013, 6, 15, 10, 20, 0);

TimeSpan ts = new TimeSpan(17, 20, 25);

 

scheduler.CreateOnceScheduleByDateTime(dt, "Once by datetime", toAddrs);

 

scheduler.CreateDailySchedule(true, 3, dt, true, 0, dt, "Daily No End Date");

scheduler.CreateDailySchedule(false, 2, dt, false, 5, dt2, "Daily two occurrences");

scheduler.CreateDailySchedule(false, 2, dt, false, 0, dt2, string.Format("Daily end by {0}_{1}", dt2.Month, dt2.Day), toAddrs, ccAddrs);

 

List<DayOfWeek> days = new List<DayOfWeek>();

days.Add(DayOfWeek.Wednesday);

days.Add(DayOfWeek.Wednesday);

days.Add(DayOfWeek.Sunday);

scheduler.CreateWeeklySchedule(2, days, dt, true, 0, null, "Weekly no end date");

scheduler.CreateWeeklySchedule(2, days, dt, false, 2, null, "Weekly 2 occurrences");

scheduler.CreateWeeklySchedule(2, days, dt, false, 0, dt2, "Weekly end by date", toAddrs, ccAddrs, bccAddrs, ts);

Hidden Article Information

Article Author
Alex Agoado
created 2015-12-17 21:11:58 UTC
updated 2017-02-21 17:11:36 UTC

Labels
API, SOAP, Examples,
Have more questions? Submit a request