MH: UserExport als Druck

This commit is contained in:
2023-09-20 16:51:35 +02:00
parent cd850f685a
commit dcac29135a
5 changed files with 75 additions and 1 deletions

View File

@@ -17,6 +17,7 @@
DeleteDemands="DeleteAll, UserView_Delete"
CreateDemands="CreateAll, UserView_Create"
ExcelExport="mainNavigationView_ExcelExport"
Print="mainNavigationView_Print"
ContentGroupStyle="{StaticResource UserNavigationStyle}"
MainListItemStyle="{StaticResource SearchDetailStyle}"
HistoryListItemStyle="{StaticResource SearchSimpleStyle}"

View File

@@ -118,7 +118,18 @@ namespace BeWo.View.Navigation
ServiceFacade.DoDownloadServiceSync(s => BeWoUtils.WriteExcelFile(s.PrepareExcelFileUserExport(mainNavigationView.DownloadLinkEngine.ExcelFileId, e.Data.Cast<CompactUserDC>().Select(c => c.UserOid).ToList()), sf.FileName));
}
private void mainNavigationView_Print(object sender, EventArgs<IEnumerable<IFilterableDC>> e)
{
var oids = e.Data.Cast<CompactUserDC>().Select(c => c.UserOid).ToList();
ServiceFacade.DoReportServiceAsync(s => s.CreateUserListReport(oids), r =>
{
this.Dispatch(() =>
{
BeWoUtils.ShowReportWindow(r, "Benutzer");
});
});
}
private void mainNavigationView_OpenObject(IFilterableDC obj)
{
CompactUserDC dc = obj as CompactUserDC;

View File

@@ -111,6 +111,8 @@ namespace BeWo.Report
public abstract XtraReport CreatePersonListReport(List<long> oids);
public abstract XtraReport CreateUserListReport(List<long> oids);
public abstract XtraReport CreateUserGroupListReport(List<long> oids);
}
}

View File

@@ -1251,6 +1251,65 @@ namespace BeWo.Report
return report as XtraReport;
}
public override XtraReport CreateUserListReport(List<long> oids)
{
var queryReport = FindReportImp<QueryRO>(null, "Benutzergruppen");
var lUser = DAOFactory.GenericDAO.LoadByIDs<ApplicationUser>(oids);
string[] lHeaderCaption = {
"Mitarbeiter", // 0
"Login", // 1
"zugeordnete Benutzergruppen", // 2
};
string[][] lContent = new string[lUser.Count][];
for (int iRowCount = 0; iRowCount < lUser.Count; iRowCount++)
{
lContent[iRowCount] = new string[lHeaderCaption.Count()];
if (lUser[iRowCount].Employee != null)
lContent[iRowCount][0] = lUser[iRowCount].Employee.Person.FirstNameLastName;
else
lContent[iRowCount][0] = string.Empty;
if (lUser[iRowCount].LoginName != null)
lContent[iRowCount][1] = lUser[iRowCount].LoginName;
else
lContent[iRowCount][1] = string.Empty;
if (lUser[iRowCount].UserGroups != null && lUser[iRowCount].UserGroups.Count > 0)
lContent[iRowCount][2] = string.Join(", ", lUser[iRowCount].UserGroups.Select(
r => r.Name).OrderBy(s => s).ToArray());
else
lContent[iRowCount][2] = string.Empty;
}
// Zweidimensionales Array zu DataTable konvertieren
DataTable table = new DataTable();
int columnNumber = 3;
for (int i = 0; i < columnNumber; i++)
table.Columns.Add(lHeaderCaption[i], typeof(string));
int rowNumber = lContent.GetLength(0);
for (int i = 0; i < rowNumber; i++)
{
DataRow row = table.NewRow();
for (int j = 0; j < columnNumber; j++)
{
row[j] = lContent[i][j];
}
table.Rows.Add(row);
}
var queryReportObject = QueryRO.Create(new Query() { Title = "Benutzer" }, table);
queryReportObject.Name = "Benutzer";
queryReport.SetReportDataSource(queryReportObject);
return queryReport as XtraReport;
}
public override XtraReport CreateUserGroupListReport(List<long> oids)
{
var queryReport = FindReportImp<QueryRO>(null, "Benutzergruppen");

View File

@@ -372,7 +372,8 @@ namespace ReportingService.ServiceImplementations
public MemoryStream CreateUserListReport(List<long> oids)
{
return null;
var reportCreator = GetReportCreator();
return CreateReportStream(reportCreator.CreateUserListReport(oids));
}
public MemoryStream CreateUserGroupListReport(List<long> oids)