/** * Método para actualizar un nuevo registro */ public static void update(long id, int green, int yellow, int red) { try { ConfigTrafficLightDAL.update(id, green, yellow, red); } catch (Exception e) { throw e; } }
public static List <Task> getTaskGreen(decimal id) { try { var list = TaskDAL.fetchAllByUnit(id).Select(x => new Task { id = long.Parse(x.id + ""), name = x.name, description = x.description, dateStart = x.date_start, dateEnd = x.date_end, taskStatusId = x.task_status }).ToList(); List <Task> newList = new List <Task>(); var alert = ConfigTrafficLightDAL.fetch(); foreach (Task task in list) { var end = (DateTime)task.dateEnd; var now = DateTime.Now; var date = -(Math.Round((now - end).TotalDays)); if (date > double.Parse(alert.yellow + "") && task.taskStatusId != "2" && task.taskStatusId != "3") { User dUser = new User(); if (task.assingId != 0) { var user = UserDAL.fetchAll().Where(x => x.id == task.assingId).FirstOrDefault(); if (user != null) { dUser.id = long.Parse(user.id + ""); dUser.name = user.name; } else { dUser.name = "Sin Asignar"; } } else { dUser.name = "Sin Asignar"; } task.creatorUser = dUser; if (task.dateEnd != null) { task.sDateEnd = ((DateTime)task.dateEnd).ToString("dd/MM/yyyy").Replace("-", "/"); } newList.Add(task); } } return(newList); } catch (Exception e) { throw e; } }
public static ListReportAlerts getReportAlerts(decimal id) { try { var list = TaskDAL.fetchAllByUser(id).Select(x => new Task { id = long.Parse(x.id + ""), name = x.name, description = x.description, dateStart = x.date_start, dateEnd = x.date_end, taskStatusId = x.task_status }).ToList(); ListReportAlerts response = new ListReportAlerts(); var alert = ConfigTrafficLightDAL.fetch(); int red = 0; int yellow = 0; int green = 0; foreach (Task task in list) { var end = (DateTime)task.dateEnd; var now = DateTime.Now; var date = -(Math.Round((now - end).TotalDays)); if (date <= double.Parse(alert.red + "") && task.taskStatusId != "2" && task.taskStatusId != "3") { red++; } else if (date <= double.Parse(alert.yellow + "") && task.taskStatusId != "2" && task.taskStatusId != "3") { yellow++; } else if (date > double.Parse(alert.green + "") && task.taskStatusId != "2" && task.taskStatusId != "3") { green++; } } response.red = red; response.yellow = yellow; response.green = green; return(response); } catch (Exception e) { throw e; } }
/** * Método para obtener los datos realizando el mapeo desde la capa de datos */ public static ConfigTrafficLight fetch() { try { var result = ConfigTrafficLightDAL.fetch(); ConfigTrafficLight entity = new ConfigTrafficLight(); entity.id = long.Parse(result.id + ""); entity.green = int.Parse(result.green + ""); entity.yellow = int.Parse(result.yellow + ""); entity.red = int.Parse(result.red + ""); return(entity); } catch (Exception e) { throw e; } }
public static List <Task> getTasksByUserId(decimal id) { try { List <Task> list = new List <Task>(); var dTasks = TaskDAL.getTasksByUser(id); foreach (tasks item in dTasks) { Task task = new Task(); task.id = long.Parse(item.id + ""); task.name = item.name; task.description = item.description; task.dateEnd = item.date_end; task.sDateEnd = ((DateTime)item.date_end).ToString("dd/MM/yyyy").Replace("-", "/"); if (item.process_id != null) { var process = ProcessDAL.getById(Decimal.Parse(item.process_id + "")); Process dProcess = new Process(); dProcess.name = process.name; dProcess.description = process.description; dProcess.id = long.Parse(process.id + ""); task.process = dProcess; } var listFiles = DocumentDAL.fetchAllByTaskId(long.Parse(item.id + "")).Select(x => new Document() { id = long.Parse(x.id + ""), name = x.name, url = x.url, path = x.path, task_id = x.task_id }).ToList(); task.documents = listFiles; var alert = ConfigTrafficLightDAL.fetch(); var end = (DateTime)item.date_end; var now = DateTime.Now; var date = -(Math.Round((now - end).TotalDays)); if (date <= double.Parse(alert.red + "")) { task.alert = 1; } else if (date <= double.Parse(alert.yellow + "")) { task.alert = 2; } else if (date > double.Parse(alert.green + "")) { task.alert = 3; } list.Add(task); } return(list); } catch (Exception e) { throw e; } }