VintaSoft Barcode .NET SDK 15.1: Руководство для .NET разработчика
Vintasoft.Barcode.SymbologySubsets Namespace / IsbtDonorGlobalRegistrationIdentifier Class
Члены типа Объект Синтаксис Example Иерархия Требования Смотрите также
В этом разделе
    Класс IsbtDonorGlobalRegistrationIdentifier
    В этом разделе
    Предоставляет информацию о глобальном регистрационном идентификаторе ISBT для доноров (структура данных 039).
    Объектная модель
    IsbtDataStructure IsbtDonorGlobalRegistrationIdentifier
    Синтаксис
    'Declaration
    
    Public Class IsbtDonorGlobalRegistrationIdentifier
       Inherits IsbtDataValue
    
    
    public class IsbtDonorGlobalRegistrationIdentifier : IsbtDataValue
    
    
    public __gc class IsbtDonorGlobalRegistrationIdentifier : public IsbtDataValue*
    
    
    public ref class IsbtDonorGlobalRegistrationIdentifier : public IsbtDataValue^
    
    
    Пример

    Вот C#/VB.NET код, который демонстрирует, как сгенерировать и распознать штрих-код ISBT 128, содержащий глобальный регистрационный идентификатор для доноров (структура данных 039):

    
    
    Imports Vintasoft.Barcode
    Imports Vintasoft.Barcode.BarcodeInfo
    Imports Vintasoft.Barcode.SymbologySubsets
    Imports Vintasoft.Imaging
    
    Class ISBT128DonorGlobalRegistrationIdentifierExample
        ''' <summary>
        ''' Generates and recognizes ISBT 128 barcode that contains Global Registration Identifier for Donors (Data Structure 039).
        ''' </summary>
        Public Shared Sub Test()
            ' create  ISBT Global Registration Identifier for Donors (Data Structure 039),
            ' checksum calculates automatically
            Dim donorGlobalRegistrationIdentifier As New IsbtDonorGlobalRegistrationIdentifier(1012, "ABCDEF1234567")
    
            ' create ISBT 128 barcode value
            Dim barcodeValue As New IsbtValueItem(donorGlobalRegistrationIdentifier)
    
            ' create barcode writer
            Using writer As New BarcodeWriter()
                ' encode ISBT 128 barcode to writer settings
                BarcodeSymbologySubsets.ISBT128.Encode(barcodeValue, writer.Settings)
    
                ' generate barcode image
                Using barcodeImage As VintasoftBitmap = writer.GetBarcodeAsVintasoftBitmap()
                    ' recognize barcode value
                    Dim recognizedValue As IsbtValueItem = Recognize(barcodeImage)
    
                    ' check value
                    If barcodeValue.ToString() <> recognizedValue.ToString() Then
                        Throw New ApplicationException()
                    End If
    
                    ' privt value
                    PrintValue(recognizedValue)
                End Using
            End Using
        End Sub
    
    
        ''' <summary>
        ''' Recognizes the ISBT 128 barcode from image.
        ''' </summary>
        ''' <param name="barcodeImage">The barcode image.</param>
        Private Shared Function Recognize(barcodeImage As VintasoftBitmap) As IsbtValueItem
            ' create barcode reader
            Using reader As New BarcodeReader()
                reader.Settings.ScanDirection = ScanDirection.Vertical Or ScanDirection.Horizontal
                reader.Settings.AutomaticRecognition = True
    
                ' specify that ISBT 128 barcode must be recognizeds
                reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.ISBT128)
                reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.ISBT128DataMatrix)
    
                ' recognize barcodes
                Dim info As IBarcodeInfo = reader.ReadBarcodes(barcodeImage)(0)
    
                ' return ISBT 128 value
                Return DirectCast(info, IsbtBarcodeInfo).IsbtValue
            End Using
        End Function
    
        ''' <summary>
        ''' Prints ISBT 128 barcode value.
        ''' </summary>
        ''' <param name="recognizedValue">The recognized value.</param>
        Private Shared Sub PrintValue(recognizedValue As IsbtValueItem)
            ' print value
            Console.WriteLine("Barcode value: " & recognizedValue.ToString())
            Dim value As IsbtDataValue() = recognizedValue.DataValues
            For Each dataValue As IsbtDataValue In value
                If TypeOf dataValue Is IsbtDonorGlobalRegistrationIdentifier Then
                    Dim donorGlobalRegistrationIdentifier As IsbtDonorGlobalRegistrationIdentifier = DirectCast(dataValue, IsbtDonorGlobalRegistrationIdentifier)
                    Console.WriteLine(String.Format("{0} ({1}):", dataValue.DataStructure.Name, dataValue.DataStructure.Number))
                    Console.WriteLine(String.Format("   GRID Issuing Organization Number: {0}", donorGlobalRegistrationIdentifier.GRIDIssuingOrganizationNumber))
                    Console.WriteLine(String.Format("   Registration Donor Identifier:    {0}", donorGlobalRegistrationIdentifier.RegistrationDonorIdentifier))
                    Console.WriteLine(String.Format("   Checksum:                         {0}", donorGlobalRegistrationIdentifier.Checksum))
                Else
                    Console.WriteLine(String.Format("{0} ({1}): {2}", dataValue.DataStructure.Name, dataValue.DataStructure.Number, dataValue.DataContent))
                End If
            Next
        End Sub
    End Class
    
    
    
    using System;
    
    using Vintasoft.Barcode;
    using Vintasoft.Barcode.BarcodeInfo;
    using Vintasoft.Barcode.SymbologySubsets;
    using Vintasoft.Imaging;
    
    class ISBT128DonorGlobalRegistrationIdentifierExample
    {
        /// <summary>
        /// Generates and recognizes ISBT 128 barcode that contains Global Registration Identifier for Donors (Data Structure 039).
        /// </summary>
        public static void Test()
        {
            // create  ISBT Global Registration Identifier for Donors (Data Structure 039),
            // checksum calculates automatically
            IsbtDonorGlobalRegistrationIdentifier donorGlobalRegistrationIdentifier = new IsbtDonorGlobalRegistrationIdentifier(1012, "ABCDEF1234567");
    
            // create ISBT 128 barcode value
            IsbtValueItem barcodeValue = new IsbtValueItem(donorGlobalRegistrationIdentifier);
    
            // create barcode writer
            using (BarcodeWriter writer = new BarcodeWriter())
            {
                // encode ISBT 128 barcode to writer settings
                BarcodeSymbologySubsets.ISBT128.Encode(barcodeValue, writer.Settings);
    
                // generate barcode image
                using (VintasoftBitmap barcodeImage = writer.GetBarcodeAsVintasoftBitmap())
                {
                    // recognize barcode value
                    IsbtValueItem recognizedValue = Recognize(barcodeImage);
    
                    // check value
                    if (barcodeValue.ToString() != recognizedValue.ToString())
                        throw new ApplicationException();
    
                    // privt value
                    PrintValue(recognizedValue);
                }
            }
        }
    
    
        /// <summary>
        /// Recognizes the ISBT 128 barcode from image.
        /// </summary>
        /// <param name="barcodeImage">The barcode image.</param>
        private static IsbtValueItem Recognize(VintasoftBitmap barcodeImage)
        {
            // create barcode reader
            using (BarcodeReader reader = new BarcodeReader())
            {
                reader.Settings.ScanDirection = ScanDirection.Vertical | ScanDirection.Horizontal;
                reader.Settings.AutomaticRecognition = true;
    
                // specify that ISBT 128 barcode must be recognizeds
                reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.ISBT128);
                reader.Settings.ScanBarcodeSubsets.Add(BarcodeSymbologySubsets.ISBT128DataMatrix);
    
                // recognize barcodes
                IBarcodeInfo info = reader.ReadBarcodes(barcodeImage)[0];
    
                // return ISBT 128 value
                return ((IsbtBarcodeInfo)info).IsbtValue;
            }
        }
    
        /// <summary>
        /// Prints ISBT 128 barcode value.
        /// </summary>
        /// <param name="recognizedValue">The recognized value.</param>
        private static void PrintValue(IsbtValueItem recognizedValue)
        {
            // print value
            Console.WriteLine("Barcode value: " + recognizedValue.ToString());
            IsbtDataValue[] value = recognizedValue.DataValues;
            foreach (IsbtDataValue dataValue in value)
            {
                if (dataValue is IsbtDonorGlobalRegistrationIdentifier)
                {
                    IsbtDonorGlobalRegistrationIdentifier donorGlobalRegistrationIdentifier = (IsbtDonorGlobalRegistrationIdentifier)dataValue;
                    Console.WriteLine(string.Format("{0} ({1}):", dataValue.DataStructure.Name, dataValue.DataStructure.Number));
                    Console.WriteLine(string.Format("   GRID Issuing Organization Number: {0}", donorGlobalRegistrationIdentifier.GRIDIssuingOrganizationNumber));
                    Console.WriteLine(string.Format("   Registration Donor Identifier:    {0}", donorGlobalRegistrationIdentifier.RegistrationDonorIdentifier));
                    Console.WriteLine(string.Format("   Checksum:                         {0}", donorGlobalRegistrationIdentifier.Checksum));
                }
                else
                {
                    Console.WriteLine(string.Format("{0} ({1}): {2}", dataValue.DataStructure.Name, dataValue.DataStructure.Number, dataValue.DataContent));
                }
            }
        }
    }
    
    

    Иерархия наследования

    System.Object
       Vintasoft.Barcode.SymbologySubsets.IsbtDataValue
          Vintasoft.Barcode.SymbologySubsets.IsbtDonorGlobalRegistrationIdentifier

    Требования

    Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также