public async Task RunUpdatesAsync() { var store = _netStore; if (store == null) { return; } Interlocked.Increment(ref _refreshCycle); { try { RetrieveConfigurationArgs.ConfigurationData[] configs = await store.ExecuteAsync(new RetrieveConfigurationArgs()); Configs = configs; } catch (Exception ex) { } } { try { var loginsArgs = new FindHyperDocumentsArgs(typeof(HyperUserLoginAttempt)); loginsArgs.Limit = 20; loginsArgs.DescriptorConditions.AddCondition(nameof(HyperUserLoginAttempt.DateTimeUTC), DateTime.UtcNow - TimeSpan.FromMinutes(120), Comparers.GreaterThanOrEqual); var docs = await store.ExecuteAsync(loginsArgs); Logins = docs?.Select(it => it.GetPayload <HyperUserLoginAttempt>()).Where(it => it != null).ToArray() ?? new HyperUserLoginAttempt[] { }; Logins = Logins?.GroupBy(x => x.UserName).Select(x => x.FirstOrDefault()).ToArray(); // Distincts by UserName } catch (Exception ex) { } } { try { var countArgs = new CountHyperDocumentsArgs(typeof(HyperMission)); _missionsCount = await store.ExecuteAsync(countArgs); } catch (Exception ex) { } } { try { var countArgs = new CountHyperDocumentsArgs(typeof(HyperWorkflow)); _workflowsCount = await store.ExecuteAsync(countArgs); } catch (Exception ex) { } } { try { var logsArgs = new CountLogsArgs() { Age = TimeSpan.FromSeconds(10) }; var logsCount = await store.ExecuteAsync(logsArgs); if (_refreshCycle % 2 == 0) { lock (_syncRoot) { _activityHistory.Enqueue(logsCount); while (_activityHistory.Count > _refreshCount) { _activityHistory.Dequeue(); } } } } catch (Exception ex) { } } { try { var countArgs = new CountHyperDocumentsArgs(typeof(HyperAsset)); _assetsCount = await store.ExecuteAsync(countArgs); } catch (Exception ex) { } } { try { var fullStatus = await store.ExecuteAsync(new RetrieveHardwareStatusArgs() { RetrieveDetailedDrivesInfo = true, RetrieveOSInfo = true, RetrieveProcessorsInfo = true }); _fullStatus = fullStatus; SetRAMNotification(false); SetCPUNotification(false); SetDiskNotification(false); if (fullStatus != null) { _status = $"CPU {fullStatus.ProcessorsInfo?.Average(it => it.PercentProcessorTime):#0.0}% RAM {fullStatus.OSInfo?.PercentageUsedRAM:##.0}% "; var cpuTime = fullStatus.ProcessorsInfo.Average(it => it.PercentProcessorTime); if (cpuTime.HasValue && _refreshCycle % 2 == 0) { lock (_syncRoot) { _cpuHistory.Enqueue(cpuTime.Value); while (_cpuHistory.Count > _refreshCount) { _cpuHistory.Dequeue(); } } } var ram = fullStatus.OSInfo?.PercentageUsedRAM; if (ram.HasValue && _refreshCycle % 2 == 0) { lock (_syncRoot) { _ramHistory.Enqueue(ram.Value); while (_ramHistory.Count > _refreshCount) { _ramHistory.Dequeue(); } } } SetCPUNotification(cpuTime > 50); SetRAMNotification(ram > 50); SetDiskNotification(fullStatus.DetailedDrivesInfo.Any(it => it.Progress > 0.9)); // 80% disk drive. Notify(nameof(Status)); } } catch (Exception ex) { } } Notify(nameof(Configs)); Notify(nameof(FullStatus)); }