executeImportOperation() Method

Table of Contents

  1. Function
  2. Syntax
  3. Parameters
  4. Return Value
  5. Sample Code
  6. Remarks
  7. Possible Errors
  8. Related Methods

Function

  • Executes an import previously defined in the client’s database

Syntax

  • AeXMLBridge.executeImportOperation(AeClientImportDetail);

Parameters

Return Value

  • None

Sample Code

C#

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45

// this code demo will include a routine used to read in a CSV file and
// translate it to Hexadecimal format. You are free to use a different
// routine if you want

try
{
TAeBasicDataItem[] systemImports = ws.getSystemImportsBasic();
// retrieve a list of available Import Titles

System.IO.StreamReader myFile = new System.IO.StreamReader(@"C:\Temp\myData.csv");
// of course, you can place your file anywhere

string hexFile;
string outData = "0x";
// need to initialize the beginning of this string with '0x'

while ((hexFile = myFile.ReadLine()) != null)
{
outData += ConvertAsciiTextToHex(hexFile) + "0D0A";
// '0D0A' is the carriage return/linefeed for a new record
}

TAeClientImportDetail cid = new TAeClientImportDetail()
{
ImportOpTitle = systemImports[0].Name, // just selecting the first Import Operation
FileContents = outData
};

ws.executeImportOperation(cid);
}
catch(Exception ex)
{
MessageBox.Show(ex.Message);
}

private String ConvertAsciiTextToHex(string hex) // routine to convert ascii to hex
{
StringBuilder sBuffer = new StringBuilder();
for (int i =0; i < hex.Length; i++)
{
sBuffer.Append(Convert.ToInt32(hex[i]).ToString("x"));
}
return sBuffer.ToString().ToUpper();
}

VB.Net

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Dim systemImports As TAeBasicDataItem() = ws.getSystemImportsBasic()
' retrieve a list of available Import Titles

Dim myFile As System.IO.StreamReader = New System.IO.StreamReader("C:\Temp\myData.csv")
' of course, you can place your file anywhere

Dim hexFile As String
Dim outData As String = "0x"
' need to initialize the beginning of this string with '0x'

While (Not (myFile.ReadLine) Is Nothing)
outData = (outData + (ConvertAsciiTextToHex(hexFile) + "0D0A"))
' '0D0A' is the carriage return/linefeed for a new record
End While

Dim cid As TAeClientImportDetail = New TAeClientImportDetail
cid.FileContents = outData
cid.ImportOpTitle = systemImports(0).Name

Try
ws.executeImportOperation(cid)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try

Private Function ConvertAsciiTextToHex(ByVal hex As String) As String
Dim sBuffer As StringBuilder = New StringBuilder()

For i As Integer = 0 To hex.Length - 1
sBuffer.Append(Convert.ToInt32(hex(i)).ToString("x"))
Next

Return sBuffer.ToString().ToUpper()
End Function

Remarks

  • the file being passed in the FileContents parameter must be converted to Hexadecimal format. The first byte must be set to ‘0x’
  • also make note of adding the hex code ‘0D0A’ (carriage return/line feed) to the end of each line
  • use getSystemImportsBasic to retrieve a list of system imports

Possible Errors

  • executeImportOperation (0x prefix not present)
  • executeImportOperation (Minimum 2 Characters Required)

executeExportOperation
executeExportOperationStrings
executeReportOperation
executeVendorOperation
getSystemExportsBasic
getSystemImportsBasic
getSystemReportsBasic
getSystemVendorOpsBasic

Back to Top