merge: 合并初始化缓存与资源释放优化

This commit is contained in:
2026-08-15 11:39:58 +08:00
27 changed files with 474 additions and 110 deletions
+60 -32
View File
@@ -77,6 +77,10 @@ namespace Lskj.Control
/// </summary>
private bool _visibleMrpSearchPanel;
/// <summary>
/// 外部已查询的MRP操作按钮数据,供搜索区域复用。
/// </summary>
public DataTable MrpClickMenus;
/// <summary>
/// 底部操作按钮是否显示简短模式,默认为简短模式
/// </summary>
private bool _operShortMode = true;
@@ -529,7 +533,17 @@ namespace Lskj.Control
searchObj.GetSearchDataCaches(Model.DataCaches);
}
}
if (this.MrpClickMenus == null && Model.DataCaches != null)
{
Model.DataCaches.GetValue(
this,
"UnionBaseGridRightMenus",
out this.MrpClickMenus);
}
this.SearchObj = searchObj;
// 搜索区域复用当前模块配置,MyControl 内部会校验模块号,不一致时仍按原逻辑查询。
this.SearchObj.SystemModel = this.SysModel;
this.SearchObj.MrpClickMenus = this.MrpClickMenus;
if (this._leftGridField != null)
{
@@ -551,13 +565,6 @@ namespace Lskj.Control
if (fixedQuery)
{
//固定条件不显示,隐藏上方。(只显示表格)
if (SystemInfo.Instance.HideFixedConditions)
{
this.pl_top.Visible = false;
return;
}
this.pl_top_fix_search.Visible = true;
// 加载固定查询条件
@@ -570,7 +577,12 @@ namespace Lskj.Control
{
table = Business.Impl.LanguageTranslation.TranslationTableColumn(table, "fieldText");
}
//固定条件不显示,隐藏上方。(只显示表格)
if (SystemInfo.Instance.HideFixedConditions)
{
this.pl_top.Visible = false;
table = new DataTable();
}
// DataTable
this.cbField.DisplayMember = "fieldText";
@@ -3480,6 +3492,12 @@ namespace Lskj.Control
// 刷新数据
if (ImportResults)
{
if (!string.IsNullOrWhiteSpace(this.SysModel.afterimportSql))
{
string sql = this.SearchObj.ReplaceControlValue(this.SysModel.afterimportSql);
string newResult = SqlHelper.ExecuteScalar(sql) + "";
}
if (ImportReturnName.Count > 0)
{
this.SearchObj.SearchGrid();
@@ -3488,11 +3506,7 @@ namespace Lskj.Control
{
this.SearchObj.SearchLastGrid();
}
if (!string.IsNullOrWhiteSpace(this.SysModel.afterimportSql))
{
string sql = this.SearchObj.ReplaceControlValue(this.SysModel.afterimportSql);
string newResult = SqlHelper.ExecuteScalar(sql) + "";
}
}
//GridColumnCollection gridColumns = this.gcMain.GridView.Columns;
@@ -3527,11 +3541,20 @@ namespace Lskj.Control
FrmImport import = new FrmImport(this.SysModel.MenuTable, this.Model.ModuleCode, _parmaryKey, this.gcMain, this.SysModel.PrefixKey, leftField, leftValue, this.Model.FormText, this.SysModel.ConcatenatedPrefix);
import.ParentGridEx = this.ParentGridEx;
import.SearchObj = this.SearchObj;
import.ImportReturnName = ImportReturnName;
import.ImportReturnValue = ImportReturnValue;
DialogResult result = import.ShowDialog();
if (result == DialogResult.OK)
{
if (!string.IsNullOrWhiteSpace(this.SysModel.afterimportSql))
{
string sql = this.SearchObj.ReplaceControlValue(this.SysModel.afterimportSql);
string newResult = SqlHelper.ExecuteScalar(sql) + "";
//if (!string.IsNullOrEmpty(newResult)) MessageUtil.Show(newResult);
}
// 刷新数据
if (ImportReturnName.Count > 0)
{
@@ -3542,14 +3565,6 @@ namespace Lskj.Control
this.SearchObj.SearchLastGrid();
}
if (!string.IsNullOrWhiteSpace(this.SysModel.afterimportSql))
{
string sql = this.SearchObj.ReplaceControlValue(this.SysModel.afterimportSql);
string newResult = SqlHelper.ExecuteScalar(sql) + "";
//if (!string.IsNullOrEmpty(newResult)) MessageUtil.Show(newResult);
}
}
}
@@ -3688,6 +3703,16 @@ namespace Lskj.Control
{
InitializeComponent();
this.OperShortMode = true;
this.Disposed += OnModuleGridExDisposed;
}
/// <summary>
/// 清理公共事件和全局右键引用,避免模块关闭后仍保留当前表格。
/// </summary>
private void OnModuleGridExDisposed(object sender, EventArgs e)
{
this.Disposed -= OnModuleGridExDisposed;
ReleaseResourcesForDispose();
}
internal void ReleaseResourcesForDispose()
@@ -3707,6 +3732,10 @@ namespace Lskj.Control
searchObj.OnSearchBeforeCallBack -= OnSearchBeforeCallBack;
searchObj.OnSearchAfterCallBack -= OnSearchAfterCallBack;
searchObj.OnDataSourceBindCallBack -= OnMainSearchDataSourceBindCallBack;
if (ReferenceEquals(StaticControl.RightMenuMyControl, searchObj))
{
StaticControl.RightMenuMyControl = null;
}
searchObj.Dispose();
}
@@ -3714,6 +3743,10 @@ namespace Lskj.Control
{
if (gcMain != null)
{
if (ReferenceEquals(StaticControl.RightMenuGridView, gcMain.GridView))
{
StaticControl.RightMenuGridView = null;
}
if (gcMain.GridView != null)
{
gcMain.GridView.FocusedRowObjectChanged -= OnGridViewFocusedRowObjectChanged;
@@ -3895,13 +3928,10 @@ namespace Lskj.Control
}
if (this.SearchObj != null)
{
this.SearchObj.SystemModel = sysModel;
}
//if (this.SearchObj != null)
//{
// this.SearchObj.SystemModel = sysModel;
//}
//禁用条件
if (this.SysModel.ForbiddenCondition)
@@ -4068,10 +4098,8 @@ namespace Lskj.Control
{
return BaseModuleImpl.GetSchemesList(dynamicModel.ModuleId);//获取高级查询条件模版
}));
Task<ModuleModel> searchSysModelTask = cachesDic.AddTask(pl_top_search, "SysModel", new Task<ModuleModel>(() =>
{
return new ModuleModel(MainImpl.GetSystemdllTab(dynamicModel.ModuleCode));
}));
// 搜索区域与当前模块共享同一个模块配置任务,避免再次查询模块信息。
cachesDic.AddTask(pl_top_search, "SysModel", sysModelTask);
//Task<DataTable> searchBaseGridRightMenusTask = cachesDic.AddTask(pl_top_search, "BaseGridRightMenus", new Task<DataTable>(() =>
//{
// return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);