Files
BeWoPlaner/ReportImp/Club74DB2/Club74ReportCreator.cs
Christian 0cdbf53408 cb
2021-11-16 10:56:40 +01:00

160 lines
5.9 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using BeWo.Data;
using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BeWo.Service.DCEntityMapper;
using BS.Shared;
using DevExpress.XtraReports.UI;
namespace BeWo.Club74
{
public class Club74ReportCreator : DefaultReportCreator
{
public override XtraReport CreateCustomerInvoiceReport(long invoiceOid)
{
var invoice = MapperFactory.InvoiceBaseDC_InvoiceBase.MapToNewDC(DAOFactory.GenericDAO.LoadByID<InvoiceBase>(invoiceOid));
var ro = InvoiceCustomerRO.Create(invoice);
if (invoice.Type == InvoiceType.General)
{
var report = new BeWo.Club74.GeneralReport();
report.SetReportDataSource(ro);
return report as XtraReport;
}
var report2 = new BeWo.Club74.InvoiceCustomerReport();
report2.SetReportDataSource(ro);
return report2 as XtraReport;
}
public override XtraReport CreateServiceOverviewAllCustomersReport(int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
{
List<ServicesOverviewRO> lROs = Create(month, year, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
if (lROs.Count > 0)
{
String reportId = null;
if (orgaOid > 0)
{
var organisation = DAOFactory.GenericDAO.LoadByID<Organisation>(orgaOid);
if (organisation != null)
reportId = organisation.Name;
}
var lServiceOverviewAllCustomersReport = this.FindReportImp<ServicesOverviewRO>(reportId);
lServiceOverviewAllCustomersReport.SetReportDataSource(lROs[0]);
(lServiceOverviewAllCustomersReport as XtraReport).CreateDocument();
var Report = lServiceOverviewAllCustomersReport as XtraReport;
for (int i = 1; i < lROs.Count; i++)
{
var lNext = FindReportImp<ServicesOverviewRO>(reportId);
lNext.SetReportDataSource(lROs[i]);
(lNext as XtraReport).CreateDocument();
Report.Pages.AddRange((lNext as XtraReport).Pages);
}
return lServiceOverviewAllCustomersReport as XtraReport;
}
return new XtraReport();
}
private List<ServicesOverviewRO> Create(int pMonth, int pYear, long orgaOid, long empOid, int startDay, int endDay, long? serviceCategoryOid = null)
{
var roList = new List<ServicesOverviewRO>();
List<long> customerOids = new List<long>();
ApplicationUser loggedInUser = null;
if (LoggedInUserOperationContextExt.Current != null && LoggedInUserOperationContextExt.Current.User != null)
{
loggedInUser = LoggedInUserOperationContextExt.Current.User;
}
else
{
loggedInUser = SessionFacade.LoggedInUser;
}
if (loggedInUser != null && loggedInUser.Employee != null)
{
foreach (var e2c in loggedInUser.Employee.Employee2CustomerList)
{
if (e2c.Customer.IsActive == ActivationTypeId.Active)
{
foreach (var v2o in e2c.ValueList)
{
if (v2o.Entry.Type == ValueListEntryType.StaffRoleType &&
v2o.Entry.Value.Contains("Hauptbetreuung"))
{
if (!customerOids.Contains(e2c.Customer.Oid.Value))
{
customerOids.Add(e2c.Customer.Oid.Value);
}
}
}
}
}
}
foreach (var coid in customerOids)
{
var ro = ServicesOverviewRO.Create(coid, pMonth, pYear, false, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
//ServicesOverviewRO ro = ServicesOverviewRO.Create(customer, pSpan, disableEmptySupportConcepts, orgaOid, empOid, searchServiceRecordsByEndDate, serviceCategoryOid);
if (ro != null)
{
roList.Add(ro);
}
}
return roList.OrderBy(r => r.CustomerLastName + ", " + r.CustomerFirstName).ToList();
}
//public override XtraReport CreateServiceOverviewAllCustomersReport(int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay)
//{
// //List<ServicesOverviewRO> lROs =
// // ServicesOverviewRO.Create(month, year, orgaOid, empOid, startDay, endDay, false, null, true, false);
// List<ServicesOverviewRO> lROs = Create(month, year, orgaOid, empOid, startDay, endDay, serviceCategoryOid);
// if (lROs.Count > 0)
// {
// var rootReport = CreateServicesOverviewReportForRo(lROs[0], serviceCategoryOid);
// if (rootReport.Pages.Count == 0)
// {
// rootReport.CreateDocument();
// }
// for (int i = 1; i < lROs.Count; i++)
// {
// var lNext = CreateServicesOverviewReportForRo(lROs[i], serviceCategoryOid);
// if (lNext.Pages.Count == 0)
// {
// lNext.CreateDocument();
// }
// rootReport.Pages.AddRange(lNext.Pages);
// }
// return rootReport;
// }
// return new XtraReport();
//}
}
}