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"); }
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(); }
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"); }
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 }); }
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"); }