DepartmentProject/DepartmentPortal/Security/SecurityWindowsDesktop/SecurityWindowDesktopExtension.cs

100 lines
2.8 KiB
C#
Raw Normal View History

using SecurityWindowsDesktop.EntityControls;
using SecurityWindowsDesktop.SpecialControls;
using System.Collections.Generic;
using ToolsDesktop.Interfaces;
2022-03-18 22:48:14 +04:00
using ToolsDesktop.Models;
using ToolsModule.BindingModels;
using ToolsModule.DependencyManagment;
using ToolsModule.Enums;
using ToolsModule.Interfaces;
using ToolsModule.Models;
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 { UserIdForAccess = manager.User },
2021-03-28 19:58:42 +04:00
AccessOperation.Администрирование, AccessType.View, "Администрирование")))
{
return null;
}
var list = new List<WindowDesktopExtensionControlModel>
{
new WindowDesktopExtensionControlModel { Title = "Администрирование" }
};
List<IControl> _controls = new()
{
new ControlUserList(),
new ControlRoleList(),
new ControlAccessList(),
new ControlEnviromentSettingList()
};
foreach (var cntrl in _controls)
{
if (manager.CheckAccess(new SecurityManagerCheckAccessModel(new AccessBindingModel { UserIdForAccess = manager.User },
2021-03-28 19:58:42 +04:00
cntrl.AccessOperation, AccessType.View, cntrl.Title)))
{
list.Add(new WindowDesktopExtensionControlModel
{
Id = cntrl.ControlId,
Title = cntrl.Title,
Control = cntrl
});
}
}
return list;
}
2021-04-02 15:53:15 +04:00
public List<WindowDesktopExtensionControlModel> GetListControlSpecialList()
{
var manager = DependencyManager.Instance.Resolve<ISecurityManager>();
if (manager == null)
{
return null;
}
if (!manager.CheckAccess(new SecurityManagerCheckAccessModel(new AccessBindingModel { UserIdForAccess = manager.User },
AccessOperation.Администрирование, AccessType.View, "Администрирование")))
{
return null;
}
var list = new List<WindowDesktopExtensionControlModel>
{
new WindowDesktopExtensionControlModel { Title = "Администрирование" }
};
List<IControl> _controls = new()
{
new BackupControl(),
new SynchronizationControl()
2021-04-02 15:53:15 +04:00
};
foreach (var cntrl in _controls)
{
if (manager.CheckAccess(new SecurityManagerCheckAccessModel(new AccessBindingModel { UserIdForAccess = manager.User },
cntrl.AccessOperation, AccessType.View, cntrl.Title)))
{
list.Add(new WindowDesktopExtensionControlModel
{
Id = cntrl.ControlId,
Title = cntrl.Title,
Control = cntrl
});
}
}
return list;
}
}
}