Beispiel #1
0
    void ReaderCallback(string evnt, Object value, Object obj)
    {
        if (value == null)
        {
            return;
        }
        switch (evnt)
        {
        case "error":
            // throw new Exception(value.ToString());  // TEMP TEST - Goes nowhere
            errors++;
            WAUtils.printLine();
            WAUtils.printLine("ERROR: " + value.ToString());
            break;

        case "barcodes":
            count++;
            if (showBarcodes != null)
            {
                showBarcodes((WABarcode[])value);
            }
            break;

        default:
            DiagCallback(evnt, value, obj);
            break;
        }
    }
Beispiel #2
0
    static void Main(string[] args)
    {
        WAUtils.fncPrintLine = AppendTextBox;

        // Configure server
        string          authorization = "";
        string          serverUrl     = "";
        WABarcodeReader reader        = new WABarcodeReader(serverUrl, authorization);

        // Configure test
        Test test = new Test();

        // test.showBarcodes = null;                    // suppress show barcodes
        reader.diagCallback = test.DiagCallback;        // Enable display processing status

/*
 *          test.bTestDropBox = false;
 *          test.bTestBase64 = false;
 *          test.bTestSamplesLocal = false;
 *          test.bTestSamplesWeb = false;
 *          test.bTestUtf8 = false;
 *          test.bTestUtf8Names = false;
 */

        // Test asynchronous API
        test.Run(reader, true);

        // Test synchronous API
        test.Run(reader, false);

        WAUtils.printLine("DONE!");
        Console.Write("Hit Enter> "); Console.ReadLine();
    }
Beispiel #3
0
 internal static void ShowBarcodes(WABarcode[] barcodes)
 {
     foreach (WABarcode barcode in barcodes)
     {
         WAUtils.printLine();
         WAUtils.printLine("Barcode Type:" + barcode.Type + "  File:" + barcode.File + "   Page:" + barcode.Page.ToString());
         WAUtils.printLine(barcode.Text);
         if (barcode.Values.Count > 0)
         {
             WAUtils.printLine("\n VALUES:");
             foreach (string key in barcode.Values.Keys)
             {
                 WAUtils.printLine(key + " : " + barcode.Values[key]);
             }
         }
     }
 }
Beispiel #4
0
    internal void DiagCallback(string evnt, Object value, Object obj)
    {
        string image = "";

        if (value == null)
        {
            return;
        }
        if (!bShowDiag)
        {
            return;
        }
        switch (evnt)
        {
        case "image":
            image = value.ToString();
            WAUtils.printLine("================= PROCESSING:  " + WAUtils.signature(image));
            break;

        case "response":
            image = (string)obj;
            if (value.GetType() == typeof(string))
            {
                WAUtils.printLine("\n ==== > " + "ERROR: " + value.ToString() + WAUtils.signature(image));
            }
            else
            {
                System.Net.HttpWebResponse result = (System.Net.HttpWebResponse)value;
                if ((int)result.StatusCode == 200)
                {
                    WAUtils.printLine(" ==== > " + "SUCCESS - status: " + ((int)result.StatusCode).ToString() + "  " + result.StatusDescription
                                      + WAUtils.signature(image));
                }
                else
                {
                    WAUtils.printLine(" ==== > " + "ERROR   - status: " + ((int)result.StatusCode).ToString() + "  " + result.StatusDescription
                                      + WAUtils.signature(image));
                }
            }
            break;
        }
        return;
    }
Beispiel #5
0
 internal static string FileToBase64(string file)
 {
     try
     {
         FileStream fs        = new FileStream(file, FileMode.Open, FileAccess.Read);
         byte[]     filebytes = new byte[fs.Length];
         fs.Read(filebytes, 0, Convert.ToInt32(fs.Length));
         string base64 = Convert.ToBase64String(filebytes, Base64FormattingOptions.InsertLineBreaks);
         string ext    = Path.GetExtension(file).Replace(".", "");
         base64 = "data:image/" + ext + ";base64," + base64;
         // Optionally attach suffix with reference file name to be placed in Barcode.File property
         base64 = base64 + ":::" + Path.GetFileName(file);
         return(base64);
     }
     catch (Exception ex)
     {
         WAUtils.printLine();
         WAUtils.printLine(ex.Message);
         return("");
     }
 }
Beispiel #6
0
 static void ShowError(Exception ex)
 {
     WAUtils.printLine();
     WAUtils.printLine("EXCEPTION: " + ex.Message);
 }