diff --git a/BeWo/View/Navigation/UserNavigationView.xaml b/BeWo/View/Navigation/UserNavigationView.xaml index 4e0e72fbe..dfec57879 100644 --- a/BeWo/View/Navigation/UserNavigationView.xaml +++ b/BeWo/View/Navigation/UserNavigationView.xaml @@ -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}" diff --git a/BeWo/View/Navigation/UserNavigationView.xaml.cs b/BeWo/View/Navigation/UserNavigationView.xaml.cs index d737afd06..3b664a537 100644 --- a/BeWo/View/Navigation/UserNavigationView.xaml.cs +++ b/BeWo/View/Navigation/UserNavigationView.xaml.cs @@ -118,7 +118,18 @@ namespace BeWo.View.Navigation ServiceFacade.DoDownloadServiceSync(s => BeWoUtils.WriteExcelFile(s.PrepareExcelFileUserExport(mainNavigationView.DownloadLinkEngine.ExcelFileId, e.Data.Cast().Select(c => c.UserOid).ToList()), sf.FileName)); } + private void mainNavigationView_Print(object sender, EventArgs> e) + { + var oids = e.Data.Cast().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; diff --git a/Report/AbstractReportCreator.cs b/Report/AbstractReportCreator.cs index ae0c7362c..7b6f2ca88 100644 --- a/Report/AbstractReportCreator.cs +++ b/Report/AbstractReportCreator.cs @@ -111,6 +111,8 @@ namespace BeWo.Report public abstract XtraReport CreatePersonListReport(List oids); + public abstract XtraReport CreateUserListReport(List oids); + public abstract XtraReport CreateUserGroupListReport(List oids); } } \ No newline at end of file diff --git a/Report/DefaultReportCreator.cs b/Report/DefaultReportCreator.cs index 6c8e4a5b2..ce7809e85 100644 --- a/Report/DefaultReportCreator.cs +++ b/Report/DefaultReportCreator.cs @@ -1251,6 +1251,65 @@ namespace BeWo.Report return report as XtraReport; } + public override XtraReport CreateUserListReport(List oids) + { + var queryReport = FindReportImp(null, "Benutzergruppen"); + + var lUser = DAOFactory.GenericDAO.LoadByIDs(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 oids) { var queryReport = FindReportImp(null, "Benutzergruppen"); diff --git a/ReportService/ServiceImplementations/ReportServiceImp.cs b/ReportService/ServiceImplementations/ReportServiceImp.cs index f0b794bd2..7bf48a095 100644 --- a/ReportService/ServiceImplementations/ReportServiceImp.cs +++ b/ReportService/ServiceImplementations/ReportServiceImp.cs @@ -372,7 +372,8 @@ namespace ReportingService.ServiceImplementations public MemoryStream CreateUserListReport(List oids) { - return null; + var reportCreator = GetReportCreator(); + return CreateReportStream(reportCreator.CreateUserListReport(oids)); } public MemoryStream CreateUserGroupListReport(List oids)