EdifactParserCLI en
Attention! This article, as well as this announcement, are automatically translated from Russian.
Preparing a command line application for translation from EDIFACT to XML. Can be used to translate from an EDIFACT file to XML files of translated messages (each message in a separate file), placed in a specified target directory. File names are assigned from data element 0062
of the UNH
message header. Applies only to batch sessions.
-
public static async Task RunAsync(string[] args, Action<IHostApplicationBuilder>? configHostBuilder = null, Action<IServiceProvider>? configApp = null)
- called when the executable starts and does all the work.
In the case where the EDIFACT XML Schema directory, input file, and target directory are all on the local file system, no additional action is required. That is, when using top-level operators, the entire application code looks like this:
using Net.Leksi.Edifact;
await EdifactParserCLI.RunAsync(args);
If, for example, the EDIFACT XML schema directory or the input file or target directory is in the cloud, then additional arguments must be used:
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Net.Leksi.Edifact;
using Net.Leksi.Streams;
await EdifactParserCLI.RunAsync(args, ConfigHostBuilder);
void ConfigHostBuilder(IHostApplicationBuilder builder)
{
builder.Services.AddKeyedSingleton<IStreamFactory, S3FileStreamFactory>("s3");
}
After this, you can use a Uri
like: s3://bucket/path
. (The S3FileStreamFactory
class is given as an example; if necessary, you should implement it yourself, or write an adapter to some existing functionality)
The configApp
argument should be used if any additional configuration of the added factory is required using previously injected dependencies.
When running a compiled application without parameters, we get brief instructions:
All parameters in one way or another correspond to properties in the EdifactParserOptions class, so we will omit the details.
Let's translate one session:
XML message files have appeared.