优化

parent f803f268
namespace Performance.Services.OnlineExcel
using Performance.DtoModels;
namespace Performance.Services.OnlineExcel
{
public partial class OnlineExcelService
{
......@@ -19,6 +21,9 @@ public string Message
return "";
}
}
public SheetType SheetType { get; internal set; }
public string ModuleName { get; internal set; }
}
}
}
\ No newline at end of file
......@@ -35,10 +35,14 @@ public partial class OnlineExcelService : IAutoInjection
public static TimeSpan absoluteExpirationRelativeToNow = new TimeSpan(0, 5, 0);
private readonly IMemoryCache _cache;
private readonly PerSheetService _sheetService;
public OnlineExcelService(IMemoryCache cache)
public OnlineExcelService(
IMemoryCache cache,
PerSheetService sheetService)
{
_cache = cache;
_sheetService = sheetService;
}
/// <summary>
/// 读取Sheet名称
......@@ -61,13 +65,20 @@ public List<ExcelSheetInfo> GetExcelSheetName(per_allot allot)
{
foreach (var sheet in package.Workbook.Worksheets)
{
sheetNames.Add(new ExcelSheetInfo
SheetType sheetType = _sheetService.GetSheetType(sheet.Name);
if (!sheetNames.Exists(w => w.Name == sheet.Name))
{
Name = sheet.Name,
Row = sheet.Dimension.End.Row,
Column = sheet.Dimension.End.Column,
Version = version.ToString(),
});
sheetNames.Add(new ExcelSheetInfo
{
Name = sheet.Name,
Row = sheet.Dimension.End.Row,
Column = sheet.Dimension.End.Column,
SheetType = sheetType,
ModuleName = EnumHelper.GetDescription(sheetType),
Version = version.ToString(),
});
}
}
}
_cache.Set(key, sheetNames, absoluteExpirationRelativeToNow);
......@@ -135,8 +146,6 @@ public EpSheet ReadSheet(per_allot allot, string sheetName)
return epSheet;
}
package.Save();
}
return null;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment