Save, Save As.., and Open Issues

Stimulsoft Reports.WEB discussion
flapjack
Posts: 7
Joined: Sun Feb 26, 2017 9:05 pm

Save, Save As.., and Open Issues

Post by flapjack »

Project: Standard Asp.Net C# MVC5 (i.e. .cshtml files and razor)

Hi, I would like to save, from the Designer, a newly created template to a predefined directory on the webapp's server. I would also like to select 'open' from the Designer and see a dialogbox with a list of available saved report templates to open. How can this be achieved? I have tried a several strategies, but none have been successful.

Alternately, if I have a report template that I have saved from the designer to a directory. How can that file be loaded into the Designer with no other information except the file name? i.e. no pre-populated HttpContext report data? Even this little bit would solve my current problem.

Oh, and this is in the Index.cshtml page

Code: Select all

@Html.Stimulsoft().StiMvcMobileDesigner("rptDesigner", new StiMvcMobileDesignerOptions()
{
    ActionGetReportTemplate = "GetReportTemplate",
    ActionGetReportSnapshot = "GetReportSnapshot",
    ActionDesignerEvent = "DesignerEvent",
    ActionSaveReportTemplate = "SaveReportTemplate",
    ActionSaveAsReportTemplate = "SaveAsReportTemplate"
})

Thanks All.

Felix
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Save, Save As.., and Open Issues

Post by Alex K. »

Hello Felix,

Sorry, maybe we did not exactly understand your question. Could you explain your issue in more details?

Also, you can use the following event:

Code: Select all

public ActionResult SaveReportTemplate(string keyValue)
{
    StiReport report = StiMvcMobileDesigner.GetReportObject(HttpContext);
    Hashtable parameters = StiMvcMobileDesigner.GetHttpContextParameters(HttpContext);

     return StiMvcMobileDesigner.SaveReportTemplateResult(HttpContext);
}
Thank you.
Attachments
01.png
01.png (94.12 KiB) Viewed 4777 times
flapjack
Posts: 7
Joined: Sun Feb 26, 2017 9:05 pm

Re: Save, Save As.., and Open Issues

Post by flapjack »

Hi Aleksey,

I am able to catch the filename and save the file, however, when I try and load that file back into the designer I get a Json Parsing Error dialog and the designer goes into an infinite loading cycle. What else needs to be saved to make the report template load?

Index.cshtml

Code: Select all

@Html.Stimulsoft().StiMvcMobileDesigner("rptDesigner", new StiMvcMobileDesignerOptions()
{
    ActionGetReportTemplate = "GetReportTemplate",
    ActionGetReportSnapshot = "GetReportSnapshot",
    ActionDesignerEvent = "DesignerEvent",
    ActionSaveReportTemplate = "SaveReportTemplate",
    ActionSaveAsReportTemplate = "SaveAsReportTemplate",
    ActionOpenReportTemplate = "OpenReportTemplate",
    ServerCacheMode = StiDesignerCacheMode.Page
})

<script>
        $(function () {
            var designerParameters = {
                "command": "OpenReport",
                "fileName": "",
                "filePath": "",
                "isPacked": false,
                "content": "",
                "reportGuid": "",
                "clipboardId": "",
                "undoArrayId": "",
                "componentCloneId": "",
                "reportCheckersId": "",
                "serverCacheMode": "Page",
                "serverTimeout": "00:20:00",
                "serverCacheItemPriority": "Default",
                "routes": {
                    "action": "Index",
                    "controller": "ReportDesigner"
                },
                "reportFile": ""
            };
            
            $('body').on('click', function (e) {
                // First Event ignored =>(e.target.id === 'rptDesignerFileMenuItemopenReport')  :: Second Event used => (e.target.id === 'openReport')
                if (e.target.id === 'openReport') {
                    debugger;
                    BootstrapDialog.show({
                        draggable: true,
                        title: 'Select Report Template to Open',
                        message: function (dialog) {
                            var $message = $('<div></div>');
                            $.post("/ReportDesigner/GetReportListModal", function (hdata) {
                                $message.html(hdata);
                            });
                            return $message;
                        },
                        buttons: [
                            {
                                label: 'Open Report',
                                id: 'btnOpen',
                                cssClass: 'btn-primary btn-sm',
                                action: function (dialogItself) {
                                    debugger;
                                    var rptFilename = $('#reportlistdata').val();
                                    designerParameters.reportFile = rptFilename;
                                    designerParameters.fileName = rptFilename;
                                    //designerParameters.data = StiMvcMobileDesigner.report.data();

                                    $.post("/ReportDesigner/OpenSavedReportTemplate/", { 'mvcMobileDesignerParameters': designerParameters });
                                    dialogItself.close();
                                    return false;
                                }
                            }, {
                                label: 'Cancel',
                                id: 'btnCancel',
                                cssClass: 'btn-warning btn-sm',
                                action: function (dialogItself) {
                                    dialogItself.close();
                                }
                            }
                        ]
                    });
                    e.preventDefault();
                };
            });
        });
