desinger.onSaveReport post json raise error

Stimulsoft Reports.JS discussion
Post Reply
pall
Posts: 17
Joined: Mon Nov 02, 2015 1:15 pm

desinger.onSaveReport post json raise error

Post by pall »

onSaveReport event
//ajax post report file to server and save,
function test(e) {

var data = { "id": e.report.reportName, "fn": e.report.saveToJsonString() };

$.ajax({
url: "/Report/SaveReport.ashx",
dataType: 'json',
async: false,
type: 'get',
data: data,
complete: function (msg) {
},
success: function (data) {
alert("success");
},
error: function (a, b, c) {
alert(a.responseText);
}
});
}
//event
var options = new Stimulsoft.Designer.StiDesignerOptions();
options.appearance.fullScreenMode = true;
var designer = new Stimulsoft.Designer.StiDesigner(options, "StiDesigner", false);
designer.onSaveReport = function (e) {
test(e);
};

//when run test(e) method designer show an error
test@http://localhost:60468/BaseUI/ClsReport.js:33:9 ClsReport/this.designReport/designer.onSaveReport@http://localhost:60468/BaseUI/ClsReport.js:60:13 o

ClsReport is the class to opt Report

the method test(e) call by button click event success
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: desinger.onSaveReport post json raise error

Post by HighAley »

Hello.

Sorry, this information is not enough to help you.
Could you send us a working sample to reproduce your issue?

Thank you.
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: desinger.onSaveReport post json raise error

Post by Vladimir »

Hello,

Please specify the following:
1. Which line is number 33, and which line is number 60 in the your code fragment?
2. Does the error is reproduced, if you change the code as follows:
var data = { "id": e.report.reportName, "fn": { } };

Thank you.
pall
Posts: 17
Joined: Mon Nov 02, 2015 1:15 pm

Re: desinger.onSaveReport post json raise error

Post by pall »

save report mrt to jsonString,and use $.ajax() method send to server,server save the json string to file.
line 33 is call $.ajax.

server code is here

Code: Select all

        public void ProcessRequest(HttpContext context)
        {
            string action = context.Request["Action"];
            string fn = context.Request["fn"];
            string id = context.Request["id"];
            var reportPath = context.Server.MapPath(string.Format("Report/{0}.mrt", id));
            if (File.Exists(reportPath))
            {
                File.Delete(reportPath);
            }
            byte[] myByte = System.Text.Encoding.UTF8.GetBytes(fn);
            try {
                using (FileStream fs = new FileStream(reportPath, FileMode.CreateNew, FileAccess.Write))
                {
                    fs.Write(myByte, 0, myByte.Length);
                    fs.Flush();
                }
                context.Response.Write("1");
            }
            catch
            {
                context.Response.Write("0");
            }
        }
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: desinger.onSaveReport post json raise error

Post by Vladimir »

Hello,

Please change the code for testing as shown below:
var data = { "id": "report-name", "fn": "report-data" };

The error reproduced in this case?
This is necessary in order to find - an error occurs due to the json report or in the data transmission method.

Thank you.
pall
Posts: 17
Joined: Mon Nov 02, 2015 1:15 pm

Re: desinger.onSaveReport post json raise error

Post by pall »

the method test() is called by a button click function,run right.but test() called by onSaveReport event,designer raise an error as before.if cancel $.ajax() code in test() function,designer never raise error again
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: desinger.onSaveReport post json raise error

Post by Vladimir »

Hello Pall,

We are unable to reproduce the problem. Please see our test project:
test-website.zip
(2.19 MiB) Downloaded 195 times
Please make changes to this project that we were able to reproduce the problem.

Thank you.
pall
Posts: 17
Joined: Mon Nov 02, 2015 1:15 pm

Re: desinger.onSaveReport post json raise error

Post by pall »

test-website.zip is ok.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: desinger.onSaveReport post json raise error

Post by HighAley »

Hello.

We are always glad to help you.
Let us know if you need any additional help.

Thank you.
Post Reply