优化模块资源释放与异步预加载
This commit is contained in:
@@ -1330,14 +1330,45 @@ namespace Lskj.Control.Model
|
||||
SmartX1Api.SmartX1Close(keyHandle);
|
||||
}
|
||||
}
|
||||
IForm form = FormHelper.LoadDllForm(dllName, str);
|
||||
string guid = isAddPage ? Guid.NewGuid().ToString() : null;
|
||||
StaticControl.ModuleResourceScope moduleScope = null;
|
||||
XtraTabPage modulePage = null;
|
||||
if (isAddPage)
|
||||
{
|
||||
modulePage = new XtraTabPage();
|
||||
modulePage.Tag = guid;
|
||||
moduleScope = new StaticControl.ModuleResourceScope(guid);
|
||||
StaticControl.AttachModuleScope(modulePage, moduleScope);
|
||||
moduleScope.Register(modulePage, () =>
|
||||
{
|
||||
if (!modulePage.IsDisposed)
|
||||
modulePage.Dispose();
|
||||
});
|
||||
}
|
||||
|
||||
IForm form;
|
||||
if (moduleScope == null)
|
||||
{
|
||||
form = FormHelper.LoadDllForm(dllName, str);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (StaticControl.PushModuleScope(moduleScope))
|
||||
{
|
||||
form = FormHelper.LoadDllForm(dllName, str);
|
||||
}
|
||||
}
|
||||
if (form == null)
|
||||
{
|
||||
if (moduleScope != null)
|
||||
moduleScope.Dispose();
|
||||
MessageUtil.Show(ResourceKeys.DyncmicDllNotFount);
|
||||
return false;
|
||||
}
|
||||
if (form.SubForm == null)
|
||||
{
|
||||
if (moduleScope != null)
|
||||
moduleScope.Dispose();
|
||||
MessageUtil.Show(ResourceKeys.DyncmicDllInitFault);
|
||||
return false;
|
||||
}
|
||||
@@ -1356,7 +1387,7 @@ namespace Lskj.Control.Model
|
||||
form.SubForm.Text = model.MenuName;
|
||||
if (isPrivateDll)
|
||||
{
|
||||
StaticControl.DogVerifyNoPageForms.Add(form);
|
||||
StaticControl.RegisterProtectedForm(form);
|
||||
}
|
||||
if (form.SubForm is BaseForm)//dllName.Equals("Lskj.BaseAccraditation.dll", StringComparison.OrdinalIgnoreCase)
|
||||
{
|
||||
@@ -1384,8 +1415,7 @@ namespace Lskj.Control.Model
|
||||
}
|
||||
else
|
||||
{
|
||||
string guid = Guid.NewGuid().ToString();
|
||||
XtraTabPage tp = new XtraTabPage();
|
||||
XtraTabPage tp = modulePage;
|
||||
tp.Text = model.MenuName;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(model.PageName))
|
||||
@@ -1403,6 +1433,7 @@ namespace Lskj.Control.Model
|
||||
tp.Controls.Add(form.SubForm);
|
||||
tp.ShowCloseButton = DefaultBoolean.True;
|
||||
tp.Dock = DockStyle.Fill;
|
||||
StaticControl.RegisterModulePage(module, tp, form.SubForm);
|
||||
//配置了右键刷新的情况下,在当前页签关闭时触发刷新
|
||||
if (model.Refresh && this.OnRightCallback != null)
|
||||
{
|
||||
@@ -1412,13 +1443,16 @@ namespace Lskj.Control.Model
|
||||
ERPInfo.Instance.CurrentModulePage = tp;
|
||||
if (isPrivateDll)
|
||||
{
|
||||
StaticControl.DogVerifyModuleForms.Add(tp);
|
||||
StaticControl.RegisterProtectedPage(tp);
|
||||
}
|
||||
if (form.SubForm is BaseForm)
|
||||
{
|
||||
(form.SubForm as BaseForm).ParentView = this.BaseGridView;
|
||||
}
|
||||
form.SubForm.Show();
|
||||
using (StaticControl.PushModuleScope(moduleScope))
|
||||
{
|
||||
form.SubForm.Show();
|
||||
}
|
||||
ERPInfo.Instance.ModuleForms.Add(guid, module);
|
||||
//直接页签打开模块会直接向后面运行,默认返回false避免外面执行右键刷新
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user