修改提示

This commit is contained in:
2022-05-17 11:58:20 +08:00
parent 6312dec704
commit a44c3dae10
10 changed files with 104 additions and 70 deletions
@@ -4,13 +4,8 @@
// 对此文件的更改可能会导致不正确的行为,并且如果重新生成代码,这些更改将会丢失。
//--------------------------------------------------------------------
using IRaCIS.Core.Domain.Models;
using Microsoft.AspNetCore.Mvc;
using IRaCIS.Core.Infrastructure.Extention;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using IRaCIS.Core.Application.Contracts;
using IRaCIS.Core.Infra.EFCore;
using User = IRaCIS.Core.Domain.Models.User;
namespace IRaCIS.Core.Application.Services
@@ -70,9 +65,8 @@ namespace IRaCIS.Core.Application.Services
}
else
{
var document = await _systemDocumentRepository.Where(t => t.Id == addOrEditSystemDocument.Id, true, true).Include(t => t.NeedConfirmedUserTypeList).FirstOrDefaultAsync();
var document = (await _systemDocumentRepository.Where(t => t.Id == addOrEditSystemDocument.Id, true, true).Include(t => t.NeedConfirmedUserTypeList).FirstOrDefaultAsync()).IfNullThrowException();
if (document == null) return Null404NotFound(document);
if (await _systemDocumentRepository.AnyAsync(t => t.FileTypeId == addOrEditSystemDocument.FileTypeId && t.Name == addOrEditSystemDocument.Name && t.Id != addOrEditSystemDocument.Id, true))
{
@@ -82,25 +76,29 @@ namespace IRaCIS.Core.Application.Services
_mapper.Map(addOrEditSystemDocument, document);
document.UpdateTime = DateTime.Now;
#region
if (document.FileTypeId != addOrEditSystemDocument.FileTypeId)
{
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName;
var beforeFilePath = Path.Combine(rootPath, document.Path);
//if (document.FileTypeId != addOrEditSystemDocument.FileTypeId)
//{
// var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName;
// var beforeFilePath = Path.Combine(rootPath, document.Path);
document.Path = document.Path.Replace(document.FileTypeId.ToString(), addOrEditSystemDocument.FileTypeId.ToString());
// document.Path = document.Path.Replace(document.FileTypeId.ToString(), addOrEditSystemDocument.FileTypeId.ToString());
var nowPath = Path.Combine(rootPath, document.Path);
// var nowPath = Path.Combine(rootPath, document.Path);
if (File.Exists(beforeFilePath))
{
File.Move(beforeFilePath, nowPath, true);
File.Delete(beforeFilePath);
}
// if (File.Exists(beforeFilePath))
// {
// File.Move(beforeFilePath, nowPath, true);
// File.Delete(beforeFilePath);
// }
}
var success = await _repository.SaveChangesAsync();
//}
#endregion
var success = await _systemDocumentRepository.SaveChangesAsync();
return ResponseOutput.Ok(document.Id.ToString());
}
@@ -418,34 +418,37 @@ namespace IRaCIS.Core.Application.Services
return ResponseOutput.NotOk("同类型已存在该文件名");
}
var document = _trialDocumentRepository.Where(t => t.Id == addOrEditTrialDocument.Id, true).Include(t => t.NeedConfirmedUserTypeList).FirstOrDefault();
var document = (await _trialDocumentRepository.Where(t => t.Id == addOrEditTrialDocument.Id, true).Include(t => t.NeedConfirmedUserTypeList).FirstOrDefaultAsync()).IfNullThrowException();
if (document == null) return Null404NotFound(document);
//var dbDocumentType = document.Type;
_mapper.Map(addOrEditTrialDocument, document);
if (document.FileTypeId != addOrEditTrialDocument.FileTypeId)
{
#region
//if (document.FileTypeId != addOrEditTrialDocument.FileTypeId)
//{
var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName;
var beforeFilePath = Path.Combine(rootPath, document.Path);
// var rootPath = Directory.GetParent(_hostEnvironment.ContentRootPath.TrimEnd('\\')).IfNullThrowException().FullName;
// var beforeFilePath = Path.Combine(rootPath, document.Path);
document.Path = document.Path.Replace(document.FileTypeId.ToString(), addOrEditTrialDocument.FileTypeId.ToString());
// document.Path = document.Path.Replace(document.FileTypeId.ToString(), addOrEditTrialDocument.FileTypeId.ToString());
var nowPath = Path.Combine(rootPath, document.Path);
// var nowPath = Path.Combine(rootPath, document.Path);
if (File.Exists(beforeFilePath))
{
File.Move(beforeFilePath, nowPath, true);
File.Delete(beforeFilePath);
}
// if (File.Exists(beforeFilePath))
// {
// File.Move(beforeFilePath, nowPath, true);
// File.Delete(beforeFilePath);
// }
}
//}
var success = await _repository.SaveChangesAsync();
#endregion
var success = await _trialDocumentRepository.SaveChangesAsync();
return ResponseOutput.Ok(document.Id.ToString());
}
@@ -525,10 +528,7 @@ namespace IRaCIS.Core.Application.Services
/// <returns></returns>
public async Task<IResponseOutput> UserConfirm(UserConfirmCommand userConfirmCommand)
{
if (userConfirmCommand.isSystemDoc)
{
if (await _repository.AnyAsync<SystemDocConfirmedUser>(t => t.SystemDocumentId == userConfirmCommand.DocumentId && t.ConfirmUserId == _userInfo.Id))