Back to Devexpress

IErrorJsonSerializer Interface

xtrareports-devexpress-dot-xtrareports-dot-web-dot-reportdesigner-dot-services-54d0c0fb.md

latest2.5 KB
Original Source

IErrorJsonSerializer Interface

Serializes errors that occur on the server to send them to the client.

Namespace : DevExpress.XtraReports.Web.ReportDesigner.Services

Assembly : DevExpress.XtraReports.v25.2.Web.dll

NuGet Package : DevExpress.Web.Reporting.Common

Declaration

csharp
public interface IErrorJsonSerializer
vb
Public Interface IErrorJsonSerializer

Remarks

You can implement and register a custom IErrorJsonSerializerservice and use the service to send error information to the client.

The following code snippet is a sample controller that creates a Report Designer View Model and returns it to the client. If an error occurs, the IErrorJsonSerializer service is used to send the information to the client.

csharp
[ApiController]
[Authorize]
[Route("api/[controller]")]
public class ReportDesignerSetupController : ControllerBase {
    [HttpPost("[action]")]
    public object GetReportDesignerModel([FromForm] string reportUrl,
        [FromServices] IReportDesignerModelBuilder reportDesignerModel,
        [FromServices] IErrorJsonSerializer errorSerializer,
        [FromServices] IReportDesignerClientSideModelGenerator modelGenerator) {
        Dictionary<string, object> dataSources = new Dictionary<string, object>();
        //Fill a data source set if needed
        if(something_goes_wrong)
            return errorSerializer.FromError("Try again later");

        reportDesignerModel
            .Report(reportUrl)
            .DataSources(dataSources)
            .DesignerUri("/DXXRDAAA")
            .ViewerUri("/DXXRDVAAA")
            .QueryBuilderUri("/DXXQBAAA")
            .BuildJsonModel();
        var model = reportDesignerModel.BuildModel();
        var modelJson = modelGenerator.GetJsonModelScript(model);
        return Content(modelJson, MediaTypeNames.Application.Json);
    }
}

See Also

IErrorJsonSerializer Members

DevExpress.XtraReports.Web.ReportDesigner.Services Namespace