</script>
Controller

Code: Select all

        public ActionResult SaveAsReportTemplate(object mvcMobileDesignerParameters)
        {
            string jsonData = ((string[])(mvcMobileDesignerParameters))[0];
            SsrdSaveAsParameters rptParameters = JsonConvert.DeserializeObject<SsrdSaveAsParameters>(jsonData);

            StiReport report = StiMvcMobileDesigner.GetReportObject(HttpContext);
            
            // Get fully qualified path and file name
            string fqReportPath = GetFqReportPath(rptParameters.reportFile);

            // Fill Db Model
            var srReport = FillSReportSaveInfo(rptParameters.reportFile, fqReportPath);

            //TODO: Check to see if this file exists in db to set the Stamp to the proper value i.e. Update
            srReport.DateTimeStampRecord(DbChangeType.Create);

            // Save report info to database
            _repo.Save<SReport>(srReport);

            try
            {
                report.Save(fqReportPath);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("SaveAsReportTemplate -Error");
                ConfigLogger.Instance.LogError(ex.ToString());
            }

            Debug.WriteLine("SaveAsReportTemplate -Exit");
            return StiMvcMobileDesigner.SaveReportTemplateResult(HttpContext);
        }

        public ActionResult OpenSavedReportTemplate(SsdOpenSavedReportTemplate mvcMobileDesignerParameters)
        {
            Debug.WriteLine("OpenSavedReportTemplate -Enter");
            var rptData = mvcMobileDesignerParameters;

            StiReport report = new StiReport();
            var filename = (rptData != null) ? rptData.fileName : "";
            string reportPath = GetFqReportPath(filename);

            try
            {
                report.Load(reportPath);
            }
            catch (Exception ex)
            {
                Debug.WriteLine("OpenSavedReportTemplate -Error");
                ConfigLogger.Instance.LogError(ex.ToString());
            }

            Debug.WriteLine("OpenSavedReportTemplate -Exit");

            return View("Index", report);
        }
Any help is greatly appreciated,

Felix
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Save, Save As.., and Open Issues

Post by Alex K. »

Hello,

Please send us a simple project which reproduces the issue for analysis.

Thank you.
flapjack
Posts: 7
Joined: Sun Feb 26, 2017 9:05 pm

Re: Save, Save As.., and Open Issues

Post by flapjack »

I'll spin-up a sample project and get it to you shortly. ~thanks
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Save, Save As.., and Open Issues

Post by Alex K. »

Hello,

Ok. Thank you.
flapjack
Posts: 7
Joined: Sun Feb 26, 2017 9:05 pm

Re: Save, Save As.., and Open Issues

Post by flapjack »

Aleksey,

Apologize for the delay, but attached is the zipped solution. This is a VS2013 project using your demo nuget package drop. I haven't observed the Json error or the endless loop error that I saw previously. I will have to investigate further as to the exact cause of this issue.
SaveAsOpenDemo.zip
Save As and Open Sample Project
(905.96 KiB) Downloaded 191 times
Thanks Aleksey,

Felix
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Save, Save As.., and Open Issues

Post by Alex K. »

Hello,

We couldn't reproduce this bug. Please try to check the last prerelease build.

If the issue still present, please send us a step by step guide how to reproduce the issue.

Thank you.
flapjack
Posts: 7
Joined: Sun Feb 26, 2017 9:05 pm

Re: Save, Save As.., and Open Issues

Post by flapjack »

Back to you soon with detailed instructions.

felix
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Save, Save As.., and Open Issues

Post by Alex K. »

Hello,

Ok. Thank you.
Post Reply