diff --git a/BeWo/View/Navigation/TeamNavigationView.xaml b/BeWo/View/Navigation/TeamNavigationView.xaml index 0c36f66bc..450047c00 100644 --- a/BeWo/View/Navigation/TeamNavigationView.xaml +++ b/BeWo/View/Navigation/TeamNavigationView.xaml @@ -13,6 +13,7 @@ DeleteDemands="DeleteAll, TeamView_Delete" CreateDemands="CreateAll, TeamView_Create" ExcelExport="mainNavigationView_ExcelExport" + Print="mainNavigationView_Print" ContentGroupStyle="{StaticResource TeamNavigationStyle}" MainListItemStyle="{StaticResource SearchDetailStyle}" HistoryListItemStyle="{StaticResource SearchSimpleStyle}" diff --git a/BeWo/View/Navigation/TeamNavigationView.xaml.cs b/BeWo/View/Navigation/TeamNavigationView.xaml.cs index d80992d4b..4227cd717 100644 --- a/BeWo/View/Navigation/TeamNavigationView.xaml.cs +++ b/BeWo/View/Navigation/TeamNavigationView.xaml.cs @@ -14,7 +14,7 @@ using BS.Shared.Core; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using BS.Shared.Extensions; - +using BS.Shared.Translation; using Microsoft.Win32; namespace BeWo.View.Navigation @@ -72,6 +72,19 @@ namespace BeWo.View.Navigation ServiceFacade.DoDownloadServiceSync(s => BeWoUtils.WriteExcelFile(s.PrepareExcelFileTeamExport(mainNavigationView.DownloadLinkEngine.ExcelFileId, e.Data.Cast().Select(c => c.TeamOid).ToList()), sf.FileName)); } + private void mainNavigationView_Print(object sender, EventArgs> e) + { + var oids = e.Data.Cast().Select(c => c.TeamOid).ToList(); + + ServiceFacade.DoReportServiceAsync(s => s.CreateTeamListReport(oids), r => + { + this.Dispatch(() => + { + BeWoUtils.ShowReportWindow(r, Translator.Translate("Teams")); + }); + }); + } + private void mainNavigationView_OpenObject(IFilterableDC obj) { if (obj is CompactTeamDC dc) diff --git a/Report/AbstractReportCreator.cs b/Report/AbstractReportCreator.cs index 7bdb35cc2..e2067e6ca 100644 --- a/Report/AbstractReportCreator.cs +++ b/Report/AbstractReportCreator.cs @@ -115,6 +115,8 @@ namespace BeWo.Report public abstract XtraReport CreateEmployeeListReport(List oids); + public abstract XtraReport CreateTeamListReport(List oids); + public abstract XtraReport CreateUserListReport(List oids); public abstract XtraReport CreateUserGroupListReport(List oids); diff --git a/Report/DefaultReportCreator.cs b/Report/DefaultReportCreator.cs index 86ae8db6a..4b8bda47e 100644 --- a/Report/DefaultReportCreator.cs +++ b/Report/DefaultReportCreator.cs @@ -1430,6 +1430,47 @@ namespace BeWo.Report return report as XtraReport; } + public override XtraReport CreateTeamListReport(List oids) + { + var queryReport = FindReportImp(null, "Teams"); + var teams = DAOFactory.GenericDAO.LoadByIDs(oids); + + DataTable table = new DataTable(); + string[] spalten = new string[] { "Name", "Leitung", "Notiz", "Mitglieder" }; + for (int i = 0; i < spalten.Length; i++) + table.Columns.Add(spalten[i], typeof(string)); + + for (int i = 0; i < teams.Count; i++) + { + DataRow row = table.NewRow(); + Team team = teams[i]; + row[0] = team.Name; + row[1] = team.Leader; + row[2] = team.Notice; + String mitglieder = ""; + + IOrderedEnumerable employees = team.MemberList.OrderBy(m => m.Person.LastName + ", " + m.Person.FirstName); + foreach (Employee employee in employees) + { + if (employee.Person != null) + { + mitglieder += employee.Person.FirstName + " " + employee.Person.LastName + ", "; + } + } + if (mitglieder.Length > 2) + { + row[3] = mitglieder.Substring(0, mitglieder.Length - 2); + } + table.Rows.Add(row); + } + + var queryReportObject = QueryRO.Create(new Query() { Title = "Teams" }, table); + queryReportObject.Name = "Teams"; + 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 24798d400..4a767bad2 100644 --- a/ReportService/ServiceImplementations/ReportServiceImp.cs +++ b/ReportService/ServiceImplementations/ReportServiceImp.cs @@ -303,7 +303,8 @@ namespace ReportingService.ServiceImplementations public MemoryStream CreateTeamListReport(List oids) { - return null; + var reportCreator = GetReportCreator(); + return CreateReportStream(reportCreator.CreateTeamListReport(oids)); } public MemoryStream CreateUserListReport(List oids)