临时文件下载

booking_auth_dev
wet 2 years ago
parent 0c5e4adbbb
commit e908538d43

@ -4822,7 +4822,14 @@
打印 打印
</summary> </summary>
<param name="bookingId">订舱Id</param> <param name="bookingId">订舱Id</param>
<param name="type">类型1pdf、2xlsx</param> <param name="typeCode">打印类型代码对应字典booking_template_type</param>
<returns></returns>
</member>
<member name="M:Myshipping.Application.BookingOrderService.DownloadPrint(System.String)">
<summary>
下载打印文件
</summary>
<param name="fileName">文件名</param>
<returns></returns> <returns></returns>
</member> </member>
<member name="M:Myshipping.Application.BookingOrderService.SendXHZ(System.Int64)"> <member name="M:Myshipping.Application.BookingOrderService.SendXHZ(System.Int64)">

@ -1211,25 +1211,20 @@ namespace Myshipping.Application
/// 打印 /// 打印
/// </summary> /// </summary>
/// <param name="bookingId">订舱Id</param> /// <param name="bookingId">订舱Id</param>
/// <param name="type">类型1pdf、2xlsx</param> /// <param name="typeCode">打印类型代码对应字典booking_template_type</param>
/// <returns></returns> /// <returns></returns>
[HttpGet("/BookingOrder/Print")] [HttpGet("/BookingOrder/Print")]
public async Task<string> Print(long bookingId, string type) public async Task<string> Print(long bookingId, string typeCode)
{ {
var bs = await GetReportFile(bookingId, type); var bs = await GetReportFile(bookingId, typeCode);
var fileName = HttpUtility.UrlEncode($"{bookingId}_{DateTime.Now.Ticks}.pdf", Encoding.GetEncoding("UTF-8"));////名称 var fileName = HttpUtility.UrlEncode($"{bookingId}_{DateTime.Now.Ticks}.pdf", Encoding.GetEncoding("UTF-8"));////名称
//var result = new FileContentResult(bs, "application/octet-stream") { FileDownloadName = fileName }; //var result = new FileContentResult(bs, "application/octet-stream") { FileDownloadName = fileName };
var opt = App.GetOptions<TempFileOptions>().Path; var opt = App.GetOptions<TempFileOptions>().Path;
var serverpath = Path.Combine(App.WebHostEnvironment.WebRootPath, opt);//服务器路径 var serverpath = Path.Combine(App.WebHostEnvironment.WebRootPath, opt);//服务器路径
if (!Directory.Exists(serverpath)) {
if (bs != null) Directory.CreateDirectory(serverpath);
{
using (System.IO.MemoryStream men = new MemoryStream(bs))
{
System.Drawing.Bitmap bmp = System.Drawing.Bitmap.FromStream(men) as System.Drawing.Bitmap;
bmp.Save(serverpath);
}
} }
await File.WriteAllBytesAsync(Path.Combine(serverpath, fileName),bs);
return fileName; return fileName;
} }
/// <summary> /// <summary>

Loading…
Cancel
Save