public static void HandleMVCGrid(IApplicationBuilder app) { app.Run(async context => { string path = context.Request.PathBase.Value; if (path.Contains(".gif") || path.Contains(".png") || path.Contains(".jpg")) { path = "Images" + path.Replace("/MVCGridHandler.axd", string.Empty); byte[] image = GetResourceFileContentAsByteArray("MVCGrid.NetCore", path); context.Response.ContentType = "image/png"; await context.Response.Body.WriteAsync(image, 0, image.Length); } else { HttpRequest httpRequest = context.Request; string gridName = httpRequest.Query["Name"]; int statusCode; string html = GridHelpers.GenerateGrid(gridName, out statusCode, httpRequest.ToNameValueCollection()); if (statusCode != 0) { context.Response.StatusCode = statusCode; await context.Response.WriteAsync(html); } } }); }
internal static SignalRGridResponse GenerateSignalRGrid(string gridName, GridGenerationType type) { string html = string.Empty; string summaryhtml = string.Empty; int statusCode = 0; NameValueCollection nameValueCollection = new NameValueCollection(); html = GridHelpers.GenerateGrid(gridName, out statusCode, nameValueCollection); if (type == GridGenerationType.Row) { var doc = new HtmlDocument(); doc.LoadHtml(html); List <HtmlNode> trNodes = doc.DocumentNode.Descendants("tr").ToList(); HtmlNode trNode = trNodes.LastOrDefault(); HtmlNode summaryNode = doc.GetElementbyId($"MVCGridTable_{gridName}_Summary"); if (trNode != null) { html = trNode.OuterHtml; if (html.Contains("noresults") == true) { html = string.Empty; } } if (summaryNode != null) { summaryhtml = summaryNode.OuterHtml; } } return(new SignalRGridResponse() { Type = Enum.GetName(typeof(GridGenerationType), type), Gridname = gridName, Html = html, SummaryHtml = summaryhtml, }); }