public async void RefreshStatisticsFromDB(string path) { if (File.Exists(path)) { ServerService.Database.Statistics stats = new ServerService.Database.Statistics(path); List <ServerService.Database.StatisticsEntry> entries = await stats.GetStatisticEntriesAsync(Settings.Instance.LinesToRead); bool dropRestart = entries.Count > Settings.Instance.LinesToRead; Keys = new DateTime[entries.Count]; ActivePlayers = new int[entries.Count]; memoryUsage = new long[entries.Count]; List <DateTime> tmpRestarts = new List <DateTime>(); int prevRestarts = 0; for (int i = 0; i < entries.Count; i++) { Keys[i] = entries[i].TimeStamp; ActivePlayers[i] = entries[i].CurrentPlayers; memoryUsage[i] = entries[i].CurrentMemory; if (entries[i].Restarts > prevRestarts) { if (dropRestart) { dropRestart = false; } else { tmpRestarts.Add(entries[i].TimeStamp); } prevRestarts = entries[i].Restarts; } } Restarts = tmpRestarts.ToArray(); } }
public async void RefreshStatisticsFromDB(string path) { if (File.Exists(path)) { ServerService.Database.Statistics stats = new ServerService.Database.Statistics(path); List<ServerService.Database.StatisticsEntry> entries = await stats.GetStatisticEntriesAsync(Settings.Instance.LinesToRead); bool dropRestart = entries.Count > Settings.Instance.LinesToRead; Keys = new DateTime[entries.Count]; ActivePlayers = new int[entries.Count]; memoryUsage = new long[entries.Count]; List<DateTime> tmpRestarts = new List<DateTime>(); int prevRestarts = 0; for (int i = 0; i < entries.Count; i++) { Keys[i] = entries[i].TimeStamp; ActivePlayers[i] = entries[i].CurrentPlayers; memoryUsage[i] = entries[i].CurrentMemory; if (entries[i].Restarts > prevRestarts) { if (dropRestart) { dropRestart = false; } else { tmpRestarts.Add(entries[i].TimeStamp); } prevRestarts = entries[i].Restarts; } } Restarts = tmpRestarts.ToArray(); } }