public ActionResult Index()
        {
            string rowArray = _processTable.GetRows();
            JArray profiles = JsonConvert.DeserializeObject <JArray>(rowArray);

            ViewBag.profiles = profiles;

            return(View());
        }
示例#2
0
        public ActionResult Index()
        {
            bool access = getpermissions("location", "r");

            if (access == true)
            {
                string rowArray = locationTable.Get("tipo", "2");
                //  string rowArray = locationTable.GetRows();
                JArray locat = JsonConvert.DeserializeObject <JArray>(rowArray);
                Dictionary <string, string> data = new Dictionary <string, string>();

                foreach (JObject items in locat)
                {
                    data.Add(items["_id"].ToString(), items["name"].ToString());
                }

                ViewData["locations"] = data;

                rowArray = _processesTable.GetRows();
                locat    = JsonConvert.DeserializeObject <JArray>(rowArray);
                data     = new Dictionary <string, string>();

                foreach (JObject items in locat)
                {
                    data.Add(items["_id"].ToString(), items["name"].ToString());
                }

                ViewData["processes"] = data;


                rowArray = _diagramTable.GetRows();
                locat    = JsonConvert.DeserializeObject <JArray>(rowArray);
                data     = new Dictionary <string, string>();

                foreach (JObject items in locat)
                {
                    data.Add(items["_id"].ToString(), items["name"].ToString());
                }

                ViewData["diagrams"] = data;

                return(View());
            }
            else
            {
                return(Redirect("~/Home"));
            }
        }
        public ActionResult Index()
        {
            String dataPermissions       = Session["Permissions"].ToString();
            String dataPermissionsClient = Session["PermissionsClient"].ToString();
            bool   access       = false;
            bool   accessClient = false;

            //  access = getpermissions("users", "r");
            access       = validatepermissions.getpermissions("processes", "r", dataPermissions);
            accessClient = validatepermissions.getpermissions("processes", "r", dataPermissionsClient);

            if (access == true && accessClient == true)
            {
                string processes = ProcessModel.GetRows();
                string hardware  = HardwareModel.GetRows();

                JArray processesArray = JsonConvert.DeserializeObject <JArray>(processes);
                JArray hardwareArray  = JsonConvert.DeserializeObject <JArray>(hardware);
                foreach (JObject document in hardwareArray)
                {
                    try
                    { //trying to set the creator's name
                        String  rowString = hardwareReferenceTable.GetRow(document["hardware_reference"].ToString());
                        JObject rowArray  = JsonConvert.DeserializeObject <JObject>(rowString);
                        document["name"] = rowArray["name"];
                    }
                    catch (Exception e)
                    {
                        document["name"] = "";
                    }
                }
                ViewBag.Processes = processesArray;
                ViewBag.Hardware  = hardwareArray;

                return(View());
            }
            else
            {
                return(Redirect("~/Home"));
            }
        }
        /// <summary>
        ///     Gets a html table with all the stored processes
        /// </summary>
        /// <returns></returns>
        public ActionResult getProcessesTable()
        {
            if (this.Request.IsAjaxRequest())
            {
                string processes      = processesTable.GetRows();
                JArray processesArray = JsonConvert.DeserializeObject <JArray>(processes);

                foreach (JObject process in processesArray)
                {
                    try
                    {
                        JToken timeData = process["min_duration"];
                        process["min_duration_time"] = timeData["duration"];
                        if (timeData["type"].ToString() == "sec")
                        {
                            process["min_duration_type"] = "segundo(s)";
                        }
                        else if (timeData["type"].ToString() == "min")
                        {
                            process["min_duration_type"] = "minuto(s)";
                        }
                        else if (timeData["type"].ToString() == "hour")
                        {
                            process["min_duration_type"] = "hora(s)";
                        }
                        else if (timeData["type"].ToString() == "day")
                        {
                            process["min_duration_type"] = "día(s)";
                        }
                        else if (timeData["type"].ToString() == "mon")
                        {
                            process["min_duration_type"] = "mes(s)";
                        }
                        process.Remove("min_duration");

                        timeData = process["max_duration"];
                        process["max_duration_time"] = timeData["duration"];
                        if (timeData["type"].ToString() == "sec")
                        {
                            process["max_duration_type"] = "segundo(s)";
                        }
                        else if (timeData["type"].ToString() == "min")
                        {
                            process["max_duration_type"] = "minuto(s)";
                        }
                        else if (timeData["type"].ToString() == "hour")
                        {
                            process["max_duration_type"] = "hora(s)";
                        }
                        else if (timeData["type"].ToString() == "day")
                        {
                            process["max_duration_type"] = "día(s)";
                        }
                        else if (timeData["type"].ToString() == "mon")
                        {
                            process["max_duration_type"] = "mes(s)";
                        }
                        process.Remove("max_duration");
                    }
                    catch (Exception e) { }
                }

                return(View(processesArray));
            }
            return(this.Redirect("/Processes/Process"));
        }