|
|
|
@ -2,6 +2,7 @@ |
|
|
|
|
using DinkToPdf.Contracts; |
|
|
|
|
using Microsoft.AspNetCore.Hosting; |
|
|
|
|
using Microsoft.Extensions.Hosting; |
|
|
|
|
using System.IO; |
|
|
|
|
using System.IO.Compression; |
|
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
|
|
|
|
|
@ -2104,6 +2105,45 @@ END"; |
|
|
|
|
var id1 = await Db.Insertable(mailOutbox).ExecuteReturnIdentityAsync(); |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 生成Offer PDf |
|
|
|
|
var globalSettings = new GlobalSettings |
|
|
|
|
{ |
|
|
|
|
ColorMode = ColorMode.Color, |
|
|
|
|
Orientation = Orientation.Portrait, |
|
|
|
|
PaperSize = PaperKind.A4, |
|
|
|
|
DocumentTitle = entity.StaffName, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var objectSettings = new ObjectSettings |
|
|
|
|
{ |
|
|
|
|
PagesCount = true, |
|
|
|
|
HtmlContent = content, |
|
|
|
|
WebSettings = { DefaultEncoding = "utf-8" }, |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var pdf = new HtmlToPdfDocument() |
|
|
|
|
{ |
|
|
|
|
GlobalSettings = globalSettings, |
|
|
|
|
Objects = { objectSettings } |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
var fileBytes = _converter.Convert(pdf); |
|
|
|
|
string pathHeader = "wwwroot/files/pdf_files"; |
|
|
|
|
if (!Directory.Exists(pathHeader)) |
|
|
|
|
Directory.CreateDirectory(pathHeader); |
|
|
|
|
var ms = new MemoryStream(fileBytes); |
|
|
|
|
var file = new FormFile(ms, 0, ms.Length, Path.GetFileNameWithoutExtension(pathHeader), Path.GetFileName(pathHeader)); |
|
|
|
|
|
|
|
|
|
var fileName = entity.StaffName + "_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".pdf"; |
|
|
|
|
await using (var fs = System.IO.File.Create(pathHeader + "/" + fileName)) |
|
|
|
|
{ |
|
|
|
|
await file.CopyToAsync(fs); |
|
|
|
|
fs.Flush(); |
|
|
|
|
} |
|
|
|
|
entity.OfferFileUrl = "/Advanced/files/pdf_files/" + fileName; |
|
|
|
|
await Update(entity, ["OfferFileUrl"]); |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
return ServiceResult.OprateSuccess(); |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|