Hi Martin,
I'm trying to do similar to what a standard method is doing, but the difference is that the standard one is XML and it's calling these two methods in Order.
Now since i want Excel,
For the first method “preProcessCatalogMaintenanceRequestXML” -- how can i change it to add uploadDateTime field to excel instead of XML?
For the 2nd method “importCatalogFile” – I think I should leave it as is, except for replacing composite entity (DictCompositeDataEntity ) class and get single entity instead, correct?
protected void preProcessCatalogMaintenanceRequestXML()
{
CatVendorDateTime uploadDateTime = CatVendorCatalogMaintenanceRequest::findRecId(catVendorCatalogMaintenanceRecId).UploadDateTime;
XmlDocument xmlDoc = XMLDocument::newFromStream(fileStream);
XMLElement catalogMaintenanceRequestNode = xmlDoc.documentElement().getNamedElement(tableStr(CatVendorCatalogMaintenanceRequestEntity));
XMLNode uploadDateTimeNode = xmlDoc.createElement(fieldStr(CatVendorCatalogMaintenanceRequestEntity, UploadDateTime));
if (CatVendorCatalogImportUploadDateTimeFormatFlight::instance().isEnabled())
{
uploadDateTimeNode.text(DateTimeUtil::toStr(uploadDateTime));
}
else
{
uploadDateTimeNode.text(datetime2Str(uploadDateTime));
}
catalogMaintenanceRequestNode.appendChild(uploadDateTimeNode);
System.IO.MemoryStream outputStream = new System.IO.MemoryStream();
ClrObject inputArray = System.Text.Encoding::get_UTF8().GetBytes(xmlDoc.InnerXML());
outputStream.Write(inputArray, 0, inputArray.get_length());
fileId = this.uploadFileToTempStorage(outputStream, fullFileName);
}
private void importCatalogFile()
{
DMFDefinitionGroup definitionGroup = CatVendorCatalogMaintenance::findVendorCatalogDefinitionGroup();
DMFExecutionId executionId = DMFUtil::setupNewExecution(definitionGroup.DefinitionGroupName);
ttsbegin;
// Find execution
DictCompositeDataEntity compositeDataEntity = new DictCompositeDataEntity(this.compositeDataEntityName());
DMFDefinitionGroupExecution execution =
DMFDefinitionGroupExecution::find(definitionGroup.DefinitionGroupName, compositeDataEntity.label(), executionId, true);
execution.IsTransformed = NoYes::No;
execution.FilePath = execution.applyTransforms(fileId);
execution.IsTransformed = NoYes::Yes;
execution.update();
ttscommit;
// Import data. Wait for data to be imported
DMFQuickImportExport::doPGImport(definitionGroup.DefinitionGroupName, executionId);
infolog.clear();
}