Die Abfrage nach der Ressourcenbelegung kommt nur ein mal und das Abbrechen des Speicherns hat keinen "kaputten" Reload zur Folge
Das Löschen eines Serientermins mit veränderten oder gelöschten Elementen führt zu keiner Exception mehr, da ich den Service-Aufruf auf synchron geändert habe.
Es gibt allerdings noch Bugs! -> Serientermin erstellen und ein Element davon ändern führt zu einer doppelten Abfrage, ausgelöst durch die Überlappungsprüfung, die eine Überlappung mit der Serie selbst feststellt!
6568 lines
258 KiB
C#
6568 lines
258 KiB
C#
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 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.Invoicing;
|
|
using BeWo.Service.OwnChat;
|
|
using BeWo.Service.Plugins;
|
|
using BeWo.Service.SBD;
|
|
using BeWo.Service.Security;
|
|
using BeWo.Service.ServiceContracts;
|
|
|
|
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 Utils = BeWo.Service.Core.Utils;
|
|
|
|
namespace BeWo.Service.ServiceImplementations
|
|
{
|
|
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
|
|
public class OperationsServiceImp : IOperationsService
|
|
{
|
|
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
|
|
{
|
|
List<FileAttachment> lOriginals = DAOFactory.GenericDAO.LoadByIDs<FileAttachment>(pOid2Version.Select(e => e.Key));
|
|
lOriginals.DoForEach(or => MapperFactory.FileAttachmentDC_FileAttachment.ConcurrencyCheck(pOid2Version[or.Oid.Value], or));
|
|
|
|
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)
|
|
{
|
|
MakeServiceRecordHistoryEntry(item.Group.ServiceRecordList, null, StatementType.Delete);
|
|
|
|
DAOFactory.GenericDAO.Delete(item.Group);
|
|
}
|
|
else
|
|
{
|
|
srListToDelete.Add(item);
|
|
}
|
|
}
|
|
|
|
if (srListToDelete.Count > 0)
|
|
{
|
|
MakeServiceRecordHistoryEntry(srListToDelete, null, StatementType.Delete);
|
|
|
|
// ConfirmationReceiptSignatures mit den zu löschenden ServiceRecords suchen und die ServiceRecords aus der Liste entfernen
|
|
foreach(var item in lOriginals)
|
|
{
|
|
if(item.Oid.HasValue)
|
|
{
|
|
var confirmationReceiptSignatures = DAOFactory.SearchDAO.GetConfirmationReceiptSignaturesByServiceRecord(item.Oid.Value);
|
|
|
|
foreach(var confirmationReceiptSignature in confirmationReceiptSignatures)
|
|
{
|
|
confirmationReceiptSignature.ServiceRecords.Remove(item);
|
|
DAOFactory.GenericDAO.Update(confirmationReceiptSignature);
|
|
}
|
|
}
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Delete(srListToDelete);
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
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
|
|
{
|
|
IEnumerable<FileAttachmentInfo> files = DAOFactory.SearchDAO.FindFileAttachmentInfos(pObjectTid, pObjectOid);
|
|
|
|
return files.Select(item => MapperFactory.FileAttachmentDC_FileAttachmentInfo.MapToNewDC(item)).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<BeWoFolderDC> GetFolderTree(TableID pObjectTid, long pObjectOid)
|
|
{
|
|
try
|
|
{
|
|
IList<BeWoFolder> folder = DAOFactory.SearchDAO.FindBeWoFolders(pObjectTid, pObjectOid);
|
|
bool templateFolder = folder.Any(f => f.SystemEntryID.Equals(SystemEntryID.TemplateDirectory));
|
|
var folderDCList = new List<BeWoFolderDC>();
|
|
|
|
foreach (BeWoFolder item in folder)
|
|
{
|
|
folderDCList.Add(MapperFactory.BeWoFolderDC_BeWoFolder.MapToNewDC(item));
|
|
}
|
|
|
|
IEnumerable<FileAttachmentInfo> files = DAOFactory.SearchDAO.FindFileAttachmentInfos(pObjectTid, pObjectOid);
|
|
var fileDCList = new List<FileAttachmentDC>();
|
|
|
|
foreach (FileAttachmentInfo item in files)
|
|
{
|
|
fileDCList.Add(MapperFactory.FileAttachmentDC_FileAttachmentInfo.MapToNewDC(item));
|
|
}
|
|
|
|
Thread.Sleep(500);
|
|
|
|
return CreateFolderTree(folderDCList, fileDCList, pObjectTid, pObjectOid, templateFolder);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteFolder(long pBeWoFolderOid, long pVersion)
|
|
{
|
|
try
|
|
{
|
|
var origFolder = DAOFactory.GenericDAO.LoadByID<BeWoFolder>(pBeWoFolderOid);
|
|
MapperFactory.BeWoFolderDC_BeWoFolder.ConcurrencyCheck(pVersion, origFolder);
|
|
|
|
DAOFactory.GenericDAO.Delete(origFolder);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public long InsertNewFolder(BeWoFolderDC folder)
|
|
{
|
|
try
|
|
{
|
|
BeWoFolder newFolder = MapperFactory.BeWoFolderDC_BeWoFolder.MapToNewEntity(folder);
|
|
|
|
DAOFactory.GenericDAO.Insert(newFolder);
|
|
|
|
BeWoFolderDC newFolderDC = MapperFactory.BeWoFolderDC_BeWoFolder.MapToNewDC(newFolder);
|
|
return newFolderDC.BeWoFolderOid.Value;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public BeWoFolderDC UpdateFolder(BeWoFolderDC folder)
|
|
{
|
|
try
|
|
{
|
|
//Root Folder kann nicht umbenannt werden
|
|
var origFolder = DAOFactory.GenericDAO.LoadByID<BeWoFolder>(folder.BeWoFolderOid.Value);
|
|
|
|
MapperFactory.BeWoFolderDC_BeWoFolder.MergeWithEntity(folder, origFolder);
|
|
|
|
|
|
DAOFactory.GenericDAO.Update(origFolder);
|
|
|
|
BeWoFolderDC updatedFolderDC = MapperFactory.BeWoFolderDC_BeWoFolder.MapToNewDC(origFolder);
|
|
return updatedFolderDC;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public FileAttachmentDC UpdateFileAttachment(FileAttachmentDC file)
|
|
{
|
|
try
|
|
{
|
|
var origFile = DAOFactory.GenericDAO.LoadByID<FileAttachmentInfo>(file.FileAttachmentOid.Value);
|
|
MapperFactory.FileAttachmentDC_FileAttachmentInfo.MergeWithEntity(file, origFile);
|
|
|
|
DAOFactory.GenericDAO.Update(origFile);
|
|
|
|
FileAttachmentDC updatedFileDC = MapperFactory.FileAttachmentDC_FileAttachmentInfo.MapToNewDC(origFile);
|
|
return updatedFileDC;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public FileAttachmentDC DoTheRealFileUpdate(FileAttachmentDC file)
|
|
{
|
|
try
|
|
{
|
|
var origFile = DAOFactory.GenericDAO.LoadByID<FileAttachment>(file.FileAttachmentOid.Value);
|
|
if (!origFile.Data.Equals(file.BinaryData))
|
|
{
|
|
}
|
|
|
|
MapperFactory.FileAttachmentDC_FileAttachment.MergeWithEntity(file, origFile);
|
|
|
|
DAOFactory.GenericDAO.Update(origFile);
|
|
|
|
FileAttachmentDC updatedFileDC = MapperFactory.FileAttachmentDC_FileAttachment.MapToNewDC(origFile);
|
|
return updatedFileDC;
|
|
}
|
|
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");
|
|
}
|
|
}
|
|
|
|
|
|
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);
|
|
|
|
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;
|
|
|
|
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.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);
|
|
}
|
|
}
|
|
|
|
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;
|
|
|
|
//Start und Ende korrigieren
|
|
|
|
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;
|
|
}
|
|
|
|
|
|
MapperFactory.ServiceRecordGroupDC_ServiceRecordGroup.MergeWithEntity(pServiceRecordGroup, lOriginal);
|
|
|
|
var lServiceRecords = new List<ServiceRecord>();
|
|
|
|
// update servicerecords
|
|
MapperFactory.ServiceRecordDC_ServiceRecord.MergeWithEntitys(pServiceRecordGroup.ServiceRecordList, lOriginal.ServiceRecordList);
|
|
foreach (ServiceRecord iServiceRecord in lOriginal.ServiceRecordList)
|
|
{
|
|
if (String.IsNullOrEmpty(iServiceRecord.IP))
|
|
iServiceRecord.IP = Utils.GetClientIP();
|
|
|
|
iServiceRecord.GroupOid = lOriginal.Oid;
|
|
lServiceRecords.Add(iServiceRecord);
|
|
}
|
|
|
|
var gdc = PluginLoader.FindClass<GroupDurationCalculator>();
|
|
|
|
if (gdc != null)
|
|
{
|
|
gdc.CalculateGroupDuration(lOriginal);
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Update(lOriginal);
|
|
MakeServiceRecordHistoryEntry(lServiceRecords, null, StatementType.Update);
|
|
|
|
|
|
ServiceRecordGroupDC 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
|
|
{
|
|
List<ServiceRecord> lOriginals =
|
|
DAOFactory.GenericDAO.LoadByIDs<ServiceRecord>(
|
|
pServiceRecords.Select(sr => sr.ServiceRecordOid.Value));
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
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
|
|
{
|
|
List<AdditionalServiceBookingDC> result =
|
|
MapperFactory.AdditionalServiceBookingDC_AdditionalServiceBooking.MapToNewDCs(
|
|
DAOFactory.SearchDAO.GetAdditionalServiceBookings(regionOid, start, end)).ToList();
|
|
|
|
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 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 = 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.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;
|
|
}
|
|
|
|
private static List<BeWoFolderDC> CreateFolderTree(List<BeWoFolderDC> folderDCList, List<FileAttachmentDC> fileDCList, TableID pObjectTid, long pObjectOid, bool templateFolder = false)
|
|
{
|
|
Dictionary<long, BeWoFolderDC> folderDict = folderDCList.ToDictionary(fo => fo.BeWoFolderOid.Value);
|
|
Dictionary<long, FileAttachmentDC> fileDict = fileDCList.ToDictionary(fi => fi.FileAttachmentOid.Value);
|
|
|
|
var resultList = new List<BeWoFolderDC>();
|
|
|
|
var root = new BeWoFolderDC
|
|
{
|
|
ObjectTid = pObjectTid,
|
|
ObjectOid = pObjectOid,
|
|
Name = "Alle Ordner",
|
|
SubFolders = new List<BeWoFolderDC>(),
|
|
Files = new List<FileAttachmentDC>()
|
|
};
|
|
|
|
if (templateFolder)
|
|
root = folderDCList.First(f => f.Name.Equals("Vorlagen"));
|
|
|
|
resultList.Add(root);
|
|
|
|
foreach (BeWoFolderDC cfo in folderDCList)
|
|
{
|
|
if (root.Equals(cfo))
|
|
continue;
|
|
|
|
if (cfo.ParentBeWoFolderOid.HasValue)
|
|
{
|
|
if (folderDict.ContainsKey(cfo.ParentBeWoFolderOid.Value))
|
|
{
|
|
BeWoFolderDC parent = folderDict[cfo.ParentBeWoFolderOid.Value];
|
|
parent.SubFolders.Add(cfo);
|
|
}
|
|
else
|
|
{
|
|
root.SubFolders.Add(cfo);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
root.SubFolders.Add(cfo);
|
|
}
|
|
}
|
|
|
|
foreach (FileAttachmentDC fi in fileDCList)
|
|
{
|
|
if (fi.BeWoFolderOid.HasValue)
|
|
{
|
|
if (folderDict.ContainsKey(fi.BeWoFolderOid.Value))
|
|
{
|
|
BeWoFolderDC parent = folderDict[fi.BeWoFolderOid.Value];
|
|
parent.Files.Add(fi);
|
|
}
|
|
else
|
|
{
|
|
root.Files.Add(fi);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
root.Files.Add(fi);
|
|
}
|
|
}
|
|
|
|
return resultList;
|
|
}
|
|
|
|
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()
|
|
{
|
|
//#if DEBUG
|
|
|
|
// info.MaxLicenseCount = 9999;
|
|
// info.PercentFreeEmployee = 100;
|
|
|
|
// info.LicenseInUseCount = DAOFactory.GenericDAO.GetAllActive<ApplicationUser>().Count;
|
|
// info.EmployeeCount = DAOFactory.GenericDAO.GetAllActive<Employee>().Count;
|
|
|
|
// info.MaxEmployeeCount = (int)Math.Ceiling(1000000 * ((100 + 100m) / 100));
|
|
// return info;
|
|
//#endif
|
|
try
|
|
{
|
|
string url = ConfigurationManager.AppSettings.Get("ContractStateUrl");
|
|
if (MultitenancyOperationContextExt.Current != null)
|
|
{
|
|
url = url.Replace("[TENANT]", MultitenancyOperationContextExt.Current.Tenant);
|
|
}
|
|
else
|
|
{
|
|
url = url.Replace("[TENANT]", SessionFacade.Tenant);
|
|
}
|
|
|
|
url += "&t=1";
|
|
|
|
using (var client = new WebClient())
|
|
{
|
|
//MessageBox.Show(hostAddress);
|
|
byte[] response = client.DownloadData(url);
|
|
|
|
return Encoding.ASCII.GetString(response);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
}
|
|
|
|
return String.Empty;
|
|
}
|
|
|
|
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
|
|
{
|
|
return MapperFactory.TextModuleDC_TextModule.MapToNewDCs(DAOFactory.GenericDAO.GetAll<TextModule>());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public IList<TextModuleDC> GetTextModules(bool pShouldShowAllTextModules, long pEmployeeOid, bool pHasRightToSeeAllTextModules, bool pIsInAdministrationView)
|
|
{
|
|
try
|
|
{
|
|
var list = MapperFactory.TextModuleDC_TextModule.MapToNewDCs(DAOFactory.SearchDAO.GetActiveTextModules(pShouldShowAllTextModules, pHasRightToSeeAllTextModules, pIsInAdministrationView, pEmployeeOid));
|
|
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
|
|
{
|
|
pTextbausteine.DoForEach(tb => tb.ActivationType = ActivationTypeId.Active);
|
|
|
|
var lTextbausteine = MapperFactory.TextModuleDC_TextModule.MapToNewEntities(pTextbausteine);
|
|
|
|
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));
|
|
|
|
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);
|
|
SignatureDC updatedSignatureDC = MapperFactory.SignatureDC_Signature.MapToNewDC(lSignature);
|
|
|
|
if (s.ServiceRecordOid.HasValue)
|
|
{
|
|
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.Count > 0)
|
|
{
|
|
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";
|
|
#endif
|
|
|
|
var serverUrl = 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 = 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 e)
|
|
{
|
|
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 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<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);
|
|
|
|
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 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();
|
|
|
|
string serverUrl = OwnChatHelper.ErmittleServerURL(customerId);
|
|
|
|
if (serverUrl == null)
|
|
{
|
|
handout.Result = 11;
|
|
|
|
return handout;
|
|
}
|
|
else if (serverUrl.Equals(""))
|
|
{
|
|
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
|
|
|
|
|
|
//############################
|
|
Dictionary<string, string> postparameter = new Dictionary<string, string>();
|
|
|
|
postparameter.Add("username", "HAns");
|
|
postparameter.Add("password", "Dito");
|
|
|
|
//neu | hinzufügen laut document
|
|
postparameter.Add("chatcode", "yyAbrams");
|
|
|
|
string postdaten = "";
|
|
int i = 0;
|
|
foreach (var key in postparameter.Keys)
|
|
{
|
|
//hier noch chatcode übergeben
|
|
postdaten += HttpUtility.UrlEncode(key) + "=" + HttpUtility.UrlEncode(postparameter[key]) + "&";
|
|
|
|
}
|
|
|
|
WebRequest requesten = WebRequest.Create(endurl);
|
|
|
|
requesten.Method = "POST";
|
|
requesten.ContentType = "application/x-www-form-urlencoded";
|
|
|
|
byte[] daten = Encoding.ASCII.GetBytes(postdaten);
|
|
|
|
requesten.ContentLength = daten.Length;
|
|
|
|
try
|
|
{
|
|
Stream requestStream = requesten.GetRequestStream();
|
|
|
|
requestStream.Write(daten, 0, daten.Length);
|
|
|
|
requestStream.Close();
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
MessageBox.Show("Es konnte keine Verbindung aufgebaut werden.", "Fehler", MessageBoxButton.OK);
|
|
|
|
}
|
|
|
|
//response bereich | Verarbeiten
|
|
HttpWebResponse 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 (Stream stream = response.GetResponseStream())
|
|
{
|
|
byte[] buffer = new byte[stream.Length];
|
|
stream.Read(buffer, 0, buffer.Length);
|
|
File.WriteAllBytes("foo.pdf", buffer);
|
|
}
|
|
|
|
string responseFromServer = ReadStreamForChatCode(response);
|
|
|
|
if (responseFromServer.Contains("PDF"))
|
|
{
|
|
PdfChatHandoutDC hd = new PdfChatHandoutDC();
|
|
hd.File = responseFromServer;
|
|
hd.Result = 0;
|
|
//hd.TestStream = dataStream;
|
|
|
|
return hd;
|
|
}
|
|
else
|
|
{
|
|
var jsonDatentyp = JsonConvert.DeserializeObject<PdfChatHandoutDC>(responseFromServer);
|
|
|
|
return jsonDatentyp;
|
|
}
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
//throw Utils.CreateBeWoFaultException(e);
|
|
var handout = new PdfChatHandoutDC();
|
|
handout.Result = 60;
|
|
handout.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.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);
|
|
|
|
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
|
|
{
|
|
|
|
}
|
|
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);
|
|
|
|
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 FlexibleReportResultDC GetFlexibleReportResult(FlexibleReportFilterDC filter)
|
|
{
|
|
try
|
|
{
|
|
var s = PluginLoader.FindClass<FlexibleReportService>();
|
|
|
|
return s.GetAllFlexibleReportEntrys(filter);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public IList<FlexibleReportLayoutDC> GetFlexibleReportLayouts()
|
|
{
|
|
var result = new List<FlexibleReportLayoutDC>();
|
|
|
|
foreach (var item in DAOFactory.GenericDAO.GetAllActive<FlexibleReportLayout>().Where(x => x.CreatorOid == LoggedInUserOperationContextExt.Current.User.Oid.Value))
|
|
{
|
|
result.Add(MapperFactory.FlexibleReportLayoutDC_FlexibleReportLayout.MapToNewDC(item));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
public void InsertNewFlexibleReportLayout(FlexibleReportLayoutDC flexibleReportLayoutDC)
|
|
{
|
|
try
|
|
{
|
|
var flexibleReportLayout = MapperFactory.FlexibleReportLayoutDC_FlexibleReportLayout.MapToNewEntity(flexibleReportLayoutDC);
|
|
flexibleReportLayout.CreatorOid = LoggedInUserOperationContextExt.Current.User.Oid.Value;
|
|
DAOFactory.GenericDAO.Insert(flexibleReportLayout);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateFlexibleReportLayouts(IList<FlexibleReportLayoutDC> flexibleReportLayouts)
|
|
{
|
|
try
|
|
{
|
|
//Enity
|
|
var flexOriList = DAOFactory.GenericDAO.GetAllActive<FlexibleReportLayout>().Where(x => x.CreatorOid == LoggedInUserOperationContextExt.Current.User.Oid.Value);
|
|
//DC
|
|
var flexNewList = flexibleReportLayouts;
|
|
|
|
var toUpdate = new List<FlexibleReportLayout>();
|
|
var toDelete = new List<FlexibleReportLayout>();
|
|
|
|
foreach (var flexOri in flexOriList)
|
|
{
|
|
bool gefunden = false;
|
|
|
|
foreach (var flexNew in flexNewList)
|
|
{
|
|
if (flexOri.Oid == flexNew.FlexibleReportOid)
|
|
{
|
|
gefunden = true;
|
|
|
|
if (flexOri.LayoutName != flexNew.LayoutName)
|
|
{
|
|
flexOri.LayoutName = flexNew.LayoutName;
|
|
DAOFactory.GenericDAO.Update(flexOri);
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!gefunden)
|
|
DAOFactory.GenericDAO.Deactivate(flexOri);
|
|
}
|
|
}
|
|
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
|
|
{
|
|
return MapperFactory.HomeViewPanelDC_HomeViewPanel.MapToNewDCs(
|
|
DAOFactory.GenericDAO.GetAllActive<HomeViewPanel>());
|
|
}
|
|
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
|
|
{
|
|
//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
|
|
//}));
|
|
return ICFDAO.GetIcf();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public IList<ReportTemplateDC> GetReportTemplates(string url)
|
|
{
|
|
try
|
|
{
|
|
if (url.IsNullOrEmpty())
|
|
return null;
|
|
|
|
var index = url.IndexOf("type=") + 5;
|
|
var typeString = url.Substring(index);
|
|
|
|
if (!Enum.TryParse(typeString, out ReportTypes reportType))
|
|
return null;
|
|
|
|
return MapperFactory.ReportTemplateDC_ReportTemplate.MapToNewDCs(DAOFactory.GenericDAO
|
|
.GetAllActive<ReportTemplate>().Where(x => x.ReportTemplateType == reportType));
|
|
}
|
|
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()
|
|
{
|
|
try
|
|
{
|
|
var temp = DAOFactory.GenericDAO.GetAllActive<DienstInfo>();
|
|
return MapperFactory.DienstInfoDC_DienstInfo.MapToNewDCs(temp);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void InsertNewDienst(List<DienstInfoDC> dienst)
|
|
{
|
|
try
|
|
{
|
|
var temp = MapperFactory.DienstInfoDC_DienstInfo.MapToNewEntities(dienst);
|
|
DAOFactory.GenericDAO.Insert(temp);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeactivateDienst(Dictionary<long, long> pOid2Version)
|
|
{
|
|
try
|
|
{
|
|
ServiceLogic.SetActivationType<DienstInfo>(pOid2Version, ActivationTypeId.Deleted);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateDienst(List<DienstInfoDC> dienste)
|
|
{
|
|
try
|
|
{
|
|
var temp = DAOFactory.GenericDAO.LoadByIDs<DienstInfo>(dienste.Select(sc => sc.Oid.Value));
|
|
|
|
MapperFactory.DienstInfoDC_DienstInfo.MergeWithEntitys(dienste, temp);
|
|
|
|
DAOFactory.GenericDAO.Update(temp);
|
|
}
|
|
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>();
|
|
|
|
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)
|
|
{
|
|
if (ve.RatingTypeOid.HasValue)
|
|
{
|
|
var ratingtype = allRatingTypes.FirstOrDefault(r => r.RatingTypeOid.HasValue && r.RatingTypeOid == ve.RatingTypeOid);
|
|
|
|
if (ratingtype != null)
|
|
{
|
|
var gr = new GoalRatingDC();
|
|
gr.GoalEntry = ve;
|
|
gr.ServiceRecord = dc;
|
|
gr.RatingType = ratingtype;
|
|
|
|
|
|
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];
|
|
}
|
|
}
|
|
|
|
|
|
result.Add(gr);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
return result;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<DienstBlockDC> GetDienstEintraege(long wOid, int year, int month)
|
|
{
|
|
try
|
|
{
|
|
var res = new List<DienstBlockDC>();
|
|
var date = new DateTime(year, month, 1);
|
|
var date2 = date.AddMonths(1).AddTicks(-1);
|
|
|
|
var dienstEintraege = DAOFactory.GenericDAO.GetAllActive<DienstEintrag>().Where(x =>
|
|
x.WohnheimOid == wOid &&
|
|
x.Datum.Month == month &&
|
|
x.Datum.Year == year);
|
|
|
|
var dienstEintraegeDC = MapperFactory.DienstEintragDC_DienstEintrag.MapToNewDCs(dienstEintraege);
|
|
|
|
var wh = DAOFactory.GenericDAO.GetByID<Wohnheim>(wOid);
|
|
var whDC = MapperFactory.CompactWohnheimDC_Wohnheim.MapToNewDC(wh);
|
|
|
|
//var empOids = new HashSet<long>(dienstEintraege.Select(x => x.EmployeeOid)).ToList();
|
|
//var emps = DAOFactory.GenericDAO.GetActiveByIDs<Employee>(wh);
|
|
//var empsDC = MapperFactory.EmployeeDC_Employee.MapToNewDCs(emps);
|
|
|
|
var emps = wh.Employee2WohnheimList.Select(x => x.Employee);
|
|
var empsDC = MapperFactory.EmployeeDC_Employee.MapToNewDCs(emps).Distinct();
|
|
|
|
foreach (var emp in empsDC)
|
|
{
|
|
var contracts = emp.Contracts.Where(x => (!x.EntryDate.HasValue || x.EntryDate.Value <= date2) &&
|
|
(!x.ContractEndDate.HasValue || x.ContractEndDate.Value >= date))
|
|
.OrderBy(x => x.EntryDate)
|
|
.ToList();
|
|
|
|
if (!contracts.Any())
|
|
continue;
|
|
|
|
var zeile = new DienstBlockDC
|
|
{
|
|
Employee = emp,
|
|
Contracts = contracts,
|
|
Wohnheim = whDC,
|
|
DienstDictArray = new Dictionary<int, long>[3]
|
|
};
|
|
|
|
for (int i = 0; i < zeile.DienstDictArray.Length; i++)
|
|
{
|
|
var empDienste = dienstEintraegeDC
|
|
.Where(x => x.EmployeeOid == emp.EmployeeOid && x.Zeile == i);
|
|
|
|
zeile.DienstDictArray[i] = empDienste
|
|
.ToDictionary(x => x.Datum.Day, x => x.DienstOid);
|
|
}
|
|
|
|
res.Add(zeile);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void InsertNewDienstEintrag(DienstEintragDC dienstEintrag)
|
|
{
|
|
try
|
|
{
|
|
DAOFactory.GenericDAO.Insert(MapperFactory.DienstEintragDC_DienstEintrag.MapToNewEntity(dienstEintrag));
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateDienstEintrag(DienstEintragDC dienstEintrag)
|
|
{
|
|
try
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void DeleteDienstEintrag(long empId, long wohnId, int zeile, DateTime date)
|
|
{
|
|
try
|
|
{
|
|
var toDel = DAOFactory.GenericDAO.GetAll<DienstEintrag>()
|
|
.FirstOrDefault(x =>
|
|
x.EmployeeOid == empId &&
|
|
x.WohnheimOid == wohnId &&
|
|
x.Zeile == zeile &&
|
|
x.Datum == date);
|
|
|
|
if (toDel != null)
|
|
DAOFactory.GenericDAO.Delete(toDel);
|
|
}
|
|
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, "NRW");
|
|
|
|
return list;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<AbsenceTimeDC> GetAbsenceTimeVacationByWohnheim(long wohnId, int year, int month)
|
|
{
|
|
try
|
|
{
|
|
var date = new DateTime(year, month, 1);
|
|
var date2 = date.AddMonths(1).AddTicks(-1);
|
|
var wh = DAOFactory.GenericDAO.GetByID<Wohnheim>(wohnId);
|
|
var emps = wh.Employee2WohnheimList.Select(x => x.Employee.Oid);
|
|
|
|
var allAbsences = DAOFactory.GenericDAO.GetAllActive<AbsenceTime>().Where(x =>
|
|
x.EmployeeOid.HasValue);
|
|
|
|
var res = allAbsences.Where(x => emps.Contains(x.EmployeeOid.Value) && x.Start <= date2 && (!x.End.HasValue || x.End.Value >= date));
|
|
|
|
return MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewDCs(res);
|
|
}
|
|
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();
|
|
|
|
foreach (var emp in allEmployees.OrderBy(x => x.Person.LastNameFirstName))
|
|
{
|
|
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));
|
|
|
|
var empDC = MapperFactory.EmployeeDC_Employee.MapToNewDC(emp);
|
|
empDC.Urlaubskonto = dict[filter.Year];
|
|
|
|
res.Add(empDC);
|
|
}
|
|
|
|
return res;
|
|
}
|
|
catch (Exception exception)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(exception);
|
|
}
|
|
}
|
|
|
|
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<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;
|
|
|
|
return "http://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)
|
|
{
|
|
try
|
|
{
|
|
return DAOFactory.SearchDAO.HasConfirmationReceiptSignatureByDateAndCustomer(customerOid, timeSpan);
|
|
}
|
|
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<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);
|
|
}
|
|
}
|
|
}
|
|
}
|