Version

Setup and Configuration

Prerequisites

The Reveal Server SDK requires .NET Core 2.2+ or .NET Framework 4.6.1+ ASP MVC application projects.

In case you are targeting .NET Framework 4.6.1+, the Reveal Server SDK supports a win7-x64 runtime environment. To debug your web project you need to add a win7-x64 compatible RuntimeIdentifier platform:

<PropertyGroup>

   <TargetFramework>net461</TargetFramework>

   <RuntimeIdentifier>win7-x64</RuntimeIdentifier>

</PropertyGroup>

1. Getting Assemblies and Dependency Packages ready

To add references to assemblies and install dependency packages we recommend using NuGet package manager.

The easiest way to setup your project is installing Infragistics.Reveal.Sdk.Web.AspNetCore (Trial) NuGet package.

After installing the Reveal SDK, you should be able to find a new NuGet package source added to your nuget.config called Infragistics (Local) that points to “%public%\Documents\Infragistics\NuGet”.

addingNugetPackage_web

After ensuring you have the Infragistics (Local) feed properly configured by the installer, you need to:

  • install the Infragistics.Reveal.Sdk.Web.AspNetCore NuGet package to your application project.

  • add a NuGet package reference to System.Data.SQLite version 1.0.111+

If you are having issues with the build, follow this link.

2. Defining the Server Context

After referencing the required DLLs, you need to create a class that implements the IRevealSdkContext interface. This interface allows the Reveal SDK to run inside of your host application and provides callbacks for working with the SDK.

using Infragistics.Sdk;
public class RevealSdkContext : IRevealSdkContext
{
    public IRVDataSourceProvider DataSourceProvider => null;

    public IRVDataProvider DataProvider => null;

    public IRVAuthenticationProvider AuthenticationProvider => null;

    public async Task<Stream> GetDashboardAsync(string dashboardId)
    {
        return await Task.Run(() =>
        {
            //load a .rdash file as a stream and return it
            var fileName = $"C:\\Temp\\{dashboardId}.rdash";
            return new FileStream(fileName, FileMode.Open, FileAccess.Read);
        });
    }

    //This callback is used only when “onSave” event is not installed on the
    //RevealView object client side. For more information see the web client SDK documentation
    public async Task SaveDashboardAsync(string userId, string dashboardId, Stream dashboardStream)
    {
        //Save edited dashboard here
        await Task.Run(() => { });
    }
}

The implementation above will load dashboards from “C:\Temp” folder, looking for a .rdash file that depends on the dashboardId variable. In your application, you may want to change this to load dashboards from another directory, from the database, or even from an embedded resource.

Note

Properties returning null: The first three properties, DataSourceProvider, DataProvider, and AuthenticationProvider, are all implemented to return null. In this guide you can find information about how to implement each of the interfaces for these properties, so they will no longer be implemented to return null.

3. Initializing the Server SDK

In the Startup.cs, in the ConfigureServices method of the application, call the services extension method AddRevealServices, passing in the RevealEmbedSettings class.

The AddRevealServices extension method is defined in the Infragistics.Sdk namespace, so you will need to add a using directive. In addition, you also need to set the CachePath property as shown below.

services.AddRevealServices(new RevealEmbedSettings
{
    LocalFileStoragePath = @"C:\Temp\Reveal\DataSources",
    CachePath = @"C:\Temp"
}, new RevealSdkContext());
Note

Note: LocalFileStoragePath is only required if you are using local Excel or CSV files as dashboard data source, and the RevealSdkContext class implements IRevealSdkContext as described before.

Finally, you need to add Reveal endpoints by calling the AddReveal extension method when adding MVC service. Similar to the following code snippet:

services.AddMvc().AddReveal();

Like AddRevealServices, the AddReveal method is defined in the Infragistics.Sdk namespace, so you need a using directive too.

4. Enabling server-side screenshot generation

In order to use the export to image functionality (either programmatically or through user interaction), you need to perform the steps below:

  1. Get the following three files from <InstallationDirectory>\SDK\Web\JS\Server:

    • package.json

    • packages-lock.json

    • screenshoteer.js

  2. Copy the files to the root level of your project (parent folder of "wwwroot").

  3. Make sure you have npm (the package manager for Node.js) installed.

If you don’t need the export to image functionality, you don’t need to copy the files to your projects. However, when trying to build the project, it will fail complaining that it cannot find npm.

To solve this error, add the following property to your project:

<PropertyGroup>
  <DisableRevealExportToImage>true</DisableRevealExportToImage>
</PropertyGroup>

Build Issues using NuGet

To handle a deployment issue related to SQLite.Interop.dll, custom .targets file are used in the NuGet package.

If you are having build issues, you can disable this behavior by adding the following property to your project:

<DisableSQLiteInteropFix>true</DisableSQLiteInteropFix>