Hello dojo, Im straing with DOM
Im tring to use script automate to insert and read all the field of each one to import from CSV and genere API output.
how can i insert a row into tha instance?
How can i read each row, using _domHelper.DomInstances.ReadAll(); i only have the ID and not the full row data.
Thanks
Hi Juan,
The instances that you retrieve using ReadAll() also contain the values. But as explained here, the values are grouped into sections. So to retrieve the values, you need to go through the instance.Sections property. Or one of the extension method, such as instance.GetFieldValue().
Examples of this, and also on how to store data in a DOM instance, can be found here: https://docs.dataminer.services/dataminer/Functions/DOM/DOM_examples/DOM_Altering_values_of_a_DomInstance.html.
Kind regards,
Tom
hello finali get read an insert data with this code.
var domDefinitionId = Guid.Parse("eb7c180f-bb6b-4816-a450-dbced2eed144"); // Vehicles definition
var definitionFilter = DomInstanceExposers.DomDefinitionId.Equal(domDefinitionId);
var all = domHelper.DomInstances.Read(definitionFilter);
foreach (var doc in all)
{
var locationVar = doc.Name;
var locationVar2 = doc.Sections;
var locationVar3 = doc.StatusId;
var locationVar4 = doc.WasStitched;
foreach ( var seccionVar in locationVar2)
{
engine.GenerateInformation($" {seccionVar.GetValue<string>(PlacaFieldDescriptorId)} – {seccionVar.GetValue<int>(LocationFieldDescriptorId)} – {seccionVar.GetValue<int>(CapabilitesFieldDescriptorId)} – {seccionVar.GetValue<Int64>(NumberOfCamerasFieldDescriptorId)} ");
}
}
Insert
var domInstance = new DomInstance() { DomDefinitionId = domDefinitionId };
domInstance.AddOrUpdateFieldValue<string>(sectionDefinitionId, PlacaFieldDescriptorId, "Placa2");
domInstance.AddOrUpdateFieldValue<int>(sectionDefinitionId, LocationFieldDescriptorId, 1);
domInstance.AddOrUpdateFieldValue<Int64>(sectionDefinitionId, NumberOfCamerasFieldDescriptorId, 7);
// Campo faltante 1: Size (int)
// Ejemplo: Medium = 1
domInstance.AddOrUpdateFieldValue<int>(sectionDefinitionId, SizeFieldDescriptorId, 1);
var doubleList = new List<int>() {1, 2 };
domInstance.AddOrUpdateListFieldValue<int>(sectionDefinitionId, CapabilitesFieldDescriptorId, doubleList);
var createdDomInstance = domHelper.DomInstances.Create(domInstance);
In the example i sow the rading by page:
var pagingHelper = helper.DomInstances.PreparePaging(filter); // Prepare with default page size of 500
while (pagingHelper.MoveToNextPage())
{
var currentPage = pagingHelper.GetCurrentPage();
// Handle current page of data…
}
How can i implement a code to read only a especific page without MoveToNextPage, i will implement a custom api with a query parameter to get a page number so i dont need use the MoveToNextPage in the code.
Thanks
Regarding your paging question. Getting a specific page is not supported, it is only possible to scroll through pages using a cookie (that is embedded in the PagingHelper). Although, it would be possible to have such a behavior by getting and ignoring the previous pages every time, we would not recommend such an implementation as this is very inefficient.
i understand, thanks
To extend this reply, some additional links that may be helpful:
– Additional info on the read API: https://docs.dataminer.services/dataminer/Functions/DOM/DomHelper_class.html#reading-dom-data
– Example of how to read a bunch of DOM instances when you have a list of IDs. https://docs.dataminer.services/dataminer/Functions/DOM/DomHelper_class.html#reading-dom-data
(Section 'Read all relevant DOM data in one call')