|
|
|
@ -2,7 +2,6 @@ |
|
|
|
|
using DinkToPdf.Contracts; |
|
|
|
|
using Microsoft.AspNetCore.Hosting; |
|
|
|
|
using Microsoft.Extensions.Hosting; |
|
|
|
|
using NPOI.OpenXmlFormats.Wordprocessing; |
|
|
|
|
using System.IO.Compression; |
|
|
|
|
using static Tiobon.Core.Model.Consts; |
|
|
|
|
|
|
|
|
@ -3641,6 +3640,7 @@ WHERE A.IsEnable = 1 AND C.IsEnable = 1 AND C.Status = A.Status"; |
|
|
|
|
|
|
|
|
|
break; |
|
|
|
|
case "SendOffer": |
|
|
|
|
case "OfferDownLoad": |
|
|
|
|
if (interviewLog.Reverse1.IsNotEmptyOrNull()) |
|
|
|
|
item.OfferFileUrl = interviewLog.Reverse1; |
|
|
|
|
break; |
|
|
|
@ -3668,6 +3668,72 @@ WHERE A.IsEnable = 1 AND C.IsEnable = 1 AND C.Status = A.Status"; |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region Offer下载 |
|
|
|
|
public async Task<ServiceResult<string>> OfferDownLoad(long id, long templateId, Dictionary<string, string> extFields) |
|
|
|
|
{ |
|
|
|
|
var entity = await base.QueryById(id); |
|
|
|
|
if (entity == null) |
|
|
|
|
return ServiceResult<string>.OprateFailed("无效的简历ID!"); |
|
|
|
|
var order = await _ghrh_InterviewOrderServices.QuerySingle(x => x.ResumeId == id); |
|
|
|
|
var content = (await _ghrh_TemplateServices.Preview(id, templateId, extFields)).Data; |
|
|
|
|
|
|
|
|
|
#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"]); |
|
|
|
|
|
|
|
|
|
await _ghrh_InterviewLogServices.Add(new InsertGhrh_InterviewLogInput() |
|
|
|
|
{ |
|
|
|
|
InterviewOrderId = order.Id, |
|
|
|
|
ResumeId = id, |
|
|
|
|
StaffId = App.User.StaffId, |
|
|
|
|
StaffName = App.User.StaffName + "(" + App.User.StaffNo + ")", |
|
|
|
|
Source = "OfferDownLoad", |
|
|
|
|
Reverse1 = entity.OfferFileUrl, |
|
|
|
|
UserId = App.User.ID, |
|
|
|
|
UserName = App.User.Name, |
|
|
|
|
RemarkSz = $"下载Offer!", |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
return ServiceResult<string>.OprateSuccess("获取成功", entity.OfferFileUrl); |
|
|
|
|
} |
|
|
|
|
#endregion |
|
|
|
|
|
|
|
|
|
#region 通用方法 |
|
|
|
|
/// <summary> |
|
|
|
|
/// 记录日志 |
|
|
|
|