Files
BeWoPlaner/ReportImp/Intego/CustomReportCreator.cs

88 lines
3.3 KiB
C#

using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Report;
using BeWo.Report.ReportObjects;
using BeWo.Service.DCEntityMapper;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using DevExpress.XtraReports.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Intego
{
public class CustomReportCreator : DefaultReportCreator
{
public override XtraReport CreateSettlementReport(string dcId, long? invoiceBaseOid, bool createAnhang)
{
XtraReport report = null;
Settlement2DC lSettlementDC;
createAnhang = true;
long result;
if (string.IsNullOrEmpty(dcId) && invoiceBaseOid.HasValue)
{
lSettlementDC = MapperFactory.SettlementDC_SettlementInvoice.MapToNewDC(DAOFactory.SearchDAO.GetSettlementInvoiceByInvoiceBaseOid(invoiceBaseOid.Value));
}
else if (Int64.TryParse(dcId, out result))
{
lSettlementDC = MapperFactory.SettlementDC_SettlementInvoice.MapToNewDC(DAOFactory.GenericDAO.LoadByID<SettlementInvoice>(result)); // = Utils.XMLDeserialize<SettlementDC>(lPath);
}
else
{
string lPath = BS.Shared.Core.Utils.CreateSavePath(TempPath, dcId);
lSettlementDC = Utils.XMLDeserialize<Settlement2DC>(lPath);
}
String reportId = null;
if (lSettlementDC.CostBearer2SupportConceptOid.HasValue)
{
CostBearer2SupportConcept c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(lSettlementDC.CostBearer2SupportConceptOid.Value);
reportId = c2s.CostBearer.ID;
IBeWoReport<Settlement2RO> lSettlementReport = null;
if (c2s.CostBearer.Organisation.Name.ToLower().Contains("lwl") || c2s.CostBearer.Organisation.Name.ToLower().Contains("landschaftsverband")
&& c2s.CostBearer.Organisation.Name.ToLower().Contains("westfalen") && c2s.CostBearer.Organisation.Name.ToLower().Contains("lippe"))
{
lSettlementReport = new SettlementReportLWL();
}
else if (c2s.CostBearer.Organisation.Name.ToLower().Contains("lvr") || c2s.CostBearer.Organisation.Name.ToLower().Contains("landschaftsverband")
&& c2s.CostBearer.Organisation.Name.ToLower().Contains("rheinland"))
{
lSettlementReport = new SettlementReportLVR();
}
else
{
lSettlementReport = FindReportImp<Settlement2RO>(reportId);
}
var ro = Settlement2RO.Create(lSettlementDC);
lSettlementReport.SetReportDataSource(ro);
report = lSettlementReport as XtraReport;
}
if (createAnhang)
{
if (report != null)
{
report.CreateDocument();
var anhang = CreateBudgetnachweisAnhang(lSettlementDC);
if (anhang != null)
{
anhang.CreateDocument();
report.Pages.AddRange(anhang.Pages);
}
}
}
return report;
}
}
}