修改提示
This commit is contained in:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user