Ejemplo n.º 1
0
 public override Collection <SymbolData> EncodeData()
 {
     Symbol      = new Collection <SymbolData>();
     barcodeData = MessagePreProcessor.NumericOnlyParser(barcodeMessage);
     IntellgentMail();
     return(Symbol);
 }
Ejemplo n.º 2
0
 public override Collection <SymbolData> EncodeData()
 {
     Symbol      = new Collection <SymbolData>();
     barcodeData = MessagePreProcessor.TildeParser(barcodeMessage);
     Code93();
     return(Symbol);
 }
Ejemplo n.º 3
0
 public override Collection <SymbolData> EncodeData()
 {
     this.Symbol = new Collection <SymbolData>();
     barcodeData = MessagePreProcessor.NumericOnlyParser(barcodeMessage);
     ChannelCode();
     return(Symbol);
 }
        public async Task RunHandlerThrowsArgumentNullExceptionWhenMessageIsNull()
        {
            // Arrange
            var preProcessor = new MessagePreProcessor(processor, logService, propertiesService);

            // Act
            await Assert.ThrowsAsync <ArgumentNullException>(async() => await preProcessor.Process(null).ConfigureAwait(false)).ConfigureAwait(false);
        }
        public async Task RunHandlerThrowsArgumentOutOfRangeExceptionWhenMessageContentTypeIsInvalid()
        {
            // Arrange
            var message      = CreateBaseMessage(contentType: (MessageContentType)999);
            var preProcessor = new MessagePreProcessor(processor, logService, propertiesService);

            // Act
            await Assert.ThrowsAsync <ArgumentOutOfRangeException>(async() => await preProcessor.Process(message).ConfigureAwait(false)).ConfigureAwait(false);
        }
        public async Task RunHandlerThrowsArgumentExceptionWhenMessageBodyIsEmpty()
        {
            // Arrange
            var message      = new Message(Encoding.ASCII.GetBytes(string.Empty));
            var preProcessor = new MessagePreProcessor(processor, logService, propertiesService);

            // Act
            await Assert.ThrowsAsync <ArgumentException>(async() => await preProcessor.Process(message).ConfigureAwait(false)).ConfigureAwait(false);
        }
Ejemplo n.º 7
0
        public override Collection <SymbolData> EncodeData()
        {
            Symbol = new Collection <SymbolData>();
            switch (symbolId)
            {
            case Symbology.PostNet:
                barcodeData = MessagePreProcessor.NumericOnlyParser(barcodeMessage);
                PostNet();
                break;

            case Symbology.Planet:
                barcodeData = MessagePreProcessor.NumericOnlyParser(barcodeMessage);
                Planet();
                break;

            case Symbology.KoreaPost:
                barcodeData = MessagePreProcessor.NumericOnlyParser(barcodeMessage);
                KoreaPost();
                break;

            case Symbology.FIM:
                barcodeData = MessagePreProcessor.MessageParser(barcodeMessage);
                FIM();
                break;

            case Symbology.RoyalMail:
                barcodeData = MessagePreProcessor.MessageParser(barcodeMessage);
                RoyalMail();
                break;

            case Symbology.KixCode:
                barcodeData = MessagePreProcessor.MessageParser(barcodeMessage);
                KixCode();
                break;

            case Symbology.DaftCode:
                barcodeData = MessagePreProcessor.MessageParser(barcodeMessage);
                DaftCode();
                break;

            case Symbology.Flattermarken:
                barcodeData = MessagePreProcessor.NumericOnlyParser(barcodeMessage);
                Flattermarken();
                break;

            case Symbology.JapanPost:
                barcodeData = MessagePreProcessor.MessageParser(barcodeMessage);
                JapanPost();
                break;
            }

            return(Symbol);
        }
