Page 1 of 2

Save, Save As.., and Open Issues

Posted: Mon Mar 13, 2017 9:04 pm
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

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

Posted: Thu Mar 16, 2017 7:17 am
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.

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

Posted: Sat Mar 18, 2017 7:46 pm
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

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

Posted: Tue Mar 21, 2017 6:28 am
by Alex K.
Hello,

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

Thank you.

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

Posted: Tue Mar 21, 2017 4:30 pm
by flapjack
I'll spin-up a sample project and get it to you shortly. ~thanks

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

Posted: Tue Mar 21, 2017 6:13 pm
by Alex K.
Hello,

Ok. Thank you.

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

Posted: Sat Mar 25, 2017 5:25 pm
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 233 times
Thanks Aleksey,

Felix

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

Posted: Mon Mar 27, 2017 9:32 pm
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.

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

Posted: Tue Mar 28, 2017 12:19 am
by flapjack
Back to you soon with detailed instructions.

felix

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

Posted: Tue Mar 28, 2017 7:20 am
by Alex K.
Hello,

Ok. Thank you.