public PluginCommandResponseMessage Execute(string args) { bool enable = false; if (args != null && !bool.TryParse(args, out enable)) // null means false { { return(new PluginCommandResponseMessage { PluginCommandStatus = PluginCommandStatus.Error, ResponseData = "Invalid Value" }); } } if (this._profileCollection.All(x => x.Name != this._pluginContext.ProfileName)) { return(new PluginCommandResponseMessage { PluginCommandStatus = PluginCommandStatus.Fail, ResponseData = "Profile {0} is not found".Fmt(this._pluginContext.ProfileName.Value) }); } var profile = this._profileCollection[this._pluginContext.ProfileName]; var settings = profile.Settings as SearcherProfile; if (settings == null) { settings = new SearcherProfile(); profile.Settings = settings; } settings.EnabledForTp2 = enable; profile.Save(); var message = "New search is " + (enable ? "enabled" : "disabled") + " for TP2"; this._log.Info(message); this._bus.SendLocal(new IPluginLocalMessage[] { new SendEnableForTp2Mashup() }); return(new PluginCommandResponseMessage { PluginCommandStatus = PluginCommandStatus.Succeed, ResponseData = message.Serialize() }); }
public PluginCommandResponseMessage Execute(string args) { bool enable = false; if (args != null && !bool.TryParse(args, out enable)) // null means false { { return new PluginCommandResponseMessage { PluginCommandStatus = PluginCommandStatus.Error, ResponseData = "Invalid Value" }; } } if (this._profileCollection.All(x => x.Name != this._pluginContext.ProfileName)) { return new PluginCommandResponseMessage { PluginCommandStatus = PluginCommandStatus.Fail, ResponseData = "Profile {0} is not found".Fmt(this._pluginContext.ProfileName.Value) }; } var profile = this._profileCollection[this._pluginContext.ProfileName]; var settings = profile.Settings as SearcherProfile; if (settings == null) { settings = new SearcherProfile(); profile.Settings = settings; } settings.EnabledForTp2 = enable; profile.Save(); var message = "New search is " + (enable ? "enabled" : "disabled") + " for TP2"; this._log.Info(message); this._bus.SendLocal(new IPluginLocalMessage[] { new SendEnableForTp2Mashup() }); return new PluginCommandResponseMessage { PluginCommandStatus = PluginCommandStatus.Succeed, ResponseData = message.Serialize() }; }