protected virtual void OnCommandReceived(SystemCommandModel theCmd) { SystemCommandEnum theEnum; Enum.TryParse(theCmd.Name, true, out theEnum); if (theEnum == SystemCommandEnum.None) { return; } var paramList = new List <KeyValuePair <string, object> >(); paramList.Add(new KeyValuePair <string, object>("targetId", theCmd.TargetId)); if (theCmd.NewPreference.HasValue) { paramList.Add(new KeyValuePair <string, object>("preference", theCmd.NewPreference)); } CommandReceived?.Invoke(this, new CommandReceivedEventArgs { Command = theEnum, Parameters = paramList }); }
public void SendCommand(string deviceId, SystemCommandModel cmd) { var msg = JsonConvert.SerializeObject(cmd); _sbTasks.Add(_serviceClt.SendAsync(deviceId, new Message(Encoding.UTF8.GetBytes(msg)))); }