public void Update(int id, string location, string name, string type) { var cache = new InMemoryRepositoryModelCache(); var device = _deviceRepository.Get(_user, id, cache); device.Update( location: location == null ? device.Location : new Location(location), name: name ?? device.Name, type: type ?? device.Type ); _deviceRepository.Update(device); var computerRepository = _repositoryFactory.GetComputerRepository(); var scriptRepository = _repositoryFactory.GetScriptRepository(); var taskRepository = _repositoryFactory.GetTaskRepository(); var runScript = new Computer.Actions.RunScript(computerRepository, scriptRepository, taskRepository); runScript.Run( computer: device.Network.AttatchedComputer, scriptText: "HomeAutomation.SyncWithCloud Network=\"" + device.Network.Address + "\"", source: "RoomieBot", updateLastRunScript: false, user: _user ); }
private void NetworkAction(Persistence.Models.Network network, string action) { var computerRepository = _repositoryFactory.GetComputerRepository(); var scriptRepository = _repositoryFactory.GetScriptRepository(); var taskRepository = _repositoryFactory.GetTaskRepository(); var runScript = new Computer.Actions.RunScript(computerRepository, scriptRepository, taskRepository); runScript.Run( computer: network.AttatchedComputer, scriptText: $"<HomeAutomation.{action} Network=\"{network.Address}\" />\n<HomeAutomation.SyncWithCloud />", source: "RoomieBot", updateLastRunScript: false, user: _user ); }