Ejemplo n.º 1
0
 public Task <Tuple <bool, X18J52, string> > Query18J52(X18J52 x18J52)
 {
     return(Task.Run(() =>
     {
         bool succ = false;
         X18J52 resp_18J52 = null;
         string msg = "查询失败!";
         try
         {
             //Hashtable hashtable = new Hashtable();
             //string queryxml = $"<?xml version=\"1.0\" encoding=\"GBK\"?><root><QueryCondition><hphm>{x18J52?.hphm}</hphm>" +
             //    $"<hpzl>{x18J52?.hpzl}</hpzl><clsbdh>{x18J52?.clsbdh}</clsbdh><dly>{x18J52?.dly}</dly><dlysfzh></dlysfzh></QueryCondition></root>";
             //hashtable.Add("xtlb", "18");
             //hashtable.Add("jkxlh", "");
             //hashtable.Add("jkid", "18J52");
             //hashtable.Add("xmlDoc", queryxml);
             //WebServiceUtils webServiceTools = new WebServiceUtils();
             //var respXml = HttpUtility.HtmlDecode(webServiceTools.SoapMethod(AppHelper.AppSetting.Namespace, AppHelper.AppSetting.WebServiceUrl, "queryObjectOut", hashtable));
             var respXml = "<?xml version=\"1.0\" encoding=\"utf - 8\"?><root><head><code>1</code><message>获取机动车上线登录信息成功</message><rownum>1</rownum></head><body><vehispara><jylsh>110002190227002940101</jylsh><jcxdh>1</jcxdh><xh>11010013239237</xh><hpzl>02</hpzl><hphm>京PWG759</hphm>" +
                           "<clsbdh>LS4ASB3RXDA636379</clsbdh><fdjh>D30J018164</fdjh><csys>B</csys><syxz>A</syxz><rlzl>A</rlzl><gl>72.0</gl><zs>2</zs><zj>2605</zj><qlj>1425</qlj><hlj>1435</hlj><zzl>1880</zzl><zbzl>1175</zbzl><ccrq>2013-02-25 00:00:00.000</ccrq><qdxs>1</qdxs><zczs>1</zczs>" +
                           "<zczw>2</zczw><zzs>2</zzs><zzly>0</zzly><qzdz>03</qzdz><ygddtz>0</ygddtz><zxzxjxs>0</zxzxjxs><lcbds>177267</lcbds><jyxm>F1,H1,H4,B1,B2,B0,DC,C1</jyxm><jylb>01</jylb><bhgx/><jycs>1</jycs><clpp1>长安牌</clpp1><clxh>SC6418HVB5</clxh><syr>曹洪喜</syr>" +
                           "<cllx>K39</cllx><cwkc>4110</cwkc><cwkk>1690</cwkk><cwkg>1930</cwkg><clyt>P1</clyt><ytsx>9</ytsx><clsslb>01</clsslb><wjbhgx/><wjjywhx/><dpbhgx/><dpjywhx/><dtdpbhgx/><dtdpjywhx/><wjpd>1</wjpd><dppd>0</dppd><dtdppd>0</dtdppd><wjy>李冬</wjy>" +
                           "<dpjyy/><dtdpjyy/><zkrs>5</zkrs><ccdjrq>2013-03-15 00:00:00.000</ccdjrq><Hdzzl>0</Hdzzl><pdyj>2</pdyj><xbwjbhgx/><xbdpbhgx/><xbdtdpbhgx/><qzs>1</qzs><ywcjyxm>F1</ywcjyxm><rgwjxm>OOOOO---O------OOOOOOOO------------------</rgwjxm><rgdtdpxm>OOOO</rgdtdpxm>" +
                           "</vehispara></body></root>";
             var code = Utils.RegexUtils.MatchField(respXml, "code", false);
             if ("1" == code)
             {
                 resp_18J52 = Utils.RegexUtils.XmlToModelByName <X18J52>(respXml);
                 msg = Utils.RegexUtils.MatchField(respXml, "message", false);
                 succ = true;
             }
             else if (string.IsNullOrEmpty(code))
             {
                 msg += respXml;
             }
             else
             {
                 msg += Utils.RegexUtils.MatchField(respXml, "message", false);
             }
         }
         catch (WebException wex)
         {
             succ = false;
             msg = wex.Message;
         }
         catch (Exception ex)
         {
             succ = false;
             msg = ex.Message;
         }
         return new Tuple <bool, X18J52, string>(succ, resp_18J52, msg);
     }));
 }
