Пример #1
0
        public IHttpActionResult GetTimeEntriesByJob(
            [FromUri] string UserScope,
            [FromUri] int[] UserIds,
            [FromUri] string JobScope,
            [FromUri] int[] JobIds,
            [FromUri] DateTime Min,
            [FromUri] DateTime Max)
        {
            var currentUser = CurrentUser();

            telemetryClient.TrackTrace($"Generating TimeEntriesByJob report for {Min:G} through {Max:G}");

            // Ensure that user is authorized.
            if (!currentUser.CanViewReports)
            {
                return(StatusCode(HttpStatusCode.Forbidden));
            }

            var bytes = new TimeCardsByProjectAsExcel().Build(currentUser, Min, Max, UserScope, UserIds, JobScope, JobIds);

            return(new FileActionResult(
                       bytes,
                       "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                       $"Report - Time Cards by Project {Min.ToString("yyyy_MM_dd")} thru {Max.ToString("yyyy_MM_dd")}.xlsx",
                       Request));
        }
Пример #2
0
        public IActionResult GetTimeEntriesByJob(
            [FromQuery] string UserScope,
            [FromQuery] int[] UserIds,
            [FromQuery] string JobScope,
            [FromQuery] int[] JobIds,
            [FromQuery] DateTime Min,
            [FromQuery] DateTime Max)
        {
            var currentUser = CurrentUser();

            _telemetryClient.TrackTrace($"Generating TimeEntriesByJob report for {Min:G} through {Max:G}");

            // Ensure that user is authorized.
            if (!currentUser.CanViewReports)
            {
                return(Forbid());
            }

            var bytes = new TimeCardsByProjectAsExcel().Build(_context, currentUser, Min, Max, UserScope, UserIds, JobScope, JobIds);

            return(File(
                       bytes,
                       "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                       fileDownloadName: $"Report - Time Cards by Project {Min.ToString("yyyy_MM_dd")} thru {Max.ToString("yyyy_MM_dd")}.xlsx"));
        }