DepartmentProject/DepartmentPortal/Security/SecurityWindowsDesktop/SecurityWindowDesktopExtension.cs

64 lines
1.9 KiB
C#
Raw Normal View History

using DesktopTools.Controls;
using DesktopTools.Interfaces;
using DesktopTools.Models;
using ModuleTools.BindingModels;
using ModuleTools.BusinessLogics;
using ModuleTools.Enums;
using ModuleTools.Interfaces;
using ModuleTools.Models;
using SecurityWindowsDesktop.Controls;
using System.Collections.Generic;
namespace SecurityWindowsDesktop
{
public class SecurityWindowDesktopExtension : IWindowDesktopExtension
{
public List<WindowDesktopExtensionControlModel> GetListControlEntityList()
{
var manager = DependencyManager.Instance.Resolve<ISecurityManager>();
if (manager == null)
{
return null;
}
if (!manager.CheckAccess(new SecurityManagerCheckAccessModel(new AccessBindingModel { UserId = manager.User },
2021-03-28 19:58:42 +04:00
AccessOperation.Администрирование, AccessType.View, "Администрирование")))
{
return null;
}
var list = new List<WindowDesktopExtensionControlModel>
{
new WindowDesktopExtensionControlModel { Order = 0, Title = "Администрирование" }
};
2021-03-30 22:34:31 +04:00
List<AbstractControlViewEntityList> _controls = new()
{
new UsersControl(),
new RolesControl(),
new AccessesControl(),
new EnviromentSettingControl()
};
foreach (var cntrl in _controls)
{
if (manager.CheckAccess(new SecurityManagerCheckAccessModel(new AccessBindingModel { UserId = manager.User },
2021-03-28 19:58:42 +04:00
cntrl.AccessOperation, AccessType.View, cntrl.Title)))
{
list.Add(new WindowDesktopExtensionControlModel
{
Id = cntrl.ControlId,
Order = cntrl.Order,
Title = cntrl.Title,
Control = cntrl
});
}
}
2021-03-30 22:34:31 +04:00
DependencyManager.Instance.RegisterType<UsersControl>();
DependencyManager.Instance.RegisterType<RolesControl>();
DependencyManager.Instance.RegisterType<AccessesControl>();
DependencyManager.Instance.RegisterType<EnviromentSettingControl>();
return list;
}
}
}