Skip to content

Client framework for IRBIS64 system ported to .NET 8

License

Notifications You must be signed in to change notification settings

amironov73/ManagedIrbis5

Repository files navigation

ManagedIrbis5

Client framework for IRBIS64 system ported to .NET 8

Currently supports:

  • Windows 10/11 x64/x86/arm64
  • Windows Server 2012 and newer
  • Various Linuxes: Debian 11+, Fedora 37+, openSUSE 15+, RHEL 8+, Ubuntu 20.04+
  • MacOS 10.15 x64/arm64 and newer
  • .NET runtime 8.0.0 and higher
  • .NET SDK 8.0.100 and higher
using System;
using ManagedIrbis;
using static System.Console;
using static AM.Utility;
using static ManagedIrbis.IrbisUtility;

try
{
    await using var connection = ConnectionFactory.Shared.CreateAsyncConnection();

    connection.Host = args.Length == 0 ? "127.0.0.1" : args[0];
    connection.Username = RequireEnvironment ("IRBIS_LOGIN");
    connection.Password = RequireEnvironment ("IRBIS_PASSWORD");

    var success = await connection.ConnectAsync();
    if (!success)
    {
        // Can't connect to the IRBIS64 server, print the error message and exit with error code
        await Error.WriteLineAsync ("Can't connect");
        await Error.WriteLineAsync (IrbisException.GetErrorDescription (connection.LastError));
        return 1;
    }

    await Out.WriteLineAsync ("Successfully connected");

    // We are looking for all books authored by A. S. Pushkin
    // Notice the double quotes in the query text
    var found = await connection.SearchAsync
        (
            "\"A=ПУШКИН$\""
        );

    await Out.WriteLineAsync ($"Records found: {found.Length}");

    // In order not to print all found records,
    // we will select only the first 10
    foreach (var mfn in found[..10])
    {
        // Get the record from the IRBIS64 server
        var record = await connection.ReadRecordAsync (mfn);

        if (record is not null)
        {
            // Extract from the record the field and subfield
            var title = record.FM (200, 'a');
            await Out.WriteLineAsync ($"Title: {title}");
        }

        // Format the record using the IRBIS64 server
        var description = await connection.FormatRecordAsync
            (
                "@brief",
                mfn
            );
        await Out.WriteLineAsync ($"Bibliorgaphical description: {description}");

        await Out.WriteLineAsync(); // Add empty line
    }

    // Disconnect from the server
    await connection.DisposeAsync();
    await Out.WriteLineAsync ("Successfully disconnected");
}
catch (Exception exception)
{
    await Error.WriteLineAsync (exception.ToString());
    return 1;
}

return 0;

Build status

Codacy Badge Build status GitHub Action FOSSA Status Maintainability CodeFactor

License

FOSSA Status