Exemplo n.º 1
0
        public IActionResult List(
            DateTime firstDate,
            DateTime endDate,
            string description,
            LogTypeEnum?type,
            Guid?projectID)
        {
            var period = new PeriodoVO(firstDate, endDate);

            return(Ok(_logQueryRepository.List(period, description, projectID, type)));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Get(DateTime startDate, DateTime endDate)
        {
            var period = new PeriodoVO(startDate, endDate);
            var emails = await _emailRepository.Serach(period, null, null);

            var model = emails.Select(e => new {
                e.Date,
                e.Project.Name,
                e.Subject,
                status = e.Status.ToString()
            }).ToList();

            return(Ok(model));
        }
        public IEnumerable <LogListDTO> List(PeriodoVO period, string description, Guid?projectID, LogTypeEnum?type)
        {
            var list = new List <LogListDTO>
            {
                new LogListDTO
                {
                    Description = "Description",
                    LogType     = (int)LogTypeEnum.Error,
                    Project     = "Project",
                    Id          = Guid.NewGuid(),
                    Creation    = DateTime.Now
                }
            };

            return(list);
        }
Exemplo n.º 4
0
        public IEnumerable <LogListDTO> List(PeriodoVO period, string description, Guid?projectID, LogTypeEnum?type)
        {
            var periodoFinal = period.DataFinal.Date.AddHours(23).AddMinutes(59).AddSeconds(59);

            var sql = $@"select
                        l.id, 
                        l.description,
                        l.creation,
                        l.log_type as LogType,
                        p.name as Project 
                            from logs l
                            join projects p on l.project_id = p.id
                        where 
                            creation >= '{period.DataInicial:yyyy-MM-dd}' and creation <= '{periodoFinal:yyyy-MM-dd HH:mm:ss}'
                            and (@description is null or (description like @description or source like @description))
                            and (@projectID is null or l.project_id = @projectID)
                            and (@type is null or log_type = @type)
                        order by creation desc
                        limit 100";

            var parameters = new List <object>();

            if (!string.IsNullOrWhiteSpace(description))
            {
                var parameter = new MySqlParameter("@description", $"%{description}%");
                parameters.Add(parameter);
            }

            if (projectID.HasValue)
            {
                var parameter = new MySqlParameter("@projectID", projectID.Value);
                parameters.Add(parameter);
            }

            if (type.HasValue)
            {
                var parameter = new MySqlParameter("@type", (int)type.Value);
                parameters.Add(parameter);
            }

            return(this.SelectSql <LogListDTO>(sql, parameters.ToArray()));
        }
Exemplo n.º 5
0
        //TODO: Implementar o restante dos filtros. Por enquanto esta somente para testes e aprendizado.
        public IEnumerable <LogListDTO> List(PeriodoVO period, string description, Guid?projectID, LogTypeEnum?type)
        {
            var endDate = period.DataFinal.Date.AddHours(23).AddMinutes(59).AddSeconds(59);
            var builder = Builders <Log> .Filter;
            FilterDefinition <Log> filter = builder.Gte(x => x.Creation, period.DataInicial.Date) & builder.Lte(x => x.Creation, endDate);

            if (!string.IsNullOrWhiteSpace(description))
            {
                var queryExpr = new BsonRegularExpression(new Regex(description, RegexOptions.None));
                filter = filter & (builder.Regex("Description", queryExpr) | builder.Regex("Source", queryExpr));
            }

            if (projectID.HasValue)
            {
                filter = filter & builder.Eq("ProjectID", projectID.Value);
            }

            if (type.HasValue)
            {
                filter = filter & builder.Eq("LogType", type.Value);
            }


            var logs = _dbSet.Find(filter).ToList();

            var dto = logs.Select(l => new LogListDTO
            {
                Description = l.Description,
                Project     = l.Project.Name,
                Id          = l.Id,
                Creation    = l.Creation,
                LogType     = (int)l.LogType
            });

            return(dto);
        }
Exemplo n.º 6
0
        public async Task <IEnumerable <Email> > Serach(PeriodoVO period, Guid?projecID, StatusMailEnum?status)
        {
            var emails = _dbSet.Find(e => e.Date >= period.DataInicial && e.Date <= period.DataFinal);

            return(await emails.ToListAsync());
        }