EBDN - Community - Question & Answers

  Monday, 07 January 2019
  0 Replies
  1.5K Visits
0
Votes
Undo
Hello,
I have created a Sub that is able to export the catalog using the Aucotec.Utils.CustomExport Sub.

The source is the following:

Public Sub CatalogExport()
Dim atParamData(0) As Aucotec.AucTPCCustomParam
Dim sFileName As String
Dim CatObj As ObjectItem

Set CatObj = Application.RootObject.Children("Catalogs";).Children(CATALOG_NAME)
sFileName = TEMP_FOLDER & CATALOG_NAME & ".ext"

If Dir(sFileName) <> "" Then Kill sFileName

atParamData(0).oOID = CatObj.ID
atParamData(0).nMethod = 1 'copy 0 or overwrite 1

Call Application.Utils.ExportCustom(sFileName, AucCustomOperationMode.aucCustomExportCatalog, atParamData)
End Sub

The question is the following:
I would like to create an custom import, using the Aucotec.Utils.CustomImport Sub, but I have some troubles defining the correct parameters of the Sub. Could someone help me for this ? I have the following source code at the moment:

Public Sub CatalogImport(TempFolder As String)
Dim atParamData(0) As Aucotec.AucTPCCustomParam
Dim aMapping(0) As Aucotec.AucDictMappingData
Dim sFileName As String
Dim CatObj As ObjectItem, CatObjs As ObjectItems
Dim DicObj As ObjectItem, DicObjs As ObjectItems

Set CatObjs = Application.RootObject.Children("Catalogs";).FindObjects(aucObjCatalog, aucSearchFlat, aucTypeUnspecified, aucAttrDesignation, aucCondEqual, CATALOG_NAME)
If CatObjs.count = 0 Then
Set CatObj = Application.RootObject.Children("Catalogs";).NewChild(aucObjCatalog, aucTypeUnspecified)
CatObj.Attributes.ItemByID(aucAttrDesignation) = CATALOG_NAME
CatObj.Store
End If
Set CatObj = Application.RootObject.Children("Catalogs";).Children(CATALOG_NAME)

Set DicObjs = Application.RootObject.Children("Dictionaries";).FindObjects(aucObjDictionary, aucSearchFlat, aucTypeUnspecified, aucAttrDesignation, aucCondEqual, DICTIONARY_NAME)
If DicObjs.count = 0 Then
Stop
Else
Set DicObj = DicObjs(1)
End If

sFileName = TempFolder & "\" & CATALOG_NAME & ".ext"

aMapping(0).sbDictNameFrom = DicObj.Name
'aMapping(0).nDictIdFrom = 3
aMapping(0).assocTypeFrom = aucDictAssocTypePrimary
'aMapping(0).MapToDict = DicObj

atParamData(0).oOID = CatObj.ID
atParamData(0).nMethod = 1 'copy 0 or overwrite 1

Call Application.Utils.ImportCustom(sFileName, AucCustomOperationMode.aucCustomImportCatalog, aMapping, atParamData)
Kill sFileName
End Sub


Thanks
Franco