119 lines
4.1 KiB
C#
119 lines
4.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Report;
|
|
using BeWo.Report.DefaultReports;
|
|
using BeWo.Report.ReportObjects;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace AwoDortmund
|
|
{
|
|
public class CustomReportCreator : DefaultReportCreator
|
|
{
|
|
public override XtraReport CreateQueryReport(long queryOid, string queryReportId)
|
|
{
|
|
if (queryOid == 300)
|
|
return CreateMonatFinanzauswertung(queryOid, queryReportId);
|
|
if (queryOid == 400)
|
|
return CreateSammelrechnungReport(queryOid, queryReportId);
|
|
|
|
return base.CreateQueryReport(queryOid, queryReportId);
|
|
}
|
|
|
|
private XtraReport CreateMonatFinanzauswertung(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)
|
|
{
|
|
DateTime start = DateTime.Parse(qro.Rows[0].Field1.ToString());
|
|
DateTime end = start.AddMonths(1).AddDays(-1);
|
|
|
|
var ro = FinanceRO.Create(start, end);
|
|
var druck = new SonderFinanzauswertung();
|
|
druck.SetReportDataSource(ro);
|
|
return druck;
|
|
}
|
|
return new XtraReport();
|
|
}
|
|
|
|
private XtraReport CreateSammelrechnungReport(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].Field3 != null)
|
|
{
|
|
|
|
|
|
DateTime start = DateTime.Parse(qro.Rows[0].Field1.ToString());
|
|
DateTime end = DateTime.Parse(qro.Rows[0].Field2.ToString());
|
|
long ktOid = Int64.Parse(qro.Rows[0].Field3.ToString());
|
|
|
|
DateTimeSpan span = new DateTimeSpan();
|
|
span.StartDate = start;
|
|
span.EndDate = end.AddMinutes(-1);
|
|
|
|
var invoices = DAOFactory.SearchDAO.GetServiceInvoices(null, span);
|
|
|
|
|
|
if (invoices.Count > 0 )
|
|
{
|
|
String ids = "";
|
|
|
|
foreach (var item in invoices)
|
|
{
|
|
try
|
|
{
|
|
if (item.InvoiceBase.CostBearer2SupportConcept != null && item.InvoiceBase.CostBearer2SupportConcept.CostBearer.Organisation.Oid == ktOid)
|
|
{
|
|
if (ids.Length > 0)
|
|
ids += ";";
|
|
ids += String.Format("{0:0}", item.Oid);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
//Bei gelöschten Costbearer2SupportConcepts kann es zu einem Hibernate Fehler kommen, den ignorieren wir einfach
|
|
}
|
|
|
|
}
|
|
if (!String.IsNullOrEmpty(ids))
|
|
{
|
|
var report = CreateServiceInvoiceReport(ids, null);
|
|
return report;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
return new XtraReport();
|
|
}
|
|
}
|
|
}
|
|
|