void ExportTo(ConnectionProvider serverConnection, int reportId, ExportOptionsBase exportOptions, ReportParameter[] parameters, Action <byte[]> action) { printReportButton.Enabled = false; export2PDFReportButton.Enabled = false; splashScreenManager1.ShowWaitForm(); serverConnection .ConnectAsync() .ContinueWith(t => { IReportServerClient client = t.Result; return(Task.Factory.ExportReportAsync(client, new ReportIdentity(reportId), exportOptions, parameters, null)); }).Unwrap() .ContinueWith(t => { splashScreenManager1.CloseWaitForm(); printReportButton.Enabled = true; export2PDFReportButton.Enabled = true; try { if (t.IsFaulted) { throw new Exception(t.Exception.Flatten().InnerException.Message); } action(t.Result); } catch (Exception e) { MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }, TaskScheduler.FromCurrentSynchronizationContext()); }
void IDocumentExportInterceptor.InvokeBefore(Document document, ExportOptionsBase exportoptions, object customArgs) { if (exportoptions is ImageExportOptions || exportoptions is PdfExportOptions) { var text = string.Format("Created by {0}{2}{1:MM/dd/yy}{2}{1:H:mm:ss}", Environment.UserName, DateTime.Now, Environment.NewLine); document.PrintingSystem.Watermark.Text = text; } }
Task <byte[]> ExportReport(ExportOptionsBase exportOptions) { ReportServiceClientFactory clientFactory = new ReportServiceClientFactory(new EndpointAddress(ReportServiceAddress)); ReportParameter[] reportParameters = new ReportParameter[] { new ReportParameter() { Path = "stringParameter", Value = ReportParameter } }; return(Task.Factory.ExportReportAsync(clientFactory.Create(), ReportName, exportOptions, reportParameters, null)); }
void IDocumentExportInterceptor.InvokeAfter(Stream documentContent, ExportOptionsBase exportoptions, object customArgs) { var exportState = customArgs as ExportState; if (exportState == null) { return; } var fileName = (exportState.FileName ?? "document") + ".pdf"; using (var file = File.OpenWrite(Path.Combine(StaticInfo.AppDataDirectoryPath, fileName))) { documentContent.CopyTo(file); } }
public static bool?Export(ExportFormat format, PrintingSystem printingSystem) { ExportOptionsBase options = GetExportOptions(format, printingSystem); ExportOptionsControllerBase controller = ExportOptionsControllerBase.GetControllerByOptions(options); LineBase[] lines = Array.ConvertAll(controller.GetExportLines(options, new LineFactory(), AvailableExportModes, new List <ExportOptionKind>()), line => (LineBase)line); if (lines.Length > 0) { LinesWindow linesWindow = new LinesWindow(); linesWindow.WindowStyle = WindowStyle.ToolWindow; linesWindow.Owner = Application.Current.MainWindow; linesWindow.Title = Properties.Resources.ExportOptions; linesWindow.SetLines(lines); return(linesWindow.ShowDialog()); } return(null); }
void ExportTo(ConnectionProvider serverConnection, int reportId, ExportOptionsBase exportOptions, ReportParameter[] parameters, Action <byte[]> action) { IsBusy = true; serverConnection .ConnectAsync() .ContinueWith(t => { IReportServerClient client = t.Result; return(Task.Factory.ExportReportAsync(client, new ReportIdentity(reportId), exportOptions, parameters, null)); }).Unwrap() .ContinueWith(t => { IsBusy = false; try { if (t.IsFaulted) { throw new Exception(t.Exception.Flatten().InnerException.Message); } action(t.Result); } catch (Exception e) { MessageBoxService.Show(e.Message, "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); } }, TaskScheduler.FromCurrentSynchronizationContext()); }
protected static string GetFileName(ExportOptionsBase options) { return(GetFileName(ExportOptionsControllerBase.GetControllerByOptions(options))); }
void IDocumentExportInterceptor.InvokeBefore(Document document, ExportOptionsBase exportoptions, object customArgs) { }
void IDocumentExportInterceptor.InvokeAfter(Stream documentContent, ExportOptionsBase exportoptions, object customArgs) { }