示例#1
0
 private BarcodeData readDataDemand()
 {
     BarcodeData bCode = new BarcodeData();
     Byte[] dataByte = new Byte[10240];
     int size = 0;
     while (true)
     {
         try
         {
             if (data != null)
             {
                 size = data.Receive(dataByte);
                 if (size > 0)
                 {
                     bCode.DataBytes = dataByte;
                 }
             }
         }
         catch (SocketException ex)
         {
             textBox_status.AppendText(ex.ToString() + "\n");
         }
     }
 }
示例#2
0
 /// <summary>
 /// This is the function to write barcode data into file and it is called whenever there is an OnDataReceived event occurs.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dataReceived(object sender,OnDataReceivedEventArgs e)
 {
     try
     {
         barcodeData = new BarcodeData();
         barcodeData.DataBytes = e.data;
         WriteData(barcodeData.ToString() + "   " + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss:fff"));
         textBox_status.AppendText(barcodeData.ToString());
     }
     catch (Exception ex)
     {
         textBox_status.AppendText(ex.ToString() + "\n");
     }
     finally
     {
         getWriter(filePath).Close();
     }
 }
示例#3
0
 private void dataReceived(object sender,OnDataReceivedEventArgs e)
 {
     try
     {
         barcodeData = new BarcodeData();
         barcodeData.DataBytes = e.data;
         getWriter(filePath).WriteLine(barcodeData.ToString() + " " + new DateTime());
         getWriter(filePath).Flush();
         textBox_status.AppendText(barcodeData.ToString());
     }
     catch (Exception ex)
     {
         textBox_status.AppendText(ex.ToString() + "\n");
     }
     finally
     {
         getWriter(filePath).Close();
     }
 }
示例#4
0
文件: Form1.cs 项目: stellant/Barcode
 /// <summary>
 /// This is the function to write barcode data into file and it is called whenever there is an OnDataReceived event occurs.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void dataReceived(object sender,OnDataReceivedEventArgs e)
 {
     try
     {
         barcodeData = new BarcodeData();
         barcodeData.DataBytes = e.data;
         WriteData(barcodeData.ToString() + "   " + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss:fff"));
         textBox_status.AppendText(barcodeData.ToString());
     }
     catch (Exception ex)
     {
         WriteLog(ex.ToString() + Environment.NewLine + "   at " + DateTime.Now.ToString("dd-MM-yyyy HH:mm:ss:fff"));
         textBox_status.AppendText("Exception Occured. Please refer log file." + "\n");
     }
     finally
     {
         CloseData();
     }
 }