Ejemplo n.º 8
0
        public override Collection <SymbolData> EncodeData()
        {
            Symbol = new Collection <SymbolData>();
            switch (symbolId)
            {
            case Symbology.Code32:
                barcodeData        = MessagePreProcessor.NumericOnlyParser(barcodeMessage);
                optionalCheckDigit = false;      // Code 32 generates it's own check digit.
                Code32();
                break;

            case Symbology.PharmaZentralNummer:
                barcodeData        = MessagePreProcessor.NumericOnlyParser(barcodeMessage);
                optionalCheckDigit = false;     // PharmaZentral generates it's own check digit.
                PNZ();
                break;

            case Symbology.Code39:
                if (encodingMode == EncodingMode.HIBC)
                {
                    barcodeData        = MessagePreProcessor.HIBCParser(barcodeMessage);
                    optionalCheckDigit = true;      // HIBC requires a Code 39 check digit.
                    Code39();
                }

                else
                {
                    barcodeData = MessagePreProcessor.MessageParser(barcodeMessage);
                    Code39();
                }

                break;

            case Symbology.Code39Extended:
                barcodeData = MessagePreProcessor.TildeParser(barcodeMessage);
                Code39Extended();
                break;

            case Symbology.LOGMARS:
                barcodeData = MessagePreProcessor.MessageParser(barcodeMessage);
                Logmars();
                break;

            case Symbology.VINCode:
                barcodeData = MessagePreProcessor.MessageParser(barcodeMessage);
                VINCode();
                break;
            }

            return(Symbol);
        }
        public async Task RunHandlerLogsWarningWhenMessageProcessorReturnsError()
        {
            // Arrange
            var message       = CreateBaseMessage();
            var fakeProcessor = A.Fake <IMessageProcessor>();

            A.CallTo(() => fakeProcessor.ProcessAsync(A <string> .Ignored, A <long> .Ignored, A <MessageContentType> .Ignored, A <MessageActionType> .Ignored)).Returns(HttpStatusCode.InternalServerError);
            var messagePropertiesService = A.Fake <IMessagePropertiesService>();

            A.CallTo(() => messagePropertiesService.GetSequenceNumber(A <Message> .Ignored)).Returns(123);

            var preProcessor = new MessagePreProcessor(fakeProcessor, logService, propertiesService);

            // Act
            await preProcessor.Process(message).ConfigureAwait(false);

            // Assert
            A.CallTo(() => logService.LogWarning(A <string> .Ignored)).MustHaveHappenedOnceExactly();
        }
Ejemplo n.º 10
0
        public override Collection <SymbolData> EncodeData()
        {
            Symbol = new Collection <SymbolData>();
            switch (symbolId)
            {
            case Symbology.Pharmacode:
                barcodeData = MessagePreProcessor.NumericOnlyParser(barcodeMessage);
                PharmaOne();
                //barcodeText = new String(barcodeData);
                break;

            case Symbology.Pharmacode2Track:
                barcodeData = MessagePreProcessor.NumericOnlyParser(barcodeMessage);
                PharmaTwo();
                //barcodeText = new String(barcodeData);
                break;
            }

            return(Symbol);
        }
Ejemplo n.º 11
0
        public override Collection <SymbolData> EncodeData()
        {
            Symbol = new Collection <SymbolData>();
            switch (encodingMode)
            {
            case EncodingMode.Standard:
                isGS1       = false;
                barcodeData = MessagePreProcessor.TildeParser(barcodeMessage);
                Code16K();
                break;

            case EncodingMode.GS1:
                isGS1       = true;
                barcodeData = MessagePreProcessor.AIParser(barcodeMessage);
                Code16K();
                break;
            }

            return(Symbol);
        }
Ejemplo n.º 12
0
        public override Collection <SymbolData> EncodeData()
        {
            Symbol = new Collection <SymbolData>();
            switch (symbolId)
            {
            case Symbology.Telepen:
                barcodeData = MessagePreProcessor.TildeParser(barcodeMessage);
                Telepen();
                barcodeText = new String(barcodeData);
                break;

            case Symbology.TelepenNumeric:
                barcodeData = MessagePreProcessor.MessageParser(barcodeMessage);
                TelepenNumeric();
                barcodeText = new String(barcodeData);
                break;
            }

            return(Symbol);
        }
