Hello everyone, hope you're all well! Can someone help me with the following erro when using an adhoc in LCA?
Steps that i already have take:
- enabled the GQI DxM as mentioned in the documentation(GQI DxM | DataMiner Docs).
- verified if the SLManagedAutomation.dll was correctly located in the path C:\Skyline DataMiner\Files, and it was there, as mentioned in another similar question(Kata 62 - could not load assembly - DataMiner Dojo).
I will make the code available here in case the error may be in it, I would be grateful if you could check it.
namespace Web_Services___Get_Bookings_1
{
using System;
using System.Linq;
using System.Collections.Generic;
using Skyline.DataMiner.Automation;
using Skyline.DataMiner.Core.DataMinerSystem.Common;
using Skyline.DataMiner.Analytics.GenericInterface;
using Skyline.DataMiner.Net.Messages;
using Skyline.DataMiner.Net.ManagerStore;
using Skyline.DataMiner.Net.ResourceManager.Objects;
using Skyline.DataMiner.Net.Messages.SLDataGateway;
{
private ReservationInstance[] _bookingsArray;
private Engine engine;
private GQIDMS gqiDms;
public OnInitOutputArgs OnInit(OnInitInputArgs args)
{
gqiDms = args.DMS;
var helper = new ResourceManagerHelper(gqiDms.SendMessage);
engine.GenerateInformation("Iniciando paginação de bookings...");
var list = new List<ReservationInstance>();
try
{
var pager = helper.PrepareReservationInstancePaging(
(SLDataGateway.API.Types.Querying.IQuery<ReservationInstance>)ResourceExposers.CreatedAt.LessThanOrEqual(DateTime.Today),
preferredPagingSize: 200);
while (pager.MoveToNextPage() && list.Count < 1000)
{
list.AddRange(pager.GetCurrentPage());
}
}
catch (CrudFailedException ex)
{
engine.GenerateInformation($"Erro ao buscar bookings: {ex.TraceData}");
}
_bookingsArray = list.Take(1000).ToArray();
engine.GenerateInformation($"Total bookings carregados: {_bookingsArray.Length}");
return new OnInitOutputArgs();
}
public GQIColumn[] GetColumns() => new GQIColumn[]
{
new GQIStringColumn("Name"),
new GQIStringColumn("CreatedBy"),
new GQIDateTimeColumn("CreatedAt"),
new GQIStringColumn("LastModifiedBy"),
new GQIDateTimeColumn("LastModifiedAt"),
};
public GQIPage GetNextPage(GetNextPageInputArgs args)
{
var rows = _bookingsArray.Select(b => new GQIRow(new GQICell[]
{
new GQICell { Value = b.Name },
new GQICell { Value = b.CreatedBy },
new GQICell { Value = b.CreatedAt },
new GQICell { Value = b.LastModifiedBy },
new GQICell { Value = b.LastModifiedAt },
})).ToArray();
return new GQIPage(rows);
}
}
}
Hi João,
In an ad-hoc data source, you do not have access to the Automation's 'Engine' object since this code is not executed as an Automation script. It is thus not really possible to use the SLManagedAutomation.dll. To get some output/logging in your ad-hoc data source, it is recommended to use the logging functionality that is built into the ad-hoc data source framework: https://docs.dataminer.services/develop/devguide/GQI%20Extensions/GQI_Extensions_Logging.html?tabs=tabid-1