95 lines
3.0 KiB
C#
95 lines
3.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Service.Configuration;
|
|
using BeWo.Service.Core;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.MessageContracts;
|
|
using BeWo.Service.Plugins;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using BS.Shared.Extensions;
|
|
using BS.Shared.Services;
|
|
using Utils = BS.Shared.Core.Utils;
|
|
|
|
namespace SPZLeverkusen.Service
|
|
{
|
|
public class CustomStundenuebersichtAuswertung : StundenuebersichtAuswertung
|
|
{
|
|
private IList<long> empOids = null;
|
|
|
|
public override List<FLSAnalysisRootDC> GetEmployeeFLSAnalysis(FLSAnalysisConfigDC config)
|
|
{
|
|
List<FLSAnalysisRootDC> result = new List<FLSAnalysisRootDC>();
|
|
|
|
var settings = AppSettings.CreateSettings();
|
|
|
|
var employees = config.ShouldAnalyzeArchivedEmployees ? DAOFactory.GenericDAO.GetAllActiveAndArchived<Employee>() : DAOFactory.GenericDAO.GetAllActive<Employee>();
|
|
var filteredEmps = SpzEmployeeService.FilterList(employees);
|
|
|
|
foreach (var e in filteredEmps)
|
|
{
|
|
var flsDc = CreateEmployeeFLSRootDC(e, config, settings.ShowRoundedDurationInEmployeeAnalysis);
|
|
|
|
result.Add(flsDc);
|
|
}
|
|
|
|
|
|
return result;
|
|
}
|
|
|
|
public override FLSAnalysisRootDC CreateCustomerFLSOverviewDC(Customer customer, FLSAnalysisConfigDC config)
|
|
{
|
|
CreateAllowedEmpOidList(config);
|
|
return base.CreateCustomerFLSOverviewDC(customer, config);
|
|
}
|
|
|
|
private void CreateAllowedEmpOidList(FLSAnalysisConfigDC config)
|
|
{
|
|
if (empOids == null)
|
|
{
|
|
empOids = new List<long>();
|
|
|
|
var employees = config.ShouldAnalyzeArchivedEmployees
|
|
? DAOFactory.GenericDAO.GetAllActiveAndArchived<Employee>()
|
|
: DAOFactory.GenericDAO.GetAllActive<Employee>();
|
|
var filteredEmps = SpzEmployeeService.FilterList(employees);
|
|
|
|
empOids = filteredEmps.Select(e => e.Oid.Value).ToList();
|
|
}
|
|
}
|
|
|
|
|
|
public override bool AllowCustomerAnalysis(Customer customer, FLSAnalysisConfigDC config, IList<IServiceRecord> serviceRecords)
|
|
{
|
|
if (config.EmployeeOid != null)
|
|
{
|
|
foreach (ServiceRecord sr in serviceRecords)
|
|
{
|
|
if (sr.Employee != null && sr.Employee.Oid.Value == config.EmployeeOid.Value)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach (ServiceRecord sr in serviceRecords)
|
|
{
|
|
if (sr.Employee != null && empOids.Contains(sr.Employee.Oid.Value))
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
|
|
return false;
|
|
}
|
|
}
|
|
}
|