Skip to content

EdifactParserCLI en

Leksiqq edited this page Apr 6, 2024 · 4 revisions

Attention! This article, as well as this announcement, are automatically translated from Russian.

Class EdifactParserCLI

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.

Methods

  • 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.

Launch and command line options

When running a compiled application without parameters, we get brief instructions: 2024-04-06_14-40-06

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: 2024-04-06_14-43-14

XML message files have appeared.

Review | To the top of the page

Clone this wiki locally