Files
zszq-trs/YLErpWeb/Common/DocFileHelper.cs
T
2024-05-09 14:06:26 +08:00

38 lines
1.2 KiB
C#

using YLErp;
namespace System.Web.Mvc
{
/// <summary>
/// 用于处理确认书文件帮助类
/// </summary>
public static class DocFileHelper
{
/// <summary>
/// 检查确认书文件返回的结果路径是否能够正确对应物理文件,如果不能够对应,尝试修补
/// </summary>
public static List<string> CheckResultDocFilePath(IEnumerable<string> files)
{
return files?.Where(n => !string.IsNullOrWhiteSpace(n)).Select(n =>
{
var physicalPath = OtcAppContext.MapPath(n.TrimStart('.'));
if (physicalPath.EndsWith("x"))
{
if (!File.Exists(physicalPath))
{
physicalPath = physicalPath.Substring(0, physicalPath.Length - 1);
return File.Exists(physicalPath) ? n.Substring(0, n.Length - 1) : n;
}
}
else if (!File.Exists(physicalPath))
{
return File.Exists(physicalPath + "x") ? n + "x" : n;
}
return n;
}).ToList();
}
}
}