using System; using System.Collections.Generic; using System.Linq; using System.Text; using BeWo.Data.Access; using BeWo.Data.Entities; using BeWo.Report; using BeWo.Report.ReportObjects; using BeWo.Service.DCEntityMapper; using BeWo.Service.Plugins; using BS.Shared.Core; using BS.Shared.DataContracts; using DevExpress.XtraReports.Design; using DevExpress.XtraReports.UI; namespace AutismusKoelnBonn { public class CustomReportCreator : DefaultReportCreator { public override XtraReport CreateSettlementReport(string dcId, long? invoiceBaseOid) { return base.CreateSettlementReport(dcId, invoiceBaseOid, true); } public override XtraReport CreateServiceOverviewAllCustomersReport(int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay) { List lROs = ServicesOverviewRO.Create(month, year, orgaOid, empOid, startDay, endDay).OrderBy(ro => ro.CustomerLastName).ToList(); if (lROs.Count > 0) { var rootReport = CreateServicesOverviewReportForRo(lROs[0], serviceCategoryOid); rootReport.CreateDocument(); for (int i = 1; i < lROs.Count; i++) { var lNext = CreateServicesOverviewReportForRo(lROs[i], serviceCategoryOid); lNext.CreateDocument(); rootReport.Pages.AddRange(lNext.Pages); } return rootReport; } return new XtraReport(); } public override XtraReport CreateServiceOverviewReportForCustomers(IList customerOids, int month, int year, long? orgaOid, long? empOid, long? serviceCategoryOid, int startDay, int endDay, bool nurFehlende) { var roList = new List(); foreach (var coid in customerOids) { var ro = ServicesOverviewRO.Create(coid, month, year, true, orgaOid ?? 0, empOid ?? 0, startDay, endDay, serviceCategoryOid); if (ro != null) { roList.Add(ro); } } roList = roList.OrderBy(ro => ro.CustomerLastName).ToList(); if (roList.Count > 0) { var rootReport = CreateServicesOverviewReportForRo(roList[0], serviceCategoryOid); rootReport.CreateDocument(); for (int i = 1; i < roList.Count; i++) { var lNext = CreateServicesOverviewReportForRo(roList[i], serviceCategoryOid); lNext.CreateDocument(); rootReport.Pages.AddRange(lNext.Pages); } return rootReport; } return new XtraReport(); } public override XtraReport CreateServiceOverviewSingleCustomerReport(long customerOid, int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay) { var ro = ServicesOverviewRO.Create(customerOid, month, year, false, orgaOid, empOid, startDay, endDay, serviceCategoryOid); return CreateServicesOverviewReportForRo(ro, serviceCategoryOid); } private XtraReport CreateServicesOverviewReportForRo(ServicesOverviewRO ro, long? serviceCategoryOid) { //IBeWoReport report = null; XtraReport report = null; String kt = ""; if (!String.IsNullOrWhiteSpace(ro.Costbearer)) { kt = ro.Costbearer.Trim(); } String function = ""; if (ro.CostBearer2SupportConceptList != null) { foreach (var c2s in ro.CostBearer2SupportConceptList) { if (c2s.CostBearer.Organisation.Function != null && !String.IsNullOrWhiteSpace(ro.Costbearer) && c2s.CostBearer.Organisation.Name == ro.Costbearer) function = c2s.CostBearer.Organisation.Function.Value; } } if (function == "Quittierungsbeleg" || ro.Costbearer == "LVR") { ServicesOverviewRO flsRo = ServicesOverviewRO.CopyFromRO(ro); ServicesOverviewRO assiRo = ServicesOverviewRO.CopyFromRO(ro); if (ro.Services != null) { foreach (ServicesOverviewRO.ServiceDetail s in ro.Services) { if (s.ServiceCategory.ToLower().Contains("asl")) { assiRo.Services.Add(s); } else { flsRo.Services.Add(s); } } } report = AddReportToReport(report, flsRo); report = AddReportToReport(report, assiRo); } if (report == null) { report = AddReportToReport(report, ro); } return report as XtraReport; } private XtraReport AddReportToReport(XtraReport report, ServicesOverviewRO ro) where T : XtraReport, IBeWoReport, new() { if (ro.Services.Count > 0) { if (report == null) { report = new T(); ((T)report).SetReportDataSource(ro); } else { if (report.Pages.Count == 0) { report.CreateDocument(); } XtraReport newReport = new T(); ((T)newReport).SetReportDataSource(ro); newReport.CreateDocument(); report.Pages.AddRange(newReport.Pages); } } return report; } } }