Using Companalytics.X9 library to read X9 file

I posted this in the regular forums a while back and haven’t gotten any replies. Maybe one of our experience MVPs has some ideas.

I have been tasked with automating in an X9 reader app. However, I also found a library that appears to allow directly parsing these files.

There is example code:

string path = @"C:\Temp\sample.x9";
string imageOutDir = @"C:\Temp\SampleCheckImages";
using (Stream x9File = File.OpenRead(path))
using (X9Reader reader = new X9Reader(x9File))
{
    doc = reader.ReadX9Document();
    reader.WriteImagesToDisk(imageOutDir);
}

How would I translate this into an Invoke Code?

Here is something typical in vb.net that can be called within invoke code.

Dim path As String = "C:\Temp\sample.x9"
Dim imageOutDir As String = "C:\Temp\SampleCheckImages"

Using x9File As Stream = File.OpenRead(path)
    Using reader As New X9Reader(x9File)
        Dim doc As X9Document = reader.ReadX9Document()
        reader.WriteImagesToDisk(imageOutDir)
    End Using
End Using

What im thinking is that you would pass in two input arguments named path and imageOutDir as strings to the InvokeCode activity. Therefore first two lines can be removed.

The output really depends on how you want to handle it.
The image output path can be checked to see if the image exists and if not the code throws an exception.

Or the next step in the calli flow in the calling flow will check for the image and take action accordingly.

Thanks

3 Likes

Thank you so much, this got me very close. I don’t actually need to write out the images, but now I am able to do the basic step of reading the file and then having the X9Document object to work with.

1 Like

Excellent! I’m glad it helped Paul!

Thanks for the update. :slight_smile: :+1:
-Andy

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.