Пример #1
0
        public ActionResult Delete(int id)
        {
            Node node = gatewayDb.GetNodeByNodeId(id);
            if (node == null)
                return HttpNotFound();

            GatewayAPIController gatewayApi = new GatewayAPIController();
            gatewayApi.DeleteNode(node.nodeId);

            gatewayDb.DeleteNodeByDbId(node.db_Id);

            ISensorsLinksRepository linksDb = SerialController.sensorsLinksDb;
            ISensorsTasksRepository tasksDb = SerialController.sensorsTasksDb;

            foreach (var sensor in node.sensors)
            {
                historyDb.DropSensorHistory(sensor.db_Id);
                linksDb.DeleteLinksTo(sensor.db_Id);
                linksDb.DeleteLinksFrom(sensor.db_Id);
                tasksDb.DeleteTasks(sensor.db_Id);
            }

            gatewayApi.UpdateSensorsTasks();
            gatewayApi.UpdateSensorsLinks();

            return RedirectToAction("Control", "Gateway");
        }
Пример #2
0
        public ActionResult DeleteAll(int? id = null, int? id2 = null)
        {
            if (id != null && id2 != null)
            {
                Sensor sensor = gatewayDb.GetSensor(id.Value, id2.Value);

                if (sensor == null)
                    return new HttpNotFoundResult();

                tasksDb.DeleteTasks(id.Value, id2.Value);

                GatewayAPIController gatewayApi = new GatewayAPIController();
                gatewayApi.UpdateSensorsTasks();

                if (Request.Headers["Referer"].Any())
                    return Redirect(Request.Headers["Referer"].ToString());
                else return RedirectToAction("List");
            }
            else if (RouteData.Values.Count <= 2)
            {
                tasksDb.DropTasks();

                GatewayAPIController gatewayApi = new GatewayAPIController();
                gatewayApi.UpdateSensorsTasks();

                if (Request.Headers["Referer"].Any())
                    return Redirect(Request.Headers["Referer"].ToString());
                else return RedirectToAction("List");
            }

            return new HttpNotFoundResult();
        }
Пример #3
0
        public ActionResult Delete(int id)
        {
            SensorTask task = tasksDb.GetTask(id);

            if (task == null)
                return new HttpNotFoundResult();

            tasksDb.DeleteTask(id);

            GatewayAPIController gatewayApi = new GatewayAPIController();
            gatewayApi.UpdateSensorsTasks();

            if (Request.Headers["Referer"].Any())
                return Redirect(Request.Headers["Referer"].ToString());
            else return RedirectToAction("List");
        }
Пример #4
0
        public ActionResult New(SensorTask task)
        {
            Sensor sensor = gatewayDb.GetSensor(task.nodeId, task.sensorId);

            if (sensor == null)
                return new HttpNotFoundResult();

            if (task.isRepeating)
                task.executionValue = task.repeatingBValue;

            tasksDb.AddTask(task);

            GatewayAPIController gatewayApi = new GatewayAPIController();
            gatewayApi.UpdateSensorsTasks();

            return RedirectToAction("List", new { id = task.nodeId, id2 = task.sensorId });
        }
Пример #5
0
        public ActionResult ExecuteNow(int id)
        {
            SensorTask task = tasksDb.GetTask(id);

            if (task == null)
                return new HttpNotFoundResult();

            tasksDb.UpdateTask(task.db_Id, true, false, DateTime.Now, 0);

            GatewayAPIController gatewayApi = new GatewayAPIController();
            gatewayApi.UpdateSensorsTasks();

            if (Request.Headers["Referer"].Any())
                return Redirect(Request.Headers["Referer"].ToString());
            else return RedirectToAction("List");
        }