Files
BeWoPlaner/Service/Dokumentverwaltung/EmployeePlaceholderManager.cs

138 lines
5.0 KiB
C#

using BeWo.Data.Access;
using BeWo.Data.Entities;
using BeWo.Service.DCEntityMapper;
using BS.Shared;
using BS.Shared.DataContracts;
using DevExpress.XtraRichEdit;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;
namespace BeWo.Service.Dokumentverwaltung
{
public class EmployeePlaceholderManager : PlaceholderManager
{
public override List<PlatzhalterDC> GetPlatzhalter()
{
List<PlatzhalterDC> liste = new List<PlatzhalterDC>();
PlatzhalterDC employeedaten = new PlatzhalterDC()
{
Bezeichnung = "Mitarbeiter/in",
Children = new List<PlatzhalterDC>(),
IconType = "UserGroupHome24bw"
};
employeedaten.Children.Add(new PlatzhalterDC { Bezeichnung = "Vorname", Platzhalter = "MaVorname", FieldName = "Person.FirstName", IconType = "AB" });
employeedaten.Children.Add(new PlatzhalterDC { Bezeichnung = "Nachname", Platzhalter = "MaNachname", FieldName = "Person.LastName", IconType = "AB" });
employeedaten.Children.Add(new PlatzhalterDC { Bezeichnung = "Telefon", Platzhalter = "MaTelefon", FieldName = "Person.Phone", IconType = "AB" });
employeedaten.Children.Add(new PlatzhalterDC { Bezeichnung = "Fax", Platzhalter = "MaFax", FieldName = "Person.Fax", IconType = "AB" });
employeedaten.Children.Add(new PlatzhalterDC { Bezeichnung = "E-Mail", Platzhalter = "MaEmail", FieldName = "Person.Mail", IconType = "AB" });
employeedaten.Children.Add(new PlatzhalterDC { Bezeichnung = "Handy", Platzhalter = "MaHandy", FieldName = "Person.Mobile", IconType = "AB" });
PlatzhalterDC adressdaten = new PlatzhalterDC()
{
Bezeichnung = "Adressdaten",
Children = new List<PlatzhalterDC>(),
IconType = "Home"
};
PlatzhalterDC strasse = new PlatzhalterDC() { Bezeichnung = "Straße", Platzhalter = "MaStrasse", IconType = "AB", FieldName = "Person.Address.Street" };
adressdaten.Children.Add(strasse);
PlatzhalterDC plz = new PlatzhalterDC() { Bezeichnung = "PLZ", Platzhalter = "MaPLZ", IconType = "AB", FieldName = "Person.Address.PostalCode" };
adressdaten.Children.Add(plz);
PlatzhalterDC ort = new PlatzhalterDC() { Bezeichnung = "Ort", Platzhalter = "MaOrt", IconType = "AB", FieldName = "Person.Address.Town" };
adressdaten.Children.Add(ort);
employeedaten.Children.Add(adressdaten);
liste.Add(employeedaten);
return liste;
}
public virtual Object GetEntityObject(long oid)
{
return DAOFactory.GenericDAO.GetByID<Employee>(oid);
}
public override String GetPlaceholderValue(PlatzhalterDC ph, Object obj)
{
return GetPlaceholderValueForEmployee(ph, obj as Employee);
}
public String GetPlaceholderValueForEmployee(PlatzhalterDC ph, Employee employee)
{
if (employee == null)
{
return String.Empty;
}
if (ph.Platzhalter == "MaVorname")
{
return base.GetPlaceholderValue(ph, employee);
//return customer.Person.FirstName;
}
if (ph.Platzhalter == "MaNachname")
{
return employee.Person.LastName;
}
if (ph.Platzhalter == "MaGeburtsdatum")
{
return String.Format("{0:dd.MM.yyyy}", employee.Person.DateOfBirth);
}
if (ph.Platzhalter == "MaTelefon")
{
foreach (Contact c in employee.Person.Contacts)
{
if (c.Type == ContactType.business_Phone)
{
return c.Value;
}
}
}
if (ph.Platzhalter == "MaHandy")
{
foreach (Contact c in employee.Person.Contacts)
{
if (c.Type == ContactType.business_MobilePhone)
{
return c.Value;
}
}
}
if (ph.Platzhalter == "MaEmail")
{
foreach (Contact c in employee.Person.Contacts)
{
if (c.Type == ContactType.business_Mail)
{
return c.Value;
}
}
}
if (ph.Platzhalter == "MaFax")
{
foreach (Contact c in employee.Person.Contacts)
{
if (c.Type == ContactType.business_Fax)
{
return c.Value;
}
}
}
return String.Empty;
}
}
}