public async Task <Error> GetEventChanges() { var parameters = new Parameters(); parameters.datetime = _dateTime; var jsonrpc = new JsonRpcClient(parameters); if (await jsonrpc.SendRequest("event::changes")) { var response = jsonrpc.GetEvents(); foreach (JdEvent e in response.Result) { switch (e.Name) { case "cmd::update": var ev = e as Event <EventOptionCmd>; var cmd = (from c in CommandList where c.id == ev.Option.CmdId select c).FirstOrDefault(); if (cmd != null) { if (cmd.DateTime < ev.DateTime) { cmd.Value = ev.Option.Value; cmd.DateTime = ev.DateTime; } } break; case "eqLogic::update": var eveq = e as Event <EventOptionEqLogic>; var eq = (from c in EqLogicList where c.Id == eveq.Option.EqLogicId select c).FirstOrDefault(); if (eq != null) { if (eq.DateTime < eveq.DateTime) { await UpdateEqLogic(eq); eq.DateTime = eveq.DateTime; } } break; default: break; } } _dateTime = response.DateTime; } return(jsonrpc.Error); }
public async Task GetEventChanges() { var parameters = new Parameters(); parameters.datetime = _dateTime; var jsonrpc = new JsonRpcClient(parameters); if (await jsonrpc.SendRequest("event::changes")) { var response = jsonrpc.GetEvents(); foreach (JdEvent e in response.result) { switch (e.name) { case "cmd::update": var ev = e as Event<Option>; var cmds = from c in CommandList where c.id == ev.option.cmd_id select c; foreach (Command cmd in cmds) { if (cmd.datetime < ev.datetime) { cmd.Value = ev.option.value; cmd.datetime = ev.datetime; } } break; } } _dateTime = response.datetime; } }