private void NodeState_StateChanged(object sender, NodeViewState e) { if (e.Id == 0 && e.TimeStamp != default(DateTime)) { History.Insert(e); BriefHist = History.FindHistory(100); if (BriefHist.Any()) { selId = BriefHist.First().id; } StateHasChanged(); } }
private async Task RefreshNodeStatusAsync() { int port = 4504; if (config["network"].Equals("mainnet", StringComparison.InvariantCultureIgnoreCase)) { port = 5504; } var bb = await client.GetBillBoardAsync(); var bag = new ConcurrentDictionary <string, GetSyncStateAPIResult>(); var tasks = bb.NodeAddresses .Select(async node => { var lcx = LyraRestClient.Create(config["network"], Environment.OSVersion.ToString(), "Nebula", "1.4", $"https://{node.Value}:{port}/api/Node/"); try { var syncState = await lcx.GetSyncState(); bag.TryAdd(node.Key, syncState); } catch (Exception ex) { bag.TryAdd(node.Key, null); } }); await Task.WhenAll(tasks); var nvs = new NodeViewState( isLoading: false, billBoard: bb, NodeStatus: bag, ipdb: config["ipdb"]); nvs.Id = 0; // create new for liteDB nvs.TimeStamp = DateTime.UtcNow; History.Insert(nvs); }
public bool Update(NodeViewState record) { return(_liteDb.GetCollection <NodeViewState>("NodeViewState") .Update(record)); }
public int Insert(NodeViewState record) { return(_liteDb.GetCollection <NodeViewState>("NodeViewState") .Insert(record)); }