Ejemplo n.º 13
0
        public async Task RunHandlerLogsInformationWhenMessageProcessorReturnsSuccess(HttpStatusCode status)
        {
            // Arrange
            var message = CreateBaseMessage();
            var logger  = A.Fake <ILogService>();

            var processor = A.Fake <IMessageProcessor>();

            A.CallTo(() => processor.ProcessAsync(A <string> .Ignored, A <long> .Ignored, A <MessageContentType> .Ignored, A <MessageActionType> .Ignored)).Returns(status);

            var messagePropertiesService = A.Fake <IMessagePropertiesService>();

            A.CallTo(() => messagePropertiesService.GetSequenceNumber(A <Message> .Ignored)).Returns(123);

            // Act
            var messagePreProcessor = new MessagePreProcessor(processor, logger, messagePropertiesService);
            await messagePreProcessor.Process(message).ConfigureAwait(false);

            // Assert
            A.CallTo(() => logger.LogInformation(A <string> .Ignored)).MustHaveHappenedOnceExactly();
        }
Ejemplo n.º 14
0
        public override Collection <SymbolData> EncodeData()
        {
            Symbol = new Collection <SymbolData>();
            if (encodingMode == EncodingMode.GS1)   // PDF417 does not support GS1.
            {
                encodingMode = EncodingMode.Standard;
            }

            switch (encodingMode)
            {
            case EncodingMode.GS1:
                encodingMode = EncodingMode.Standard;       // PDF417 does not support GS1.
                barcodeData  = MessagePreProcessor.TildeParser(barcodeMessage);
                break;

            case EncodingMode.Standard:
                barcodeData = MessagePreProcessor.TildeParser(barcodeMessage);
                break;

            case EncodingMode.HIBC:
                barcodeData = MessagePreProcessor.HIBCParser(barcodeMessage);
                break;
            }

            switch (symbolId)
            {
            case Symbology.PDF417:
            case Symbology.PDF417Truncated:
                isTruncated = symbolId == Symbology.PDF417 ? false : true;
                PDF417();
                break;

            case Symbology.MicroPDF417:
                MicroPDF417();
                break;
            }

            return(Symbol);
        }
Ejemplo n.º 15
0
        public static void AddComposite(Symbology symbology, string message, Collection <SymbolData> encodedLinearData,
                                        CompositeMode compositeMode, int linearSymbolWidth)
        {
            int       dataColumns         = 0;
            int       eccLevel            = 0;
            int       compositeShiftCount = 0;
            int       linearShiftCount    = 0;
            BitVector bitStream;

            hostSymbol  = symbology;
            encodedData = encodedLinearData;
            linearWidth = linearSymbolWidth;

            compositeData = MessagePreProcessor.AIParser(message);
            int inputLength = compositeData.Length;

            if (inputLength > 2990)
            {
                throw new InvalidDataLengthException("2D Component: Input data too long.");
            }

            if ((compositeMode == CompositeMode.CCC) && (symbology != Symbology.Code128))
            {
                throw new DataEncodingException("2D Component: Invalid mode, CC-C only valid with a GS1-128 linear component.");
            }

            switch (symbology)
            {
            // Determine width of 2D component according to ISO/IEC 24723 Table 1.
            case Symbology.EAN8:
                dataColumns      = 3;
                linearShiftCount = 3;
                if (compositeMode == CompositeMode.CCB)
                {
                    linearShiftCount = 13;
                }

                break;

            case Symbology.EAN13:
                dataColumns      = 4;
                linearShiftCount = 2;
                break;

            case Symbology.UPCE:
                dataColumns      = 2;
                linearShiftCount = 2;
                break;

            case Symbology.UPCA:
                dataColumns      = 4;
                linearShiftCount = 3;
                break;

            case Symbology.Code128:
                dataColumns = 4;
                if (compositeMode == CompositeMode.CCC)
                {
                    linearShiftCount = 7;
                }

                break;

            case Symbology.DatabarOmni:
            case Symbology.DatabarTruncated:
                dataColumns      = 4;
                linearShiftCount = 4;
                break;

            case Symbology.DatabarLimited:
                dataColumns         = 3;
                compositeShiftCount = 0;
                break;

            case Symbology.DatabarExpanded:
                dataColumns         = 4;
                compositeShiftCount = 1;
                while ((encodedData[1].GetRowData()[compositeShiftCount - 1] == 0) && (encodedData[1].GetRowData()[compositeShiftCount] == 1))
                {
                    compositeShiftCount++;
                }

                break;

            case Symbology.DatabarStacked:
            case Symbology.DatabarOmniStacked:
                dataColumns         = 2;
                compositeShiftCount = 0;
                break;

            case Symbology.DatabarExpandedStacked:
                dataColumns         = 4;
                compositeShiftCount = 1;
                while ((encodedData[1].GetRowData()[compositeShiftCount - 1] == 0) && (encodedData[1].GetRowData()[compositeShiftCount] == 1))
                {
                    compositeShiftCount++;
                }

                break;
            }

            if (linearShiftCount > 0)
            {
                ShiftLinearHost(linearShiftCount);
            }

            bitStream = BitStreamEncoder.CompositeBitStream(symbology, compositeData, ref compositeMode, ref dataColumns, ref eccLevel, linearWidth);
            if (bitStream == null)
            {
                throw new InvalidDataLengthException();
            }

            switch (compositeMode)
            {
            // Note that eccLevel is only relevant to CC-C.
            case CompositeMode.CCA:
                CompositeA(bitStream, dataColumns, compositeShiftCount);
                break;

            case CompositeMode.CCB:
                CompositeB(bitStream, dataColumns, compositeShiftCount);
                break;

            case CompositeMode.CCC:
                CompositeC(bitStream, dataColumns, eccLevel);
                break;
            }
        }
