This commit is contained in:
geh
2025-05-06 15:21:24 +08:00
parent 5d52ebd488
commit 6a7a44f9da
5 changed files with 42 additions and 13 deletions
@@ -88,7 +88,7 @@ namespace WebAPI.Controllers.HSSE
Model.ToDoItem toDoItem = new Model.ToDoItem
{
MenuId = Const.PersonListMenuId,
DataId = item.PersonId + "_1",
DataId = item.PersonId + "_2",
UrlStr = item.AttachUrl1,
};
if (!string.IsNullOrEmpty(item.AttachUrl1))
@@ -96,21 +96,21 @@ namespace WebAPI.Controllers.HSSE
APIUpLoadFileService.SaveAttachUrl(toDoItem);
}
toDoItem.DataId = item.PersonId + "_2";
toDoItem.DataId = item.PersonId + "_3";
toDoItem.UrlStr = item.AttachUrl2;
if (!string.IsNullOrEmpty(item.AttachUrl2))
{
APIUpLoadFileService.SaveAttachUrl(toDoItem);
}
toDoItem.DataId = item.PersonId + "_3";
toDoItem.DataId = item.PersonId + "_4";
toDoItem.UrlStr = item.AttachUrl3;
if (!string.IsNullOrEmpty(item.AttachUrl3))
{
APIUpLoadFileService.SaveAttachUrl(toDoItem);
}
toDoItem.DataId = item.PersonId + "_4";
toDoItem.DataId = item.PersonId + "_5";
toDoItem.UrlStr = item.AttachUrl4;
if (!string.IsNullOrEmpty(item.AttachUrl4))
{
@@ -641,8 +641,11 @@ namespace WebAPI.Controllers
/// 岗位交卷
/// <param name="testRecordId">试卷ID</param>
/// </summary>
public Model.ResponeData SaveSubmitTestRecord(string testRecordId,string Signature)
[HttpPost]
public Model.ResponeData postSubmitTestRecord(Model.TestRecordItem testRecordItem)
{
string testRecordId = testRecordItem.TestRecordId;
string Signature = testRecordItem.Signature;
var responeData = new Model.ResponeData();
try
{
@@ -653,9 +656,31 @@ namespace WebAPI.Controllers
var getTestRecord = db.Training_TestRecord.FirstOrDefault(e => e.TestRecordId == testRecordId);
if (getTestRecord != null)
{
string rootUrl = ConfigurationManager.AppSettings["localRoot"];
string SignatureUrl = @"FileUpload\TestRecord\" + getTestRecord.TestRecordId + "~签名" + ".png";
string Signaturefilename = rootUrl + SignatureUrl;
if (getTestRecord.TestStartTime.HasValue)
{
getTestRecord.Signature = Signature;
if (!string.IsNullOrEmpty(Signature))
{
Signature = Signature.Replace("data:image/svg+xml;base64,", "").Replace("data:image/png;base64,", "").Replace("data:image/jgp;base64,", "").Replace("data:image/jpg;base64,", "").Replace("data:image/jpeg;base64,", "");//将base64头部信息替换
byte[] bytes = Convert.FromBase64String(Signature);
MemoryStream memStream = new MemoryStream(bytes);
Image mImage = Image.FromStream(memStream);
Bitmap bp = new Bitmap(mImage);
MemoryStream ms = new MemoryStream();
// 确保目录存在
string directory = Path.GetDirectoryName(Signaturefilename);
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
bp.Save(Signaturefilename, System.Drawing.Imaging.ImageFormat.Png);
getTestRecord.Signature = Signaturefilename.Replace(rootUrl, "");
}
getTestRecord.TestEndTime = DateTime.Now;
getTestRecord.TestScores = db.Training_TestRecordItem.Where(x => x.TestRecordId == testRecordId).Sum(x => x.SubjectScore ?? 0);
db.SubmitChanges();
@@ -158,7 +158,7 @@ namespace WebAPI.Filter
, "TestRecord*getTestRecordItemListByTestRecordId"
, "TestRecord*getTestTimesByTestRecordId"
, "TestRecord*getTestRecordItemAnswerBySelectedItem"
, "TestRecord*SaveSubmitTestRecord"
, "TestRecord*postSubmitTestRecord"
};
/// <summary>