static void getallrolesrespectdutiesandprivileges(Args _args)
{
SecurityTaskEntryPoint taskEntryPoint;
SecurityRole role;
SecurityRoleTaskGrant taskGrant;
SecuritySubTask subTask;
SecurityTask privilege;
SecurityTask securityTask;
SecurableObject securableObject;
DictEnum dictEnum;
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
SysExcelCell cell;
int row;
str privAOTName;
str dutyAOTName;
str privName;
str dutyName;
str entrName;
str accessLevel;
str menuItemType;
FromTime startTime = timeNow();
// EXCEL Header
application = SysExcelApplication::construct();
workbooks = application.workbooks();
workbook = workbooks.add();
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum(1);
cells = worksheet.cells();
cells.range('A:A').numberFormat('@');
cell = cells.item(1,1);
cell.value("Role AOT name");
cell = cells.item(1,2);
cell.value("Description");
cell = cells.item(1,3);
cell.value("Duty AOT name");
cell = cells.item(1,4);
cell.value("Description");
cell = cells.item(1,5);
cell.value("Privilidge AOT name");
cell = cells.item(1,6);
cell.value("Description");
cell = cells.item(1,7);
cell.value("Entry Point");
cell = cells.item(1,8);
cell.value("Type");
cell = cells.item(1,9);
cell.value("Access level");
row = 1;
while select taskEntryPoint
join subTask
where subTask.SecuritySubTask == taskEntryPoint.SecurityTask
join taskGrant
where taskGrant.SecurityTask == subTask.SecurityTask
join role
where role.RecId == taskGrant.SecurityRole
{
menuItemType = "";
dutyAOTName = "";
dutyName = "";
privAOTName = "";
privName = "";
if (subTask.RecId)
{
switch (taskEntryPoint.PermissionGroup)
{
case AccessRight::View:
accessLevel = "Read";
break;
case AccessRight::Edit:
accessLevel = "Update";
break;
case AccessRight::Add:
accessLevel = "Create";
break;
case AccessRight::Delete:
accessLevel = "Delete";
break;
default:
accessLevel = "";
break;
}
}
select privilege
where privilege.RecId == taskGrant.SecurityTask
&& SecurityTaskType::Duty == privilege.Type;
dutyAOTName = privilege.AotName;
dutyName = privilege.Name;
select privilege
where privilege.RecId == subTask.SecuritySubTask
&& SecurityTaskType::Privilege == privilege.Type;
privAOTName = privilege.AotName;
privName = privilege.Name;
select RecId, Type, Name from securableObject
where securableObject.RecId == taskEntryPoint.EntryPoint && (securableObject.Type == SecurableType::MenuItemDisplay
|| securableObject.Type == SecurableType::MenuItemAction || securableObject.Type == SecurableType::MenuItemOutput);
dictEnum = new DictEnum(enumNum(MenuItemType));
menuItemType = dictEnum.index2Name(securableObject.Type);
row++;
cell = cells.item(row, 1);
cell.value(role.AotName);
cell = cells.item(row, 2);
cell.value(role.Name);
cell = cells.item(row, 3);
cell.value(dutyAOTName);
cell = cells.item(row, 4);
cell.value(dutyName);
cell = cells.item(row, 5);
cell.value(privAOTName);
cell = cells.item(row, 6);
cell.value(privName);
cell = cells.item(row, 7);
cell.value(securableObject.Name);
cell = cells.item(row, 8);
cell.value(menuItemType);
cell = cells.item(row, 9);
cell.value(accessLevel);
}
while select SecurityTask, SecurityRole from taskGrant
join RecId, Type, AOTName from securitytask where securityTask.RecId == taskGrant.SecurityTask
&& taskGrant.SecurityRole == taskGrant.SecurityRole
&& securitytask.Type == SecurityTaskType::Privilege
join securityTask, EntryPoint from taskEntryPoint
where taskEntryPoint.SecurityTask == securitytask.RecId
{
menuItemType = "";
dutyAOTName = "";
dutyName = "";
privAOTName = "";
privName = "";
select RecId, Type, Name from securableObject
where securableObject.RecId == taskEntryPoint.EntryPoint &&
(securableObject.Type == SecurableType::MenuItemDisplay || securableObject.Type == SecurableType::MenuItemAction
|| securableObject.Type == SecurableType::MenuItemOutput);
if(securableObject)
{
select privilege where privilege.RecId == securityTask.RecId
&& SecurityTaskType::Privilege == privilege.Type;
privAOTName = privilege.AotName;
privName = privilege.Name;
dictEnum = new DictEnum(enumNum(MenuItemType));
menuItemType = dictEnum.index2Name(securableObject.Type);
row++;
cell = cells.item(row, 1);
cell.value(role.AotName);
cell = cells.item(row, 2);
cell.value(role.Name);
cell = cells.item(row, 3);
cell.value(dutyAOTName);
cell = cells.item(row, 4);
cell.value(dutyName);
cell = cells.item(row, 5);
cell.value(privAOTName);
cell = cells.item(row, 6);
cell.value(privName);
cell = cells.item(row, 7);
cell.value(securableObject.Name);
cell = cells.item(row, 8);
cell.value(menuItemType);
cell = cells.item(row, 9);
cell.value(accessLevel);
}
}
CodeAccessPermission::revertAssert();
info(strFmt("Total time: %1", timeConsumed(startTime, timeNow())));
}
Subscribe to:
Post Comments (Atom)
Create number sequence in D365 FO
Create the data type. Add code in the loadModule method of the appropriate NumberSeqModule subclass. Add a method to the module’s paramet...
-
Dialogbutton dialogButtonConfirm; ; dialogButtonConfirm = Box::yesNo("continue ", dialogButton::Yes, ...
-
Breakpoints Command Shortcut key Remove all breakpoints. CTRL+SHIFT+F9 I...
-
Just use the below code to remove the special character from the string. strRem('String','*'); You can replace * with...
No comments:
Post a Comment