Register
Forgot your password?

  • .NET iFrame
  • REST
  • Client
  • .NET iFrame [Report]
// STEP 1: Instantiate Api Object. Specify path to Exago.
Api api = new Api("C:\Program Files\Exago\ExagoWeb");

// STEP 2: Set parameters userId and companyId
api.Parameters.GetParameter("userId").Value = [userId];
api.Parameters.GetParameter("companyId").Value = [companyId];

// STEP 3: Activate a Role
Role role = api.Roles.GetRole("[currentRole]"); 
role.Activate();

// STEP 4: Set identity values for Storage Management
api.SetupData.StorageMgmtConfig.SetIdentity("userId", [userId]);
api.SetupData.StorageMgmtConfig.SetIdentity("companyId", [companyId]);
api.SetupData.StorageMgmtConfig.SetIdentity("classId", [classId]);
api.SetupData.StorageMgmtConfig.SetIdentity("ownerId", [userId]);

// STEP 5: Action to display FullUI 
api.Action = wrApiAction.Home;

// STEP 6: Create URL and Launch using an iframe defined in the aspx page
string paramString = api.GetUrlParamString("ExagoHome", true);
ExagoTestFrame.Src = "http://localhost/Exago/" + paramString
// Set request headers, base URL
IHttpClientFactory cf = new HttpClientFactory();
HttpClient client = cf.CreateClient();
client.BaseAddress = new Uri("http://localhost/ExagoWebApi");
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue('ExagoKey APIUSER:EncodedAuthorizationString');

// STEP 1: Instantiate Api Object, POST to sessions endpoint
content = new StringContent(JsonConvert.SerializeObject(new { }));
res = await client.PostAsync("/rest/sessions", content);
string body = await res.Content.ReadAsStringAsync();
Dictionary<string, object> dict = JsonConvert.DeserializeObject<Dictionary<string, object>>(body);
string sessionId = dict["Id"].ToString(); // grab Exago's session id from response

// STEP 2: Set userId parameter
content = new StringContent(JsonConvert.SerializeObject(new { Value = id }));
res = await client.PatchAsync("/rest/parameters/userId?sid=" + sessionId, content);

// STEP 3: Set identity values for Storage Management
StorageMgmtObj storageMgmtObj = new StorageMgmtObj();
storageMgmtObj.Identities = new IdentityObj
{userId=[userId], companyId=[companyId], classId=[classId], ownerId=[ownerId]};

content = new StringContent(JsonConvert.SerializeObject(storageMgmtObj));
res = await client.PatchAsync("/rest/StorageMgmt?sid=" + sessionId, content);

// STEP 4: Activate a Role
content = new StringContent(JsonConvert.SerializeObject(new { IsActive = true }));
res = await client.PatchAsync("/rest/roles/Admin?sid=" + sessionId, content);

// Exago session setup complete; return ApiKey
return JsonConvert.SerializeObject(new { ApiKey = dict["ApiKey"].ToString() });

<script type="text/javascript" src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
   var api = null;
   $.getScript("http://localhost/Exago/WrScriptResource.axd?s=ExagoApi"); // define script include

// set up button click handling
$(() => {
   $("#btnLogin").click((e) => { // handle "Login" button click
     createExagoSession($.trim($("#txtUserId").val()))
     .then(createHandshake)
   });

   $(".actionBtn").click((e) => { // handle "Report" or "Full UI" button click
     renderExago(e)
   });
});

// define AJAX call to service to set up Exago session
// on server side for user <id> and return ApiKey
+ const createExagoSession = (id) => {...};

// using returned ApiKey, create handshake between this client and Exago session defined for this specific client; 
// display action buttons upon success
const createHandshake = (data) => {
   const apiKey = JSON.parse(data.d.Result).ApiKey;
   api = new ExagoApi('http://localhost/Exago/', apiKey, () => { $(".actionBtn").css("display", "inline") }, true);
};

// based on action button click, determine which was clicked
// and render Exago - specific report or full UI - accordingly
const renderExago = (data) => {
   const container = $("#ExagoWrapper")[0];
   if (data.target.id == 'btnRpt')
     api.ExecuteReport(container, "html", 'Examples\\Report';, null, null, (ctnr, errMsg) => { console.log(errMsg) });
   else
     api.LoadFullUI(container);
   };
</script>
...
<p>Execute a Report or Navigate to Full UI</p>
<form id="form1">
   <p>Username: 
     <input id="txtUserId" type="text"/>&nbsp;&nbsp;
     <button id="btnLogin" type="button">Login</button>
   </p>
   <p>
     <button id="btnRpt" type="button" class="actionBtn">Report</button>&nbsp;&nbsp;
     <button id="btnUi" type="button" class="actionBtn">Full UI</button>
   </p>
</form>
<div id="ExagoWrapper" style="height:750px;width:calc(100%);position:relative"></div>
// STEP 1: Instantiate Api Object. Specify path to Exago.
Api api = new Api("C:\Program Files\Exago\ExagoWeb");

// STEP 2: Set parameters userId and companyId
api.Parameters.GetParameter("userId").Value = [userId];
api.Parameters.GetParameter("companyId").Value = [companyId];

// STEP 3: Activate a Role
Role role = api.Roles.GetRole("[currentRole]");
role.Activate();

// STEP 4: Set identity values for Storage Management
api.SetupData.StorageMgmtConfig.SetIdentity("userId", [userId]);
api.SetupData.StorageMgmtConfig.SetIdentity("companyId", [companyId]);
api.SetupData.StorageMgmtConfig.SetIdentity("classId", [classId]);
api.SetupData.StorageMgmtConfig.SetIdentity("ownerId", [userId]);

// STEP 5: Load and configure report to display
api.Action = wrApiAction.ExecuteReport; // set API action to Execute Report
ReportObject ro = api.ReportObjectFactory.LoadFromRepository("Demo\\Report - Orders by Customer");
ro.ExportType = wrExportType.Html; // Select Export Type for report execution
api.ReportObjectFactory.SaveToApi(ro); // Save Changes back to the api object

// STEP 6: Create URL and launch using an iFrame defined in the aspx page
string paramString = api.GetUrlParamString("ExagoHome", true);
ExagoTestFrame.Src = "http://localhost/Exago/" + paramString