Ejemplo n.º 2
0
 public Task <ResponseModel> Query18J52(X18J52 x18J52)
 {
     return(Task.Run(async() =>
     {
         ResponseModel responseModel = new ResponseModel();
         var result = await queryService.Query18J52(x18J52);
         responseModel.Code = result.Item1 ? 1 : 0;
         responseModel.Data = result.Item2;
         responseModel.Message = result.Item3;
         return responseModel;
     }));
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 方法:扫码线程方法
        /// </summary>
        private void DecodeThreadMethod()
        {
            string decoderesult = null;
            //ShowRichTextBoxMsgRef ShowRichTextBoxMsgRef_Instance = new ShowRichTextBoxMsgRef(ShowRichTextBoxMsg);
            UpdateCaptionControl updateCaptionControl = new UpdateCaptionControl(UpdateMsg);

            do
            {
                //+ Environment.NewLine
                decoderesult = Decoder();
                if (decoderesult != null)
                {
                    try
                    {
                        // decoderesult = new string(decoderesult.Where(c => !Char.IsWhiteSpace(c)).ToArray());
                        X18J52 x18J52 = JsonConvert.DeserializeObject <X18J52>(decoderesult.Substring(1, decoderesult.Length - 1));
                        //this.Invoke(ShowRichTextBoxMsgRef_Instance, new object[] { this.richTextBox1, decoderesult + Environment.NewLine });
                        PropertyInfo[] propertyInfos = x18J52.GetType().GetProperties();
                        foreach (var item in propertyInfos)
                        {
                            foreach (var con in panel1.Controls)
                            {
                                if (con is CaptionLabel)
                                {
                                    CaptionLabel captionLabel = con as CaptionLabel;
                                    if (captionLabel.Tag.ToString().Equals(item.Name))
                                    {
                                        object obj = item.GetValue(x18J52, null);
                                        string str = obj == null ? "" : obj.ToString();
                                        this.Invoke(updateCaptionControl, new object[] { captionLabel, str });
                                    }
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        foreach (var con in panel1.Controls)
                        {
                            if (con is CaptionLabel)
                            {
                                CaptionLabel captionLabel = con as CaptionLabel;
                                this.Invoke(updateCaptionControl, new object[] { captionLabel, "" });
                            }
                        }
                    }
                    decoderesult = null;
                }
            }while (bIsLoop);
        }
Ejemplo n.º 4
0
        private void btnPrint_Click(object sender, EventArgs e)
        {
            if (!validator1.Validate())
            {
                return;
            }
            string      hpzl       = combQueryPlateType.Text;
            LoadingForm frmLoading = new LoadingForm("正在打印...");

            frmLoading.BackgroundWorkAction = delegate()
            {
                using (MemoryStream memoryStream = new MemoryStream())
                {
                    try
                    {
                        frmLoading.CurrentMsg = new KeyValuePair <int, string>(10, "正在打印...");
                        byte[] buffer = null;
                        if (picQRCode.BackgroundImage != null)
                        {
                            picQRCode.BackgroundImage.Save(memoryStream, ImageFormat.Png);
                            buffer = new byte[memoryStream.Length];
                            memoryStream.Seek(0, SeekOrigin.Begin);
                            memoryStream.Read(buffer, 0, buffer.Length);
                        }
                        frmLoading.CurrentMsg = new KeyValuePair <int, string>(40, "正在打印...");
                        X18J52 x18J52 = new X18J52();
                        carFiller.FillEntity(x18J52);
                        CreatePDF(x18J52, hpzl, buffer);
                        frmLoading.CurrentMsg = new KeyValuePair <int, string>(100, "正在打印...");
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            };
            frmLoading.ShowDialog();
        }
Ejemplo n.º 5
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            //查询前清空之前的数据
            picQRCode.BackgroundImage = null;
            carFiller.DisplayEntity(null);

            string hphm      = combQueryAera.Text + txtQueryPlateNo.Text.Trim();
            string vin       = txtQueryVIN.Text.Trim();
            string hpzl      = AppHelper.GetCodeByName(combQueryPlateType.Text, "HPZL");
            string result    = "";
            string loginUser = "";


            LoadingForm frmLoading = new LoadingForm("正在查询...");

            frmLoading.BackgroundWorkAction = delegate()
            {
                try
                {
                    frmLoading.CurrentMsg = new KeyValuePair <int, string>(10, "正在查询...");
                    NetHelper netHelper = new NetHelper();
                    result = netHelper.QueryCar(hphm, hpzl, loginUser, vin);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("查询时出现错误:" + ex.Message);
                }
            };
            frmLoading.ShowDialog();

            if (string.IsNullOrEmpty(result))
            {
                MessageBox.Show("查询结果为空");
                return;
            }

            File.WriteAllText("18J52.txt", result);

            result = HttpUtility.HtmlDecode(result);
            string code = RegexXML.MatchField(result, "code", false);

            if ("1".Equals(code))
            {
                X18J52 x18J52 = RegexXML.XmlToModelByName <X18J52>(result);
                string js     = JsonConvert.SerializeObject(x18J52);
                Bitmap bitmap = Live0xUtils.QRCodeUtils.QRCodeHelper.CreateCode(js, -1, 3, true);
                picQRCode.BackgroundImage = bitmap;

                DateTime d;
                if (x18J52.ccrq != null && DateTime.TryParse(x18J52.ccrq, out d))
                {
                    x18J52.ccrq = d.ToString("yyyy年MM月dd日");
                }

                if (x18J52.ccdjrq != null && DateTime.TryParse(x18J52.ccdjrq, out d))
                {
                    x18J52.ccdjrq = d.ToString("yyyy年MM月dd日");
                }

                x18J52.cllx = AppHelper.GetNameByCode(x18J52.cllx, "CLZL");
                x18J52.hpzl = AppHelper.GetNameByCode(x18J52.hpzl, "HPZL");

                carFiller.DisplayEntity(x18J52);
            }
            else if (string.IsNullOrEmpty(code))
            {
                MessageBox.Show("查询信息为空" + result);
            }
            else
            {
                MessageBox.Show(RegexXML.MatchField(result, "message", false));
            }
        }
Ejemplo n.º 6
0
        private void CreatePDF(X18J52 x18J52, string hpzl, byte[] qrcode)
        {
            PdfHelper    pdfHelper    = new PdfHelper();
            Document     doc          = pdfHelper.CreateDocumentA4();
            MemoryStream memoryStream = new MemoryStream();
            PdfWriter    writer       = PdfWriter.GetInstance(doc, memoryStream);

            try
            {
                doc.Open();
                doc.NewPage();

                BaseFont             ArialFont = BaseFont.CreateFont("STZHONGS.TTF", BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
                iTextSharp.text.Font BoldFont  = new iTextSharp.text.Font(ArialFont, 11, iTextSharp.text.Font.NORMAL, new BaseColor(System.Drawing.Color.Black));

                //二维码
                iTextSharp.text.Image img = pdfHelper.CreateImage(qrcode, 100, 100f);
                img.SetAbsolutePosition(AppHelper.PointSetting.X_QRCode, AppHelper.PointSetting.Y_QRCode);
                doc.Add(img);

                PrintPoint     print = AppHelper.PointSetting;
                PdfContentByte pb    = writer.DirectContent;
                pb.BeginText();
                pb.SetFontAndSize(ArialFont, 9);
                pb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, DateTime.Now.ToString("yyyy"), print.X_Year, print.Y_Year, 0);
                pb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, DateTime.Now.ToString("MM"), print.X_Month, print.Y_Month, 0);
                pb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, DateTime.Now.ToString("dd"), print.X_Day, print.Y_Day, 0);
                pb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, x18J52.hphm, print.X_PlateNo, print.Y_PlateNo, 0);
                pb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, x18J52.syr, print.X_Owner, print.Y_Owner, 0);
                pb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, hpzl, print.X_PlateType, print.Y_PlateType, 0);
                pb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, "", print.X_PlateColor, print.Y_PlateColor, 0);
                pb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, x18J52.cllx, print.X_CarType, print.Y_CarType, 0);
                pb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, x18J52.clpp1, print.X_CarBrand, print.Y_CarBrand, 0);
                pb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, x18J52.clxh, print.X_CarMold, print.Y_CarMold, 0);
                pb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, x18J52.ccdjrq, print.X_RegisterDate, print.Y_RegisterDate, 0);
                pb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, x18J52.ccrq, print.X_MakeDate, print.Y_MakeDate, 0);
                pb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, x18J52.zzl, print.X_Weight, print.Y_Weight, 0);
                pb.ShowTextAligned(PdfContentByte.ALIGN_LEFT, x18J52.zbzl, print.X_KerbWeight, print.Y_KerbWeight, 0);

                pb.EndText();

                doc.Close();
                MemoryStream pdf     = new MemoryStream(memoryStream.ToArray());
                PDFFile      pdfFile = PDFFile.Open(pdf);

                PrinterSettings settings = new PrinterSettings();
                PrintDocument   pd       = new PrintDocument();
                settings.PrinterName = AppHelper.AppSetting.PrinterName;
                settings.PrintToFile = false;

                PDFPrintSettings pdfPrintSettings = new PDFPrintSettings(settings);
                pdfPrintSettings.PageScaling            = PageScaling.MultiplePagesPerSheetProportional;
                pdfPrintSettings.PrinterSettings.Copies = 1;
                pdfFile.Print(pdfPrintSettings);
                pdf.Close();
                pdf.Dispose();
                pdfFile.Dispose();
            }
            catch (Exception ex)
            {
                MessageBox.Show("打印异常" + ex.Message);
            }
            finally
            {
                memoryStream.Dispose();
                memoryStream.Close();
                writer.Dispose();
                doc.Dispose();
                doc.Close();
            }
        }
