Commit b56a0203 by tangzhongyang

新增下载当前测算表的接口

parent d9e82b65
using FluentValidation.AspNetCore; using FluentValidation.AspNetCore;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal; using Microsoft.AspNetCore.Http.Internal;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.StaticFiles;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Performance.DtoModels; using Performance.DtoModels;
...@@ -16,6 +18,7 @@ ...@@ -16,6 +18,7 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
...@@ -500,5 +503,30 @@ public ApiResponse Reserved([FromBody] ReservedRequest request) ...@@ -500,5 +503,30 @@ public ApiResponse Reserved([FromBody] ReservedRequest request)
return new ApiResponse(ResponseType.OK, result); return new ApiResponse(ResponseType.OK, result);
} }
/// <summary>
/// 下载当前测算表
/// </summary>
/// <returns></returns>
[Route("download")]
[HttpPost]
[AllowAnonymous]
public IActionResult DownloadCurrentCalculationTable([FromBody] AllotRequest request)
{
var allot = _allotService.GetAllot(request.ID);
if (null == allot)
throw new PerformanceException("当前测算表不存在");
var memoryStream = new MemoryStream();
using (var stream = new FileStream(allot.Path, FileMode.Open))
{
stream.CopyToAsync(memoryStream).Wait();
}
memoryStream.Seek(0, SeekOrigin.Begin);
var provider = new FileExtensionContentTypeProvider();
FileInfo fileInfo = new FileInfo(allot.Path);
var memi = provider.Mappings[".xlsx"];
return File(memoryStream, memi, Path.GetFileName(fileInfo.Name));
}
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment