Beispiel #1
0
 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());
 }
Beispiel #2
0
        void MainForm_Load(object sender, EventArgs e)
        {
            SynchronizationContext uiContext = SynchronizationContext.Current;

            splashScreenManager1.ShowWaitForm();

            serverConnection
            .ConnectAsync()
            .ContinueWith(task => {
                IReportServerClient client = task.Result;
                client.SetSynchronizationContext(uiContext);
                return(client.GetReportsAsync(null));
            }).Unwrap()
            .ContinueWith(task => {
                splashScreenManager1.CloseWaitForm();
                if (task.IsFaulted)
                {
                    MessageBox.Show(task.Exception.Flatten().InnerException.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    FillReportListBox(task.Result);
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
Beispiel #3
0
        public MainViewModel()
        {
            SynchronizationContext uiContext = SynchronizationContext.Current;

            ReportObjectCollection = new ObservableCollection <ReportObjects>();
            SelectedReportObject   = new ReportObjects()
            {
                Id = -1
            };
            serverConnection
            .ConnectAsync()
            .ContinueWith(task => {
                IReportServerClient client = task.Result;
                client.SetSynchronizationContext(uiContext);
                return(client.GetReportsAsync(null));
            }).Unwrap()
            .ContinueWith(task => {
                if (task.IsFaulted)
                {
                    MessageBoxService.Show(task.Exception.Message, "Error", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
                }
                else
                {
                    FillReportListBox(task.Result);
                }
            }, TaskScheduler.FromCurrentSynchronizationContext());
        }
 public static Task <T> DoWithScheduledJobAsync <T>(this ConnectionProvider serverConnection, Func <IReportServerClient, Task <T> > func)
 {
     return(serverConnection
            .ConnectAsync()
            .ContinueWith(taskFunc => {
         IReportServerClient client = taskFunc.Result;
         return func(client);
     })
            .Unwrap());
 }
Beispiel #5
0
 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());
 }
Beispiel #6
0
 public ReportServerDataProvider(ILogger logger, IReportServerClient reportServerClient)
 {
     _logger             = logger;
     _reportServerClient = reportServerClient;
 }