public static async Task SendGridData(string gridName, GridGenerationType gridGenerationType) { SignalRGridSession session = MVCGridSignalR.SignalRGridSessions[gridName]; List <string> connectionIds = session.GridConnections; SignalRGridResponse signalrGridResponse = SignalRGridHelpers.GenerateSignalRGrid(gridName, gridGenerationType); string json = JsonConvert.SerializeObject(signalrGridResponse); await _hubContext.Clients.Clients(connectionIds).SendCoreAsync("Message", new object[] { json }); }
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, }); }