Ejemplo n.º 7
0
 private void Print(string s)
 {
     try
     {
         ControlHelper.ThreadInvokerControl(this, () =>
         {
             lock (_lockObj)
             {
                 try
                 {
                     X18J52 entity = JsonConvert.DeserializeObject <X18J52>(s);
                     if (entity != null)
                     {
                         LogHelper.Trace($"处理数据[{entity.hphm}][{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}]");
                         if (_dicPlateNo.ContainsKey(entity.hphm))
                         {
                             LogHelper.Trace($"上次处理时间[{entity.hphm}][{_dicPlateNo[entity.hphm].ToString("yyyy-MM-dd HH:mm:ss")}]");
                         }
                         else
                         {
                             LogHelper.Trace($"没有重复记录[{entity.hphm}]");
                         }
                         if (_dicPlateNo.ContainsKey(entity.hphm) && _dicPlateNo[entity.hphm].AddSeconds(8) >= DateTime.Now)
                         {
                             LogHelper.Trace("重复扫码");
                         }
                         else
                         {
                             _dicPlateNo[entity.hphm] = DateTime.Now;
                             LogHelper.Trace("开始取号……");
                             string ticketType = "普通车".Equals(entity.BusinessType) ? "B" : "A";
                             CallEntity call   = CallService.GetNo(ticketType, entity.hphm);
                             CallOptForm callOptForm;
                             if ("1".Equals(call.State))
                             {
                                 callOptForm = new CallOptForm(entity.hphm, call.ClientId, call.WaitCount);
                                 try
                                 {
                                     string ticket         = ("B".Equals(ticketType) ? "普通车" : "网约车") + $":{call.ClientId}";
                                     ApplyTable applyTable = new ApplyTable(new CarInfo()
                                     {
                                         PlateNo   = entity.hphm,
                                         Owner     = entity.syr,
                                         PlateType = AppHelper.GetNameByCode(entity.hpzl, "HPZL")
                                     }, ticket);
                                     applyTable.PrintMsg();
                                 }
                                 catch (Exception ex)
                                 {
                                     LogHelper.Error($"打印异常:{ex.Message}");
                                 }
                             }
                             else
                             {
                                 callOptForm = new CallOptForm(entity.hphm, $"异常代码{call.State}", $"异常代码{SHDic.GetSHDeifine(call.State) ?? "未定义异常"}");
                             }
                             callOptForm.ShowDialog(this);
                             _dicPlateNo[entity.hphm] = DateTime.Now;
                         }
                     }
                 }
                 catch (Exception ex)
                 {
                     LogHelper.Trace($"取号异常:{ex.Message}");
                 }
             }
         });
     }
     catch (Exception ex)
     {
         LogHelper.Error("打印异常" + ex.Message);
     }
 }
