Beispiel #1
0
        public object GetQuerySource(ReportSourceFilterDto filter, User user)
        {
            var report  = _reportRepository.Get(filter.ReportGUID);
            var relUser = _userReportRel.Get(report.Id, user.Id);

            if (relUser == null || relUser.AuthoryLayer != (int)ReportUserPermissions.CanModify)
            {
                throw new PermissionException("Don't have permission.");
            }

            return(_queryManager.GetQuerySource(
                       new Models.Dtos.QueryDtos.QuerySourceFilterDto
            {
                QueryGUID = report.Query.QueryGUID,
                Rows = filter.X,
                Page = filter.Y,
                Columns = report.Columns.Split(':'),
                Filter = report.Filter,
                Sort = JsonConvert.DeserializeObject <SortDto>(report.Sort)
            }));
        }
Beispiel #2
0
 public IActionResult GetReportSource([FromBody] ReportSourceFilterDto filter)
 {
     try
     {
         if (filter == null)
         {
             throw new BasicException("Wrong structure!");
         }
         if (!ModelState.IsValid)
         {
             BadRequest(ModelState);
         }
         User user = _userRep.GetByEmailAdd(this.User.Claims.SingleOrDefault(x => x.Type == "EmailAddress").Value);
         return(Ok(_manager.GetQuerySource(filter, user)));
     }
     catch (BasicException ex)
     {
         _logger.LogError(ex.Message);
         return(BadRequest(ex.Message));
     }
     catch (NotFoundException ex)
     {
         _logger.LogError(ex.Message);
         return(NotFound(ex.Message));
     }
     catch (PermissionException ex)
     {
         _logger.LogError(ex.Message);
         return(Unauthorized());
     }
     catch (Exception ex)
     {
         _logger.LogError(ex.Message);
         return(BadRequest());
     }
 }