/// <summary> /// This method allows to get the rules of an especific process /// </summary> /// <param name="id_process"></param> /// <author> /// Abigail Rodriguez /// </author> /// <returns> /// Returns Json with the information /// </returns> public JsonResult getRules(string id_process) { try { String processString = processesTable.GetRow(id_process); JObject process = JsonConvert.DeserializeObject <JObject>(processString); JToken rules = process["rules"]; String rulesString = JsonConvert.SerializeObject(rules); JArray rulesArray = JsonConvert.DeserializeObject <JArray>(rulesString); foreach (JObject rule in rulesArray) { JToken locations = rule["Locations"]; String nameLocation = ""; foreach (String location in locations) { String locationString = locationTable.GetRow(location); JObject locationRow = JsonConvert.DeserializeObject <JObject>(locationString); nameLocation += locationRow["name"] + ","; } rule.Add("nameLocations", nameLocation); } return(Json(JsonConvert.SerializeObject(rulesArray))); } catch (Exception e) { return(null); } }
public JsonResult getDiagrambyLocationControl(string id_location) { string diagramResult = _circuitTable.GetRows(); JArray arraycontrol = JsonConvert.DeserializeObject <JArray>(diagramResult); string idcircuito = ""; foreach (JObject obj in arraycontrol) { JArray processarray = JsonConvert.DeserializeObject <JArray>(obj["processes"].ToString()); foreach (JObject obj1 in processarray) { if (obj1["processId"].ToString() == id_location) { idcircuito = obj["locationid"].ToString(); } } } if (idcircuito == "") { diagramResult = locationTable.GetRow(id_location); JObject control = JsonConvert.DeserializeObject <JObject>(diagramResult); control["locationid"] = control["parent"].ToString(); arraycontrol = new JArray(); arraycontrol.Add(control); diagramResult = JsonConvert.SerializeObject(arraycontrol); } else { diagramResult = _circuitTable.Get("locationid", idcircuito); } if (diagramResult != null) { return(Json(diagramResult)); } return(Json("")); }
public JsonResult getRoute(String parentCategory = "null") { //Creating the route data JArray route = new JArray(); while (parentCategory != "null" && parentCategory != "") { String actualCategory = locationTable.GetRow(parentCategory); JObject actualCatObject = JsonConvert.DeserializeObject <JObject>(actualCategory); JObject categoryObject = new JObject(); categoryObject.Add("id", actualCatObject["_id"].ToString()); route.Add(categoryObject); parentCategory = actualCatObject["parent"].ToString(); } JObject result = new JObject(); result.Add("route", route); return(Json(JsonConvert.SerializeObject(result))); }