Ejemplo n.º 8
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            //查询前清空之前的数据
            picQRCode.BackgroundImage = null;
            m_18J52 = new X18J52();
            carFiller.DisplayEntity(null);

            string hphm = combQueryAera.Text + txtQueryPlateNo.Text.Trim();
            string vin  = txtQueryVIN.Text.Trim();
            string hpzl = AppHelper.GetCodeByName(combQueryPlateType.Text, "HPZL");
            // string result = "";
            string        loginUser     = "";
            ResponseModel responseModel = new ResponseModel();
            LoadingForm   frmLoading    = new LoadingForm("正在查询...");

            frmLoading.BackgroundWorkAction = delegate()
            {
                try
                {
                    frmLoading.CurrentMsg = new KeyValuePair <int, string>(10, "正在查询...");
                    NetHelper netHelper = new NetHelper();

                    Api.QueryVehicleApi queryVehicleApi = new Api.QueryVehicleApi();
                    responseModel = queryVehicleApi.Query18J52(hphm, loginUser, hpzl, vin);

                    //result = netHelper.QueryCar(hphm, hpzl, loginUser, vin);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("查询时出现错误:" + ex.Message);
                }
            };
            frmLoading.ShowDialog();

            //if (string.IsNullOrEmpty(result))
            //{
            //    FrmTips.ShowTipsError(AppHelper.MainForm, "查询结果为空", ContentAlignment.MiddleCenter);
            //    return;
            //}
            //LogHelper.Trace("查询信息:" + result);

            //  result = HttpUtility.HtmlDecode(result);
            //string code = RegexXML.MatchField(result, "code", false);
            if (1.Equals(responseModel.Code))
            {
                //m_18J52 = RegexXML.XmlToModelByName<X18J52>(result);

                m_18J52 = JsonConvert.DeserializeObject <X18J52>(responseModel.Data?.ToString());
                m_18J52.BusinessType = combType.Text;

                //string js = JsonConvert.SerializeObject(x18J52);
                //Bitmap bitmap = Live0xUtils.QRCodeUtils.QRCodeHelper.CreateCode(js, -1, 3, true);
                //picQRCode.BackgroundImage = bitmap;

                DateTime d;
                if (m_18J52.ccrq != null && DateTime.TryParse(m_18J52.ccrq, out d))
                {
                    m_18J52.ccrq = d.ToString("yyyy年MM月dd日");
                }

                if (m_18J52.ccdjrq != null && DateTime.TryParse(m_18J52.ccdjrq, out d))
                {
                    m_18J52.ccdjrq = d.ToString("yyyy年MM月dd日");
                }

                m_18J52.cllx = AppHelper.GetNameByCode(m_18J52.cllx, "CLZL");
                m_18J52.hpzl = AppHelper.GetNameByCode(m_18J52.hpzl, "HPZL");

                carFiller.DisplayEntity(m_18J52);
            }
            else
            {
                MessageBox.Show(responseModel.Message);
            }
            //else if (string.IsNullOrEmpty(code))
            //{
            //    MessageBox.Show("查询信息为空" + result);
            //}
            //else
            //{
            //    MessageBox.Show(RegexXML.MatchField(result, "message", false));
            //}
        }