135 lines
4.0 KiB
C#
135 lines
4.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.IO;
|
|
using System.Linq;
|
|
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.Core;
|
|
using BS.Shared.DataContracts;
|
|
using DevExpress.XtraReports.UI;
|
|
|
|
namespace BeWo.SeWo
|
|
{
|
|
public class CustomReportCreator : DefaultReportCreator
|
|
{
|
|
public override XtraReport CreateQueryReport(long queryOid, string queryReportId)
|
|
{
|
|
|
|
if (queryOid == 400 || queryOid == 500 || queryOid == 600)
|
|
{
|
|
return CreateZeitzuschlagsbeleg(queryOid, queryReportId);
|
|
}
|
|
return base.CreateQueryReport(queryOid, queryReportId);
|
|
|
|
}
|
|
|
|
private XtraReport CreateZeitzuschlagsbeleg(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)
|
|
{
|
|
long? employeeOid = null;
|
|
if (qro.Rows[0].Field2 != null && qro.Rows[0].Field2.ToString() != "0")
|
|
{
|
|
employeeOid = Int64.Parse(qro.Rows[0].Field2.ToString());
|
|
}
|
|
|
|
DateTime monat = DateTime.Parse(qro.Rows[0].Field1.ToString());
|
|
|
|
|
|
DateTimeSpan span = new DateTimeSpan();
|
|
span.StartDateTime = monat;
|
|
span.EndDateTime = monat.AddMonths(1).AddTicks(-1);
|
|
|
|
IList<long> teamOids = null;
|
|
|
|
if (!employeeOid.HasValue && queryOid == 500)
|
|
{
|
|
//Suche Mitarbeiter des Teams
|
|
ApplicationUser loggedInUser;
|
|
|
|
if (LoggedInUserOperationContextExt.Current != null &&
|
|
LoggedInUserOperationContextExt.Current.User != null)
|
|
{
|
|
loggedInUser = LoggedInUserOperationContextExt.Current.User;
|
|
|
|
|
|
}
|
|
else
|
|
{
|
|
loggedInUser = SessionFacade.LoggedInUser;
|
|
}
|
|
|
|
if (loggedInUser != null && loggedInUser.Employee != null)
|
|
{
|
|
var teams = DAOFactory.SearchDAO.FindLeadingTeams(loggedInUser.Employee.Oid.Value);
|
|
teamOids = teams.Select(t => t.Oid.Value).ToList();
|
|
}
|
|
}
|
|
|
|
MitarbeiterstundenkontoRO ro = MitarbeiterstundenkontoRO.Create(employeeOid, teamOids, monat, monat.AddMonths(1), null);
|
|
|
|
var msb = new SeWoMitarbeiterstundenkontoBerechnung();
|
|
msb.IgnoreSeWoRufUndNotdienst = false;
|
|
|
|
msb.CreateReport(ro);
|
|
|
|
|
|
//IEnumerable<ServiceRecord> records = null;
|
|
|
|
//if (employeeOid.HasValue && employeeOid.Value > 0)
|
|
//{
|
|
// records = DAOFactory.SearchDAO.FindEmployeeServiceRecords(employeeOid, span, null, null);
|
|
//}
|
|
//else
|
|
//{
|
|
// records = DAOFactory.SearchDAO.FindServiceRecordsInSpan(span, null);
|
|
// }
|
|
|
|
XtraReport allReports = null;
|
|
|
|
|
|
foreach (var ed in ro.EmployeeDetailList)
|
|
{
|
|
ed.StundenGesamtIst += ed.Custom10;
|
|
|
|
Zeitzuschlagsbeleg beleg = new Zeitzuschlagsbeleg();
|
|
|
|
beleg.SetReportDataSource(ro.ReportStartDate, ed);
|
|
|
|
beleg.CreateDocument();
|
|
if (allReports == null)
|
|
allReports = beleg;
|
|
else
|
|
allReports.Pages.AddRange(beleg.Pages);
|
|
}
|
|
|
|
if (allReports != null)
|
|
{
|
|
return allReports;
|
|
}
|
|
}
|
|
|
|
|
|
return new XtraReport();
|
|
}
|
|
}
|
|
}
|