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;
        }
Пример #2
0
 private object apiGetZoneRich(HttpRequestParams request)
 {
     var id = request.GetRequiredGuid("id");
     return BuildZoneRichWebModel(Get(id));
 }
Пример #3
0
        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;
        }
Пример #4
0
        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;
        }
Пример #5
0
        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;
        }
Пример #11
0
        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;
        }
Пример #13
0
 public object UpdateLocationWeather(HttpRequestParams request)
 {
     var locationId = request.GetRequiredGuid("locationId");
     UpdateWeatherData(locationId);
     return null;
 }
Пример #14
0
        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;
        }
Пример #15
0
        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;
        }
Пример #16
0
 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));
        }
Пример #18
0
        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;
        }
Пример #20
0
        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;
        }
Пример #21
0
 private object apiGetScript(HttpRequestParams request)
 {
     Guid id = request.GetRequiredGuid("id");
     return BuildScriptRichWebModel(GetScript(id));
 }
Пример #22
0
 private object apiGetMonitorBySensor(HttpRequestParams request)
 {
     var id = request.GetRequiredGuid("id");
     return BuildMonitorRichWebModel(GetBySensor(id));
 }
Пример #23
0
        private object apiRunScript(HttpRequestParams request)
        {
            Guid scriptId = request.GetRequiredGuid("scriptId");

            ExecuteScript(GetScript(scriptId), new object[0]);

            return null;
        }
Пример #24
0
        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;
        }
Пример #25
0
        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;
        }
Пример #26
0
        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;
        }
Пример #27
0
        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;
        }
Пример #28
0
        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;
        }
Пример #29
0
 private object apiDeleteZone(HttpRequestParams request)
 {
     var id = request.GetRequiredGuid("Id");
     Delete(id);
     //NotifyForSignalR(new { MsgId = "SensorDeleted", Data = new { Id = id } });
     return null;
 }
Пример #30
0
        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;
        }