<commit_before>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Dhgms.AspNetCoreContrib.Example.WebSite.Features.MediaTypeHeaders;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Net.Http.Headers;

namespace Dhgms.AspNetCoreContrib.Example.WebSite.Controllers
{
    public class ExcelController : Controller
    {
        public async Task<IActionResult> GetAsync()
        {
            var filestream = Stream.Null;
            if (filestream == null)
            {
                return this.NotFound();
            }

            var contentType = MediaTypeHeaderStringHelpers.ApplicationVndOpenXmlFormatsOfficeDocumentSpreadsheetMlSheet;
            return this.File(filestream, contentType);<commit_msg>more skeleton work on excel controller<commit_after>﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Claims;
using System.Threading;
using System.Threading.Tasks;
using Dhgms.AspNetCoreContrib.Abstractions;
using Dhgms.AspNetCoreContrib.Controllers.Extensions;
using Dhgms.AspNetCoreContrib.Example.WebSite.Features.MediaTypeHeaders;
using MediatR;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Microsoft.Net.Http.Headers;

namespace Dhgms.AspNetCoreContrib.Example.WebSite.Controllers
{
    public sealed class ExcelController : Controller
    {
        private IAuthorizationService _authorizationService;

        private ILogger<ExcelController> _logger;

        private IMediator _mediator;

        public ExcelController(
            IAuthorizationService authorizationService,
            ILogger<ExcelController> logger,
            IMediator mediator)
        {
            this._authorizationService = authorizationService ??
                                        throw new ArgumentNullException(nameof(authorizationService));
            this._logger = logger ??
                          throw new ArgumentNullException(nameof(logger));

            this._mediator = mediator ?? throw new ArgumentNullException(nameof(mediator));

        }

        public async Task<IActionResult> GetAsync()
        {
            int viewRequestDto = 1;
            string viewPolicyName = "viewExcelSpreadSheet";

            return await this.GetViewActionAsync<int, FileNameAndStream, IAuditableRequest<int, FileNameAndStream>>(
                this._logger,
                _mediator,
                _authorizationService,
                viewRequestDto,
                new EventId(1, "View Spreadsheet"),
                viewPolicyName,
                getViewActionResultAsync,
                viewCommandFactoryAsync,
                CancellationToken.None).ConfigureAwait(false);
        }

        private Task<IAuditableRequest<int, FileNameAndStream>> viewCommandFactoryAsync(
            int id,
            ClaimsPrincipal claimsPrincipal,
            CancellationToken cancellationToken)
        {
            throw new NotImplementedException();
        }

        private async Task<IActionResult> getViewActionResultAsync(FileNameAndStream file)
        {
            var contentType = MediaTypeHeaderStringHelpers.ApplicationVndOpenXmlFormatsOfficeDocumentSpreadsheetMlSheet;
            return this.File(file.FileStream, contentType, file.FileName);
        }

        public sealed class FileNameAndStream
        {
            public string FileName { get; set; }
            public Stream FileStream { get; set; }
{'fraction_non_alphanumeric': 0.06649760495914342, 'fraction_numerical': 0.0005635390250774866, 'mean_word_length': 2.6825726141078836, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4232425', 'n_tokens_mistral': 883, 'n_tokens_neox': 878, 'n_words': 180}