public MainWindow() { InitializeComponent(); address = infile.ReadValue("CONFIG", "ADDRESS"); addressSave = infile.ReadValue("CONFIG", "ADDRESSSave"); string a = "020569780311932141656018027901188600178574445818676009179083681404611325017558988810910223024416059959220427736603679376380069730519525691492099"; var qrUrl = ConfigurationManager.AppSettings["QRURL"]; string res = RestClient.HttpPost(qrUrl, a); TicketInfo ticketInfo = JsonConvert.DeserializeObject <TicketInfo>(res); TicketGet ticketGet = new TicketGet(); ticketGet.trainDate = ticketInfo.ticket.trainDate; ticketGet.trainCodeAt = ticketInfo.ticket.trainCodeAt; ticketGet.coachNo = ticketInfo.ticket.coachNo; ticketGet.seatNo = ticketInfo.ticket.seatNo; ticketGet.seatType = ticketInfo.ticket.seatType; DataTable aa = SQLhelp.GetInfo(ticketGet); List <DJ60_change_seat_log> listdj = TableToList.ToDataList <DJ60_change_seat_log>(aa); dayinxieru(listdj); streamToPrint = new FileStream(@address, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); // 创建一个PrintDialog的实例。 PrintDialog PrintDialog1 = new PrintDialog(); // 把PrintDialog的Document属性设为上面配置好的PrintDocument的实例 streamToPrint.Close(); PrintDocument p = new PrintDocument(); //隐藏 对话框 PrintController printController = new StandardPrintController(); p.PrintController = printController; //创建打印画布 p.PrintPage += new PrintPageEventHandler(docToPrint_PrintPage); p.Print(); }
public void theoutTicket(object source, System.Timers.ElapsedEventArgs e) { tTicket.Stop(); tTicket.Close(); try { int flag = Dll_Camera.StartDevice();//启动设备(1设备启动成功) if (flag != 1) { tTicket.Start(); return; } Dll_Camera.SetBeep(true); //蜂鸣开启 int flagg = Dll_Camera.GetDevice(); //查找设备(1设备查找成功) if (flagg != 1) { Dll_Camera.ReleaseLostDevice(); tTicket.Start(); return; } //设置qr Dll_Camera.setQRable(true); //QR引擎开启 Dll_Camera.SetBeepTime(100); //蜂鸣时间 Dll_Camera.SetDecodeTime(200); int Length = 1024; StringBuilder tempStr = new StringBuilder(Length); Dll_Camera.setQRable(false);//为防止重复信息误读 关闭解码 Dll_Camera.GetDecodeString(tempStr, out Length); var result = ""; if (Length > 0) { result = tempStr.ToString(); var qrUrl = ConfigurationManager.AppSettings["QRURL"]; string res = RestClient.HttpPost(qrUrl, result); TicketInfo ticketInfo = JsonConvert.DeserializeObject <TicketInfo>(res); if (ticketInfo.status == 1) { TicketGet ticketGet = new TicketGet(); ticketGet.trainDate = ticketInfo.ticket.trainDate; ticketGet.trainCodeAt = ticketInfo.ticket.trainCodeAt; ticketGet.coachNo = ticketInfo.ticket.coachNo; ticketGet.seatNo = ticketInfo.ticket.seatNo; ticketGet.seatType = ticketInfo.ticket.seatType; DataTable aa = SQLhelp.GetInfo(ticketGet); List <DJ60_change_seat_log> listdj = TableToList.ToDataList <DJ60_change_seat_log>(aa); dayinxieru(listdj); streamToPrint = new FileStream(@address, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.None); // 创建一个PrintDialog的实例。 PrintDialog PrintDialog1 = new PrintDialog(); // 把PrintDialog的Document属性设为上面配置好的PrintDocument的实例 streamToPrint.Close(); PrintDocument p = new PrintDocument(); //隐藏 对话框 PrintController printController = new StandardPrintController(); p.PrintController = printController; //创建打印画布 p.PrintPage += new PrintPageEventHandler(docToPrint_PrintPage); p.Print(); //DoPrint(ticketInfo.ticket); } else {//根据二维码信息获取旅客信息失败 return; } this.Dispatcher.Invoke(new Action(() => { //dayinxieru(result); //streamToPrint = new FileStream(@address, FileMode.OpenOrCreate, FileAccess.ReadWrite, // FileShare.None); //// 创建一个PrintDialog的实例。 //PrintDialog PrintDialog1 = new PrintDialog(); //// 把PrintDialog的Document属性设为上面配置好的PrintDocument的实例 //streamToPrint.Close(); //PrintDocument p = new PrintDocument(); ////隐藏 对话框 //PrintController printController = new StandardPrintController(); //p.PrintController = printController; ////创建打印画布 //p.PrintPage += new PrintPageEventHandler(docToPrint_PrintPage); //p.Print(); frameMain.NavigationService.GoBack(); this.back.Visibility = Visibility.Hidden; this.topTitle.Content = "席位置换自助终端"; })); } else { tTicket.Start(); return; } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }