Toolbar option

Сonversation on different topics
Post Reply
winmyint
Posts: 7
Joined: Fri Mar 01, 2013 7:10 am

Toolbar option

Post by winmyint »

Hi Stimulsoft Team,

I am using Stimulsoft since 2011.
I have come up with two question.
The first one:
Is there any option for Undo and Redo function in StiWebViewer.
I tried both : StiWebDesignerOptions.Viewer.Toolbar
StiWebViewerFxOptions.Toolbar.


But no luck.
The second question:
I can use Save As in Designer which is saved in local.
The issue is, I allow the clients to create Report and view/edit/save through StiWebViewer. When they create report, the report is saved in WebHosting (under App_Data folder).

The code:

Code: Select all

protected void ReportDesigner_SaveReport(object sender, StiWebDesigner.StiSaveReportEventArgs e)
    {
        var reportId = Page.Request["ID"];
        int id = int.Parse(reportId);

        using (var db = new TMS_DAL.DataContext())
        {
            var report = db.Reports.Single(x => x.Id == id);

            try
            {
                var path = string.Format("{0}\\{1}.mrt", Server.MapPath("~/App_Data/Reports"), report.Name);
                e.Report.Save(path);

                template.LastModified = DateTime.Now;
                db.ExecuteCommand("update table_Reports set LastModified = '" + report.LastModified.Value.ToString("yyyy-MM-dd hh:mm:ss") + "' where reportId = " + report.Id + ";");
            }
            catch (Exception ex)
            {
                // TODO - can we log this to user?
            }
        } 
    }
       
Is there any workaround to get it done for Save As.

Thank you for help in advance.

Regards,
Win
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Toolbar option

Post by HighAley »

Hello.

Maybe we don't real understand you, but about what Undo/Redo function in the StiWebViewer are you writing?
Did you mix up Viewer and Designer?

Thank you.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Toolbar option

Post by HighAley »

Hello.

Please, look at the attached sample.

Thank you.
Attachments
Sample.zip
(9.69 KiB) Downloaded 351 times
winmyint
Posts: 7
Joined: Fri Mar 01, 2013 7:10 am

Re: Toolbar option

Post by winmyint »

Hi Aleksey,

Thanks a lot for reply. Yes, I mean Is there any way to Add, Undo and Redo inWebViewer?? As I mentioned above, I let my clients to create custom report and they can modify the report whatever they want to do in WebViewer, but when they got anything wrong, they can't able to Undo as there is no Undo in WebViewer. Is there any workaround to add these function in WebViewer? Any Suggestion? Thank you so much for help in advance.

Regards,
Win
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Toolbar option

Post by HighAley »

Hello.

It's impossible to edit report in the WebViewer. How do your clients change report in the WebViewer? Could you send us any sample?

Thank you.
winmyint
Posts: 7
Joined: Fri Mar 01, 2013 7:10 am

Re: Toolbar option

Post by winmyint »

Hi Aleksey,

I am really sorry. That's my bad. You right. That is StiWebDesigner. How can I add Undo and Redo in there?

ASPX:
<asp:Content ID="Content3" ContentPlaceHolderID="PlaceHolderBodyContent" Runat="Server">
<cc2:StiWebDesigner ID="ReportDesigner" Width="100%" Height="100%" runat="server"
OnSaveReport="ReportDesigner_SaveReport" ongetpreviewdataset="ReportDesigner_GetPreviewDataSet">
</cc2:StiWebDesigner>
</asp:Content>

Code: Select all

             ASPX.cs
                 protected void Page_Load(object sender, EventArgs e)
    {
        var reportId = Page.Request["ID"];
        if (!string.IsNullOrEmpty(reportId))
        {
            int id = 0;
            if (int.TryParse(reportId, out id))
            {
                var db = new DAL.DataContext();
                var template = db.Templates.Where(t => t.Id == id).SingleOrDefault();
                if (template != null)
                {
                    ReportFile = HttpContext.Current.Server.MapPath(string.Format("~/App_Data/Reports/{0}.mrt", template.Name));
                    var report = new StiReport();

                    report.Load(ReportFile);
                    report.ReportName = template.Name;
                    ////report.DataSources.Clear();
                    ////report.Dictionary.Databases.Clear();

                    DataSet ds = null;
                    if (template.TemplateGroup == "TaxInvoice")
                    {
                        ds = BLL.Report.TaxInvoiceSampleData();
                    }
                    else if (template.TemplateGroup == "DataExportEnrolment")
                    {
                        // just grab the first 2 rows to set the data-types
                        ds = GenerateDataExportEnrolmentData(2);
                    }
                    else if (template.TemplateGroup == "DataExportResult")
                    {
                        // just grab the first 2 rows to set the data-types
                        ds = GenerateDataExportResultData(2);
                    }
                    else if (template.TemplateGroup == "DataExportAssessment")
                    {
                        ds = new Templates.ReportViewer().GenerateDataExportAssessmentData(3);
                    }
                    else if (template.TemplateGroup == "DataExportCertificate")
                    {
                        ds = new Templates.ReportViewer().GenerateDataExportCertificateData(3);
                    }
                    else if (template.TemplateGroup == "DataExportActivity")
                    {
                        ds = new Templates.ReportViewer().GenerateDataExportActivityData(5);
                    }

                    if (ds != null)
                    {
                        report.DataSources.Clear();
                        report.Dictionary.Databases.Clear();
                        report.RegData(ds.DataSetName, ds);
                        report.Dictionary.Synchronize();
                    }

                    // Fix from SS suport to allow templates to be loaded over SSL
                    StiWebDesignerOptions.Connection.RelativeUrls = true;
                    StiWebDesignerOptions.Connection.EnableDataLogger = true;
                    StiWebDesignerOptions.Connection.ClientRequestTimeout = 60;
                    StiWebDesignerOptions.Connection.ShowCancelButton = true;
                    StiWebViewerFxOptions.Toolbar.ShowEditButton = true;

                    ReportDesigner.Design(report);                    
                }
            }
        }
    }

protected void ReportDesigner_GetPreviewDataSet(object sender, StiWebDesigner.StiPreviewDataSetEventArgs e)
    {
        //var reportName = Page.Request["ID"];
        //if (reportName == "TaxInvoiceV3")
        //{
        //    e.PreviewDataSet = Report.GenerateTaxInvoiceReportSampleData();
        //}

        const int previewSize = 50;
        var reportId = Page.Request["ID"];
        if (!string.IsNullOrEmpty(reportId))
        {
            int id = 0;
            if (int.TryParse(reportId, out id))
            {
                using (var db = new DataContext())
                {
                    var template = db.Templates.Where(t => t.Id == id).SingleOrDefault();
                    if (template != null)
                    {
                       if (template.TemplateGroup == "TaxInvoice")
                        {
                            var ds = Report.GenerateTaxInvoiceReportSampleData();
                            //e.Report.Dictionary.Databases.Clear();
                            e.PreviewDataSet = ds;

                        }
                         // data export reports
                        else if (template.TemplateGroup == "DataExportEnrolment")
                        {
                            e.PreviewDataSet = new Templates.ReportViewer().GenerateDataExportEnrolmentData(previewSize);                        
                        }
                        else if (template.TemplateGroup == "DataExportResult")
                        {
                            e.PreviewDataSet = new Templates.ReportViewer().GenerateDataExportResultData(previewSize); 
                        }
                        else if (template.TemplateGroup == "DataExportAssessment")
                        {
                            e.PreviewDataSet = newTemplates.ReportViewer().GenerateDataExportAssessmentData(60);
                        }
                        else if (template.TemplateGroup == "DataExportCertificate")
                        {
                            e.PreviewDataSet = new Templates.ReportViewer().GenerateDataExportCertificateData(previewSize);
                        }
                        else if (template.TemplateGroup == "DataExportActivity")
                        {
                            e.PreviewDataSet = new Templates.ReportViewer().GenerateDataExportActivityData(previewSize);
                        }

                    }
                }
            }
        }
    }
winmyint
Posts: 7
Joined: Fri Mar 01, 2013 7:10 am

Re: Toolbar option

Post by winmyint »

Hi Aleksey,

Save Report As is used to download the report definition on local user's drive. Is there any way to save the report on the server side as a new when click on Save Report As??

Many Thanks,
Win
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Toolbar option

Post by HighAley »

Hello.

The Undo/Redo feature is in our to-do list.
winmyint wrote:Save Report As is used to download the report definition on local user's drive. Is there any way to save the report on the server side as a new when click on Save Report As??
Please, look at the project that I sent you before.

Thank you.
Post Reply