97 lines
3.1 KiB
C#
97 lines
3.1 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.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 DevExpress.DataProcessing;
|
|
using Utils = BS.Shared.Core.Utils;
|
|
|
|
namespace VkmAachenSbd.Service
|
|
{
|
|
public class CustomEmployeeService : EmployeeService
|
|
{
|
|
|
|
public override long InsertNewEmployee(EmployeeDC pEmployeeDC)
|
|
{
|
|
Employee e = MapperFactory.EmployeeDC_Employee.MapToNewEntity(pEmployeeDC);
|
|
|
|
if (String.IsNullOrWhiteSpace(pEmployeeDC.PersonnelNumber))
|
|
{
|
|
int newPersonalNummer = 1500;
|
|
|
|
var result = DAOFactory.SearchDAO.GetSqlResult(
|
|
"SELECT Max(CONVERT(PersonnelNumber, UNSIGNED INTEGER)) FROM employee");
|
|
|
|
if (result.Count > 0)
|
|
{
|
|
var test = result[0];
|
|
int p = 0;
|
|
if (test != null && Int32.TryParse(test.ToString(), out p))
|
|
{
|
|
if (p >= 1500)
|
|
{
|
|
newPersonalNummer = p + 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
e.PersonnelNumber = newPersonalNummer.ToString();
|
|
}
|
|
DAOFactory.GenericDAO.Insert(e);
|
|
return e.Oid.Value;
|
|
}
|
|
|
|
public override List<CompactEmployeeDC> GetAllCompactEmployees()
|
|
{
|
|
var employees = DAOFactory.GenericDAO.GetAll<Employee>();
|
|
|
|
var result = new List<CompactEmployeeDC>();
|
|
foreach (var employee in employees)
|
|
{
|
|
var empDc = MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(employee);
|
|
|
|
if (employee.Person.Address != null)
|
|
{
|
|
empDc.Details2 = String.Format("{0}\n{1} {2}", employee.Person.Address.Street, employee.Person.Address.PostalCode, employee.Person.Address.Town);
|
|
}
|
|
|
|
String contacts = "";
|
|
|
|
var tel = employee.Person.Contacts.Where(c => c.Type == ContactType.business_Phone).FirstOrDefault();
|
|
if (tel != null)
|
|
{
|
|
contacts = tel.Value;
|
|
}
|
|
var handy = employee.Person.Contacts.Where(c => c.Type == ContactType.business_MobilePhone).FirstOrDefault();
|
|
if (handy != null)
|
|
{
|
|
if (contacts.Length > 0)
|
|
{
|
|
contacts += "\n";
|
|
}
|
|
contacts += handy.Value;
|
|
|
|
|
|
}
|
|
empDc.Details3 = contacts;
|
|
//txtDetails fixen und richtig anordnen + Bewertung aus Version rausnehmen
|
|
result.Add(empDc);
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
}
|
|
}
|