Detailed configuration of jsreport rendering request
예제 #1
0
        /// <summary>
        /// Overload for more sophisticated rendering.
        /// </summary>
        /// <param name="request">ram name="request">Description of rendering process <see cref="RenderRequest"/></param>
        /// <exception cref="JsReportException"></exception>
        /// <returns>Report result promise</returns>
        public async Task <Report> RenderAsync(RenderRequest request)
        {
            request.options = request.options ?? new RenderOptions();
            request.CopyDynamicAttributes();

            request.Validate();

            var client   = CreateClient();
            var settings = new JsonSerializerSettings()
            {
                NullValueHandling          = NullValueHandling.Ignore,
                ReferenceLoopHandling      = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
                PreserveReferencesHandling = PreserveReferencesHandling.All
            };

            var response =
                await
                client.PostAsync("api/report",
                                 new StringContent(JsonConvert.SerializeObject(request, settings), Encoding.UTF8,
                                                   "application/json")).ConfigureAwait(false);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw JsReportException.Create("Unable to render template. ", response);
            }

            response.EnsureSuccessStatusCode();

            return(await ReportFromResponse(response).ConfigureAwait(false));
        }
예제 #2
0
 /// <summary>
 /// Overload for more sophisticated rendering.
 /// </summary>
 /// <param name="request">ram name="request">Description of rendering process <see cref="RenderRequest"/></param>
 /// <exception cref="JsReportException"></exception>
 /// <returns>Report result promise</returns>
 public async Task <Report> RenderAsync(RenderRequest request, CancellationToken ct = default(CancellationToken))
 {
     return(await RenderAsync((object)request, ct).ConfigureAwait(false));
 }
예제 #3
0
 /// <summary>
 /// Overload for more sophisticated rendering.
 /// </summary>
 /// <param name="request">ram name="request">Description of rendering process <see cref="RenderRequest"/></param>
 /// <exception cref="JsReportException"></exception>
 /// <returns>Report result promise</returns>
 public async Task<Report> RenderAsync(RenderRequest request, CancellationToken ct = default(CancellationToken))
 {
     return await RenderAsync((object)request, ct).ConfigureAwait(false);
 }
예제 #4
0
 /// <summary>
 /// Specify comnpletely the rendering requests, see https://jsreport.net/learn/api for details
 /// </summary>
 /// <param name="request">ram name="request">Description of rendering process</param>
 /// <exception cref="JsReportException"></exception>
 /// <returns>Report result promise</returns>
 public Task <Report> RenderAsync(RenderRequest request, CancellationToken ct = default(CancellationToken))
 {
     return(RenderAsync(SerializerHelper.SerializeRenderRequest(request, ContractResolverForDataProperty), ct));
 }
예제 #5
0
 /// <summary>
 /// Specify comnpletely the rendering requests, see https://jsreport.net/learn/api for details
 /// </summary>
 /// <param name="request">ram name="request">Description of rendering process</param>
 /// <exception cref="JsReportException"></exception>
 /// <returns>Report result promise</returns>
 public Task <Report> RenderAsync(RenderRequest request, CancellationToken ct = default(CancellationToken))
 {
     return(RenderAsync(SerializerHelper.SerializeRenderRequest(request), ct));
 }
예제 #6
0
        /// <summary>
        /// Overload for more sophisticated rendering.
        /// </summary>
        /// <param name="request">ram name="request">Description of rendering process <see cref="RenderRequest"/></param>
        /// <exception cref="JsReportException"></exception>
        /// <returns>Report result promise</returns>
        public async Task<Report> RenderAsync(RenderRequest request)
        {
            request.options = request.options ?? new RenderOptions();
            request.CopyDynamicAttributes();

            request.Validate();

            var client = CreateClient();

            var settings = new JsonSerializerSettings()
                {
                    NullValueHandling = NullValueHandling.Ignore,
                    ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
                    PreserveReferencesHandling = PreserveReferencesHandling.All
                };
          
            var response =
                await
                client.PostAsync("/api/report",
                                 new StringContent(JsonConvert.SerializeObject(request, settings), Encoding.UTF8,
                                                   "application/json")).ConfigureAwait(false);

            if (response.StatusCode != HttpStatusCode.OK)
                throw JsReportException.Create("Unable to render template. ", response);

            response.EnsureSuccessStatusCode();

            return await ReportFromResponse(response).ConfigureAwait(false);
        }