134 lines
4.2 KiB
C#
134 lines
4.2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.Services;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using Castle.Components.DictionaryAdapter;
|
|
using NHibernate.Linq;
|
|
|
|
namespace BeWo.Service.Reporting
|
|
{
|
|
public class JahresBerichtNachVarFieldDef : JahresBerichtBase
|
|
{
|
|
private long varFieldDefOid;
|
|
|
|
private Dictionary<String, int> varfieldM = new Dictionary<String, int>();
|
|
private Dictionary<String, int> varfieldF = new Dictionary<String, int>();
|
|
private Dictionary<String, int> varfieldD = new Dictionary<String, int>();
|
|
private Dictionary<String, int> varfieldUnbekannt = new Dictionary<String, int>();
|
|
|
|
private List<string> varfieldvalues = new List<string>();
|
|
|
|
public JahresBerichtNachVarFieldDef(String titel, long defOid) : base(titel)
|
|
{
|
|
varFieldDefOid = defOid;
|
|
}
|
|
|
|
public override void ProcessCustomer(Customer customer)
|
|
{
|
|
|
|
Sex? geschlecht = null;
|
|
if (customer.Person.Sex.HasValue)
|
|
{
|
|
geschlecht = customer.Person.Sex;
|
|
}
|
|
|
|
foreach (var vv in customer.VarFieldValueList)
|
|
{
|
|
if (vv.VarFieldDefOid == varFieldDefOid)
|
|
{
|
|
Type type = Type.GetType(vv.TypeName);
|
|
var varFieldValue = Utils.XMLDeserializeFromString(vv.SerializedValue, type);
|
|
if (varFieldValue != null)
|
|
{
|
|
String str = varFieldValue.ToString();
|
|
|
|
if (!varfieldvalues.Contains(str))
|
|
{
|
|
varfieldvalues.Add(str);
|
|
}
|
|
Dictionary<String, int> dict = null;
|
|
|
|
if (geschlecht == null)
|
|
{
|
|
dict = varfieldUnbekannt;
|
|
}
|
|
else if (geschlecht.Value == Sex.Male)
|
|
{
|
|
dict = varfieldM;
|
|
}
|
|
else if (geschlecht.Value == Sex.Female)
|
|
{
|
|
dict = varfieldF;
|
|
}
|
|
else if (geschlecht.Value == Sex.Divers)
|
|
{
|
|
dict = varfieldD;
|
|
}
|
|
else
|
|
{
|
|
dict = varfieldUnbekannt;
|
|
}
|
|
|
|
if (!dict.ContainsKey(str))
|
|
{
|
|
dict.Add(str, 0);
|
|
}
|
|
|
|
dict[str]++;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public override AnnualReportDC CreateAuswertung()
|
|
{
|
|
var report = new AnnualReportDC();
|
|
report.Name = Titel;
|
|
report.Data = new List<AnnualReportDataDC>();
|
|
var index = 1;
|
|
|
|
foreach (var at in varfieldvalues.OrderBy(a => a))
|
|
{
|
|
var d = new AnnualReportDataDC();
|
|
report.Data.Add(d);
|
|
d.Index = index++;
|
|
d.Name = at;
|
|
d.Value = 0;
|
|
|
|
if (varfieldM.ContainsKey(at))
|
|
{
|
|
d.Value += varfieldM[at];
|
|
d.Male += varfieldM[at];
|
|
}
|
|
if (varfieldF.ContainsKey(at))
|
|
{
|
|
d.Value += varfieldF[at];
|
|
d.Female += varfieldF[at];
|
|
}
|
|
if (varfieldD.ContainsKey(at))
|
|
{
|
|
d.Value += varfieldD[at];
|
|
d.Divers += varfieldD[at];
|
|
}
|
|
if (varfieldUnbekannt.ContainsKey(at))
|
|
{
|
|
d.Value += varfieldUnbekannt[at];
|
|
d.NoSex += varfieldUnbekannt[at];
|
|
}
|
|
}
|
|
|
|
return report;
|
|
}
|
|
|
|
}
|
|
|
|
} |