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

This commit is contained in:
2026-08-15 11:39:58 +08:00
27 changed files with 474 additions and 110 deletions
+21 -7
View File
@@ -26,6 +26,7 @@ namespace Lskj.Control.Model
/// </summary>
public class GridDragTree : IDisposable
{
private bool _disposed;
/// <summary>
/// 拖动位置
/// </summary>
@@ -38,7 +39,6 @@ namespace Lskj.Control.Model
/// 拖动目标源
/// </summary>
private TreeView _treeView;
private bool _disposed;
public bool CanDragParentNode = false;
/// <summary>
/// 表格数据拖动完成
@@ -60,25 +60,40 @@ namespace Lskj.Control.Model
this._treeView.AllowDrop = true;
this._treeView.DragOver += new DragEventHandler(treeView_DragOver);
this._treeView.DragDrop += new DragEventHandler(treeView_DragDrop);
if (this._gridView.GridControl != null)
{
this._gridView.GridControl.Disposed += OnOwnerDisposed;
}
this._treeView.Disposed += OnOwnerDisposed;
}
private void OnOwnerDisposed(object sender, EventArgs e)
{
Dispose();
}
/// <summary>
/// 模块关闭时解除源表格和目标树的拖拽事件。
/// </summary>
public void Dispose()
{
if (_disposed)
{
return;
}
if (_disposed) return;
_disposed = true;
if (_gridView != null)
{
_gridView.MouseDown -= gridView_MouseDown;
_gridView.MouseMove -= gridView_MouseMove;
if (_gridView.GridControl != null)
{
_gridView.GridControl.Disposed -= OnOwnerDisposed;
}
}
if (_treeView != null)
{
_treeView.DragOver -= treeView_DragOver;
_treeView.DragDrop -= treeView_DragDrop;
_treeView.Disposed -= OnOwnerDisposed;
}
OnDragComplete = null;
@@ -86,7 +101,6 @@ namespace Lskj.Control.Model
_gridView = null;
_treeView = null;
}
/// <summary>
/// <para>说明:获取表格选中行数据</para>
+1 -1
View File
@@ -958,7 +958,7 @@ namespace Lskj.Control.Model
{
try
{
if (!BaseImpl.HasExistsColumn(ResourceKeys.SettingTableName, ""))
if (!BaseImpl.HasExistsColumn(ResourceKeys.SettingTableName, "IfFixColumn"))
{
BaseImpl.ExecSqlValue("alter table " + ResourceKeys.SettingTableName + " add IfFixColumn bit");
}
@@ -114,6 +114,7 @@ namespace Lskj.Control.Model.MenuStrip
{
conditionRows = new DataRow[] { new DataTable().NewRow() };
}
if (conditionRows.Length == 0) continue;
foreach (DataRow selectRow in conditionRows)
{
@@ -137,6 +137,7 @@ namespace Lskj.Control.Model
{
conditionRows = new DataRow[] { new DataTable().NewRow() };
}
if (conditionRows.Length == 0) continue;
foreach (DataRow selectRow in conditionRows)
{
@@ -147,6 +147,7 @@ namespace Lskj.Control.Model.MenuStrip
{
conditionRows = new DataRow[] { new DataTable().NewRow() };
}
if (conditionRows.Length == 0) continue;
foreach (DataRow selectRow in conditionRows)
{
+33 -11
View File
@@ -143,6 +143,10 @@ namespace Lskj.Control.Model
public DataRow CurrentData;
public ModuleModel SystemModel;
/// <summary>
/// 外部已查询的MRP操作按钮数据;为空时保持原查询逻辑。
/// </summary>
public DataTable MrpClickMenus;
/// <summary>
/// 下拉框、搜索框控件对象
/// </summary>
public List<ControlModel> mControlList = new List<ControlModel>();
@@ -909,10 +913,13 @@ namespace Lskj.Control.Model
return controlModel;
}));
}
Task<DataTable> rightDtGridRightMenusTask = cachesDic.AddTask(this, "RightDtGridRightMenus", new Task<DataTable>(() =>
if (MrpClickMenus == null)
{
return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}));
Task<DataTable> rightDtGridRightMenusTask = cachesDic.AddTask(this, "RightDtGridRightMenus", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}));
}
return true;
}));
}
@@ -1056,7 +1063,17 @@ namespace Lskj.Control.Model
}
if (dynamicModel != null && !string.IsNullOrEmpty(dynamicModel.ModuleCode))
{
if (!dataCaches.GetValue(parent, "SysModel", out ModuleModel moduleModel))
ModuleModel moduleModel = null;
if (SystemModel != null && string.Equals(SystemModel.ModeCode, dynamicModel.ModuleCode, StringComparison.OrdinalIgnoreCase))
{
moduleModel = SystemModel;
}
if (moduleModel == null && dataCaches.GetValue(parent, "SysModel", out ModuleModel cacheModuleModel) &&
cacheModuleModel != null && string.Equals(cacheModuleModel.ModeCode, dynamicModel.ModuleCode, StringComparison.OrdinalIgnoreCase))
{
moduleModel = cacheModuleModel;
}
if (moduleModel == null)
{
moduleModel = new ModuleModel(MainImpl.GetSystemdllTab(dynamicModel.ModuleCode));
}
@@ -1074,13 +1091,14 @@ namespace Lskj.Control.Model
btnCondSearch.Click += new EventHandler(OnBtnCondSearchClick);
}
}
DataTable rightDt = null;
if (dynamicModel != null)
DataTable rightDt = MrpClickMenus;
if (rightDt == null && dynamicModel != null)
{
if (!dataCaches.GetValue(this, "RightDtGridRightMenus", out rightDt))
{
rightDt = BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}
MrpClickMenus = rightDt;
}
if (rightDt != null && rightDt.Rows.Count > 0)
{
@@ -1238,13 +1256,14 @@ namespace Lskj.Control.Model
_popupMenu.Name = "pm_search";
CreateSearchScheme();
}
DataTable rightDt = null;
if (dynamicModel != null)
DataTable rightDt = MrpClickMenus;
if (rightDt == null && dynamicModel != null)
{
if (!dynamicModel.DataCaches.GetValue(this, "RightDtGridRightMenus", out rightDt))
{
rightDt = BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}
MrpClickMenus = rightDt;
}
if (rightDt != null && rightDt.Rows.Count > 0)
{
@@ -1313,10 +1332,13 @@ namespace Lskj.Control.Model
return controlModel;
}));
}
Task<DataTable> rightDtGridRightMenusTask = cachesDic.AddTask(this, "RightDtGridRightMenus", new Task<DataTable>(() =>
if (MrpClickMenus == null)
{
return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}));
Task<DataTable> rightDtGridRightMenusTask = cachesDic.AddTask(this, "RightDtGridRightMenus", new Task<DataTable>(() =>
{
return BaseModuleImpl.GetBaseGridRightMenus(dynamicModel.ModuleCode, ModuleType.MrpClickBtn);
}));
}
return true;
}));
}