Ejemplo n.º 1
0
        public IActionResult PostReportsGrid([FromBody] RequestReportsGrid reportsGridData)
        {
            try
            {
                var userName = this.GetUserNameWithImpersonation();

                switch (reportsGridData.GroupById)
                {
                case (int)ReportsGroupBy.Project:
                {
                    return(_service.ExportGroupByProjects(userName, reportsGridData, HttpContext));
                }

                case (int)ReportsGroupBy.User:
                {
                    return(_service.ExportGroupByUsers(userName, reportsGridData, HttpContext));
                }

                case (int)ReportsGroupBy.Date:
                {
                    return(_service.ExportGroupByDates(userName, reportsGridData, HttpContext));
                }

                case (int)ReportsGroupBy.Client:
                {
                    return(_service.ExportGroupByClients(userName, reportsGridData, HttpContext));
                }

                default:
                {
                    return(_service.ExportGroupByNone(userName, reportsGridData, HttpContext));
                }
                }
            }
            catch (InvalidOperationException invalidOperationException)
            {
                _logger.LogWarning(invalidOperationException.Message + $"\n {invalidOperationException}");
                var errors = ExceptionsChecker.CheckRunMethodSetCommonValuesForExportException(invalidOperationException);
                return(BadRequest(errors));
            }
            catch (Exception e)
            {
                _logger.LogWarning($"PostReportsGrid method with parameters ({reportsGridData});\n {e}");
                var errors = ExceptionsChecker.CheckProjectsException(e);
                return(BadRequest(errors));
            }
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> ReportsExportFileAsync([FromBody] ReportsGridView reportsGridData)
        {
            try
            {
                switch (reportsGridData.CurrentQuery.GroupById)
                {
                case (int)ReportsGroupBy.Project:
                {
                    return(await _service.ExportFileGroupByProjectsAsync(reportsGridData, HttpContext));
                }

                case (int)ReportsGroupBy.User:
                {
                    return(await _service.ExportFileGroupByUsersAsync(reportsGridData, HttpContext));
                }

                case (int)ReportsGroupBy.Date:
                {
                    return(await _service.ExportFileGroupByDatesAsync(reportsGridData, HttpContext));
                }

                case (int)ReportsGroupBy.Client:
                {
                    return(await _service.ExportFileGroupByClientsAsync(reportsGridData, HttpContext));
                }

                default:
                {
                    return(BadRequest());
                }
                }
            }
            catch (InvalidOperationException invalidOperationException)
            {
                _logger.LogWarning(invalidOperationException.Message + $"\n {invalidOperationException}");
                var errors = ExceptionsChecker.CheckRunMethodSetCommonValuesForExportException(invalidOperationException);
                return(BadRequest(errors));
            }
            catch (Exception e)
            {
                _logger.LogWarning($"ReportsExportFile method with parameters ({reportsGridData});\n {e}");
                var errors = ExceptionsChecker.CheckProjectsException(e);
                return(BadRequest(errors));
            }
        }