public async Task ExecuteCommand(Command cmd, Parameters parameters = null) { if (config.IsDemoEnabled) { return; } cmd.Updating = true; if (parameters == null) { parameters = new Parameters(); parameters.id = cmd.id; parameters.name = cmd.name; } var jsonrpc = new JsonRpcClient(parameters); if (await jsonrpc.SendRequest("cmd::execCmd")) { var response = jsonrpc.GetRequestResponseDeserialized <Response <CommandResult> >(); cmd.value = response.result.value; } else { cmd.value = "N/A"; } cmd.Updating = false; }
public async Task <Error> SendNotificationUri(string uri) { Parameters parameters = new Parameters(); parameters.plugin = "pushNotification"; parameters.platform = "windows"; parameters.query = uri; if (config.IdPush != null) { parameters.id = config.IdPush; } var jsonrpc = new JsonRpcClient(parameters); if (await jsonrpc.SendRequest("Iq")) { // Récupère la liste de tous les eqLogics var reponse = jsonrpc.GetRequestResponseDeserialized <Response <string> >(); if (reponse != null) { config.IdPush = reponse.result; } } return(jsonrpc.Error); }
public async Task <Error> PingJeedom() { Updating = true; LoadingMessage = "Contacte Jeedom"; var jsonrpc = new JsonRpcClient(); //LoadingMessage = "Tentative de connexion en https"; config.Address.ProtocolType = Address.Protocol.Https; if (await jsonrpc.SendRequest("ping")) { var response = jsonrpc.GetRequestResponseDeserialized <Response <string> >(); if (response.result == "pong") { Updating = false; return(null); } } //LoadingMessage = "Tentative de connexion en https en ignorant les erreurs de certificat"; config.Address.ProtocolType = Address.Protocol.SelfSigned; if (await jsonrpc.SendRequest("ping")) { var response = jsonrpc.GetRequestResponseDeserialized <Response <string> >(); if (response.result == "pong") { Updating = false; return(null); } } //LoadingMessage = "Tentative de connexion en http"; config.Address.ProtocolType = Address.Protocol.Http; if (await jsonrpc.SendRequest("ping")) { var response = jsonrpc.GetRequestResponseDeserialized <Response <string> >(); if (response.result == "pong") { Updating = false; return(null); } } // Par sécurité on retourne sur https config.Address.ProtocolType = Address.Protocol.Https; Updating = false; return(jsonrpc.Error); }
/// <summary> /// Gets a collection of Todos. /// </summary> /// <param name="userId">The ID of the User to get Todos for (optional)</param> /// <returns>A collection of all available Todos</returns> public IEnumerable <Todo> GetTodos(int?userId = null) { Log.Debug($"Getting Todos"); var request = _client.CreateRequest("getTodos", new { userId }); var response = _client.SendRequest <IEnumerable <Todo> >(request); Log.Debug($"Found {response.Count()} Todos"); return(response); }
public async Task <Error> DownloadVersion() { var jsonrpc = new JsonRpcClient(); if (await jsonrpc.SendRequest("version")) { var response = jsonrpc.GetRequestResponseDeserialized <Response <string> >(); Version = response.result; } return(jsonrpc.Error); }
private async Task <Error> DownloadDateTime() { var jsonrpc = new JsonRpcClient(); if (await jsonrpc.SendRequest("datetime")) { var response = jsonrpc.GetRequestResponseDeserialized <Response <double> >(); _dateTime = response.result; } return(jsonrpc.Error); }
public static async Task<Error> PingJeedom() { var jsonrpc = new JsonRpcClient(); if (await jsonrpc.SendRequest("ping")) { var response = jsonrpc.GetRequestResponseDeserialized<ResponseString>(); if (response.result == "pong") return null; } return jsonrpc.Error; }
public async Task <Error> ConnectJeedomByLogin() { Parameters parameters = new Parameters(); parameters.login = config.Login; parameters.password = config.Password; //if (config.TwoFactor == true) // parameters.twoFactorCode = config.TwoFactorCode; var jsonrpc = new JsonRpcClient(parameters); //LoadingMessage = "Tentative de connexion en https"; config.Address.ProtocolType = Address.Protocol.Https; if (await jsonrpc.SendRequest("user::getHash")) { var reponse = jsonrpc.GetRequestResponseDeserialized <Response <string> >(); config.ApiKey = reponse.result; return(jsonrpc.Error); } //LoadingMessage = "Tentative de connexion en https en ignorant les erreurs de certificat"; config.Address.ProtocolType = Address.Protocol.SelfSigned; if (await jsonrpc.SendRequest("user::getHash")) { var reponse = jsonrpc.GetRequestResponseDeserialized <Response <string> >(); config.ApiKey = reponse.result; return(jsonrpc.Error); } //LoadingMessage = "Tentative de connexion en http"; config.Address.ProtocolType = Address.Protocol.Http; if (await jsonrpc.SendRequest("user::getHash")) { var reponse = jsonrpc.GetRequestResponseDeserialized <Response <string> >(); config.ApiKey = reponse.result; return(jsonrpc.Error); } // Par sécurité on retourne sur https config.Address.ProtocolType = Address.Protocol.Https; return(jsonrpc.Error); }
/*public async Task<bool> SendNotificationUri(string uri) * { * var httpRpcClient = new HttpRpcClient("/plugins/pushNotification/php/updatUri.php?api=" + config.ApiKey + "&id=" + config.NotificationObjectId + "&uri=" + uri); * * return await httpRpcClient.SendRequest(); * }*/ private async Task UpdateScene(Scene scene) { var parameters = new Parameters(); parameters.id = scene.Id; var jsonrpc = new JsonRpcClient(parameters); if (await jsonrpc.SendRequest("scenario::byId")) { var response = jsonrpc.GetRequestResponseDeserialized <Response <Scene> >(); scene.lastLaunch = response.result.lastLaunch; } }
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 static async Task <Error> PingJeedom() { var jsonrpc = new JsonRpcClient(); if (await jsonrpc.SendRequest("ping")) { var response = jsonrpc.GetRequestResponseDeserialized <ResponseString>(); if (response.result == "pong") { return(null); } } return(jsonrpc.Error); }
public async Task <Error> SearchConfigByKey(string key, string plugin) { Parameters parameters = new Parameters(); parameters.key = key; parameters.plugin = plugin; var jsonrpc = new JsonRpcClient(parameters); if (await jsonrpc.SendRequest("config::byKey")) { configByKey = jsonrpc.GetRequestResponseDeserialized <Response <string> >().result; } return(jsonrpc.Error); }
public async Task <Error> DownloadScenes() { var jsonrpc = new JsonRpcClient(); if (await jsonrpc.SendRequest("scenario::all")) { SceneList.Clear(); var response = jsonrpc.GetRequestResponseDeserialized <Response <ObservableCollection <Scene> > >(); if (response != null) { SceneList = response.result; } } return(jsonrpc.Error); }
public Butler() { if (string.IsNullOrEmpty(ExecutablePath)) { throw new FileNotFoundException("Butler executable not found."); } if (string.IsNullOrEmpty(DatabasePath)) { throw new FileNotFoundException("Butler database not found."); } var butlerArgs = string.Format(startupArgs, DatabasePath); proc = new Process { EnableRaisingEvents = true, StartInfo = new ProcessStartInfo { Arguments = butlerArgs, FileName = ExecutablePath, RedirectStandardError = true, RedirectStandardOutput = true, UseShellExecute = false, CreateNoWindow = true } }; proc.OutputDataReceived += Proc_OutputDataReceived; proc.ErrorDataReceived += Proc_ErrorDataReceived; proc.Start(); proc.BeginErrorReadLine(); proc.BeginOutputReadLine(); if (!startupEvent.WaitOne(10000)) { proc.Kill(); throw new Exception("Butler failed to start properly."); } client = new JsonRpcClient(endpoint); client.NotificationReceived += Client_NotificationReceived; client.RequestReceived += Client_RequestReceived; client.SendRequest <Dictionary <string, object> >(Methods.Meta_Authenticate, new Dictionary <string, object>() { { "secret", secret } }); }
public async Task <Error> DownloadInteraction() { var jsonrpc = new JsonRpcClient(); //Ajouter le téléchargemnent et la mise a jours des interaction Jeedom try { var storageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///JeedomAppVoiceCommandes.xml")); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(storageFile); VoiceCommandDefinition commandDefinitions; string countryCode = CultureInfo.CurrentCulture.Name.ToLower(); if (countryCode.Length == 0) { countryCode = "fr-fr"; } if (VoiceCommandDefinitionManager.InstalledCommandDefinitions.TryGetValue("JeedomAppCommandSet_" + countryCode, out commandDefinitions)) { List <string> InteractsList = new List <string>(); if (await jsonrpc.SendRequest("interactQuery::all")) { InteractList.Clear(); var response = jsonrpc.GetRequestResponseDeserialized <Response <ObservableCollection <Interact> > >(); if (response != null) { InteractList = response.result; } } foreach (var Iteract in InteractList) { InteractsList.Add(Iteract.query); } await commandDefinitions.SetPhraseListAsync("InteractList", InteractsList); } } catch (Exception ex) { // System.Diagnostics.Debug.WriteLine("Updating Phrase list for VCDs: " + ex.ToString()); } return(jsonrpc.Error); }
public async Task RunScene(Scene scene) { if (config.IsDemoEnabled) { return; } var parameters = new Parameters(); parameters.id = scene.Id; parameters.state = "run"; var jsonrpc = new JsonRpcClient(parameters); if (await jsonrpc.SendRequest("scenario::changeState")) { await UpdateScene(scene); } }
public async Task <Error> interactTryToReply(string query) { InteractReply = ""; var jsonrpc = new JsonRpcClient(); Parameters parameters = new Parameters(); parameters.query = query; jsonrpc.SetParameters(parameters); if (await jsonrpc.SendRequest("interact::tryToReply")) { var response = jsonrpc.GetRequestResponseDeserialized <Response <string> >(); if (response != null) { InteractReply = response.result; } } return(jsonrpc.Error); }
public async Task <bool> Upgrade() { if (config.IsDemoEnabled) { return(true); } var jsonrpc = new JsonRpcClient(); await jsonrpc.SendRequest("update::update"); if (jsonrpc.Error == null) { return(true); } else { return(false); } }
public async Task <bool> Shutdown() { if (config.IsDemoEnabled) { return(true); } var jsonrpc = new JsonRpcClient(); await jsonrpc.SendRequest("jeeNetwork::halt"); if (jsonrpc.Error == null) { return(true); } else { return(false); } }
public async Task <Error> CreateEqLogicMobile() { Parameters parameters = new Parameters(); parameters.plugin = "mobile"; parameters.platform = "windows"; var jsonrpc = new JsonRpcClient(parameters); if (await jsonrpc.SendRequest("Iq")) { // Récupère la liste de tous les eqLogics var reponse = jsonrpc.GetRequestResponseDeserialized <Response <string> >(); if (reponse != null) { config.IdMobile = reponse.result; } } return(jsonrpc.Error); }
public async Task <Error> CheckTwoFactorConnexion() { Parameters parameters = new Parameters(); parameters.login = config.Login; var jsonrpc = new JsonRpcClient(parameters); if (await jsonrpc.SendRequest("user::useTwoFactorAuthentification")) { var reponse = jsonrpc.GetRequestResponseDeserialized <Response <string> >(); if (reponse.result == "1") { config.TwoFactor = true; } else { config.TwoFactor = false; } } return(jsonrpc.Error); }
/*public async Task UpdateObject(JdObject obj) * { * var parameters = new Parameters(); * parameters.object_id = obj.Id; * var jsonrpc = new JsonRpcClient(parameters); * * if (await jsonrpc.SendRequest("eqLogic::byObjectId")) * { * var response = jsonrpc.GetRequestResponseDeserialized<Response<ObservableCollection<EqLogic>>>(); * if (response.result != null) * { * foreach (EqLogic eqnew in response.result) * { * var lst = from e in EqLogicList where e.Id == eqnew.Id select e; * if (lst.Count() != 0) * { * var eqold = lst.FirstOrDefault(); * eqnew.Cmds = eqold.Cmds; * eqold = eqnew; * } * else * { * EqLogicList.Add(eqnew); * obj.EqLogics.Add(eqnew); * } * await UpdateEqLogic(eqnew); * } * } * } * }*/ public async Task UpdateObjectList() { var jsonrpc = new JsonRpcClient(); if (await jsonrpc.SendRequest("object::all")) { var response = jsonrpc.GetRequestResponseDeserialized <Response <ObservableCollection <JeedomObject> > >(); foreach (JeedomObject obj in response.result) { var lst = from o in ObjectList where o.id == obj.id select o; if (lst.Count() != 0) { var ob = lst.FirstOrDefault(); ob = obj; } else { ObjectList.Add(obj); } } } }
public async Task <Error> DownloadObjects() { var jsonrpc = new JsonRpcClient(); if (await jsonrpc.SendRequest("object::full")) { var response = jsonrpc.GetRequestResponseDeserialized <RootJeedomObjects>(); foreach (JeedomObject obj in response.result) { var lst = from o in ObjectList where o.id == obj.id select o; if (lst.Count() != 0) { var ob = lst.FirstOrDefault(); ob = obj; } else { ObjectList.Add(obj); } } } return(jsonrpc.Error); }
public List <Cave> GetCaves() { var allCaves = new List <Cave>(); FetchCaves caveResult = null; do { var prms = new Dictionary <string, object>(); if (!string.IsNullOrEmpty(caveResult?.nextCursor)) { prms.Add("cursor", caveResult.nextCursor); } caveResult = client.SendRequest <FetchCaves>(Methods.Fetch_Caves, prms); if (caveResult.items != null) { allCaves.AddRange(caveResult.items); } }while (!string.IsNullOrEmpty(caveResult?.nextCursor)); return(allCaves); }
public async Task UpdateObject(JdObject obj) { var parameters = new Parameters(); parameters.object_id = obj.id; var jsonrpc = new JsonRpcClient(parameters); if (await jsonrpc.SendRequest("eqLogic::byObjectId")) { var response = jsonrpc.GetRequestResponseDeserialized<Response<ObservableCollection<EqLogic>>>(); if (response.result != null) { foreach (EqLogic eqnew in response.result) { var lst = from e in EqLogicList where e.id == eqnew.id select e; if (lst.Count() != 0) { var eqold = lst.First(); eqnew.cmds = eqold.cmds; eqold = eqnew; } else { EqLogicList.Add(eqnew); obj.eqLogics.Add(eqnew); } await UpdateEqLogic(eqnew); } } } }
public List <Cave> GetCaves() { return(client.SendRequest <FetchCaves>(Methods.Fetch_Caves).items); }
public async Task <Error> SynchMobilePlugin() { var jsonrpc = new JsonRpcClient(); Parameters parameters = new Parameters(); parameters.plugin = "mobile"; jsonrpc.SetParameters(parameters); EqLogicList.Clear(); CommandList.Clear(); if (await jsonrpc.SendRequest("sync")) { // Récupère la liste de tous les eqLogics var EqLogics = jsonrpc.GetRequestResponseDeserialized <Response <JeedomObject> >(); if (EqLogics != null) { foreach (Model.EqLogic eq in EqLogics.result.eqLogics) { EqLogicList.Add(eq); } } // Récupère la liste de toutes les cmds var Cmds = jsonrpc.GetRequestResponseDeserialized <Response <Model.EqLogic> >(); if (Cmds.result.Cmds != null) { foreach (Model.Command cmd in Cmds.result.Cmds) { // AJoute la cmd à son eqLogic var eq = (from e in EqLogicList where e.Id == cmd.EqLogic_id select e).FirstOrDefault(); if (eq.Cmds == null) { eq.Cmds = new ObservableCollectionEx <Model.Command>(); } eq.Cmds.Add(cmd); /*if (EqLogicList.Where(o => o.Id.Equals(cmd.EqLogic_id)).FirstOrDefault().Cmds == null) * EqLogicList.Where(o => o.Id.Equals(cmd.EqLogic_id)).FirstOrDefault().Cmds = new ObservableCollectionEx<Command>(); * EqLogicList.Where(o => o.Id.Equals(cmd.EqLogic_id)).FirstOrDefault().Cmds.Add(cmd);*/ // Ajoute la commande à la liste globale des cmds CommandList.Add(cmd); } } // Suppression des eqLogics sans cmds for (int i = EqLogicList.Count - 1; i >= 0; i--) { if (EqLogicList[i].Cmds == null) { EqLogicList.RemoveAt(i); } } // Affecte les eqLogics à leurs objects correspondants foreach (EqLogic eq in EqLogicList) { var ob = (from o in ObjectList where o.id == eq.object_id select o).FirstOrDefault(); if (ob.eqLogics == null) { ob.eqLogics = new List <EqLogic>(); } ob.eqLogics.Add(eq); } // Suppression des objects sans eqLogics for (int i = ObjectList.Count - 1; i >= 0; i--) { //todo review eqlogics //if (ObjectList[i].EqLogics == null) // ObjectList.RemoveAt(i); } // Mise à jour des favoris PopulateFavoriteList(); } return(jsonrpc.Error); }
public async Task UpdateObjectList() { var jsonrpc = new JsonRpcClient(); if (await jsonrpc.SendRequest("object::all")) { var response = jsonrpc.GetRequestResponseDeserialized<Response<ObservableCollection<JdObject>>>(); foreach (JdObject obj in response.result) { var lst = from o in ObjectList where o.id == obj.id select o; if (lst.Count() != 0) { var ob = lst.First(); ob = obj; } else ObjectList.Add(obj); } } }
public async Task<Error> PingJeedom() { Updating = true; LoadingMessage = "Contacte Jeedom"; var jsonrpc = new JsonRpcClient(); if (await jsonrpc.SendRequest("ping")) { var response = jsonrpc.GetRequestResponseDeserialized<Response<string>>(); if (response.result == "pong") { Updating = false; return null; } } Updating = false; return jsonrpc.Error; }
private async Task UpdateScene(Scene scene) { var parameters = new Parameters(); parameters.id = scene.id; var jsonrpc = new JsonRpcClient(parameters); if (await jsonrpc.SendRequest("scenario::byId")) { var response = jsonrpc.GetRequestResponseDeserialized<Response<Scene>>(); scene.lastLaunch = response.result.lastLaunch; } }
public async Task ExecuteCommand(Command cmd, Parameters parameters = null) { cmd.Updating = true; if (parameters == null) { parameters = new Parameters(); parameters.id = cmd.id; parameters.name = cmd.name; } var jsonrpc = new JsonRpcClient(parameters); if (await jsonrpc.SendRequest("cmd::execCmd")) { var response = jsonrpc.GetRequestResponseDeserialized<Response<CommandResult>>(); cmd.Value = response.result.value; } else { cmd.Value = "N/A"; } cmd.Updating = false; }
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; } }
public async Task<Error> DownloadInteraction() { var jsonrpc = new JsonRpcClient(); //Ajouter le téléchargemnent et la mise a jours des interaction Jeedom try { var storageFile = await Windows.Storage.StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///DomojeeVoiceCommandes.xml")); await VoiceCommandDefinitionManager.InstallCommandDefinitionsFromStorageFileAsync(storageFile); VoiceCommandDefinition commandDefinitions; string countryCode = CultureInfo.CurrentCulture.Name.ToLower(); if (countryCode.Length == 0) { countryCode = "fr-fr"; } if (VoiceCommandDefinitionManager.InstalledCommandDefinitions.TryGetValue("DomojeeCommandSet_" + countryCode, out commandDefinitions)) { List<string> InteractsList = new List<string>(); if (await jsonrpc.SendRequest("interactQuery::all")) { InteractList.Clear(); var response = jsonrpc.GetRequestResponseDeserialized<Response<ObservableCollection<Interact>>>(); if (response != null) InteractList = response.result; } foreach (var Iteract in InteractList) { InteractsList.Add(Iteract.query); } await commandDefinitions.SetPhraseListAsync("InteractList", InteractsList); } } catch (Exception ex) { System.Diagnostics.Debug.WriteLine("Updating Phrase list for VCDs: " + ex.ToString()); } return jsonrpc.Error; }
public async Task<Error> DownloadVersion() { var jsonrpc = new JsonRpcClient(); if (await jsonrpc.SendRequest("version")) { var response = jsonrpc.GetRequestResponseDeserialized<Response<string>>(); Version = response.result; } return jsonrpc.Error; }
/*public async Task<Error> DownloadCommands() { var jsonrpc = new JsonRpcClient(); if (await jsonrpc.SendRequest("cmd::all")) { CommandList.Clear(); var response = jsonrpc.GetRequestResponseDeserialized<ResponseCommandList>(); if (response != null) CommandList = response.result; foreach (Command cmd in CommandList) { var eqlist = from eq in EqLogicList where eq.id == cmd.eqLogic_id select eq; var parenteq = eqlist.First(); if (parenteq.cmds == null) parenteq.cmds = new ObservableCollection<Command>(); parenteq.cmds.Add(cmd); cmd.Parent = parenteq; if (cmd.name == "On") parenteq.OnVisibility = true; if (cmd.type == "info") await ExecuteCommand(cmd); } } return jsonrpc.Error; }*/ public async Task<Error> interactTryToReply(string query) { InteractReply = ""; var jsonrpc = new JsonRpcClient(); Parameters parameters = new Parameters(); parameters.query = query; jsonrpc.SetParameters(parameters); if (await jsonrpc.SendRequest("interact::tryToReply")) { var response = jsonrpc.GetRequestResponseDeserialized<Response<string>>(); if (response != null) InteractReply = response.result; } return jsonrpc.Error; }
private async Task<Error> DownloadDateTime() { var jsonrpc = new JsonRpcClient(); if (await jsonrpc.SendRequest("datetime")) { var response = jsonrpc.GetRequestResponseDeserialized<Response<double>>(); _dateTime = response.result; } return jsonrpc.Error; }
/// <summary> /// Télécharge les informations sur les JdObject, les EqLogic et les Command (sans les value) /// </summary> /// <returns>Le code et le message d'erreur de Jeedom</returns> public async Task<Error> DownloadObjects() { var jsonrpc = new JsonRpcClient(); EqLogicList.Clear(); CommandList.Clear(); ObjectList.Clear(); if (await jsonrpc.SendRequest("object::full")) { //List<string> idList = new List<string>(); var response = jsonrpc.GetRequestResponseDeserialized<Response<ObservableCollection<JdObject>>>(); if (response != null) { foreach (JdObject o in response.result) { ObjectList.Add(o); //idList.Add("dmj" + o.id); //UpdateObjectImage(o); if (o.eqLogics != null) { foreach (EqLogic eq in o.eqLogics) { EqLogicList.Add(eq); if (eq.cmds != null) { foreach (Command cmd in eq.cmds) { cmd.Parent = eq; CommandList.Add(cmd); } } else eq.cmds = new ObservableCollection<Command>(); } } } JdObject fakeobj = new JdObject(); fakeobj.name = "Autres"; //UpdateObjectImage(fakeobj); ObjectList.Add(fakeobj); fakeobj.eqLogics = new ObservableCollection<EqLogic>(); // Récupère les EqLogic du fake (object_id==null) if (await jsonrpc.SendRequest("eqLogic::byObjectId")) { var responseEqLogic = jsonrpc.GetRequestResponseDeserialized<Response<ObservableCollection<EqLogic>>>(); if (responseEqLogic != null) { foreach (EqLogic eq in responseEqLogic.result) { var param = new Parameters(); param.id = eq.id; jsonrpc.SetParameters(param); if (await jsonrpc.SendRequest("eqLogic::fullById")) { var responseEq = jsonrpc.GetRequestResponseDeserialized<Response<EqLogic>>(); if (responseEq.result?.cmds != null) eq.cmds = responseEq.result.cmds; else eq.cmds = new ObservableCollection<Command>(); fakeobj.eqLogics.Add(eq); EqLogicList.Add(eq); foreach (Command cmd in eq.cmds) { CommandList.Add(cmd); } } } } } // Efface les images inutiles /*var files = await ImageFolder.GetFilesAsync(); foreach (StorageFile f in files) { if (!idList.Contains(f.DisplayName)) { await f.DeleteAsync(); } }*/ } } return jsonrpc.Error; }
public async Task<bool> Reboot() { var jsonrpc = new JsonRpcClient(); await jsonrpc.SendRequest("jeeNetwork::reboot"); if (jsonrpc.Error == null) return true; else return false; }
public async Task RunScene(Scene scene) { var parameters = new Parameters(); parameters.id = scene.id; parameters.state = "run"; var jsonrpc = new JsonRpcClient(parameters); if (await jsonrpc.SendRequest("scenario::changeState")) { await UpdateScene(scene); } }
public async Task<bool> Upgrade() { var jsonrpc = new JsonRpcClient(); await jsonrpc.SendRequest("update::update"); if (jsonrpc.Error == null) return true; else return false; }
public async Task<Error> DownloadMessages() { var jsonrpc = new JsonRpcClient(); if (await jsonrpc.SendRequest("message::all")) { MessageList.Clear(); var response = jsonrpc.GetRequestResponseDeserialized<Response<ObservableCollection<Message>>>(); if (response != null) MessageList = response.result; } return jsonrpc.Error; }