// Gets the list of network nodes by network id public NodesData GetNodes(string network, int page, int limit) { if (limit < 10 || limit > 100) { limit = 25; } if (page <= 0) { page = 1; } var offset = limit * (page - 1); var nodes = _states[network].Nodes; var nodesCount = nodes.Count; var listNodes = nodes.Skip(offset).Take(limit).ToList(); // Prepare the result and return var result = new NodesData { Page = page, Nodes = listNodes, OnlineCount = nodes.Count(n => n.Active), OfflineCount = nodes.Count(n => !n.Active), HaveNextPage = nodesCount > offset + limit, LastPage = ConvUtils.GetNumPages(nodesCount, limit), NumStr = nodesCount > 0 ? $"{offset + 1} - {offset + listNodes.Count} of {nodesCount}" : "0" }; return(result); }
public NodesData GetNodes(string network) { var net = Network.GetById(network); using (var db = ApiFab.GetDbContext()) { var result = new NodesData { Nodes = db.Nodes.Where(n => (n.Network == network) && (net.RandomNodes || (n.ModifyTime.AddMinutes(LiveTimeMinutes) >= DateTime.Now))) .OrderBy(n => n.ModifyTime) .Take(1000).ToList() }; return(result); } }
public NodesData GetNodes(string network) { using (var db = GetDbContext()) { var result = new NodesData { // ReSharper disable once CompareOfFloatsByEqualityOperator Nodes = db.Nodes .Where(n => (n.Network == network) && (n.ModifyTime.AddMinutes(LiveTimeMinutes) >= DateTime.Now)) .Take(1000).ToList() }; return(result); } }
public NodesData GetNodes(string network) { var net = Network.GetById(network); using (var db = ApiFab.GetDbContext()) { var now = DateTime.Now; var nodes = db.Nodes.Where(n => n.Network == network && (net.RandomNodes || n.ModifyTime.AddSeconds(Settings.NodesLivePeriodSec) >= now)) .OrderBy(n => n.ModifyTime) .Take(1000).ToList(); var result = new NodesData { Nodes = nodes }; return(result); } }