public static List <ListReportProcess> getReportProcess(decimal id)
        {
            try {
                List <ListReportProcess> processList = new List <ListReportProcess>();

                var dProcess = ProcessDAL.fetchAllByUnit(id);

                foreach (process p in dProcess)
                {
                    ListReportProcess response = new ListReportProcess();
                    response.processId   = int.Parse(p.id + "");
                    response.processName = p.name;

                    var list = TaskDAL.fetchByProcess(p.id).Select(x => new Task {
                        id           = long.Parse(x.id + ""),
                        name         = x.name,
                        taskStatusId = x.task_status,
                    }).ToList();

                    response.taskList = list;

                    int ready   = 0;
                    int working = 0;
                    int pending = 0;

                    foreach (Task task in list)
                    {
                        if (task.taskStatusId == "0")
                        {
                            pending++;
                        }
                        else if (task.taskStatusId == "2")
                        {
                            ready++;
                        }
                        else if (task.taskStatusId == "4")
                        {
                            working++;
                        }
                    }

                    response.tasks   = list.Count();
                    response.done    = ready;
                    response.working = working;
                    response.pending = pending;

                    processList.Add(response);
                }

                return(processList);
            } catch (Exception e) {
                throw e;
            }
        }
Example #2
0
        /**
         * Método para obtener la lista de datos realizando el mapeo desde la capa de datos
         */
        public static List <Process> fetchAllByUnit(decimal id)
        {
            try {
                List <Process> list     = new List <Process>();
                var            mProcess = ProcessDAL.fetchAllByUnit(id).ToList();

                foreach (process proceso in mProcess)
                {
                    var     tasks = TaskDAL.fetchByProcess(proceso.id).Count();
                    Process model = new Process();
                    model.id          = long.Parse(proceso.id + "");
                    model.name        = proceso.name;
                    model.description = proceso.description;
                    model.n_tasks     = tasks;
                    list.Add(model);
                }

                return(list);
            } catch (Exception e) {
                throw e;
            }
        }
Example #3
0
        public static List <ListProcessResponse> getBackLogByUnit(decimal id)
        {
            try {
                List <ListProcessResponse> list = new List <ListProcessResponse>();
                var mProcess = ProcessDAL.fetchAllByUnit(id).ToList();

                foreach (process proceso in mProcess)
                {
                    var dListTasks            = TaskDAL.fetchByProcess(proceso.id);
                    ListProcessResponse model = new ListProcessResponse();
                    model.id          = long.Parse(proceso.id + "");
                    model.name        = proceso.name;
                    model.description = proceso.description;

                    var dTasks = 0;
                    if (dListTasks != null)
                    {
                        model.n_tasks = dListTasks.Count();
                        dTasks        = dListTasks.Count();
                    }

                    var pendingTask = 0;
                    var readyTask   = 0;
                    var workingTask = 0;
                    if (dListTasks != null)
                    {
                        foreach (tasks tarea in dListTasks)
                        {
                            if (tarea.task_status == "2")
                            {
                                readyTask = readyTask + 1;
                            }
                            if (tarea.task_status == "0" || tarea.task_status == "1")
                            {
                                pendingTask = pendingTask + 1;
                            }
                            if (tarea.task_status == "4")
                            {
                                workingTask = workingTask + 1;
                            }
                        }
                    }

                    model.task_working = workingTask;
                    model.task_peding  = pendingTask;
                    model.task_ready   = readyTask;


                    var lastTask = TaskDAL.fetchByProcess(proceso.id).OrderByDescending(x => x.date_end).FirstOrDefault();
                    if (lastTask != null)
                    {
                        model.endDate = ((DateTime)lastTask.date_end).ToString("dd/MM/yyyy").Replace("-", "/");
                    }
                    var progress = 0;
                    if (dTasks > 0)
                    {
                        progress = readyTask * 100 / dTasks;
                    }

                    model.progress = progress;
                    list.Add(model);
                }

                return(list);
            } catch (Exception e) {
                throw e;
            }
        }