|
|
@ -23,7 +23,7 @@ namespace ISPChk |
|
|
|
|
|
|
|
public async void LoadHostsFromDatabase() |
|
|
|
{ |
|
|
|
List<Host> hosts = await _context.Hosts.Include(host => host.PingItems).ToListAsync(); |
|
|
|
List<Host> hosts = await _context.Hosts.ToListAsync(); |
|
|
|
foreach (Host host in hosts) |
|
|
|
{ |
|
|
|
AddHost(host); |
|
|
@ -47,7 +47,7 @@ namespace ISPChk |
|
|
|
// Do not use the outer context, not threadsafe?
|
|
|
|
var ctx = CreateDbContext(); |
|
|
|
var h = await ctx.Hosts.FindAsync(host.HostId); |
|
|
|
ctx.Entry(h).Collection(hst => hst.PingItems).Load(); |
|
|
|
ctx.Entry(h).Collection(hst => hst.PingItems).Query().FirstOrDefault(); |
|
|
|
|
|
|
|
IPAddress pingAddress; |
|
|
|
|
|
|
@ -139,7 +139,7 @@ namespace ISPChk |
|
|
|
if (min > timeout) |
|
|
|
min = 0; |
|
|
|
System.Diagnostics.Debug.WriteLine(h.HostName+": "+"min:" + min + " max:" + max + " avg:" + avg); |
|
|
|
PingItem pi = new PingItem { Date = DateTimeOffset.UtcNow, Min = min, Max = max, Avg = avg, Failures = failures }; |
|
|
|
PingItem pi = new PingItem { Date = DateTimeOffset.UtcNow.DateTime, Min = min, Max = max, Avg = avg, Failures = failures }; |
|
|
|
h.PingItems.Add(pi); |
|
|
|
ctx.SaveChanges(); |
|
|
|
// Throttle if everything is ok
|
|
|
|