202 lines
6.8 KiB
C#
202 lines
6.8 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
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 BeWo.Service.ServiceImplementations;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace UebergangshilfeUnnaEV.Reporting
|
|
{
|
|
public class CustomReportCreator : DefaultReportCreator
|
|
{
|
|
|
|
public override XtraReport CreateQueryReport(long queryOid, string queryReportId)
|
|
{
|
|
if (queryOid == 100)
|
|
{
|
|
return CreateHilfeplanKontingent(queryOid, queryReportId);
|
|
}
|
|
|
|
return base.CreateQueryReport(queryOid, queryReportId);
|
|
}
|
|
|
|
private XtraReport CreateHilfeplanKontingent(long queryOid, string queryReportId)
|
|
{
|
|
var query = DAOFactory.GenericDAO.LoadByID<Query>(queryOid);
|
|
|
|
if (query == null)
|
|
return new XtraReport();
|
|
|
|
var path = Path.Combine(TempPath, queryReportId + ".xml");
|
|
var table = Utils.XMLDeserialize<DataTable>(path);
|
|
var qro = QueryRO.Create(query, table);
|
|
|
|
|
|
if (qro.Rows.Count > 0)
|
|
{
|
|
if (qro.Rows[0].Field1 != null && qro.Rows[0].Field1.ToString() != "0")
|
|
{
|
|
var oid = Int64.Parse(qro.Rows[0].Field1.ToString());
|
|
|
|
List<long> oidList = new List<long>();
|
|
oidList.Add(oid);
|
|
|
|
var druck = new HilfeplanKontingent();
|
|
druck.SetReportDataSource(HilfeplanKontingentRO.Create(oidList));
|
|
return druck;
|
|
}
|
|
|
|
//DateTime dt = DateTime.Now;
|
|
//DateTime.TryParse(qro.Rows[0].Field1.ToString(), out dt);
|
|
//dt = dt.AddMonths(1).AddDays(-1);
|
|
|
|
//long? customerOid = null;
|
|
//if (qro.Rows[0].Field2 != null && qro.Rows[0].Field2.ToString() != "0")
|
|
//{
|
|
// var oid = Int64.Parse(qro.Rows[0].Field2.ToString());
|
|
// var c = DAOFactory.GenericDAO.LoadByID<Customer>(customerOid.Value);
|
|
|
|
// var ro = (CustomerDataRO.Create(MapperFactory.CustomerDC_Customer.MapToNewDC(customer)));
|
|
// var cRo = CreateKlientenStammdatenRO(dt, ro);
|
|
// var druck = new Selbsteinschaetzung();
|
|
// druck.SetReportDataSource(cRo);
|
|
// return druck;
|
|
//}
|
|
|
|
}
|
|
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 SelectVersion(ro);
|
|
}
|
|
public override XtraReport CreateServiceOverviewAllCustomersReport(int month, int year, long orgaOid, long empOid, long? serviceCategoryOid, int startDay, int endDay, bool nurFehlende)
|
|
{
|
|
var os = new OperationsServiceImp();
|
|
var m = os.GetMandator2(false);
|
|
if (m.AllowSbd)
|
|
{
|
|
return CreateSbdLeistungsnachweisForAllCustomers(month, year, orgaOid, empOid, serviceCategoryOid ?? 0, startDay, endDay, false, "nrw");
|
|
}
|
|
|
|
List<ServicesOverviewRO> lROs = ServicesOverviewRO.Create(month, year, orgaOid, empOid, startDay, endDay, serviceCategoryOid, true, nurFehlende);
|
|
|
|
if (lROs.Count > 0)
|
|
{
|
|
var lServiceOverviewAllCustomersReport = SelectVersion(lROs[0]);
|
|
var Report = lServiceOverviewAllCustomersReport;
|
|
|
|
|
|
for (int i = 1; i < lROs.Count; i++)
|
|
{
|
|
var lNext = SelectVersion(lROs[i]);
|
|
Report.Pages.AddRange(lNext.Pages);
|
|
}
|
|
|
|
return lServiceOverviewAllCustomersReport;
|
|
}
|
|
return new XtraReport();
|
|
}
|
|
public override XtraReport CreateServiceOverviewReportForCustomers(IList<long> customerOids, int month, int year, long? orgaOid, long? empOid, long? serviceCategoryOid, int startDay, int endDay, bool nurFehlende)
|
|
{
|
|
var roList = new List<ServicesOverviewRO>();
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
var sortedList = roList.OrderBy(r => r.CustomerLastName + ", " + r.CustomerFirstName).ToList();
|
|
|
|
if (sortedList.Count > 0)
|
|
{
|
|
String reportId = null;
|
|
if (orgaOid.HasValue && orgaOid > 0)
|
|
{
|
|
var organisation = DAOFactory.GenericDAO.LoadByID<Organisation>(orgaOid.Value);
|
|
if (organisation != null)
|
|
reportId = organisation.Name;
|
|
}
|
|
|
|
var rootReport = SelectVersion(sortedList[0]);
|
|
if (rootReport.Pages.Count == 0)
|
|
{
|
|
rootReport.CreateDocument();
|
|
}
|
|
|
|
|
|
for (int i = 1; i < sortedList.Count; i++)
|
|
{
|
|
var lNext = SelectVersion(sortedList[i]);
|
|
rootReport.Pages.AddRange(lNext.Pages);
|
|
}
|
|
|
|
return rootReport;
|
|
}
|
|
return new XtraReport();
|
|
}
|
|
|
|
private IEnumerable CreateMitHandzeichenAddition(ServicesOverviewRO ro)
|
|
{
|
|
var addition = new Monatsprotokoll();
|
|
addition.SetReportDataSource(ro);
|
|
(addition as XtraReport).CreateDocument();
|
|
return addition.Pages;
|
|
}
|
|
|
|
private XtraReport SelectVersion(ServicesOverviewRO ro)
|
|
{
|
|
IBeWoReport<ServicesOverviewRO> result = null;
|
|
if (TemplateOid.HasValue)
|
|
{
|
|
switch (TemplateOid)
|
|
{
|
|
case 1:
|
|
result = new ServicesOverviewReport();
|
|
break;
|
|
case 2:
|
|
result = new QuittierungMitUnterschriften();
|
|
break;
|
|
case 3:
|
|
result = new QuittierungOhneUnterschriften();
|
|
break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
result = new ServicesOverviewReport();
|
|
}
|
|
|
|
result.SetReportDataSource(ro);
|
|
(result as XtraReport).CreateDocument();
|
|
var report = result as XtraReport;
|
|
//if (TemplateOid == 2)
|
|
// report.Pages.AddRange(CreateMitHandzeichenAddition(ro));
|
|
|
|
|
|
return report;
|
|
}
|
|
}
|
|
}
|