static void userSecurityExcelDocumentnew(Args _args)
{
SysExcelWorksheetHelper worksheetHelper;
SysExcelHelper sysExcelHelper;
SysExcelWorkSheet xlsWorkSheet;
dialogField dialogFilename;
Dialog dialog;
SecurityUserRole _SecurityUserRole;
SecurityRoleTaskGrant _SecurityRoleTaskGrant;
SecurityTask _SecurityTask;
SecurityRole _SecurityRole;
UserInfo _UserInfo;
SysUserInfo _sysUserInfo;
FilenameOpen filename;
str worksheetName;
int row = 1;
SysOperationProgress Progressbar = new SysOperationProgress();
#Excel
;
startLengthyOperation();
dialog = new Dialog("Excel Upoad");
dialogFilename = dialog.addField(extendedTypeStr(FilenameOpen));
dialog.filenameLookupFilter(["@SYS28576",#XLS,"@SYS28576",#XLSX]);
dialog.filenameLookupTitle("Export to Excel");
dialog.caption("User Security details");
dialogFilename.value(filename);
if(!dialog.run())
return;
filename = dialogFilename.value();
worksheetName = strfmt("%1", date2str(systemdateget(),321,DateDay::Digits2,DateSeparator::None,DateMonth::Digits2,DateSeparator::None,DateYear::Digits4, DateFlags::None));
sysExcelHelper = SysExcelHelper::construct();
sysExcelHelper.initialize();
xlsWorkSheet = sysExcelHelper.addWorksheet(worksheetName);
worksheetHelper = SysExcelWorksheetHelper::construct(xlsWorkSheet);
worksheetHelper.addColumn(1, 'User Id', Types::String);
worksheetHelper.addColumn(2, 'User Name', Types::String);
worksheetHelper.addColumn(3, 'User Role', Types::String);
worksheetHelper.addColumn(4, 'Department', Types::String);
worksheetHelper.addColumn(5, 'Active', Types::String);
worksheetHelper.addColumn(6, 'Legal Entity', Types::String);
worksheetHelper.addColumn(7, 'Created Date Time', Types::Date);
worksheetHelper.addColumn(8, 'Modified Date Time', Types::Date);
worksheetHelper.setCellValue(1, row,'User Id');
worksheetHelper.setCellValue(2, row,'User Name');
worksheetHelper.setCellValue(3, row,'User Role');
worksheetHelper.setCellValue(4, row,'Department');
worksheetHelper.setCellValue(5, row,'Active');
worksheetHelper.setCellValue(6, row,'Legal Entity');
worksheetHelper.setCellValue(7, row,'Created Date Time');
worksheetHelper.setCellValue(8, row,'Modified Date Time');
row++;
while select _UserInfo
{
select _sysUserInfo where _sysUserInfo.Id == _UserInfo.id;
while select _SecurityUserRole where _SecurityUserRole.User==_UserInfo.id
{
while select _SecurityRole where _SecurityRole.RecId==_SecurityUserRole.SecurityRole
{
worksheetHelper.setCellValue(1, row,_UserInfo.id);
worksheetHelper.setCellValue(2, row,_UserInfo.name);
worksheetHelper.setCellValue(3, row,_SecurityRole.name);
worksheetHelper.setCellValue(4, row,_sysUserInfo.departmentName());
worksheetHelper.setCellValue(5, row,_UserInfo.enable);
worksheetHelper.setCellValue(6, row,_UserInfo.company);
worksheetHelper.setCellValue(7, row,_sysUserInfo.createdDateTime);
worksheetHelper.setCellValue(8, row,_sysUserInfo.modifiedDateTime);
row++;
}
}
}
if(WinApi::fileExists(fileName))
WinApi::deleteFile(fileName);
sysExcelHelper.save(filename);
sysExcelHelper.close();
info(strFmt("Created file: %1", fileName));
}
{
SysExcelWorksheetHelper worksheetHelper;
SysExcelHelper sysExcelHelper;
SysExcelWorkSheet xlsWorkSheet;
dialogField dialogFilename;
Dialog dialog;
SecurityUserRole _SecurityUserRole;
SecurityRoleTaskGrant _SecurityRoleTaskGrant;
SecurityTask _SecurityTask;
SecurityRole _SecurityRole;
UserInfo _UserInfo;
SysUserInfo _sysUserInfo;
FilenameOpen filename;
str worksheetName;
int row = 1;
SysOperationProgress Progressbar = new SysOperationProgress();
#Excel
;
startLengthyOperation();
dialog = new Dialog("Excel Upoad");
dialogFilename = dialog.addField(extendedTypeStr(FilenameOpen));
dialog.filenameLookupFilter(["@SYS28576",#XLS,"@SYS28576",#XLSX]);
dialog.filenameLookupTitle("Export to Excel");
dialog.caption("User Security details");
dialogFilename.value(filename);
if(!dialog.run())
return;
filename = dialogFilename.value();
worksheetName = strfmt("%1", date2str(systemdateget(),321,DateDay::Digits2,DateSeparator::None,DateMonth::Digits2,DateSeparator::None,DateYear::Digits4, DateFlags::None));
sysExcelHelper = SysExcelHelper::construct();
sysExcelHelper.initialize();
xlsWorkSheet = sysExcelHelper.addWorksheet(worksheetName);
worksheetHelper = SysExcelWorksheetHelper::construct(xlsWorkSheet);
worksheetHelper.addColumn(1, 'User Id', Types::String);
worksheetHelper.addColumn(2, 'User Name', Types::String);
worksheetHelper.addColumn(3, 'User Role', Types::String);
worksheetHelper.addColumn(4, 'Department', Types::String);
worksheetHelper.addColumn(5, 'Active', Types::String);
worksheetHelper.addColumn(6, 'Legal Entity', Types::String);
worksheetHelper.addColumn(7, 'Created Date Time', Types::Date);
worksheetHelper.addColumn(8, 'Modified Date Time', Types::Date);
worksheetHelper.setCellValue(1, row,'User Id');
worksheetHelper.setCellValue(2, row,'User Name');
worksheetHelper.setCellValue(3, row,'User Role');
worksheetHelper.setCellValue(4, row,'Department');
worksheetHelper.setCellValue(5, row,'Active');
worksheetHelper.setCellValue(6, row,'Legal Entity');
worksheetHelper.setCellValue(7, row,'Created Date Time');
worksheetHelper.setCellValue(8, row,'Modified Date Time');
row++;
while select _UserInfo
{
select _sysUserInfo where _sysUserInfo.Id == _UserInfo.id;
while select _SecurityUserRole where _SecurityUserRole.User==_UserInfo.id
{
while select _SecurityRole where _SecurityRole.RecId==_SecurityUserRole.SecurityRole
{
worksheetHelper.setCellValue(1, row,_UserInfo.id);
worksheetHelper.setCellValue(2, row,_UserInfo.name);
worksheetHelper.setCellValue(3, row,_SecurityRole.name);
worksheetHelper.setCellValue(4, row,_sysUserInfo.departmentName());
worksheetHelper.setCellValue(5, row,_UserInfo.enable);
worksheetHelper.setCellValue(6, row,_UserInfo.company);
worksheetHelper.setCellValue(7, row,_sysUserInfo.createdDateTime);
worksheetHelper.setCellValue(8, row,_sysUserInfo.modifiedDateTime);
row++;
}
}
}
if(WinApi::fileExists(fileName))
WinApi::deleteFile(fileName);
sysExcelHelper.save(filename);
sysExcelHelper.close();
info(strFmt("Created file: %1", fileName));
}