Пример #1
0
        void pdf417Scanner_OnComplete(IList <IRecognitionResult> resultList)
        {
            Pdf417ScannerResult pluginResult = new Pdf417ScannerResult();

            pluginResult.cancelled  = false;
            pluginResult.resultList = new List <Pdf417ScannerBaseResult>();
            foreach (var recognitionResult in resultList)
            {
                if (recognitionResult.Valid && !recognitionResult.Empty)
                {
                    if (recognitionResult is PDF417RecognitionResult)
                    {
                        PDF417RecognitionResult    pdf417Result  = (PDF417RecognitionResult)recognitionResult;
                        Pdf417ScannerBarcodeResult barcodeResult = new Pdf417ScannerBarcodeResult();
                        barcodeResult.type = "PDF417";
                        barcodeResult.data = pdf417Result.StringData;
                        byte[] rawData = pdf417Result.RawData.GetAllData();
                        barcodeResult.raw = ByteArrayToHex(rawData);
                        pluginResult.resultList.Add(barcodeResult);
                    }
                    else if (recognitionResult is ZXingRecognitionResult)
                    {
                        ZXingRecognitionResult     zxingResult   = (ZXingRecognitionResult)recognitionResult;
                        Pdf417ScannerBarcodeResult barcodeResult = new Pdf417ScannerBarcodeResult();
                        barcodeResult.type = zxingResult.BarcodeTypeString;
                        barcodeResult.data = zxingResult.StringData;
                        pluginResult.resultList.Add(barcodeResult);
                    }
                    else if (recognitionResult is BarDecoderRecognitionResult)
                    {
                        BarDecoderRecognitionResult bcodeResult   = (BarDecoderRecognitionResult)recognitionResult;
                        Pdf417ScannerBarcodeResult  barcodeResult = new Pdf417ScannerBarcodeResult();
                        barcodeResult.type = bcodeResult.BarcodeTypeString;
                        barcodeResult.data = bcodeResult.StringData;
                        pluginResult.resultList.Add(barcodeResult);
                    }
                    else if (recognitionResult is USDLRecognitionResult)
                    {
                        USDLRecognitionResult   uResult    = (USDLRecognitionResult)recognitionResult;
                        Pdf417ScannerUSDLResult usdlResult = new Pdf417ScannerUSDLResult();
                        usdlResult.fields = new Dictionary <string, string>();
                        foreach (string key in uResult.Elements.Keys)
                        {
                            if (uResult.Elements[key] is string)
                            {
                                usdlResult.fields.Add(key, (string)uResult.Elements[key]);
                            }
                        }
                        pluginResult.resultList.Add(usdlResult);
                    }
                }
            }
            // dispatct JSON result
            string json = pluginResult.GetJSON();

            DispatchCommandResult(new PluginResult(PluginResult.Status.OK, json));
        }
 void pdf417Scanner_OnComplete(IList<IRecognitionResult> resultList)
 {
     Pdf417ScannerResult pluginResult = new Pdf417ScannerResult();
     pluginResult.cancelled = false;
     pluginResult.resultList = new List<Pdf417ScannerBaseResult>();
     foreach (var recognitionResult in resultList) {
         if (recognitionResult.Valid && !recognitionResult.Empty) {
             if (recognitionResult is PDF417RecognitionResult) {
                 PDF417RecognitionResult pdf417Result = (PDF417RecognitionResult)recognitionResult;
                 Pdf417ScannerBarcodeResult barcodeResult = new Pdf417ScannerBarcodeResult();
                 barcodeResult.type = "PDF417";
                 barcodeResult.data = pdf417Result.StringData;
                 byte[] rawData = pdf417Result.RawData.GetAllData();
                 barcodeResult.raw = ByteArrayToHex(rawData);
                 pluginResult.resultList.Add(barcodeResult);
             } else if (recognitionResult is ZXingRecognitionResult) {
                 ZXingRecognitionResult zxingResult = (ZXingRecognitionResult)recognitionResult;
                 Pdf417ScannerBarcodeResult barcodeResult = new Pdf417ScannerBarcodeResult();
                 barcodeResult.type = zxingResult.BarcodeTypeString;
                 barcodeResult.data = zxingResult.StringData;
                 pluginResult.resultList.Add(barcodeResult);
             } else if (recognitionResult is BarDecoderRecognitionResult) {
                 BarDecoderRecognitionResult bcodeResult = (BarDecoderRecognitionResult)recognitionResult;
                 Pdf417ScannerBarcodeResult barcodeResult = new Pdf417ScannerBarcodeResult();
                 barcodeResult.type = bcodeResult.BarcodeTypeString;
                 barcodeResult.data = bcodeResult.StringData;
                 pluginResult.resultList.Add(barcodeResult);
             } else if (recognitionResult is USDLRecognitionResult) {
                 USDLRecognitionResult uResult = (USDLRecognitionResult)recognitionResult;
                 Pdf417ScannerUSDLResult usdlResult = new Pdf417ScannerUSDLResult();
                 usdlResult.fields = new Dictionary<string,string>();
                 foreach (string key in uResult.Elements.Keys) {
                     if (uResult.Elements[key] is string) {
                         usdlResult.fields.Add(key, (string)uResult.Elements[key]);
                     }
                 }
                 pluginResult.resultList.Add(usdlResult);
             }
         }
     }
     // dispatct JSON result
     string json = pluginResult.GetJSON();
     DispatchCommandResult(new PluginResult(PluginResult.Status.OK, json));
 }