NoteThis version of the .NET API documentation is deprecated. A new version can be found at https://www.exagoaccess.com/api-docs/.
To access the API, add a reference to the assembly WebReportsApi.dll
to your project. For more information, review the Introduction to the .NET API.
In all of the examples below the return value should be checked for validity. The examples below have omitted validations for clarity.
Create API Object
// create WebReports API object passing Exago virtual path; Api api = new Api("ExagoServer/Exago");
Add or Modify a Role
// create a new runtime Role (is automatically made active) Role role = api.Roles.NewRole(); // -- OR -- // accessing a pre-created Role and making it active Role role = api.Roles.GetRole("Admin"); role.Activate();
Add Folder Security to a Role
// start with privileges to all folders for this user session (this is the default) role.Security.Folders.IncludeAll = true; // disallow access to folder 'Stew's Reports' (and any subfolders) Folder folder = role.Security.Folders.NewFolder(); folder.Name = "Stew's Reports"; // make folder 'Summary Reports' (and any subfolders) read only Folder folder = role.Security.Folders.NewFolder(); folder.Name = "Summary Reports"; folder.ReadOnly = true;
Add Data Object Column Security to a Role
// start with privileges to all data objects (this is the default) role.Security.DataObjects.IncludeAll = true; // disallow access to data object ‘vw_cancellation’ DataObject dataObject = role.Security.DataObjects.NewDataObject(); dataObject.Name = "vw_cancellation";
Add Data Object Row Security to a Role
// don’t allow this user to view rows from the ‘vw_grant’ object with a // ‘Grant Date’ value of ‘2000-01-01’ DataObjectRow dataObjectRow = role.Security.DataObjectRows.NewDataObjectRow(); dataObjectRow.ObjectName = "vw_grant"; dataObjectRow.FilterString = @"""Grant Date"" <> '2000-01-01'";
Set Configuration Settings for the Session in a Role
Set up several general user session parameters for a role (overriding individual global general parameters)
// set global date format for this user role.General.DateFormat = "dd/MM/yyyy"; // set currency symbol for this user role.General.CurrencySymbol = "kr";
Modify a Data Source's Connection String
// set data connection string for a specific datasource DataSource dataSource = api.DataSources.GetDataSource("MyDb"); dataSource.DataConnStr = "Server=SVR;Database=db1;uid=userId;pwd=password;";
Modify a Parameter Value
// modify a parameter value Parameter parameter = api.Parameters.GetParameter("asOfDate"); parameter.Value = "2007-06-01";
Set a Data Object Column Alias
api.Entities.GetEntity("vw_webrpt_optionee").ColumnMetadatas.SetColumnAlias("Hire Date", "Date of Hire");
Clone a Data Object
NoteThe ability to specify a description and category/folder or to inherit them from the parent was added in v2019.2.18.
pageInfo.SetupData.Entities.GetEntity("originalEntityId"); Entity clone = orignal.Clone(); clone.Id = "uniqueId"; clone.Alias = "uniqueAlias"; //v2019.2.18+ only
clone.Description = "Clone Description"; clone.HasInheritedDescription = false; clone.HasInheritedCategory = true;
Set User Identification Parameters
For additional information about user authentication in Exago, review the User Identification article.
api.Parameters.GetItem("userId").Value = "ApiUser"; api.Parameters.GetItem("companyId").Value = "ApiCompany";
Set the End User's Time Zone
For additional information about time zones in Exago v2019.1+, review the Time Zone Calculation Enhancements in v2019.1 article.
PageInfo.SetupData.General.ClientTimeZoneName = 'America/New_York'
Launch the Exago Session
At this point if you want to run the Exago applications, do the following:
// setup URL string url = "http://MyDomainServer/Exago/" + api.GetUrlParamString(); Response.Redirect(url); // or you can redirect any control that can be set to a URL this.ReportIFrame.Attributes["src"] = url;
Execute 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:
// load a specific report and return Report object (make sure to check return value) Report report = (Report)api.ReportObjectFactory.LoadFromRepository(@"Stew Meyers' Reports\My Report"); // add a sort Sort sort = report.Sorts.NewSort();
sort.SortText = "vw_optionee.First Name";
sort.Direction = wrSortDirection.Ascending;
report.Sorts.Add(sort); // add a filter Filter filter = report.Filters.NewFilter(); filter.DbName = "vw_grant.Grant Date"; filter.Operator = wrFilterOperator.LessThan; // default is EqualTo filter.Value = "20070501"; // filter dates are entered in YYYYMMDD sequence filter.AndOrWithNext = wrFilterAndOrWithNext.And; // default is And filter.GroupWithNext = false; // default is false filter.Prompt = true; // default is false // Set the Execute behavior to run in the Report Viewer (default is export to PDF) report.ExportType = wrExportType.Html; // "Html" refers to the Report Viewer // should Report Viewer be opened in new browser window report.OpenNewWindow = false; // default is false report.ShowStatus = false; // default is true // saves a temporary version of the report to be used for execution api.ReportObjectFactory.SaveToApi(report);
Execute a Dashboard Directly from the Host Application
api.Action = wrApiAction.ExecuteReport; DashboardReport report = (DashboardReport)Api.ReportObjectFactory.LoadFromRepository(@"Reports\My Dashboard") as DashboardReport; report.ReportItems[0].SetParameterValue("productname", "Parm1"); report.ReportItems[0].SetFilterValue("Employees.EmployeeID", wrFilterOperator.EqualTo, new List<string>() { "3" }); report.ReportItems[0].SetFilterValue("Orders.OrderDate", wrFilterOperator.GreaterThanOrEqualTo, new List<string>() { "1996-07-04 01:00:00" }); report.ReportItems[1].SetParameterValue("productname", "Parm2"); report.ReportItems[1].SetFilterValue("Employees.EmployeeID", wrFilterOperator.EqualTo, new List<string>() { "5" }); report.ReportItems[1].SetFilterValue("Orders.OrderDate", wrFilterOperator.GreaterThanOrEqualTo, new List<string>() { "1996-07-04 01:00:00" }); api.ReportObjectFactory.SaveToApi(report); string url = @"[Exago Install Path] /" + api.GetUrlParamString("Home"); this.ReportIFrame.Attributes["src"] = url;
Start Report Execution
//setup URL string url = "http://MyDomainServer/Exago/" + api.GetUrlParamString(); Response.Redirect(url); // or you can redirect any control that can be set to a URL this.ReportIFrame.Attributes["src"] = url;
Schedule a Report
Schedule a report with a filter, and e-mail the output.
//load in the report Report report = (Report)api.ReportObjectFactory.LoadFromRepository(@"Reports\Employee Performance") as Report; //specify the export type of the scheduled report report.ExportType = wrExportType.Pdf; //set email information List<string> toList = new List<string>(); toList.Add("emailaddress@example.com"); SchedulerEmailInfo info = new SchedulerEmailInfo(toList); //set a filter on the report Filter filter = report.Filters.NewFilter(); filter.DbName = "Employees.FirstName"; filter.Operator = wrFilterOperator.EqualTo; filter.Value = "Janet"; filter.Prompt = true; //create a schedule api.ReportScheduler.CreateImmediateSchedule("Schedule Test", info); //save the report to the API object api.ReportObjectFactory.SaveToApi(report);