using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using ChuPiao.Common.Models;
using ChuPiao.AutoPrint.Machine.Models;
using ChuPiao.Common.Core.Utils;
using System.IO;
using ChuPiao.Common.Utils;
using System.Diagnostics;
using ChuPiao.Common.Communication.GtdJson.Packs;
using ChuPiao.Common.Communication.GtdJson;
using ChuPiao.Common.Communication.GtdJson.Items;
using System.Text.RegularExpressions;
using ChuPiao.Common.Core.Security;
using ZXing;
using ZXing.Common;
using ZXing.PDF417;
using ZXing.PDF417.Internal;
using System.Drawing.Imaging;
using ChuPiao.Common.Enums;
using ChuPiao.AutoPrint.Machine.TjJingCaiV1;
using ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode;
using ChuPiao.AutoPrint.Machine;
using System.Threading;


namespace ChuPiao.AutoPrint.Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeQxFsService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeQxFsService();
            L_LotTicketEntity ticket = new L_LotTicketEntity();
            ticket.L_Money = 48;
            ticket.L_Code = "4,7|0,4|1,8,9|6|8|3|0,12";
            ticket.MacModeId = 7040102;

            M_MachineEntity machine = new M_MachineEntity();
            M_MachineModeConfigEntity config = new M_MachineModeConfigEntity();
            config.C_IsCheckCode = true;
            machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>();
            machine.MachineModeConfigs.Add(7040102, config);
            DecodePrintData data = new DecodePrintData();
            data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("D:/20210402121337.prn", Encoding.GetEncoding("gb2312"))));
            service.DecodeData(ticket, machine, data);


            //ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModePsDsService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModePsDsService();
            //L_LotTicketEntity ticket = new L_LotTicketEntity();
            //ticket.L_Money = 2;
            //ticket.L_Code = "6|2|4";
            //ticket.MacModeId = 7020101;

            //M_MachineEntity machine = new M_MachineEntity();
            //M_MachineModeConfigEntity config = new M_MachineModeConfigEntity();
            //config.C_IsCheckCode = true;
            //machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>();
            //machine.MachineModeConfigs.Add(7020101, config);
            //DecodePrintData data = new DecodePrintData();
            //data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("D:/ps.prn", Encoding.GetEncoding("gb2312"))));
            //service.DecodeData(ticket, machine, data);


            //ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeJzHhggService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeJzHhggService();
            //L_LotTicketEntity ticket = new L_LotTicketEntity();
            //ticket.L_Money = 2;
            //ticket.L_Code = "1002→91106[1]/1003→91106[1]/1004→91101[1]/1005→91106[1]";
            //ticket.MacModeId = 9110111;

            //M_MachineEntity machine = new M_MachineEntity();
            //M_MachineModeConfigEntity config = new M_MachineModeConfigEntity();
            //config.C_IsCheckCode = true;
            //machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>();
            //machine.MachineModeConfigs.Add(9110111, config);
            //DecodePrintData data = new DecodePrintData();
            //data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("D:/jz2.prn", Encoding.GetEncoding("gb2312"))));
            //service.DecodeData(ticket, machine, data);

            //ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeJlHhggService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeJlHhggService();
            //L_LotTicketEntity ticket = new L_LotTicketEntity();
            //ticket.L_Money = 100;
            //ticket.L_Code = "1307→95101[1]/1308→95104[2]/1309→95101[2]";
            //ticket.MacModeId = 9110112;

            //M_MachineEntity machine = new M_MachineEntity();
            //M_MachineModeConfigEntity config = new M_MachineModeConfigEntity();
            //config.C_IsCheckCode = true;
            //machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>();
            //machine.MachineModeConfigs.Add(9110112, config);
            //DecodePrintData data = new DecodePrintData();
            //data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("E:/4.prn", Encoding.GetEncoding("gb2312"))));
            //service.DecodeData(ticket, machine, data);

            //ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeDlX3DsService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeDlX3DsService();
            //L_LotTicketEntity ticket = new L_LotTicketEntity();
            //ticket.L_Money = 24;
            //ticket.L_Code = "03,05,06";
            //ticket.MacModeId = 5030301;
            //ticket.L_Expect = "20041901";

            //M_MachineEntity machine = new M_MachineEntity();
            //M_MachineModeConfigEntity config = new M_MachineModeConfigEntity();
            //config.C_IsCheckCode = true;
            //machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>();
            //machine.MachineModeConfigs.Add(5030301, config);
            //DecodePrintData data = new DecodePrintData();
            //data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("C:/333.prn", Encoding.GetEncoding("gb2312"))));
            //service.DecodeData(ticket, machine, data);

            //ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeLtZjDsService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacLotPlayMode.MacLotPlayModeLtZjDsService();
            //L_LotTicketEntity ticket = new L_LotTicketEntity();
            //ticket.L_Money = 15;
            //ticket.L_Code = "09,18,21,28,29|05,10$11,12,15,16,18|01,05$01,03,06,21,30|07,09$02,06,15,27,33|07,12$11,13,18,24,29|03,09";
            //ticket.MacModeId = 7010201;
            //ticket.L_Expect = "20028";

            //M_MachineEntity machine = new M_MachineEntity();
            //M_MachineModeConfigEntity config = new M_MachineModeConfigEntity();
            //config.C_IsCheckCode = true;
            //machine.MachineModeConfigs = new SortedDictionary<int, M_MachineModeConfigEntity>();
            //machine.MachineModeConfigs.Add(7010201, config);
            //DecodePrintData data = new DecodePrintData();
            //data.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("C:/444.prn", Encoding.GetEncoding("gb2312"))));
            //service.DecodeData(ticket, machine, data);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                string ticketFilePath = @"D:\data\logs\1001\2019-09-05\ticket";
                if (Directory.Exists(ticketFilePath))
                {
                    DirectoryInfo directoryInfo = new DirectoryInfo(ticketFilePath);
                    FileInfo[] fileInfoList = directoryInfo.GetFiles("*.prn");
                    if (fileInfoList.Length != 0)
                    {
                        LastTicketFileComparer fileComparer = new LastTicketFileComparer();
                        Array.Sort(fileInfoList, fileComparer);

                        FileInfo file = fileInfoList[0];
                        file.Delete();
                    }
                }
            }
            catch (Exception exception)
            {

            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string url = "www.baidu.com";
            Process p = null;

            Microsoft.Win32.RegistryKey key = Microsoft.Win32.Registry.ClassesRoot.OpenSubKey(@"http\shell\open\command\");//获得注册表HKEY_CLASSES_ROOT\http\shell\open\command文件（执行regedit查看）
            if (key != null)
            {
                string s = key.GetValue("").ToString();//获得command里面的浏览器默认值："D:\Program Files (x86)\Mozilla Firefox\firefox.exe" -osint -url "%1"  "D:\Program Files\360\360se3\360se.exe" “%1”
                //获得要打开默认浏览器的路径"D:\Program Files\360\360se3\360se.exe"
                //string app = s.Substring(0, s.Length - 5);  //截掉后面
                string app = s.Split(new string[] { " -" }, StringSplitOptions.RemoveEmptyEntries)[0];//s就是你的默认浏览器，截掉后面的参数部分
                try
                {
                    p = System.Diagnostics.Process.Start(app, url);  //打开浏览器浏览网址
                }
                catch (Exception ex)
                { }
                if (p == null)
                {
                    try
                    {
                        p = Process.Start("iexplore.exe", url);
                    }
                    catch (Exception ex)
                    { }
                    if (p == null)
                    {
                        Process.Start(url);
                    }
                }
            }
            else
            {
                try
                {
                    p = Process.Start("iexplore.exe", url);
                }
                catch (Exception ex)
                { }
                if (p == null)
                {
                    Process.Start(url);
                }
            }
        }

        private void button4_Click(object sender, EventArgs e)
        {
            LogUtil.Setup();
            PackSetting.Instance.Configure();


            //缴款
            ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacReport.MacReportService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacReport.MacReportService();
            DecodeMachinePayMoneyReport decodePrintData = new DecodeMachinePayMoneyReport();
            decodePrintData.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("D:/jkbb_yidongzhifu.prn", Encoding.GetEncoding("gb2312"))));
            service.DecodeMachinePayMoneyReport(null, decodePrintData);

            if (decodePrintData.DecodeSuccess)
            {
                string agentid = "1001";

                A10006UploadMachineBalance pack = new A10006UploadMachineBalance();
                pack.AgentId = agentid;
                pack.Salt = "408b2378857d34ca484a7c321c35b302";

                pack.Balance = decodePrintData.MachinePayMoneyReportEntity.R_Balance;
                pack.QueryTime = decodePrintData.MachinePayMoneyReportEntity.R_QueryTime.ToString("yyyyMMddHHmmss");
                pack.From = decodePrintData.MachinePayMoneyReportEntity.R_QueryTime.ToString("yyyyMMdd");
                pack.To = decodePrintData.MachinePayMoneyReportEntity.R_QueryTime.ToString("yyyyMMdd");
                pack.Type = 1;
                pack.TypeName = pack.From;   //暂时只打天报表，以后有周月报表再说
                pack.Prntext = decodePrintData.MachinePayMoneyReportEntity.R_PrnText;

                A10006UploadMachineBalanceRet packRet = PackManager.Instance.Send(pack) as A10006UploadMachineBalanceRet;
                if (packRet.Code <= 0)
                {
                    throw new Exception("上传缴款报表中的余额失败，" + packRet.Code.ToString() + " " + packRet.Message);
                }

                A10007UploadMachinePay pack1 = new A10007UploadMachinePay();
                pack1.AgentId = agentid;
                pack1.Salt = "408b2378857d34ca484a7c321c35b302";

                pack1.QueryTime = decodePrintData.MachinePayMoneyReportEntity.R_QueryTime;
                foreach (PayMoneyDataItem item in decodePrintData.MachinePayMoneyReportEntity.R_DataList)
                {
                    pack1.PaymentList.Add(new UploadMachinePayItem(item.PayType, item.PayMoney, item.PayTime));
                }

                A10007UploadMachinePayRet packRet1 = PackManager.Instance.Send(pack1) as A10007UploadMachinePayRet;
                if (packRet1.Code <= 0)
                {
                    //throw new Exception("上传缴款报表中的缴款记录失败，" + packRet1.Code.ToString() + " " + packRet1.Message);
                }
            }
            else
            {
                //throw new Exception(string.Concat("解析缴款报表失败。错误信息：", decodePrintData.ErrorMessage));
            }

            ////竞彩时段报表
            //ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacReport.MacReportService service = new ChuPiao.AutoPrint.Machine.TjJingCaiV1.MacReport.MacReportService();
            //DecodeMachineReport decodeMachineReport = new DecodeMachineReport();
            //decodeMachineReport.InputData = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("D:/sdbb_2.prn", Encoding.GetEncoding("gb2312"))));
            //service.DecodeMachineReportReport(null, decodeMachineReport);

            //if (decodeMachineReport.DecodeSuccess)
            //{
            //    A10005UploadMachineSale pack = new A10005UploadMachineSale();
            //    pack.AgentId = "1001";
            //    pack.Salt = "408b2378857d34ca484a7c321c35b302";
            //    pack.Type = 1;
            //    pack.TypeName = "20200312";

            //    pack.SaleMoney = decodeMachineReport.MachineReportEntity.R_SaleMoney;
            //    pack.EncashMoney = decodeMachineReport.MachineReportEntity.R_EncashMoney;
            //    pack.ReturnMoney = decodeMachineReport.MachineReportEntity.R_ReturnMoney;
            //    pack.QueryTime = decodeMachineReport.MachineReportEntity.R_QueryTime.ToString("yyyyMMddHHmmss");
            //    pack.From = decodeMachineReport.MachineReportEntity.R_StartTime.ToString("yyyyMMdd");
            //    pack.To = decodeMachineReport.MachineReportEntity.R_EndTime.ToString("yyyyMMdd");
            //    pack.Prntext = decodeMachineReport.MachineReportEntity.R_PrnText;

            //    A10005UploadMachineSaleRet packRet = PackManager.Instance.Send(pack) as A10005UploadMachineSaleRet;
            //    if (packRet.Code <= 0)
            //    {
            //        //throw new Exception("上传天报表失败，" + packRet.Message);
            //    }

            //}
            ////else
            ////{
            ////    throw new Exception(string.Concat("解析天报表失败。错误信息：", decodeMachineReport.ErrorMessage));
            ////}
        }

        private void button5_Click(object sender, EventArgs e)
        {
            CaptureDataInfo info = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText("d:/dlt.prn", Encoding.GetEncoding("gb2312"))));

            string passwd;
            Regex regex = new Regex(@"[0-9]{6}-[0-9]{6}-[0-9]{6}-[0-9]{6} (\d{6}) ");   //110430-289460-026185-900502 503504  xxygvQ   常规彩
            //Regex regex = new Regex(@"[0-9]{6}-[0-9]{6}-[0-9]{6}-[0-9]{2} (\d{8}) ");   //201060-033637-824126-40 00141962 EC8FE3A5  竞足
            //Regex regex = new Regex(@"[0-9]{24} (\d{8}) ");   //140420016905364708861926 47545142 D4EB6EC3  竞篮
            Match match = regex.Match(info.CaptureDataString);
            if (match.Success)
                passwd = match.Groups[1].Value;
            
        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private string tempStr = "";
        private void button6_Click(object sender, EventArgs e)
        {
            tempStr = DesUtil.Encrypt("433260");
            MessageBox.Show(tempStr);
        }

        private void button7_Click(object sender, EventArgs e)
        {
            tempStr = DesUtil.Decrypt(tempStr);
            MessageBox.Show(tempStr);
        }

        private void button8_Click(object sender, EventArgs e)
        {
            //PDF417 PDF417 = new PDF417();
            //PDF417.Data = "80110420450660062345111803+2997510E!�(恚j颇篏為e�'菼JF/婬`?筙�#� 晱仪�鴁鏑琨锚鳚猦�娖鳜]砼鏖�";

            //PDF417.UOM = UnitOfMeasure.CM;
            //PDF417.BackgroundColor = System.Drawing.Color.White;
            //PDF417.ModuleColor = System.Drawing.Color.Black;
            //PDF417.ImageFormat = System.Drawing.Imaging.ImageFormat.Png;
            //PDF417.ImageWidth = 8.1F;
            //PDF417.ImageHeight = 3.3F;
            //PDF417.LeftMargin=0;
            //PDF417.TopMargin = 0;
            //PDF417.RightMargin = 0;
            //PDF417.BottomMargin = 0;
            //PDF417.Columns = 6;
            //PDF417.Rows = 10;
            //PDF417.Encoding = PDF417Encoding.Binary;
            //PDF417.ECL = PDF417ErrorCorrectionLevel.Level_4;

            //// Save barcode image into your file system
            //PDF417.drawBarcode("c:/pdf417.png");
            //-------------------------------------------------
            ////图片路径
            //string imgPath = @"D:\111.jpg";

            ////解码通用类
            

            //IBarcodeReader reader = new BarcodeReader();

            //Bitmap bmp = new Bitmap(imgPath);
            //Result result = reader.Decode(bmp);
            //bmp.Dispose();
            //if (result != null)
            //{

            //    string text = Encoding.UTF8.GetString(Encoding.Unicode.GetBytes(result.Text)); //条码内容
            //    string foramt = result.BarcodeFormat.ToString(); //条码类型
            //}

            PDF417EncodingOptions options = new PDF417EncodingOptions();
            options.AspectRatio = PDF417AspectRatio.AUTO;
            options.Compact = false;
            options.Compaction = Compaction.AUTO;
            options.DisableECI = true;
            options.ErrorCorrection = PDF417ErrorCorrectionLevel.L4;
            options.PureBarcode = false;
            options.GS1Format = false;
            options.Width = 280;
            options.Height = 75;
            options.Margin = 10;

            BarcodeWriter writer = new BarcodeWriter();
            writer.Format = BarcodeFormat.PDF_417;
            writer.Options = options;

            //如需设置图片为其它颜色，使用此段代码
            //BitmapRenderer renderer = new BitmapRenderer();
            //renderer.Foreground = Color.Black;
            //renderer.Background = Color.White;
            //writer.Renderer = renderer;

            //Bitmap bmp = writer.Write("80110420435360025185078807+433260\00E!\0o(í");
            Bitmap bmp = writer.Write("80110420450660062345111803+299751\00");
           // MemoryStream ms = new MemoryStream();
            bmp.Save("D:\\222.png", ImageFormat.Png);
            //ms.Flush();
            //ms.Position = 0;
            //new File(ms, "application/x-png");
        }

        private void button9_Click(object sender, EventArgs e)
        {
            LogUtil.Setup();
            PackSetting.Instance.Configure();

            OpenFileDialog dialog = new OpenFileDialog();
            dialog.Title = "请选择文件";
            dialog.Filter = "(*.prn)|*.prn";
            string file;
            if (dialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                file = dialog.FileName;
            }
            else
            {
                return;
            }


            //解析票
            CaptureDataInfo captureDataInfo = new CaptureDataInfo(TicketTextUtil.DecryptAndDecompress(File.ReadAllText(file, Encoding.GetEncoding("gb2312"))));
            string input = captureDataInfo.CaptureDataString;
            int tmpEnd = input.IndexOf("-------------------");
            string strPlayCodetype = input.Substring(0, tmpEnd);

            L_LotTicketEntity ticketEntity = new L_LotTicketEntity();
            if (strPlayCodetype.IndexOf("竞彩足球") > 0)
            {
                ticketEntity.LotId = (int)Lottype.Jz;
                if (strPlayCodetype.IndexOf("竞彩足球混合过关") > 0)
                {
                    ticketEntity.L_PlayId = (int)Playtype.JzHHGG;
                    ticketEntity.MacModeId = (int)TjJingCaiV1ModeType.JzHhgg;
                }
                else if (strPlayCodetype.IndexOf("竞彩足球胜平负") > 0)
                {
                    ticketEntity.L_PlayId = (int)Playtype.JzSPF;
                    ticketEntity.MacModeId = (int)TjJingCaiV1ModeType.JzSpf;
                }
                else if (strPlayCodetype.IndexOf("竞彩足球让球胜平负") > 0)
                {
                    ticketEntity.L_PlayId = (int)Playtype.JzRQSPF;
                    ticketEntity.MacModeId = (int)TjJingCaiV1ModeType.JzSpfn;
                }
                else if (strPlayCodetype.IndexOf("竞彩足球比分") > 0)
                {
                    ticketEntity.L_PlayId = (int)Playtype.JzBF;
                    ticketEntity.MacModeId = (int)TjJingCaiV1ModeType.JzBf;
                }
                else if (strPlayCodetype.IndexOf("竞彩足球半全场胜平负") > 0)
                {
                    ticketEntity.L_PlayId = (int)Playtype.JzBQC;
                    ticketEntity.MacModeId = (int)TjJingCaiV1ModeType.JzBqc;
                }
                else if (strPlayCodetype.IndexOf("竞彩足球总进球数") > 0)
                {
                    ticketEntity.L_PlayId = (int)Playtype.JzJQS;
                    ticketEntity.MacModeId = (int)TjJingCaiV1ModeType.JzZjq;
                }
            }
            else if (strPlayCodetype.IndexOf("竞彩篮球") > 0)
            {
                ticketEntity.LotId = (int)Lottype.Jl;
                if (strPlayCodetype.IndexOf("竞彩篮球混合过关") > 0)
                {
                    ticketEntity.L_PlayId = (int)Playtype.JlHHGG;
                    ticketEntity.MacModeId = (int)TjJingCaiV1ModeType.JlHhgg;
                }
                else if (strPlayCodetype.IndexOf("竞彩篮球大小分") > 0)
                {
                    ticketEntity.L_PlayId = (int)Playtype.JlDXF;
                    ticketEntity.MacModeId = (int)TjJingCaiV1ModeType.JlDxf;
                }
                else if (strPlayCodetype.IndexOf("竞彩篮球让分胜负") > 0)
                {
                    ticketEntity.L_PlayId = (int)Playtype.JlRFSF;
                    ticketEntity.MacModeId = (int)TjJingCaiV1ModeType.JlRfsf;
                }
                else if (strPlayCodetype.IndexOf("竞彩篮球胜分差") > 0)
                {
                    ticketEntity.L_PlayId = (int)Playtype.JlSFC;
                    ticketEntity.MacModeId = (int)TjJingCaiV1ModeType.JlSfc;
                }
                else if (strPlayCodetype.IndexOf("竞彩篮球胜负") > 0)
                {
                    ticketEntity.L_PlayId = (int)Playtype.JlSF;
                    ticketEntity.MacModeId = (int)TjJingCaiV1ModeType.JlSf;
                }
            }
            //else if (strPlayCodetype.IndexOf("竞彩名次") > 0)
            //{
            //    ticketEntity.LotId = (int)Lottype.Jm;
            //    if (strPlayCodetype.IndexOf("竞彩名次-冠军") > 0)
            //    {
            //        ticketEntity.L_PlayId = (int)Playtype.JmGj;
            //        ticketEntity.MacModeId = (int)TjJingCaiV1ModeType.JmGj;
            //    }
            //    else if (strPlayCodetype.IndexOf("竞彩名次-冠亚军") > 0)
            //    {
            //        ticketEntity.L_PlayId = (int)Playtype.JmGyj;
            //        ticketEntity.MacModeId = (int)TjJingCaiV1ModeType.JmGyj;
            //    }
            //}
            //else  //非竞彩电子票
            //{

            //}

            //竞彩上传电子票
            if (ticketEntity.LotId == (int)Lottype.Jz || ticketEntity.LotId == (int)Lottype.Jl)
            {

                DecodePrintData decodePrintData = new DecodePrintData();
                decodePrintData.InputData = captureDataInfo;
                MacLotPlayModeServiceFactory modeServiceFactory = new MacLotPlayModeServiceFactory();
                IMacLotPlayModeService modeService = modeServiceFactory.GetLotPlayService(ticketEntity.MacModeId);
                modeService.DecodeData(ticketEntity, null, decodePrintData);

                if (decodePrintData.DecodeSuccess)
                {
                    try
                    {

                        //通知票号
                        A10002NotifyTicket pack = new A10002NotifyTicket();
                        pack.AgentId = "1002";
                        pack.Salt = "408b2378857d34ca484a7c321c35b302";
                        ticketEntity.L_TicketCode = decodePrintData.L_PrintTicketEntity.P_TicketCode;
                        ticketEntity.L_Password = decodePrintData.L_PrintTicketEntity.P_Password;
                        ticketEntity.L_CodeRate = decodePrintData.L_PrintTicketEntity.L_CodeRate;
                        ticketEntity.L_CodeReference = decodePrintData.L_PrintTicketEntity.L_CodeReference;   //篮球
                        ticketEntity.L_SucTime = decodePrintData.L_PrintTicketEntity.P_SucTime;
                        ticketEntity.L_PrnText = decodePrintData.L_PrintTicketEntity.P_PrnText;
                        ticketEntity.L_Status = (int)TicketStatus.Suc;
                        ticketEntity.L_LimitType = 0;
                        //解析出来的内容
                        ticketEntity.L_Code = decodePrintData.L_PrintTicketEntity.P_Code;
                        ticketEntity.L_Money = decodePrintData.L_PrintTicketEntity.P_Money;
                        ticketEntity.L_Mutiple = decodePrintData.L_PrintTicketEntity.P_Mutiple;
                        ticketEntity.L_CodeType = decodePrintData.L_PrintTicketEntity.L_CodeType;
                        pack.Ticket = ticketEntity;

                        int retry = 0;
                        while (retry < 3)
                        {
                            A10002NotifyTicketRet packRet = PackManager.Instance.Send(pack) as A10002NotifyTicketRet;
                            if (packRet.Code > 0)
                            {
                                break;
                            }

                            retry++;
                            if (retry == 3)
                            {
                               // LotMachine.Log.Warn("【操作提示】：请尝试点击“重新通知”！");
                                throw new Exception("票号通知失败（已自动尝试3次），" + packRet.Code.ToString() + " " + packRet.Message);
                            }

                            Thread.Sleep(retry * 1000);
                        }

                        ////删除last目录下最后一个文件
                        //LotMachine.VirtualPrinter.DeleteLastFile();

                        //LotMachine.Log.Info(string.Concat("票号通知成功：", ticket.L_TicketSn, " 彩种：", ticket.L_LotName, ticket.LotId, "玩法：", ticket.L_PlayName, ticket.L_PlayId, "倍数：", ticket.L_Mutiple, "金额：", ticket.L_Money, " 出票耗时为：", totalTime.ToString("0"), "毫秒 ", ticket.IsUseScanner ? "扫描出票" : "键码出票"));

                    }
                    catch (Exception exception)
                    {
                        //LotMachine.Log.Warn(string.Concat("票号通知失败。生产流水号：", ticket.L_TicketSn, " 票号：", ticket.L_TicketCode, " 密码：", ticket.L_Password));

                    }
                }
                else
                {
                   // LotMachine.Log.Warn(string.Concat("解析电子票失败。生产流水号：", ticket.L_TicketSn, " 错误信息：", decodePrintData.ErrorMessage));
                }
            }


        }
    }
}