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