I am using the ediFabric framework to generate Purchase orders in the X12 850 format version 040010. I am using the TS850 class and calling the ToEdi() method to generate the file. The only problem I am running into is that the performance for the method is poor(taking a couple hundred ms for each call) and I need to generate hundreds of files.
public string[] GeneratePurchaseOrders(TS850[] ts850s)
{
var settings = new X12WriterSettings();
var separators = Separators.X12;
separators.Segment = '~';
separators.ComponentDataElement = '>';
settings.Separators = Separators;
List<string> files = new List<string>(ts850s.Length);
for (var ts850 in ts850s)
{
files.Add(ts850.toEdi(settings));
}
return files.ToArray();
}
Is there a more efficient method for generating large numbers of files?
Why you are using the undocumented method ToEdi()? It's mentioned neither in the examples nor in the documentation, so I'm curious why you chose to utilize it.
ToEdi() first writes the EDI data to a stream and then loads the stream to a string.
For writing large messages out I would recommend using the async Write methods to write directly to a file or a stream.