private static void PrintDocumentThread(Object document) { //Report File exists string reportPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), WmsSetupValues.RdlTemplateDir + "\\" + curTemplate.Header); if (!File.Exists(reportPath)) { return; } //Rendering Report localReport = new LocalReport(); localReport.EnableExternalImages = true; localReport.ExecuteReportInCurrentAppDomain(System.Reflection.Assembly.GetExecutingAssembly().Evidence); localReport.AddTrustedCodeModuleInCurrentAppDomain("Barcode, Version=1.0.5.40001, Culture=neutral, PublicKeyToken=6dc438ab78a525b3"); localReport.AddTrustedCodeModuleInCurrentAppDomain("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); localReport.EnableExternalImages = true; localReport.ReportPath = reportPath; DataSet ds; //Document ds = ReportMngr.ProcessDocument(((Document)document).DocID, new WMSServiceClient(), curTemplate.Header); if (ds == null) { return; } localReport.DataSources.Add(new ReportDataSource("Header", ds.Tables["ReportHeaderFormat"])); localReport.DataSources.Add(new ReportDataSource("Details", ds.Tables["ReportDetailFormat"])); //Print Report //Proceso de Creacion de archivos m_streams.Add(curTemplate, new List <Stream>()); m_currentPageIndex.Add(curTemplate, 0); Export(localReport, curTemplate, "IMAGE"); //1 - Document, 2 - Label m_currentPageIndex[curTemplate] = 0; //Ejecutar la impresion global en un Hilo //Thread th = new Thread(new ParameterizedThreadStart(Print)); //th.Start(printer.PrinterName); Print(usePrinter.PrinterName); }
public ViewDocument(LabelTemplate report, int docID, string printer, bool showBtnPrint, IList<WpfFront.WMSBusinessService.Label> list) { if (report == null) { Util.ShowError("Report could not be found."); return; } InitializeComponent(); printerName = printer; documentID = docID; labelList = list; #region Windows Form Host //if (showBtnPrint) // btnPrintBatch.Visibility = Visibility.Visible; //else // btnPrintBatch.Visibility = Visibility.Collapsed; //Create a Windows Forms Host to host a form WindowsFormsHost host = new WindowsFormsHost(); //Report ddimensions host.HorizontalAlignment = HorizontalAlignment.Stretch; host.VerticalAlignment = VerticalAlignment.Stretch; //pivotView.Width = 900; //pivotView.Height = 700; pivotView.Margin = new System.Windows.Forms.Padding { All = 5 }; //Add the component to the host host.Child = pivotView; gridP.Children.Add(host); #endregion try { //Report File exists string reportPath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), WmsSetupValues.RdlTemplateDir + "\\" + report.Header); if (!File.Exists(reportPath)) { Util.ShowError("Report file does not exists."); return; } //Rendering Report this.pivotView.ProcessingMode = ProcessingMode.Local; this.pivotView.LocalReport.ReportPath = reportPath; this.pivotView.LocalReport.EnableExternalImages = true; this.pivotView.LocalReport.ExecuteReportInCurrentAppDomain(System.Reflection.Assembly.GetExecutingAssembly().Evidence); this.pivotView.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("Barcode, Version=1.0.5.40001, Culture=neutral, PublicKeyToken=6dc438ab78a525b3"); this.pivotView.LocalReport.AddTrustedCodeModuleInCurrentAppDomain("System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"); DataSet ds; //Document if (documentID > 0) { ds = ReportMngr.ProcessDocument(documentID, service, report.Header); if (ds == null) return; pivotView.LocalReport.DataSources.Add(new ReportDataSource("Header", ds.Tables["ReportHeaderFormat"])); pivotView.LocalReport.DataSources.Add(new ReportDataSource("Details", ds.Tables["ReportDetailFormat"])); } //Labels else if (report.LabelType.DocClass.DocClassID == SDocClass.Label) { ds = ReportMngr.ProcessLabels(labelList); pivotView.LocalReport.DataSources.Add(new ReportDataSource("Details", ds.Tables["Details"])); } /* // CAA [2010/06/22] // Nueva opción para enviar parámetros al reporte if (parameters != null) { ReportParameter rp; ReportParameter[] rpList= new ReportParameter[parameters.Count()]; int cont = 1; foreach (string parameter in parameters) { rp = new ReportParameter("p"+cont.ToString(), parameter); rpList[cont-1] = rp; cont++; } pivotView.LocalReport.SetParameters(rpList); } */ //Showing pivotView.Show(); pivotView.ShowFindControls = false; pivotView.ShowExportButton = false; pivotView.ShowRefreshButton = false; pivotView.LocalReport.Refresh(); pivotView.RefreshReport(); } catch (Exception ex) { Util.ShowError("Report could not shown: " + ex.Message); } }