public void TestParsingBelowMinimal()
        {
            BarCodeType         type        = BarCodeType.Interleaved25;
            NameValueCollection querystring = new NameValueCollection();

            querystring.Add(QueryStringSerializer.TYPE_KEY, type.ToString());

            IBarCodeSettings settings = QueryStringSerializer.ParseQueryString(querystring);
        }
Пример #2
0
 private ZXing.BarcodeFormat BarcodeToZxing(BarCodeType format)
 {
     foreach (ZXing.BarcodeFormat type in Enum.GetValues(typeof(ZXing.BarcodeFormat)))
     {
         if (format.ToString().Equals(type.ToString()))
         {
             return(type);
         }
     }
     return(ZXing.BarcodeFormat.QR_CODE);
 }
        public void TestParsingInvalidKey()
        {
            BarCodeType         type        = BarCodeType.Code128;
            string              data        = "123456";
            NameValueCollection querystring = new NameValueCollection();

            querystring.Add(QueryStringSerializer.TYPE_KEY, type.ToString());
            querystring.Add(QueryStringSerializer.DATA_KEY, data);
            querystring.Add("InvalidKey", "whatever");

            IBarCodeSettings settings = QueryStringSerializer.ParseQueryString(querystring);
        }
        public void TestParsingMinimal()
        {
            BarCodeType         type        = BarCodeType.Code128;
            string              data        = "123456";
            NameValueCollection querystring = new NameValueCollection();

            querystring.Add(QueryStringSerializer.TYPE_KEY, type.ToString());
            querystring.Add(QueryStringSerializer.DATA_KEY, data);

            IBarCodeSettings settings = QueryStringSerializer.ParseQueryString(querystring);

            Assert.AreEqual(type, settings.Type, "Barcode type differs");
            Assert.AreEqual(data, settings.Data, "Barcode data differs");
        }
Пример #5
0
        /// <summary>
        /// Default implementation of printing functionality.  For debugging purposes only.
        /// </summary>
        /// <param name="barCodeType"></param>
        /// <param name="descriptiveTextLines"></param>
        /// <param name="barCodeText"></param>
        /// <returns></returns>
        private string PrintDataToString(BarCodeType barCodeType, List <string> descriptiveTextLines, string barCodeText)
        {
            var output = new StringBuilder();

            output.AppendFormat("Type: {0}\n", barCodeType.ToString());

            for (int i = 0; i < descriptiveTextLines.Count; ++i)
            {
                output.AppendFormat("Text {0}: {1}\n", i, descriptiveTextLines[i]);
            }

            output.AppendLine(barCodeText);

            return(output.ToString());
        }
Пример #6
0
        /// <summary>
        /// See ILabelPrinter.GetPrintData.
        /// </summary>
        public override string GetPrintData(
            BarCodeType barCodeType,
            List <string> descriptiveTextLines,
            string barCodeText)
        {
            const string tag = ClassName + ".GetPrintData:";

            // Check arguments and fill with blanks if missing.
            //

            string zebraBarCodeDesignator;

            switch (barCodeType)
            {
            case BarCodeType.Code128:
                zebraBarCodeDesignator = ZplBarCodeDesignatorCode128;
                break;

            default:
                throw new ArgumentException(
                          tag + string.Format("BarCodeType {0} not supported.", barCodeType.ToString()));
            }

            descriptiveTextLines = (descriptiveTextLines == null) ? new List <string>() : descriptiveTextLines;
            barCodeText          = (barCodeText == null) ? string.Empty : barCodeText;

            // Load our 3 descriptive lines with text.
            //

            string descriptionLine1 = (descriptiveTextLines.Count < 1) ? string.Empty : descriptiveTextLines[0];
            string descriptionLine2 = (descriptiveTextLines.Count < 2) ? string.Empty : descriptiveTextLines[1];
            string descriptionLine3 = (descriptiveTextLines.Count < 3) ? string.Empty : descriptiveTextLines[2];

            // Generate output
            //

            string output = string.Format(
                PrintFormat,
                descriptionLine1,
                descriptionLine2,
                descriptionLine3,
                zebraBarCodeDesignator,
                barCodeText);

            return(output);
        }
Пример #7
0
        /// <summary>
        /// 检查证卡条码
        /// </summary>
        /// <param name="UserCode"></param>
        /// <param name="BoxNOs">输出,箱头号码,如:1,2....</param>
        /// <returns></returns>
        public static BarCodeType CheckCardType(string UserCode, ref string BoxNOs, out string UnitName, out string UserName)
        {
            DateTime dtStart    = DateTime.Now;
            string   LogMessage = "检查证卡条码:" + UserCode + "\r\n";

            BarCodeType rType = BarCodeType.无效;

            BoxNOs   = "";
            UnitName = ""; UserName = "";
            try
            {
                MonitorService_NoLocal.MonitorService_NoLocal obj = GetConnectionObj();

                int i = obj.CheckCardType(UserCode, ref BoxNOs, out UnitName, out UserName);
                //条码类型。0:无效, 1:厂方维修  2:管理员,3:交换员
                if (i == 2)
                {
                    rType = BarCodeType.管理员;
                }
                else if (i == 3)
                {
                    rType = BarCodeType.交换员;
                }

                LogMessage += "返回检查结果,条码类型:" + rType.ToString() + "\r\n";
            }
            catch (Exception ee)
            {
                LogInfo.Log.WriteInfo(LogInfo.LogType.Error, ee.ToString());
                LogMessage += "异常,内容:" + ee.ToString() + "\r\n";
            }

            TimeSpan ts = DateTime.Now - dtStart;

            LogMessage = "耗时 " + ts.ToString() + " 。\r\n" + LogMessage + "\r\n\r\n";
            LogInfo.Log.WriteFileLog(LogMessage);

            return(rType);
        }
Пример #8
0
 private ZXing.BarcodeFormat BarcodeToZxing(BarCodeType format)
 {
     foreach(ZXing.BarcodeFormat type in Enum.GetValues(typeof(ZXing.BarcodeFormat))){
         if(format.ToString().Equals(type.ToString())) return type;
     }
     return ZXing.BarcodeFormat.QR_CODE;
 }
Пример #9
0
        /// <summary>
        /// 返回条码的类型。如果是信件条码,同时返回可以接收的箱子号码
        /// </summary>
        /// <param name="BarCode">输入,扫描条码</param>
        /// <param name="boxs">输出,箱头号码和收件数量,如:21:1,22:3....</param>
        /// <returns>条码类型</returns>
        public static BarCodeType CheckBarCodeType(string BarCode, List <SendBoxList> boxs)
        {
            DateTime dtStart    = DateTime.Now;
            string   LogMessage = "检查条码:" + BarCode + "\r\n";

            BarCodeType rType = BarCodeType.无效;

            try
            {
                MonitorService_NoLocal.MonitorService_NoLocal obj = GetConnectionObj();

                string BoxNOs = "";
                int    iRet   = obj.CheckBarCodeType(BarCode, ref BoxNOs);
                if (iRet == 0)
                {
                    rType = BarCodeType.无效;
                }
                else if (iRet == 1)
                {
                    rType = BarCodeType.唯一直投;
                    if (BoxNOs != "")
                    {
                        string[] ar1 = BoxNOs.Split(',');
                        foreach (string s in ar1)
                        {
                            if (s.Trim() == "")
                            {
                                continue;
                            }
                            string[] ar2 = s.Split(':');
                            if (ar2.Length != 2)
                            {
                                continue;
                            }
                            try
                            {
                                SendBoxList sl = new SendBoxList();
                                sl.BoxNo = Convert.ToInt32(ar2[0]);
                                sl.Count = Convert.ToInt32(ar2[1]);
                                boxs.Add(sl);
                            }
                            catch
                            {
                            }
                        }
                        if (boxs.Count == 1)
                        {
                            rType = BarCodeType.唯一指定;
                        }
                        else if (boxs.Count > 1)
                        {
                            rType = BarCodeType.通码分发;
                        }
                    }
                }


                LogMessage += "返回检查结果,条码类型:" + rType.ToString() + "\r\n";
            }
            catch (Exception ee)
            {
                LogInfo.Log.WriteInfo(LogInfo.LogType.Error, ee.ToString());
                LogMessage += "异常,内容:" + ee.ToString() + "\r\n";
            }

            TimeSpan ts = DateTime.Now - dtStart;

            LogMessage = "耗时 " + ts.ToString() + " 。\r\n" + LogMessage + "\r\n\r\n";
            LogInfo.Log.WriteFileLog(LogMessage);

            return(rType);
        }
Пример #10
0
 public static BarcodeFormat BarcodeToZxing(BarCodeType format)
 {
     return Enum.GetValues(typeof(BarcodeFormat))
             .Cast<BarcodeFormat>().First(code => code.ToString().Equals(format.ToString()));
 }