204 lines
9.1 KiB
C#
204 lines
9.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.Plugins;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.Extensions;
|
|
using BS.Shared.Services;
|
|
using DevExpress.Xpo.Providers;
|
|
|
|
namespace ProBalance.Calculations
|
|
{
|
|
public class CustomServiceRecordStatisticFactory : ServiceRecordStatisticFactory
|
|
{
|
|
// public override ServiceRecordStatisticsInfoDC GetServiceRecordStatisticInfo(long costBearer2SupportConceptOid, DateTime statisticsDate)
|
|
// {
|
|
|
|
// var stats = CreateSupportConceptStatisticsImpl(costBearer2SupportConceptOid, statisticsDate);
|
|
|
|
// var dc = new ServiceRecordStatisticsInfoDC();
|
|
// dc.Header = new string[4];
|
|
// dc.Header[0] = "Bewilligungszeitraum:";
|
|
// dc.Header[1] = "Geleistet/bewilligt Gesamt:";
|
|
// dc.Header[2] = "Geleistet/bewilligt pro Woche:";
|
|
// dc.Header[3] = "Geleistet/bewilligt pro Monat:";
|
|
|
|
|
|
// dc.ForegroundColor = new string[4];
|
|
// dc.ForegroundColor[0] = "#FF2B508B";
|
|
// dc.ForegroundColor[1] = "#FF2B508B";
|
|
// dc.ForegroundColor[2] = "#FF2B508B";
|
|
// dc.ForegroundColor[3] = "#FF2B508B";
|
|
|
|
// dc.PeriodStatisticInfos = new List<ServiceRecordPeriodStatisticsInfoDC>();
|
|
|
|
// bool addPeriodStats = true;
|
|
// if (stats != null)
|
|
// {
|
|
// if (stats.PeriodStatistics.Count > 1)
|
|
// {
|
|
// if (!TimeSpanOverlapping(stats))
|
|
// {
|
|
// dc.PeriodStatisticInfos.Add(CreateLastPeriodStatistics(stats));
|
|
|
|
// }
|
|
// else if (!TimeSpanIsEqual(stats))
|
|
// {
|
|
// dc.PeriodStatisticInfos.Add(CreateTotalStatistics(stats));
|
|
// }
|
|
// }
|
|
|
|
|
|
// if (addPeriodStats)
|
|
// {
|
|
// foreach (var pdc in stats.PeriodStatistics)
|
|
// {
|
|
// bool showOutOfPeriod = stats.PeriodStatistics.Count == 1;
|
|
// dc.PeriodStatisticInfos.Add(CreateServiceRecordPeriodStatisticsInfo(stats, pdc, showOutOfPeriod));
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// return dc;
|
|
// }
|
|
|
|
//private ServiceRecordPeriodStatisticsInfoDC CreateLastPeriodStatistics(SupportConceptStatisticsDC stats)
|
|
//{
|
|
|
|
|
|
|
|
// var dc = CreateServiceRecordPeriodStatisticsInfo(stats,
|
|
// stats.PeriodStatistics[stats.PeriodStatistics.Count - 1], false);
|
|
|
|
|
|
// DateTime min = DateTime.MaxValue;
|
|
// DateTime max = DateTime.MinValue;
|
|
|
|
// decimal istGesamt = 0;
|
|
// foreach (var ps in stats.PeriodStatistics)
|
|
// {
|
|
// if (ps.SupportConceptApprovalPeriod.StartDate.HasValue && ps.SupportConceptApprovalPeriod.StartDate < min)
|
|
// {
|
|
// min = ps.SupportConceptApprovalPeriod.StartDate.Value;
|
|
// }
|
|
// if (ps.SupportConceptApprovalPeriod.EndDate.HasValue && ps.SupportConceptApprovalPeriod.EndDate > max)
|
|
// {
|
|
// max = ps.SupportConceptApprovalPeriod.EndDate.Value;
|
|
// }
|
|
|
|
// istGesamt += ps.IstTotalUntilThisMonth;
|
|
// }
|
|
|
|
// dc.LeftValues[0] = String.Format("{0:dd.MM.yyyy} - {1:dd.MM.yyyy}", min, max);
|
|
|
|
// dc.LeftValues[1] = String.Format("{0:0.00}", stats.MinutesProvidedTotalRounded / 60);
|
|
// dc.RightValues[1] = String.Format("{0:0.00}", stats.MinutesApprovedTotal / 60);
|
|
|
|
|
|
// return dc;
|
|
|
|
//}
|
|
|
|
//public ServiceRecordPeriodStatisticsInfoDC CreateTotalStatistics(SupportConceptStatisticsDC stats)
|
|
// {
|
|
// var dc = CreateDefaultServiceRecordPeriodStatisticsInfo(5);
|
|
// dc.LeftValues[0] = "Gesamt";
|
|
|
|
// dc.LeftValues[1] = String.Format("{0:0.00}", stats.MinutesProvidedTotalRounded / 60);
|
|
// dc.RightValues[1] = String.Format("{0:0.00}", stats.MinutesApprovedTotal / 60);
|
|
|
|
// dc.LeftValues[2] = String.Format("{0:0.00}", stats.MinutesProvidedThisWeek / 60);
|
|
// dc.RightValues[2] = String.Format("{0:0.00}", stats.MinutesApprovedPerWeek / 60);
|
|
|
|
// dc.LeftValues[3] = String.Format("{0:0.00}", stats.MinutesProvidedThisMonth / 60);
|
|
// dc.RightValues[3] = String.Format("{0:0.00}", stats.MinutesApprovedPerMonth / 60);
|
|
|
|
// dc.LeftValues[4] = String.Format("{0:0.00}", (stats.SollTotalUntilThisMonth - stats.IstTotalUntilThisMonth) / 60);
|
|
|
|
|
|
// return dc;
|
|
// }
|
|
|
|
// public ServiceRecordPeriodStatisticsInfoDC CreateServiceRecordPeriodStatisticsInfo(SupportConceptStatisticsDC stats, SupportConceptPeriodStatisticsDC periodStats, bool showOutOfPeriod)
|
|
// {
|
|
// var dc = CreateDefaultServiceRecordPeriodStatisticsInfo(5);
|
|
|
|
// if (periodStats.SupportConceptApprovalPeriod != null)
|
|
// {
|
|
// if (periodStats.SupportConceptApprovalPeriod.ServiceCategory != null)
|
|
// {
|
|
// if (periodStats.SupportConceptApprovalPeriod.StartDate.HasValue && periodStats.SupportConceptApprovalPeriod.EndDate.HasValue &&
|
|
// periodStats.SupportConceptApprovalPeriod.StartDate.Value.Date == stats.StatisticsStartDate.Date &&
|
|
// periodStats.SupportConceptApprovalPeriod.EndDate.Value.Date == stats.StatisticsEndDate.Date)
|
|
// {
|
|
// dc.LeftValues[0] = periodStats.SupportConceptApprovalPeriod.ServiceCategory.Name;
|
|
// }
|
|
// else
|
|
// {
|
|
// dc.LeftValues[0] = String.Format("{0}: {1:dd.MM.yy} - {2:dd.MM.yy}",
|
|
// periodStats.SupportConceptApprovalPeriod.ServiceCategory.Name,
|
|
// periodStats.SupportConceptApprovalPeriod.StartDate,
|
|
// periodStats.SupportConceptApprovalPeriod.EndDate);
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// dc.LeftValues[0] = String.Format("{0:dd.MM.yy} - {1:dd.MM.yy}",
|
|
// periodStats.SupportConceptApprovalPeriod.StartDate,
|
|
// periodStats.SupportConceptApprovalPeriod.EndDate);
|
|
// }
|
|
// }
|
|
|
|
// dc.LeftValues[1] = String.Format("{0:0.00}", periodStats.MinutesProvidedTotalRounded / 60);
|
|
// dc.RightValues[1] = String.Format("{0:0.00}", periodStats.MinutesApprovedTotal / 60);
|
|
|
|
// dc.LeftValues[2] = String.Format("{0:0.00}", periodStats.MinutesProvidedThisWeek / 60);
|
|
// dc.RightValues[2] = String.Format("{0:0.00}", periodStats.MinutesApprovedPerWeek / 60);
|
|
|
|
// dc.LeftValues[3] = String.Format("{0:0.00}", periodStats.MinutesProvidedThisMonth / 60);
|
|
// dc.RightValues[3] = String.Format("{0:0.00}", periodStats.MinutesApprovedPerMonth / 60);
|
|
|
|
|
|
|
|
// return dc;
|
|
// }
|
|
|
|
// public override SupportConceptStatisticsDC CreateSupportConceptStatistics(long costBearer2SupportConceptOid, DateTime statisticsDate)
|
|
// {
|
|
// return null;
|
|
// }
|
|
|
|
// protected bool TimeSpanOverlapping(SupportConceptStatisticsDC r)
|
|
// {
|
|
// if (r.PeriodStatistics != null && r.PeriodStatistics.Count > 1)
|
|
// {
|
|
// for (int i = 0; i < r.PeriodStatistics.Count - 1; i++)
|
|
// {
|
|
// var p1 = r.PeriodStatistics[i];
|
|
|
|
// if (p1.SupportConceptApprovalPeriod.StartDate.HasValue && p1.SupportConceptApprovalPeriod.EndDate.HasValue)
|
|
// {
|
|
// for (int j = i + 1; j < r.PeriodStatistics.Count; j++)
|
|
// {
|
|
// var p2 = r.PeriodStatistics[j];
|
|
// if (p2.SupportConceptApprovalPeriod.StartDate.HasValue && p2.SupportConceptApprovalPeriod.EndDate.HasValue)
|
|
// {
|
|
// if ((p1.SupportConceptApprovalPeriod.StartDate.Value.Date >= p2.SupportConceptApprovalPeriod.StartDate.Value.Date) &&
|
|
// (p1.SupportConceptApprovalPeriod.StartDate.Value.Date <= p2.SupportConceptApprovalPeriod.EndDate.Value.Date))
|
|
// return true;
|
|
|
|
// if ((p1.SupportConceptApprovalPeriod.EndDate.Value.Date >= p2.SupportConceptApprovalPeriod.StartDate.Value.Date) &&
|
|
// (p1.SupportConceptApprovalPeriod.EndDate.Value.Date <= p2.SupportConceptApprovalPeriod.EndDate.Value.Date))
|
|
// return true;
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// return false;
|
|
// }
|
|
}
|
|
}
|