fix: 收敛旧模块资源释放与诊断
This commit is contained in:
@@ -48,6 +48,55 @@ namespace Lskj.PubAccraditation
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void ReleaseResourcesForDispose()
|
||||
{
|
||||
if (mResourcesReleased)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
mResourcesReleased = true;
|
||||
PrintUtil.OnAfterPrint -= OnReportPrintAfter;
|
||||
|
||||
MyControl control = ControlObj;
|
||||
ControlObj = null;
|
||||
if (control != null)
|
||||
{
|
||||
control.OnDataSourceBindCallBack -=
|
||||
OnControlObjOnDataSourceBindCallBack;
|
||||
control.OnDataFileRefrshCallBack -= OnDataFileRefrshFile;
|
||||
control.Dispose();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (gridBillInfo != null)
|
||||
{
|
||||
TreeGridControlEx treeGrid =
|
||||
gridBillInfo as TreeGridControlEx;
|
||||
if (treeGrid != null)
|
||||
{
|
||||
treeGrid.OnDataSourceBindCallBack -=
|
||||
OnGridBillInfoOnDataSourceBindCallBack;
|
||||
}
|
||||
else
|
||||
{
|
||||
gridBillInfo.OnDataSourceBindCallBack -=
|
||||
OnGridBillInfoOnDataSourceBindCallBack;
|
||||
}
|
||||
gridBillInfo.ParentControl = null;
|
||||
}
|
||||
if (SysModel != null && SysModel.DataCaches != null)
|
||||
{
|
||||
SysModel.DataCaches.Remove(this);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
// A partially disposed child must not stop form cleanup.
|
||||
}
|
||||
}
|
||||
#region 公有变量
|
||||
|
||||
/// <summary>
|
||||
@@ -70,6 +119,7 @@ namespace Lskj.PubAccraditation
|
||||
/// 主表控件
|
||||
/// </summary>
|
||||
public MyControl ControlObj;
|
||||
private bool mResourcesReleased;
|
||||
/// <summary>
|
||||
/// 是否是Brp模块加载审核明细
|
||||
/// </summary>
|
||||
@@ -385,16 +435,6 @@ namespace Lskj.PubAccraditation
|
||||
{
|
||||
return BaseModuleImpl.GetControlLocation(billAuditModelTask.Result.FormKey, dynamicModel.ModuleCode);
|
||||
}));
|
||||
Task<MyControl> controlObjTask = cachesDic.AddTask(this, "ControlObj", new Task<MyControl>(() =>
|
||||
{
|
||||
MyControl myControl = new MyControl();
|
||||
myControl.Model = SysModel;
|
||||
myControl.PrimaryValue = dynamicModel.BillDocumentId;
|
||||
cachesDic.AddTask(myControl, "DynamicModel", dynamicModelTask);
|
||||
cachesDic.AddTask(myControl, "ControlsTable", controlLocationTask);
|
||||
myControl.GetControlDataCaches(cachesDic);
|
||||
return myControl;
|
||||
}));
|
||||
Task<DataTable> detailColumnsTask = cachesDic.AddTask(gridBillInfo, "DetailColumns", new Task<DataTable>(() =>
|
||||
{
|
||||
return BillImpl.GetDetailColumns(dynamicModel.ModuleCode);
|
||||
@@ -980,14 +1020,26 @@ namespace Lskj.PubAccraditation
|
||||
{
|
||||
Dictionary<object, Hashtable> dataCaches = SysModel != null ? SysModel.DataCaches : null;
|
||||
// 初始化表头
|
||||
bool controlCreated = false;
|
||||
if (!dataCaches.GetValue(this, "ControlObj", out this.ControlObj))
|
||||
{
|
||||
this.ControlObj = new MyControl();
|
||||
controlCreated = true;
|
||||
}
|
||||
if (!dataCaches.GetValue(this, "ControlLocation", out DataTable dtControlLocation))
|
||||
{
|
||||
dtControlLocation = BaseModuleImpl.GetControlLocation(this.BillModelObj.FormKey, this.SysModel.ModuleCode);
|
||||
}
|
||||
if (controlCreated && dataCaches != null)
|
||||
{
|
||||
DynamicModel controlModel = SysModel;
|
||||
DataTable controlsTable = dtControlLocation;
|
||||
dataCaches.AddTask(ControlObj, "DynamicModel",
|
||||
new Task<DynamicModel>(() => controlModel));
|
||||
dataCaches.AddTask(ControlObj, "ControlsTable",
|
||||
new Task<DataTable>(() => controlsTable));
|
||||
ControlObj.GetControlDataCaches(dataCaches);
|
||||
}
|
||||
this.ControlObj.PrimaryValue = this.SysModel.BillDocumentId;
|
||||
this.ControlObj.isAuditMain = true;
|
||||
this.ControlObj.InitControl(dtControlLocation, this.pl_left_top);
|
||||
|
||||
Reference in New Issue
Block a user