Kalender: Enddatum bei Abwesenheiten im ToolTip korrigiert. Verwaltung: Sessiontimeout für den MoK zwischen 20 und 60 Minuten einstellbar gemacht. Auswertungen: Ansehenrechte hinzugefügt (hat man nur das Recht Auswertungen ansehen zu dürfen und sonst keine Auswertungsrechte (z.B. "Auswertungen Berichte ansehen" oder "Jahresberichte"), wird das Modul nicht angezeigt). MoK (siehe "MoK Neuerungen Juni Release 2023.pdf"): Zeiterfassung: + Berechnung der Dauer/Start/Ende korrigiert. + Hilfeplanbezeichnungen werden angezeigt. + Unterschriften sind löschbar und machen Monatsunterschriften ungültig (Warnung inklusive) + Infotext (dass die erneute Unterschrift nicht notwendig ist) wird im Unterschriftenformular angezeigt, wenn bereits eine Monatsunterschrift für den zu unterschreibenden Eintrag geleistet wurde. Klienten: + Diagnosen hinzugefügt + Behinderungen hinzugefügt Quittierungsbelege: + Neue Informationen von Monatsunterschriften: Ob für alle Zeiterfassungseinträge im ausgewählten Zeitraum gültig, ob die Monatsunterschrift auf dem Quittierungsbeleg angezeigt wird, Unterschrift von, geleistet am (sekundengenau), und geleistet für x erbrachte Leistungen. Auswertungen: + Mitarbeiterstundenkonto hinzugefügt
7960 lines
312 KiB
C#
7960 lines
312 KiB
C#
using BeWo.Data;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Data.ICD10;
|
|
using BeWo.Data.ICF;
|
|
using BeWo.Service.Configuration;
|
|
using BeWo.Service.Core;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.Dienstplanung;
|
|
using BeWo.Service.Dokumentverwaltung;
|
|
using BeWo.Service.Invoicing;
|
|
using BeWo.Service.OwnChat;
|
|
using BeWo.Service.PivotTabelle;
|
|
using BeWo.Service.Plugins;
|
|
using BeWo.Service.SBD;
|
|
using BeWo.Service.Security;
|
|
using BeWo.Service.ServiceContracts;
|
|
using BeWo.Service.Vorlagen;
|
|
using BS.Shared;
|
|
using BS.Shared.Core;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using BS.Shared.DataContracts.Reports;
|
|
using BS.Shared.Extensions;
|
|
using BS.Shared.Services;
|
|
using Newtonsoft.Json;
|
|
using RestSharp;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.ServiceModel;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Web;
|
|
using System.Windows;
|
|
using Utils = BeWo.Service.Core.Utils;
|
|
|
|
namespace BeWo.Service.ServiceImplementations
|
|
{
|
|
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
|
|
public class OperationsServiceImp : IOperationsService
|
|
{
|
|
private static object _Lock = string.Empty;
|
|
private static Dictionary<string, string> _ContractStates = new Dictionary<string, string>();
|
|
private static Dictionary<string, DateTime> _ContractStateDate = new Dictionary<string, DateTime>();
|
|
|
|
public Mandator GetMandatorEntity()
|
|
{
|
|
return AppSettings.GetMandatorEntity();
|
|
}
|
|
|
|
public void DeactivateInvoices(List<InvoiceDC> pInvoices)
|
|
{
|
|
try
|
|
{
|
|
ServiceLogic.SetActivationType<Invoice>(pInvoices.ToDictionary(i => i.InvoiceOid.Value, i => i.InvoiceVersion.Value), ActivationTypeId.Deleted);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeactivateServiceCategories(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
ServiceLogic.SetActivationType<ServiceCategory>(pOid2Version, ActivationTypeId.Deleted);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeactivateAdditionalServices(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
ServiceLogic.SetActivationType<AdditionalService>(pOid2Version, ActivationTypeId.Deleted);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeactivateServiceCategory(long pOid, long pVersion)
|
|
{
|
|
try
|
|
{
|
|
ServiceLogic.SetActivationType<ServiceCategory>(new Dictionary<long, long>
|
|
{
|
|
{
|
|
pOid, pVersion
|
|
}
|
|
}, ActivationTypeId.Deleted);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeactivateServiceDescription(long pOid, long pVersion)
|
|
{
|
|
try
|
|
{
|
|
ServiceLogic.SetActivationType<ServiceDescription>(new Dictionary<long, long>
|
|
{
|
|
{
|
|
pOid, pVersion
|
|
}
|
|
}, ActivationTypeId.Deleted);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeactivateServiceDescriptions(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
ServiceLogic.SetActivationType<ServiceDescription>(pOid2Version, ActivationTypeId.Deleted);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeactivateAdditionalServiceRegions(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
ServiceLogic.SetActivationType<AdditionalServiceRegion>(pOid2Version, ActivationTypeId.Deleted);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteAccountingTransaction(long pOid, long pVersion)
|
|
{
|
|
try
|
|
{
|
|
DeleteAccountingTransactions(new Dictionary<long, long>
|
|
{
|
|
{
|
|
pOid, pVersion
|
|
}
|
|
});
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteAccountingTransactions(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
List<AccountingTransaction> lOriginals = DAOFactory.GenericDAO.LoadByIDs<AccountingTransaction>(pOid2Version.Select(e => e.Key));
|
|
lOriginals.DoForEach(or => MapperFactory.AccountingTransactionDC_AccountingTransaction.ConcurrencyCheck(pOid2Version[or.Oid.Value], or));
|
|
|
|
// DAOFactory.GenericDAO.Deactivate<AccountingTransaction>(lOriginals);
|
|
DAOFactory.GenericDAO.Delete(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteFileAttachment(long pOid, long pVersion)
|
|
{
|
|
try
|
|
{
|
|
DeleteFileAttachments(new Dictionary<long, long>
|
|
{
|
|
{
|
|
pOid, pVersion
|
|
}
|
|
});
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteFileAttachments(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
ServiceLogic.SetActivationType<FileAttachment>(pOid2Version, ActivationTypeId.Deleted);
|
|
|
|
//var lOriginals = DAOFactory.GenericDAO.LoadByIDs<FileAttachment>(pOid2Version.Select(e => e.Key));
|
|
//lOriginals.DoForEach(or => MapperFactory.FileAttachmentDC_FileAttachment.ConcurrencyCheck(pOid2Version[or.Oid.Value], or));
|
|
|
|
//var fileAttachmentOids = new List<long>();
|
|
|
|
//lOriginals.DoForEach(fileAttachment =>
|
|
//{
|
|
// if(fileAttachment.Oid.HasValue)
|
|
// {
|
|
// fileAttachmentOids.AddIfNotIn(fileAttachment.Oid.Value);
|
|
// }
|
|
//});
|
|
|
|
//FileAttachmentUtils.DeleteFilesFromFileDirectory(fileAttachmentOids);
|
|
|
|
//DAOFactory.GenericDAO.Delete(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteServiceCategories(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
List<ServiceCategory> lOriginals = DAOFactory.GenericDAO.LoadByIDs<ServiceCategory>(pOid2Version.Select(e => e.Key));
|
|
lOriginals.DoForEach(or => MapperFactory.ServiceCategoryDC_ServiceCategory.ConcurrencyCheck(pOid2Version[or.Oid.Value], or));
|
|
|
|
DAOFactory.GenericDAO.Delete(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteServiceCategory(long pOid, long pVersion)
|
|
{
|
|
try
|
|
{
|
|
DeleteServiceCategories(new Dictionary<long, long>
|
|
{
|
|
{
|
|
pOid, pVersion
|
|
}
|
|
});
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteServiceDescription(long pOid, long pVersion)
|
|
{
|
|
try
|
|
{
|
|
DeleteServiceDescriptions(new Dictionary<long, long>
|
|
{
|
|
{
|
|
pOid, pVersion
|
|
}
|
|
});
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteServiceDescriptions(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
List<ServiceDescription> lOriginals = DAOFactory.GenericDAO.LoadByIDs<ServiceDescription>(pOid2Version.Select(e => e.Key));
|
|
lOriginals.DoForEach(or => MapperFactory.ServiceDescriptionDC_ServiceDescription.ConcurrencyCheck(pOid2Version[or.Oid.Value], or));
|
|
|
|
DAOFactory.GenericDAO.Delete(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteServiceRecord(long pOid, long pVersion)
|
|
{
|
|
try
|
|
{
|
|
DeleteServiceRecords(new Dictionary<long, long>
|
|
{
|
|
{
|
|
pOid, pVersion
|
|
}
|
|
});
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteServiceRecords(Dictionary<long, long> pOid2Version)
|
|
{
|
|
InternalDeleteServicerecords(pOid2Version);
|
|
}
|
|
|
|
public static void InternalDeleteServicerecords(IDictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
var lOriginals = DAOFactory.GenericDAO.LoadByIDs<ServiceRecord>(pOid2Version.Select(e => e.Key));
|
|
|
|
lOriginals.DoForEach(or => MapperFactory.ServiceRecordDC_ServiceRecord.ConcurrencyCheck(pOid2Version[or.Oid.Value], or));
|
|
|
|
var srListToDelete = new List<ServiceRecord>();
|
|
|
|
foreach(var item in lOriginals)
|
|
{
|
|
if(item.Group != null)
|
|
{
|
|
DeleteServiceRecordsFromAppointments(item.Group.ServiceRecordList.ToList());
|
|
|
|
DAOFactory.GenericDAO.Delete(item.Group);
|
|
}
|
|
else
|
|
{
|
|
srListToDelete.Add(item);
|
|
}
|
|
}
|
|
|
|
if(srListToDelete.Count <= 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
DeleteServiceRecordsFromAppointments(srListToDelete);
|
|
|
|
DAOFactory.GenericDAO.Delete(srListToDelete);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
private static void DeleteServiceRecordsFromAppointments(List<ServiceRecord> serviceRecords)
|
|
{
|
|
MakeServiceRecordHistoryEntry(serviceRecords, null, StatementType.Delete);
|
|
|
|
RemoveServiceRecordsFromConfirmationReceiptSignatures(MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(serviceRecords), DAOFactory.GenericDAO.LoadByIDs<ServiceRecord>(serviceRecords.Select(s => s.Oid.Value)), true);
|
|
|
|
var appointmentsToUpdate = DAOFactory.SearchDAO.LoadAppointmentsWithServiceRecords(serviceRecords.Select(s => s.Oid.Value).ToList());
|
|
|
|
appointmentsToUpdate.DoForEach(appointment => appointment.ServiceRecordList = appointment.ServiceRecordList.Where(sr => !serviceRecords.Select(s => s.Oid.Value).Contains(sr.Oid.Value)).ToList());
|
|
|
|
DAOFactory.GenericDAO.Update(appointmentsToUpdate);
|
|
}
|
|
|
|
public Settlement2DC GenerateInitialSettlementDC(long pCostBearer2SupportConceptOid)
|
|
{
|
|
return GenerateInitialSettlementDCForPeriod(pCostBearer2SupportConceptOid, null, null);
|
|
}
|
|
|
|
public Settlement2DC GenerateInitialSettlementDCForPeriod(long pCostBearer2SupportConceptOid, DateTime? periodStart, DateTime? periodEnd)
|
|
{
|
|
try
|
|
{
|
|
var lCb2Sc = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(pCostBearer2SupportConceptOid);
|
|
|
|
var costBearer = lCb2Sc.CostBearer;
|
|
string tenant = null;
|
|
|
|
if (MultitenancyOperationContextExt.Current != null)
|
|
{
|
|
tenant = MultitenancyOperationContextExt.Current.Tenant;
|
|
}
|
|
|
|
var factory = PluginLoader.FindClass<InvoiceFactory>(costBearer.ID);
|
|
|
|
if (factory == null)
|
|
{
|
|
factory = InvoiceFactory.GetInstance(costBearer.ID, tenant);
|
|
}
|
|
|
|
var creator = factory.CreateSettlementInvoiceCreator(costBearer.ID, tenant, lCb2Sc);
|
|
|
|
var lResult = creator.GenerateSettlementInvoice(lCb2Sc, periodStart, periodEnd);
|
|
|
|
return lResult;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<Settlement2DC> GenerateInitialSettlementDCsForPeriod(long pCostBearer, DateTime periodStart, DateTime periodEnd)
|
|
{
|
|
return new CustomerServiceImp()
|
|
.GetAllActiveSupportConceptsCompact()
|
|
.Where(i => i.IsApproved && i.CostBearerOids2CostBearerRelOids.ContainsKey(pCostBearer))
|
|
.Select(i => GenerateInitialSettlementDCForPeriod(i.CostBearerOids2CostBearerRelOids[pCostBearer], periodStart, periodEnd))
|
|
.ToList();
|
|
}
|
|
|
|
public List<AccountingTransactionDC> GetAccountingTransactions(DateTimeSpan pSpan, long? pSupportConceptOid, long? pSupportConceptCostBearerRelOid)
|
|
{
|
|
try
|
|
{
|
|
return MapperFactory.AccountingTransactionDC_AccountingTransaction.MapToNewDCs(DAOFactory.SearchDAO.FindAccoutingTransactions(pSpan, pSupportConceptOid, pSupportConceptCostBearerRelOid));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<InvoiceDC> GetAllActiveInvoices()
|
|
{
|
|
try
|
|
{
|
|
return MapperFactory.InvoiceDC_Invoice.MapToNewDCs(DAOFactory.GenericDAO.GetAllActive<Invoice>());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<CompactSupportConceptDC> GetAllActiveSupportConceptCostbearer(bool onlyApproved, bool onlyWithAssignedCostbearer, long employeeOid)
|
|
{
|
|
try
|
|
{
|
|
var s = PluginLoader.FindClass<CustomerService>();
|
|
|
|
return s.GetAllActiveSupportConceptCostbearer(onlyApproved, onlyWithAssignedCostbearer, employeeOid);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<AdditionalServiceDC> GetAllAdditionalService()
|
|
{
|
|
try
|
|
{
|
|
IList<AdditionalService> list = DAOFactory.GenericDAO.GetAllActive<AdditionalService>();
|
|
return MapperFactory.AdditionalServiceDC_AdditionalService.MapToNewDCs(list);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<AdditionalServiceRegionDC> GetAllAdditionalServiceRegion()
|
|
{
|
|
try
|
|
{
|
|
var result = new List<AdditionalServiceRegionDC>();
|
|
|
|
result =
|
|
MapperFactory.AdditionalServiceRegionDC_AdditionalServiceRegion.MapToNewDCs(
|
|
DAOFactory.GenericDAO.GetAllActive<AdditionalServiceRegion>());
|
|
|
|
return result;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ServiceCategoryDC> GetAllServiceCategories()
|
|
{
|
|
try
|
|
{
|
|
IList<ServiceCategory> list = DAOFactory.GenericDAO.GetAllActive<ServiceCategory>();
|
|
var dcList = MapperFactory.ServiceCategoryDC_ServiceCategory.MapToNewDCs(list);
|
|
|
|
//AppSettings settings = AppSettings.CreateSettings();
|
|
//if (settings.SortServiceDescriptionAlphabetically)
|
|
//{
|
|
// dcList = dcList.OrderBy(c => c.Name).ToList();
|
|
//}
|
|
//else
|
|
//{
|
|
dcList.Sort((a, b) =>
|
|
{
|
|
if (a.Position == b.Position)
|
|
{
|
|
return a.ServiceCategoryOid.Value.CompareTo(b.ServiceCategoryOid.Value);
|
|
}
|
|
else
|
|
{
|
|
return a.Position.CompareTo(b.Position);
|
|
}
|
|
});
|
|
//}
|
|
|
|
return dcList;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ServiceDescriptionDC> GetAllServiceDescriptions()
|
|
{
|
|
try
|
|
{
|
|
IList<ServiceDescription> list = DAOFactory.GenericDAO.GetAllActive<ServiceDescription>();
|
|
|
|
var dcList = MapperFactory.ServiceDescriptionDC_ServiceDescription.MapToNewDCs(list);
|
|
|
|
AppSettings settings = AppSettings.CreateSettings();
|
|
if (settings.SortServiceDescriptionAlphabetically)
|
|
{
|
|
dcList = dcList.OrderBy(sd => sd.Name).ToList();
|
|
}
|
|
else
|
|
{
|
|
dcList.Sort((a, b) =>
|
|
{
|
|
if (a.Position == b.Position)
|
|
{
|
|
return a.ServiceDescriptionOid.Value.CompareTo(b.ServiceDescriptionOid.Value);
|
|
}
|
|
else
|
|
{
|
|
return a.Position.CompareTo(b.Position);
|
|
}
|
|
});
|
|
}
|
|
|
|
return dcList;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ServiceDescriptionDC> FindServiceDescriptionsForCategory(long pCategoryOid)
|
|
{
|
|
try
|
|
{
|
|
return MapperFactory.ServiceDescriptionDC_ServiceDescription.MapToNewDCs(DAOFactory.SearchDAO.FindServiceDescriptionForCategory(pCategoryOid));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public ServiceDescriptionDC GetServiceDescription(long pServiceDescriptionOid)
|
|
{
|
|
try
|
|
{
|
|
return MapperFactory.ServiceDescriptionDC_ServiceDescription.MapToNewDC(DAOFactory.GenericDAO.GetByID<ServiceDescription>(pServiceDescriptionOid));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public string GetCompressedICD10Diagnosis()
|
|
{
|
|
try
|
|
{
|
|
return ICD10DAO.GetCompressedString();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public CustomerInfoDC GetCustomerInfosForCustomerOid(long customerOid)
|
|
{
|
|
try
|
|
{
|
|
var result = new CustomerInfoDC();
|
|
var customer = DAOFactory.GenericDAO.LoadByID<Customer>(customerOid);
|
|
|
|
if (customer.SupportConcepts == null || !customer.SupportConcepts.Exists(sc => sc.IsActive == ActivationTypeId.Active))
|
|
{
|
|
result.CurrentSupportConcept = "Kein aktueller Hilfeplan";
|
|
}
|
|
else
|
|
{
|
|
SupportConcept currentSC = customer.SupportConcepts.Where(sc => sc.IsActive == ActivationTypeId.Active).OrderByDescending(sc => sc.StartDate).First();
|
|
|
|
result.CurrentSupportConcept = "Akt. HP: ";
|
|
if (currentSC.StartDate.HasValue)
|
|
{
|
|
result.CurrentSupportConcept += currentSC.StartDate.Value.ToShortDateString().Remove(6, 2);
|
|
}
|
|
|
|
if (currentSC.EndDate.HasValue)
|
|
{
|
|
result.CurrentSupportConcept += " - " + currentSC.EndDate.Value.ToShortDateString().Remove(6, 2);
|
|
}
|
|
|
|
result.SupportConceptInfos = GetSupportConceptInfosForSupportConceptOid(currentSC.Oid.Value);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ServiceRecordDC> GetCustomerServiceRecordsCompact(long pCustomerOid, long costbearer2SupportConceptOid, long? days)
|
|
{
|
|
try
|
|
{
|
|
var result = new List<ServiceRecordDC>();
|
|
var srList = DAOFactory.SearchDAO.FindServiceRecordsDetailsForLastDays(costbearer2SupportConceptOid, days);
|
|
|
|
if (srList != null)
|
|
{
|
|
var serviceRecordsProcessed = new Dictionary<long, bool>();
|
|
foreach (var item in srList)
|
|
{
|
|
if (!serviceRecordsProcessed.ContainsKey(item.Oid.Value))
|
|
{
|
|
//ServiceRecordDC dc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(item);
|
|
//result.Add(dc);
|
|
var dc = CreateServiceRecordDCCompact(item);
|
|
if (dc != null)
|
|
{
|
|
result.Add(dc);
|
|
}
|
|
|
|
serviceRecordsProcessed.Add(item.Oid.Value, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ServiceRecordDC> GetCustomerServiceRecords(long pCustomerOid, bool fetchArchivedSupportConcepts)
|
|
{
|
|
try
|
|
{
|
|
var result = new List<ServiceRecordDC>();
|
|
|
|
var lCustomer = DAOFactory.SearchDAO.FindCustomerWithServiceRecordsWithDetail(pCustomerOid);
|
|
if (lCustomer != null)
|
|
{
|
|
var srList = lCustomer.ServiceRecordList;
|
|
|
|
if (srList != null)
|
|
{
|
|
var serviceRecordsProcessed = new Dictionary<long, bool>();
|
|
foreach (var item in srList)
|
|
{
|
|
if (!serviceRecordsProcessed.ContainsKey(item.Oid.Value))
|
|
{
|
|
var dc = CreateServiceRecordDCIfSupportConceptIsActive(item, lCustomer, !fetchArchivedSupportConcepts);
|
|
if (dc != null)
|
|
{
|
|
result.Add(dc);
|
|
}
|
|
|
|
serviceRecordsProcessed.Add(item.Oid.Value, true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ServiceRecordDC> GetCustomerServiceRecordsInMonth(long pCustomerOid, DateTime pMonth)
|
|
{
|
|
try
|
|
{
|
|
var list = GetCustomerServiceRecords(pCustomerOid, false);
|
|
|
|
return list.Where(i => i.Start.HasValue && i.Start.Value.Year.Equals(pMonth.Year) && i.Start.Value.Month.Equals(pMonth.Month)).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ServiceRecordDC> GetEmployeesServiceRecords(long pEmployeeOid)
|
|
{
|
|
try
|
|
{
|
|
IEnumerable<ServiceRecord> list = DAOFactory.SearchDAO.FindEmployeeServiceRecordsWithoutCustomer(pEmployeeOid, null);
|
|
|
|
return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(list);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ServiceRecordDC> GetEmployeesServiceRecords2(long pEmployeeOid, long? days)
|
|
{
|
|
try
|
|
{
|
|
IEnumerable<ServiceRecord> list = DAOFactory.SearchDAO.FindEmployeeServiceRecordsWithoutCustomer(pEmployeeOid, days);
|
|
|
|
return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(list);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ServiceRecordDC> GetEmployeesServiceRecordsWithStartEndDate(long pEmployeeOid, DateTime start, DateTime ende)
|
|
{
|
|
try
|
|
{
|
|
IEnumerable<ServiceRecord> list = DAOFactory.SearchDAO.FindEmployeeServiceRecordsWithoutCustomerWithStartEndDate(pEmployeeOid, start, ende);
|
|
|
|
return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(list);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ServiceRecordDC> GetCustomerServiceRecordsCompactWithStartEndDate(long pCustomerOid, long costbearer2SupportConceptOid, DateTime start, DateTime ende)
|
|
{
|
|
try
|
|
{
|
|
var result = new List<ServiceRecordDC>();
|
|
var srList = DAOFactory.SearchDAO.FindServiceRecordsDetailsForLastDaysWithStartEndDate(costbearer2SupportConceptOid, start, ende);
|
|
|
|
if (srList != null)
|
|
{
|
|
var serviceRecordsProcessed = new Dictionary<long, bool>();
|
|
foreach (var item in srList)
|
|
{
|
|
if (!serviceRecordsProcessed.ContainsKey(item.Oid.Value))
|
|
{
|
|
//ServiceRecordDC dc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(item);
|
|
//result.Add(dc);
|
|
var dc = CreateServiceRecordDCCompact(item);
|
|
if (dc != null)
|
|
{
|
|
result.Add(dc);
|
|
}
|
|
|
|
serviceRecordsProcessed.Add(item.Oid.Value, true);
|
|
}
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ServiceRecordDC> GetEmployeesServiceRecordsInSpan(long pEmployeeOid, DateTimeSpan limitinDateTimeSpan)
|
|
{
|
|
try
|
|
{
|
|
IEnumerable<ServiceRecord> list = DAOFactory.SearchDAO.FindEmployeeServiceRecordsWithoutCustomerInSpan(pEmployeeOid, limitinDateTimeSpan);
|
|
|
|
return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(list);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<FileAttachmentDC> GetFileAttachments(TableID pObjectTid, long pObjectOid)
|
|
{
|
|
try
|
|
{
|
|
var files = DAOFactory.SearchDAO.FindFileAttachmentInfos(pObjectTid, pObjectOid).ToList();
|
|
|
|
var fileAttachments = files.Select(item => MapperFactory.FileAttachmentDC_FileAttachmentInfo.MapToNewDC(item)).ToList();
|
|
|
|
fileAttachments.DoForEach(fileAttachment =>
|
|
{
|
|
if(fileAttachment.BinaryData != null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
fileAttachment.BinaryData = FileAttachmentUtils.LoadFileFromDirectory(fileAttachment.FileAttachmentOid);
|
|
});
|
|
|
|
return fileAttachments;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<BeWoFolderDC> GetFolderTree(TableID pObjectTid, long pObjectOid)
|
|
{
|
|
try
|
|
{
|
|
return DokumentManager.GetFolderTree(pObjectTid, pObjectOid);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteFolder(long pBeWoFolderOid, long pVersion)
|
|
{
|
|
try
|
|
{
|
|
DokumentManager.DeleteFolder(pBeWoFolderOid, pVersion);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public long InsertNewFolder(BeWoFolderDC folder)
|
|
{
|
|
try
|
|
{
|
|
return DokumentManager.InsertNewFolder(folder);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public BeWoFolderDC UpdateFolder(BeWoFolderDC folder)
|
|
{
|
|
try
|
|
{
|
|
return DokumentManager.UpdateFolder(folder);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public FileAttachmentDC UpdateFileAttachment(FileAttachmentDC file)
|
|
{
|
|
try
|
|
{
|
|
return DokumentManager.UpdateFileAttachment(file);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public FileAttachmentDC DoTheRealFileUpdate(FileAttachmentDC file)
|
|
{
|
|
try
|
|
{
|
|
return DokumentManager.DoTheRealFileUpdate(file);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public MandatorDC GetMandator()
|
|
{
|
|
return GetMandator2(true);
|
|
}
|
|
|
|
public MandatorDC GetMandator2(bool fetchContractState)
|
|
{
|
|
try
|
|
{
|
|
Mandator man = GetMandatorEntity();
|
|
MandatorDC manDc = MapperFactory.MandatorDC_Mandator.MapToNewDC(man);
|
|
|
|
Dictionary<string, string> settingValueDict = GetSettingsValueDict(manDc.Settings);
|
|
|
|
if (fetchContractState)
|
|
{
|
|
string contractState = GetContractState();
|
|
Dictionary<string, string> contractStateDict = GetSettingsValueDict(contractState);
|
|
|
|
foreach (var kv in contractStateDict)
|
|
{
|
|
if (settingValueDict.ContainsKey(kv.Key))
|
|
{
|
|
settingValueDict.Remove(kv.Key);
|
|
}
|
|
|
|
settingValueDict.Add(kv.Key, kv.Value);
|
|
}
|
|
}
|
|
|
|
if (!settingValueDict.ContainsKey("ShowScheduler") && man.IsSchedulerAllowed)
|
|
{
|
|
settingValueDict.Add("ShowScheduler", "1");
|
|
}
|
|
|
|
if (!settingValueDict.ContainsKey("ShowMedication") && man.IsMedicationAllowed)
|
|
{
|
|
settingValueDict.Add("ShowMedication", "1");
|
|
}
|
|
|
|
if (!settingValueDict.ContainsKey("ShowDistanceFields") && settingValueDict.ContainsKey("ShowKilometer"))
|
|
{
|
|
if (settingValueDict["ShowKilometer"] != "0")
|
|
{
|
|
settingValueDict.Add("ShowDistanceFields", "1");
|
|
}
|
|
}
|
|
if (!settingValueDict.ContainsKey("EinheitZeiterfassung") && settingValueDict.ContainsKey("IsZeiterfassungInStdMin"))
|
|
{
|
|
if (settingValueDict["IsZeiterfassungInStdMin"] == "1")
|
|
{
|
|
settingValueDict.Add("EinheitZeiterfassung", "2");
|
|
}
|
|
}
|
|
|
|
manDc.Settings = "";
|
|
|
|
|
|
foreach (var kv in settingValueDict)
|
|
{
|
|
if (manDc.Settings.Length > 0)
|
|
{
|
|
manDc.Settings += ";";
|
|
}
|
|
|
|
manDc.Settings += String.Format("{0}={1}", kv.Key, kv.Value);
|
|
}
|
|
|
|
return manDc;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ServiceRecordHistoryDC> GetServiceRecordHistory(long serviceRecordOid)
|
|
{
|
|
try
|
|
{
|
|
IEnumerable<ServiceRecordHistory> historyList = DAOFactory.SearchDAO.FindServiceRecordHistory(serviceRecordOid);
|
|
|
|
List<ServiceRecordHistoryDC> result = MapperFactory.ServiceRecordHistoryDC_ServiceRecordHistory.MapToNewDCs(historyList);
|
|
foreach (var srh in result)
|
|
{
|
|
if (srh.DurationInStunden.HasValue && srh.DurationInStunden.Value == ZeiterfassungsDauer.Stunden)
|
|
{
|
|
srh.RoundedDuration = srh.RoundedDuration / 60;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public ServiceRecordGroupDC GetServiceRecordGroup(long pGroupOid)
|
|
{
|
|
try
|
|
{
|
|
ServiceRecordGroup group = DAOFactory.SearchDAO.FindServiceRecordGroup(pGroupOid);
|
|
|
|
ServiceRecordGroupDC groupDC = MapperFactory.ServiceRecordGroupDC_ServiceRecordGroup.MapToNewDC(group);
|
|
|
|
var result = new List<ServiceRecordDC>();
|
|
|
|
var serviceRecordsProcessed = new Dictionary<long, bool>();
|
|
foreach (ServiceRecord item in group.ServiceRecordList)
|
|
{
|
|
if (!serviceRecordsProcessed.ContainsKey(item.Oid.Value))
|
|
{
|
|
var dc = new ServiceRecordDC();
|
|
|
|
dc.ServiceRecordOid = item.Oid;
|
|
dc.ServiceRecordVersion = item.Version;
|
|
dc.Start = item.Start;
|
|
dc.End = item.End;
|
|
dc.Notice = item.Notice;
|
|
dc.Notice2 = item.Notice2;
|
|
dc.Notice3 = item.Notice3;
|
|
dc.Notice4 = item.Notice4;
|
|
dc.Notice5 = item.Notice5;
|
|
dc.RoundedDuration = item.RoundedDuration;
|
|
dc.InsertedOn = item.InsTs;
|
|
dc.InsUser = item.InsUser;
|
|
|
|
dc.DurationInStunden = item.DurationInStunden;
|
|
dc.ServiceRecordFormat = item.ServiceRecordFormat;
|
|
|
|
CompactCustomerDC customerDC = null;
|
|
if (item.Customer != null)
|
|
{
|
|
customerDC = new CompactCustomerDC();
|
|
|
|
customerDC.CustomerOid = item.Customer.Oid.Value;
|
|
customerDC.CustomerVersion = item.Customer.Version.Value;
|
|
customerDC.FirstName = item.Customer.Person.FirstName;
|
|
customerDC.LastName = item.Customer.Person.LastName;
|
|
customerDC.DateOfBirth = item.Customer.Person.DateOfBirth;
|
|
customerDC.Sex = item.Customer.Person.Sex;
|
|
customerDC.ActivationType = item.Customer.IsActive;
|
|
customerDC.TerminationDate = item.Customer.TerminationDate;
|
|
customerDC.EquityContribution = item.Customer.EquityContribution;
|
|
}
|
|
|
|
dc.Customer = customerDC;
|
|
if (item.Employee != null)
|
|
{
|
|
var employeeDC = new CompactEmployeeDC();
|
|
|
|
employeeDC.EmployeeOid = item.Employee.Oid.Value;
|
|
employeeDC.EmployeeVersion = item.Employee.Version.Value;
|
|
employeeDC.FirstName = item.Employee.Person.FirstName;
|
|
employeeDC.LastName = item.Employee.Person.LastName;
|
|
employeeDC.PersonnelNumber = item.Employee.PersonnelNumber;
|
|
//employeeDC.FLSPerWeek = item.Employee.WeeklyFLS;
|
|
|
|
dc.Employee = employeeDC;
|
|
}
|
|
|
|
CompactSupportConceptDC scDC = null;
|
|
if (item.SupportConcept != null)
|
|
{
|
|
scDC = new CompactSupportConceptDC();
|
|
|
|
scDC.SupportConceptOid = item.SupportConcept.Oid.Value;
|
|
scDC.SupportConceptVersion = item.SupportConcept.Version.Value;
|
|
scDC.Customer = customerDC;
|
|
scDC.ActivationType = item.SupportConcept.IsActive;
|
|
scDC.ConferenceDate = item.SupportConcept.ConferenceDate;
|
|
}
|
|
|
|
dc.SupportConcept = scDC;
|
|
|
|
CostBearer2SupportConcept cb2sc = item.CostBearer2SupportConcept;
|
|
if (cb2sc != null)
|
|
{
|
|
dc.CostBearer2SupportConceptOid = cb2sc.Oid.Value;
|
|
|
|
if (scDC != null)
|
|
{
|
|
var costBearer = new CompactCostBearerDC();
|
|
|
|
costBearer.IsCalculatingWithFactor = cb2sc.CostBearer.IsCalculatingWithFactor;
|
|
costBearer.CostBearerID = cb2sc.CostBearer.ID;
|
|
costBearer.CostBearerOid = cb2sc.CostBearer.Oid.Value;
|
|
costBearer.CostBearer2SupportConceptOid = cb2sc.Oid.Value;
|
|
costBearer.SupportConceptStatus = cb2sc.Status;
|
|
costBearer.RequestedStartDate = cb2sc.RequestedStartDate;
|
|
costBearer.RequestedEndDate = cb2sc.RequestedEndDate;
|
|
costBearer.ApprovedStartDate = cb2sc.ApprovedStartDate;
|
|
costBearer.ApprovedEndDate = cb2sc.ApprovedEndDate;
|
|
|
|
// costBearer.ApprovedFLS = cb2sc.ApprovedFLS;
|
|
// costBearer.ApprovedFLSTotal = cb2sc.ApprovedFLSTotal;
|
|
costBearer.CustomerReferenceNumber = cb2sc.CustomerReferenceNumber;
|
|
|
|
if (cb2sc.CostBearer.Organisation != null)
|
|
{
|
|
CompactOrganisationDC orgDC = MapperFactory.CompactOrganisationDC_Organisation.MapToNewDC(cb2sc.CostBearer.Organisation);
|
|
|
|
costBearer.Organisation = orgDC;
|
|
|
|
dc.CostBearer = orgDC;
|
|
}
|
|
|
|
scDC.CostBearerList.Add(costBearer);
|
|
scDC.CustomerReferenceNumbers.Add(cb2sc.CustomerReferenceNumber);
|
|
scDC.CostBearerRelOids.Add(cb2sc.Oid.Value);
|
|
}
|
|
}
|
|
|
|
dc.GroupEmployeeCount = item.GroupEmployeeCount;
|
|
dc.GroupPersonCount = item.GroupPersonCount;
|
|
dc.GroupRoundedDuration = item.GroupRoundedDuration;
|
|
dc.GroupOid = item.GroupOid;
|
|
dc.SignatureOid = item.SignatureOid;
|
|
|
|
result.Add(dc);
|
|
|
|
serviceRecordsProcessed.Add(item.Oid.Value, true);
|
|
}
|
|
}
|
|
|
|
groupDC.ServiceRecordList = result;
|
|
|
|
return groupDC;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public long GetLastServiceRecordGroupOid()
|
|
{
|
|
var sc = DAOFactory.GenericDAO.GetAllActiveAndArchived<ServiceRecordGroup>();
|
|
|
|
long x = sc.Last().Oid.Value;
|
|
|
|
return x;
|
|
}
|
|
|
|
public List<SupportConcetInfoDC> GetSupportConceptInfosForSupportConceptOid(long supportConceptOid)
|
|
{
|
|
try
|
|
{
|
|
var sc = DAOFactory.GenericDAO.LoadByID<SupportConcept>(supportConceptOid);
|
|
return sc.CostBearer2SupportConceptList.Select(
|
|
cb2sc =>
|
|
{
|
|
Calculations calc = PluginLoader.FindClass<Calculations>(cb2sc.CostBearer.ID) ?? Calculations.GetInstance(cb2sc.CostBearer.ID);
|
|
var res = new SupportConcetInfoDC
|
|
{
|
|
CostBearer = cb2sc.CostBearer.Organisation.Name,
|
|
ApprovedHours = calc.GetApprovedHoursTotal(cb2sc.MapToNewDC(), true) ?? 0m,
|
|
RecordedHours = calc.GetBillableDurationInMinutes(cb2sc.ServiceRecords.MapToNewDCsCompact()) / 60
|
|
};
|
|
|
|
// if (cb2sc.ApprovedStartDate.HasValue && cb2sc.ApprovedEndDate.HasValue)
|
|
// {
|
|
// decimal lDurationInWeeks = Convert.ToDecimal((cb2sc.ApprovedEndDate.Value - cb2sc.ApprovedStartDate.Value).Days + 1) / 7;
|
|
|
|
// if (cb2sc.ApprovedFLSTotal == null)
|
|
// {
|
|
// if (cb2sc.ApprovedFLS.HasValue)
|
|
// {
|
|
// res.ApprovedHours = cb2sc.ApprovedFLS.Value * lDurationInWeeks;
|
|
// }
|
|
// }
|
|
// else
|
|
// {
|
|
// res.ApprovedHours = cb2sc.ApprovedFLSTotal.Value;
|
|
// }
|
|
// }
|
|
|
|
// res.RecordedHours = 0;
|
|
// if (cb2sc.ServiceRecords != null)
|
|
// {
|
|
// foreach (var sr in cb2sc.ServiceRecords)
|
|
// {
|
|
// if (sr.ServiceDescription != null && sr.ServiceDescription.ServiceCategory != null && sr.ServiceDescription.ServiceCategory.IsBillable)
|
|
// {
|
|
// decimal rd = sr.RoundedDuration;
|
|
|
|
// if (sr.ServiceDescription.ServiceCategory.Percentage != 100)
|
|
// {
|
|
// rd = (rd * sr.ServiceDescription.ServiceCategory.Percentage) / 100;
|
|
// }
|
|
|
|
// res.RecordedHours += rd;
|
|
// }
|
|
// }
|
|
// }
|
|
|
|
// res.RecordedHours /= 60;
|
|
return res;
|
|
}).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<SupportConceptTreeNodeDC> GetSupportConceptTreeAllActive()
|
|
{
|
|
try
|
|
{
|
|
return BuildTree(DAOFactory.GenericDAO.GetAllActiveAndArchived<SupportConcept>());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<SupportConceptTreeNodeDC> GetSupportConceptTreeAllActiveWithCostbearer()
|
|
{
|
|
try
|
|
{
|
|
return BuildTree(DAOFactory.GenericDAO.GetAllActive<SupportConcept>().Where(sc => sc.CostBearer2SupportConceptList.Count > 0));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<SupportConceptTreeNodeDC> GetSupportConceptTreeAllCurrent()
|
|
{
|
|
try
|
|
{
|
|
return BuildTree(DAOFactory.SearchDAO.FindCurrentSupportConcepts());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<SupportConceptTreeNodeDC> GetSupportConceptTreeByEmployee(long pEmployeeOid)
|
|
{
|
|
try
|
|
{
|
|
var s = PluginLoader.FindClass<CustomerService>();
|
|
|
|
return s.GetSupportConceptTreeByEmployee(pEmployeeOid);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<SupportConceptTreeNodeDC> GetSupportConceptTreeInSpan(DateTimeSpan pSpan)
|
|
{
|
|
try
|
|
{
|
|
return BuildTree(DAOFactory.SearchDAO.FindSupportConceptsInSpan(pSpan));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public SupportConceptTreeNodeDetailInfoDC GetSupportConceptTreeNodeDetailInfo(long pCustomerOid, long? pSupportConceptOid, long? pCostbearer2SupportConceptOid)
|
|
{
|
|
try
|
|
{
|
|
var dc = new SupportConceptTreeNodeDetailInfoDC();
|
|
|
|
var customer = DAOFactory.GenericDAO.LoadByID<Customer>(pCustomerOid);
|
|
|
|
dc.CustomerAbsenceTimes = MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewDCs(customer.AbsenceTimes);
|
|
|
|
if (pSupportConceptOid != null)
|
|
{
|
|
var sc = DAOFactory.GenericDAO.LoadByID<SupportConcept>(pSupportConceptOid.Value);
|
|
|
|
var list = new List<ValueListEntryType>();
|
|
list.Add(ValueListEntryType.SupportConceptGoalType);
|
|
list.Add(ValueListEntryType.SupportConceptGoalCategoryType);
|
|
list.Add(ValueListEntryType.SupportConceptIndividualGoalCategoryType);
|
|
list.Add(ValueListEntryType.SupportConceptIndividualGoalType);
|
|
|
|
dc.SupportConceptGoals =
|
|
MapperFactory.ValueListEntryDC_ValueListEntry.MapToNewDCs(
|
|
sc.ValueList.FindByTypes(list)
|
|
.Select(e2o => e2o.Entry)
|
|
.Where(e => e.IsActive == ActivationTypeId.Active));
|
|
|
|
dc.ServiceAccountings = MapperFactory.ServiceAccountingDC_ServiceAccounting.MapToNewDCs(sc.ServiceAccountings);
|
|
}
|
|
|
|
if (pCostbearer2SupportConceptOid != null)
|
|
{
|
|
var c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(pCostbearer2SupportConceptOid.Value);
|
|
dc.ApprovalPeriods = MapperFactory.SupportConceptApprovalPeriodDC_SupportConceptApprovalPeriod.MapToNewDCs(c2s.ApprovalPeriodList);
|
|
if (dc.ApprovalPeriods != null)
|
|
{
|
|
foreach (SupportConceptApprovalPeriodDC item in dc.ApprovalPeriods)
|
|
{
|
|
if (!item.StartDate.HasValue)
|
|
{
|
|
item.StartDate = c2s.ApprovedStartDate.HasValue ? c2s.ApprovedStartDate : c2s.RequestedStartDate;
|
|
}
|
|
|
|
if (!item.EndDate.HasValue)
|
|
{
|
|
item.EndDate = c2s.ApprovedEndDate.HasValue ? c2s.ApprovedEndDate : c2s.RequestedEndDate;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return dc;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public CompactOrganisationDC FillCostbearerDetails(CompactOrganisationDC dc)
|
|
{
|
|
try
|
|
{
|
|
if (dc.CostRatePeriods == null || dc.CostRatePeriods.Count == 0)
|
|
{
|
|
var org = DAOFactory.GenericDAO.LoadByID<Organisation>(dc.OrganisationOid);
|
|
if (org != null)
|
|
{
|
|
MapperFactory.CompactOrganisationDC_Organisation.MergeWithDC(org, dc);
|
|
}
|
|
}
|
|
|
|
return dc;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<AccountingTransactionDC> GetUnassignedAccountingTransactions()
|
|
{
|
|
try
|
|
{
|
|
IEnumerable<AccountingTransaction> list = DAOFactory.SearchDAO.FindUnassignedAccountingTransactions();
|
|
|
|
return MapperFactory.AccountingTransactionDC_AccountingTransaction.MapToNewDCs(list);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<VarFieldDC> GetVarFieldDefs(TableID tid)
|
|
{
|
|
try
|
|
{
|
|
return MapperFactory.VarFieldDC_VarField.VarFieldMapToDCs(DAOFactory.SearchDAO.GetVarFieldDefs(tid), null);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<long> InsertNewAccountingTransactions(List<AccountingTransactionDC> pAccountingTransactions)
|
|
{
|
|
try
|
|
{
|
|
foreach (var at in pAccountingTransactions)
|
|
{
|
|
if (at.SupportConceptCostBearerRelDC != null && at.SupportConceptCostBearerRelDC.CostBearer2SupportConceptOid.HasValue && !at.SupportConceptCostBearerRelDC.CostBearer2SupportConceptVersion.HasValue)
|
|
{
|
|
var c2s = DAOFactory.GenericDAO.LoadByID<CostBearer2SupportConcept>(at.SupportConceptCostBearerRelDC.CostBearer2SupportConceptOid.Value);
|
|
var c2sDc = MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(c2s);
|
|
at.SupportConceptCostBearerRelDC = c2sDc;
|
|
}
|
|
|
|
}
|
|
|
|
List<AccountingTransaction> lEntities = MapperFactory.AccountingTransactionDC_AccountingTransaction.MapToNewEntities(pAccountingTransactions);
|
|
DAOFactory.GenericDAO.Insert(lEntities);
|
|
return lEntities.Select(e => e.Oid.Value).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void InsertNewInvoices(List<InvoiceDC> pInvoices)
|
|
{
|
|
try
|
|
{
|
|
DAOFactory.GenericDAO.Insert(MapperFactory.InvoiceDC_Invoice.MapToNewEntities(pInvoices));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<long> InsertNewServiceCategories(List<ServiceCategoryDC> pServiceCategories)
|
|
{
|
|
try
|
|
{
|
|
List<ServiceCategory> lServiceCategories = MapperFactory.ServiceCategoryDC_ServiceCategory.MapToNewEntities(pServiceCategories);
|
|
DAOFactory.GenericDAO.Insert(lServiceCategories);
|
|
return lServiceCategories.Select(sc => sc.Oid.Value).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<long> InsertNewAdditionalServices(IEnumerable<AdditionalServiceDC> pAdditionalServiceDcs)
|
|
{
|
|
try
|
|
{
|
|
List<AdditionalService> lAdditionalServices = MapperFactory.AdditionalServiceDC_AdditionalService.MapToNewEntities(pAdditionalServiceDcs);
|
|
DAOFactory.GenericDAO.Insert(lAdditionalServices);
|
|
return lAdditionalServices.Select(ads => ads.Oid.Value).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<long> InsertNewServiceDescriptions(List<ServiceDescriptionDC> pServiceDescriptions)
|
|
{
|
|
try
|
|
{
|
|
List<ServiceDescription> lServiceDescriptions = MapperFactory.ServiceDescriptionDC_ServiceDescription.MapToNewEntities(pServiceDescriptions);
|
|
DAOFactory.GenericDAO.Insert(lServiceDescriptions);
|
|
IList<SupportConcept> scToSave = new List<SupportConcept>();
|
|
//Prüfe ob es HPs gibt wo die Leistung hinterlegt werden muss
|
|
|
|
IList<long> newServiceDescriptionOids = new List<long>();
|
|
foreach (ServiceDescription newSd in lServiceDescriptions)
|
|
{
|
|
newServiceDescriptionOids.Add(newSd.Oid.Value);
|
|
}
|
|
|
|
foreach (ServiceDescription newSd in lServiceDescriptions)
|
|
{
|
|
ServiceCategory cat = newSd.ServiceCategory;
|
|
|
|
IEnumerable<ServiceDescription> descList = DAOFactory.SearchDAO.FindServiceDescriptionForCategory(cat.Oid.Value);
|
|
|
|
IList<long> oids = new List<long>();
|
|
foreach (ServiceDescription oldSd in descList)
|
|
{
|
|
if (!newServiceDescriptionOids.Contains(oldSd.Oid.Value))
|
|
{
|
|
oids.Add(oldSd.Oid.Value);
|
|
}
|
|
}
|
|
|
|
//Prüfe für alle Leistungen dieser Kategorie, ob sie im Hilfeplan angehakt wurden
|
|
IEnumerable<ServiceAccounting> accountingList = DAOFactory.SearchDAO.FindServiceAccountingsForServiceDescriptions(oids);
|
|
|
|
var supportConceptCountDict = new Dictionary<long, int>();
|
|
foreach (ServiceAccounting acc in accountingList)
|
|
{
|
|
if (acc.SupportConceptOid.HasValue)
|
|
{
|
|
if (supportConceptCountDict.ContainsKey(acc.SupportConceptOid.Value))
|
|
{
|
|
supportConceptCountDict[acc.SupportConceptOid.Value]++;
|
|
}
|
|
else
|
|
{
|
|
supportConceptCountDict.Add(acc.SupportConceptOid.Value, 1);
|
|
}
|
|
}
|
|
}
|
|
|
|
IList<long> supportConceptToUpdateOids = new List<long>();
|
|
foreach (var pair in supportConceptCountDict)
|
|
{
|
|
if (pair.Value == oids.Count)
|
|
{
|
|
//Wenn es für alle alten Leistungen eine ServiceAccounting gibt, füge die neue Leistung auch hinzu
|
|
supportConceptToUpdateOids.Add(pair.Key);
|
|
}
|
|
}
|
|
|
|
foreach (long scOid in supportConceptToUpdateOids)
|
|
{
|
|
var sc = DAOFactory.GenericDAO.LoadByID<SupportConcept>(scOid);
|
|
var newSa = new ServiceAccounting();
|
|
newSa.ServiceDescription = newSd;
|
|
|
|
sc.ServiceAccountings.Add(newSa);
|
|
|
|
scToSave.Add(sc);
|
|
}
|
|
}
|
|
|
|
if (scToSave.Count > 0)
|
|
{
|
|
DAOFactory.GenericDAO.Insert(scToSave);
|
|
}
|
|
|
|
|
|
return lServiceDescriptions.Select(sd => sd.Oid.Value).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<long> InsertNewAdditionalServiceRegions(List<AdditionalServiceRegionDC> pAdditionalServiceRegions)
|
|
{
|
|
try
|
|
{
|
|
List<AdditionalServiceRegion> lAdditionalServiceRegions = MapperFactory.AdditionalServiceRegionDC_AdditionalServiceRegion.MapToNewEntities(pAdditionalServiceRegions);
|
|
DAOFactory.GenericDAO.Insert(lAdditionalServiceRegions);
|
|
return lAdditionalServiceRegions.Select(asr => asr.Oid.Value).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public long InsertNewAdditionalServiceRegion(AdditionalServiceRegionDC pAdditionalServiceRegionDC)
|
|
{
|
|
try
|
|
{
|
|
AdditionalServiceRegion lAdditionalServiceRegion = MapperFactory.AdditionalServiceRegionDC_AdditionalServiceRegion.MapToNewEntity(pAdditionalServiceRegionDC);
|
|
DAOFactory.GenericDAO.Insert(lAdditionalServiceRegion);
|
|
return lAdditionalServiceRegion.Oid.Value;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public AdditionalServiceRegionDC GetAdditionalServiceRegion(long pRegionOid)
|
|
{
|
|
try
|
|
{
|
|
return MapperFactory.AdditionalServiceRegionDC_AdditionalServiceRegion.MapToNewDC(DAOFactory.GenericDAO.GetByID<AdditionalServiceRegion>(pRegionOid));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public ServiceRecordGroupDC InsertNewServiceRecordGroup(ServiceRecordGroupDC pServiceRecordGroup)
|
|
{
|
|
try
|
|
{
|
|
var group = MapperFactory.ServiceRecordGroupDC_ServiceRecordGroup.MapToNewEntity(pServiceRecordGroup);
|
|
var lServiceRecords = new List<ServiceRecord>();
|
|
|
|
if (pServiceRecordGroup.ServiceRecordList != null && pServiceRecordGroup.ServiceRecordList.Count > 0)
|
|
{
|
|
lServiceRecords = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewEntities(pServiceRecordGroup.ServiceRecordList);
|
|
|
|
foreach (var iServiceRecord in lServiceRecords)
|
|
{
|
|
if (!group.StartDate.HasValue && group.EndDate.HasValue)
|
|
{
|
|
group.StartDate = group.EndDate.Value.AddMinutes((double)group.RoundedDuration * -1);
|
|
}
|
|
|
|
if (group.StartDate.HasValue && group.EndDate.HasValue)
|
|
{
|
|
//Korrigieren
|
|
if (group.StartDate.Value == group.EndDate.Value)
|
|
{
|
|
if (iServiceRecord.RoundedDuration > 0)
|
|
{
|
|
group.EndDate = group.StartDate.Value.AddMinutes((double)iServiceRecord.RoundedDuration);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (group.StartDate.HasValue)
|
|
{
|
|
iServiceRecord.Start = group.StartDate;
|
|
}
|
|
|
|
if (group.EndDate.HasValue)
|
|
{
|
|
iServiceRecord.End = group.EndDate;
|
|
}
|
|
|
|
//if(group.RoundedDuration == 0)
|
|
//{
|
|
if (group.EndDate.HasValue && group.StartDate.HasValue)
|
|
{
|
|
var minutes = group.EndDate.Value.Subtract(group.StartDate.Value).TotalMinutes;
|
|
|
|
group.RoundedDuration = (decimal)minutes;
|
|
}
|
|
//}
|
|
|
|
//if(!iServiceRecord.GroupRoundedDuration.HasValue || iServiceRecord.GroupRoundedDuration.Value == 0)
|
|
//{
|
|
iServiceRecord.GroupRoundedDuration = group.RoundedDuration;
|
|
//}
|
|
|
|
if (iServiceRecord.IP == null)
|
|
{
|
|
iServiceRecord.IP = Utils.GetClientIP();
|
|
}
|
|
|
|
// iServiceRecord.Group = group;
|
|
}
|
|
|
|
group.ServiceRecordList = lServiceRecords;
|
|
|
|
|
|
var gdc = PluginLoader.FindClass<GroupDurationCalculator>();
|
|
|
|
gdc?.CalculateGroupDuration(@group);
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Insert(group);
|
|
|
|
if (lServiceRecords.Count > 0)
|
|
{
|
|
MakeServiceRecordHistoryEntry(lServiceRecords, lServiceRecords.Select(sr => sr.Oid.Value).ToList(), StatementType.Insert);
|
|
}
|
|
|
|
var newGroupDC = MapperFactory.ServiceRecordGroupDC_ServiceRecordGroup.MapToNewDC(group);
|
|
|
|
newGroupDC.ServiceRecordList = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(group.ServiceRecordList);
|
|
|
|
return newGroupDC;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteAdditionalServiceGroupOfPeopleRelation(long pOid, long pVersion)
|
|
{
|
|
try
|
|
{
|
|
DeleteAdditionalServiceGroupOfPeopleRelations(new Dictionary<long, long> { { pOid, pVersion } });
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteAdditionalServiceBookings(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
List<AdditionalServiceBooking> lOriginals =
|
|
DAOFactory.GenericDAO.LoadByIDs<AdditionalServiceBooking>(pOid2Version.Select(e => e.Key));
|
|
lOriginals.DoForEach(or => MapperFactory.AdditionalServiceBookingDC_AdditionalServiceBooking.ConcurrencyCheck(pOid2Version[or.Oid.Value], or));
|
|
|
|
List<AdditionalServiceBooking> asbListToDelete = lOriginals.ToList();
|
|
if (asbListToDelete.Count <= 0)
|
|
return;
|
|
|
|
DAOFactory.GenericDAO.Delete(asbListToDelete);
|
|
|
|
IList<AssessmentSheetEntry> allEntries = DAOFactory.GenericDAO.GetAll<AssessmentSheetEntry>();
|
|
var entries2Delete = new List<AssessmentSheetEntry>();
|
|
|
|
foreach (AdditionalServiceBooking item in lOriginals)
|
|
{
|
|
entries2Delete.AddRange(allEntries.Where(e => pOid2Version.ContainsKey(e.Customer.Oid.Value) &&
|
|
e.Day.Equals(item.Datum.Value) &&
|
|
e.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet)).ToList());
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Delete(entries2Delete);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateAdditionalServiceGroupOfPeopleRelations(List<AdditionalServiceGroupOfPeopleRelationDC> pAdditionalServiceGroupOfPeopleRelations)
|
|
{
|
|
try
|
|
{
|
|
List<AdditionalService2GroupOfPeople> lOriginals = DAOFactory.GenericDAO.LoadByIDs<AdditionalService2GroupOfPeople>(pAdditionalServiceGroupOfPeopleRelations.Select(dc => dc.AdditionalService2GroupOfPeopleOid.Value));
|
|
MapperFactory.AdditionalServiceGroupOfPeopleRelationDC_AdditionalService2GroupOfPeople.MergeWithEntitys(pAdditionalServiceGroupOfPeopleRelations, lOriginals);
|
|
DAOFactory.GenericDAO.Update(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateAdditionalServiceBookings(List<AdditionalServiceBookingDC> pAdditionalServiceBookings)
|
|
{
|
|
try
|
|
{
|
|
List<AdditionalServiceBooking> lOriginals = DAOFactory.GenericDAO.LoadByIDs<AdditionalServiceBooking>(pAdditionalServiceBookings.Select(dc => dc.AdditionalServiceBookingOid.Value));
|
|
MapperFactory.AdditionalServiceBookingDC_AdditionalServiceBooking.MergeWithEntitys(pAdditionalServiceBookings, lOriginals);
|
|
DAOFactory.GenericDAO.Update(lOriginals);
|
|
|
|
var entries2Update = new List<AssessmentSheetEntry>();
|
|
var entries2Delete = new List<AssessmentSheetEntry>();
|
|
var newEntries = new List<AssessmentSheetEntry>();
|
|
|
|
IList<AssessmentSheetValue> avList = DAOFactory.GenericDAO.GetAll<AssessmentSheetValue>();
|
|
|
|
AssessmentSheetValue yes = avList.First(v => !String.IsNullOrEmpty(v.Description) && v.Description.Equals("Ja") &&
|
|
v.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet));
|
|
|
|
//var no = avList.First(v => !String.IsNullOrEmpty(v.Description) && v.Description.Equals("Nein") &&
|
|
// v.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet));
|
|
|
|
foreach (AdditionalServiceBooking item in lOriginals)
|
|
{
|
|
IEnumerable<AssessmentSheetEntry> list = DAOFactory.SearchDAO.GetAdditionalAssessmentSheetEntries(item.Datum.Value);
|
|
|
|
IEnumerable<AssessmentSheetEntry> list2 = list.Where(e => !String.IsNullOrEmpty(e.AssessmentSheetCategory.Description) &&
|
|
e.AssessmentSheetCategory.Description.Equals(item.AdditionalServiceRegion.AdditionalService.Name) &&
|
|
item.Customer2AddServiceBookings.Exists(c2a => c2a.CustomerOid == e.Customer.Oid));
|
|
|
|
entries2Update.AddRange(list2);
|
|
|
|
foreach (Customer2AddServiceBooking c2a in item.Customer2AddServiceBookings)
|
|
{
|
|
bool containsEntry = false;
|
|
|
|
foreach (AssessmentSheetEntry entry in entries2Update)
|
|
{
|
|
if (entry.Customer.Oid == null)
|
|
continue;
|
|
if (entry.Customer.Oid.Value.Equals(c2a.CustomerOid))
|
|
{
|
|
containsEntry = true;
|
|
if (c2a.Participated)
|
|
entry.AssessmentSheetValue = yes;
|
|
else
|
|
entries2Delete.Add(entry);
|
|
}
|
|
}
|
|
|
|
if (c2a.Participated && !containsEntry)
|
|
{
|
|
AssessmentSheetCategory cat =
|
|
DAOFactory.SearchDAO.GetAddServiceAssessmentSheetCategoryWithName(
|
|
item.AdditionalServiceRegion.AdditionalService.Name);
|
|
if (cat != null)
|
|
{
|
|
newEntries.Add(new AssessmentSheetEntry
|
|
{
|
|
Customer = DAOFactory.GenericDAO.GetByID<Customer>(c2a.CustomerOid),
|
|
AssessmentSheetCategory = cat,
|
|
AssessmentSheetValue = yes,
|
|
SystemEntryID = SystemEntryID.AdditionalServiceAssessmentSheet,
|
|
Day = item.Datum.Value
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
entries2Update.RemoveRange(entries2Delete);
|
|
|
|
DAOFactory.GenericDAO.Update(entries2Update);
|
|
DAOFactory.GenericDAO.Delete(entries2Delete);
|
|
DAOFactory.GenericDAO.Insert(newEntries);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public bool AssessmentSheetEntryBelongsToAddServices(long assessmentSheetCategoryOid)
|
|
{
|
|
var lOriginal = DAOFactory.GenericDAO.GetByID<AssessmentSheetCategory>(assessmentSheetCategoryOid);
|
|
IList<AdditionalService> services = DAOFactory.GenericDAO.GetAll<AdditionalService>();
|
|
|
|
bool result = lOriginal.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet) && services.Count(e => e.Name.Equals(lOriginal.Description)) > 0;
|
|
|
|
return result;
|
|
}
|
|
|
|
public AdditionalServiceGroupOfPeopleDC UpdateAdditionalServiceGroupOfPeople(AdditionalServiceGroupOfPeopleDC pAdditionalServiceGroupOfPeople)
|
|
{
|
|
try
|
|
{
|
|
var lOriginal =
|
|
DAOFactory.GenericDAO.LoadByID<AdditionalServiceGroupOfPeople>(
|
|
pAdditionalServiceGroupOfPeople.AdditionalServiceGroupOfPeopleOid.Value);
|
|
|
|
MapperFactory.AdditionalServiceGroupOfPeopleCD_AdditionalServiceGroupOfPeople.MergeWithEntity(
|
|
pAdditionalServiceGroupOfPeople, lOriginal);
|
|
|
|
MapperFactory.CompactCustomerDC_Customer.MergeWithEntitys(
|
|
pAdditionalServiceGroupOfPeople.CustomerList, lOriginal.CustomerList);
|
|
|
|
DAOFactory.GenericDAO.Update(lOriginal);
|
|
|
|
AdditionalServiceGroupOfPeopleDC newGroupDC =
|
|
MapperFactory.AdditionalServiceGroupOfPeopleCD_AdditionalServiceGroupOfPeople.MapToNewDC(
|
|
lOriginal);
|
|
|
|
newGroupDC.CustomerList =
|
|
MapperFactory.CompactCustomerDC_Customer.MapToNewDCs(lOriginal.CustomerList);
|
|
|
|
return newGroupDC;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<long> InsertNewAdditionalServiceGroupOfPeopleRelations(List<AdditionalServiceGroupOfPeopleRelationDC> pAdditionalServiceGroupOfPeopleRelations)
|
|
{
|
|
try
|
|
{
|
|
List<AdditionalService2GroupOfPeople> lAdditionalServiceGroupOfPeopleRelations =
|
|
MapperFactory.AdditionalServiceGroupOfPeopleRelationDC_AdditionalService2GroupOfPeople.MapToNewEntities(pAdditionalServiceGroupOfPeopleRelations);
|
|
|
|
DAOFactory.GenericDAO.Insert(lAdditionalServiceGroupOfPeopleRelations);
|
|
|
|
return lAdditionalServiceGroupOfPeopleRelations.Select(asgopr => asgopr.Oid.Value).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<long> InsertNewAdditionalServiceGroupsOfPeople(List<AdditionalServiceGroupOfPeopleDC> pGroups)
|
|
{
|
|
try
|
|
{
|
|
List<AdditionalServiceGroupOfPeople> lGroups =
|
|
MapperFactory.AdditionalServiceGroupOfPeopleCD_AdditionalServiceGroupOfPeople.MapToNewEntities(
|
|
pGroups);
|
|
|
|
DAOFactory.GenericDAO.Insert(lGroups);
|
|
|
|
return lGroups.Select(asgop => asgop.Oid.Value).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<long> InsertNewServiceRecords(List<ServiceRecordDC> pServiceRecords)
|
|
{
|
|
return InternalInsertNewServiceRecords(MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewEntities(pServiceRecords));
|
|
}
|
|
|
|
public static List<long> InternalInsertNewServiceRecords(IEnumerable<ServiceRecord> lServiceRecords)
|
|
{
|
|
try
|
|
{
|
|
ServiceRecordGroup group = null;
|
|
|
|
foreach (var iServiceRecord in lServiceRecords)
|
|
{
|
|
if (string.IsNullOrEmpty(iServiceRecord.IP))
|
|
{
|
|
iServiceRecord.IP = OperationContext.Current != null ? Utils.GetClientIP() : "::1";
|
|
}
|
|
|
|
if (iServiceRecord.InsTs == null)
|
|
{
|
|
iServiceRecord.InsTs = DateTime.Now;
|
|
}
|
|
|
|
if (iServiceRecord.GroupEmployeeCount != null && iServiceRecord.GroupPersonCount != null &&
|
|
(iServiceRecord.GroupEmployeeCount.Value + iServiceRecord.GroupPersonCount.Value > 2))
|
|
{
|
|
if (group == null)
|
|
{
|
|
group = new ServiceRecordGroup
|
|
{
|
|
CustomerCount = iServiceRecord.GroupPersonCount.Value,
|
|
EmployeeCount = iServiceRecord.GroupEmployeeCount.Value,
|
|
RoundedDuration = iServiceRecord.GroupRoundedDuration.Value,
|
|
StartDate = iServiceRecord.Start,
|
|
EndDate = iServiceRecord.End
|
|
};
|
|
}
|
|
|
|
iServiceRecord.Group = group;
|
|
}
|
|
else
|
|
{
|
|
var srdc = PluginLoader.FindClass<ServiceRecordDurationCalculator>();
|
|
if (srdc != null)
|
|
{
|
|
srdc.CalculateRoundedDuration(iServiceRecord);
|
|
}
|
|
|
|
var bsi = PluginLoader.FindClass<SaveInterceptor>();
|
|
if (bsi != null)
|
|
{
|
|
bsi.BeforeSaveServiceRecord(iServiceRecord);
|
|
}
|
|
}
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Insert(lServiceRecords);
|
|
|
|
MakeServiceRecordHistoryEntry(lServiceRecords, lServiceRecords.Select(sr => sr.Oid.Value).ToList(), StatementType.Insert);
|
|
|
|
return lServiceRecords.Select(sr => sr.Oid.Value).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<long> InsertNewAdditionalServiceBookings(List<AdditionalServiceBookingDC> pAdditionalServiceBookings)
|
|
{
|
|
try
|
|
{
|
|
List<AdditionalServiceBooking> lAdditionalServiceBookings = MapperFactory.AdditionalServiceBookingDC_AdditionalServiceBooking.MapToNewEntities(pAdditionalServiceBookings);
|
|
DAOFactory.GenericDAO.Insert(lAdditionalServiceBookings);
|
|
|
|
foreach (AdditionalServiceBooking booking in lAdditionalServiceBookings)
|
|
{
|
|
AttachAddServiceToAssessment(booking);
|
|
}
|
|
|
|
return lAdditionalServiceBookings.Select(asb => asb.Oid.Value).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public bool IsAlive()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public string PrepareFLSReport(FLSAnalysisDataReportDC pReportDC, string id)
|
|
{
|
|
try
|
|
{
|
|
string lResult = id + ".xml";
|
|
|
|
string lDir = BS.Shared.Core.Utils.CreateSavePath(AppDomain.CurrentDomain.BaseDirectory, MultitenancyOperationContextExt.Current.Tenant + @"\temp");
|
|
string lPath = BS.Shared.Core.Utils.CreateSavePath(lDir, lResult);
|
|
|
|
BS.Shared.Core.Utils.XMLSerialize(lPath, pReportDC);
|
|
|
|
return lResult;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public string PrepareSettlementReport(Settlement2DC pSettlementDC)
|
|
{
|
|
try
|
|
{
|
|
string lResult = Guid.NewGuid() + ".xml";
|
|
|
|
string lDir = BS.Shared.Core.Utils.CreateSavePath(AppDomain.CurrentDomain.BaseDirectory, MultitenancyOperationContextExt.Current.Tenant + @"\temp");
|
|
string lPath = BS.Shared.Core.Utils.CreateSavePath(lDir, lResult);
|
|
|
|
BS.Shared.Core.Utils.XMLSerialize(lPath, pSettlementDC);
|
|
|
|
return lResult;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateAccountingTransactions(List<AccountingTransactionDC> pAccountingTransactions)
|
|
{
|
|
try
|
|
{
|
|
List<AccountingTransaction> lOriginals = DAOFactory.GenericDAO.LoadByIDs<AccountingTransaction>(pAccountingTransactions.Select(dc => dc.AccountingTransactionOid.Value));
|
|
MapperFactory.AccountingTransactionDC_AccountingTransaction.MergeWithEntitys(pAccountingTransactions, lOriginals);
|
|
DAOFactory.GenericDAO.Update(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateInvoices(List<InvoiceDC> invoices)
|
|
{
|
|
try
|
|
{
|
|
List<Invoice> lOriginals = DAOFactory.GenericDAO.LoadByIDs<Invoice>(invoices.Select(dc => dc.InvoiceOid.Value));
|
|
MapperFactory.InvoiceDC_Invoice.MergeWithEntitys(invoices, lOriginals);
|
|
DAOFactory.GenericDAO.Update(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public MandatorDC UpdateMandator(MandatorDC mandator)
|
|
{
|
|
try
|
|
{
|
|
Mandator lOriginal = GetMandatorEntity();
|
|
//var oldDc = MapperFactory.MandatorDC_Mandator.MapToNewDC(lOriginal);
|
|
|
|
MapperFactory.MandatorDC_Mandator.MergeWithEntity(mandator, lOriginal);
|
|
DAOFactory.GenericDAO.Update(lOriginal);
|
|
return MapperFactory.MandatorDC_Mandator.MapToNewDC(lOriginal);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateServiceCategories(List<ServiceCategoryDC> pServiceCategories)
|
|
{
|
|
try
|
|
{
|
|
List<ServiceCategory> lOriginals = DAOFactory.GenericDAO.LoadByIDs<ServiceCategory>(pServiceCategories.Select(sc => sc.ServiceCategoryOid.Value));
|
|
|
|
MapperFactory.ServiceCategoryDC_ServiceCategory.MergeWithEntitys(pServiceCategories, lOriginals);
|
|
|
|
DAOFactory.GenericDAO.Update(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateAdditionalServices(List<AdditionalServiceDC> pAdditionalServices)
|
|
{
|
|
try
|
|
{
|
|
List<AdditionalService> lOriginals = DAOFactory.GenericDAO.LoadByIDs<AdditionalService>(pAdditionalServices.Select(sc => sc.AdditionalServiceOid.Value));
|
|
|
|
MapperFactory.AdditionalServiceDC_AdditionalService.MergeWithEntitys(pAdditionalServices, lOriginals);
|
|
|
|
DAOFactory.GenericDAO.Update(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateServiceDescriptions(List<ServiceDescriptionDC> pServiceDescriptions)
|
|
{
|
|
try
|
|
{
|
|
List<ServiceDescription> lOriginals = DAOFactory.GenericDAO.LoadByIDs<ServiceDescription>(pServiceDescriptions.Select(sc => sc.ServiceDescriptionOid.Value));
|
|
|
|
MapperFactory.ServiceDescriptionDC_ServiceDescription.MergeWithEntitys(pServiceDescriptions, lOriginals);
|
|
|
|
DAOFactory.GenericDAO.Update(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateAdditionalServiceRegions(List<AdditionalServiceRegionDC> pAdditionalServiceRegions)
|
|
{
|
|
try
|
|
{
|
|
List<AdditionalServiceRegion> lOriginals = DAOFactory.GenericDAO.LoadByIDs<AdditionalServiceRegion>(pAdditionalServiceRegions.Select(sc => sc.AdditionalServiceRegionOid.Value));
|
|
|
|
MapperFactory.AdditionalServiceRegionDC_AdditionalServiceRegion.MergeWithEntitys(pAdditionalServiceRegions, lOriginals);
|
|
|
|
DAOFactory.GenericDAO.Update(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
// TODO: vorhandene Unterschriften löschen!
|
|
public ServiceRecordGroupDC UpdateServiceRecordGroup(ServiceRecordGroupDC pServiceRecordGroup)
|
|
{
|
|
try
|
|
{
|
|
var lOriginal = DAOFactory.GenericDAO.LoadByID<ServiceRecordGroup>(pServiceRecordGroup.ServiceRecordGroupOid.Value);
|
|
|
|
var originalStart = lOriginal.StartDate;
|
|
var originalEnde = lOriginal.EndDate;
|
|
|
|
if (originalStart.HasValue && originalEnde.HasValue && pServiceRecordGroup.StartDate.HasValue && pServiceRecordGroup.EndDate.HasValue)
|
|
{
|
|
var minutesOrg = originalEnde.Value.Subtract(originalStart.Value).TotalMinutes;
|
|
var minutesNew = pServiceRecordGroup.EndDate.Value.Subtract(pServiceRecordGroup.StartDate.Value).TotalMinutes;
|
|
|
|
if (Math.Abs(minutesNew - minutesOrg) < 0.1 && pServiceRecordGroup.StartDate.Value.Hour == 0 && pServiceRecordGroup.StartDate.Value.Minute == 0 && pServiceRecordGroup.StartDate.Value.Second == 0)
|
|
{
|
|
//prüfen ob korrigiert werden muss
|
|
if (originalStart.Value.Hour != 0 || originalStart.Value.Minute != 0)
|
|
{
|
|
pServiceRecordGroup.StartDate = originalStart;
|
|
pServiceRecordGroup.EndDate = originalEnde;
|
|
pServiceRecordGroup.RoundedDuration = (decimal)originalEnde.Value.Subtract(originalStart.Value).TotalMinutes;
|
|
foreach (var srdc in pServiceRecordGroup.ServiceRecordList)
|
|
{
|
|
srdc.Start = originalStart;
|
|
srdc.End = originalEnde;
|
|
srdc.GroupRoundedDuration = pServiceRecordGroup.RoundedDuration;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if (!pServiceRecordGroup.StartDate.HasValue && pServiceRecordGroup.EndDate.HasValue)
|
|
{
|
|
pServiceRecordGroup.StartDate = pServiceRecordGroup.EndDate.Value.AddMinutes((double)pServiceRecordGroup.RoundedDuration * -1);
|
|
}
|
|
|
|
pServiceRecordGroup.RoundedDuration = (decimal)pServiceRecordGroup.EndDate.Value.Subtract(pServiceRecordGroup.StartDate.Value).TotalMinutes;
|
|
foreach (var srdc in pServiceRecordGroup.ServiceRecordList)
|
|
{
|
|
srdc.GroupRoundedDuration = pServiceRecordGroup.RoundedDuration;
|
|
}
|
|
|
|
// Bei geänderten Daten oder Uhrzeiten werden die Klientenunterschriften gelöscht
|
|
var serviceRecords = pServiceRecordGroup.ServiceRecordList;
|
|
var originalServiceRecords = lOriginal.ServiceRecordList;
|
|
DeleteSignaturesFromServiceRecords(serviceRecords, originalServiceRecords);
|
|
|
|
MapperFactory.ServiceRecordGroupDC_ServiceRecordGroup.MergeWithEntity(pServiceRecordGroup, lOriginal);
|
|
|
|
var lServiceRecords = new List<ServiceRecord>();
|
|
|
|
// update servicerecords
|
|
MapperFactory.ServiceRecordDC_ServiceRecord.MergeWithEntitys(pServiceRecordGroup.ServiceRecordList, lOriginal.ServiceRecordList);
|
|
foreach (var iServiceRecord in lOriginal.ServiceRecordList)
|
|
{
|
|
if (string.IsNullOrEmpty(iServiceRecord.IP))
|
|
{
|
|
iServiceRecord.IP = Utils.GetClientIP();
|
|
}
|
|
|
|
iServiceRecord.GroupOid = lOriginal.Oid;
|
|
lServiceRecords.Add(iServiceRecord);
|
|
}
|
|
|
|
RemoveServiceRecordsFromConfirmationReceiptSignatures(MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(lServiceRecords), lOriginal.ServiceRecordList.ToList(), false);
|
|
|
|
var groupDurationCalculator = PluginLoader.FindClass<GroupDurationCalculator>();
|
|
|
|
groupDurationCalculator?.CalculateGroupDuration(lOriginal);
|
|
|
|
DAOFactory.GenericDAO.Update(lOriginal);
|
|
MakeServiceRecordHistoryEntry(lServiceRecords, null, StatementType.Update);
|
|
|
|
var newGroupDC = MapperFactory.ServiceRecordGroupDC_ServiceRecordGroup.MapToNewDC(lOriginal);
|
|
|
|
newGroupDC.ServiceRecordList = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(lOriginal.ServiceRecordList);
|
|
|
|
return newGroupDC;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateServiceRecords(List<ServiceRecordDC> pServiceRecords)
|
|
{
|
|
try
|
|
{
|
|
var lOriginals = DAOFactory.GenericDAO.LoadByIDs<ServiceRecord>(pServiceRecords.Select(sr => sr.ServiceRecordOid.Value));
|
|
|
|
DeleteSignaturesFromServiceRecords(pServiceRecords, lOriginals);
|
|
RemoveServiceRecordsFromConfirmationReceiptSignatures(pServiceRecords, lOriginals, false);
|
|
|
|
if (lOriginals.Count == 1 && pServiceRecords.Count == 1)
|
|
{
|
|
var srDc = pServiceRecords[0];
|
|
var srOrg = lOriginals[0];
|
|
|
|
var originalStart = srOrg.Start;
|
|
var originalEnde = srOrg.End;
|
|
|
|
if (originalStart.HasValue && originalEnde.HasValue && srDc.Start.HasValue && srDc.End.HasValue)
|
|
{
|
|
var minutesOrg = originalEnde.Value.Subtract(originalStart.Value).TotalMinutes;
|
|
var minutesNew = srDc.End.Value.Subtract(srDc.Start.Value).TotalMinutes;
|
|
|
|
|
|
//Start und Ende korrigieren
|
|
if (Math.Abs(minutesNew - minutesOrg) < 0.1 && srDc.Start.Value.Hour == 0 && srDc.Start.Value.Minute == 0 && srDc.Start.Value.Second == 0)
|
|
{
|
|
//prüfen, ob korrigiert werden muss
|
|
if (originalStart.Value.Hour != 0 ||
|
|
originalStart.Value.Minute != 0)
|
|
{
|
|
srDc.Start = originalStart;
|
|
srDc.End = originalEnde;
|
|
//pServiceRecordGroup.RoundedDuration = (decimal)originalEnde.Value.Subtract(originalStart.Value).TotalMinutes;
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
MapperFactory.ServiceRecordDC_ServiceRecord.MergeWithEntitys(pServiceRecords, lOriginals);
|
|
|
|
var srdc = PluginLoader.FindClass<ServiceRecordDurationCalculator>();
|
|
var gdc = PluginLoader.FindClass<GroupDurationCalculator>();
|
|
|
|
foreach (var serviceRecord in lOriginals)
|
|
{
|
|
if (srdc != null)
|
|
{
|
|
srdc.CalculateRoundedDuration(serviceRecord);
|
|
}
|
|
|
|
if (serviceRecord.GroupOid.HasValue && serviceRecord.GroupPersonCount.HasValue && serviceRecord.GroupEmployeeCount.HasValue && gdc != null)
|
|
{
|
|
var gc = gdc.CalculateGroupDuration(serviceRecord.GroupPersonCount.Value,
|
|
serviceRecord.GroupEmployeeCount.Value, serviceRecord.RoundedDuration);
|
|
|
|
var singleduration = serviceRecord.RoundedDuration / serviceRecord.GroupPersonCount.Value;
|
|
|
|
if (gc != null)
|
|
{
|
|
singleduration = gc.SingleDuration;
|
|
}
|
|
|
|
serviceRecord.RoundedDuration = singleduration;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
if (srdc != null)
|
|
{
|
|
|
|
}
|
|
|
|
var si = PluginLoader.FindClass<SaveInterceptor>();
|
|
if (si != null)
|
|
{
|
|
foreach (var serviceRecord in lOriginals)
|
|
{
|
|
si.BeforeSaveServiceRecord(serviceRecord);
|
|
}
|
|
}
|
|
|
|
//RemoveServiceRecordsFromConfirmationReceiptSignatures(pServiceRecords, lOriginals);
|
|
|
|
DAOFactory.GenericDAO.Update(lOriginals);
|
|
|
|
|
|
lOriginals =
|
|
DAOFactory.GenericDAO.LoadByIDs<ServiceRecord>(
|
|
pServiceRecords.Select(sr => sr.ServiceRecordOid.Value));
|
|
|
|
MakeServiceRecordHistoryEntry(lOriginals, null, StatementType.Update);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public bool DoesNotOverlapWithOtherServiceRecord(ServiceRecordDC pServiceRecord, long customerOid, long? employeeOid)
|
|
{
|
|
//obsolete
|
|
return false;
|
|
//if (pServiceRecord.ServiceDescription.DoNotCheckOverlapping)
|
|
//{
|
|
// return false;
|
|
//}
|
|
//var span = new DateTimeSpan
|
|
//{StartDate = pServiceRecord.Start.Value, EndDate = pServiceRecord.End.Value.AddDays(1).AddTicks(-1)};
|
|
|
|
//List<ServiceRecord> records = DAOFactory.SearchDAO.FindCustomerServiceRecords(customerOid, span, employeeOid, null).ToList();
|
|
|
|
//return records.Count <= 0 || records.Where(record => record.CostBearer2SupportConcept.CostBearer.Oid == pServiceRecord.CostBearer.OrganisationOid).Select(record => TimeSpanOverlapsWithOtherTimeSpan(pServiceRecord.Start, record.Start, pServiceRecord.RoundedDuration, record.RoundedDuration)).All(timeCheck => !timeCheck);
|
|
}
|
|
|
|
public bool OverlapsWithAnotherAdditionalServiceBooking(long additionalServiceRegionOid, List<long> customerOids, DateTime pDatum)
|
|
{
|
|
List<AdditionalServiceBooking> bookings = DAOFactory.GenericDAO.GetAll<AdditionalServiceBooking>().Where(b => b.Datum.Equals(pDatum) && b.AdditionalServiceRegion.Oid.Value.Equals(additionalServiceRegionOid)).ToList();
|
|
|
|
return bookings.Any(booking => booking.Customer2AddServiceBookings.Any(customer => customerOids.Contains(customer.CustomerOid)));
|
|
}
|
|
|
|
public List<AdditionalServiceGroupOfPeopleRelationDC> GetAllAdditionalServiceGroupOfPeopleRelation()
|
|
{
|
|
try
|
|
{
|
|
IList<AdditionalService2GroupOfPeople> as2gop = DAOFactory.GenericDAO.GetAll<AdditionalService2GroupOfPeople>();
|
|
return as2gop.Select(item => MapperFactory.AdditionalServiceGroupOfPeopleRelationDC_AdditionalService2GroupOfPeople.MergeWithDC(item, new AdditionalServiceGroupOfPeopleRelationDC())).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<AdditionalServiceGroupOfPeopleDC> GetAllAdditionalServiceGroupOfPeople()
|
|
{
|
|
try
|
|
{
|
|
List<AdditionalServiceGroupOfPeopleDC> result =
|
|
MapperFactory.AdditionalServiceGroupOfPeopleCD_AdditionalServiceGroupOfPeople.MapToNewDCs(
|
|
DAOFactory.GenericDAO.GetAll<AdditionalServiceGroupOfPeople>()).ToList();
|
|
|
|
return result;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<AdditionalServiceBookingDC> GetAllAdditionalServiceBookings(long? regionOid, DateTime start, DateTime end)
|
|
{
|
|
try
|
|
{
|
|
//Filtere Customer mit TerminationDate raus
|
|
var clist = DAOFactory.GenericDAO.GetAllActiveAndArchived<Customer>();
|
|
|
|
var notAllowedCustomerOids = new List<long>();
|
|
|
|
foreach (var c in clist)
|
|
{
|
|
if (c.TerminationDate.HasValue && c.TerminationDate.Value < start)
|
|
{
|
|
notAllowedCustomerOids.Add(c.Oid.Value);
|
|
}
|
|
}
|
|
|
|
List<AdditionalServiceBookingDC> result =
|
|
MapperFactory.AdditionalServiceBookingDC_AdditionalServiceBooking.MapToNewDCs(
|
|
DAOFactory.SearchDAO.GetAdditionalServiceBookings(regionOid, start, end)).ToList();
|
|
|
|
|
|
foreach (var booking in result)
|
|
{
|
|
foreach (var oid in notAllowedCustomerOids)
|
|
{
|
|
if (booking.CustomerOidDict.ContainsKey(oid))
|
|
{
|
|
booking.CustomerOidDict.Remove(oid);
|
|
}
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public Dictionary<ServiceRecordDC, List<ServiceRecordValidationResult>> ValidateGroupServiceRecordEntry(ServiceRecordDC pServiceRecord, List<ServiceRecordDC> groupServiceRecords, List<CompactEmployeeDC> employees, DateTime? date, int maxDaysEditServiceRecordsAllowed, decimal flsTotalRounded, out Dictionary<long, string> overlappingRecords, out Dictionary<long, string> overlappingEmployees)
|
|
{
|
|
var validator = PluginLoader.FindClass<ServiceRecordValidator>();
|
|
return validator.ValidateGroupServiceRecordEntry(pServiceRecord, groupServiceRecords, employees, date, maxDaysEditServiceRecordsAllowed, flsTotalRounded, out overlappingRecords, out overlappingEmployees);
|
|
|
|
}
|
|
|
|
public List<ServiceRecordValidationResultDC> ValidateServiceRecordEntry(ServiceRecordDC newServiceRecord, SupportConceptStatisticsDC statistics, int maxDaysEditServiceRecordsAllowed, bool isGroupRecord, IList<long> employeeOids)
|
|
{
|
|
return ValidateServiceRecord(newServiceRecord, statistics, maxDaysEditServiceRecordsAllowed, employeeOids, null);
|
|
}
|
|
|
|
public List<ServiceRecordValidationResultDC> ValidateServiceRecord(ServiceRecordDC newServiceRecord, SupportConceptStatisticsDC statistics, int maxDaysEditServiceRecordsAllowed, IList<long> employeeOids, IList<long> cb2scOids)
|
|
{
|
|
var validator = PluginLoader.FindClass<ServiceRecordValidator>();
|
|
return validator.ValidateServiceRecord(newServiceRecord, statistics, maxDaysEditServiceRecordsAllowed, employeeOids, cb2scOids);
|
|
}
|
|
|
|
public List<ServiceRecordValidationResultDC> ValidateServiceRecordDeletion(ServiceRecordDC serviceRecord, long employeeOid)
|
|
{
|
|
var validator = PluginLoader.FindClass<ServiceRecordValidator>();
|
|
return validator.ValidateServiceRecordDeletion(serviceRecord, employeeOid);
|
|
|
|
}
|
|
|
|
public ServiceRecordValidationResultDC CheckForExistingSignature(ServiceRecordDC serviceRecord)
|
|
{
|
|
var validator = PluginLoader.FindClass<ServiceRecordValidator>();
|
|
return validator.CheckForExistingSignature(serviceRecord);
|
|
}
|
|
|
|
public List<ServiceRecordValidationResult> CheckExistingSettlementInvoices(ServiceRecordDC pServiceRecord)
|
|
{
|
|
var result = new List<ServiceRecordValidationResult>();
|
|
// 6. SettlementInvoiceAlreadyExisting
|
|
try
|
|
{
|
|
IList<SettlementInvoice> allSettlementInvoices = DAOFactory.GenericDAO.GetAll<SettlementInvoice>();
|
|
|
|
foreach (SettlementInvoice rechnung in allSettlementInvoices)
|
|
{
|
|
if (rechnung.InvoiceBase.CostBearer2SupportConcept.Oid.HasValue)
|
|
if (rechnung.InvoiceBase.CostBearer2SupportConcept.Oid.Value.Equals(pServiceRecord.CostBearer2SupportConceptOid.Value) && rechnung.IsActive.Equals(ActivationTypeId.Active))
|
|
{
|
|
result.Add(ServiceRecordValidationResult.SettlementInvoiceAlreadyExisting);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
result.Add(ServiceRecordValidationResult.Error);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public List<AdditionalServiceBookingDC> GetAllAdditionalServiceBookingsForCustomer(long customerOid, DateTime start, DateTime end)
|
|
{
|
|
try
|
|
{
|
|
;
|
|
List<AdditionalServiceBookingDC> result =
|
|
MapperFactory.AdditionalServiceBookingDC_AdditionalServiceBooking.MapToNewDCs(
|
|
DAOFactory.SearchDAO.GetAdditionalServiceBookingsForCustomer(customerOid, start, end));
|
|
//var result =
|
|
// MapperFactory.AdditionalServiceBookingDC_AdditionalServiceBooking.MapToNewDCs(
|
|
// DAOFactory.GenericDAO.GetAll<AdditionalServiceBooking>()).ToList().Where(b => b.CustomerOidDict.Any(c => c.Key.Equals(customerOid))).ToList();
|
|
|
|
return result;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public ServiceRecordDC GetServiceRecordById(long pId)
|
|
{
|
|
try
|
|
{
|
|
var sr = DAOFactory.GenericDAO.GetByID<ServiceRecord>(pId);
|
|
|
|
if (sr == null)
|
|
return null;
|
|
|
|
ServiceRecordDC result = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(sr);
|
|
return result;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<FileAttachmentDC> GetFileAttachmentInfoByType(FileAttachmentType fileAttachmentType)
|
|
{
|
|
try
|
|
{
|
|
return MapperFactory.FileAttachmentDC_FileAttachmentInfo.MapToNewDCs(DAOFactory.SearchDAO.FindFileAttachmentInfoByType(fileAttachmentType));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ServiceRecordDC> GetActiveServiceRecordsBySupportConcept(long pSupportConceptOid)
|
|
{
|
|
try
|
|
{
|
|
return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(DAOFactory.SearchDAO.FindServiceRecordsForSupportConcept(pSupportConceptOid));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void InsertBeWoMobilBrowserInfo(BeWoMobilBrowserInfoDC browserInfo)
|
|
{
|
|
try
|
|
{
|
|
BeWoMobilBrowserInfo info = MapperFactory.BeWoMobilBrowserInfoDC_BeWoMobilBrowserInfo.MapToNewEntity(browserInfo);
|
|
DAOFactory.GenericDAO.Insert(info);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public IList<ServiceRecordDC> FindServiceRecordsForLastDays(long? costbearer2SupportConceptOid, int days, long? employeeOid)
|
|
{
|
|
try
|
|
{
|
|
return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(DAOFactory.SearchDAO.FindServiceRecordsForDays(costbearer2SupportConceptOid, days, employeeOid));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public IEnumerable<CompactSupportConceptDC> GetCompactSupportConcepts(long supportConceptOid, long? employeeOid)
|
|
{
|
|
try
|
|
{
|
|
var s = PluginLoader.FindClass<CustomerService>();
|
|
|
|
return s.GetCompactSupportConcepts(supportConceptOid, employeeOid);
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
private static ServiceRecordDC CreateServiceRecordDCCompact(ServiceRecord sr)
|
|
{
|
|
var dc = new ServiceRecordDC();
|
|
|
|
dc.ServiceRecordOid = sr.Oid;
|
|
dc.ServiceRecordVersion = sr.Version;
|
|
dc.Start = sr.Start;
|
|
dc.End = sr.End;
|
|
dc.Notice = sr.Notice;
|
|
dc.Notice2 = sr.Notice2;
|
|
dc.Notice3 = sr.Notice3;
|
|
dc.Notice4 = sr.Notice4;
|
|
dc.Notice5 = sr.Notice5;
|
|
if (sr.ServiceDescription != null)
|
|
dc.ServiceDescription = MapperFactory.ServiceDescriptionDC_ServiceDescription.MapToNewDC(sr.ServiceDescription);
|
|
|
|
|
|
dc.RoundedDuration = sr.RoundedDuration;
|
|
|
|
dc.DistanceInMeter = (int?)sr.DistanceInMeter;
|
|
dc.DistanceInMeterDecimal = sr.DistanceInMeter;
|
|
dc.Betrag = sr.Betrag;
|
|
dc.InsertedOn = sr.InsTs;
|
|
dc.InsUser = sr.InsUser;
|
|
|
|
dc.DurationInStunden = sr.DurationInStunden;
|
|
dc.ServiceRecordFormat = sr.ServiceRecordFormat;
|
|
|
|
dc.GroupEmployeeCount = sr.GroupEmployeeCount;
|
|
dc.GroupPersonCount = sr.GroupPersonCount;
|
|
dc.GroupRoundedDuration = sr.GroupRoundedDuration;
|
|
dc.ServiceRecordType = sr.ServiceRecordType ?? ServiceRecordTypeId.DefaultActivity;
|
|
dc.GroupOid = sr.GroupOid;
|
|
dc.SignatureOid = sr.SignatureOid;
|
|
|
|
if (sr.GroupOid.HasValue)
|
|
{
|
|
dc.BackgroundColor = "#FFFDC784";
|
|
}
|
|
|
|
if (sr.ServiceRecordType.HasValue && sr.ServiceRecordType.Value == ServiceRecordTypeId.Content)
|
|
{
|
|
dc.BackgroundColor = "#FF78BFFF";
|
|
}
|
|
|
|
|
|
if (sr.Employee != null)
|
|
{
|
|
//dc.Employee = MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(sr.Employee);
|
|
dc.Employee = new CompactEmployeeDC();
|
|
dc.Employee.EmployeeOid = sr.Employee.Oid.Value;
|
|
dc.Employee.EmployeeVersion = sr.Employee.Version.Value;
|
|
dc.Employee.FirstName = sr.Employee.Person.FirstName;
|
|
dc.Employee.LastName = sr.Employee.Person.LastName;
|
|
dc.Employee.PersonnelNumber = sr.Employee.PersonnelNumber;
|
|
//pDataContract.FLSPerWeek = pEntity.WeeklyFLS;
|
|
dc.Employee.ActivationType = sr.Employee.IsActive;
|
|
}
|
|
|
|
//if(sr.DurationInStunden == ZeiterfassungsDauer.Stunden)
|
|
// dc.RoundedDuration = sr.RoundedDuration /60;
|
|
//else
|
|
// dc.RoundedDuration = sr.RoundedDuration;
|
|
|
|
//Goals -------------------------
|
|
var list = new List<ValueListEntryType>();
|
|
list.Add(ValueListEntryType.SupportConceptGoalType);
|
|
list.Add(ValueListEntryType.SupportConceptGoalCategoryType);
|
|
list.Add(ValueListEntryType.SupportConceptIndividualGoalCategoryType);
|
|
list.Add(ValueListEntryType.SupportConceptIndividualGoalType);
|
|
|
|
dc.Goals = new List<ValueListEntryDC>();
|
|
foreach (var v2o in sr.ValueList.FindByTypes(list))
|
|
{
|
|
var entryDc = MapperFactory.ValueListEntryDC_ValueListEntry.MapToNewDC(v2o.Entry);
|
|
entryDc.RatingTypeOid = v2o.RatingTypeOid;
|
|
dc.Goals.Add(entryDc);
|
|
}
|
|
|
|
return dc;
|
|
}
|
|
|
|
private static ServiceRecordDC CreateServiceRecordDCIfSupportConceptIsActive(ServiceRecord sr, Customer cust, bool checkArchivedSupportConcepts)
|
|
{
|
|
ServiceRecordDC dc = null;
|
|
if (!checkArchivedSupportConcepts || (sr.SupportConcept != null && sr.SupportConcept.IsActive == ActivationTypeId.Active))
|
|
{
|
|
dc = new ServiceRecordDC();
|
|
|
|
dc.ServiceRecordOid = sr.Oid;
|
|
dc.ServiceRecordVersion = sr.Version;
|
|
dc.Start = sr.Start;
|
|
dc.End = sr.End;
|
|
dc.Notice = sr.Notice;
|
|
dc.Notice2 = sr.Notice2;
|
|
dc.Notice3 = sr.Notice3;
|
|
dc.Notice4 = sr.Notice4;
|
|
dc.Notice5 = sr.Notice5;
|
|
if (sr.ServiceDescription != null)
|
|
dc.ServiceDescription = MapperFactory.ServiceDescriptionDC_ServiceDescription.MapToNewDC(sr.ServiceDescription);
|
|
dc.RoundedDuration = sr.RoundedDuration;
|
|
dc.InsertedOn = sr.InsTs;
|
|
dc.InsUser = sr.InsUser;
|
|
dc.DurationInStunden = sr.DurationInStunden;
|
|
dc.SignatureOid = sr.SignatureOid;
|
|
dc.ServiceRecordFormat = sr.ServiceRecordFormat;
|
|
|
|
//Customer -----------------
|
|
dc.Customer = new CompactCustomerDC();
|
|
|
|
|
|
dc.Customer.CustomerOid = cust.Oid.Value;
|
|
dc.Customer.CustomerVersion = cust.Version.Value;
|
|
dc.Customer.FirstName = cust.Person.FirstName;
|
|
dc.Customer.LastName = cust.Person.LastName;
|
|
dc.Customer.Sex = cust.Person.Sex;
|
|
//dc.Customer.DateOfBirth = cust.Person.DateOfBirth;
|
|
//dc.Customer.ActivationType = cust.IsActive;
|
|
//dc.Customer.TerminationDate = cust.TerminationDate;
|
|
//dc.Customer.EquityContribution = cust.EquityContribution;
|
|
|
|
//pDataContract.AbsenceTimes = MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewDCs(pEntity.AbsenceTimes);
|
|
|
|
|
|
//Employee -----------------
|
|
|
|
|
|
if (sr.Employee != null)
|
|
{
|
|
//dc.Employee = MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(sr.Employee);
|
|
dc.Employee = new CompactEmployeeDC();
|
|
dc.Employee.EmployeeOid = sr.Employee.Oid.Value;
|
|
dc.Employee.EmployeeVersion = sr.Employee.Version.Value;
|
|
dc.Employee.FirstName = sr.Employee.Person.FirstName;
|
|
dc.Employee.LastName = sr.Employee.Person.LastName;
|
|
dc.Employee.PersonnelNumber = sr.Employee.PersonnelNumber;
|
|
//pDataContract.FLSPerWeek = pEntity.WeeklyFLS;
|
|
dc.Employee.ActivationType = sr.Employee.IsActive;
|
|
}
|
|
|
|
|
|
//SupportConcept -----------------
|
|
if (sr.SupportConcept != null)
|
|
{
|
|
dc.SupportConcept = new CompactSupportConceptDC();
|
|
|
|
dc.SupportConcept.SupportConceptOid = sr.SupportConcept.Oid.Value;
|
|
dc.SupportConcept.SupportConceptVersion = sr.SupportConcept.Version.Value;
|
|
dc.SupportConcept.Customer = dc.Customer;
|
|
//pDataContract.Customer = MapperFactory.CompactCustomerDC_Customer.MapToNewDC(pEntity.Customer);
|
|
dc.SupportConcept.ActivationType = sr.SupportConcept.IsActive;
|
|
dc.SupportConcept.ConferenceDate = sr.SupportConcept.ConferenceDate;
|
|
|
|
//foreach (var iCBRel in pEntity.CostBearer2SupportConceptList)
|
|
//{
|
|
// CompactCostBearerDC costBearer = new CompactCostBearerDC();
|
|
|
|
// if (iCBRel.CostBearer.Organisation != null)
|
|
// {
|
|
// CompactOrganisationDC orgDC = new CompactOrganisationDC();
|
|
// orgDC.Name = iCBRel.CostBearer.Organisation.Name;
|
|
// orgDC.OrganisationOid = iCBRel.CostBearer.Organisation.Oid.Value;
|
|
|
|
// if (iCBRel.CostBearer.Organisation.Address != null)
|
|
// {
|
|
// orgDC.Street = iCBRel.CostBearer.Organisation.Address.Street;
|
|
// orgDC.PostalCode = iCBRel.CostBearer.Organisation.Address.PostalCode;
|
|
// orgDC.Town = iCBRel.CostBearer.Organisation.Address.Town;
|
|
// }
|
|
// costBearer.Organisation = orgDC;
|
|
// }
|
|
// costBearer.CostBearerOid = iCBRel.CostBearer.Oid.Value;
|
|
// costBearer.CostBearer2SupportConceptOid = iCBRel.Oid.Value;
|
|
// costBearer.SupportConceptStatus = iCBRel.Status;
|
|
// costBearer.RequestedStartDate = iCBRel.RequestedStartDate;
|
|
// costBearer.RequestedEndDate = iCBRel.RequestedEndDate;
|
|
// costBearer.ApprovedStartDate = iCBRel.ApprovedStartDate;
|
|
// costBearer.ApprovedEndDate = iCBRel.ApprovedEndDate;
|
|
// costBearer.ApprovedFLS = iCBRel.ApprovedFLS;
|
|
// costBearer.ApprovedFLSTotal = iCBRel.ApprovedFLSTotal;
|
|
// costBearer.CustomerReferenceNumber = iCBRel.CustomerReferenceNumber;
|
|
// costBearer.IsCalculatingWithFactor = iCBRel.CostBearer.IsCalculatingWithFactor;
|
|
|
|
// pDataContract.CostBearerList.Add(costBearer);
|
|
// pDataContract.CustomerReferenceNumbers.Add(iCBRel.CustomerReferenceNumber);
|
|
// pDataContract.CostBearerRelOids.Add(iCBRel.Oid.Value);
|
|
//}
|
|
|
|
//dc.SupportConcept = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDC(sr.SupportConcept);
|
|
}
|
|
|
|
//Costbearer -----------------
|
|
if (sr.CostBearer2SupportConcept != null)
|
|
{
|
|
dc.CostBearer2SupportConceptOid = sr.CostBearer2SupportConcept.Oid.Value;
|
|
|
|
if (dc.SupportConcept != null)
|
|
{
|
|
var costBearer = new CompactCostBearerDC();
|
|
|
|
if (sr.CostBearer2SupportConcept.CostBearer.Organisation != null)
|
|
{
|
|
var orgDC = new CompactOrganisationDC();
|
|
orgDC.Name = sr.CostBearer2SupportConcept.CostBearer.Organisation.Name;
|
|
orgDC.OrganisationOid = sr.CostBearer2SupportConcept.CostBearer.Organisation.Oid.Value;
|
|
orgDC.CostBearerOid = sr.CostBearer2SupportConcept.CostBearer.Oid;
|
|
dc.CostBearer = orgDC;
|
|
costBearer.Organisation = orgDC;
|
|
}
|
|
|
|
costBearer.CostBearerID = sr.CostBearer2SupportConcept.CostBearer.ID;
|
|
costBearer.CostBearerOid = sr.CostBearer2SupportConcept.CostBearer.Oid.Value;
|
|
costBearer.CostBearer2SupportConceptOid = sr.CostBearer2SupportConcept.Oid.Value;
|
|
costBearer.SupportConceptStatus = sr.CostBearer2SupportConcept.Status;
|
|
costBearer.RequestedStartDate = sr.CostBearer2SupportConcept.RequestedStartDate;
|
|
costBearer.RequestedEndDate = sr.CostBearer2SupportConcept.RequestedEndDate;
|
|
costBearer.ApprovedStartDate = sr.CostBearer2SupportConcept.ApprovedStartDate;
|
|
costBearer.ApprovedEndDate = sr.CostBearer2SupportConcept.ApprovedEndDate;
|
|
costBearer.CustomerReferenceNumber = sr.CostBearer2SupportConcept.CustomerReferenceNumber;
|
|
costBearer.IsCalculatingWithFactor = sr.CostBearer2SupportConcept.CostBearer.IsCalculatingWithFactor;
|
|
|
|
dc.SupportConcept.CostBearerList.Add(costBearer);
|
|
dc.SupportConcept.CustomerReferenceNumbers.Add(sr.CostBearer2SupportConcept.CustomerReferenceNumber);
|
|
dc.SupportConcept.CostBearerRelOids.Add(sr.CostBearer2SupportConcept.Oid.Value);
|
|
}
|
|
|
|
if (dc.CostBearer == null)
|
|
{
|
|
if (sr.CostBearer2SupportConcept.CostBearer.Organisation != null)
|
|
dc.CostBearer = MapperFactory.CompactOrganisationDC_Organisation.MapToNewDC(sr.CostBearer2SupportConcept.CostBearer.Organisation);
|
|
}
|
|
}
|
|
|
|
//Goals -------------------------
|
|
var list = new List<ValueListEntryType>();
|
|
list.Add(ValueListEntryType.SupportConceptGoalType);
|
|
list.Add(ValueListEntryType.SupportConceptGoalCategoryType);
|
|
list.Add(ValueListEntryType.SupportConceptIndividualGoalCategoryType);
|
|
list.Add(ValueListEntryType.SupportConceptIndividualGoalType);
|
|
dc.Goals = MapperFactory.ValueListEntryDC_ValueListEntry.MapToNewDCs(
|
|
sr.ValueList.FindByTypes(list).Select(e2o => e2o.Entry));
|
|
|
|
dc.GroupEmployeeCount = sr.GroupEmployeeCount;
|
|
dc.GroupPersonCount = sr.GroupPersonCount;
|
|
dc.GroupRoundedDuration = sr.GroupRoundedDuration;
|
|
dc.GroupOid = sr.GroupOid;
|
|
dc.ServiceRecordType = sr.ServiceRecordType ?? ServiceRecordTypeId.DefaultActivity;
|
|
}
|
|
|
|
return dc;
|
|
}
|
|
|
|
public static Dictionary<string, string> GetSettingsValueDict(string settings)
|
|
{
|
|
var dict = new Dictionary<String, String>();
|
|
if (!String.IsNullOrEmpty(settings))
|
|
{
|
|
string[] keyValuePairs = settings.Split(';');
|
|
|
|
foreach (string pair in keyValuePairs)
|
|
{
|
|
string[] keyValuePair = pair.Split('=');
|
|
if (keyValuePair.Length == 2)
|
|
{
|
|
dict.Add(keyValuePair[0], keyValuePair[1]);
|
|
}
|
|
}
|
|
}
|
|
|
|
return dict;
|
|
}
|
|
|
|
|
|
private static string GetContractState()
|
|
{
|
|
try
|
|
{
|
|
String responseStr = "";
|
|
String tenant = "";
|
|
String typ = "&t=0";
|
|
|
|
if (MultitenancyOperationContextExt.Current != null)
|
|
{
|
|
tenant = MultitenancyOperationContextExt.Current.Tenant;
|
|
}
|
|
else
|
|
{
|
|
tenant = SessionFacade.Tenant;
|
|
typ = "&t=1";
|
|
}
|
|
if (String.IsNullOrEmpty(tenant))
|
|
{
|
|
return "";
|
|
}
|
|
|
|
Monitor.Enter(_Lock);
|
|
|
|
if (_ContractStateDate.ContainsKey(tenant))
|
|
{
|
|
DateTime oldDate = _ContractStateDate[tenant];
|
|
if (DateTime.Now.Subtract(oldDate).TotalMinutes > 5)
|
|
{
|
|
//Aktualisiere ContractState alle 5 Minuten
|
|
_ContractStates.Remove(tenant);
|
|
_ContractStateDate.Remove(tenant);
|
|
}
|
|
}
|
|
if (!_ContractStates.ContainsKey(tenant))
|
|
{
|
|
string url = ConfigurationManager.AppSettings.Get("ContractStateUrl");
|
|
url = url.Replace("[TENANT]", tenant);
|
|
url += typ;
|
|
|
|
using (var client = new WebClient())
|
|
{
|
|
//MessageBox.Show(hostAddress);
|
|
byte[] response = client.DownloadData(url);
|
|
|
|
responseStr = Encoding.ASCII.GetString(response);
|
|
_ContractStates[tenant] = responseStr;
|
|
_ContractStateDate[tenant] = DateTime.Now;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
responseStr = _ContractStates[tenant];
|
|
}
|
|
return responseStr;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
|
|
}
|
|
finally
|
|
{
|
|
Monitor.Exit(_Lock);
|
|
}
|
|
|
|
return "";
|
|
}
|
|
|
|
public static void DeleteAdditionalServiceGroupOfPeopleRelations(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
List<AdditionalService2GroupOfPeople> lOriginals = DAOFactory.GenericDAO.LoadByIDs<AdditionalService2GroupOfPeople>(pOid2Version.Select(e => e.Key));
|
|
|
|
lOriginals.DoForEach(or => MapperFactory.AdditionalServiceGroupOfPeopleRelationDC_AdditionalService2GroupOfPeople.ConcurrencyCheck(pOid2Version[or.Oid.Value], or));
|
|
|
|
List<AdditionalService2GroupOfPeople> srListToDelete = lOriginals.ToList();
|
|
|
|
if (srListToDelete.Count > 0)
|
|
DAOFactory.GenericDAO.Delete(srListToDelete);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
private static void AttachAddServiceToAssessment(AdditionalServiceBooking pAdditionalServiceBookingDC)
|
|
{
|
|
try
|
|
{
|
|
var newCategoryDC = new AssessmentSheetCategoryDC { Description = pAdditionalServiceBookingDC.AdditionalServiceRegion.AdditionalService.Name };
|
|
AssessmentSheetCategory lCategory = MapperFactory.AssessmentSheetCategoryDC_AssessmentSheetCategory.MapToNewEntity(newCategoryDC);
|
|
lCategory.SystemEntryID = SystemEntryID.AdditionalServiceAssessmentSheet;
|
|
|
|
AssessmentSheetCategory cat = DAOFactory.SearchDAO.GetAddServiceAssessmentSheetCategoryWithName(lCategory.Description);
|
|
|
|
|
|
if (cat == null)
|
|
{
|
|
DAOFactory.GenericDAO.Insert(lCategory);
|
|
}
|
|
else
|
|
{
|
|
lCategory = cat;
|
|
}
|
|
|
|
IList<AssessmentSheetValue> values = DAOFactory.GenericDAO.GetAll<AssessmentSheetValue>();
|
|
bool yesExists =
|
|
values.Count(
|
|
v =>
|
|
v.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet) &&
|
|
v.Description.Equals("Ja")) == 1;
|
|
|
|
bool noExists =
|
|
values.Count(
|
|
v =>
|
|
v.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet) &&
|
|
v.Description.Equals("Nein")) == 1;
|
|
|
|
var lYes = new AssessmentSheetValue
|
|
{
|
|
Color = "#FF7FFF00",
|
|
Description = "Ja",
|
|
Position = 0,
|
|
Sign = "",
|
|
SystemEntryID = SystemEntryID.AdditionalServiceAssessmentSheet
|
|
};
|
|
|
|
var lNo = new AssessmentSheetValue
|
|
{
|
|
Color = "#FFFF0000",
|
|
Description = "Nein",
|
|
Position = 0,
|
|
Sign = "x",
|
|
SystemEntryID = SystemEntryID.AdditionalServiceAssessmentSheet
|
|
};
|
|
|
|
if (!yesExists)
|
|
{
|
|
DAOFactory.GenericDAO.Insert(lYes);
|
|
}
|
|
else
|
|
{
|
|
lYes = values.First(
|
|
c =>
|
|
c.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet) &&
|
|
c.Description.Equals(lYes.Description));
|
|
}
|
|
|
|
if (!noExists)
|
|
{
|
|
DAOFactory.GenericDAO.Insert(lNo);
|
|
}
|
|
else
|
|
{
|
|
lNo = values.First(
|
|
c =>
|
|
c.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet) &&
|
|
c.Description.Equals(lNo.Description));
|
|
}
|
|
|
|
if (!lCategory.PossibleValues.Contains(lYes))
|
|
DAOFactory.AdoDAO.ExecuteQuery(string.Format("INSERT INTO assessmentsheetcategory2assessmentsheetvalue(assessmentsheetcategoryoid, assessmentsheetvalueoid) VALUES({0}, {1})", lCategory.Oid.Value, lYes.Oid.Value));
|
|
|
|
if (!lCategory.PossibleValues.Contains(lNo))
|
|
DAOFactory.AdoDAO.ExecuteQuery(string.Format("INSERT INTO assessmentsheetcategory2assessmentsheetvalue(assessmentsheetcategoryoid, assessmentsheetvalueoid) VALUES({0}, {1})", lCategory.Oid.Value, lNo.Oid.Value));
|
|
|
|
var entryList = new List<AssessmentSheetEntry>();
|
|
string sqlString = string.Empty;
|
|
|
|
foreach (Customer2AddServiceBooking customerParticipated in pAdditionalServiceBookingDC.Customer2AddServiceBookings)
|
|
{
|
|
var customer = DAOFactory.GenericDAO.GetByID<Customer>(customerParticipated.CustomerOid);
|
|
entryList.Add(new AssessmentSheetEntry
|
|
{
|
|
Customer = customer,
|
|
AssessmentSheetCategory = lCategory,
|
|
AssessmentSheetValue = (customerParticipated.Participated ? lYes : lNo),
|
|
SystemEntryID = SystemEntryID.AdditionalServiceAssessmentSheet,
|
|
Day = pAdditionalServiceBookingDC.Datum
|
|
});
|
|
IList<AssessmentSheetCategory> customer2Category = DAOFactory.GenericDAO.GetAll<AssessmentSheetCategory>();
|
|
AssessmentSheetCategory f = customer2Category.First(
|
|
abc =>
|
|
abc.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet) &&
|
|
abc.Description.Equals(lCategory.Description));
|
|
|
|
if (f.Customers == null || !f.Customers.Contains(customer))
|
|
sqlString += string.Format("INSERT INTO customer2assessmentsheetcategory(customeroid, assessmentsheetoid) VALUES({0}, {1});", customer.Oid.Value, lCategory.Oid.Value);
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Insert(entryList);
|
|
DAOFactory.AdoDAO.ExecuteQuery(sqlString);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
private static void MakeServiceRecordHistoryEntry(IEnumerable<ServiceRecord> lOriginals, IEnumerable<long> serviceRecordOidList, StatementType statementType)
|
|
{
|
|
var hServiceRecords = new List<ServiceRecordHistory>();
|
|
|
|
if (statementType.Equals(StatementType.Insert) && serviceRecordOidList != null)
|
|
{
|
|
int iterator = 0;
|
|
foreach (ServiceRecordHistory history in lOriginals.Select(ServiceRecordOriginal => new ServiceRecordHistory
|
|
{
|
|
TimeStamp = DateTime.Now,
|
|
ChangeType = statementType,
|
|
CostBearer2SupportConcept = ServiceRecordOriginal.CostBearer2SupportConcept,
|
|
CostBearer2SupportConceptOid = ServiceRecordOriginal.CostBearer2SupportConceptOid,
|
|
Customer = ServiceRecordOriginal.Customer,
|
|
CustomerOid = ServiceRecordOriginal.CustomerOid,
|
|
Employee = ServiceRecordOriginal.Employee,
|
|
EmployeeOid = ServiceRecordOriginal.EmployeeOid,
|
|
End = ServiceRecordOriginal.End,
|
|
Group = ServiceRecordOriginal.Group,
|
|
GroupEmployeeCount = ServiceRecordOriginal.GroupEmployeeCount,
|
|
GroupOid = ServiceRecordOriginal.GroupOid,
|
|
GroupPersonCount = ServiceRecordOriginal.GroupPersonCount,
|
|
GroupRoundedDuration = ServiceRecordOriginal.GroupRoundedDuration,
|
|
IP = ServiceRecordOriginal.IP,
|
|
IsActive = ServiceRecordOriginal.IsActive,
|
|
Notice = ServiceRecordOriginal.Notice,
|
|
ServiceRecordOid = serviceRecordOidList.ElementAt(iterator),
|
|
RoundedDuration = ServiceRecordOriginal.RoundedDuration,
|
|
ServiceDescription = ServiceRecordOriginal.ServiceDescription,
|
|
ServiceRecordType = ServiceRecordOriginal.ServiceRecordType,
|
|
ServiceRecordInsTs = ServiceRecordOriginal.InsTs,
|
|
ServiceRecordVersion = ServiceRecordOriginal.Version.Value,
|
|
ServiceRecordInsUser = ServiceRecordOriginal.InsUser,
|
|
ServiceRecordUdpUser = ServiceRecordOriginal.UdpUser,
|
|
Start = ServiceRecordOriginal.Start,
|
|
SupportConcept = ServiceRecordOriginal.SupportConcept,
|
|
SystemEntryID = ServiceRecordOriginal.SystemEntryID,
|
|
DistanceInMeter = ServiceRecordOriginal.DistanceInMeter,
|
|
IsCreatedInMobileClient = ServiceRecordOriginal.IsCreatedInMobileClient
|
|
}))
|
|
{
|
|
iterator++;
|
|
hServiceRecords.Add(history);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
hServiceRecords.AddRange(lOriginals.Select(ServiceRecordOriginal => new ServiceRecordHistory
|
|
{
|
|
TimeStamp = DateTime.Now,
|
|
ChangeType = statementType,
|
|
CostBearer2SupportConcept = ServiceRecordOriginal.CostBearer2SupportConcept,
|
|
CostBearer2SupportConceptOid = ServiceRecordOriginal.CostBearer2SupportConceptOid,
|
|
Customer = ServiceRecordOriginal.Customer,
|
|
CustomerOid = ServiceRecordOriginal.CustomerOid,
|
|
Employee = ServiceRecordOriginal.Employee,
|
|
EmployeeOid = ServiceRecordOriginal.EmployeeOid,
|
|
End = ServiceRecordOriginal.End,
|
|
Group = ServiceRecordOriginal.Group,
|
|
GroupEmployeeCount = ServiceRecordOriginal.GroupEmployeeCount,
|
|
GroupOid = ServiceRecordOriginal.GroupOid,
|
|
GroupPersonCount = ServiceRecordOriginal.GroupPersonCount,
|
|
GroupRoundedDuration = ServiceRecordOriginal.GroupRoundedDuration,
|
|
IP = ServiceRecordOriginal.IP,
|
|
IsActive = ServiceRecordOriginal.IsActive,
|
|
Notice = ServiceRecordOriginal.Notice,
|
|
ServiceRecordOid = ServiceRecordOriginal.Oid,
|
|
RoundedDuration = ServiceRecordOriginal.RoundedDuration,
|
|
ServiceDescription = ServiceRecordOriginal.ServiceDescription,
|
|
ServiceRecordType = ServiceRecordOriginal.ServiceRecordType,
|
|
ServiceRecordInsTs = ServiceRecordOriginal.InsTs,
|
|
ServiceRecordVersion = ServiceRecordOriginal.Version.Value,
|
|
ServiceRecordInsUser = ServiceRecordOriginal.InsUser,
|
|
ServiceRecordUdpUser = ServiceRecordOriginal.UdpUser,
|
|
Start = ServiceRecordOriginal.Start,
|
|
SupportConcept = ServiceRecordOriginal.SupportConcept,
|
|
SystemEntryID = ServiceRecordOriginal.SystemEntryID,
|
|
DistanceInMeter = ServiceRecordOriginal.DistanceInMeter,
|
|
IsCreatedInMobileClient = ServiceRecordOriginal.IsCreatedInMobileClient
|
|
}));
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Insert(hServiceRecords);
|
|
}
|
|
|
|
public IList<TextModuleDC> GetAllTextModules()
|
|
{
|
|
try
|
|
{
|
|
var allTextModules = DAOFactory.GenericDAO.GetAll<TextModule>();
|
|
|
|
return MapperFactory.TextModuleDC_TextModule.CreateDcList(allTextModules);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public IList<TextModuleDC> GetTextModules(bool pShouldShowAllTextModules, long pEmployeeOid, bool pHasRightToSeeAllTextModules, bool pIsInAdministrationView)
|
|
{
|
|
try
|
|
{
|
|
var textmodules = DAOFactory.SearchDAO.GetActiveTextModules(pShouldShowAllTextModules, pHasRightToSeeAllTextModules, pIsInAdministrationView, pEmployeeOid);
|
|
|
|
var abc = textmodules.FirstOrDefault(f => f.Oid == 41);
|
|
var isActive = abc?.IsActive;
|
|
|
|
var list = MapperFactory.TextModuleDC_TextModule.CreateDcList(textmodules);
|
|
|
|
var abcDC = list.FirstOrDefault(f => f.TextModuleOid == 41);
|
|
var activationType = abcDC?.ActivationType;
|
|
|
|
return list.OrderBy(t => t.Name).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public IList<TextModuleDC> GetTextModulesByServiceCategory(long pServiceCategoryOid)
|
|
{
|
|
try
|
|
{
|
|
return MapperFactory.TextModuleDC_TextModule.MapToNewDCs(DAOFactory.SearchDAO.GetActiveTextModuleByServiceCategory(pServiceCategoryOid));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public IList<long> InsertNewTextModules(IEnumerable<TextModuleDC> pTextbausteine)
|
|
{
|
|
try
|
|
{
|
|
var lTextbausteine = MapperFactory.TextModuleDC_TextModule.MapToNewEntities(pTextbausteine);
|
|
|
|
foreach (var tm in lTextbausteine)
|
|
{
|
|
tm.IsActive = ActivationTypeId.Active;
|
|
}
|
|
DAOFactory.GenericDAO.Insert(lTextbausteine);
|
|
|
|
return lTextbausteine.Select(asb => asb.Oid.Value).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateTextModules(List<TextModuleDC> pTextbausteine)
|
|
{
|
|
try
|
|
{
|
|
var lOriginals = DAOFactory.GenericDAO.LoadByIDs<TextModule>(pTextbausteine.Select(sc => sc.TextModuleOid.Value));
|
|
foreach (var item in pTextbausteine)
|
|
{
|
|
item.ActivationType = ActivationTypeId.Active;
|
|
}
|
|
MapperFactory.TextModuleDC_TextModule.MergeWithEntitys(pTextbausteine, lOriginals);
|
|
|
|
DAOFactory.GenericDAO.Update(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteTextModules(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
var lOriginals = DAOFactory.GenericDAO.LoadByIDs<TextModule>(pOid2Version.Select(e => e.Key));
|
|
lOriginals.DoForEach(or => MapperFactory.TextModuleDC_TextModule.ConcurrencyCheck(pOid2Version[or.Oid.Value], or));
|
|
|
|
IList<TextModule> modulesToDelete = new List<TextModule>();
|
|
|
|
foreach (var textModule in lOriginals)
|
|
{
|
|
AddModuleAndChildsToList(textModule, modulesToDelete);
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Delete(modulesToDelete);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
private void AddModuleAndChildsToList(TextModule textModule, IList<TextModule> modulesToDelete)
|
|
{
|
|
var children = DAOFactory.SearchDAO.GetChildTextModules(textModule);
|
|
|
|
foreach (var child in children)
|
|
{
|
|
AddModuleAndChildsToList(child, modulesToDelete);
|
|
}
|
|
|
|
modulesToDelete.Add(textModule);
|
|
}
|
|
|
|
public IList<ServiceRecordDC> FindServiceRecordsInSpan(long pCostBearer2SupportConceptOid, DateTimeSpan period)
|
|
{
|
|
try
|
|
{
|
|
var records = DAOFactory.SearchDAO.FindServiceRecordsInSpan(pCostBearer2SupportConceptOid, period);
|
|
return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(records);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public SignatureDC InsertSignature(SignatureDC s)
|
|
{
|
|
try
|
|
{
|
|
var lSignature = MapperFactory.SignatureDC_Signature.MapToNewEntity(s);
|
|
DAOFactory.GenericDAO.Insert(lSignature);
|
|
var updatedSignatureDC = MapperFactory.SignatureDC_Signature.MapToNewDC(lSignature);
|
|
|
|
if(!s.ServiceRecordOid.HasValue)
|
|
{
|
|
return updatedSignatureDC;
|
|
}
|
|
|
|
var sr = DAOFactory.GenericDAO.LoadByID<ServiceRecord>(s.ServiceRecordOid.Value);
|
|
|
|
sr.SignatureOid = lSignature.Oid;
|
|
|
|
DAOFactory.GenericDAO.Update(sr);
|
|
|
|
return updatedSignatureDC;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
|
|
public EmployeeAPPCodeDC CreateNewEmployeeAPPCodeDC(long employeeOid, string kundennummer, string apikey)
|
|
{
|
|
try
|
|
{
|
|
#if DEBUG
|
|
kundennummer = "0000000001";
|
|
apikey = "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97";
|
|
#endif
|
|
var appCodes = DAOFactory.SearchDAO.FindAllEmployeeAppCodes(employeeOid).ToList();
|
|
|
|
if (appCodes.Any(c => !string.IsNullOrWhiteSpace(c.EmployeeCode)))
|
|
{
|
|
var response = DeletZufallsCode(apikey, kundennummer, "E" + employeeOid);
|
|
|
|
if (response != 0)
|
|
{
|
|
return new EmployeeAPPCodeDC { Result = response };
|
|
}
|
|
}
|
|
|
|
var zufallscode = ErzeugeZufallsCode(apikey, kundennummer, "E" + employeeOid);
|
|
|
|
if (zufallscode != null)
|
|
{
|
|
var appcodes = DAOFactory.SearchDAO.FindAllEmployeeAppCodes(employeeOid).ToList();
|
|
|
|
var newCode = appcodes.Count > 0 ? appcodes[0] : new EmployeeAPPCode { EmployeeOid = employeeOid };
|
|
|
|
newCode.EmployeeCode = zufallscode;
|
|
newCode.EmployeeCodeGenDate = DateTime.Now;
|
|
newCode.NotfallStatement = string.Empty;
|
|
newCode.IsChatAktiv = 1;
|
|
|
|
DAOFactory.GenericDAO.Insert(newCode);
|
|
|
|
var employeeAppCodeDC = MapperFactory.EmployeeAPPCodeDC_EmployeeAPPCode.MapToNewDC(newCode);
|
|
|
|
return employeeAppCodeDC;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateIsChatActiveEmployeeAPPCodeDC(long employeeOid, int activeType)
|
|
{
|
|
try
|
|
{
|
|
var employeecode = DAOFactory.SearchDAO.FindAllEmployeeAppCodes(employeeOid).ToList();
|
|
|
|
foreach (var items in employeecode)
|
|
{
|
|
items.IsChatAktiv = activeType == 1 ? activeType : 0;
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Update(employeecode);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateNotfallNacrichtEmployeeAPPCodeDC(long employeeOid, String notfallstate)
|
|
{
|
|
try
|
|
{
|
|
var employeecode = DAOFactory.SearchDAO.FindAllEmployeeAppCodes(employeeOid).ToList();
|
|
|
|
foreach (var items in employeecode)
|
|
{
|
|
items.NotfallStatement = notfallstate;
|
|
}
|
|
|
|
|
|
DAOFactory.GenericDAO.Update(employeecode);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
|
|
public CustomerAPPCodeDC CreateNewCustomerAPPCodeDC(long customerOid, string kundennummer, string apikey)
|
|
{
|
|
try
|
|
{
|
|
#if DEBUG
|
|
kundennummer = "0000000001";
|
|
apikey = "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97";
|
|
#endif
|
|
|
|
var aa = DAOFactory.SearchDAO.FindAllCustomerAppCodes(customerOid).ToList();
|
|
bool isOk = false;
|
|
if (aa.Where(c => !String.IsNullOrWhiteSpace(c.CustomerCode)).Count() > 0)
|
|
{
|
|
var response = DeletZufallsCode(apikey, kundennummer, "C" + customerOid);
|
|
|
|
if (response == 0)
|
|
{
|
|
isOk = true;
|
|
}
|
|
else
|
|
{
|
|
CustomerAPPCodeDC appcode = new CustomerAPPCodeDC();
|
|
|
|
appcode.Result = response;
|
|
|
|
return appcode;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
isOk = true;
|
|
}
|
|
|
|
|
|
if (isOk)
|
|
{
|
|
string zufallscode = ErzeugeZufallsCode(apikey, kundennummer, "C" + customerOid);
|
|
|
|
if (zufallscode != null)
|
|
{
|
|
var appcodes = DAOFactory.SearchDAO.FindAllCustomerAppCodes(customerOid).ToList();
|
|
CustomerAPPCode newCode = null;
|
|
if (appcodes.Count > 0)
|
|
{
|
|
newCode = appcodes[0];
|
|
}
|
|
else
|
|
{
|
|
newCode = new CustomerAPPCode();
|
|
newCode.CustomerOid = customerOid;
|
|
}
|
|
|
|
newCode.CustomerCode = zufallscode; //bei C noch die UserID mitgeben
|
|
newCode.CustomerCodeGenDate = DateTime.Now;
|
|
newCode.IsChatAktiv = 1;
|
|
|
|
DAOFactory.GenericDAO.Insert(newCode);
|
|
|
|
var customerAPPCodeDC = MapperFactory.CustomerAPPCodeDC_CustomerAPPCode.MapToNewDC(newCode);
|
|
|
|
return customerAPPCodeDC;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public ChatMessageDC CreateNewChatMessagesDC(long senderOid, long empfängerOid, string message, bool isDeliverd, long teamid, string messageid)
|
|
{
|
|
try
|
|
{
|
|
var chatMessage = new ChatMessage
|
|
{
|
|
EmpfaengerPersonOid = empfängerOid,
|
|
SenderPersonOid = senderOid,
|
|
Uhrzeit = DateTime.Now,
|
|
IsDelivered = isDeliverd,
|
|
ChatText = Encoding.UTF8.GetBytes(message),
|
|
IstGelesen = 0,
|
|
MessageId = messageid
|
|
|
|
};
|
|
|
|
if (teamid != 0)
|
|
{
|
|
chatMessage.TeamOid = teamid;
|
|
}
|
|
else
|
|
{
|
|
chatMessage.TeamOid = null;
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Insert(chatMessage);
|
|
|
|
var ChatMessagesDC = MapperFactory.ChatMessagesDC_ChatMessages.MapToNewDC(chatMessage);
|
|
|
|
return ChatMessagesDC;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateIsChatActiveCustomerAPPCodeDC(long customerOid, int activeType)
|
|
{
|
|
try
|
|
{
|
|
var customerChatCodes = DAOFactory.SearchDAO.FindAllCustomerAppCodes(customerOid).ToList();
|
|
|
|
foreach (var items in customerChatCodes)
|
|
{
|
|
items.IsChatAktiv = activeType == 1 ? activeType : 0;
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Update(customerChatCodes);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public IList<CustomerAPPCodeDC> GetIsChatActiveCustomerAPPCodeDC(long customerOid, int activeType)
|
|
{
|
|
try
|
|
{
|
|
var customercode = DAOFactory.SearchDAO.FindAllCustomerAppCodes(customerOid);
|
|
|
|
return MapperFactory.CustomerAPPCodeDC_CustomerAPPCode.MapToNewDCs(customercode);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public int DeletZufallsCode(string apikey, string customerId, string userId)
|
|
{
|
|
try
|
|
{
|
|
#if DEBUG
|
|
customerId = "0000000001";
|
|
apikey = "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97";
|
|
//customerId = "4526293996";
|
|
#endif
|
|
|
|
var serverUrl = OwnChatHelper.ErmittleServerURL(customerId);
|
|
|
|
if (serverUrl.IsNullOrEmpty())
|
|
{
|
|
return 3; // ServerURl konnte nicht ermittelt werden
|
|
}
|
|
|
|
try
|
|
{
|
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
|
|
|
var url = $"{serverUrl}/api/ownchat/chatcode/revoke/{apikey}/{customerId}/{userId}";
|
|
|
|
var client = new RestClient(url);
|
|
var request = new RestRequest(Method.GET);
|
|
|
|
var response = client.Execute(request);
|
|
|
|
var result = JsonConvert.DeserializeAnonymousType(response.Content, new { Result = string.Empty });
|
|
|
|
return Convert.ToInt32(result.Result);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public string ErzeugeZufallsCode(string apikey, string customerId, string userId)
|
|
{
|
|
|
|
var serverUrl = OwnChatHelper.ErmittleServerURL(customerId);
|
|
|
|
try
|
|
{
|
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
|
|
|
var url = $"{serverUrl}/api/ownchat/chatcode/create/{apikey}/{customerId}/{userId}";
|
|
|
|
var client = new RestClient(url);
|
|
var request = new RestRequest(Method.GET);
|
|
|
|
var response = client.Execute(request);
|
|
|
|
var result = JsonConvert.DeserializeAnonymousType(response.Content, new { Result = string.Empty, ChatCode = string.Empty });
|
|
|
|
return !result.Result.Equals("0") ? null : result.ChatCode;
|
|
|
|
//var request = WebRequest.Create(url);
|
|
|
|
//request.Credentials = CredentialCache.DefaultCredentials;
|
|
|
|
//var response = request.GetResponse();
|
|
|
|
//var responseFromServer = ReadStreamForChatCode(response);
|
|
|
|
//var definiti = new {result = string.Empty, chatcode = string.Empty };
|
|
|
|
//var jsonDatentyp = JsonConvert.DeserializeAnonymousType(responseFromServer, definiti);
|
|
|
|
//response.Close();
|
|
|
|
//return !jsonDatentyp.result.Equals("0") ? null : jsonDatentyp.chatcode;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
//private static string ErmittleServerURL(string customerId)
|
|
//{
|
|
// try
|
|
// {
|
|
// ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
|
|
|
// var url = "https://dict.ownchat.de/api/server/resolve/1/" + customerId;
|
|
|
|
// var client = new RestClient(url);
|
|
// var request = new RestRequest(Method.GET);
|
|
|
|
// var response = client.Execute(request);
|
|
|
|
// var result = JsonConvert.DeserializeAnonymousType(response.Content, new { Status = string.Empty, Url = string.Empty, SyncType = string.Empty });
|
|
|
|
// return result.Url;
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// throw Utils.CreateBeWoFaultException(e);
|
|
// }
|
|
//}
|
|
|
|
private static string ReadStreamForChatCode(WebResponse response)
|
|
{
|
|
try
|
|
{
|
|
var dataStream = response.GetResponseStream();
|
|
|
|
var reader = new StreamReader(dataStream);
|
|
|
|
var responseFromServer = reader.ReadToEnd();
|
|
|
|
dataStream.Dispose();
|
|
reader.Dispose();
|
|
|
|
dataStream.Close();
|
|
reader.Close();
|
|
|
|
return responseFromServer;
|
|
}
|
|
catch (Exception)
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public List<ChatMessageDC> FindUnreadChatMessagesForRecipient(long personOid)
|
|
{
|
|
try
|
|
{
|
|
var chatMessage = DAOFactory.SearchDAO.FindUnreadChatMessagesForRecipient(personOid);
|
|
|
|
var ChatMessagesDC = MapperFactory.ChatMessagesDC_ChatMessages.MapToNewDCs(chatMessage);
|
|
|
|
return ChatMessagesDC;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public long InsertNewServiceRecordAndSignature(ServiceRecordDC sr, SignatureDC sig)
|
|
{
|
|
|
|
try
|
|
{
|
|
var dcList = new List<ServiceRecordDC> { sr };
|
|
|
|
var oidList = InsertNewServiceRecords(dcList);
|
|
var serviceRecordOid = oidList[0];
|
|
|
|
if (!string.IsNullOrEmpty(sig.DataBild))
|
|
{
|
|
var lSignature = MapperFactory.SignatureDC_Signature.MapToNewEntity(sig);
|
|
|
|
DAOFactory.GenericDAO.Insert(lSignature);
|
|
}
|
|
|
|
return serviceRecordOid;
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public string CreateDefaultServiceRecords(DateTime monat, IList<long> oids)
|
|
{
|
|
try
|
|
{
|
|
var s = PluginLoader.FindClass<SchulbegleitenderDienstService>();
|
|
|
|
return s.CreateDefaultServiceRecords(monat, oids);
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public String CreateDefaultCustomerServiceRecords(DateTime start, DateTime end, IList<long> customerOids)
|
|
{
|
|
try
|
|
{
|
|
var s = PluginLoader.FindClass<OperationService>();
|
|
|
|
return s.CreateDefaultCustomerServiceRecords(start, end, customerOids);
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public List<OrganisationPersonRelationDC> LoadOrganisationPersonRelationsByOid(IEnumerable<long> pOids)
|
|
{
|
|
try
|
|
{
|
|
var customerPersonRels = DAOFactory.GenericDAO.LoadByIDs<Organisation2Person>(pOids);
|
|
|
|
return MapperFactory.OrganisationPersonRelDC_Organisation2PersonMapper.MapToNewDCs(customerPersonRels);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ArbeitszeitDC> LoadArbeitszeitenForObject(TableID objectTid, long objectOid)
|
|
{
|
|
try
|
|
{
|
|
var arbeitszeiten = DAOFactory.SearchDAO.FindArbeitszeiten(objectTid, objectOid);
|
|
|
|
return MapperFactory.ArbeitszeitDC_Arbeitszeit.MapToNewDCs(arbeitszeiten);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<BargeldkassenDC> LoadBargeldkassenForObject(TableID objectTid, long objectOid)
|
|
{
|
|
try
|
|
{
|
|
var bargeldkassen = DAOFactory.SearchDAO.FindBargeldkasse(objectTid, objectOid);
|
|
|
|
return MapperFactory.BargeldkassenDCBargeldkasseDC_BargeldkassenDCBargeldkasse.MapToNewDCs(bargeldkassen);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public long InsertNewBargeldkasse(BargeldkassenDC pBargeldkasse)
|
|
{
|
|
try
|
|
{
|
|
var lBargeldkasse = MapperFactory.BargeldkassenDCBargeldkasseDC_BargeldkassenDCBargeldkasse.MapToNewEntity(pBargeldkasse);
|
|
DAOFactory.GenericDAO.Insert(lBargeldkasse);
|
|
|
|
return lBargeldkasse.Oid.Value;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public BargeldkassenDC UpdateBargeldkasse(BargeldkassenDC pBargeldkasse)
|
|
{
|
|
try
|
|
{
|
|
var lOriginal = DAOFactory.GenericDAO.LoadByID<Bargeldkasse>(pBargeldkasse.BargeldkassenOid.Value);
|
|
|
|
MapperFactory.BargeldkassenDCBargeldkasseDC_BargeldkassenDCBargeldkasse.MergeWithEntity(pBargeldkasse, lOriginal);
|
|
DAOFactory.GenericDAO.Update(lOriginal);
|
|
|
|
return MapperFactory.BargeldkassenDCBargeldkasseDC_BargeldkassenDCBargeldkasse.MapToNewDC(lOriginal);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeactivateBargeldkasse(long pOid, long pVersion)
|
|
{
|
|
try
|
|
{
|
|
ServiceLogic.SetActivationType<Bargeldkasse>(new Dictionary<long, long> { { pOid, pVersion } }, ActivationTypeId.Deleted);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<NotizenKategorieDC> LoadNotizenKategorienForObject(TableID objectTid, long objectOid)
|
|
{
|
|
try
|
|
{
|
|
var kategorien = DAOFactory.SearchDAO.FindNotizenKategorien(objectTid, objectOid);
|
|
|
|
if (kategorien.Count == 0)
|
|
{
|
|
var newKat = new NotizenKategorie();
|
|
newKat.KategorieName = "Gesprächsnotizen";
|
|
newKat.ObjectOid = objectOid;
|
|
newKat.ObjectTid = objectTid;
|
|
DAOFactory.GenericDAO.Insert(newKat);
|
|
|
|
kategorien.Add(newKat);
|
|
}
|
|
|
|
return MapperFactory.NotizenKategorieDC_NotizenKategorie.MapToNewDCs(kategorien.Where(k => k.IsActive == ActivationTypeId.Active));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public long InsertNewNotizenKategorie(NotizenKategorieDC kategorie)
|
|
{
|
|
try
|
|
{
|
|
var entity = MapperFactory.NotizenKategorieDC_NotizenKategorie.MapToNewEntity(kategorie);
|
|
DAOFactory.GenericDAO.Insert(entity);
|
|
|
|
return entity.Oid.Value;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public NotizenKategorieDC UpdateNotizenKategorie(NotizenKategorieDC kategorie)
|
|
{
|
|
try
|
|
{
|
|
var lOriginal = DAOFactory.GenericDAO.LoadByID<NotizenKategorie>(kategorie.NotizenKategorieOid.Value);
|
|
kategorie.NotizenKategorieVersion = lOriginal.Version;
|
|
|
|
MapperFactory.NotizenKategorieDC_NotizenKategorie.MergeWithEntity(kategorie, lOriginal);
|
|
DAOFactory.GenericDAO.Update(lOriginal);
|
|
|
|
return MapperFactory.NotizenKategorieDC_NotizenKategorie.MapToNewDC(lOriginal);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeactivateNotizenEintrag(long pOid, long pVersion)
|
|
{
|
|
try
|
|
{
|
|
ServiceLogic.SetActivationType<NotizenEintrag>(new Dictionary<long, long> { { pOid, pVersion } }, ActivationTypeId.Deleted);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeactivateNotizenKategorie(long pOid, long pVersion)
|
|
{
|
|
try
|
|
{
|
|
ServiceLogic.SetActivationType<NotizenKategorie>(new Dictionary<long, long> { { pOid, pVersion } }, ActivationTypeId.Deleted);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeactivateAbsenceTime(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
//ServiceLogic.SetActivationType<AbsenceTime>(pOid2Version, ActivationTypeId.Deleted);
|
|
|
|
var lOriginals = DAOFactory.GenericDAO.LoadByIDs<AbsenceTime>(pOid2Version.Select(e => e.Key)).Where(e => e.SystemEntryID == null).ToList();
|
|
DAOFactory.GenericDAO.Delete(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void InsertNewEmployeeAbsenceTime(long employeeOid, AbsenceTimeDC at)
|
|
{
|
|
try
|
|
{
|
|
var emp = DAOFactory.GenericDAO.GetByID<Employee>(employeeOid);
|
|
emp.AbsenceTimes.Add(MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewEntity(at));
|
|
|
|
DAOFactory.GenericDAO.Update(emp);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void InsertNewCustomerAbsenceTime(long customerOid, AbsenceTimeDC at)
|
|
{
|
|
try
|
|
{
|
|
var cust = DAOFactory.GenericDAO.GetByID<Customer>(customerOid);
|
|
cust.AbsenceTimes.Add(MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewEntity(at));
|
|
|
|
|
|
DAOFactory.GenericDAO.Update(cust);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteVertretung(long vert)
|
|
{
|
|
try
|
|
{
|
|
var origVertretung = DAOFactory.GenericDAO.LoadByID<Vertretung>(vert);
|
|
|
|
DAOFactory.GenericDAO.Delete(origVertretung);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateVertretung(VertretungDC vert)
|
|
{
|
|
try
|
|
{
|
|
var origVertretung = DAOFactory.GenericDAO.LoadByID<Vertretung>(vert.VertretungOid.Value);
|
|
|
|
// TODO: Beim Aufruf dieser Methode prüfen, ob eine Vertretung sich mit dem Objekt überschneidet
|
|
var isOverlapping = DAOFactory.SearchDAO.CheckForOverlappingSubstitutions(vert.EmployeeOid, vert.CustomerOid, vert.VertretungsZeitraumVon, vert.VertretungsZeitraumBis, vert.VertretungOid);
|
|
|
|
MapperFactory.VertretungDC_Vertretung.MergeWithEntity(vert, origVertretung);
|
|
|
|
DAOFactory.GenericDAO.Update(origVertretung);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateVertretungAndAbsenceTime(VertretungDC vert, AbsenceTimeDC abs)
|
|
{
|
|
try
|
|
{
|
|
var origVertretung = DAOFactory.GenericDAO.LoadByID<Vertretung>(vert.VertretungOid.Value);
|
|
|
|
MapperFactory.VertretungDC_Vertretung.MergeWithEntity(vert, origVertretung);
|
|
|
|
DAOFactory.GenericDAO.Update(origVertretung);
|
|
|
|
|
|
//Update AbsenceTime
|
|
var origAbsenceTime = DAOFactory.GenericDAO.LoadByID<AbsenceTime>(abs.AbsenceTimeOid.Value);
|
|
|
|
MapperFactory.AbsenceTimeDC_AbsenceTime.MergeWithEntity(abs, origAbsenceTime);
|
|
|
|
DAOFactory.GenericDAO.Update(origAbsenceTime);
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void CreateVertretung(VertretungDC vertretung)
|
|
{
|
|
try
|
|
{
|
|
var x = MapperFactory.VertretungDC_Vertretung.MapToNewEntity(vertretung);
|
|
|
|
DAOFactory.GenericDAO.Insert(x);
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateAbsenceTime(AbsenceTimeDC abs)
|
|
{
|
|
try
|
|
{
|
|
var x = DAOFactory.GenericDAO.LoadByID<AbsenceTime>(abs.AbsenceTimeOid.Value);
|
|
|
|
MapperFactory.AbsenceTimeDC_AbsenceTime.MergeWithEntity(abs, x);
|
|
|
|
DAOFactory.GenericDAO.Update(x);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<VertretungsItemDC> GetVertretungsListe(DateTime datum)
|
|
{
|
|
try
|
|
{
|
|
var vertretungsManager = new VertretungsManager();
|
|
return vertretungsManager.CreateVertretungsListe(datum.Date, datum.Date);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<VertretungsListeMitarbeiterItemsDC> VertretungsMitarbeiterListeWoechentlich(DateTime start, DateTime ende)
|
|
{
|
|
try
|
|
{
|
|
// VertretungsManager mgr = new VertretungsManager();
|
|
|
|
//var x = mgr.CreateVertretungsListe(start, ende);
|
|
|
|
// return x;
|
|
return null;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public VertretungsKlientAccountingsListeItemsDC KlientenAbschlagsInfoListe(DateTime start, DateTime end)
|
|
{
|
|
try
|
|
{
|
|
//VertretungsAlgorithmus alorythmus = new VertretungsAlgorithmus(start, end,3);
|
|
|
|
//VertretungsKlientAccountingsListeItemsDC cusAcc = new VertretungsKlientAccountingsListeItemsDC();
|
|
|
|
//cusAcc.CustomerAccountItemList = alorythmus.c2a;
|
|
|
|
//return cusAcc;
|
|
return null;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<VertretungsItemDC> GetVertretungsListeForTimeSpan(DateTime start, DateTime ende)
|
|
{
|
|
try
|
|
{
|
|
var mgr = new VertretungsManager();
|
|
|
|
|
|
return mgr.CreateVertretungsListe(start.Date, ende.Date);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
|
|
}
|
|
|
|
public List<CompactVertreterEmployeeDC> GetLastVertreter(long? klientenOid)
|
|
{
|
|
try
|
|
{
|
|
List<Vertretung> vlist = new List<Vertretung>();
|
|
|
|
var vertreter = DAOFactory.GenericDAO.GetAllActive<Vertretung>();
|
|
|
|
foreach (var vert in vertreter)
|
|
{
|
|
if (vert.CustomerOid == klientenOid)
|
|
{
|
|
vlist.Add(vert);
|
|
}
|
|
}
|
|
|
|
List<long> emOidList = new List<long>();
|
|
|
|
foreach (var empoid in vlist)
|
|
{
|
|
if (empoid.VertretenderMitarbeiterOid.HasValue)
|
|
{
|
|
emOidList.Add(empoid.VertretenderMitarbeiterOid.Value);
|
|
}
|
|
}
|
|
|
|
|
|
var employee = DAOFactory.GenericDAO.GetActiveByIDs<Employee>(emOidList);
|
|
|
|
var x = MapperFactory.CompactVertreterEmployeeDC_VertreterEmployee.MapToNewDCs(employee);
|
|
//var x = MapperFactory.CompactEmployeeDC_Employee.MapToNewDCs(employee);
|
|
|
|
return x;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<CompactTokenDC> GetAllTokens(SchulbegleitenderZugehoerigkeitsTyp zugehoerigkeitsTyp, long? oid)
|
|
{
|
|
try
|
|
{
|
|
var token = DAOFactory.GenericDAO.GetAllActive<Token>();
|
|
|
|
IList<Token> fToken = new List<Token>();
|
|
|
|
if (zugehoerigkeitsTyp == SchulbegleitenderZugehoerigkeitsTyp.Klient)
|
|
{
|
|
var x = GetCustomer2TokenList();
|
|
|
|
foreach (var item in token)
|
|
{
|
|
foreach (var c2t in x)
|
|
{
|
|
if (item.Oid == c2t.Token.TokenOid && c2t.Customer.CustomerOid == oid)
|
|
{
|
|
item.MemberOid = oid;
|
|
fToken.Add(item);
|
|
}
|
|
else if (item.Oid == c2t.Token.TokenOid)
|
|
{
|
|
fToken.Add(item);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (zugehoerigkeitsTyp == SchulbegleitenderZugehoerigkeitsTyp.Mitarbeiter)
|
|
{
|
|
var x = GetEmployee2TokenList();
|
|
|
|
foreach (var item in token)
|
|
{
|
|
foreach (var e2t in x)
|
|
{
|
|
if (item.Oid == e2t.Token.TokenOid && e2t.Employee.EmployeeOid == oid)
|
|
{
|
|
item.MemberOid = oid;
|
|
fToken.Add(item);
|
|
}
|
|
else if (item.Oid == e2t.Token.TokenOid)
|
|
{
|
|
fToken.Add(item);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
return MapperFactory.CompactTokenDC_Token.MapToNewDCs(fToken);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateToken(TokenDC token)
|
|
{
|
|
try
|
|
{
|
|
var t = MapperFactory.TokenDC_Token.MapToNewEntity(token);
|
|
|
|
DAOFactory.GenericDAO.Update(t);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void InsertNewToken(string beschreibung, TokenTyp typ, SchulbegleitenderZugehoerigkeitsTyp zugehoerigkeitsTyp, long? oid)
|
|
{
|
|
try
|
|
{
|
|
TokenDC token = new TokenDC()
|
|
{
|
|
Beschreibung = beschreibung,
|
|
TokenTyp = typ
|
|
};
|
|
|
|
if (zugehoerigkeitsTyp == SchulbegleitenderZugehoerigkeitsTyp.Klient)
|
|
{
|
|
var x = DAOFactory.GenericDAO.GetByID<Customer>(oid.Value);
|
|
|
|
var xyz = MapperFactory.CustomerDC_Customer.MapToNewDC(x);
|
|
|
|
CustomerTokenRelationDC c2t = new CustomerTokenRelationDC()
|
|
{
|
|
Customer = xyz
|
|
};
|
|
|
|
List<CustomerTokenRelationDC> c2tList = new List<CustomerTokenRelationDC>();
|
|
c2tList.Add(c2t);
|
|
|
|
token.RelatedCustomers = c2tList;
|
|
|
|
}
|
|
else if (zugehoerigkeitsTyp == SchulbegleitenderZugehoerigkeitsTyp.Mitarbeiter)
|
|
{
|
|
var x = DAOFactory.GenericDAO.GetByID<Employee>(oid.Value);
|
|
|
|
var xyz = MapperFactory.EmployeeDC_Employee.MapToNewDC(x);
|
|
|
|
EmployeeTokenRelationDC e2t = new EmployeeTokenRelationDC()
|
|
{
|
|
Employee = xyz
|
|
};
|
|
|
|
List<EmployeeTokenRelationDC> e2tList = new List<EmployeeTokenRelationDC>();
|
|
e2tList.Add(e2t);
|
|
|
|
token.RelatedEmployees = e2tList;
|
|
}
|
|
|
|
var t = MapperFactory.TokenDC_Token.MapToNewEntity(token);
|
|
|
|
DAOFactory.GenericDAO.Insert(t);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DoTokenAusschlussOperation(int art, long? Oid, SchulbegleitenderZugehoerigkeitsTyp zugehoerigkeitsTyp, Dictionary<string, CompactTokenDC> verfuegbarerAusschlussToken, string token)
|
|
{
|
|
try
|
|
{
|
|
if (art == 1)
|
|
{
|
|
if (verfuegbarerAusschlussToken.ContainsKey(token))
|
|
{
|
|
CompactTokenDC nToken = null;
|
|
|
|
foreach (var tokenkey in verfuegbarerAusschlussToken)
|
|
{
|
|
if (tokenkey.Key.Equals(token))
|
|
{
|
|
nToken = tokenkey.Value;
|
|
}
|
|
}
|
|
|
|
if (nToken != null)
|
|
{
|
|
InsertNewRelationToken(nToken, TokenTyp.AusschlussKriterium, zugehoerigkeitsTyp, Oid);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
InsertNewToken(token, TokenTyp.AusschlussKriterium, zugehoerigkeitsTyp, Oid);
|
|
}
|
|
}
|
|
|
|
if (art == 0)
|
|
{
|
|
if (verfuegbarerAusschlussToken.ContainsKey(token))
|
|
{
|
|
CompactTokenDC nToken = null;
|
|
|
|
foreach (var tokenkey in verfuegbarerAusschlussToken)
|
|
{
|
|
if (tokenkey.Key.Equals(token))
|
|
{
|
|
nToken = tokenkey.Value;
|
|
}
|
|
}
|
|
|
|
if (nToken != null)
|
|
{
|
|
DeletTokenRelation(nToken, Oid, zugehoerigkeitsTyp);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (zugehoerigkeitsTyp == SchulbegleitenderZugehoerigkeitsTyp.Klient)
|
|
{
|
|
var c2tList = GetCustomer2TokenList();
|
|
|
|
List<CompactTokenDC> otoken = new List<CompactTokenDC>();
|
|
|
|
foreach (var ct2 in c2tList)
|
|
{
|
|
if (ct2.Token.Beschreibung.Equals(token) && ct2.Customer.CustomerOid == Oid)
|
|
{
|
|
otoken.Add(ct2.Token);
|
|
}
|
|
}
|
|
|
|
foreach (var ken in otoken)
|
|
{
|
|
if (ken != null)
|
|
DeletTokenRelation(ken, Oid, zugehoerigkeitsTyp);
|
|
}
|
|
}
|
|
else if (zugehoerigkeitsTyp == SchulbegleitenderZugehoerigkeitsTyp.Mitarbeiter)
|
|
{
|
|
var e2tList = GetEmployee2TokenList();
|
|
|
|
List<CompactTokenDC> otoken = new List<CompactTokenDC>();
|
|
|
|
foreach (var et2 in e2tList)
|
|
{
|
|
|
|
if (et2.Token.Beschreibung.Equals(token) && et2.Employee.EmployeeOid == Oid)
|
|
{
|
|
otoken.Add(et2.Token);
|
|
}
|
|
}
|
|
|
|
foreach (var ken in otoken)
|
|
{
|
|
DeletTokenRelation(ken, Oid, zugehoerigkeitsTyp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DoTokenWunschOperation(int art, long? Oid, SchulbegleitenderZugehoerigkeitsTyp zugehoerigkeitsTyp, Dictionary<string, CompactTokenDC> verfuegbarerWunschToken, string token)
|
|
{
|
|
try
|
|
{
|
|
if (art == 1)
|
|
{
|
|
if (verfuegbarerWunschToken.ContainsKey(token))
|
|
{
|
|
CompactTokenDC nToken = null;
|
|
|
|
foreach (var tokenkey in verfuegbarerWunschToken)
|
|
{
|
|
if (tokenkey.Key.Equals(token))
|
|
{
|
|
nToken = tokenkey.Value;
|
|
}
|
|
}
|
|
|
|
if (nToken != null)
|
|
{
|
|
InsertNewRelationToken(nToken, TokenTyp.WunschKriterium, zugehoerigkeitsTyp, Oid);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
InsertNewToken(token.ToString(), TokenTyp.WunschKriterium, zugehoerigkeitsTyp, Oid);
|
|
}
|
|
|
|
}
|
|
|
|
if (art == 0)
|
|
{
|
|
if (verfuegbarerWunschToken.ContainsKey(token))
|
|
{
|
|
CompactTokenDC nToken = null;
|
|
|
|
foreach (var tokenkey in verfuegbarerWunschToken)
|
|
{
|
|
if (tokenkey.Key.Equals(token))
|
|
{
|
|
nToken = tokenkey.Value;
|
|
}
|
|
}
|
|
|
|
if (nToken != null)
|
|
{
|
|
DeletTokenRelation(nToken, Oid, zugehoerigkeitsTyp);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (zugehoerigkeitsTyp == SchulbegleitenderZugehoerigkeitsTyp.Klient)
|
|
{
|
|
var c2tList = GetCustomer2TokenList();
|
|
|
|
List<CompactTokenDC> otoken = new List<CompactTokenDC>();
|
|
|
|
foreach (var ct2 in c2tList)
|
|
{
|
|
if (ct2.Token.Beschreibung.Equals(token) && ct2.Customer.CustomerOid == Oid)
|
|
{
|
|
otoken.Add(ct2.Token);
|
|
}
|
|
}
|
|
|
|
foreach (var ken in otoken)
|
|
{
|
|
DeletTokenRelation(ken, Oid, zugehoerigkeitsTyp);
|
|
}
|
|
}
|
|
else if (zugehoerigkeitsTyp == SchulbegleitenderZugehoerigkeitsTyp.Mitarbeiter)
|
|
{
|
|
var e2tList = GetEmployee2TokenList();
|
|
|
|
List<CompactTokenDC> otoken = new List<CompactTokenDC>();
|
|
|
|
foreach (var et2 in e2tList)
|
|
{
|
|
if (et2.Token.Beschreibung.Equals(token) && et2.Employee.EmployeeOid == Oid)
|
|
{
|
|
otoken.Add(et2.Token);
|
|
}
|
|
}
|
|
|
|
foreach (var ken in otoken)
|
|
{
|
|
DeletTokenRelation(ken, Oid, zugehoerigkeitsTyp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void InsertNewRelationToken(CompactTokenDC ctoken, TokenTyp typ, SchulbegleitenderZugehoerigkeitsTyp zugehoerigkeitsTyp, long? oid)
|
|
{
|
|
try
|
|
{
|
|
var tk = DAOFactory.GenericDAO.GetByID<Token>(ctoken.TokenOid.Value);
|
|
|
|
var token = MapperFactory.TokenDC_Token.MapToNewDC(tk);
|
|
|
|
if (zugehoerigkeitsTyp == SchulbegleitenderZugehoerigkeitsTyp.Klient)
|
|
{
|
|
var x = DAOFactory.GenericDAO.GetByID<Customer>(oid.Value);
|
|
|
|
var xyz = MapperFactory.CustomerDC_Customer.MapToNewDC(x);
|
|
|
|
CustomerTokenRelationDC c2t = new CustomerTokenRelationDC()
|
|
{
|
|
Customer = xyz
|
|
};
|
|
|
|
List<CustomerTokenRelationDC> c2tList = new List<CustomerTokenRelationDC>();
|
|
c2tList.Add(c2t);
|
|
|
|
token.RelatedCustomers = c2tList;
|
|
|
|
}
|
|
else if (zugehoerigkeitsTyp == SchulbegleitenderZugehoerigkeitsTyp.Mitarbeiter)
|
|
{
|
|
var x = DAOFactory.GenericDAO.GetByID<Employee>(oid.Value);
|
|
|
|
var xyz = MapperFactory.EmployeeDC_Employee.MapToNewDC(x);
|
|
|
|
EmployeeTokenRelationDC e2t = new EmployeeTokenRelationDC()
|
|
{
|
|
Employee = xyz
|
|
};
|
|
|
|
List<EmployeeTokenRelationDC> e2tList = new List<EmployeeTokenRelationDC>();
|
|
e2tList.Add(e2t);
|
|
|
|
token.RelatedEmployees = e2tList;
|
|
}
|
|
|
|
var tok = DAOFactory.GenericDAO.GetByID<Token>(token.TokenOid.Value);
|
|
|
|
var t = MapperFactory.TokenDC_Token.MergeWithEntity(token, tok);
|
|
|
|
DAOFactory.GenericDAO.Update(t);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteToken(TokenDC token)
|
|
{
|
|
try
|
|
{
|
|
var t = MapperFactory.TokenDC_Token.MapToNewEntity(token);
|
|
|
|
DAOFactory.GenericDAO.Delete(t);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeletTokenRelation(CompactTokenDC token, long? oid, SchulbegleitenderZugehoerigkeitsTyp typ)
|
|
{
|
|
try
|
|
{
|
|
if (typ == SchulbegleitenderZugehoerigkeitsTyp.Klient)
|
|
{
|
|
var tokenEntity = DAOFactory.GenericDAO.LoadByID<Token>(token.TokenOid.Value);
|
|
|
|
Customer2Token t = null;
|
|
|
|
foreach (var c2tToken in tokenEntity.Customer2TokenList)
|
|
{
|
|
if (c2tToken.Customer.Oid == oid)
|
|
{
|
|
t = c2tToken;
|
|
}
|
|
}
|
|
|
|
if (t != null)
|
|
{
|
|
tokenEntity.Customer2TokenList.Remove(t);
|
|
DAOFactory.GenericDAO.Update(tokenEntity);
|
|
}
|
|
}
|
|
else if (typ == SchulbegleitenderZugehoerigkeitsTyp.Mitarbeiter)
|
|
{
|
|
var tokenEntity = DAOFactory.GenericDAO.LoadByID<Token>(token.TokenOid.Value);
|
|
|
|
Employee2Token t = null;
|
|
|
|
foreach (var e2tToken in tokenEntity.Employee2TokenList)
|
|
{
|
|
if (e2tToken.Employee.Oid == oid)
|
|
{
|
|
t = e2tToken;
|
|
}
|
|
}
|
|
|
|
if (t != null)
|
|
{
|
|
tokenEntity.Employee2TokenList.Remove(t);
|
|
DAOFactory.GenericDAO.Update(tokenEntity);
|
|
}
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<CustomerTokenRelationDC> GetCustomer2TokenList()
|
|
{
|
|
try
|
|
{
|
|
var x = DAOFactory.GenericDAO.GetAllActive<Customer2Token>();
|
|
|
|
var y = MapperFactory.CustomerTokenRelationDC_Customer2Token.MapToNewDCs(x);
|
|
|
|
return y;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<EmployeeTokenRelationDC> GetEmployee2TokenList()
|
|
{
|
|
try
|
|
{
|
|
var x = DAOFactory.GenericDAO.GetAllActive<Employee2Token>();
|
|
|
|
var y = MapperFactory.EmployeeTokenRelationDC_Employee2Token.MapToNewDCs(x);
|
|
|
|
return y;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public string PrepareAuslastungReport(AuslastungAnalysisRootDC pReport, string id)
|
|
{
|
|
try
|
|
{
|
|
string lResult = id + ".xml";
|
|
|
|
string lDir = BS.Shared.Core.Utils.CreateSavePath(AppDomain.CurrentDomain.BaseDirectory, MultitenancyOperationContextExt.Current.Tenant + @"\temp");
|
|
string lPath = BS.Shared.Core.Utils.CreateSavePath(lDir, lResult);
|
|
|
|
BS.Shared.Core.Utils.XMLSerialize(lPath, pReport);
|
|
|
|
return lResult;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw (Utils.CreateBeWoFaultException(e));
|
|
}
|
|
}
|
|
|
|
public ServiceRecordStatisticsInfoDC GetServiceRecordStatisticInfo(long costBearer2SupportConceptOid, DateTime statisticsDate)
|
|
{
|
|
var factory = PluginLoader.FindClass<ServiceRecordStatisticFactory>();
|
|
|
|
if (factory != null)
|
|
{
|
|
return factory.GetServiceRecordStatisticInfo(costBearer2SupportConceptOid, statisticsDate);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public SupportConceptStatisticsDC CreateSupportConceptStatistics(long costBearer2SupportConceptOid, DateTime statisticsDate)
|
|
{
|
|
var factory = PluginLoader.FindClass<ServiceRecordStatisticFactory>();
|
|
|
|
|
|
if (factory == null)
|
|
{
|
|
factory = new ServiceRecordStatisticFactory();
|
|
}
|
|
|
|
return factory.CreateSupportConceptStatistics(costBearer2SupportConceptOid, statisticsDate);
|
|
}
|
|
|
|
public void ResetTenant(String tenant)
|
|
{
|
|
WCFHibernateSessionManager.ResetSessionFactory(tenant);
|
|
}
|
|
|
|
public void ResetAllTenants()
|
|
{
|
|
//WCFHibernateSessionManager.ResetAllSessionFactories();
|
|
}
|
|
|
|
public String GetLicenseOrderUrl()
|
|
{
|
|
var url = ConfigurationManager.AppSettings.Get("LicenseOrderUrl");
|
|
url = url.Replace("[TENANT]", MultitenancyOperationContextExt.Current.Tenant);
|
|
|
|
|
|
return url;
|
|
}
|
|
|
|
public String GetLicenseOrderUrlNeu(String type)
|
|
{
|
|
var url = ConfigurationManager.AppSettings.Get("LicenseOrderUrl");
|
|
url = url.Replace("[TENANT]", MultitenancyOperationContextExt.Current.Tenant);
|
|
if (type == "1")
|
|
{
|
|
url += "&LicenseType=1";
|
|
}
|
|
else if (type == "2")
|
|
{
|
|
var m = GetMandator2(false);
|
|
if (!m.AllowSbd)
|
|
{
|
|
return "";
|
|
}
|
|
url += "&LicenseType=2";
|
|
}
|
|
|
|
return url;
|
|
}
|
|
|
|
public LicenseInfoDC GetLicenseInfo()
|
|
{
|
|
return SecurityUtils.GetLicenseInfo();
|
|
}
|
|
|
|
public GroupDurationDC CalculateGroupDuration(int personCount, int employeeCount, decimal totalDuration)
|
|
{
|
|
var calc = PluginLoader.FindClass<GroupDurationCalculator>();
|
|
|
|
return calc?.CalculateGroupDuration(personCount, employeeCount, totalDuration);
|
|
}
|
|
|
|
public GroupDurationDC CalculateGroupDuration2(int personCount, int employeeCount, decimal totalDuration, long[] costBearer2SupportConceptArray)
|
|
{
|
|
var calc = PluginLoader.FindClass<GroupDurationCalculator>();
|
|
|
|
return calc?.CalculateGroupDuration(personCount, employeeCount, totalDuration, costBearer2SupportConceptArray);
|
|
}
|
|
|
|
public IList<UiElementDC> GetUiElements(UiElementType? uiType, long? employeeOid, long? teamOid, long[] oidArray)
|
|
{
|
|
var factory = PluginLoader.FindClass<UiElementFactory>() ?? new UiElementFactory();
|
|
|
|
return factory.GetUiElements(uiType, employeeOid, teamOid);
|
|
}
|
|
|
|
private static List<SupportConceptTreeNodeDC> BuildTree(IEnumerable<SupportConcept> pSupportConcepts)
|
|
{
|
|
var lResult = new List<SupportConceptTreeNodeDC>();
|
|
|
|
foreach (var iSc in pSupportConcepts)
|
|
{
|
|
var lScNode = new SupportConceptTreeNodeDC
|
|
{
|
|
NodeType = NodeType.SupportConcept,
|
|
SupportConcept = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDC(iSc),
|
|
Description = $"{iSc.Customer.Person.LastName}, {iSc.Customer.Person.FirstName}"
|
|
};
|
|
|
|
foreach (var iSc2Cb in iSc.CostBearer2SupportConceptList)
|
|
{
|
|
var treeNode = new SupportConceptTreeNodeDC
|
|
{
|
|
NodeType = NodeType.SupportConceptCostBearerRelDC,
|
|
SupportConcept = lScNode.SupportConcept,
|
|
SupportConceptCostBearerRelDC = MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(iSc2Cb)
|
|
};
|
|
|
|
if (iSc2Cb.CostBearer.Organisation != null)
|
|
{
|
|
treeNode.Description = iSc2Cb.CostBearer.Organisation.Name;
|
|
}
|
|
|
|
lScNode.ChildNodes.Add(treeNode);
|
|
}
|
|
|
|
lResult.Add(lScNode);
|
|
}
|
|
|
|
return lResult.OrderBy(s => s.Description).ToList();
|
|
}
|
|
|
|
public void CreateNewPerson2OrganisationRelation(long pOrganisationOid, ValueListEntryDC pValue, long personOid, string pMailAddress, string pFaxNumber, string pPhoneNumber, string pNotice)
|
|
{
|
|
try
|
|
{
|
|
var contactList = new List<Contact>
|
|
{
|
|
new Contact {Type = ContactType.business_Fax, Value = pFaxNumber},
|
|
new Contact {Type = ContactType.business_Mail, Value = pMailAddress},
|
|
new Contact {Type = ContactType.business_Phone, Value = pPhoneNumber}
|
|
};
|
|
|
|
var organisation2Person = new Organisation2Person
|
|
{
|
|
Organisation = DAOFactory.GenericDAO.LoadByID<Organisation>(pOrganisationOid),
|
|
Notice = pNotice,
|
|
RolleInOrganisation = pValue != null ? DAOFactory.GenericDAO.LoadByID<ValueListEntry>(pValue.ValueListEntryOid.Value) : null,
|
|
Person = DAOFactory.GenericDAO.LoadByID<Person>(personOid),
|
|
Contacts = contactList
|
|
};
|
|
|
|
DAOFactory.GenericDAO.Insert(organisation2Person);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeletePerson2OrganisationRelation(long oid)
|
|
{
|
|
try
|
|
{
|
|
var organisation2Person = DAOFactory.GenericDAO.LoadByID<Organisation2Person>(oid);
|
|
|
|
DAOFactory.GenericDAO.Delete(organisation2Person);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public PdfChatHandoutDC GetHandOutPdfForChat(string customerId, string apikey)
|
|
{
|
|
try
|
|
{
|
|
var handout = new PdfChatHandoutDC();
|
|
|
|
var serverUrl = OwnChatHelper.ErmittleServerURL(customerId);
|
|
|
|
if (serverUrl == null)
|
|
{
|
|
handout.Result = 11;
|
|
|
|
return handout;
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(serverUrl))
|
|
{
|
|
handout.Result = 11;
|
|
|
|
return handout;
|
|
}
|
|
|
|
var endurl = serverUrl + "/api/ownchat/createpdfmanual/" + apikey + "/" + customerId;
|
|
|
|
|
|
//Bereich zum Testen Multiform Test gedönse
|
|
//using (MultipartFormDataContent multiPartContent = new MultipartFormDataContent())
|
|
//{
|
|
// Uri requestUri = new Uri(ChatDaten.ServerUrl + "/api/ownchat/createpdfmanual/");
|
|
|
|
// Links Content / Rechts name
|
|
// multiPartContent.Add(new StringContent(chatcode + ""), "chatcode");
|
|
// multiPartContent.Add(new StringContent(login + ""), "login");
|
|
// multiPartContent.Add(new StringContent(password + ""), "password");
|
|
// multiPartContent.Add(new StringContent("https://support.bewoplaner.de/bewoplaner_logo_big.png"), "custom_logo_url");
|
|
|
|
// httpRequest = new HttpRequestMessage();
|
|
// httpRequest.Method = HttpMethod.Post;
|
|
// httpRequest.RequestUri = requestUri;
|
|
// httpRequest.Content = multiPartContent;
|
|
|
|
// httpRequest.Headers.Add("Token", apikey);
|
|
// httpRequest.Headers.Add("CustomerID", customerId);
|
|
|
|
|
|
// HttpResponseMessage httpResponse = null;
|
|
|
|
// HttpClient httpClient = new HttpClient();
|
|
|
|
// httpResponse = await httpClient.SendAsync(httpRequest, CancellationToken.None).ConfigureAwait(false);
|
|
|
|
|
|
// string antwortResponse = await httpResponse.Content.ReadAsStringAsync();
|
|
|
|
// var jsonDatentyp = JsonConvert.DeserializeObject<PdfChatHandoutDC>(antwortResponse);
|
|
|
|
// return jsonDatentyp;
|
|
//}
|
|
|
|
//neu post bereich
|
|
//Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
|
|
//dic.Add("chatcode", "Hier ChatCode");
|
|
//dic.Add("login", "hier benutzername");
|
|
//dic.Add("password", "hier passwort");
|
|
//dic.Add("custom_logo_url", "https://support.bewoplaner.de/bewoplaner_logo_big.png");
|
|
|
|
//string postdaten = "";
|
|
//foreach (var key in dic.Keys)
|
|
//{
|
|
// postdaten += HttpUtility.UrlEncode(key) + "=" + HttpUtility.UrlEncode(dic[key]) + "&";
|
|
//}
|
|
|
|
//WebRequest requesten = WebRequest.Create(endurl);
|
|
//requesten.Method = "POST";
|
|
//requesten.ContentType = "application/x-www-form-urlencoded";
|
|
////requesten.Headers["Token"] = "hier ggf. token hin ";
|
|
//requesten.Headers["CustomerID"] = customerId;
|
|
|
|
//byte[] daten = Encoding.ASCII.GetBytes(postdaten);
|
|
|
|
//requesten.ContentLength = daten.Length;
|
|
|
|
//Stream requestStream = requesten.GetRequestStream();
|
|
|
|
//requestStream.Write(daten, 0, daten.Length);
|
|
|
|
//requestStream.Close();
|
|
|
|
|
|
//neu ende
|
|
|
|
|
|
//############################
|
|
var postparameter = new Dictionary<string, string>
|
|
{
|
|
{ "username", "HAns" },
|
|
{ "password", "Dito" },
|
|
//neu | hinzufügen laut document
|
|
{ "chatcode", "yyAbrams" }
|
|
};
|
|
|
|
var postdaten = "";
|
|
//int i = 0;
|
|
foreach (var key in postparameter.Keys)
|
|
{
|
|
//hier noch chatcode übergeben
|
|
postdaten += HttpUtility.UrlEncode(key) + "=" + HttpUtility.UrlEncode(postparameter[key]) + "&";
|
|
}
|
|
|
|
var requesten = WebRequest.Create(endurl);
|
|
|
|
requesten.Method = "POST";
|
|
requesten.ContentType = "application/x-www-form-urlencoded";
|
|
|
|
var daten = Encoding.ASCII.GetBytes(postdaten);
|
|
|
|
requesten.ContentLength = daten.Length;
|
|
|
|
try
|
|
{
|
|
var requestStream = requesten.GetRequestStream();
|
|
|
|
requestStream.Write(daten, 0, daten.Length);
|
|
|
|
requestStream.Close();
|
|
|
|
}
|
|
catch (Exception)
|
|
{
|
|
MessageBox.Show("Es konnte keine Verbindung aufgebaut werden.", "Fehler", MessageBoxButton.OK);
|
|
|
|
}
|
|
|
|
//response bereich | Verarbeiten
|
|
var response = (HttpWebResponse)requesten.GetResponse();
|
|
//response.ContentType = "application/pdf";
|
|
|
|
//######################################################################
|
|
|
|
//alt get bereich
|
|
//WebRequest request = WebRequest.Create(endurl);
|
|
|
|
//request.Method = WebRequestMethods.Http.Post;
|
|
|
|
//request.Credentials = CredentialCache.DefaultCredentials;
|
|
//request.Proxy = null;
|
|
|
|
//WebResponse response = request.GetResponse();
|
|
|
|
using (var stream = response.GetResponseStream())
|
|
{
|
|
var buffer = new byte[stream.Length];
|
|
stream.Read(buffer, 0, buffer.Length);
|
|
File.WriteAllBytes("foo.pdf", buffer);
|
|
}
|
|
|
|
string responseFromServer = ReadStreamForChatCode(response);
|
|
|
|
if (responseFromServer.Contains("PDF"))
|
|
{
|
|
var hd = new PdfChatHandoutDC
|
|
{
|
|
File = responseFromServer,
|
|
Result = 0
|
|
};
|
|
//hd.TestStream = dataStream;
|
|
|
|
return hd;
|
|
}
|
|
|
|
var jsonDatentyp = JsonConvert.DeserializeObject<PdfChatHandoutDC>(responseFromServer);
|
|
|
|
return jsonDatentyp;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
//throw Utils.CreateBeWoFaultException(e);
|
|
var handout = new PdfChatHandoutDC
|
|
{
|
|
Result = 60,
|
|
File = e.Message
|
|
};
|
|
|
|
return handout;
|
|
}
|
|
}
|
|
|
|
public CustomerAPPCodeDC DeletCustomerChatCode(string apikey, string kundennummer, long customeroid)
|
|
{
|
|
var customerAppCode = new CustomerAPPCodeDC();
|
|
var result = DeletZufallsCode(apikey, kundennummer, "C" + customeroid);
|
|
|
|
if (result == 0 || result == 32)
|
|
{
|
|
try
|
|
{
|
|
var customerappcode = DAOFactory.SearchDAO.FindAllCustomerAppCodes(customeroid).ToList();
|
|
|
|
var anzahl = customerappcode.Count;
|
|
|
|
if (anzahl > 0)
|
|
{
|
|
foreach (var code in customerappcode)
|
|
{
|
|
code.CustomerCode = string.Empty;
|
|
code.CustomerCodeGenDate = DateTime.Now;
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Update(customerappcode);
|
|
|
|
customerAppCode.Result = 0;
|
|
return customerAppCode;
|
|
}
|
|
|
|
customerAppCode.Result = 4;
|
|
return customerAppCode;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
customerAppCode.Result = result;
|
|
return customerAppCode;
|
|
}
|
|
|
|
public EmployeeAPPCodeDC DeletEmployeeChatCode(string apikey, string kundennummer, long employeeoid)
|
|
{
|
|
var employeeAppCode = new EmployeeAPPCodeDC();
|
|
var result = DeletZufallsCode(apikey, kundennummer, "E" + employeeoid);
|
|
|
|
if (result == 0 || result == 32)
|
|
{
|
|
try
|
|
{
|
|
var employeeappcode = DAOFactory.SearchDAO.FindAllEmployeeAppCodes(employeeoid).ToList();
|
|
|
|
var anzahl = employeeappcode.Count;
|
|
|
|
if (anzahl > 0)
|
|
{
|
|
foreach (var code in employeeappcode)
|
|
{
|
|
code.EmployeeCode = string.Empty;
|
|
code.EmployeeCodeGenDate = DateTime.Now;
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Update(employeeappcode);
|
|
|
|
employeeAppCode.Result = 0; // alles ok
|
|
|
|
return employeeAppCode;
|
|
}
|
|
|
|
employeeAppCode.Result = 4; // ChatCode Datensatz konnte nicht gefunden werden
|
|
|
|
return employeeAppCode;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
employeeAppCode.Result = result;
|
|
|
|
return employeeAppCode;
|
|
}
|
|
|
|
public Dictionary<string, string> GetTranslationDictionary()
|
|
{
|
|
var translationDictionary = PluginLoader.FindClass<TranslationDictionary>();
|
|
|
|
return translationDictionary?.GetTranslationDictionary();
|
|
}
|
|
|
|
public IList<TextbausteinDC> GetAllTextbausteine()
|
|
{
|
|
try
|
|
{
|
|
return MapperFactory.TextbausteinDC_Textbaustein.MapToNewDCs(DAOFactory.GenericDAO.GetAllActive<Textbaustein>());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public IList<long> InsertNewTextbausteine(IEnumerable<TextbausteinDC> pTextbausteine)
|
|
{
|
|
try
|
|
{
|
|
var lTextbausteine = MapperFactory.TextbausteinDC_Textbaustein.MapToNewEntities(pTextbausteine);
|
|
DAOFactory.GenericDAO.Insert(lTextbausteine);
|
|
|
|
return lTextbausteine.Select(asb => asb.Oid.Value).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateTextbausteine(List<TextbausteinDC> pTextbausteine)
|
|
{
|
|
try
|
|
{
|
|
var lOriginals = DAOFactory.GenericDAO.LoadByIDs<Textbaustein>(pTextbausteine.Select(sc => sc.TextbausteinOid.Value));
|
|
|
|
MapperFactory.TextbausteinDC_Textbaustein.MergeWithEntitys(pTextbausteine, lOriginals);
|
|
|
|
DAOFactory.GenericDAO.Update(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteTextbausteine(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
var lOriginals = DAOFactory.GenericDAO.LoadByIDs<Textbaustein>(pOid2Version.Select(e => e.Key));
|
|
lOriginals.DoForEach(or => MapperFactory.TextbausteinDC_Textbaustein.ConcurrencyCheck(pOid2Version[or.Oid.Value], or));
|
|
|
|
DAOFactory.GenericDAO.Delete(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public SbdConfigDC GetSbdConfig()
|
|
{
|
|
try
|
|
{
|
|
var pi = PluginLoader.FindClass<SchulbegleitenderDienstService>();
|
|
|
|
if (pi != null)
|
|
{
|
|
return pi.GetSbdConfig();
|
|
}
|
|
|
|
return new SbdConfigDC();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void SaveSbdConfig(SbdConfigDC config)
|
|
{
|
|
try
|
|
{
|
|
var pi = PluginLoader.FindClass<SchulbegleitenderDienstService>();
|
|
|
|
pi?.SaveSbdConfig(config);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
private static void AnonymizePerson(long pPersonOid)
|
|
{
|
|
try
|
|
{
|
|
const string anonimyzedName = "Anonymisiert";
|
|
|
|
var pPerson = DAOFactory.GenericDAO.LoadByID<Person>(pPersonOid);
|
|
|
|
pPerson.Abbreviation = null;
|
|
if (pPerson.DateOfBirth != null)
|
|
{
|
|
pPerson.DateOfBirth = new DateTime(pPerson.DateOfBirth.Value.Year, 1, 1);
|
|
}
|
|
|
|
pPerson.FirstName = anonimyzedName;
|
|
pPerson.LastName = anonimyzedName;
|
|
pPerson.Notice = null;
|
|
|
|
if (pPerson.Address != null)
|
|
{
|
|
pPerson.Address.AddressLine1 = null;
|
|
pPerson.Address.AddressLine2 = null;
|
|
pPerson.Address.Country = null;
|
|
pPerson.Address.Street = null;
|
|
pPerson.Address.State = null;
|
|
pPerson.Address.PostalCode = null;
|
|
pPerson.Address.Town = null;
|
|
pPerson.Address.InsUser = anonimyzedName;
|
|
pPerson.Address.UdpUser = anonimyzedName;
|
|
}
|
|
|
|
pPerson.AufenthaltsStatus = null;
|
|
pPerson.Profession = null;
|
|
pPerson.Title = null;
|
|
pPerson.InsUser = anonimyzedName;
|
|
pPerson.UdpUser = anonimyzedName;
|
|
var bankaccountOid = pPerson.BankAccount?.Oid;
|
|
|
|
if (bankaccountOid != null)
|
|
{
|
|
pPerson.BankAccount = null;
|
|
}
|
|
|
|
pPerson.FamilyStatus = null;
|
|
if (pPerson.InvoiceAddress != null)
|
|
{
|
|
pPerson.InvoiceAddress.AddressLine1 = null;
|
|
pPerson.InvoiceAddress.AddressLine2 = null;
|
|
pPerson.InvoiceAddress.Country = null;
|
|
pPerson.InvoiceAddress.Street = null;
|
|
pPerson.InvoiceAddress.State = null;
|
|
pPerson.InvoiceAddress.InsUser = anonimyzedName;
|
|
pPerson.InvoiceAddress.UdpUser = anonimyzedName;
|
|
}
|
|
|
|
pPerson.IsMigrant = false;
|
|
pPerson.Nationalitaet = null;
|
|
pPerson.Contacts.Clear();
|
|
|
|
pPerson.Images?.Clear();
|
|
|
|
DAOFactory.GenericDAO.Update(pPerson);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void AnonymizeCustomer(long pCustomerOid)
|
|
{
|
|
try
|
|
{
|
|
const string anonimyzedName = "Anonymisiert";
|
|
var customer = DAOFactory.GenericDAO.GetByID<Customer>(pCustomerOid);
|
|
|
|
if (customer.Person.Oid != null)
|
|
{
|
|
AnonymizePerson(customer.Person.Oid.Value);
|
|
}
|
|
|
|
customer.VarFieldValueList?.Clear();
|
|
|
|
customer.AbWelchemKrankheitsTag = 0;
|
|
customer.AbsenceTimes.DoForEach(at =>
|
|
{
|
|
at.Notice = null;
|
|
at.InsUser = anonimyzedName;
|
|
at.UdpUser = anonimyzedName;
|
|
});
|
|
|
|
customer.Ansprechpartner = null;
|
|
customer.AssessmentSheetCategoryList?.Clear();
|
|
customer.AssistanceBegin = null;
|
|
customer.AusstVersAmt = null;
|
|
customer.AusweisGueltigBis = null;
|
|
customer.AusweisGueltigVon = null;
|
|
customer.AusweisUnbefristetGueltig = null;
|
|
customer.AusweisAktenzeichen = null;
|
|
customer.BehinderungsartenListe?.Clear();
|
|
customer.BeiblattGueltigBis = null;
|
|
customer.Childs = null;
|
|
customer.CostCenter = null;
|
|
customer.Ansprechpartner = null;
|
|
customer.AssistanceBegin = null;
|
|
customer.Customer2CostBearerList?.Clear();
|
|
customer.Customer2OrganisationList?.Clear();
|
|
|
|
var personRelations2Delete = customer.Customer2PersonList.Where(person => !person.IstFamilie && person.Oid != null).ToList();
|
|
|
|
customer.Customer2PersonList.RemoveRange(personRelations2Delete);
|
|
|
|
customer.Customer2PersonList.DoForEach(personRelation =>
|
|
{
|
|
personRelation.InsUser = anonimyzedName;
|
|
personRelation.UdpUser = anonimyzedName;
|
|
personRelation.Notice = null;
|
|
});
|
|
|
|
customer.CustomerAlias = null;
|
|
customer.DebitorNumber = null;
|
|
customer.Diagnosis = null;
|
|
customer.Diagnosis2CustomerList?.Clear();
|
|
customer.DistanceInMeter = null;
|
|
customer.Employee2CustomerList?.Clear();
|
|
customer.Environment = null;
|
|
customer.EquityContribution = null;
|
|
customer.FamilyData = null;
|
|
customer.GradDerBehinderung = null;
|
|
customer.ICD10Diagnosis = null;
|
|
customer.InsUser = anonimyzedName;
|
|
customer.IsAdvisedOrAttended = null;
|
|
customer.Jugendamt = null;
|
|
customer.Medication = null;
|
|
customer.Medikamentenverordnungslisten?.Clear();
|
|
customer.MerkzeichenListe?.Clear();
|
|
customer.Notice = null;
|
|
customer.Pflegegrad = null;
|
|
customer.PlacementList?.Clear();
|
|
customer.ReferenceNumber = null;
|
|
customer.Team2CustomerList?.Clear();
|
|
customer.TerminationDate = null;
|
|
customer.TerminationReason = null;
|
|
customer.UdpUser = anonimyzedName;
|
|
customer.ValueList?.Clear();
|
|
customer.VertretungDringendErforderlich = false;
|
|
customer.VertretungGewuenscht = false;
|
|
|
|
customer.ServiceRecordList?.DoForEach(record =>
|
|
{
|
|
record.Notice = null;
|
|
record.Notice2 = null;
|
|
record.Notice3 = null;
|
|
record.Notice4 = null;
|
|
record.Notice5 = null;
|
|
record.RTFNotice1 = null;
|
|
record.RTFNotice2 = null;
|
|
record.RTFNotice3 = null;
|
|
record.RTFNotice4 = null;
|
|
record.RTFNotice5 = null;
|
|
record.InsUser = anonimyzedName;
|
|
record.UdpUser = anonimyzedName;
|
|
});
|
|
|
|
customer.SupportConcepts?.DoForEach(supportConcept =>
|
|
{
|
|
supportConcept.Notice = null;
|
|
supportConcept.InsUser = anonimyzedName;
|
|
supportConcept.UdpUser = anonimyzedName;
|
|
|
|
supportConcept.CostBearer2SupportConceptList.DoForEach(cb2SC =>
|
|
{
|
|
cb2SC.CustomerReferenceNumber = null;
|
|
cb2SC.Notice = null;
|
|
cb2SC.InsUser = anonimyzedName;
|
|
cb2SC.UdpUser = anonimyzedName;
|
|
});
|
|
});
|
|
|
|
if (customer.Oid != null)
|
|
{
|
|
var bargeldKassen = DAOFactory.SearchDAO.FindBargeldkasse(TableID.Customer, customer.Oid.Value);
|
|
|
|
DAOFactory.GenericDAO.Delete(bargeldKassen);
|
|
|
|
var fileAttachments = DAOFactory.SearchDAO.FindFileAttachments(TableID.Customer, customer.Oid.Value);
|
|
|
|
FileAttachmentUtils.DeleteFilesFromFileDirectory(fileAttachments.Where(fileAttachment => fileAttachment.Oid.HasValue).Select(fileAttachment => fileAttachment.Oid.Value).ToList());
|
|
|
|
DAOFactory.GenericDAO.Delete(fileAttachments);
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Update(customer);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
// TODO: Den ersten Buchstaben des Klienten und den Namen des Mitarbeiters speichern, der ihn gelöscht hat. -> Neue Tabelle
|
|
public void DeleteCustomerForGood(long pCustomerOid)
|
|
{
|
|
try
|
|
{
|
|
var deletionHistoryEntry = new DeletionHistory();
|
|
|
|
var appointments = DAOFactory.SearchDAO.FindAppointmentsForCustomer(pCustomerOid);
|
|
var customer = DAOFactory.GenericDAO.LoadByID<Customer>(pCustomerOid);
|
|
var supportConceptOids = customer.SupportConcepts.Select(sc => sc.Oid.Value).ToList();
|
|
|
|
UserDC user;
|
|
if (LoggedInUserOperationContextExt.Current != null && LoggedInUserOperationContextExt.Current.User != null)
|
|
{
|
|
user = MapperFactory.UserDC_User.MapToNewDC(LoggedInUserOperationContextExt.Current.User);
|
|
}
|
|
else
|
|
{
|
|
user = MapperFactory.UserDC_User.MapToNewDC(SessionFacade.LoggedInUser);
|
|
}
|
|
|
|
if (user != null)
|
|
{
|
|
string initial;
|
|
|
|
if (customer.Person.FirstName.Length > 0)
|
|
{
|
|
initial = customer.Person.FirstName[0].ToString();
|
|
}
|
|
else if (customer.Person.LastName.Length > 0)
|
|
{
|
|
initial = customer.Person.LastName[0].ToString();
|
|
}
|
|
else if (customer.CustomerAlias?.Length > 0)
|
|
{
|
|
initial = customer.CustomerAlias[0].ToString();
|
|
}
|
|
else
|
|
{
|
|
initial = "unbekannt";
|
|
}
|
|
|
|
deletionHistoryEntry.DeletingEmployeeName = $"{user.Employee.FirstName} {user.Employee.LastName}";
|
|
deletionHistoryEntry.DeletedEntityName = initial;
|
|
deletionHistoryEntry.DeletedEntityTableId = TableID.Customer;
|
|
}
|
|
|
|
appointments.DoForEach(app => app.CustomerList.Remove(customer));
|
|
|
|
DAOFactory.GenericDAO.Update(appointments);
|
|
|
|
var costBearer2SupportConcepts = new List<CostBearer2SupportConcept>();
|
|
var groupsToGetReferencesRemoved = new List<GroupOfPeople>();
|
|
foreach (var sc in customer.SupportConcepts)
|
|
{
|
|
foreach (var cb2sc in sc.CostBearer2SupportConceptList)
|
|
{
|
|
groupsToGetReferencesRemoved.AddRangeIfElementsNotIn(DAOFactory.SearchDAO.GroupOfPeopleForSupportConcept(cb2sc.Oid.Value));
|
|
costBearer2SupportConcepts.AddIfNotIn(cb2sc);
|
|
}
|
|
}
|
|
|
|
foreach (var group in groupsToGetReferencesRemoved)
|
|
{
|
|
group.CostBearer2SupportConceptList.RemoveRange(costBearer2SupportConcepts);
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Update(groupsToGetReferencesRemoved);
|
|
|
|
DAOFactory.GenericDAO.Update(customer.SupportConcepts);
|
|
|
|
var additionalServiceGroups = DAOFactory.SearchDAO.GetAdditionalServiceGroupOfPeopleForCustomer(customer.Oid.Value);
|
|
foreach (var additionalServiceGroup in additionalServiceGroups)
|
|
{
|
|
additionalServiceGroup.CustomerList.Remove(customer);
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Update(additionalServiceGroups);
|
|
|
|
var additionalServiceBookings = DAOFactory.SearchDAO.GetAllAdditionalServiceBookingsForCustomer(customer.Oid.Value);
|
|
DAOFactory.GenericDAO.Delete(additionalServiceBookings);
|
|
|
|
var images2delete = customer.Person.Images;
|
|
customer.Person.Images.Clear();
|
|
|
|
DAOFactory.GenericDAO.Delete(images2delete);
|
|
DAOFactory.GenericDAO.Update(customer);
|
|
|
|
customer.SupportConcepts.DoForEach(s => s.CostBearer2SupportConceptList?.Clear());
|
|
foreach (var assessmentSheetCategory in customer.AssessmentSheetCategoryList)
|
|
{
|
|
assessmentSheetCategory.Customers.Remove(customer);
|
|
}
|
|
|
|
var assessmentSheetEntries = DAOFactory.SearchDAO.GetAssessmentSheetEntriesForCustomer(customer.Oid.Value, DateTime.MinValue, DateTime.MaxValue);
|
|
|
|
var invoiceBases2Delete = DAOFactory.SearchDAO.GetInvoiceBasesBySupportConceptOids(supportConceptOids);
|
|
invoiceBases2Delete.DoForEach(ib => ib.InvoiceItems.Clear());
|
|
|
|
var settlementInvoices = DAOFactory.SearchDAO.GetSettlementInvoiceBySupportConceptOids(supportConceptOids);
|
|
var serviceInvoices = DAOFactory.SearchDAO.GetServiceInvoicesByInvoiceBaseOids(invoiceBases2Delete.Select(s => s.Oid.Value).ToList());
|
|
|
|
var invoiceItems = new List<InvoiceItem>();
|
|
invoiceBases2Delete.DoForEach(ib => invoiceItems.AddRange(ib.InvoiceItems));
|
|
DAOFactory.GenericDAO.Update(invoiceBases2Delete);
|
|
|
|
if (supportConceptOids.Any())
|
|
{
|
|
var tasksAndAppointments2Delete = DAOFactory.SearchDAO.GetTasksAndAppointmentsBySupportConceptOids(supportConceptOids);
|
|
DAOFactory.GenericDAO.Delete(tasksAndAppointments2Delete);
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Delete(invoiceItems);
|
|
DAOFactory.GenericDAO.Delete(settlementInvoices);
|
|
DAOFactory.GenericDAO.Delete(serviceInvoices);
|
|
|
|
invoiceBases2Delete = DAOFactory.SearchDAO.GetInvoiceBasesBySupportConceptOids(supportConceptOids);
|
|
DAOFactory.GenericDAO.Delete(invoiceBases2Delete);
|
|
|
|
var customer2Tokens2Delete = DAOFactory.SearchDAO.GetCustomer2TokensByCustomerOid(customer.Oid.Value);
|
|
DAOFactory.GenericDAO.Delete(customer2Tokens2Delete);
|
|
|
|
DAOFactory.GenericDAO.Delete(assessmentSheetEntries);
|
|
|
|
DAOFactory.GenericDAO.Update(customer);
|
|
|
|
DAOFactory.GenericDAO.Delete(customer.SupportConcepts);
|
|
|
|
DAOFactory.GenericDAO.Delete(DAOFactory.GenericDAO.LoadByID<Customer>(customer.Oid.Value));
|
|
|
|
if (deletionHistoryEntry.DeletingEmployeeName != null)
|
|
{
|
|
DAOFactory.GenericDAO.Insert(deletionHistoryEntry);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
// TODO: implementieren!
|
|
public void DeletePersonForGood(long pPersonOid)
|
|
{
|
|
try
|
|
{
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
// TODO: implementieren!
|
|
public void DeleteEmployeeForGood(long pEmployeeOid)
|
|
{
|
|
try
|
|
{
|
|
var deletionHistoryEntry = new DeletionHistory();
|
|
|
|
//var appointments = DAOFactory.SearchDAO.FindAppointmentsForEmployee(pEmployeeOid);
|
|
var emp = DAOFactory.GenericDAO.LoadByID<Employee>(pEmployeeOid);
|
|
//var supportConceptOids = customer.SupportConcepts.Select(sc => sc.Oid.Value).ToList();
|
|
|
|
UserDC user;
|
|
if (LoggedInUserOperationContextExt.Current != null && LoggedInUserOperationContextExt.Current.User != null)
|
|
{
|
|
user = MapperFactory.UserDC_User.MapToNewDC(LoggedInUserOperationContextExt.Current.User);
|
|
}
|
|
else
|
|
{
|
|
user = MapperFactory.UserDC_User.MapToNewDC(SessionFacade.LoggedInUser);
|
|
}
|
|
|
|
if (user != null)
|
|
{
|
|
string initial;
|
|
|
|
if (emp.Person.FirstName.Length > 0)
|
|
{
|
|
initial = emp.Person.FirstName[0].ToString();
|
|
}
|
|
else if (emp.Person.LastName.Length > 0)
|
|
{
|
|
initial = emp.Person.LastName[0].ToString();
|
|
}
|
|
else
|
|
{
|
|
initial = "unbekannt";
|
|
}
|
|
|
|
deletionHistoryEntry.DeletingEmployeeName = $"{user.Employee.FirstName} {user.Employee.LastName}";
|
|
deletionHistoryEntry.DeletedEntityName = initial;
|
|
deletionHistoryEntry.DeletedEntityTableId = TableID.Employee;
|
|
}
|
|
|
|
//appointments.DoForEach(app => app.CustomerList.Remove(customer));
|
|
|
|
//DAOFactory.GenericDAO.Update(appointments);
|
|
|
|
//var costBearer2SupportConcepts = new List<CostBearer2SupportConcept>();
|
|
//var groupsToGetReferencesRemoved = new List<GroupOfPeople>();
|
|
//foreach (var sc in customer.SupportConcepts)
|
|
//{
|
|
// foreach (var cb2sc in sc.CostBearer2SupportConceptList)
|
|
// {
|
|
// groupsToGetReferencesRemoved.AddRangeIfElementsNotIn(DAOFactory.SearchDAO.GroupOfPeopleForSupportConcept(cb2sc.Oid.Value));
|
|
// costBearer2SupportConcepts.AddIfNotIn(cb2sc);
|
|
// }
|
|
//}
|
|
|
|
//foreach (var group in groupsToGetReferencesRemoved)
|
|
//{
|
|
// group.CostBearer2SupportConceptList.RemoveRange(costBearer2SupportConcepts);
|
|
//}
|
|
|
|
//DAOFactory.GenericDAO.Update(groupsToGetReferencesRemoved);
|
|
|
|
//DAOFactory.GenericDAO.Update(customer.SupportConcepts);
|
|
|
|
//var additionalServiceGroups = DAOFactory.SearchDAO.GetAdditionalServiceGroupOfPeopleForCustomer(customer.Oid.Value);
|
|
//foreach (var additionalServiceGroup in additionalServiceGroups)
|
|
//{
|
|
// additionalServiceGroup.CustomerList.Remove(customer);
|
|
//}
|
|
|
|
//DAOFactory.GenericDAO.Update(additionalServiceGroups);
|
|
|
|
//var additionalServiceBookings = DAOFactory.SearchDAO.GetAllAdditionalServiceBookingsForCustomer(customer.Oid.Value);
|
|
//DAOFactory.GenericDAO.Delete(additionalServiceBookings);
|
|
|
|
//var images2delete = customer.Person.Images;
|
|
//customer.Person.Images.Clear();
|
|
|
|
//DAOFactory.GenericDAO.Delete(images2delete);
|
|
//DAOFactory.GenericDAO.Update(customer);
|
|
|
|
//customer.SupportConcepts.DoForEach(s => s.CostBearer2SupportConceptList?.Clear());
|
|
//foreach (var assessmentSheetCategory in customer.AssessmentSheetCategoryList)
|
|
//{
|
|
// assessmentSheetCategory.Customers.Remove(customer);
|
|
//}
|
|
|
|
//var assessmentSheetEntries = DAOFactory.SearchDAO.GetAssessmentSheetEntriesForCustomer(customer.Oid.Value, DateTime.MinValue, DateTime.MaxValue);
|
|
|
|
//var invoiceBases2Delete = DAOFactory.SearchDAO.GetInvoiceBasesBySupportConceptOids(supportConceptOids);
|
|
//invoiceBases2Delete.DoForEach(ib => ib.InvoiceItems.Clear());
|
|
|
|
//var settlementInvoices = DAOFactory.SearchDAO.GetSettlementInvoiceBySupportConceptOids(supportConceptOids);
|
|
//var serviceInvoices = DAOFactory.SearchDAO.GetServiceInvoicesByInvoiceBaseOids(invoiceBases2Delete.Select(s => s.Oid.Value).ToList());
|
|
|
|
//var invoiceItems = new List<InvoiceItem>();
|
|
//invoiceBases2Delete.DoForEach(ib => invoiceItems.AddRange(ib.InvoiceItems));
|
|
//DAOFactory.GenericDAO.Update(invoiceBases2Delete);
|
|
|
|
//if (supportConceptOids.Any())
|
|
//{
|
|
// var tasksAndAppointments2Delete = DAOFactory.SearchDAO.GetTasksAndAppointmentsBySupportConceptOids(supportConceptOids);
|
|
// DAOFactory.GenericDAO.Delete(tasksAndAppointments2Delete);
|
|
//}
|
|
|
|
//DAOFactory.GenericDAO.Delete(invoiceItems);
|
|
//DAOFactory.GenericDAO.Delete(settlementInvoices);
|
|
//DAOFactory.GenericDAO.Delete(serviceInvoices);
|
|
|
|
//invoiceBases2Delete = DAOFactory.SearchDAO.GetInvoiceBasesBySupportConceptOids(supportConceptOids);
|
|
//DAOFactory.GenericDAO.Delete(invoiceBases2Delete);
|
|
|
|
//var customer2Tokens2Delete = DAOFactory.SearchDAO.GetCustomer2TokensByCustomerOid(customer.Oid.Value);
|
|
//DAOFactory.GenericDAO.Delete(customer2Tokens2Delete);
|
|
|
|
//DAOFactory.GenericDAO.Delete(assessmentSheetEntries);
|
|
|
|
//DAOFactory.GenericDAO.Update(customer);
|
|
|
|
//DAOFactory.GenericDAO.Delete(customer.SupportConcepts);
|
|
|
|
DAOFactory.GenericDAO.Delete(emp);
|
|
|
|
if (deletionHistoryEntry.DeletingEmployeeName != null)
|
|
{
|
|
DAOFactory.GenericDAO.Insert(deletionHistoryEntry);
|
|
}
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
// TODO: implementieren!
|
|
public void AnonymizeEmployee(long pEmployeeOid)
|
|
{
|
|
try
|
|
{
|
|
var employee = DAOFactory.GenericDAO.LoadByID<Employee>(pEmployeeOid);
|
|
|
|
if (employee.Person.Oid != null)
|
|
{
|
|
AnonymizePerson(employee.Person.Oid.Value);
|
|
}
|
|
|
|
var fileAttachments = DAOFactory.SearchDAO.FindFileAttachments(TableID.Employee, pEmployeeOid);
|
|
|
|
FileAttachmentUtils.DeleteFilesFromFileDirectory(fileAttachments.Where(fileAttachment => fileAttachment.Oid.HasValue).Select(fileAttachment => fileAttachment.Oid.Value).ToList());
|
|
|
|
DAOFactory.GenericDAO.Delete(fileAttachments);
|
|
|
|
employee.AbsenceTimes?.Clear();
|
|
|
|
DAOFactory.GenericDAO.Update(employee);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
// TODO: implementieren!
|
|
public void DeleteAppointmentsInInterval(bool pHasRightToSeeAllEmployeeAppointments, long pEmployeeOid, DateTime pIntervalEnd, List<long> pSelectedEmployees, List<long> pSelectedCustomers, List<long> pSelectedResources, bool pEmployeesOnly, bool pCustomersOnly, bool pResourcesOnly, bool pPrivateAppointmentsOnly, bool pOnlyMyAppointments, Dictionary<UserRightType, bool> pUserRights)
|
|
{
|
|
try
|
|
{
|
|
var appointments2Delete = DAOFactory.SearchDAO.LoadFilteredAppointments(pHasRightToSeeAllEmployeeAppointments, pEmployeeOid, new DateTime(1, 1, 1), pIntervalEnd, pSelectedEmployees, pSelectedCustomers, pSelectedResources, pEmployeesOnly, pCustomersOnly, pResourcesOnly, pPrivateAppointmentsOnly, pOnlyMyAppointments, true);
|
|
DAOFactory.GenericDAO.Delete(appointments2Delete);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public string GetMessageFromServer(TableID pObjectTid, long? pObjectOid, MessageType pMessageType)
|
|
{
|
|
try
|
|
{
|
|
var actualTextMessage = "";
|
|
const string foreground = "Foreground=\"Red\"";
|
|
const string fontWeight = "FontWeight=\"Bold\"";
|
|
|
|
if (pObjectTid == TableID.Customer && pMessageType == MessageType.Anonymization)
|
|
{
|
|
actualTextMessage = "Achtung!

Das Anonymisieren eines Klienten kann nicht rückgängig gemacht werden!
";
|
|
}
|
|
|
|
if (pObjectTid == TableID.Customer && pMessageType == MessageType.DeleteForGood)
|
|
{
|
|
actualTextMessage = "Achtung!

Das endgültige Löschen eines Klienten kann nicht rückgängig gemacht werden!
";
|
|
}
|
|
|
|
if (pObjectTid == TableID.Person && pMessageType == MessageType.DeleteForGood)
|
|
{
|
|
actualTextMessage = "Achtung!

Das endgültige Löschen einer Person kann nicht rückgängig gemacht werden!
";
|
|
}
|
|
|
|
if (pObjectTid == TableID.Employee && pMessageType == MessageType.Anonymization)
|
|
{
|
|
actualTextMessage = "Achtung!

Das Anonymisieren eines Mitarbeiters kann nicht rückgängig gemacht werden!
";
|
|
}
|
|
|
|
if (pObjectTid == TableID.Employee && pMessageType == MessageType.DeleteForGood)
|
|
{
|
|
actualTextMessage = "Achtung!

Das endgültige Löschen eines Mitarbeiters kann nicht rückgängig gemacht werden!
";
|
|
}
|
|
|
|
return $"<TextBlock xmlns =\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" Grid.Row=\"0\" TextAlignment=\"Center\" {fontWeight} TextWrapping=\"Wrap\" Background=\"Transparent\" FontSize=\"14\" Margin=\"3\" {foreground} HorizontalAlignment=\"Center\" Text=\"{actualTextMessage}\"/>";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public string GetMessageFromServerForDeletingAppointments(bool pHasRightToSeeAllEmployeeAppointments, long pEmployeeOid, DateTime pIntervalEnd, List<long> pSelectedEmployees, List<long> pSelectedCustomers, List<long> pSelectedResources, bool pEmployeesOnly, bool pCustomersOnly, bool pResourcesOnly, bool pPrivateAppointmentsOnly, bool pOnlyMyAppointments, Dictionary<UserRightType, bool> pUserRights)
|
|
{
|
|
var appointments2Delete = DAOFactory.SearchDAO.LoadFilteredAppointments(pHasRightToSeeAllEmployeeAppointments, pEmployeeOid, new DateTime(1, 1, 1), pIntervalEnd, pSelectedEmployees, pSelectedCustomers, pSelectedResources, pEmployeesOnly, pCustomersOnly, pResourcesOnly, pPrivateAppointmentsOnly, pOnlyMyAppointments, true);
|
|
|
|
var actualTextMessage = $"Achtung!

Das Löschen von {appointments2Delete.Count} {(appointments2Delete.Count == 1 ? "Termin" : "Terminen")} bis zum {pIntervalEnd.ToShortDateString()} kann nicht rückgängig gemacht werden!
";
|
|
|
|
return $"<TextBlock xmlns =\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\" Grid.Row=\"0\" TextAlignment=\"Center\" FontWeight=\"Bold\" TextWrapping=\"Wrap\" Background=\"Transparent\" FontSize=\"14\" Margin=\"3\" Foreground=\"Red\" HorizontalAlignment=\"Center\" Text=\"{actualTextMessage}\"/>";
|
|
}
|
|
|
|
public SignatureDC GetSignature(long pSignatureOid)
|
|
{
|
|
try
|
|
{
|
|
var lOriginal = DAOFactory.GenericDAO.LoadByID<Signature>(pSignatureOid);
|
|
|
|
return MapperFactory.SignatureDC_Signature.MapToNewDC(lOriginal);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<BudgetDC> GetAllBudgets()
|
|
{
|
|
try
|
|
{
|
|
var list = DAOFactory.GenericDAO.GetAllActive<Budget>();
|
|
return MapperFactory.BudgetDC_Budget.MapToNewDCs(list);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void InsertNewBudget(List<BudgetDC> budgets)
|
|
{
|
|
try
|
|
{
|
|
var budget = MapperFactory.BudgetDC_Budget.MapToNewEntities(budgets);
|
|
DAOFactory.GenericDAO.Insert(budget);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeactivateBudget(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
ServiceLogic.SetActivationType<Budget>(pOid2Version, ActivationTypeId.Deleted);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateBudget(List<BudgetDC> budgets)
|
|
{
|
|
try
|
|
{
|
|
var lOriginals = DAOFactory.GenericDAO.LoadByIDs<Budget>(budgets.Select(sc => sc.BudgetOid.Value));
|
|
|
|
MapperFactory.BudgetDC_Budget.MergeWithEntitys(budgets, lOriginals);
|
|
|
|
DAOFactory.GenericDAO.Update(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<PreisDC> GetAllPreise()
|
|
{
|
|
try
|
|
{
|
|
var list = DAOFactory.GenericDAO.GetAllActive<Preis>();
|
|
return MapperFactory.PreisDC_Preis.MapToNewDCs(list);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void InsertNewPreis(List<PreisDC> preise)
|
|
{
|
|
try
|
|
{
|
|
var preis = MapperFactory.PreisDC_Preis.MapToNewEntities(preise);
|
|
DAOFactory.GenericDAO.Insert(preis);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeactivatePreis(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
ServiceLogic.SetActivationType<Preis>(pOid2Version, ActivationTypeId.Deleted);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdatePreis(List<PreisDC> preise)
|
|
{
|
|
try
|
|
{
|
|
var lOriginals = DAOFactory.GenericDAO.LoadByIDs<Preis>(preise.Select(sc => sc.PreisOid.Value));
|
|
|
|
MapperFactory.PreisDC_Preis.MergeWithEntitys(preise, lOriginals);
|
|
|
|
DAOFactory.GenericDAO.Update(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
|
|
public FlexibleReportResultDC GetFlexibleReportResult(FlexibleReportFilterDC filter)
|
|
{
|
|
try
|
|
{
|
|
return FlexibleReportManager.GetFlexibleReportResult(filter);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public IList<FlexibleReportLayoutDC> GetFlexibleReportLayouts()
|
|
{
|
|
try
|
|
{
|
|
return FlexibleReportManager.GetFlexibleReportLayouts();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void InsertNewFlexibleReportLayout(FlexibleReportLayoutDC flexibleReportLayoutDC)
|
|
{
|
|
try
|
|
{
|
|
FlexibleReportManager.InsertNewFlexibleReportLayout(flexibleReportLayoutDC);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateFlexibleReportLayouts(IList<FlexibleReportLayoutDC> flexibleReportLayouts)
|
|
{
|
|
try
|
|
{
|
|
FlexibleReportManager.UpdateFlexibleReportLayouts(flexibleReportLayouts);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public bool CheckForOverlappingSubstitutionEntries(DateTime startDate, DateTime endDate, long? employeeOid, long? customerOid, long? substitutionOid)
|
|
{
|
|
try
|
|
{
|
|
return DAOFactory.SearchDAO.CheckForOverlappingSubstitutions(employeeOid, customerOid, startDate, endDate, substitutionOid);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public IList<HomeViewPanelDC> GetHomeViewPanels()
|
|
{
|
|
try
|
|
{
|
|
var hcg = PluginLoader.FindClass<HomeContentGenerator>();
|
|
|
|
return hcg.GetHomeViewPanels();
|
|
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
public bool CheckForOverlappingAbsenceTimes(DateTime startDate, DateTime endDate, long? employeeOid, long? customerOid)
|
|
{
|
|
try
|
|
{
|
|
return DAOFactory.SearchDAO.CheckForOverlappingAbsenceTimes(startDate, endDate, employeeOid, customerOid);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public IList<ValueListEntryDC> GetIcf()
|
|
{
|
|
try
|
|
{
|
|
#region auskommentiert
|
|
//string key = "2BT%eGprU\"E$!\"5Flq@l^^KZaYa\"u/icq@MMSWsy$XFo@#q3Arbnx@Plzv7s\\+$a";
|
|
|
|
//string url = "https://support.bewoplaner.de/api/geticf.php?k=[TENANT]";
|
|
|
|
|
|
//if (MultitenancyOperationContextExt.Current != null)
|
|
//{
|
|
// url = url.Replace("[TENANT]", MultitenancyOperationContextExt.Current.Tenant);
|
|
//}
|
|
//else
|
|
//{
|
|
// url = url.Replace("[TENANT]", SessionFacade.Tenant);
|
|
//}
|
|
|
|
//String json = "";
|
|
|
|
//using (var client = new WebClient())
|
|
//{
|
|
// byte[] response = client.UploadValues(url, "POST", new NameValueCollection()
|
|
// {
|
|
// {"API-KEY", key}
|
|
// });
|
|
|
|
// json = System.Text.Encoding.ASCII.GetString(response);
|
|
|
|
|
|
//}
|
|
|
|
//[{"Oid":"1","Code":"","Bezeichnung":"Kapitel 1: Lernen und Wissensanwendung","Beschreibung":"","ParentOID":""}
|
|
//var icfentry = new { Oid = 0, Code = "", Bezeichnung = "", Beschreibung = "", ParentOid = 0 };
|
|
|
|
//var icfList = JsonConvert.DeserializeObject<List<Icf>>(json);
|
|
|
|
|
|
////var rawList = DAOFactory.GenericDAO.GetAll<Icf>().ToList();
|
|
|
|
//var icfs = new List<ValueListEntryDC>
|
|
//{
|
|
// new ValueListEntryDC() {ParentOid = -1, TypeDescription = "ICF"}
|
|
//};
|
|
|
|
//icfs.AddRange(icfList.Select(x => new ValueListEntryDC()
|
|
//{
|
|
// ValueListEntryOid = x.Oid,
|
|
// ParentOid = x.ParentOID,
|
|
// TypeDescription = x.Bezeichnung,
|
|
// Abbreviation = x.Code,
|
|
// Notice = x.Beschreibung
|
|
//}));
|
|
|
|
//var wholeICF = ICFDAO.GetWholeIcf();
|
|
#endregion
|
|
|
|
return ICFDAO.GetIcf();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public List<ValueListEntryDC> GetWholeIcf()
|
|
{
|
|
try
|
|
{
|
|
return ICFDAO.GetWholeIcf();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ValueListEntryDC> GetWholeIcfOhneImportierte(List<ValueListEntryDC> vorhandeneZiele)
|
|
{
|
|
try
|
|
{
|
|
List<ValueListEntryDC> listeMitUeberschneidungen = new List<ValueListEntryDC>();
|
|
var icf = ICFDAO.GetWholeIcf();
|
|
|
|
foreach (var chapter in icf)
|
|
{
|
|
foreach (var vorhandenesKapitel in vorhandeneZiele)
|
|
{
|
|
// TEMPORÄR ZUM TESTEN; Richtiger Ansatz, aber muss differenzieren, ob es oberkapitel sind
|
|
if (vorhandenesKapitel != null && vorhandenesKapitel.DisplayName == chapter.DisplayName && !vorhandenesKapitel.DisplayName.Contains("ICF") &&
|
|
!vorhandenesKapitel.DisplayName.Contains("Komponente") && !vorhandenesKapitel.DisplayName.Contains("Kapitel"))
|
|
{
|
|
if (!icf.Any(c => c.ParentOid == vorhandenesKapitel.ValueListEntryOid))
|
|
{
|
|
listeMitUeberschneidungen.Add(chapter);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Statt Parent-Objekten vllt eher Children zusammensuchen?
|
|
List<ValueListEntryDC> parentObjekte = new List<ValueListEntryDC>();
|
|
foreach (var item in listeMitUeberschneidungen)
|
|
{
|
|
if (item.ValueListEntryOid == 85)
|
|
Console.WriteLine("hallo");
|
|
if (item.ParentOid != null)
|
|
{
|
|
var parent = listeMitUeberschneidungen.FirstOrDefault(i => i.ValueListEntryOid == item.ParentOid);
|
|
|
|
if (parent != null)
|
|
{
|
|
parentObjekte.Add(parent);
|
|
}
|
|
}
|
|
}
|
|
//listeMitUeberschneidungen.RemoveRange(parentObjekte);
|
|
|
|
Dictionary<long?, List<ValueListEntryDC>> alleKinderDerVadderOid = new Dictionary<long?, List<ValueListEntryDC>>();
|
|
foreach (var item in icf)
|
|
{
|
|
if (item.ParentOid.HasValue && !alleKinderDerVadderOid.ContainsKey(item.ParentOid.Value))
|
|
{
|
|
alleKinderDerVadderOid.Add(item.ParentOid.Value, new List<ValueListEntryDC>());
|
|
}
|
|
if (alleKinderDerVadderOid.ContainsKey(item.ParentOid.Value))
|
|
{
|
|
alleKinderDerVadderOid[item.ParentOid.Value].Add(item);
|
|
}
|
|
}
|
|
|
|
|
|
//icf.RemoveRange(listeMitUeberschneidungen);
|
|
|
|
icf = EntferneParentOhneKinder(listeMitUeberschneidungen, alleKinderDerVadderOid, icf);
|
|
|
|
var funktionenDesBewusstseins = icf.Where(i => i.DisplayName.Contains("Funktionen des Bewusstseins")).ToList();
|
|
|
|
return icf;
|
|
|
|
// Komplett importiertes verschwindet jetzt, außer alles, wo "Kapitel", "Komponente" oder "ICF" enthalten ist (if-Bedingungen weiter oben)
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
// enthält alles, außer das, was gebraucht wird
|
|
private List<ValueListEntryDC> EntferneParentOhneKinder(List<ValueListEntryDC> listeMitUeberschneidungen, Dictionary<long?, List<ValueListEntryDC>> alleKinderDerVadderOid, List<ValueListEntryDC> icf)
|
|
{
|
|
// Zum Zeitpunkt des Aufrufens dieser Methode sind alle Ziele, die bereits importiert wurden, aus dem ICF entfernt, sofern diese keine Kinder mehr haben
|
|
// (also alle "Blätter" des Baums. Die leeren Äste sind allerdings noch da. Jeder Ast muss jetzt geprüft werden, und zwar darauf, ob er noch mindestens ein Blatt hat)
|
|
List<ValueListEntryDC> toRemove = new List<ValueListEntryDC>();
|
|
|
|
foreach (var item in listeMitUeberschneidungen)
|
|
{
|
|
var kinderlisteFuerCurrent = (alleKinderDerVadderOid.ContainsKey(item.ValueListEntryOid)) ? alleKinderDerVadderOid[item.ValueListEntryOid] : null;
|
|
bool enthealtBereitsAlleKinder = true;
|
|
|
|
if (kinderlisteFuerCurrent != null)
|
|
{
|
|
foreach (var child in kinderlisteFuerCurrent)
|
|
{
|
|
if (!listeMitUeberschneidungen.Contains(child))
|
|
{
|
|
enthealtBereitsAlleKinder = false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
if (enthealtBereitsAlleKinder)
|
|
toRemove.Add(item);
|
|
}
|
|
|
|
//icf.RemoveRange(toRemove); // Entfernen klappt nicht
|
|
|
|
for (int i = icf.Count - 1; i >= 0; i--)
|
|
{
|
|
var current = icf[i];
|
|
foreach (var c in toRemove) // In toRemove stehen alle drin, die nicht sollen, und nur das gewollte fehlt (noch in listeMitUeberschneidungen)
|
|
{
|
|
if (current.ValueListEntryOid == 85)
|
|
Console.WriteLine("hallo"); // Es gibt im ICF keinen Eintrag damit.. hä?
|
|
if (c.ValueListEntryOid == 85)
|
|
Console.WriteLine("hallo");
|
|
|
|
if (c.ValueListEntryOid == current.ValueListEntryOid)
|
|
{
|
|
icf.Remove(c); // Code kommt hier nicht an
|
|
}
|
|
}
|
|
}
|
|
|
|
return icf;
|
|
}
|
|
|
|
public IList<ReportTemplateDC> GetReportTemplates(string url)
|
|
{
|
|
try
|
|
{
|
|
if (url.IsNullOrEmpty())
|
|
return null;
|
|
|
|
var index = url.IndexOf("type=") + 5;
|
|
var typeString = url.Substring(index);
|
|
if (typeString.IndexOf("&") > 0)
|
|
{
|
|
typeString = typeString.Substring(0, typeString.IndexOf("&"));
|
|
}
|
|
if (!Enum.TryParse(typeString, out ReportTypes reportType))
|
|
return null;
|
|
|
|
var list = MapperFactory.ReportTemplateDC_ReportTemplate.MapToNewDCs(DAOFactory.GenericDAO.GetAllActive<ReportTemplate>().Where(x => x.ReportTemplateType == reportType));
|
|
|
|
if (list.Count == 0 && reportType == ReportTypes.RosterReport)
|
|
{
|
|
list.Add(new ReportTemplateDC
|
|
{
|
|
DisplayName = "Dienstplanung",
|
|
ReportTemplateType = ReportTypes.RosterReport,
|
|
Oid = -1
|
|
});
|
|
|
|
list.Add(new ReportTemplateDC
|
|
{
|
|
DisplayName = "Arbeitszeiterfassung",
|
|
ReportTemplateType = ReportTypes.RosterReportIst,
|
|
Oid = -2
|
|
});
|
|
}
|
|
return list;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
//public Tuple<IList<AbsenceTimeDC>, IList<EmployeeDC>> GetAbsenceTimeDCEmployee11()
|
|
//{
|
|
// try
|
|
// {
|
|
// return GetAbsenceTimeDCEmployee41(DateTime.MinValue, DateTime.MaxValue, null, null);
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// throw Utils.CreateBeWoFaultException(e);
|
|
// }
|
|
//}
|
|
|
|
//public Tuple<IList<AbsenceTimeDC>, IList<EmployeeDC>> GetAbsenceTimeDCEmployee21(List<AbsenceReasonDC> absenceReasons, List<EmploymentTypeDC> employmentTypes)
|
|
//{
|
|
// try
|
|
// {
|
|
// return GetAbsenceTimeDCEmployee41(DateTime.MinValue, DateTime.MaxValue, absenceReasons, employmentTypes);
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// throw Utils.CreateBeWoFaultException(e);
|
|
// }
|
|
//}
|
|
|
|
//public Tuple<IList<AbsenceTimeDC>, IList<EmployeeDC>> GetAbsenceTimeDCEmployee31(DateTime start, DateTime end)
|
|
//{
|
|
// try
|
|
// {
|
|
// return GetAbsenceTimeDCEmployee41(start, end, null, null);
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// throw Utils.CreateBeWoFaultException(e);
|
|
// }
|
|
//}
|
|
|
|
//public Tuple<IList<AbsenceTimeDC>, IList<EmployeeDC>> GetAbsenceTimeDCEmployee41(DateTime start, DateTime end, List<AbsenceReasonDC> absenceReasons, List<EmploymentTypeDC> employmentTypes)
|
|
//{
|
|
// try
|
|
// {
|
|
// var absenceReasonIDs = (absenceReasons == null || !absenceReasons.Any()) ? null : absenceReasons.Select(x => x.AbsenceReasonOid.Value).ToList();
|
|
// var employmentTypeIDs = (employmentTypes == null || !employmentTypes.Any()) ? null : employmentTypes.Select(x => x.EmploymentTypeOid.Value).ToList();
|
|
|
|
// return GetAbsenceTimeDCEmployee51(start, end, absenceReasonIDs, employmentTypeIDs);
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// throw Utils.CreateBeWoFaultException(e);
|
|
// }
|
|
//}
|
|
|
|
//public Tuple<IList<AbsenceTimeDC>, IList<EmployeeDC>> GetAbsenceTimeDCEmployee51(DateTime start, DateTime end, List<long> absenceReasonIDs, List<long> employmentTypeIDs)
|
|
//{
|
|
// try
|
|
// {
|
|
// Func<AbsenceTime, bool> endHasValueMatch = (x) => x.End.HasValue;
|
|
|
|
// Func<AbsenceTime, bool> leftMatch;
|
|
// Func<AbsenceTime, bool> rightMatch;
|
|
// Func<AbsenceTime, bool> absenceReasonMatch;
|
|
// Func<Employee, bool> employmentTypeMatch;
|
|
|
|
// if (start != DateTime.MinValue) leftMatch = (x) => start <= x.End;
|
|
// else leftMatch = (x) => true;
|
|
|
|
// if (end != DateTime.MaxValue) rightMatch = (x) => end >= x.Start;
|
|
// else rightMatch = (x) => true;
|
|
|
|
// if (absenceReasonIDs != null) absenceReasonMatch = (x) => absenceReasonIDs.Contains(x.AbsenceReason.Oid.Value);
|
|
// else absenceReasonMatch = (x) => true;
|
|
|
|
// if (employmentTypeIDs != null) employmentTypeMatch = (x) => employmentTypeIDs.Contains(x.Oid.Value);
|
|
// else employmentTypeMatch = (x) => true;
|
|
|
|
// Func<AbsenceTime, bool> absenceMatch = (x) => rightMatch(x) && (!endHasValueMatch(x) || leftMatch(x)) && absenceReasonMatch(x);
|
|
// //startMatch(x) && (!endHasValueMatch(x) || endMatch(x)) && absenceReasonMatch(x);
|
|
|
|
// var res1 = new List<AbsenceTime>();
|
|
// var res2 = new HashSet<Employee>();
|
|
|
|
// var allAbsences = DAOFactory.GenericDAO.GetAllActive<AbsenceTime>().Where(x => x.EmployeeOid.HasValue);
|
|
// var allEmployees = DAOFactory.GenericDAO.GetAllActive<Employee>().ToList();
|
|
|
|
// foreach (var absence in allAbsences.Where(absenceMatch)) //allAbsences.Where(absenceMatch))
|
|
// {
|
|
// var employee = allEmployees.Find(x => x.Oid == absence.EmployeeOid.Value);
|
|
|
|
// if (!employmentTypeMatch(employee))
|
|
// continue;
|
|
|
|
// res1.Add(absence);
|
|
// res2.Add(employee);
|
|
// }
|
|
|
|
// return new Tuple<IList<AbsenceTimeDC>, IList<EmployeeDC>>(MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewDCs(res1), MapperFactory.EmployeeDC_Employee.MapToNewDCs(res2.ToList()));
|
|
// }
|
|
// catch (Exception e)
|
|
// {
|
|
// throw Utils.CreateBeWoFaultException(e);
|
|
// }
|
|
//}
|
|
|
|
public IList<AbsenceReasonDC> GetAllAbsenceReason()
|
|
{
|
|
try
|
|
{
|
|
var list = DAOFactory.GenericDAO.GetAllActive<AbsenceReason>();
|
|
return MapperFactory.AbsenceReasonDC_AbsenceReason.MapToNewDCs(list);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public AbsenceTimeDC UpdateAbsenceTimeWithReturn(AbsenceTimeDC abs)
|
|
{
|
|
try
|
|
{
|
|
var testbefore = abs.AbsenceTimeVersion;
|
|
|
|
var x = DAOFactory.GenericDAO.LoadByID<AbsenceTime>(abs.AbsenceTimeOid.Value);
|
|
|
|
MapperFactory.AbsenceTimeDC_AbsenceTime.MergeWithEntity(abs, x);
|
|
|
|
DAOFactory.GenericDAO.Update(x);
|
|
|
|
var y = DAOFactory.GenericDAO.LoadByID<AbsenceTime>(abs.AbsenceTimeOid.Value);
|
|
|
|
var z = MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewDC(y);
|
|
|
|
return z;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public AbsenceTimeDC InsertAbsenceTimeWithReturn(AbsenceTimeDC absenceTimeDC)
|
|
{
|
|
try
|
|
{
|
|
var emp = DAOFactory.GenericDAO.GetByID<Employee>(absenceTimeDC.EmployeeOid.Value);
|
|
emp.AbsenceTimes.Add(MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewEntity(absenceTimeDC));
|
|
DAOFactory.GenericDAO.Update(emp);
|
|
|
|
emp = DAOFactory.GenericDAO.LoadByID<Employee>(absenceTimeDC.EmployeeOid.Value);
|
|
var newAbsenceTimeOid = emp.AbsenceTimes.Max(x => x.Oid);
|
|
var newAbsenceTimeDC = DAOFactory.GenericDAO.GetByID<AbsenceTime>(newAbsenceTimeOid.Value);
|
|
|
|
newAbsenceTimeDC.EmployeeOid = emp.Oid;
|
|
return MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewDC(newAbsenceTimeDC);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteAbsenceTime(AbsenceTimeDC absenceTimeDC)
|
|
{
|
|
try
|
|
{
|
|
var emp = DAOFactory.GenericDAO.GetByID<Employee>(absenceTimeDC.EmployeeOid.Value);
|
|
emp.AbsenceTimes.Remove(emp.AbsenceTimes.First(a => a.Oid == absenceTimeDC.AbsenceTimeOid));
|
|
DAOFactory.GenericDAO.Update(emp);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<SupportConceptCostBearerRelDC> GetSupportConceptCostBearerRelDCsByOids(List<long> supportConcept2CostbearerOids)
|
|
{
|
|
var costbearer2SupportConcepts = DAOFactory.SearchDAO.FindCostBearer2SupportConceptsByOids(supportConcept2CostbearerOids);
|
|
|
|
return MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDCs(costbearer2SupportConcepts);
|
|
}
|
|
|
|
public List<DienstInfoDC> GetAllDienste(long? wOid)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.GetAllDienste(wOid);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void InsertNewDienst(List<DienstInfoDC> dienst)
|
|
{
|
|
try
|
|
{
|
|
DienstplanungsManager.InsertNewDienst(dienst);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeactivateDienst(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
DienstplanungsManager.DeactivateDienst(pOid2Version);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateDienst(List<DienstInfoDC> dienste)
|
|
{
|
|
try
|
|
{
|
|
DienstplanungsManager.UpdateDienst(dienste);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<RatingTypeDC> GetAllRatingTypes()
|
|
{
|
|
try
|
|
{
|
|
var list = DAOFactory.GenericDAO.GetAllActive<RatingType>();
|
|
var result = MapperFactory.RatingTypeDC_RatingType.MapToNewDCs(list);
|
|
|
|
return result.OrderBy(r => r.Position).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void InsertNewRatingType(List<RatingTypeDC> ratingTypes)
|
|
{
|
|
try
|
|
{
|
|
var ratingType = MapperFactory.RatingTypeDC_RatingType.MapToNewEntities(ratingTypes);
|
|
DAOFactory.GenericDAO.Insert(ratingType);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeactivateRatingType(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
ServiceLogic.SetActivationType<RatingType>(pOid2Version, ActivationTypeId.Deleted);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateRatingType(List<RatingTypeDC> ratingTypes)
|
|
{
|
|
try
|
|
{
|
|
var lOriginals = DAOFactory.GenericDAO.LoadByIDs<RatingType>(ratingTypes.Select(r => r.RatingTypeOid.Value));
|
|
|
|
MapperFactory.RatingTypeDC_RatingType.MergeWithEntitys(ratingTypes, lOriginals);
|
|
|
|
DAOFactory.GenericDAO.Update(lOriginals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<GoalRatingDC> FetchServiceRecordRatings(long? supportConceptOid, long? costBearer2SupportConceptOid, long? supportConceptApprovalPeriodOid, long? serviceCategoryOid, DateTime? start, DateTime? end)
|
|
{
|
|
try
|
|
{
|
|
var types = new List<ValueListEntryType>();
|
|
types.Add(ValueListEntryType.SupportConceptGoalCategoryType);
|
|
types.Add(ValueListEntryType.SupportConceptIndividualGoalCategoryType);
|
|
|
|
var goals = DAOFactory.SearchDAO.FindValueListEntries(types);
|
|
|
|
Dictionary<long, ValueListEntryDC> oid2Entry = new Dictionary<long, ValueListEntryDC>();
|
|
|
|
foreach (var valueListEntry in goals)
|
|
{
|
|
if (!oid2Entry.ContainsKey(valueListEntry.Oid.Value))
|
|
{
|
|
oid2Entry.Add(valueListEntry.Oid.Value, MapperFactory.ValueListEntryDC_ValueListEntry.MapToNewDC(valueListEntry));
|
|
}
|
|
}
|
|
|
|
var allRatingTypes = MapperFactory.RatingTypeDC_RatingType.MapToNewDCs(DAOFactory.GenericDAO.GetAllActive<RatingType>());
|
|
|
|
List<GoalRatingDC> result = new List<GoalRatingDC>();
|
|
if (end.HasValue)
|
|
{
|
|
end = end.Value.Date.AddDays(1).AddSeconds(-1);
|
|
}
|
|
var records = DAOFactory.SearchDAO.FindServiceRecords(supportConceptOid, costBearer2SupportConceptOid, serviceCategoryOid, start, end);
|
|
|
|
foreach (var serviceRecord in records)
|
|
{
|
|
var dc = CreateServiceRecordDCCompact(serviceRecord);
|
|
if (dc.Goals != null)
|
|
{
|
|
foreach (var ve in dc.Goals)
|
|
{
|
|
var gr = new GoalRatingDC();
|
|
gr.GoalEntry = ve;
|
|
|
|
|
|
if (ve.Type == ValueListEntryType.SupportConceptGoalType || ve.Type == ValueListEntryType.SupportConceptIndividualGoalType)
|
|
{
|
|
//Bei Maßnahmen nimm das übergeordnete Ziel
|
|
if (ve.ParentOid.HasValue && oid2Entry.ContainsKey(ve.ParentOid.Value))
|
|
{
|
|
gr.GoalEntry = oid2Entry[ve.ParentOid.Value];
|
|
}
|
|
}
|
|
|
|
gr.ServiceRecord = dc;
|
|
|
|
if (ve.RatingTypeOid.HasValue)
|
|
{
|
|
gr.RatingType = allRatingTypes.FirstOrDefault(r => r.RatingTypeOid.HasValue && r.RatingTypeOid == ve.RatingTypeOid);
|
|
}
|
|
result.Add(gr);
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<DienstEintragDC> GetAllDienstEintraegeAsList(long wOid, int year, int month)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.GetAllDienstEintraegeAsList(wOid, year, month);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public List<DienstvertretungDC> GetAllDienstvertretungenAsList(long wOid, int year, int month)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.GetAllDienstvertretungenAsList(wOid, year, month);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public List<DienstBlockDC> GetDienstEintraege(long wOid, int year, int month)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.GetDienstEintraege(wOid, year, month);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public List<DienstBlockDC> GetDienstvertretungen(long wOid, int year, int month)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.GetDienstvertretungen(wOid, year, month);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
|
|
public void InsertNewDienstEintrag(DienstEintragDC dienstEintrag)
|
|
{
|
|
try
|
|
{
|
|
DienstplanungsManager.InsertNewDienstEintrag(dienstEintrag);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public bool InsertNewDienstEintrag2(DienstEintragDC dienstEintrag, List<DienstEintragDC> alleDiensteintraege, List<DienstvertretungDC> alleDienstvertretungen,
|
|
int day, DateTime pflichtStart, DateTime pflichtEnde)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.InsertNewDienstEintrag2(dienstEintrag, alleDiensteintraege, alleDienstvertretungen, day, pflichtStart, pflichtEnde);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public void InsertNewDienstEintraege(List<DienstEintragDC> dienstEintraege)
|
|
{
|
|
try
|
|
{
|
|
DienstplanungsManager.InsertNewDienstEintraege(dienstEintraege);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void InsertNewDienstvertretung(DienstvertretungDC dienstvertretung)
|
|
{
|
|
try
|
|
{
|
|
DienstplanungsManager.InsertNewDienstvertretung(dienstvertretung);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public bool InsertNewDienstvertretung2(DienstvertretungDC dienstvertretung, List<DienstEintragDC> alleDiensteintraege, List<DienstvertretungDC> alleDienstvertretungen,
|
|
int day, DateTime pflichtStart, DateTime pflichtEnde)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.InsertNewDienstvertretung2(dienstvertretung, alleDiensteintraege, alleDienstvertretungen, day, pflichtStart, pflichtEnde);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateDienstEintrag(DienstEintragDC dienstEintrag)
|
|
{
|
|
try
|
|
{
|
|
DienstplanungsManager.UpdateDienstEintrag(dienstEintrag);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteDienstEintrag(long empId, long wohnId, int zeile, DateTime date)
|
|
{
|
|
try
|
|
{
|
|
DienstplanungsManager.DeleteDienstEintrag(empId, wohnId, zeile, date);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public bool DeleteDienstEintrag2(long empId, long wohnId, int zeile, DateTime date, DienstEintragDC dienstEintrag, List<DienstEintragDC> alleDiensteintraege,
|
|
List<DienstvertretungDC> alleDienstvertretungen, int day, DateTime pflichtStart, DateTime pflichtEnde)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.DeleteDienstEintrag2(empId, wohnId, zeile, date, dienstEintrag, alleDiensteintraege, alleDienstvertretungen, day, pflichtStart, pflichtEnde);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public void DeleteDienstvertretung(long empId, long wohnId, int zeile, DateTime date)
|
|
{
|
|
try
|
|
{
|
|
DienstplanungsManager.DeleteDienstvertretung(empId, wohnId, zeile, date);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public bool DeleteDienstvertretung2(long empId, long wohnId, int zeile, DateTime date, DienstvertretungDC dienstvertretung, List<DienstEintragDC> alleDiensteintraege,
|
|
List<DienstvertretungDC> alleDienstvertretungen, int day, DateTime pflichtStart, DateTime pflichtEnde)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.DeleteDienstvertretung2(empId, wohnId, zeile, date, dienstvertretung, alleDiensteintraege, alleDienstvertretungen, day, pflichtStart, pflichtEnde);
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteCertainDienstEintragOutOfTable(long dienstEintragOid)
|
|
{
|
|
try
|
|
{
|
|
DienstplanungsManager.DeleteCertainDienstEintragOutOfTable(dienstEintragOid);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(ex);
|
|
}
|
|
}
|
|
public string GetBemerkungForDienstEintrag(long empId, long wohnId, int zeile, DateTime date)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.GetBemerkungForDienstEintrag(empId, wohnId, zeile, date);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public DienstEintragDC GetDienstEintrag(long empId, long wohnId, int zeile, DateTime date)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.GetDienstEintrag(empId, wohnId, zeile, date);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public DienstvertretungDC GetDienstvertretung(long empId, long wohnId, int zeile, DateTime date)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.GetDienstvertretung(empId, wohnId, zeile, date);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public virtual List<FeiertagDC> ErstelleDefaultFeiertage(int year)
|
|
{
|
|
try
|
|
{
|
|
var vs = PluginLoader.FindClass<VacationService>();
|
|
|
|
var list = vs.GetFeiertage(year, vs.Bundesland);
|
|
|
|
return list;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public List<FeiertagDC> GetDefaultFeiertageForYear(int year)
|
|
{
|
|
try
|
|
{
|
|
var vs = PluginLoader.FindClass<VacationService>();
|
|
var ber = PluginLoader.FindClass<MitarbeiterstundenkontoBerechnung>();
|
|
var altList = ber.GetFeiertage(year);
|
|
var list = vs.GetFeiertage(year, vs.Bundesland);
|
|
|
|
return list;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public void InsertRegelmaessigerDienst(RegelmaessigerDienstDC dienst)
|
|
{
|
|
try
|
|
{
|
|
DAOFactory.GenericDAO.Insert(MapperFactory.RegelmaessigerDienstDC_RegelmaessigerDienst.MapToNewEntity(dienst));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public List<DienstEintragDC> InsertRegelmaessigerDienst2(RegelmaessigerDienstDC dienst, List<DienstEintragDC> alleDienstEintraege, List<DienstvertretungDC> alleDienstvertretungen,
|
|
List<AbsenceTimeDC> absenceTimes, bool enableDiensteAnFeiertagen, List<FeiertagDC> feiertage, List<DienstZeileDC> dienstZeilenListe, DateTime pflichtStart, DateTime pflichtEnde,
|
|
bool enableStatusZeile, DateTime datum)
|
|
{
|
|
try
|
|
{
|
|
DAOFactory.GenericDAO.Insert(MapperFactory.RegelmaessigerDienstDC_RegelmaessigerDienst.MapToNewEntity(dienst));
|
|
return DienstplanungsManager.AddRegelmaessigeDiensteToDienstplaner(dienst, alleDienstEintraege, alleDienstvertretungen, absenceTimes, feiertage, enableDiensteAnFeiertagen,
|
|
dienstZeilenListe, pflichtStart, pflichtEnde, enableStatusZeile, datum);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public void DeleteRegelmaessigerDienst(RegelmaessigerDienstDC dienst)
|
|
{
|
|
try
|
|
{
|
|
DAOFactory.GenericDAO.Delete(DAOFactory.GenericDAO.GetByID<RegelmaessigerDienst>((long)dienst.Oid));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void InsertConfirmationReceiptSignature(ConfirmationReceiptSignatureDC confirmationReceiptSignature)
|
|
{
|
|
try
|
|
{
|
|
var confRecSig = MapperFactory.ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature.MapToNewEntity(confirmationReceiptSignature);
|
|
|
|
DAOFactory.GenericDAO.Insert(confRecSig);
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
public void InsertConfirmationReceiptSignatures(List<ConfirmationReceiptSignatureDC> confirmationReceiptSignatures)
|
|
{
|
|
try
|
|
{
|
|
var confRecSigs = MapperFactory.ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature.MapToNewEntities(confirmationReceiptSignatures);
|
|
|
|
DAOFactory.GenericDAO.Insert(confRecSigs);
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
public void DeleteConfirmationReceiptSignature(long confirmationReceiptSignatureOid)
|
|
{
|
|
try
|
|
{
|
|
var confirmationReceiptSignatureToDelete = DAOFactory.GenericDAO.LoadByID<ConfirmationReceiptSignature>(confirmationReceiptSignatureOid);
|
|
|
|
DAOFactory.GenericDAO.Delete(confirmationReceiptSignatureToDelete);
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
public ConfirmationReceiptSignatureDC UpdateConfirmationReceiptSignature(ConfirmationReceiptSignatureDC confirmationReceiptSignature)
|
|
{
|
|
try
|
|
{
|
|
var confirmationReceiptSignatureToUpdate = DAOFactory.GenericDAO.LoadByID<ConfirmationReceiptSignature>(confirmationReceiptSignature.ConfirmationReceiptSignatureOid.Value);
|
|
|
|
MapperFactory.ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature.MergeWithEntity(confirmationReceiptSignature, confirmationReceiptSignatureToUpdate);
|
|
|
|
DAOFactory.GenericDAO.Update(confirmationReceiptSignatureToUpdate);
|
|
|
|
var updatedConfirmationReceiptSignature = DAOFactory.GenericDAO.LoadByID<ConfirmationReceiptSignature>(confirmationReceiptSignature.ConfirmationReceiptSignatureOid.Value);
|
|
|
|
return MapperFactory.ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature.MapToNewDC(updatedConfirmationReceiptSignature);
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
public List<ConfirmationReceiptSignatureDC> GetConfirmationReceiptSignaturesByEmployee(long employeeOid, DateTimeSpan timeSpan)
|
|
{
|
|
try
|
|
{
|
|
var signatures = DAOFactory.SearchDAO.GetConfirmationReceiptSignaturesByEmployee(employeeOid, timeSpan);
|
|
|
|
var signatureDCs = MapperFactory.ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature.MapToNewDCs(signatures);
|
|
|
|
return signatureDCs;
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
public List<ConfirmationReceiptSignatureDC> GetConfirmationReceiptSignaturesByServiceRecord(long serviceRecordOid)
|
|
{
|
|
try
|
|
{
|
|
var signatures = DAOFactory.SearchDAO.GetConfirmationReceiptSignaturesByServiceRecord(serviceRecordOid);
|
|
|
|
var signatureDCs = MapperFactory.ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature.MapToNewDCs(signatures);
|
|
|
|
return signatureDCs;
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
public List<EmployeeDC> GetAbsenceOverview(AbsenceOverviewFilterDC filter)
|
|
{
|
|
try
|
|
{
|
|
var res = new List<EmployeeDC>();
|
|
var vs = PluginLoader.FindClass<VacationService>();
|
|
|
|
var allEmployees = DAOFactory.GenericDAO.GetAllActive<Employee>().ToList();
|
|
|
|
List<Team> teams = new List<Team>();
|
|
if (filter.Teams != null)
|
|
teams = DAOFactory.GenericDAO.GetActiveByIDs<Team>(filter.Teams) as List<Team>;
|
|
|
|
|
|
//foreach (var emp in allEmployees.OrderBy(x => x.Person.LastNameFirstName))
|
|
List<Employee> benoetigteMitarbeiter = new List<Employee>();
|
|
if (teams.Count == 0)
|
|
benoetigteMitarbeiter = allEmployees;
|
|
else
|
|
{
|
|
foreach (var team in teams)
|
|
{
|
|
benoetigteMitarbeiter.AddRange(team.MemberList);
|
|
}
|
|
}
|
|
benoetigteMitarbeiter.OrderBy(x => x.Person.LastNameFirstName).ToList();
|
|
|
|
foreach (var emp in benoetigteMitarbeiter)
|
|
{
|
|
if (filter.EmploymentType != null)
|
|
if (!emp.Contracts.Any(x => x.EmploymentType != null && filter.EmploymentType.Contains(x.EmploymentType.Oid.Value)))
|
|
continue;
|
|
|
|
|
|
var dict = vs.BerechneUrlaubskonto(emp, filter.Year);
|
|
|
|
if (filter.AbsenceReasons != null)
|
|
emp.AbsenceTimes.RemoveRange(x => !filter.AbsenceReasons.Contains(x.AbsenceReason.Oid.Value));
|
|
|
|
//if (filter.Teams != null)
|
|
//{
|
|
// bool isInTeam = false;
|
|
// foreach (var team in teams)
|
|
// {
|
|
// if (team.MemberList.Contains(emp))
|
|
// isInTeam = true;
|
|
// }
|
|
// if (!isInTeam)
|
|
// continue;
|
|
//}
|
|
|
|
var empDC = MapperFactory.EmployeeDC_Employee.MapToNewDC(emp);
|
|
if (dict.ContainsKey(filter.Year))
|
|
{
|
|
empDC.Urlaubskonto = dict[filter.Year];
|
|
}
|
|
else
|
|
{
|
|
int test = 0;
|
|
}
|
|
|
|
res.Add(empDC);
|
|
}
|
|
|
|
return res.OrderBy(e => e.LastNameFirstName).ToList();
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
public List<CompactTeamDC> GetCertainTeamsById(List<long> oids)
|
|
{
|
|
var teams = DAOFactory.GenericDAO.GetActiveByIDs<Team>(oids);
|
|
return MapperFactory.CompactTeamDC_Team.MapToNewDCs(teams);
|
|
}
|
|
public UrlaubskontoDC GetUrlaubskontoByEmployee(long empOid, int year)
|
|
{
|
|
try
|
|
{
|
|
var vs = PluginLoader.FindClass<VacationService>();
|
|
var emp = DAOFactory.GenericDAO.GetByID<Employee>(empOid);
|
|
|
|
return vs.BerechneUrlaubskonto(emp, year)[year];
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
public List<AbsenceTimeDC> GetAbsenceTimesForMonth(long empOid, int month, int year, long absenceReason)
|
|
{
|
|
// monat und jahr sind 0
|
|
var date = new DateTime(year, month, 1);
|
|
List<AbsenceTime> timesForMonth = DAOFactory.SearchDAO.FindAbsenceTimesForEmployee(date, date.AddMonths(1).AddTicks(-1), empOid) as List<AbsenceTime>;
|
|
|
|
List<AbsenceTime> urlaub = new List<AbsenceTime>();
|
|
|
|
foreach (var item in timesForMonth)
|
|
{
|
|
if (item.AbsenceReason.Description.Equals("Urlaub"))
|
|
urlaub.Add(item);
|
|
}
|
|
|
|
List<AbsenceTimeDC> dcs = MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewDCs(urlaub);
|
|
|
|
return dcs;
|
|
}
|
|
|
|
public List<ConfirmationReceiptSignatureDC> GetAllConfirmationReceiptSignatures()
|
|
{
|
|
try
|
|
{
|
|
return MapperFactory.ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature.MapToNewDCs(DAOFactory.GenericDAO.GetAllActive<ConfirmationReceiptSignature>());
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
public List<ServiceRecordDC> GetServiceRecordsByIds(List<long> serviceRecordOids)
|
|
{
|
|
try
|
|
{
|
|
return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(DAOFactory.GenericDAO.LoadByIDs<ServiceRecord>(serviceRecordOids));
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
|
|
public String GetOwnChatSettingsUrl()
|
|
{
|
|
//var url = ConfigurationManager.AppSettings.Get("OwnChatSettingsUrl");
|
|
//url = url.Replace("[TENANT]", MultitenancyOperationContextExt.Current.Tenant);
|
|
|
|
//return url;
|
|
|
|
if (MultitenancyOperationContextExt.Current != null)
|
|
{
|
|
var tenant = MultitenancyOperationContextExt.Current.Tenant;
|
|
|
|
var mandant = GetMandatorEntity();
|
|
|
|
var apikey = mandant.Apikey;
|
|
#if DEBUG
|
|
tenant = "6000000000";
|
|
apikey = "CpmUcJGhFwySzMjFrahNKeWdv4paFo5VTfdS6ebq111DpL8LurkX3aKOPwiLVCdv";
|
|
#endif
|
|
|
|
var serverUrl = OwnChatHelper.ErmittleServerURL(tenant);
|
|
String accesstokenUrl = String.Format("{0}/api/ownchat/settings/accesstoken/{1}/{2}", serverUrl, tenant, apikey);
|
|
WebRequest request = WebRequest.Create(accesstokenUrl);
|
|
|
|
request.Credentials = CredentialCache.DefaultCredentials;
|
|
|
|
WebResponse response = request.GetResponse();
|
|
|
|
string responseFromServer = ReadStreamForChatCode(response);
|
|
|
|
var definition = new { result = "", errortext = "", token = "" };
|
|
|
|
var jsondaten = JsonConvert.DeserializeAnonymousType(responseFromServer, definition);
|
|
|
|
response.Close();
|
|
|
|
|
|
return String.Format("{0}/settings/{1}/{2}", serverUrl, tenant, jsondaten.token);
|
|
}
|
|
|
|
|
|
return "https://www.bewoplaner.de";
|
|
}
|
|
|
|
public bool HasConfirmationReceiptSignaturesByEmployeeAndServiceRecords(long employeeOid, IEnumerable<long> serviceRecordOids)
|
|
{
|
|
try
|
|
{
|
|
return DAOFactory.SearchDAO.HasConfirmationReceiptSignaturesByEmployeeAndServiceRecords(employeeOid, serviceRecordOids);
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
public bool HasConfirmationReceiptSignatureByDateAndCustomer(long customerOid, DateTimeSpan timeSpan, SignatureType signatureType)
|
|
{
|
|
try
|
|
{
|
|
return DAOFactory.SearchDAO.HasConfirmationReceiptSignatureByDateAndCustomer(customerOid, timeSpan, signatureType);
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
public ServiceCategoryDC LoadServiceCategory(long serviceCategoryOid)
|
|
{
|
|
try
|
|
{
|
|
var serviceCategory = DAOFactory.GenericDAO.LoadByID<ServiceCategory>(serviceCategoryOid);
|
|
|
|
return MapperFactory.ServiceCategoryDC_ServiceCategory.MapToNewDC(serviceCategory);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ConfirmationReceiptSignatureDC> FindConfirmationReceiptSignaturesByEmployeeAndServiceRecords(long employeeOid, IEnumerable<long> serviceRecordOids)
|
|
{
|
|
try
|
|
{
|
|
var confirmationReceiptSignatureEntities = DAOFactory.SearchDAO.FindConfirmationReceiptSignaturesByEmployeeAndServiceRecords(employeeOid, serviceRecordOids);
|
|
|
|
return MapperFactory.ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature.MapToNewDCs(confirmationReceiptSignatureEntities);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<VorlagentabelleDC> GetVorlagentabelleDCs()
|
|
{
|
|
try
|
|
{
|
|
return VorlagenManager.GetVorlagentabelleDCs();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(ex);
|
|
|
|
}
|
|
}
|
|
|
|
public DokumentvorlageDC InsertTemplate(DokumentvorlageDC dc)
|
|
{
|
|
try
|
|
{
|
|
return VorlagenManager.InsertTemplate(dc);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(ex);
|
|
}
|
|
}
|
|
public List<PlatzhalterDC> GetPlatzhalterForCustomer()
|
|
{
|
|
try
|
|
{
|
|
return VorlagenManager.GetPlatzhalterForCustomer();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(ex);
|
|
}
|
|
}
|
|
public List<PlatzhalterDC> GetPlatzhalterForSupportConcept()
|
|
{
|
|
try
|
|
{
|
|
return VorlagenManager.GetPlatzhalterForSupportConcept();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(ex);
|
|
}
|
|
}
|
|
public List<PlatzhalterDC> GetPlatzhalterForEmployee()
|
|
{
|
|
try
|
|
{
|
|
return VorlagenManager.GetPlatzhalterForEmployee();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(ex);
|
|
}
|
|
}
|
|
public BeWoFolderDC GetFolderById(long oid)
|
|
{
|
|
try
|
|
{
|
|
return VorlagenManager.GetFolderById(oid);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(ex);
|
|
}
|
|
}
|
|
public VorlagentabelleDC GetVorlagentabelleById(long oid)
|
|
{
|
|
try
|
|
{
|
|
return VorlagenManager.GetVorlagentabelleById(oid);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(ex);
|
|
}
|
|
}
|
|
public List<DokumentvorlageDC> GetDokumentvorlagenInFolder(long folderOid)
|
|
{
|
|
try
|
|
{
|
|
return VorlagenManager.GetDokumentvorlagenInFolder(folderOid);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(ex);
|
|
}
|
|
}
|
|
|
|
public List<SupportConceptDC> GetSupportConceptsById(IEnumerable<long> supportConceptOids)
|
|
{
|
|
try
|
|
{
|
|
var supportConcepts = DAOFactory.GenericDAO.LoadByIDs<SupportConcept>(supportConceptOids);
|
|
|
|
return MapperFactory.SupportConceptDC_SupportConcept.MapToNewDCs(supportConcepts);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public void DeleteTemplates(List<DokumentvorlageDC> vorlagen)
|
|
{
|
|
try
|
|
{
|
|
VorlagenManager.DeleteTemplates(vorlagen);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public bool HasConfirmationReceiptSignature(IList<long> serviceRecordOids, SignatureType signatureType)
|
|
{
|
|
try
|
|
{
|
|
return DAOFactory.SearchDAO.HasConfirmationReceiptSignature(serviceRecordOids, signatureType);
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public string ReplacePlaceholdersInTemplate(DokumentvorlageDC template, long? objectOid, long? tableOid)
|
|
{
|
|
try
|
|
{
|
|
return VorlagenManager.ReplacePlaceholdersInTemplate(template, objectOid, tableOid);
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void InsertFileAttachment(FileAttachmentDC fileAttachmentDC)
|
|
{
|
|
try
|
|
{
|
|
DokumentManager.InsertFileAttachment(fileAttachmentDC);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<FileAttachmentDC> SearchForFiles(string nutzereingabe)
|
|
{
|
|
try
|
|
{
|
|
return DokumentManager.SearchForFiles(nutzereingabe);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public string GetObjectForFilePath(TableID table, long? oid)
|
|
{
|
|
try
|
|
{
|
|
return DokumentManager.GetObjectForFilePath(table, oid);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
|
|
public void RemoveAllDiensteForOneMonth(CompactWohnheimDC wh, DateTime month, List<RegelmaessigerDienstDC> rd)
|
|
{
|
|
try
|
|
{
|
|
DienstplanungsManager.RemoveAllDiensteForOneMonth(wh, month, rd);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public void RemoveAllDiensteForOneYear(CompactWohnheimDC wh, DateTime year, List<RegelmaessigerDienstDC> rd)
|
|
{
|
|
try
|
|
{
|
|
DienstplanungsManager.RemoveAllDiensteForOneYear(wh, year, rd);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public string GetColorForStatus(bool status)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.GetColorForStatus(status);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public string GetColorForForeground()
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.GetColorForForeground();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public string GetColorForServiceRecordView2()
|
|
{
|
|
try
|
|
{
|
|
return "#008EED";
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public DienstplanerRootDC BuildDienstplanerRootObject(DateTime date, long wohnheimOid)
|
|
{
|
|
try
|
|
{
|
|
DienstplanerRootDC root = DienstplanungsManager.BuildDienstplanerRootObject(date, wohnheimOid);
|
|
//root.Feiertage = GetDefaultFeiertageForYear(date.Year);
|
|
|
|
return root;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public void DeleteRegelmaessigeDiensteOfRemovedEmployee(List<CompactEmployeeDC> employee, long wOid)
|
|
{
|
|
try
|
|
{
|
|
DienstplanungsManager.DeleteRegelmaessigeDiensteOfRemovedEmployee(employee, wOid);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<CompactEmployeeDC> GetCompactEmployeesForTeam(long teamOid)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.GetCompactEmployeesForTeam(teamOid);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public DienstZeileDC InitStatusZeile(DateTime date)
|
|
{
|
|
|
|
try
|
|
{
|
|
return DienstplanungsManager.InitStatusZeile(date);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public List<string> SetSortierMethoden()
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.SetSortierMethoden();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public List<DienstBlockDC> DienstBloeckeNeuSortieren(List<DienstBlockDC> bloecke, string auswahl, bool aufsteigend)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.DienstBloeckeNeuSortieren(bloecke, auswahl, aufsteigend);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
|
|
public Dictionary<string, string> GetAdditionalEmployeeInformationForScheduler(long empOid)
|
|
{
|
|
Dictionary<string, string> dict = new Dictionary<string, string>();
|
|
|
|
var employee = DAOFactory.GenericDAO.GetByID<Employee>(empOid);
|
|
|
|
dict.Add("Vorname", employee.Person.FirstName);
|
|
dict.Add("Nachname", employee.Person.LastName);
|
|
if(employee.Person.DateOfBirth != null)
|
|
{
|
|
var dateAndTime = employee.Person.DateOfBirth.ToString().Split(' ');
|
|
dict.Add("Geburtstag", dateAndTime[0]);
|
|
}
|
|
//if(employee.AbsenceTimes != null)
|
|
//{
|
|
// int c = 1;
|
|
// foreach (var item in employee.AbsenceTimes)
|
|
// {
|
|
// dict.Add("Abwesenheit " + c, item.AbsenceSpan.ToDateString());
|
|
// c++;
|
|
// }
|
|
//}
|
|
if(employee.IsQualified != null)
|
|
dict.Add("Qualifiziert", ((bool)employee.IsQualified) ? "Ja" : "Nein");
|
|
if(employee.Schutzstufe != null)
|
|
dict.Add("Schutzstufe", employee.Schutzstufe);
|
|
|
|
|
|
return dict;
|
|
}
|
|
|
|
public string GetXAMLInformationStringForEmployee(long empOid)
|
|
{
|
|
try
|
|
{
|
|
return XAMLInformation.InfoViaXAMLManager.GetXAMLInformationStringForEmployee(empOid, null);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public string GetXAMLInformationStringForScheduler(long customerOid)
|
|
{
|
|
try
|
|
{
|
|
return XAMLInformation.InfoViaXAMLManager.GetXAMLInformationStringForScheduler(customerOid);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public string GetXAMLInformationStringForCustomer(long customerOid)
|
|
{
|
|
try
|
|
{
|
|
return XAMLInformation.InfoViaXAMLManager.GetXAMLInformationStringForCustomer(customerOid, null);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ConfirmationReceiptSignatureDC> LoadConfirmationReceiptSignaturesByServiceRecordOids(IList<long> serviceRecordOids, SignatureType signatureType, out List<long> serviceRecordOidsWithSignatures)
|
|
{
|
|
try
|
|
{
|
|
var signatures = DAOFactory.SearchDAO.LoadConfirmationReceiptSignaturesByServiceRecordOids(serviceRecordOids, signatureType);
|
|
|
|
serviceRecordOidsWithSignatures = new List<long>();
|
|
|
|
foreach(var crs in signatures)
|
|
{
|
|
foreach(var sr in crs.ServiceRecords)
|
|
{
|
|
if(sr.Oid.HasValue && serviceRecordOids.Contains(sr.Oid.Value))
|
|
{
|
|
serviceRecordOidsWithSignatures.AddIfNotIn(sr.Oid.Value);
|
|
}
|
|
}
|
|
}
|
|
|
|
return MapperFactory.ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature.MapToNewDCs(signatures);
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ConfirmationReceiptSignatureDC> UpdateConfirmationReceiptSignatures(IList<ConfirmationReceiptSignatureDC> confirmationReceiptSignatures2Update)
|
|
{
|
|
try
|
|
{
|
|
var lOriginals = DAOFactory.GenericDAO.LoadByIDs<ConfirmationReceiptSignature>(confirmationReceiptSignatures2Update.Where(w => w.ConfirmationReceiptSignatureOid.HasValue).Select(confirmationReceiptSignatur => confirmationReceiptSignatur.ConfirmationReceiptSignatureOid.Value));
|
|
|
|
MapperFactory.ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature.MergeWithEntitys(confirmationReceiptSignatures2Update, lOriginals);
|
|
|
|
DAOFactory.GenericDAO.Update(lOriginals);
|
|
|
|
lOriginals = DAOFactory.GenericDAO.LoadByIDs<ConfirmationReceiptSignature>(confirmationReceiptSignatures2Update.Where(w => w.ConfirmationReceiptSignatureOid.HasValue).Select(confirmationReceiptSignatur => confirmationReceiptSignatur.ConfirmationReceiptSignatureOid.Value));
|
|
|
|
return MapperFactory.ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature.MapToNewDCs(lOriginals);
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteConfirmationReceiptSignatures(Dictionary<long, long> oid2Version)
|
|
{
|
|
try
|
|
{
|
|
var originals = DAOFactory.GenericDAO.LoadByIDs<ConfirmationReceiptSignature>(oid2Version.Select(e => e.Key));
|
|
originals.DoForEach(or => MapperFactory.ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature.ConcurrencyCheck(oid2Version[or.Oid.Value], or));
|
|
|
|
DAOFactory.GenericDAO.Delete(originals);
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public bool HasConfirmationReceiptSignaturesByCustomerAndServiceRecords(long customerOid, IEnumerable<long> serviceRecordOids)
|
|
{
|
|
try
|
|
{
|
|
return DAOFactory.SearchDAO.HasConfirmationReceiptSignaturesByCustomerAndServiceRecords(customerOid, serviceRecordOids);
|
|
}
|
|
catch(Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
public List<ConfirmationReceiptSignatureDC> LoadAllConfirmationReceiptSignaturesByServiceRecordOids(IList<long> serviceRecordOids, out Dictionary<SignatureType, List<long>> serviceRecordOidsWithSignature)
|
|
{
|
|
try
|
|
{
|
|
var confirmationReceiptSignatures = DAOFactory.SearchDAO.LoadConfirmationReceiptSignaturesByServiceRecordOids(serviceRecordOids);
|
|
|
|
serviceRecordOidsWithSignature = new Dictionary<SignatureType, List<long>>();
|
|
|
|
foreach(var csr in confirmationReceiptSignatures)
|
|
{
|
|
serviceRecordOidsWithSignature.AddOrUpdateValueInDictionary(csr.SignatureType, csr.ServiceRecords.Where(sr => sr.Oid.HasValue).Select(sr => sr.Oid.Value).ToList());
|
|
}
|
|
|
|
return MapperFactory.ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature.MapToNewDCs(confirmationReceiptSignatures);
|
|
}
|
|
catch(Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
public List<long> LoadServiceRecordOidsWithConfirmationReceiptSignatures(IList<long> serviceRecordOids)
|
|
{
|
|
try
|
|
{
|
|
return DAOFactory.SearchDAO.LoadServiceRecordOidsWithConfirmationReceiptSignatures(serviceRecordOids);
|
|
}
|
|
catch(Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
public List<long> LoadServiceRecordOidsWithCustomerConfirmationReceiptSignatures(IList<long> serviceRecordOids, SignatureType signatureType)
|
|
{
|
|
try
|
|
{
|
|
return DAOFactory.SearchDAO.LoadServiceRecordOidsWithConfirmationReceiptSignatures(serviceRecordOids, signatureType);
|
|
}
|
|
catch(Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
public List<ServiceRecordDC> GetServiceRecordsWithoutConfirmationReceiptSignature(IList<long> serviceRecordOids, SignatureType signatureType)
|
|
{
|
|
try
|
|
{
|
|
return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(DAOFactory.SearchDAO.GetServiceRecordsWithoutConfirmationReceiptSignature(serviceRecordOids, signatureType));
|
|
}
|
|
catch(Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
// ToDo: Hier wie beim Löschen der ServiceRecord-Unterschriften die Zeiten prüfen!
|
|
private static void RemoveServiceRecordsFromConfirmationReceiptSignatures(List<ServiceRecordDC> serviceRecordsToUpdate, List<ServiceRecord> oldServiceRecords, bool isDeleting)
|
|
{
|
|
var serviceRecordOids = new List<long>();
|
|
var oldVsNew = new Dictionary<ServiceRecord, ServiceRecordDC>();
|
|
var orderedOldOnes = oldServiceRecords.Where(x => x.Oid.HasValue).OrderBy(x => x.Oid.Value).ToList();
|
|
var orderedNewOnes = serviceRecordsToUpdate.Where(x => x.ServiceRecordOid.HasValue).OrderBy(x => x.ServiceRecordOid.Value).ToList();
|
|
|
|
foreach(var oldSr in orderedOldOnes)
|
|
{
|
|
var newSr = orderedNewOnes.FirstOrDefault(f => f.ServiceRecordOid == oldSr.Oid);
|
|
|
|
if(newSr != null)
|
|
{
|
|
oldVsNew.Add(oldSr, newSr);
|
|
}
|
|
}
|
|
|
|
foreach(var kvp in oldVsNew)
|
|
{
|
|
if(kvp.Key.Start != kvp.Value.Start || kvp.Key.End != kvp.Value.End || isDeleting)
|
|
{
|
|
serviceRecordOids.AddIfNotIn(kvp.Value.ServiceRecordOid.Value);
|
|
}
|
|
}
|
|
|
|
var confirmationReceiptSignatures = DAOFactory.SearchDAO.LoadConfirmationReceiptSignaturesByServiceRecordOids(serviceRecordOids);
|
|
|
|
var confirmationReceiptSignatures2Delete = new List<ConfirmationReceiptSignature>();
|
|
var confirmationReceiptSignatures2Update = new List<ConfirmationReceiptSignature>();
|
|
|
|
foreach(var signature in confirmationReceiptSignatures)
|
|
{
|
|
var signatures2Keep = signature.ServiceRecords.Where(sr => sr.Oid.HasValue && !serviceRecordOids.Contains(sr.Oid.Value)).ToList();
|
|
|
|
if(signatures2Keep.Count == 0)
|
|
{
|
|
confirmationReceiptSignatures2Delete.AddIfNotIn(signature);
|
|
continue;
|
|
}
|
|
|
|
signature.ServiceRecords.Clear();
|
|
signature.ServiceRecords = signatures2Keep;
|
|
|
|
confirmationReceiptSignatures2Update.AddIfNotIn(signature);
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Update(confirmationReceiptSignatures2Update);
|
|
DAOFactory.GenericDAO.Delete(confirmationReceiptSignatures2Delete);
|
|
}
|
|
|
|
public List<RatingTypeDC> GetRatingTypesByOids(List<long> ratingTypeOids)
|
|
{
|
|
try
|
|
{
|
|
var ratingTypes = DAOFactory.GenericDAO.LoadByIDs<RatingType>(ratingTypeOids);
|
|
|
|
return MapperFactory.RatingTypeDC_RatingType.MapToNewDCs(ratingTypes);
|
|
}
|
|
catch(Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
public UrlaubsplanerRootDC BuildUrlaubsplanerRootObject(AbsenceOverviewFilterDC filter)
|
|
{
|
|
UrlaubsplanerRootDC root = new UrlaubsplanerRootDC();
|
|
var empService = new EmployeeServiceImp();
|
|
|
|
root.Feiertage = GetDefaultFeiertageForYear(filter.Year).Where(f => f.Datum.Month == filter.Month).ToList();
|
|
root.Abwesenheiten = empService.GetAllEmployeeAbsenceTimesForMonth(filter.Year, filter.Month);
|
|
root.GeschenkteUrlaubstage = empService.GetGeschenkteUrlaubstageForYear(filter.Year);
|
|
|
|
var DCsToDelete = empService.GetAllAbwesenheitsInformationPrints();
|
|
empService.DeleteAbwesenheitsInformationPrints(DCsToDelete);
|
|
|
|
//root.AlleAbwesenheitsInformationDCs = new List<AbwesenheitsInformationDC>();
|
|
|
|
//var employee = GetAbsenceOverview(filter);
|
|
|
|
//foreach (var emp in employee)
|
|
//{
|
|
// root.AlleAbwesenheitsInformationDCs.Add(new AbwesenheitsInformationDC()
|
|
// {
|
|
// Employee = emp,
|
|
// Month = filter.Month,
|
|
// Year = filter.Year,
|
|
// AbsenceTimes = root.Abwesenheiten.Where(a => a.EmployeeOid == emp.EmployeeOid).ToList(),
|
|
// GeschenkteUrlaubstage = root.GeschenkteUrlaubstage.Where(u => u.Employee == emp.EmployeeOid).ToList()
|
|
// });
|
|
//}
|
|
|
|
return root;
|
|
}
|
|
|
|
public string GetInformationStringForUrlaubsplaner(UrlaubskontoDC dc, decimal tageUrlaub, decimal tageKrank, bool urlaubVerfallen)
|
|
{
|
|
try
|
|
{
|
|
return XAMLInformation.InfoViaXAMLManager.GetXAMLInformationStringForUrlaubsplaner(dc, tageUrlaub, tageKrank, urlaubVerfallen);
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
private static void DeleteSignaturesFromServiceRecords(IEnumerable<ServiceRecordDC> serviceRecords, IEnumerable<ServiceRecord> originals)
|
|
{
|
|
var oldVsNew = new Dictionary<ServiceRecord, ServiceRecordDC>();
|
|
var orderedOldOnes = originals.Where(x => x.Oid.HasValue).OrderBy(x => x.Oid.Value).ToList();
|
|
var orderedNewOnes = serviceRecords.Where(x => x.ServiceRecordOid.HasValue).OrderBy(x => x.ServiceRecordOid.Value).ToList();
|
|
|
|
foreach (var oldSr in orderedOldOnes)
|
|
{
|
|
var newSr = orderedNewOnes.FirstOrDefault(f => f.ServiceRecordOid == oldSr.Oid);
|
|
|
|
if (newSr != null)
|
|
{
|
|
oldVsNew.Add(oldSr, newSr);
|
|
}
|
|
}
|
|
|
|
var signatureOids = new List<long>();
|
|
foreach (var kvp in oldVsNew)
|
|
{
|
|
if ((kvp.Key.Start != kvp.Value.Start || kvp.Key.End != kvp.Value.End) && kvp.Key.SignatureOid.HasValue)
|
|
{
|
|
signatureOids.AddIfNotIn(kvp.Key.SignatureOid.Value);
|
|
kvp.Value.SignatureOid = null;
|
|
}
|
|
}
|
|
|
|
if(signatureOids.Any())
|
|
{
|
|
var signatures2Delete = DAOFactory.GenericDAO.LoadByIDs<Signature>(signatureOids);
|
|
|
|
DAOFactory.GenericDAO.Delete(signatures2Delete);
|
|
}
|
|
}
|
|
|
|
public List<DienstZeileDC> InitDienstzeilen(DienstBlockDC block, List<DienstInfoDC> dienste, DateTime date, int? standardanzahlZeilen)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.Init(block, dienste, date, standardanzahlZeilen);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public List<DienstZeileDC> InitDienstzeilenNachSortieren(List<DienstBlockDC> bloecke, List<DienstInfoDC> dienste, DateTime date, int? standardanzahlZeilen)
|
|
{
|
|
try
|
|
{
|
|
return DienstplanungsManager.InitNachSortieren(bloecke, dienste, date, standardanzahlZeilen);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
public DienstplanerMonthlySummaryDC BerechneSollSaldoUndIstFuerEinzelnenMitarbeiter(DateTime date, long empOid, List<DienstEintragDC> dienstEintraege, List<DienstvertretungDC> dienstvertretungen,
|
|
List<AbsenceTimeDC> absenceTimes, List<OvertimeDC> overtimes, out long stundenBeiAbwesenheitKey, out decimal stundenBeiAbwesenheitValue)
|
|
{
|
|
return DienstplanungsManager.BerechneSollSaldoUndIstFuerEinzelnenMitarbeiter(date, empOid, dienstEintraege, dienstvertretungen, absenceTimes, overtimes, out stundenBeiAbwesenheitKey, out stundenBeiAbwesenheitValue);
|
|
}
|
|
|
|
|
|
public void SaveAllFilesToDisk()
|
|
{
|
|
var oid = DAOFactory.SearchDAO.GetMaxOidFromFileAttachment();
|
|
|
|
for (int i = 1; i <= oid; i++)
|
|
{
|
|
var file = DAOFactory.GenericDAO.LoadByID<FileAttachment>(i);
|
|
|
|
try
|
|
{
|
|
//prüfe ob Datei existiert, sonst kommt ein Hibernate Fehler
|
|
|
|
if (file.Data?.Length > 0)
|
|
{
|
|
FileAttachmentUtils.SaveFileToFileDirectory(file);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
public List<ServiceRecordDC> GetCustomerServiceRecordsWithStartEndDate(long pCustomerOid, long costbearer2SupportConceptOid, DateTime start, DateTime ende)
|
|
{
|
|
try
|
|
{
|
|
var serviceRecords = DAOFactory.SearchDAO.FindServiceRecordsDetailsForLastDaysWithStartEndDate(costbearer2SupportConceptOid, start, ende);
|
|
var distinctServiceRecords = serviceRecords.Distinct();
|
|
|
|
return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(distinctServiceRecords);
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<ConfirmationReceiptSignatureDC> GetConfirmationReceiptSignatures(List<long> oids)
|
|
{
|
|
try
|
|
{
|
|
var signatures = DAOFactory.GenericDAO.GetActiveByIDs<ConfirmationReceiptSignature>(oids);
|
|
|
|
return MapperFactory.ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature.MapToNewDCs(signatures);
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public SchedulerAppointmentDC GetRootAppointment(string recurrenceId)
|
|
{
|
|
try
|
|
{
|
|
if(Guid.TryParse(recurrenceId, out var guid))
|
|
{
|
|
var rootAppointment = DAOFactory.SearchDAO.FindRootAppointmentByRecurrenceId(recurrenceId);
|
|
|
|
return MapperFactory.SchedulerAppointmentDCSchedulerAppointment.MapToNewDC(rootAppointment);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public Dictionary<string, string> GetDiagiosisStringsForICD10Codes(List<string> icd10Codes)
|
|
{
|
|
try
|
|
{
|
|
var result = new Dictionary<string, string>();
|
|
|
|
foreach(var code in icd10Codes)
|
|
{
|
|
result.AddIfNotIn(new KeyValuePair<string, string>(code, ICD10DAO.GetDiagnosisForCode(code)));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteSignature(long signatureOid, long serviceRecordOid)
|
|
{
|
|
try
|
|
{
|
|
var serviceRecord = DAOFactory.GenericDAO.LoadByID<ServiceRecord>(serviceRecordOid);
|
|
|
|
var signature = DAOFactory.GenericDAO.LoadByID<Signature>(signatureOid);
|
|
|
|
if(signature?.Oid is null || serviceRecord?.SignatureOid is null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if(!serviceRecord.SignatureOid.Value.Equals(signature.Oid.Value))
|
|
{
|
|
return;
|
|
}
|
|
|
|
MapperFactory.SignatureDC_Signature.ConcurrencyCheck(signature.Version, signature);
|
|
|
|
DAOFactory.GenericDAO.Delete(signature);
|
|
|
|
var customerSignature = DAOFactory.SearchDAO.GetConfirmationReceiptSignatureForServiceRecords(new List<long> { serviceRecordOid }, SignatureType.Customer);
|
|
var employeeSignature = DAOFactory.SearchDAO.GetConfirmationReceiptSignatureForServiceRecords(new List<long> { serviceRecordOid }, SignatureType.Employee);
|
|
|
|
serviceRecord.SignatureOid = null;
|
|
DAOFactory.GenericDAO.Update(serviceRecord);
|
|
|
|
if(customerSignature?.ServiceRecords.Any(sr => sr.Oid.HasValue && sr.Oid.Value.Equals(serviceRecordOid)) ?? false)
|
|
{
|
|
customerSignature.ServiceRecords = customerSignature.ServiceRecords.Where(sr => sr.Oid.HasValue && !sr.Oid.Value.Equals(serviceRecordOid)).ToList();
|
|
|
|
DAOFactory.GenericDAO.Update(customerSignature);
|
|
}
|
|
|
|
if(!(employeeSignature?.ServiceRecords.Any(sr => sr.Oid.HasValue && sr.Oid.Value.Equals(serviceRecordOid)) ?? false))
|
|
{
|
|
return;
|
|
}
|
|
|
|
employeeSignature.ServiceRecords = employeeSignature.ServiceRecords.Where(sr => sr.Oid.HasValue && !sr.Oid.Value.Equals(serviceRecordOid)).ToList();
|
|
|
|
DAOFactory.GenericDAO.Update(employeeSignature);
|
|
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
}
|
|
}
|