Пример #1
0
        public object GetPackages(HttpRequestParams request)
        {
            string query = request.GetString("query");

            var list = Context.PackageManager.GetPackages(query);

            return list.Select(BuildModel).Where(x => x != null).ToArray();
        }
Пример #2
0
        private object apiSaveScript(HttpRequestParams request)
        {
            Guid? id = request.GetGuid("id");
            string name = request.GetRequiredString("name");
            string body = request.GetString("body");

            using (var session = Context.OpenSession())
            {
                var script = id.HasValue ? session.Get<UserScript>(id.Value) : new UserScript { Id = Guid.NewGuid() };
                script.Name = name;
                script.Body = body;

                session.SaveOrUpdate(script);
                session.Flush();
            }

            return null;
        }
Пример #3
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;
        }
        public object SaveAlarm(HttpRequestParams request)
        {
            var id = request.GetGuid("id");
            var name = request.GetString("name");
            var hours = request.GetRequiredInt32("hours");
            var minutes = request.GetRequiredInt32("minutes");
            var scriptId = request.GetGuid("scriptId");

            using (var session = Context.OpenSession())
            {
                var alarmTime = id.HasValue
                    ? session.Get<AlarmTime>(id.Value)
                    : new AlarmTime { Id = Guid.NewGuid() };

                var script = scriptId.HasValue
                    ? session.Load<UserScript>(scriptId.Value)
                    : null;

                alarmTime.Name = name;
                alarmTime.Hours = hours;
                alarmTime.Minutes = minutes;
                alarmTime.UserScript = script;
                alarmTime.Enabled = true;

                session.Save(alarmTime);
                session.Flush();
            }

            Context.GetPlugin<AlarmClockPlugin>().ReloadTimes();
            return null;
        }
        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;
        }