打印采用 MemoryCache 替代原有 Web 缓存,,提升兼容性与性能。报表数据与参数缓存方式由 Session 直接存储对象改为存储缓存键,实际数据存入 MemoryCache,避免 Session 大对象。
This commit is contained in:
@@ -29,14 +29,35 @@ namespace FineUIPro.Web.common.ReportPrint
|
||||
{
|
||||
get
|
||||
{
|
||||
return (List<DataTable>)Session["ReportDataTables"];
|
||||
List<DataTable> dataTables = new List<DataTable>();
|
||||
var cacheKeys = HttpContext.Current.Session["ReportDataCacheKeys"] as List<string>;
|
||||
if (cacheKeys != null)
|
||||
{
|
||||
foreach (var key in cacheKeys)
|
||||
{
|
||||
|
||||
var dataTable = CacheHelper.Get<DataTable>(key);
|
||||
if (dataTable != null)
|
||||
{
|
||||
dataTables.Add(dataTable);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
return dataTables;
|
||||
}
|
||||
}
|
||||
public Dictionary<string, string> ParameterValues
|
||||
{
|
||||
get
|
||||
{
|
||||
return (Dictionary<string, string>)Session["ReportParameterValues"];
|
||||
var cacheKey = Session["ReportParameterCacheKey"] as string;
|
||||
if (!string.IsNullOrEmpty(cacheKey))
|
||||
{
|
||||
return CacheHelper.Get<Dictionary<string, string>>(cacheKey);
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
@@ -58,7 +79,10 @@ namespace FineUIPro.Web.common.ReportPrint
|
||||
WebReport1.Report.Save(ReportPath);
|
||||
}
|
||||
WebReport1.ReportFile = ReportPath;
|
||||
WebReport1.Prepare();
|
||||
System.Threading.Tasks.Task.Run(() =>
|
||||
{
|
||||
WebReport1.Prepare();
|
||||
});
|
||||
// WebReport1.ExportPdf();
|
||||
}
|
||||
private void demo()
|
||||
|
||||
Reference in New Issue
Block a user