コード例 #1
0
        public IHttpActionResult GetPunchesByUser(
            [FromUri] string UserScope,
            [FromUri] int[] UserIds,
            [FromUri] string JobScope,
            [FromUri] int[] JobIds,
            [FromUri] DateTime Min,
            [FromUri] DateTime Max,
            [FromUri] string CommitStatus)
        {
            var currentUser = CurrentUser();

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

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

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

            return(new FileActionResult(
                       bytes,
                       "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
                       $"Report - Punches by User {Min.ToString("yyyy_MM_dd")} thru {Max.ToString("yyyy_MM_dd")}.xlsx",
                       Request));
        }
コード例 #2
0
        public IActionResult GetPunchesByUser(
            [FromQuery] string UserScope,
            [FromQuery] int[] UserIds,
            [FromQuery] string JobScope,
            [FromQuery] int[] JobIds,
            [FromQuery] DateTime Min,
            [FromQuery] DateTime Max,
            [FromQuery] string CommitStatus)
        {
            var currentUser = CurrentUser();

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

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

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

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