public ActionResponseMessage AddModule(byte[] zip) { try { logger?.LogDebug("Adding new module DLLs from Zip."); var modules = PluginHelper.ExtractModulesFromZipData(zip, logger); if (modules != null) { AllModules.AddRange(modules); logger?.LogDebug("Modules added: " + string.Join(", ", modules.Select(m => m.Name))); db.Modules.AddRange(modules.Select(m => ModuleConfig.From(m, zip, true))); db.SaveChanges(); return(ActionResponseMessage.Success("Modules added: " + string.Join(", ", modules.Select(m => m.Name)))); } else { logger?.LogWarning("Modules failed to load."); return(ActionResponseMessage.Failure("Modules failed to load. Did you provide a zip file?")); } } catch (Exception e) { logger?.LogWarning("Modules failed to load."); return(ActionResponseMessage.Failure(e, "Modules failed to load. Did you provide a zip file?")); } }
public ActionResponseMessage RemoveModule(string reference) { AllModules.RemoveAll(m => m.UniqueReference == reference); db.Modules.RemoveRange(db.Modules.Where(m => m.UniqueReference == reference)); db.SaveChanges(); return(ActionResponseMessage.Success("Removed: " + reference)); }
public async Task <ActionResponseMessage> ActivateBehaviourAsync(string reference) { var allBehaviours = AllModules.SelectMany(m => m.Behaviours); var behaviour = allBehaviours.SingleOrDefault(b => b.UniqueReference == reference); if (behaviour != null) { await Controller.AddBehaviourAsync(behaviour); return(ActionResponseMessage.Success("Behaviour activated.")); } else { return(ActionResponseMessage.Failure("Behaviour not found.")); } }
public async Task <ActionResponseMessage> DeactivateBehaviourAsync(string reference) { await Controller.RemoveBehaviourAsync(reference); return(ActionResponseMessage.Success("Behaviour deactivated.")); }
public async Task <ActionResponseMessage> DisconnectAsync() { await DisconnectAsync(executionStoppingToken); return(ActionResponseMessage.Success("Disconnected.")); }
public async Task <ActionResponseMessage> ReconnectAsync() { bool reconnected = await ReconnectAsync(executionStoppingToken); return(reconnected ? ActionResponseMessage.Success("Connected") : ActionResponseMessage.Failure("Failed to connect.")); }