DepartmentProject/DepartmentPortal/Security/SecurityWindowsDesktop/SecurityWindowDesktopExtension.cs

60 lines
1.6 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 },
AccessOperation.Администрирование, AccessType.View, "Администрирование")))
{
return null;
}
var list = new List<WindowDesktopExtensionControlModel>
{
new WindowDesktopExtensionControlModel { Order = 0, Title = "Администрирование" }
};
List<ControlViewEntityList> _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 },
cntrl.AccessOperation, AccessType.View, cntrl.Title)))
{
list.Add(new WindowDesktopExtensionControlModel
{
Id = cntrl.Id,
Order = cntrl.Order,
Title = cntrl.Title,
Control = cntrl
});
}
}
return list;
}
}
}