优化

parent f803f268
namespace Performance.Services.OnlineExcel using Performance.DtoModels;
namespace Performance.Services.OnlineExcel
{ {
public partial class OnlineExcelService public partial class OnlineExcelService
{ {
...@@ -19,6 +21,9 @@ public string Message ...@@ -19,6 +21,9 @@ public string Message
return ""; 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 ...@@ -35,10 +35,14 @@ public partial class OnlineExcelService : IAutoInjection
public static TimeSpan absoluteExpirationRelativeToNow = new TimeSpan(0, 5, 0); public static TimeSpan absoluteExpirationRelativeToNow = new TimeSpan(0, 5, 0);
private readonly IMemoryCache _cache; private readonly IMemoryCache _cache;
private readonly PerSheetService _sheetService;
public OnlineExcelService(IMemoryCache cache) public OnlineExcelService(
IMemoryCache cache,
PerSheetService sheetService)
{ {
_cache = cache; _cache = cache;
_sheetService = sheetService;
} }
/// <summary> /// <summary>
/// 读取Sheet名称 /// 读取Sheet名称
...@@ -61,13 +65,20 @@ public List<ExcelSheetInfo> GetExcelSheetName(per_allot allot) ...@@ -61,13 +65,20 @@ public List<ExcelSheetInfo> GetExcelSheetName(per_allot allot)
{ {
foreach (var sheet in package.Workbook.Worksheets) 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, sheetNames.Add(new ExcelSheetInfo
Row = sheet.Dimension.End.Row, {
Column = sheet.Dimension.End.Column, Name = sheet.Name,
Version = version.ToString(), Row = sheet.Dimension.End.Row,
}); Column = sheet.Dimension.End.Column,
SheetType = sheetType,
ModuleName = EnumHelper.GetDescription(sheetType),
Version = version.ToString(),
});
}
} }
} }
_cache.Set(key, sheetNames, absoluteExpirationRelativeToNow); _cache.Set(key, sheetNames, absoluteExpirationRelativeToNow);
...@@ -135,8 +146,6 @@ public EpSheet ReadSheet(per_allot allot, string sheetName) ...@@ -135,8 +146,6 @@ public EpSheet ReadSheet(per_allot allot, string sheetName)
return epSheet; return epSheet;
} }
package.Save();
} }
return null; 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