Files
zszq-trs/YLErpDAL/Helpers/TradeContractHelper.cs
2024-05-09 14:06:26 +08:00

70 lines
1.9 KiB
C#

namespace YLErp.Helpers
{
/// <summary>
/// 交易确认书帮助类
/// </summary>
public static class TradeContractHelper
{
/// <summary>
/// 获取文件绝对路径
/// </summary>
public static string GetAbsolutePath(string dbRelativePath, string dbFileName)
{
var path2 = GetPhysicalPath(dbRelativePath, dbFileName);
string pdfPath;
if (PS.Config.Is海通 || PS.Config.Is宏源)
{
pdfPath = path2.Replace(".pdf", ".doc");
if (!File.Exists(pdfPath))
{
pdfPath = path2.Replace(".pdf", ".docx");
}
}
else
{
// pdfPath = path2.Replace(".docx", ".pdf").Replace(".doc", ".pdf");
pdfPath = path2;
}
if (File.Exists(pdfPath))
{
return pdfPath;
}
return path2;
}
//获取物理路径
public static string GetPhysicalPath(string path, string fileName = null)
{
var path2 = (path ?? string.Empty).Replace("\\", "/").Trim('/');
if (path2.StartsWith("App_Docs", StringComparison.OrdinalIgnoreCase))
{
path2 = "/" + path2;
}
else
{
var index = path2.IndexOf("/App_Docs/", StringComparison.OrdinalIgnoreCase);
if (index < 0)
{
path2 = "/App_Docs/" + path2;
}
else
{
path2 = path2.Substring(index);
}
}
if (!string.IsNullOrWhiteSpace(fileName) && !path2.EndsWith(fileName))
{
path2 = string.Concat(path2, "/", fileName);
}
return OtcAppContext.MapPath(path2);
}
}
}