private KeepAliveItem[] OnUpdate() { var req = new EKeepAliveRequest { Groups = _model.Groups.ToArray(), Instances = _model.Instances.ToArray() }; EKeepAlive_[] response; try { response = _model.Cache.Service.GetKeepAlives(req); } catch { return(new[] { new KeepAliveItem { Instance = new Instance { ID = -1, Name = "INTERNAL", Source = new Source { ID = -1, Name = "ERROR" } }, Created = DateTime.Now } }); } if (response.Length > 0) { LastId = response.Max(x => x.ID); } response = response.GroupBy(x => _model.Cache.GetInstance(x.InstanceID).Name).OrderBy(g => g.Key) .SelectMany(g => g.OrderBy(x => _model.Cache.GetInstance(x.InstanceID).Source.Name)).ToArray(); var result = response.Select(x => { var created = x.Created.ToLocalTime(); var statusIsOk = (DateTime.Now - x.Created.ToLocalTime()).TotalSeconds < _model.KeepAliveWarningPeriod; return(new KeepAliveItem { Created = created, CreatedStr = created.ToString(_model.DateTimeFormat), Instance = _model.Cache.GetInstance(x.InstanceID), StatusIsOk = statusIsOk, Status = statusIsOk ? "OK" : "ERROR" }); }); return(result.ToArray()); }
public EKeepAlive_[] GetKeepAlives(EKeepAliveRequest aRequest) { var reqJson = JsonConvert.SerializeObject(aRequest); var resJson = PostJson("keepalive2", reqJson); var result = JsonConvert.DeserializeObject <EKeepAlive_[]>(resJson); return(result); }