Ejemplo n.º 16
0
        public override Collection <SymbolData> EncodeData()
        {
            Symbol = new Collection <SymbolData>();
            switch (symbolId)
            {
            case Symbology.Code128:
                switch (encodingMode)
                {
                case EncodingMode.Standard:
                    barcodeData = MessagePreProcessor.TildeParser(barcodeMessage);
                    Code128();
                    barcodeText = new String(barcodeData);
                    break;

                case EncodingMode.GS1:
                    isGS1       = true;
                    barcodeData = MessagePreProcessor.AIParser(barcodeMessage);
                    EAN128();
                    barcodeText = barcodeMessage;
                    barcodeText = barcodeText.Replace('[', '(');
                    barcodeText = barcodeText.Replace(']', ')');
                    break;

                case EncodingMode.HIBC:
                    barcodeData = MessagePreProcessor.HIBCParser(barcodeMessage);
                    Code128();
                    barcodeText = new String(barcodeData);
                    break;
                }

                break;

            case Symbology.EAN14:
                isCompositeSymbol = false;
                barcodeData       = MessagePreProcessor.MessageParser(barcodeMessage);
                EAN14();
                barcodeText = new string(barcodeData);
                break;

            case Symbology.SSCC18:
                isCompositeSymbol = false;
                barcodeData       = MessagePreProcessor.MessageParser(barcodeMessage);
                SSC18();
                barcodeText = new string(barcodeData);
                break;
            }

            // Expand the row pattern into the symbol data.
            SymbolBuilder.ExpandSymbolRow(Symbol, rowPattern, 0.0f);

            // Build the symbol separator and add the 2D component (GS1-128)
            if (isGS1 && isCompositeSymbol)
            {
                byte[] rowData = new byte[Symbol[0].GetRowData().Length];
                for (int i = 0; i < rowData.Length; i++)
                {
                    if (Symbol[0].GetRowData()[i] == 0)
                    {
                        rowData[i] = 1;
                    }
                }

                // Insert the separator to the symbol (top down ).
                SymbolData symbolData = new SymbolData(rowData, 1.0f);
                Symbol.Insert(0, symbolData);
                CompositeEncoder.AddComposite(symbolId, compositeMessage, Symbol, compositeMode, rowData.Length);
            }

            return(Symbol);
        }