Page 1 of 1

StiSLViewerControl - too many clicks to export

Posted: Thu Jul 14, 2016 10:08 am
by vecs
There are too many clicks required to export report to PDF or Excel from StiSLViewerControl.
Is it possible to reduce clicks number by excluding "Export settings" dialog (use default export settings) and intermediate one-botton dialog?

Here is my current code:

Code: Select all

...
Stimulsoft.Report.StiOptions.Silverlight.WCFService.UseWCFService = true;
...
        private void WCFService_WCFExportDocument(object sender, Stimulsoft.Report.Events.StiWCFExportEventArgs e)
        {
            if (sender != this.viewer)
                return;

            string exportFilter = e.Filter;
            (sender as Stimulsoft.Report.Viewer.StiSLViewerControl).StartProgressInformation("In progress", "Exporting", Visibility.Visible);

            var serv = new ReportServ(); //remote WCF service wrapper

            InvokeOperation<byte[]> result = serv.ExportDocument(e.Xml); //Export (server-side)

            result.Completed += (send, args) =>
            {
                (sender as Stimulsoft.Report.Viewer.StiSLViewerControl).CloseProgressInformation();
                service_ExportDocumentCompleted(send, new ExportDocumentCompletedArgs(result.Value, result.Error), exportFilter);
            };

        }

        private void service_ExportDocumentCompleted(object sender, ExportDocumentCompletedArgs e, string exportFilter)
        {
            if (e.Error == null && e.Result != null)
            {
                //SaveFileDialog could be launched by UI-event only (user click)
                //So intermediate dlg with button required
                var window = new SaveWindow();
                window.OKButton.Click += delegate
                {
                    window.Close();

                    SaveFileDialog saveFileDialog = new SaveFileDialog
                    {
                        Filter = string.Format("Document export (*.{0})|*.{0}", exportFilter)
                    };

                   saveFileDialog.DefaultFileName = CurrentReportName;

                    if (saveFileDialog.ShowDialog() == true)
                    {
                        var stream = saveFileDialog.OpenFile() as FileStream;
                        stream.Write(e.Result, 0, e.Result.Length);

                        stream.Flush();
                        stream.Close();
                        stream.Dispose();
                    }
                };

                window.Show();
            }
        }

Re: StiSLViewerControl - too many clicks to export

Posted: Fri Jul 15, 2016 12:32 pm
by Alex K.
Hello,

Please send us a request on support@stimulsoft.com with detail description.

Thank you.