private object apiSetSensorName(HttpRequestParams request) { var id = request.GetRequiredGuid("Id"); var name = request.GetString("Name"); using (var session = Context.OpenSession()) { var sensor = session.Load<Sensor>(id); sensor.Name = name; session.Flush(); } NotifyForSignalR(new { MsgId = "SensorNameChanged", Data = new { Id = id, Name = name } }); return null; }
private object apiGetZoneRich(HttpRequestParams request) { var id = request.GetRequiredGuid("id"); return BuildZoneRichWebModel(Get(id)); }
private object apiSetZoneConfiguration(HttpRequestParams request) { var id = request.GetRequiredGuid("id"); var monitorsIds = request.GetRequiredString("monitorsIds"); var controllersIds = request.GetRequiredString("controllersIds"); var scriptsIds = request.GetRequiredString("scriptsIds"); //var graphsIds = request.GetRequiredString("graphsIds"); using (var session = Context.OpenSession()) { var zone = session.Load<Zone>(id); zone.MonitorsList = monitorsIds; zone.ControllersList = controllersIds; zone.ScriptsList = scriptsIds; //zone.GraphsList = graphsIds; session.Flush(); } //NotifyForSignalR(new { MsgId = "ControllerIsVisibleChanged", Data = BuildControllerWebModel(ctrl) }); return null; }
private object apiDeleteScript(HttpRequestParams request) { Guid scriptId = request.GetRequiredGuid("scriptId"); using (var session = Context.OpenSession()) { var subscription = session.Load<UserScript>(scriptId); session.Delete(subscription); session.Flush(); } return null; }
public object AddSubscription(HttpRequestParams request) { string eventAlias = request.GetRequiredString("eventAlias"); Guid scriptId = request.GetRequiredGuid("scriptId"); using (var session = Context.OpenSession()) { var guid = Guid.NewGuid(); var script = session.Load<UserScript>(scriptId); var subscription = new ScriptEventHandler { Id = guid, EventAlias = eventAlias, UserScript = script }; session.Save(subscription); session.Flush(); return guid; } }
private object apiSetControllerIsAutoMode(HttpRequestParams request) { var id = request.GetRequiredGuid("id"); var isAutoMode = request.GetRequiredBool("isAutoMode"); foreach (ControllerBase controller in controllers) if (controller.ID == id) { controller.IsAutoMode = isAutoMode; break; } //NotifyForSignalR(new { MsgId = "ControllerIsAutoModeChanged", Data = BuildControllerWebModel(ctrl) }); return null; }
private object apiDeleteController(HttpRequestParams request) { var id = request.GetRequiredGuid("Id"); using (var session = Context.OpenSession()) { var ctrl = session.Load<Controller>(id); session.Delete(ctrl); session.Flush(); NotifyForSignalR(new { MsgId = "ControllerDeleted", Data = new { Id = id } }); } foreach (ControllerBase controller in controllers) if (controller.ID == id) { controllers.Remove(controller); break; } return null; }
private object apiSetInformerName(HttpRequestParams request) { var id = request.GetRequiredGuid("id"); var name = request.GetRequiredString("name"); using (var session = Context.OpenSession()) { var informer = session.Load<Informer>(id); informer.Name = name; session.Flush(); } return null; }
private object apiSetInformerConfiguration(HttpRequestParams request) { var id = request.GetRequiredGuid("id"); var monitorsIds = request.GetRequiredString("monitorsIds"); using (var session = Context.OpenSession()) { var informer = session.Load<Informer>(id); informer.MonitorsIds = monitorsIds; session.Flush(); } return null; }
public object DeleteAlarm(HttpRequestParams request) { var id = request.GetRequiredGuid("id"); using (var session = Context.OpenSession()) { var alarmTime = session.Load<AlarmTime>(id); session.Delete(alarmTime); session.Flush(); } ReloadTimes(); return null; }
private object apiAddInformer(HttpRequestParams request) { var name = request.GetRequiredString("name"); var sensorDisplayId = request.GetRequiredGuid("sensorDisplayId"); using (var session = Context.OpenSession()) { Informer informer = new Informer() { Id = Guid.NewGuid(), Name = name, SensorDisplayId = sensorDisplayId, MonitorsIds = "[]" }; session.Save(informer); session.Flush(); } return null; }
public object SetAlarmState(HttpRequestParams request) { var id = request.GetRequiredGuid("id"); var enabled = request.GetRequiredBool("enabled"); using (var session = Context.OpenSession()) { var alarmTime = session.Get<AlarmTime>(id); alarmTime.Enabled = enabled; session.Save(alarmTime); session.Flush(); } ReloadTimes(); return null; }
public object UpdateLocationWeather(HttpRequestParams request) { var locationId = request.GetRequiredGuid("locationId"); UpdateWeatherData(locationId); return null; }
public object DeleteLocation(HttpRequestParams request) { var locationId = request.GetRequiredGuid("locationId"); using (var session = Context.OpenSession()) { var location = session.Get<Location>(locationId); if (location != null) { session.Delete(location); session.Flush(); } } return null; }
private object apiDeleteMonitor(HttpRequestParams request) { var id = request.GetRequiredGuid("Id"); using (var session = Context.OpenSession()) { var monitor = session.Load<Monitor>(id); session.Delete(monitor); session.Flush(); } //NotifyForSignalR(new { MsgId = "SensorDeleted", Data = new { Id = id } }); return null; }
private object apiDeleteInformer(HttpRequestParams request) { var id = request.GetRequiredGuid("Id"); Delete(id); return null; }
private object apiGetController(HttpRequestParams request) { var id = request.GetRequiredGuid("id"); return BuildControllerWebModel(Get(id)); }
private object apiAddCommand(HttpRequestParams request) { var text = request.GetRequiredString("text"); var scriptId = request.GetRequiredGuid("scriptId"); using (var session = Context.OpenSession()) { VoiceCommand cmd = new VoiceCommand() { Id = Guid.NewGuid(), CommandText = text, UserScript = Context.GetPlugin<ScriptsPlugin>().GetScript(scriptId) }; session.Save(cmd); session.Flush(); } //NotifyForSignalR(new //{ // MsgId = "SensorNameChanged", // Data = new // { // Id = id, // Name = name // } //}); return null; }
private object apiSetControllerConfiguration(HttpRequestParams request) { var id = request.GetRequiredGuid("id"); var conf = request.GetRequiredString("config"); foreach (ControllerBase controller in controllers) if (controller.ID == id) { controller.SetConfiguration(conf); break; } //NotifyForSignalR(new { MsgId = "ControllerIsVisibleChanged", Data = BuildControllerWebModel(ctrl) }); return null; }
private object apiSetCommandName(HttpRequestParams request) { var id = request.GetRequiredGuid("id"); var text = request.GetRequiredString("text"); using (var session = Context.OpenSession()) { var cmd = session.Load<VoiceCommand>(id); cmd.CommandText = text; session.Flush(); } CloseRecognitionEngine(); InitRecognitionEngine(); //NotifyForSignalR(new //{ // MsgId = "SensorNameChanged", // Data = new // { // Id = id, // Name = name // } //}); return null; }
private object apiGetScript(HttpRequestParams request) { Guid id = request.GetRequiredGuid("id"); return BuildScriptRichWebModel(GetScript(id)); }
private object apiGetMonitorBySensor(HttpRequestParams request) { var id = request.GetRequiredGuid("id"); return BuildMonitorRichWebModel(GetBySensor(id)); }
private object apiRunScript(HttpRequestParams request) { Guid scriptId = request.GetRequiredGuid("scriptId"); ExecuteScript(GetScript(scriptId), new object[0]); return null; }
private object apiAddMonitor(HttpRequestParams request) { var name = request.GetRequiredString("name"); var sensorId = request.GetRequiredGuid("sensorId"); var configuration = request.GetRequiredString("config"); using (var session = Context.OpenSession()) { Monitor monitor = new Monitor() { Id = Guid.NewGuid(), Name = name, SensorId = sensorId, Configuration = configuration }; session.Save(monitor); session.Flush(); } //NotifyForSignalR(new { MsgId = "MonitorAdded", Data = BuildMonitorWebModel(ctrl) }); return null; }
public object DeleteSubscription(HttpRequestParams request) { Guid subscriptionId = request.GetRequiredGuid("subscriptionId"); using (var session = Context.OpenSession()) { var subscription = session.Load<ScriptEventHandler>(subscriptionId); session.Delete(subscription); session.Flush(); } return null; }
private object apiSetMonitorNameForInformer(HttpRequestParams request) { var id = request.GetRequiredGuid("id"); var name = request.GetString("name"); using (var session = Context.OpenSession()) { var monitor = session.Load<Monitor>(id); monitor.NameForInformer = name; session.Flush(); } //NotifyForSignalR(new //{ // MsgId = "SensorNameChanged", // Data = new // { // Id = id, // Name = name // } //}); return null; }
private object apiSetZoneName(HttpRequestParams request) { var id = request.GetRequiredGuid("id"); var name = request.GetRequiredString("name"); using (var session = Context.OpenSession()) { var zone = session.Load<Zone>(id); zone.Name = name; session.Flush(); } //NotifyForSignalR(new //{ // MsgId = "SensorNameChanged", // Data = new // { // Id = id, // Name = name // } //}); return null; }
private object apiSetMonitorConfiguration(HttpRequestParams request) { var id = request.GetRequiredGuid("id"); var configuration = request.GetRequiredString("config"); using (var session = Context.OpenSession()) { var monitor = session.Load<Monitor>(id); monitor.Configuration = configuration; session.Flush(); } //NotifyForSignalR(new { MsgId = "ControllerIsVisibleChanged", Data = BuildControllerWebModel(ctrl) }); return null; }
private object apiDeleteZone(HttpRequestParams request) { var id = request.GetRequiredGuid("Id"); Delete(id); //NotifyForSignalR(new { MsgId = "SensorDeleted", Data = new { Id = id } }); return null; }
private object apiDeleteNode(HttpRequestParams request) { var id = request.GetRequiredGuid("Id"); using (var session = Context.OpenSession()) { var node = session.Load<Node>(id); session.Delete(node); session.Flush(); } NotifyForSignalR(new { MsgId = "NodeDeleted", Data = new { Id = id } }); return null; }