Web Report Designer throws exception when trying to create a report with a name that already exists

2 Answers 184 Views
.NET Framework Report Designer - Web Rest Service
Arthur
Top achievements
Rank 1
Veteran
Iron
Arthur asked on 23 Jun 2022, 08:51 AM

Hi,

I am trying to implement the Web Report Designer using version 16.1.22.511 under .NET Framework 4.8.

I have a custom IDefinitionStorage, but the behaviour is exactly the same using the native FileDefinitionStorage.

I have only one report named Report1.trdp. When I try and upload two reports in the Assets Manager, Report2.trdp and Report1.trdp, the following method gets called twice.

Task<ResourceFileModel> GetModelAsync(string uri)

Please see 1_upload_report1.png and 2_upload_report2.png to see what it returns, and 3_upload_results.png to see the result (it successfully uploaded Report2.trdp, and failed to upload Report1.trdp because it already exists).

 

Now I would have expected the same kind of behaviour when trying to create new reports, ie allow reports that don't match by name an existing one and reject reports that do or at least warn the user.

When I try and create a new report named Report2.trdp, the following method is called (see 4_new_report2.png)

Task<byte[]> GetAsync(string resourceName)

It returns null because no such report already exists, then the following method is called

Task<ResourceFileModel> SaveAsync(SaveResourceModel model, byte[] resource)

When I try and create Report1.trdp however, the first method (GetAsync) returns an actual byte[] (see 5_new_report1.png) and an exception is thrown by Telerik.WebReportDesigner.Services (see 6_new_report1.png). If I continue the execution, the second method (SaveAsync) eventually gets called, and my Report1.trdp gets overwritten by the new report.

I've also included some details, see 7_new_report1.png.

Thanks in advance,

Arthur

2 Answers, 1 is accepted

Sort by
0
Todor
Telerik team
answered on 28 Jun 2022, 08:37 AM

Hello Arthur,

Thank you for the detailed description of the issue. I confirm I managed to reproduce it for the .NET Framework. The designer overrides the existing report, which is not expected and we recognize it as a bug. I have logged it and voted on your behalf - If you create a new report with a name that already exists in the Web Designer for .NET 4.8, it automatically overrides the existing report. As a token of gratitude, we have updated your Telerik points.

In .NET Core/5/6 the workflow is as expected: When you try to create a new report with a name that already exists, the web designer asks you whether you want to override it.

The problem seems to be in the check whether the report exists in the Storage. Currently, for the .NET Framework implementation, it throws and the designer continues with overriding the existing report.

The workaround I may suggest is to override the ReportDesignerController's method ReportExistsAsync and return the correct result stating that the report already exists. The designer's script for the .NET Framework and .NET Core is the same, and this should fix the issue.

Regards,


Todor
Progress Telerik

Brand new Telerik Reporting course in Virtual Classroom - the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products. Check it out at https://learn.telerik.com/.
0
Arthur
Top achievements
Rank 1
Veteran
Iron
answered on 28 Jun 2022, 10:08 AM

Hello Todor,

Thanks for your input.

I have overridden ReportExistsAsync like so

public override async Task<IHttpActionResult> ReportExistsAsync([FromUri] string uri)
{
    var model = await _designerConfigurationInstance.DefinitionStorage.GetModelAsync(uri);

    if (model != null)
    {
        return new StatusCodeResult(HttpStatusCode.NoContent, this);
    }

    return await base.ReportExistsAsync(uri);
}

Now I do get an error message telling me that the report already exists (see error_already_exists.png), and SaveAsync is not called. This is already a major improvement.

I'm not being asked if I want to overwrite it though, anything I should do differently?

Neli
Telerik team
commented on 01 Jul 2022, 09:54 AM

Hi Arthur,

You may use Fiddler Jam to check if there are more details and logs about the error. I would recommend installing the Fiddler Jam extension then generating a log and sharing it with us.

I will be looking forward to receiving an update from you

Tags
.NET Framework Report Designer - Web Rest Service
Asked by
Arthur
Top achievements
Rank 1
Veteran
Iron
Answers by
Todor
Telerik team
Arthur
Top achievements
Rank 1
Veteran
Iron
Share this question
or