2020-12-15 12:45:07 +01:00
using BeWo.Data ;
2016-06-27 01:45:38 +02:00
using BeWo.Data.Access ;
using BeWo.Data.Entities ;
using BeWo.Data.ICD10 ;
2019-11-14 16:05:43 +01:00
using BeWo.Data.ICF ;
2016-06-27 01:45:38 +02:00
using BeWo.Service.Configuration ;
using BeWo.Service.Core ;
using BeWo.Service.DCEntityMapper ;
2021-02-15 08:04:40 +01:00
using BeWo.Service.Dienstplanung ;
using BeWo.Service.Dokumentverwaltung ;
2016-06-27 01:45:38 +02:00
using BeWo.Service.Invoicing ;
2020-04-08 14:25:01 +02:00
using BeWo.Service.OwnChat ;
2021-02-19 11:04:33 +01:00
using BeWo.Service.PivotTabelle ;
2016-06-27 01:45:38 +02:00
using BeWo.Service.Plugins ;
2018-05-21 16:39:24 +02:00
using BeWo.Service.SBD ;
2016-06-27 01:45:38 +02:00
using BeWo.Service.Security ;
using BeWo.Service.ServiceContracts ;
2021-02-15 08:04:40 +01:00
using BeWo.Service.Vorlagen ;
2016-06-27 01:45:38 +02:00
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 ;
2023-10-17 12:53:39 +02:00
using Dakota.Logic ;
2017-10-06 12:06:34 +02:00
using Newtonsoft.Json ;
2020-04-16 15:57:01 +02:00
using RestSharp ;
2020-12-15 12:45:07 +01:00
using System ;
using System.Collections.Generic ;
using System.Configuration ;
using System.IO ;
using System.Linq ;
using System.Net ;
using System.ServiceModel ;
using System.Text ;
2023-05-02 14:24:26 +02:00
using System.Threading ;
2020-12-15 12:45:07 +01:00
using System.Web ;
using System.Windows ;
2023-11-02 16:25:36 +01:00
using BeWo.Data.Utils ;
2016-06-27 01:45:38 +02:00
using Utils = BeWo . Service . Core . Utils ;
2024-01-08 18:36:29 +01:00
using System.Collections.Specialized ;
2016-06-27 01:45:38 +02:00
namespace BeWo.Service.ServiceImplementations
{
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
public class OperationsServiceImp : IOperationsService
{
2023-05-02 14:24:26 +02:00
private static object _Lock = string . Empty ;
private static Dictionary < string , string > _ContractStates = new Dictionary < string , string > ( ) ;
private static Dictionary < string , DateTime > _ContractStateDate = new Dictionary < string , DateTime > ( ) ;
2016-06-27 01:45:38 +02:00
public Mandator GetMandatorEntity ( )
{
return AppSettings . GetMandatorEntity ( ) ;
}
2020-04-08 14:25:01 +02:00
2016-06-27 01:45:38 +02:00
public void DeactivateInvoices ( List < InvoiceDC > pInvoices )
{
try
{
ServiceLogic . SetActivationType < Invoice > ( pInvoices . ToDictionary ( i = > i . InvoiceOid . Value , i = > i . InvoiceVersion . Value ) , ActivationTypeId . Deleted ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeactivateServiceCategories ( Dictionary < long , long > pOid2Version )
{
try
{
ServiceLogic . SetActivationType < ServiceCategory > ( pOid2Version , ActivationTypeId . Deleted ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeactivateAdditionalServices ( Dictionary < long , long > pOid2Version )
{
try
{
ServiceLogic . SetActivationType < AdditionalService > ( pOid2Version , ActivationTypeId . Deleted ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeactivateServiceCategory ( long pOid , long pVersion )
{
try
{
ServiceLogic . SetActivationType < ServiceCategory > ( new Dictionary < long , long >
{
{
pOid , pVersion
}
} , ActivationTypeId . Deleted ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeactivateServiceDescription ( long pOid , long pVersion )
{
try
{
ServiceLogic . SetActivationType < ServiceDescription > ( new Dictionary < long , long >
{
{
pOid , pVersion
}
} , ActivationTypeId . Deleted ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeactivateServiceDescriptions ( Dictionary < long , long > pOid2Version )
{
try
{
ServiceLogic . SetActivationType < ServiceDescription > ( pOid2Version , ActivationTypeId . Deleted ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeactivateAdditionalServiceRegions ( Dictionary < long , long > pOid2Version )
{
try
{
ServiceLogic . SetActivationType < AdditionalServiceRegion > ( pOid2Version , ActivationTypeId . Deleted ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeleteAccountingTransaction ( long pOid , long pVersion )
{
try
{
DeleteAccountingTransactions ( new Dictionary < long , long >
{
{
pOid , pVersion
}
} ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeleteFileAttachment ( long pOid , long pVersion )
{
try
{
DeleteFileAttachments ( new Dictionary < long , long >
{
{
pOid , pVersion
}
} ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeleteFileAttachments ( Dictionary < long , long > pOid2Version )
{
try
{
2022-12-15 23:16:04 +01:00
ServiceLogic . SetActivationType < FileAttachment > ( pOid2Version , ActivationTypeId . Deleted ) ;
2016-06-27 01:45:38 +02:00
2022-12-15 23:16:04 +01:00
//var lOriginals = DAOFactory.GenericDAO.LoadByIDs<FileAttachment>(pOid2Version.Select(e => e.Key));
//lOriginals.DoForEach(or => MapperFactory.FileAttachmentDC_FileAttachment.ConcurrencyCheck(pOid2Version[or.Oid.Value], or));
2021-03-30 16:35:45 +02:00
2022-12-15 23:16:04 +01:00
//var fileAttachmentOids = new List<long>();
2021-03-30 16:35:45 +02:00
2022-12-15 23:16:04 +01:00
//lOriginals.DoForEach(fileAttachment =>
//{
// if(fileAttachment.Oid.HasValue)
// {
// fileAttachmentOids.AddIfNotIn(fileAttachment.Oid.Value);
// }
//});
2021-03-30 16:35:45 +02:00
2022-12-15 23:16:04 +01:00
//FileAttachmentUtils.DeleteFilesFromFileDirectory(fileAttachmentOids);
//DAOFactory.GenericDAO.Delete(lOriginals);
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeleteServiceCategory ( long pOid , long pVersion )
{
try
{
DeleteServiceCategories ( new Dictionary < long , long >
{
{
pOid , pVersion
}
} ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeleteServiceDescription ( long pOid , long pVersion )
{
try
{
DeleteServiceDescriptions ( new Dictionary < long , long >
{
{
pOid , pVersion
}
} ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeleteServiceRecord ( long pOid , long pVersion )
{
try
{
DeleteServiceRecords ( new Dictionary < long , long >
{
{
pOid , pVersion
}
} ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 > ( ) ;
2024-04-17 16:33:19 +02:00
foreach ( var item in lOriginals )
2016-06-27 01:45:38 +02:00
{
2024-04-17 16:33:19 +02:00
if ( item . Group ! = null )
2016-06-27 01:45:38 +02:00
{
2023-07-24 17:57:14 +02:00
RemoveServiceRecordsFromConfirmationReceiptSignatureForDeletion ( item . Group . ServiceRecordList ) ;
2023-03-31 14:20:25 +02:00
DeleteServiceRecordsFromAppointments ( item . Group . ServiceRecordList . ToList ( ) ) ;
2016-06-27 01:45:38 +02:00
DAOFactory . GenericDAO . Delete ( item . Group ) ;
}
else
{
srListToDelete . Add ( item ) ;
}
}
2024-04-17 16:33:19 +02:00
if ( srListToDelete . Count < = 0 )
2016-06-27 01:45:38 +02:00
{
2023-03-31 14:20:25 +02:00
return ;
}
2023-01-26 12:55:56 +01:00
2023-07-24 17:57:14 +02:00
RemoveServiceRecordsFromConfirmationReceiptSignatureForDeletion ( srListToDelete ) ;
2023-03-31 14:20:25 +02:00
DeleteServiceRecordsFromAppointments ( srListToDelete ) ;
2023-01-26 12:55:56 +01:00
2023-03-31 14:20:25 +02:00
DAOFactory . GenericDAO . Delete ( srListToDelete ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2023-03-31 14:20:25 +02:00
private static void DeleteServiceRecordsFromAppointments ( List < ServiceRecord > serviceRecords )
{
MakeServiceRecordHistoryEntry ( serviceRecords , null , StatementType . Delete ) ;
2023-06-18 17:11:35 +02:00
RemoveServiceRecordsFromConfirmationReceiptSignatures ( MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDCs ( serviceRecords ) , DAOFactory . GenericDAO . LoadByIDs < ServiceRecord > ( serviceRecords . Select ( s = > s . Oid . Value ) ) , true ) ;
2023-03-31 14:20:25 +02:00
var appointmentsToUpdate = DAOFactory . SearchDAO . LoadAppointmentsWithServiceRecords ( serviceRecords . Select ( s = > s . Oid . Value ) . ToList ( ) ) ;
appointmentsToUpdate . DoForEach ( appointment = > appointment . ServiceRecordList = appointment . ServiceRecordList . Where ( sr = > ! serviceRecords . Select ( s = > s . Oid . Value ) . Contains ( sr . Oid . Value ) ) . ToList ( ) ) ;
DAOFactory . GenericDAO . Update ( appointmentsToUpdate ) ;
}
2016-06-27 01:45:38 +02:00
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 ;
2020-04-08 14:25:01 +02:00
if ( MultitenancyOperationContextExt . Current ! = null )
2016-06-27 01:45:38 +02:00
{
tenant = MultitenancyOperationContextExt . Current . Tenant ;
}
2017-02-01 13:53:59 +01:00
var factory = PluginLoader . FindClass < InvoiceFactory > ( costBearer . ID ) ;
2020-04-08 14:25:01 +02:00
if ( factory = = null )
2017-02-01 13:53:59 +01:00
{
factory = InvoiceFactory . GetInstance ( costBearer . ID , tenant ) ;
}
var creator = factory . CreateSettlementInvoiceCreator ( costBearer . ID , tenant , lCb2Sc ) ;
2019-07-12 12:52:47 +02:00
2016-06-27 01:45:38 +02:00
var lResult = creator . GenerateSettlementInvoice ( lCb2Sc , periodStart , periodEnd ) ;
return lResult ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ( ) ;
}
2023-12-20 00:51:44 +01:00
public Settlement2DC GenerateDifferenzSettlementDC ( long pCostBearer2SupportConceptOid )
{
try
{
var newInvoice = GenerateInitialSettlementDC ( pCostBearer2SupportConceptOid ) ;
var existingInvoices = DAOFactory . SearchDAO . GetSettlementInvoiceByCostBearer2SupportConceptOid ( pCostBearer2SupportConceptOid ) ;
if ( existingInvoices . Count = = 0 ) //Sollte eigentlich nicht sein
{
return newInvoice ;
}
var juengsteRechnung = existingInvoices . OrderByDescending ( i = > i . InvoiceBase . AccountingPeriodEnd ) . First ( ) ;
var acs = PluginLoader . FindClass < AccountingService > ( ) ;
2024-04-17 16:33:19 +02:00
2023-12-20 00:51:44 +01:00
return acs . ErstelleDifferenzSpitzabrechnung ( newInvoice , MapperFactory . SettlementDC_SettlementInvoice . MapToNewDC ( juengsteRechnung ) ) ;
2024-04-17 16:33:19 +02:00
2023-12-20 00:51:44 +01:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2016-06-27 01:45:38 +02:00
public List < AccountingTransactionDC > GetAccountingTransactions ( DateTimeSpan pSpan , long? pSupportConceptOid , long? pSupportConceptCostBearerRelOid )
{
try
{
return MapperFactory . AccountingTransactionDC_AccountingTransaction . MapToNewDCs ( DAOFactory . SearchDAO . FindAccoutingTransactions ( pSpan , pSupportConceptOid , pSupportConceptCostBearerRelOid ) ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < InvoiceDC > GetAllActiveInvoices ( )
{
try
{
return MapperFactory . InvoiceDC_Invoice . MapToNewDCs ( DAOFactory . GenericDAO . GetAllActive < Invoice > ( ) ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < CompactSupportConceptDC > GetAllActiveSupportConceptCostbearer ( bool onlyApproved , bool onlyWithAssignedCostbearer , long employeeOid )
{
try
{
2019-07-12 12:52:47 +02:00
var s = PluginLoader . FindClass < CustomerService > ( ) ;
2016-06-27 01:45:38 +02:00
2019-07-12 12:52:47 +02:00
return s . GetAllActiveSupportConceptCostbearer ( onlyApproved , onlyWithAssignedCostbearer , employeeOid ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < AdditionalServiceDC > GetAllAdditionalService ( )
{
try
{
IList < AdditionalService > list = DAOFactory . GenericDAO . GetAllActive < AdditionalService > ( ) ;
return MapperFactory . AdditionalServiceDC_AdditionalService . MapToNewDCs ( list ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < ServiceCategoryDC > GetAllServiceCategories ( )
{
try
{
IList < ServiceCategory > list = DAOFactory . GenericDAO . GetAllActive < ServiceCategory > ( ) ;
2020-11-10 02:25:15 +01:00
var dcList = MapperFactory . ServiceCategoryDC_ServiceCategory . MapToNewDCs ( list ) ;
//AppSettings settings = AppSettings.CreateSettings();
//if (settings.SortServiceDescriptionAlphabetically)
//{
// dcList = dcList.OrderBy(c => c.Name).ToList();
//}
//else
//{
2020-12-15 12:45:07 +01:00
dcList . Sort ( ( a , b ) = >
{
if ( a . Position = = b . Position )
2020-11-10 02:25:15 +01:00
{
2020-12-15 12:45:07 +01:00
return a . ServiceCategoryOid . Value . CompareTo ( b . ServiceCategoryOid . Value ) ;
}
else
{
return a . Position . CompareTo ( b . Position ) ;
}
} ) ;
2020-11-10 02:25:15 +01:00
//}
return dcList ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < ServiceDescriptionDC > GetAllServiceDescriptions ( )
{
try
{
IList < ServiceDescription > list = DAOFactory . GenericDAO . GetAllActive < ServiceDescription > ( ) ;
2017-10-11 14:43:49 +02:00
var dcList = MapperFactory . ServiceDescriptionDC_ServiceDescription . MapToNewDCs ( list ) ;
2016-06-27 01:45:38 +02:00
AppSettings settings = AppSettings . CreateSettings ( ) ;
2020-04-08 14:25:01 +02:00
if ( settings . SortServiceDescriptionAlphabetically )
2016-06-27 01:45:38 +02:00
{
2017-10-11 14:43:49 +02:00
dcList = dcList . OrderBy ( sd = > sd . Name ) . ToList ( ) ;
}
else
{
dcList . Sort ( ( a , b ) = >
{
2020-04-08 14:25:01 +02:00
if ( a . Position = = b . Position )
2017-10-11 14:43:49 +02:00
{
return a . ServiceDescriptionOid . Value . CompareTo ( b . ServiceDescriptionOid . Value ) ;
}
else
{
return a . Position . CompareTo ( b . Position ) ;
}
} ) ;
2016-06-27 01:45:38 +02:00
}
2017-10-11 14:43:49 +02:00
return dcList ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < ServiceDescriptionDC > FindServiceDescriptionsForCategory ( long pCategoryOid )
{
try
{
return MapperFactory . ServiceDescriptionDC_ServiceDescription . MapToNewDCs ( DAOFactory . SearchDAO . FindServiceDescriptionForCategory ( pCategoryOid ) ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public ServiceDescriptionDC GetServiceDescription ( long pServiceDescriptionOid )
{
try
{
return MapperFactory . ServiceDescriptionDC_ServiceDescription . MapToNewDC ( DAOFactory . GenericDAO . GetByID < ServiceDescription > ( pServiceDescriptionOid ) ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public string GetCompressedICD10Diagnosis ( )
{
try
{
return ICD10DAO . GetCompressedString ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public CustomerInfoDC GetCustomerInfosForCustomerOid ( long customerOid )
{
try
{
var result = new CustomerInfoDC ( ) ;
var customer = DAOFactory . GenericDAO . LoadByID < Customer > ( customerOid ) ;
2020-04-08 14:25:01 +02:00
if ( customer . SupportConcepts = = null | | ! customer . SupportConcepts . Exists ( sc = > sc . IsActive = = ActivationTypeId . Active ) )
2016-06-27 01:45:38 +02:00
{
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: " ;
2020-04-08 14:25:01 +02:00
if ( currentSC . StartDate . HasValue )
2016-06-27 01:45:38 +02:00
{
result . CurrentSupportConcept + = currentSC . StartDate . Value . ToShortDateString ( ) . Remove ( 6 , 2 ) ;
}
2020-04-08 14:25:01 +02:00
if ( currentSC . EndDate . HasValue )
2016-06-27 01:45:38 +02:00
{
result . CurrentSupportConcept + = " - " + currentSC . EndDate . Value . ToShortDateString ( ) . Remove ( 6 , 2 ) ;
}
result . SupportConceptInfos = GetSupportConceptInfosForSupportConceptOid ( currentSC . Oid . Value ) ;
}
return result ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ) ;
2020-04-08 14:25:01 +02:00
if ( srList ! = null )
2016-06-27 01:45:38 +02:00
{
var serviceRecordsProcessed = new Dictionary < long , bool > ( ) ;
2020-04-08 14:25:01 +02:00
foreach ( var item in srList )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
if ( ! serviceRecordsProcessed . ContainsKey ( item . Oid . Value ) )
2016-06-27 01:45:38 +02:00
{
//ServiceRecordDC dc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(item);
//result.Add(dc);
var dc = CreateServiceRecordDCCompact ( item ) ;
2020-04-08 14:25:01 +02:00
if ( dc ! = null )
2016-06-27 01:45:38 +02:00
{
result . Add ( dc ) ;
}
serviceRecordsProcessed . Add ( item . Oid . Value , true ) ;
}
}
}
return result ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < ServiceRecordDC > GetCustomerServiceRecords ( long pCustomerOid , bool fetchArchivedSupportConcepts )
{
try
{
var result = new List < ServiceRecordDC > ( ) ;
var lCustomer = DAOFactory . SearchDAO . FindCustomerWithServiceRecordsWithDetail ( pCustomerOid ) ;
2020-04-08 14:25:01 +02:00
if ( lCustomer ! = null )
2016-06-27 01:45:38 +02:00
{
var srList = lCustomer . ServiceRecordList ;
2020-04-08 14:25:01 +02:00
if ( srList ! = null )
2016-06-27 01:45:38 +02:00
{
var serviceRecordsProcessed = new Dictionary < long , bool > ( ) ;
2020-04-08 14:25:01 +02:00
foreach ( var item in srList )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
if ( ! serviceRecordsProcessed . ContainsKey ( item . Oid . Value ) )
2016-06-27 01:45:38 +02:00
{
var dc = CreateServiceRecordDCIfSupportConceptIsActive ( item , lCustomer , ! fetchArchivedSupportConcepts ) ;
2020-04-08 14:25:01 +02:00
if ( dc ! = null )
2016-06-27 01:45:38 +02:00
{
result . Add ( dc ) ;
}
serviceRecordsProcessed . Add ( item . Oid . Value , true ) ;
}
}
}
}
return result ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
2016-06-27 01:45:38 +02:00
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 ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
public List < ServiceRecordDC > GetEmployeesServiceRecords2 ( long pEmployeeOid , long? days )
{
try
{
IEnumerable < ServiceRecord > list = DAOFactory . SearchDAO . FindEmployeeServiceRecordsWithoutCustomer ( pEmployeeOid , days ) ;
2016-06-27 01:45:38 +02:00
2019-07-12 12:52:47 +02:00
return MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDCs ( list ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2019-07-12 12:52:47 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2016-06-27 01:45:38 +02:00
2017-03-14 12:48:31 +01:00
public List < ServiceRecordDC > GetEmployeesServiceRecordsWithStartEndDate ( long pEmployeeOid , DateTime start , DateTime ende )
{
try
{
2019-07-12 12:52:47 +02:00
IEnumerable < ServiceRecord > list = DAOFactory . SearchDAO . FindEmployeeServiceRecordsWithoutCustomerWithStartEndDate ( pEmployeeOid , start , ende ) ;
2017-03-14 12:48:31 +01:00
return MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDCs ( list ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-03-14 12:48:31 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < ServiceRecordDC > GetCustomerServiceRecordsCompactWithStartEndDate ( long pCustomerOid , long costbearer2SupportConceptOid , DateTime start , DateTime ende )
{
try
{
var result = new List < ServiceRecordDC > ( ) ;
2019-07-12 12:52:47 +02:00
var srList = DAOFactory . SearchDAO . FindServiceRecordsDetailsForLastDaysWithStartEndDate ( costbearer2SupportConceptOid , start , ende ) ;
2017-03-14 12:48:31 +01:00
2020-04-08 14:25:01 +02:00
if ( srList ! = null )
2017-03-14 12:48:31 +01:00
{
var serviceRecordsProcessed = new Dictionary < long , bool > ( ) ;
2020-04-08 14:25:01 +02:00
foreach ( var item in srList )
2017-03-14 12:48:31 +01:00
{
2020-04-08 14:25:01 +02:00
if ( ! serviceRecordsProcessed . ContainsKey ( item . Oid . Value ) )
2017-03-14 12:48:31 +01:00
{
//ServiceRecordDC dc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(item);
//result.Add(dc);
var dc = CreateServiceRecordDCCompact ( item ) ;
2020-04-08 14:25:01 +02:00
if ( dc ! = null )
2017-03-14 12:48:31 +01:00
{
result . Add ( dc ) ;
}
serviceRecordsProcessed . Add ( item . Oid . Value , true ) ;
}
}
}
return result ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-03-14 12:48:31 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < ServiceRecordDC > GetEmployeesServiceRecordsInSpan ( long pEmployeeOid , DateTimeSpan limitinDateTimeSpan )
2019-07-12 12:52:47 +02:00
{
try
{
IEnumerable < ServiceRecord > list = DAOFactory . SearchDAO . FindEmployeeServiceRecordsWithoutCustomerInSpan ( pEmployeeOid , limitinDateTimeSpan ) ;
return MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDCs ( list ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2019-07-12 12:52:47 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2016-06-27 01:45:38 +02:00
public List < FileAttachmentDC > GetFileAttachments ( TableID pObjectTid , long pObjectOid )
{
try
{
2021-03-30 16:35:45 +02:00
var files = DAOFactory . SearchDAO . FindFileAttachmentInfos ( pObjectTid , pObjectOid ) . ToList ( ) ;
2021-03-30 16:53:22 +02:00
var fileAttachments = files . Select ( item = > MapperFactory . FileAttachmentDC_FileAttachmentInfo . MapToNewDC ( item ) ) . ToList ( ) ;
2016-06-27 01:45:38 +02:00
2021-03-30 16:53:22 +02:00
fileAttachments . DoForEach ( fileAttachment = >
{
2024-04-17 16:33:19 +02:00
if ( fileAttachment . BinaryData ! = null )
2021-03-30 16:53:22 +02:00
{
return ;
}
fileAttachment . BinaryData = FileAttachmentUtils . LoadFileFromDirectory ( fileAttachment . FileAttachmentOid ) ;
} ) ;
2016-06-27 01:45:38 +02:00
2021-03-30 16:53:22 +02:00
return fileAttachments ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < BeWoFolderDC > GetFolderTree ( TableID pObjectTid , long pObjectOid )
{
try
{
2021-02-15 08:04:40 +01:00
return DokumentManager . GetFolderTree ( pObjectTid , pObjectOid ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeleteFolder ( long pBeWoFolderOid , long pVersion )
{
try
{
2021-02-15 08:04:40 +01:00
DokumentManager . DeleteFolder ( pBeWoFolderOid , pVersion ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public long InsertNewFolder ( BeWoFolderDC folder )
{
try
{
2021-02-15 08:04:40 +01:00
return DokumentManager . InsertNewFolder ( folder ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public BeWoFolderDC UpdateFolder ( BeWoFolderDC folder )
{
try
{
2021-02-15 08:04:40 +01:00
return DokumentManager . UpdateFolder ( folder ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public FileAttachmentDC UpdateFileAttachment ( FileAttachmentDC file )
{
try
{
2021-02-15 08:04:40 +01:00
return DokumentManager . UpdateFileAttachment ( file ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public FileAttachmentDC DoTheRealFileUpdate ( FileAttachmentDC file )
{
try
{
2021-02-15 08:04:40 +01:00
return DokumentManager . DoTheRealFileUpdate ( file ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public MandatorDC GetMandator ( )
2019-02-12 19:22:22 +01:00
{
return GetMandator2 ( true ) ;
}
public MandatorDC GetMandator2 ( bool fetchContractState )
2016-06-27 01:45:38 +02:00
{
try
{
Mandator man = GetMandatorEntity ( ) ;
MandatorDC manDc = MapperFactory . MandatorDC_Mandator . MapToNewDC ( man ) ;
Dictionary < string , string > settingValueDict = GetSettingsValueDict ( manDc . Settings ) ;
2020-04-08 14:25:01 +02:00
if ( fetchContractState )
2016-06-27 01:45:38 +02:00
{
2019-02-12 19:22:22 +01:00
string contractState = GetContractState ( ) ;
2023-09-08 15:52:55 +02:00
if ( ! String . IsNullOrEmpty ( contractState ) & & contractState = = "Fehler" )
{
contractState = man . LastModules ;
}
else
{
if ( contractState ! = man . LastModules )
{
man . LastModules = contractState ;
DAOFactory . GenericDAO . Update ( man ) ;
}
}
2019-02-12 19:22:22 +01:00
Dictionary < string , string > contractStateDict = GetSettingsValueDict ( contractState ) ;
2020-04-08 14:25:01 +02:00
foreach ( var kv in contractStateDict )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
if ( settingValueDict . ContainsKey ( kv . Key ) )
2019-02-12 19:22:22 +01:00
{
settingValueDict . Remove ( kv . Key ) ;
}
settingValueDict . Add ( kv . Key , kv . Value ) ;
2016-06-27 01:45:38 +02:00
}
}
2019-02-12 19:22:22 +01:00
2024-06-24 16:30:36 +02:00
//if (!settingValueDict.ContainsKey("Arbeitszeiterfassung") && settingValueDict.ContainsKey("ShowWorktime"))
//{
// if (settingValueDict["ShowWorktime"] != "0")
// {
// settingValueDict.Add("Arbeitszeiterfassung", "1");
// }
//}
2024-05-13 17:56:09 +02:00
2020-04-08 14:25:01 +02:00
if ( ! settingValueDict . ContainsKey ( "ShowScheduler" ) & & man . IsSchedulerAllowed )
2016-06-27 01:45:38 +02:00
{
settingValueDict . Add ( "ShowScheduler" , "1" ) ;
}
2019-09-02 15:48:37 +02:00
2020-04-08 14:25:01 +02:00
if ( ! settingValueDict . ContainsKey ( "ShowMedication" ) & & man . IsMedicationAllowed )
2016-06-27 01:45:38 +02:00
{
settingValueDict . Add ( "ShowMedication" , "1" ) ;
}
2019-09-02 15:48:37 +02:00
2020-04-08 14:25:01 +02:00
if ( ! settingValueDict . ContainsKey ( "ShowDistanceFields" ) & & settingValueDict . ContainsKey ( "ShowKilometer" ) )
2019-02-12 19:22:22 +01:00
{
2020-04-08 14:25:01 +02:00
if ( settingValueDict [ "ShowKilometer" ] ! = "0" )
2019-02-12 19:22:22 +01:00
{
settingValueDict . Add ( "ShowDistanceFields" , "1" ) ;
}
}
2023-02-28 17:16:54 +01:00
if ( ! settingValueDict . ContainsKey ( "EinheitZeiterfassung" ) & & settingValueDict . ContainsKey ( "IsZeiterfassungInStdMin" ) )
{
if ( settingValueDict [ "IsZeiterfassungInStdMin" ] = = "1" )
{
settingValueDict . Add ( "EinheitZeiterfassung" , "2" ) ;
}
}
2019-07-12 12:52:47 +02:00
2023-09-08 15:52:55 +02:00
if ( ! settingValueDict . ContainsKey ( "FilterGroupServiceCategories" ) )
{
settingValueDict . Add ( "FilterGroupServiceCategories" , "0" ) ;
}
2016-06-27 01:45:38 +02:00
manDc . Settings = "" ;
2017-07-25 10:52:20 +02:00
2019-07-12 12:52:47 +02:00
2020-04-08 14:25:01 +02:00
foreach ( var kv in settingValueDict )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
if ( manDc . Settings . Length > 0 )
2016-06-27 01:45:38 +02:00
{
manDc . Settings + = ";" ;
}
2019-09-02 15:48:37 +02:00
2016-06-27 01:45:38 +02:00
manDc . Settings + = String . Format ( "{0}={1}" , kv . Key , kv . Value ) ;
}
return manDc ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ) ;
2020-12-30 02:46:55 +01:00
foreach ( var srh in result )
{
if ( srh . DurationInStunden . HasValue & & srh . DurationInStunden . Value = = ZeiterfassungsDauer . Stunden )
{
srh . RoundedDuration = srh . RoundedDuration / 60 ;
}
}
2016-06-27 01:45:38 +02:00
return result ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 > ( ) ;
2020-04-08 14:25:01 +02:00
foreach ( ServiceRecord item in group . ServiceRecordList )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
if ( ! serviceRecordsProcessed . ContainsKey ( item . Oid . Value ) )
2016-06-27 01:45:38 +02:00
{
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 ;
2017-02-01 09:24:33 +01:00
dc . DurationInStunden = item . DurationInStunden ;
2017-03-08 13:05:45 +01:00
dc . ServiceRecordFormat = item . ServiceRecordFormat ;
2017-02-01 09:24:33 +01:00
2016-06-27 01:45:38 +02:00
CompactCustomerDC customerDC = null ;
2020-04-08 14:25:01 +02:00
if ( item . Customer ! = null )
2016-06-27 01:45:38 +02:00
{
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 ;
2020-04-08 14:25:01 +02:00
if ( item . Employee ! = null )
2016-06-27 01:45:38 +02:00
{
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 ;
2020-04-08 14:25:01 +02:00
if ( item . SupportConcept ! = null )
2016-06-27 01:45:38 +02:00
{
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 ;
2020-04-08 14:25:01 +02:00
if ( cb2sc ! = null )
2016-06-27 01:45:38 +02:00
{
dc . CostBearer2SupportConceptOid = cb2sc . Oid . Value ;
2020-04-08 14:25:01 +02:00
if ( scDC ! = null )
2016-06-27 01:45:38 +02:00
{
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 ;
2020-04-08 14:25:01 +02:00
if ( cb2sc . CostBearer . Organisation ! = null )
2016-06-27 01:45:38 +02:00
{
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 ;
2021-07-05 18:05:43 +02:00
dc . SignatureOid = item . SignatureOid ;
2016-06-27 01:45:38 +02:00
result . Add ( dc ) ;
serviceRecordsProcessed . Add ( item . Oid . Value , true ) ;
}
}
groupDC . ServiceRecordList = result ;
return groupDC ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-02-07 12:56:47 +01:00
public long GetLastServiceRecordGroupOid ( )
{
var sc = DAOFactory . GenericDAO . GetAllActiveAndArchived < ServiceRecordGroup > ( ) ;
long x = sc . Last ( ) . Oid . Value ;
return x ;
}
2016-06-27 01:45:38 +02:00
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 ) ? ? 0 m ,
2019-09-02 15:48:37 +02:00
RecordedHours = calc . GetBillableDurationInMinutes ( cb2sc . ServiceRecords . MapToNewDCsCompact ( ) ) / 60
2016-06-27 01:45:38 +02:00
} ;
// 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 ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < SupportConceptTreeNodeDC > GetSupportConceptTreeAllActive ( )
{
try
{
return BuildTree ( DAOFactory . GenericDAO . GetAllActiveAndArchived < SupportConcept > ( ) ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < SupportConceptTreeNodeDC > GetSupportConceptTreeAllActiveWithCostbearer ( )
{
try
{
return BuildTree ( DAOFactory . GenericDAO . GetAllActive < SupportConcept > ( ) . Where ( sc = > sc . CostBearer2SupportConceptList . Count > 0 ) ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < SupportConceptTreeNodeDC > GetSupportConceptTreeAllCurrent ( )
{
try
{
return BuildTree ( DAOFactory . SearchDAO . FindCurrentSupportConcepts ( ) ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < SupportConceptTreeNodeDC > GetSupportConceptTreeByEmployee ( long pEmployeeOid )
{
try
{
2019-07-12 12:52:47 +02:00
var s = PluginLoader . FindClass < CustomerService > ( ) ;
2016-06-27 01:45:38 +02:00
2019-07-12 12:52:47 +02:00
return s . GetSupportConceptTreeByEmployee ( pEmployeeOid ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < SupportConceptTreeNodeDC > GetSupportConceptTreeInSpan ( DateTimeSpan pSpan )
{
try
{
return BuildTree ( DAOFactory . SearchDAO . FindSupportConceptsInSpan ( pSpan ) ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public SupportConceptTreeNodeDetailInfoDC GetSupportConceptTreeNodeDetailInfo ( long pCustomerOid , long? pSupportConceptOid , long? pCostbearer2SupportConceptOid )
{
try
{
var dc = new SupportConceptTreeNodeDetailInfoDC ( ) ;
2023-08-17 01:03:19 +02:00
if ( pCustomerOid > 0 )
{
var customer = DAOFactory . GenericDAO . LoadByID < Customer > ( pCustomerOid ) ;
2016-06-27 01:45:38 +02:00
2023-08-17 01:03:19 +02:00
dc . CustomerAbsenceTimes = MapperFactory . AbsenceTimeDC_AbsenceTime . MapToNewDCs ( customer . AbsenceTimes ) ;
}
2020-04-08 14:25:01 +02:00
if ( pSupportConceptOid ! = null )
2016-06-27 01:45:38 +02:00
{
var sc = DAOFactory . GenericDAO . LoadByID < SupportConcept > ( pSupportConceptOid . Value ) ;
var list = new List < ValueListEntryType > ( ) ;
list . Add ( ValueListEntryType . SupportConceptGoalType ) ;
2019-07-12 12:52:47 +02:00
list . Add ( ValueListEntryType . SupportConceptGoalCategoryType ) ;
2016-06-27 01:45:38 +02:00
list . Add ( ValueListEntryType . SupportConceptIndividualGoalCategoryType ) ;
2019-07-12 12:52:47 +02:00
list . Add ( ValueListEntryType . SupportConceptIndividualGoalType ) ;
2016-06-27 01:45:38 +02:00
2019-07-12 12:52:47 +02:00
dc . SupportConceptGoals =
MapperFactory . ValueListEntryDC_ValueListEntry . MapToNewDCs (
sc . ValueList . FindByTypes ( list )
. Select ( e2o = > e2o . Entry )
. Where ( e = > e . IsActive = = ActivationTypeId . Active ) ) ;
2016-06-27 01:45:38 +02:00
dc . ServiceAccountings = MapperFactory . ServiceAccountingDC_ServiceAccounting . MapToNewDCs ( sc . ServiceAccountings ) ;
}
2020-04-08 14:25:01 +02:00
if ( pCostbearer2SupportConceptOid ! = null )
2016-06-27 01:45:38 +02:00
{
var c2s = DAOFactory . GenericDAO . LoadByID < CostBearer2SupportConcept > ( pCostbearer2SupportConceptOid . Value ) ;
dc . ApprovalPeriods = MapperFactory . SupportConceptApprovalPeriodDC_SupportConceptApprovalPeriod . MapToNewDCs ( c2s . ApprovalPeriodList ) ;
2020-04-08 14:25:01 +02:00
if ( dc . ApprovalPeriods ! = null )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
foreach ( SupportConceptApprovalPeriodDC item in dc . ApprovalPeriods )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
if ( ! item . StartDate . HasValue )
2016-06-27 01:45:38 +02:00
{
item . StartDate = c2s . ApprovedStartDate . HasValue ? c2s . ApprovedStartDate : c2s . RequestedStartDate ;
}
2019-09-02 15:48:37 +02:00
2020-04-08 14:25:01 +02:00
if ( ! item . EndDate . HasValue )
2016-06-27 01:45:38 +02:00
{
item . EndDate = c2s . ApprovedEndDate . HasValue ? c2s . ApprovedEndDate : c2s . RequestedEndDate ;
}
}
}
}
2019-09-02 15:48:37 +02:00
2016-06-27 01:45:38 +02:00
return dc ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2024-01-24 13:29:51 +01:00
public List < SupportConceptTreeNodeDetailInfoDC > GetSupportConceptTreeNodeDetailInfos ( List < long > supportConceptOids )
{
try
{
var result = new List < SupportConceptTreeNodeDetailInfoDC > ( ) ;
if ( supportConceptOids . Count > 0 )
{
var scList = DAOFactory . GenericDAO . LoadByIDs < SupportConcept > ( supportConceptOids ) ;
foreach ( var sc in scList )
{
var list = new List < ValueListEntryType > ( ) ;
list . Add ( ValueListEntryType . SupportConceptGoalType ) ;
list . Add ( ValueListEntryType . SupportConceptGoalCategoryType ) ;
list . Add ( ValueListEntryType . SupportConceptIndividualGoalCategoryType ) ;
list . Add ( ValueListEntryType . SupportConceptIndividualGoalType ) ;
2024-06-26 12:29:22 +02:00
var dc = new SupportConceptTreeNodeDetailInfoDC
{
SupportConceptGoals = MapperFactory . ValueListEntryDC_ValueListEntry . MapToNewDCs (
2024-01-24 13:29:51 +01:00
sc . ValueList . FindByTypes ( list )
. Select ( e2o = > e2o . Entry )
2024-06-26 12:29:22 +02:00
. Where ( e = > e . IsActive = = ActivationTypeId . Active ) ) ,
ServiceAccountings = MapperFactory . ServiceAccountingDC_ServiceAccounting . MapToNewDCs ( sc . ServiceAccountings ) ,
} ;
if ( sc . Customer ? . Oid . HasValue ? ? false )
{
dc . CustomerOid = sc . Customer . Oid . Value ;
}
2024-01-24 13:29:51 +01:00
2024-06-26 12:29:22 +02:00
if ( sc . Oid . HasValue )
{
dc . SupportConceptOid = sc . Oid . Value ;
}
2024-01-24 13:29:51 +01:00
result . Add ( dc ) ;
}
}
return result ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2016-06-27 01:45:38 +02:00
public CompactOrganisationDC FillCostbearerDetails ( CompactOrganisationDC dc )
{
try
{
2020-04-08 14:25:01 +02:00
if ( dc . CostRatePeriods = = null | | dc . CostRatePeriods . Count = = 0 )
2016-06-27 01:45:38 +02:00
{
var org = DAOFactory . GenericDAO . LoadByID < Organisation > ( dc . OrganisationOid ) ;
2020-04-08 14:25:01 +02:00
if ( org ! = null )
2016-06-27 01:45:38 +02:00
{
MapperFactory . CompactOrganisationDC_Organisation . MergeWithDC ( org , dc ) ;
}
}
2019-09-02 15:48:37 +02:00
2016-06-27 01:45:38 +02:00
return dc ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < AccountingTransactionDC > GetUnassignedAccountingTransactions ( )
{
try
{
IEnumerable < AccountingTransaction > list = DAOFactory . SearchDAO . FindUnassignedAccountingTransactions ( ) ;
return MapperFactory . AccountingTransactionDC_AccountingTransaction . MapToNewDCs ( list ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < VarFieldDC > GetVarFieldDefs ( TableID tid )
{
try
{
return MapperFactory . VarFieldDC_VarField . VarFieldMapToDCs ( DAOFactory . SearchDAO . GetVarFieldDefs ( tid ) , null ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < long > InsertNewAccountingTransactions ( List < AccountingTransactionDC > pAccountingTransactions )
{
try
{
2020-04-08 14:25:01 +02:00
foreach ( var at in pAccountingTransactions )
2016-06-27 01:45:38 +02:00
{
2020-12-30 02:46:55 +01:00
if ( at . SupportConceptCostBearerRelDC ! = null & & at . SupportConceptCostBearerRelDC . CostBearer2SupportConceptOid . HasValue & & ! at . SupportConceptCostBearerRelDC . CostBearer2SupportConceptVersion . HasValue )
2016-06-27 01:45:38 +02:00
{
var c2s = DAOFactory . GenericDAO . LoadByID < CostBearer2SupportConcept > ( at . SupportConceptCostBearerRelDC . CostBearer2SupportConceptOid . Value ) ;
var c2sDc = MapperFactory . SupportConceptCostBearerRelDC_CostBearer2SupportConcept . MapToNewDC ( c2s ) ;
at . SupportConceptCostBearerRelDC = c2sDc ;
}
}
2019-09-02 15:48:37 +02:00
2016-06-27 01:45:38 +02:00
List < AccountingTransaction > lEntities = MapperFactory . AccountingTransactionDC_AccountingTransaction . MapToNewEntities ( pAccountingTransactions ) ;
DAOFactory . GenericDAO . Insert ( lEntities ) ;
return lEntities . Select ( e = > e . Oid . Value ) . ToList ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void InsertNewInvoices ( List < InvoiceDC > pInvoices )
{
try
{
DAOFactory . GenericDAO . Insert ( MapperFactory . InvoiceDC_Invoice . MapToNewEntities ( pInvoices ) ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 > ( ) ;
2020-04-08 14:25:01 +02:00
foreach ( ServiceDescription newSd in lServiceDescriptions )
2016-06-27 01:45:38 +02:00
{
newServiceDescriptionOids . Add ( newSd . Oid . Value ) ;
}
2019-09-02 15:48:37 +02:00
2020-04-08 14:25:01 +02:00
foreach ( ServiceDescription newSd in lServiceDescriptions )
2016-06-27 01:45:38 +02:00
{
ServiceCategory cat = newSd . ServiceCategory ;
IEnumerable < ServiceDescription > descList = DAOFactory . SearchDAO . FindServiceDescriptionForCategory ( cat . Oid . Value ) ;
IList < long > oids = new List < long > ( ) ;
2020-04-08 14:25:01 +02:00
foreach ( ServiceDescription oldSd in descList )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
if ( ! newServiceDescriptionOids . Contains ( oldSd . Oid . Value ) )
2016-06-27 01:45:38 +02:00
{
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 > ( ) ;
2020-04-08 14:25:01 +02:00
foreach ( ServiceAccounting acc in accountingList )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
if ( acc . SupportConceptOid . HasValue )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
if ( supportConceptCountDict . ContainsKey ( acc . SupportConceptOid . Value ) )
2016-06-27 01:45:38 +02:00
{
supportConceptCountDict [ acc . SupportConceptOid . Value ] + + ;
}
else
{
supportConceptCountDict . Add ( acc . SupportConceptOid . Value , 1 ) ;
}
}
}
IList < long > supportConceptToUpdateOids = new List < long > ( ) ;
2020-04-08 14:25:01 +02:00
foreach ( var pair in supportConceptCountDict )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
if ( pair . Value = = oids . Count )
2016-06-27 01:45:38 +02:00
{
//Wenn es für alle alten Leistungen eine ServiceAccounting gibt, füge die neue Leistung auch hinzu
supportConceptToUpdateOids . Add ( pair . Key ) ;
}
}
2020-04-08 14:25:01 +02:00
foreach ( long scOid in supportConceptToUpdateOids )
2016-06-27 01:45:38 +02:00
{
var sc = DAOFactory . GenericDAO . LoadByID < SupportConcept > ( scOid ) ;
var newSa = new ServiceAccounting ( ) ;
newSa . ServiceDescription = newSd ;
sc . ServiceAccountings . Add ( newSa ) ;
scToSave . Add ( sc ) ;
}
}
2020-04-08 14:25:01 +02:00
if ( scToSave . Count > 0 )
2016-06-27 01:45:38 +02:00
{
DAOFactory . GenericDAO . Insert ( scToSave ) ;
}
return lServiceDescriptions . Select ( sd = > sd . Oid . Value ) . ToList ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public AdditionalServiceRegionDC GetAdditionalServiceRegion ( long pRegionOid )
{
try
{
return MapperFactory . AdditionalServiceRegionDC_AdditionalServiceRegion . MapToNewDC ( DAOFactory . GenericDAO . GetByID < AdditionalServiceRegion > ( pRegionOid ) ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public ServiceRecordGroupDC InsertNewServiceRecordGroup ( ServiceRecordGroupDC pServiceRecordGroup )
{
try
{
2018-04-18 14:33:21 +02:00
var group = MapperFactory . ServiceRecordGroupDC_ServiceRecordGroup . MapToNewEntity ( pServiceRecordGroup ) ;
2016-06-27 01:45:38 +02:00
var lServiceRecords = new List < ServiceRecord > ( ) ;
2020-04-08 14:25:01 +02:00
if ( pServiceRecordGroup . ServiceRecordList ! = null & & pServiceRecordGroup . ServiceRecordList . Count > 0 )
2016-06-27 01:45:38 +02:00
{
lServiceRecords = MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewEntities ( pServiceRecordGroup . ServiceRecordList ) ;
2020-04-08 14:25:01 +02:00
foreach ( var iServiceRecord in lServiceRecords )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
if ( ! group . StartDate . HasValue & & group . EndDate . HasValue )
2017-06-28 09:00:09 +02:00
{
2020-04-08 14:25:01 +02:00
group . StartDate = group . EndDate . Value . AddMinutes ( ( double ) group . RoundedDuration * - 1 ) ;
2017-06-28 09:00:09 +02:00
}
2020-04-08 14:25:01 +02:00
if ( group . StartDate . HasValue & & group . EndDate . HasValue )
2017-06-28 09:00:09 +02:00
{
//Korrigieren
2020-04-08 14:25:01 +02:00
if ( group . StartDate . Value = = group . EndDate . Value )
2017-06-28 09:00:09 +02:00
{
2020-04-08 14:25:01 +02:00
if ( iServiceRecord . RoundedDuration > 0 )
2017-06-28 09:00:09 +02:00
{
2020-04-08 14:25:01 +02:00
group . EndDate = group . StartDate . Value . AddMinutes ( ( double ) iServiceRecord . RoundedDuration ) ;
2017-06-28 09:00:09 +02:00
}
}
}
2019-07-12 12:52:47 +02:00
2020-04-08 14:25:01 +02:00
if ( group . StartDate . HasValue )
2017-06-28 09:00:09 +02:00
{
iServiceRecord . Start = group . StartDate ;
}
2019-07-12 12:52:47 +02:00
2020-04-08 14:25:01 +02:00
if ( group . EndDate . HasValue )
2017-06-28 09:00:09 +02:00
{
iServiceRecord . End = group . EndDate ;
}
2018-05-23 10:37:57 +02:00
//if(group.RoundedDuration == 0)
//{
2020-04-08 14:25:01 +02:00
if ( group . EndDate . HasValue & & group . StartDate . HasValue )
2019-07-12 12:52:47 +02:00
{
var minutes = group . EndDate . Value . Subtract ( group . StartDate . Value ) . TotalMinutes ;
2017-06-28 09:00:09 +02:00
2020-04-08 14:25:01 +02:00
group . RoundedDuration = ( decimal ) minutes ;
2019-07-12 12:52:47 +02:00
}
2018-05-23 10:37:57 +02:00
//}
2017-06-28 09:00:09 +02:00
2018-05-23 10:37:57 +02:00
//if(!iServiceRecord.GroupRoundedDuration.HasValue || iServiceRecord.GroupRoundedDuration.Value == 0)
//{
2019-07-12 12:52:47 +02:00
iServiceRecord . GroupRoundedDuration = group . RoundedDuration ;
2018-05-23 10:37:57 +02:00
//}
2017-06-28 09:00:09 +02:00
2020-04-08 14:25:01 +02:00
if ( iServiceRecord . IP = = null )
2018-04-18 14:33:21 +02:00
{
iServiceRecord . IP = Utils . GetClientIP ( ) ;
}
2016-06-27 01:45:38 +02:00
// iServiceRecord.Group = group;
}
2019-07-12 12:52:47 +02:00
2016-06-27 01:45:38 +02:00
group . ServiceRecordList = lServiceRecords ;
2017-05-18 21:47:09 +02:00
2019-07-12 12:52:47 +02:00
2017-05-18 21:47:09 +02:00
var gdc = PluginLoader . FindClass < GroupDurationCalculator > ( ) ;
2018-04-18 14:33:21 +02:00
gdc ? . CalculateGroupDuration ( @group ) ;
2016-06-27 01:45:38 +02:00
}
DAOFactory . GenericDAO . Insert ( group ) ;
2020-04-08 14:25:01 +02:00
if ( lServiceRecords . Count > 0 )
2018-04-18 14:33:21 +02:00
{
2016-06-27 01:45:38 +02:00
MakeServiceRecordHistoryEntry ( lServiceRecords , lServiceRecords . Select ( sr = > sr . Oid . Value ) . ToList ( ) , StatementType . Insert ) ;
2018-04-18 14:33:21 +02:00
}
2016-06-27 01:45:38 +02:00
2018-04-18 14:33:21 +02:00
var newGroupDC = MapperFactory . ServiceRecordGroupDC_ServiceRecordGroup . MapToNewDC ( group ) ;
2016-06-27 01:45:38 +02:00
newGroupDC . ServiceRecordList = MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDCs ( group . ServiceRecordList ) ;
return newGroupDC ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeleteAdditionalServiceGroupOfPeopleRelation ( long pOid , long pVersion )
{
try
{
2020-04-08 14:25:01 +02:00
DeleteAdditionalServiceGroupOfPeopleRelations ( new Dictionary < long , long > { { pOid , pVersion } } ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ( ) ;
2020-04-08 14:25:01 +02:00
if ( asbListToDelete . Count < = 0 )
2016-06-27 01:45:38 +02:00
return ;
DAOFactory . GenericDAO . Delete ( asbListToDelete ) ;
IList < AssessmentSheetEntry > allEntries = DAOFactory . GenericDAO . GetAll < AssessmentSheetEntry > ( ) ;
var entries2Delete = new List < AssessmentSheetEntry > ( ) ;
2020-04-08 14:25:01 +02:00
foreach ( AdditionalServiceBooking item in lOriginals )
2016-06-27 01:45:38 +02:00
{
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 ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2023-12-20 00:51:44 +01:00
public void RemoveAdditionalServiceCustomer ( List < long > customerOids , long? regionOid , DateTime monat )
{
try
{
foreach ( var oid in customerOids )
{
var bookings = DAOFactory . SearchDAO . GetAdditionalServiceBookingsForCustomer ( oid , monat , monat . AddMonths ( 1 ) . AddDays ( - 1 ) ) ;
2024-04-17 16:33:19 +02:00
2023-12-20 00:51:44 +01:00
foreach ( var item in bookings )
{
2024-01-16 18:42:02 +01:00
if ( item . AdditionalServiceRegion ! = null & & item . AdditionalServiceRegion . Oid = = regionOid )
2023-12-20 00:51:44 +01:00
{
var entries2Delete = new List < Customer2AddServiceBooking > ( ) ;
foreach ( var c2a in item . Customer2AddServiceBookings )
{
if ( c2a . CustomerOid = = oid )
{
entries2Delete . Add ( c2a ) ;
}
}
item . Customer2AddServiceBookings . RemoveRange ( entries2Delete ) ;
DAOFactory . GenericDAO . Update ( item ) ;
}
}
2024-04-17 16:33:19 +02:00
2023-12-20 00:51:44 +01:00
}
2024-04-17 16:33:19 +02:00
2023-12-20 00:51:44 +01:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2016-06-27 01:45:38 +02:00
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 ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void UpdateAdditionalServiceBookings ( List < AdditionalServiceBookingDC > pAdditionalServiceBookings )
{
try
{
2023-12-20 00:51:44 +01:00
//Bugfix: die AdditionalServiceBookingList enthält manchmal mehrere Objekte mit gleicher OID
//var distinctDcs = pAdditionalServiceBookings.Distinct().ToList();
var distinctDcs = new List < AdditionalServiceBookingDC > ( ) ;
var dict = new Dictionary < long , bool > ( ) ;
foreach ( var item in pAdditionalServiceBookings )
{
if ( ! item . AdditionalServiceBookingOid . HasValue )
{
distinctDcs . Add ( item ) ;
}
else if ( ! dict . ContainsKey ( item . AdditionalServiceBookingOid . Value ) )
{
distinctDcs . Add ( item ) ;
dict . Add ( item . AdditionalServiceBookingOid . Value , true ) ;
}
}
List < AdditionalServiceBooking > lOriginals = DAOFactory . GenericDAO . LoadByIDs < AdditionalServiceBooking > ( distinctDcs . Select ( dc = > dc . AdditionalServiceBookingOid . Value ) ) ;
MapperFactory . AdditionalServiceBookingDC_AdditionalServiceBooking . MergeWithEntitys ( distinctDcs , lOriginals ) ;
2016-06-27 01:45:38 +02:00
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));
2020-04-08 14:25:01 +02:00
foreach ( AdditionalServiceBooking item in lOriginals )
2016-06-27 01:45:38 +02:00
{
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 ) ;
2020-04-08 14:25:01 +02:00
foreach ( Customer2AddServiceBooking c2a in item . Customer2AddServiceBookings )
2016-06-27 01:45:38 +02:00
{
bool containsEntry = false ;
2020-04-08 14:25:01 +02:00
foreach ( AssessmentSheetEntry entry in entries2Update )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
if ( entry . Customer . Oid = = null )
2019-07-12 12:52:47 +02:00
continue ;
2020-04-08 14:25:01 +02:00
if ( entry . Customer . Oid . Value . Equals ( c2a . CustomerOid ) )
2016-06-27 01:45:38 +02:00
{
containsEntry = true ;
2020-04-08 14:25:01 +02:00
if ( c2a . Participated )
2016-06-27 01:45:38 +02:00
entry . AssessmentSheetValue = yes ;
else
entries2Delete . Add ( entry ) ;
}
}
2019-09-02 15:48:37 +02:00
2020-04-08 14:25:01 +02:00
if ( c2a . Participated & & ! containsEntry )
2016-06-27 01:45:38 +02:00
{
AssessmentSheetCategory cat =
DAOFactory . SearchDAO . GetAddServiceAssessmentSheetCategoryWithName (
item . AdditionalServiceRegion . AdditionalService . Name ) ;
2020-04-08 14:25:01 +02:00
if ( cat ! = null )
2016-06-27 01:45:38 +02:00
{
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 ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < long > InsertNewAdditionalServiceGroupOfPeopleRelations ( List < AdditionalServiceGroupOfPeopleRelationDC > pAdditionalServiceGroupOfPeopleRelations )
{
try
{
List < AdditionalService2GroupOfPeople > lAdditionalServiceGroupOfPeopleRelations =
2019-09-02 15:48:37 +02:00
MapperFactory . AdditionalServiceGroupOfPeopleRelationDC_AdditionalService2GroupOfPeople . MapToNewEntities ( pAdditionalServiceGroupOfPeopleRelations ) ;
2016-06-27 01:45:38 +02:00
DAOFactory . GenericDAO . Insert ( lAdditionalServiceGroupOfPeopleRelations ) ;
return lAdditionalServiceGroupOfPeopleRelations . Select ( asgopr = > asgopr . Oid . Value ) . ToList ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ;
2020-04-08 14:25:01 +02:00
foreach ( var iServiceRecord in lServiceRecords )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
if ( string . IsNullOrEmpty ( iServiceRecord . IP ) )
2016-06-27 01:45:38 +02:00
{
iServiceRecord . IP = OperationContext . Current ! = null ? Utils . GetClientIP ( ) : "::1" ;
}
2020-04-08 14:25:01 +02:00
if ( iServiceRecord . InsTs = = null )
2016-06-27 01:45:38 +02:00
{
iServiceRecord . InsTs = DateTime . Now ;
}
2020-04-08 14:25:01 +02:00
if ( iServiceRecord . GroupEmployeeCount ! = null & & iServiceRecord . GroupPersonCount ! = null & &
2019-09-02 15:48:37 +02:00
( iServiceRecord . GroupEmployeeCount . Value + iServiceRecord . GroupPersonCount . Value > 2 ) )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
if ( group = = null )
2016-06-27 01:45:38 +02:00
{
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
{
2017-05-18 21:47:09 +02:00
var srdc = PluginLoader . FindClass < ServiceRecordDurationCalculator > ( ) ;
2020-04-08 14:25:01 +02:00
if ( srdc ! = null )
2017-05-18 21:47:09 +02:00
{
srdc . CalculateRoundedDuration ( iServiceRecord ) ;
}
2019-09-02 15:48:37 +02:00
2016-06-27 01:45:38 +02:00
var bsi = PluginLoader . FindClass < SaveInterceptor > ( ) ;
2020-04-08 14:25:01 +02:00
if ( bsi ! = null )
2016-06-27 01:45:38 +02:00
{
bsi . BeforeSaveServiceRecord ( iServiceRecord ) ;
}
}
}
DAOFactory . GenericDAO . Insert ( lServiceRecords ) ;
2023-10-25 21:52:23 +02:00
MakeServiceRecordHistoryEntry ( lServiceRecords . ToList ( ) , lServiceRecords . Select ( sr = > sr . Oid . Value ) . ToList ( ) , StatementType . Insert ) ;
2016-06-27 01:45:38 +02:00
return lServiceRecords . Select ( sr = > sr . Oid . Value ) . ToList ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < long > InsertNewAdditionalServiceBookings ( List < AdditionalServiceBookingDC > pAdditionalServiceBookings )
{
try
{
List < AdditionalServiceBooking > lAdditionalServiceBookings = MapperFactory . AdditionalServiceBookingDC_AdditionalServiceBooking . MapToNewEntities ( pAdditionalServiceBookings ) ;
DAOFactory . GenericDAO . Insert ( lAdditionalServiceBookings ) ;
2020-04-08 14:25:01 +02:00
foreach ( AdditionalServiceBooking booking in lAdditionalServiceBookings )
2016-06-27 01:45:38 +02:00
{
AttachAddServiceToAssessment ( booking ) ;
}
return lAdditionalServiceBookings . Select ( asb = > asb . Oid . Value ) . ToList ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public bool IsAlive ( )
{
return true ;
}
public string PrepareFLSReport ( FLSAnalysisDataReportDC pReportDC , string id )
{
try
{
string lResult = id + ".xml" ;
2020-09-23 22:10:52 +02:00
string lDir = BS . Shared . Core . Utils . CreateSavePath ( AppDomain . CurrentDomain . BaseDirectory , MultitenancyOperationContextExt . Current . Tenant + @"\temp" ) ;
string lPath = BS . Shared . Core . Utils . CreateSavePath ( lDir , lResult ) ;
2016-06-27 01:45:38 +02:00
BS . Shared . Core . Utils . XMLSerialize ( lPath , pReportDC ) ;
return lResult ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public string PrepareSettlementReport ( Settlement2DC pSettlementDC )
{
try
{
string lResult = Guid . NewGuid ( ) + ".xml" ;
2020-09-23 22:10:52 +02:00
string lDir = BS . Shared . Core . Utils . CreateSavePath ( AppDomain . CurrentDomain . BaseDirectory , MultitenancyOperationContextExt . Current . Tenant + @"\temp" ) ;
string lPath = BS . Shared . Core . Utils . CreateSavePath ( lDir , lResult ) ;
2016-06-27 01:45:38 +02:00
BS . Shared . Core . Utils . XMLSerialize ( lPath , pSettlementDC ) ;
return lResult ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public MandatorDC UpdateMandator ( MandatorDC mandator )
{
try
{
Mandator lOriginal = GetMandatorEntity ( ) ;
2017-10-11 14:43:49 +02:00
//var oldDc = MapperFactory.MandatorDC_Mandator.MapToNewDC(lOriginal);
2016-06-27 01:45:38 +02:00
MapperFactory . MandatorDC_Mandator . MergeWithEntity ( mandator , lOriginal ) ;
DAOFactory . GenericDAO . Update ( lOriginal ) ;
return MapperFactory . MandatorDC_Mandator . MapToNewDC ( lOriginal ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public ServiceRecordGroupDC UpdateServiceRecordGroup ( ServiceRecordGroupDC pServiceRecordGroup )
{
try
{
var lOriginal = DAOFactory . GenericDAO . LoadByID < ServiceRecordGroup > ( pServiceRecordGroup . ServiceRecordGroupOid . Value ) ;
2017-06-28 09:00:09 +02:00
var originalStart = lOriginal . StartDate ;
var originalEnde = lOriginal . EndDate ;
2021-07-05 18:05:43 +02:00
if ( originalStart . HasValue & & originalEnde . HasValue & & pServiceRecordGroup . StartDate . HasValue & & pServiceRecordGroup . EndDate . HasValue )
2017-06-28 09:00:09 +02:00
{
var minutesOrg = originalEnde . Value . Subtract ( originalStart . Value ) . TotalMinutes ;
var minutesNew = pServiceRecordGroup . EndDate . Value . Subtract ( pServiceRecordGroup . StartDate . Value ) . TotalMinutes ;
2021-07-05 18:05:43 +02:00
if ( Math . Abs ( minutesNew - minutesOrg ) < 0.1 & & pServiceRecordGroup . StartDate . Value . Hour = = 0 & & pServiceRecordGroup . StartDate . Value . Minute = = 0 & & pServiceRecordGroup . StartDate . Value . Second = = 0 )
2017-06-28 09:00:09 +02:00
{
2023-10-25 21:52:23 +02:00
// Prüfen, ob korrigiert werden muss
2021-07-05 18:05:43 +02:00
if ( originalStart . Value . Hour ! = 0 | | originalStart . Value . Minute ! = 0 )
2017-06-28 09:00:09 +02:00
{
pServiceRecordGroup . StartDate = originalStart ;
pServiceRecordGroup . EndDate = originalEnde ;
2020-04-08 14:25:01 +02:00
pServiceRecordGroup . RoundedDuration = ( decimal ) originalEnde . Value . Subtract ( originalStart . Value ) . TotalMinutes ;
foreach ( var srdc in pServiceRecordGroup . ServiceRecordList )
2017-06-28 09:00:09 +02:00
{
srdc . Start = originalStart ;
srdc . End = originalEnde ;
srdc . GroupRoundedDuration = pServiceRecordGroup . RoundedDuration ;
}
}
}
}
2019-09-02 15:48:37 +02:00
2020-04-08 14:25:01 +02:00
if ( ! pServiceRecordGroup . StartDate . HasValue & & pServiceRecordGroup . EndDate . HasValue )
2017-06-28 09:00:09 +02:00
{
2024-04-17 16:33:19 +02:00
pServiceRecordGroup . StartDate = pServiceRecordGroup . EndDate . Value . AddMinutes ( ( double ) pServiceRecordGroup . RoundedDuration * - 1 ) ;
2017-06-28 09:00:09 +02:00
}
2019-09-02 15:48:37 +02:00
2020-04-08 14:25:01 +02:00
pServiceRecordGroup . RoundedDuration = ( decimal ) pServiceRecordGroup . EndDate . Value . Subtract ( pServiceRecordGroup . StartDate . Value ) . TotalMinutes ;
foreach ( var srdc in pServiceRecordGroup . ServiceRecordList )
2017-06-28 09:00:09 +02:00
{
srdc . GroupRoundedDuration = pServiceRecordGroup . RoundedDuration ;
}
2023-10-25 21:52:23 +02:00
// (Veraltet. Es ist keine Änderung an der Zeit bei vorhandener Einzelunterschrift) Bei geänderten Daten oder Uhrzeiten werden die Klientenunterschriften gelöscht
2024-04-17 16:33:19 +02:00
var serviceRecords = pServiceRecordGroup . ServiceRecordList ;
var originalServiceRecords = lOriginal . ServiceRecordList . ToList ( ) ;
2023-10-25 21:52:23 +02:00
var serviceRecordOidsWithDeletedSingleSignatures = DeleteSignaturesFromServiceRecords ( serviceRecords , originalServiceRecords ) ;
var serviceRecordsdWithRemovedConfirmationReceiptSignatures = RemoveServiceRecordsFromConfirmationReceiptSignatures ( serviceRecords , originalServiceRecords , false ) ;
2017-06-28 09:00:09 +02:00
MapperFactory . ServiceRecordGroupDC_ServiceRecordGroup . MergeWithEntity ( pServiceRecordGroup , lOriginal ) ;
2019-07-12 12:52:47 +02:00
2016-06-27 01:45:38 +02:00
var lServiceRecords = new List < ServiceRecord > ( ) ;
2023-10-25 21:52:23 +02:00
// Update der einzelnen Servicerecords
2016-06-27 01:45:38 +02:00
MapperFactory . ServiceRecordDC_ServiceRecord . MergeWithEntitys ( pServiceRecordGroup . ServiceRecordList , lOriginal . ServiceRecordList ) ;
2021-07-05 18:05:43 +02:00
foreach ( var iServiceRecord in lOriginal . ServiceRecordList )
2016-06-27 01:45:38 +02:00
{
2021-07-05 18:05:43 +02:00
if ( string . IsNullOrEmpty ( iServiceRecord . IP ) )
{
2016-06-27 01:45:38 +02:00
iServiceRecord . IP = Utils . GetClientIP ( ) ;
2021-07-05 18:05:43 +02:00
}
2016-06-27 01:45:38 +02:00
iServiceRecord . GroupOid = lOriginal . Oid ;
lServiceRecords . Add ( iServiceRecord ) ;
}
2019-09-02 15:48:37 +02:00
2021-07-05 18:05:43 +02:00
var groupDurationCalculator = PluginLoader . FindClass < GroupDurationCalculator > ( ) ;
2016-06-27 01:45:38 +02:00
2021-07-05 18:05:43 +02:00
groupDurationCalculator ? . CalculateGroupDuration ( lOriginal ) ;
2019-09-02 15:48:37 +02:00
2016-06-27 01:45:38 +02:00
DAOFactory . GenericDAO . Update ( lOriginal ) ;
2023-10-25 21:52:23 +02:00
// Die ServiceRecords, deren Einzelunterschriften duch bearbeitete Zeitangaben im Zuge des Updates gelöscht werden zu der SignatureStatus-Liste hinzugefügt (sollte eigentlich nicht vorkommen)
var serviceRecords2SignatureStates = GenerateSignatureStates ( serviceRecordOidsWithDeletedSingleSignatures , serviceRecordsdWithRemovedConfirmationReceiptSignatures , lOriginal . ServiceRecordList . ToList ( ) ) ;
MakeServiceRecordHistoryEntryWithSignatureStates ( serviceRecords2SignatureStates , StatementType . Update ) ;
2016-06-27 01:45:38 +02:00
2021-07-05 18:05:43 +02:00
var newGroupDC = MapperFactory . ServiceRecordGroupDC_ServiceRecordGroup . MapToNewDC ( lOriginal ) ;
2016-06-27 01:45:38 +02:00
newGroupDC . ServiceRecordList = MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDCs ( lOriginal . ServiceRecordList ) ;
return newGroupDC ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2024-04-17 16:33:19 +02:00
private static void MakeServiceRecordHistoryEntryWithSignatureStates ( List < ServiceRecord2SignatureStates > serviceRecords2SignatureStates , StatementType statementType )
2023-10-25 21:52:23 +02:00
{
var serviceRecordHistoryEntries = new List < ServiceRecordHistory > ( ) ;
2024-04-17 16:33:19 +02:00
foreach ( var serviceRecord2SignatureState in serviceRecords2SignatureStates )
2023-10-25 21:52:23 +02:00
{
var serviceRecord = serviceRecord2SignatureState . ServiceRecord ;
var singleSignatureState = serviceRecord2SignatureState . SingleSignatureStateType ;
var customerMonthlySignatureState = serviceRecord2SignatureState . CustomerMonthlySignatureStateType ;
var employeeMonthlySignatureState = serviceRecord2SignatureState . EmployeeMonthlySignatreStateType ;
2023-11-02 16:25:36 +01:00
SignatureStateInfoFromServiceRecordHistoryEntry previousRecordHistorySignatureInfo = null ;
2023-10-25 21:52:23 +02:00
2024-04-17 16:33:19 +02:00
if ( serviceRecord . Oid . HasValue )
2023-10-25 21:52:23 +02:00
{
2023-11-02 16:25:36 +01:00
//previousRecordHistoryEntry = DAOFactory.SearchDAO.FindMostRecentServiceRecordHistoryEntryByServiceRecordOid(serviceRecord.Oid.Value);
previousRecordHistorySignatureInfo = DAOFactory . SearchDAO . FindMostRecentSignatureStatusInfoByServiceRecordOid ( serviceRecord . Oid . Value ) ;
2023-10-25 21:52:23 +02:00
}
serviceRecordHistoryEntries . AddIfNotIn ( new ServiceRecordHistory
{
2024-04-17 16:33:19 +02:00
TimeStamp = DateTime . Now ,
ChangeType = statementType ,
CostBearer2SupportConcept = serviceRecord . CostBearer2SupportConcept ,
CostBearer2SupportConceptOid = serviceRecord . CostBearer2SupportConceptOid ,
Customer = serviceRecord . Customer ,
CustomerOid = serviceRecord . CustomerOid ,
Employee = serviceRecord . Employee ,
EmployeeOid = serviceRecord . EmployeeOid ,
End = serviceRecord . End ,
Group = serviceRecord . Group ,
GroupEmployeeCount = serviceRecord . GroupEmployeeCount ,
GroupOid = serviceRecord . GroupOid ,
GroupPersonCount = serviceRecord . GroupPersonCount ,
GroupRoundedDuration = serviceRecord . GroupRoundedDuration ,
IP = serviceRecord . IP ,
IsActive = serviceRecord . IsActive ,
Notice = serviceRecord . Notice ,
ServiceRecordOid = serviceRecord . Oid ,
RoundedDuration = serviceRecord . RoundedDuration ,
ServiceDescription = serviceRecord . ServiceDescription ,
ServiceRecordType = serviceRecord . ServiceRecordType ,
ServiceRecordInsTs = serviceRecord . InsTs ,
ServiceRecordVersion = serviceRecord . Version ? ? 0 ,
ServiceRecordInsUser = serviceRecord . InsUser ,
ServiceRecordUdpUser = serviceRecord . UdpUser ,
Start = serviceRecord . Start ,
SupportConcept = serviceRecord . SupportConcept ,
SystemEntryID = serviceRecord . SystemEntryID ,
DistanceInMeter = serviceRecord . DistanceInMeter ,
IsCreatedInMobileClient = serviceRecord . IsCreatedInMobileClient ,
ServiceRecordSignatureStateType = singleSignatureState ? ? previousRecordHistorySignatureInfo ? . ServiceRecordSignatureStateType ? ? SignatureStateType . None ,
2023-11-02 16:25:36 +01:00
CustomerConfirmationReceiptSignatureStateType = customerMonthlySignatureState ? ? previousRecordHistorySignatureInfo ? . CustomerConfirmationReceiptSignatureStateType ? ? SignatureStateType . None ,
EmployeeConfirmationReceiptSignatureStateType = employeeMonthlySignatureState ? ? previousRecordHistorySignatureInfo ? . EmployeeConfirmationReceiptSignatureStateType ? ? SignatureStateType . None ,
2024-04-17 16:33:19 +02:00
CustomerConfirmationReceiptSignatureOid = previousRecordHistorySignatureInfo ? . CustomerConfirmationReceiptSignatureOid ,
EmployeeConfirmationReceiptSignatureOid = previousRecordHistorySignatureInfo ? . EmployeeConfirmationReceiptSignatureOid
2023-10-25 21:52:23 +02:00
} ) ;
}
DAOFactory . GenericDAO . Insert ( serviceRecordHistoryEntries ) ;
}
private static List < ServiceRecord2SignatureStates > GenerateSignatureStates ( List < ServiceRecord > serviceRecordsWithDeletedSingleSignatures , List < ServiceRecord2SignatureStates > serviceRecordsdWithRemovedConfirmationReceiptSignatures , List < ServiceRecord > originals )
{
var serviceRecords2SignatureStates = new List < ServiceRecord2SignatureStates > ( ) ;
// Die ServiceRecords, deren Einzelunterschriften duch bearbeitete Zeitangaben im Zuge des Updates gelöscht werden zu der SignatureStatus-Liste hinzugefügt (sollte eigentlich nicht vorkommen)
2024-04-17 16:33:19 +02:00
foreach ( var serviceRecord in serviceRecordsWithDeletedSingleSignatures )
2023-10-25 21:52:23 +02:00
{
serviceRecords2SignatureStates . Add ( new ServiceRecord2SignatureStates ( serviceRecord , SignatureStateType . AutomaticallyDeleted , null , null ) ) ;
}
// Die ServiceRecords, deren Monatsunterschriften duch bearbeitete Zeitangaben im Zuge des Updates gelöscht werden zu der SignatureStatus-Liste hinzugefügt
2024-04-17 16:33:19 +02:00
foreach ( var serviceRecord2SignatureStates in serviceRecordsdWithRemovedConfirmationReceiptSignatures )
2023-10-25 21:52:23 +02:00
{
var existingServiceRecord2SignatureStates = serviceRecords2SignatureStates . FirstOrDefault ( f = > f . ServiceRecord . Equals ( serviceRecord2SignatureStates . ServiceRecord ) ) ;
2024-04-17 16:33:19 +02:00
if ( existingServiceRecord2SignatureStates is null )
2023-10-25 21:52:23 +02:00
{
serviceRecords2SignatureStates . Add ( serviceRecord2SignatureStates ) ;
}
else
{
existingServiceRecord2SignatureStates . CustomerMonthlySignatureStateType = serviceRecord2SignatureStates . CustomerMonthlySignatureStateType ;
existingServiceRecord2SignatureStates . EmployeeMonthlySignatreStateType = serviceRecord2SignatureStates . EmployeeMonthlySignatreStateType ;
}
}
// Die ServiceRecords, bei denen keine Zeitangaben geändert wurden und deren Unterschriften so erhalten bleiben, werden zu der SignatureStatus-Liste hinzugefügt
2024-04-17 16:33:19 +02:00
foreach ( var serviceRecord in originals )
2023-10-25 21:52:23 +02:00
{
2024-04-17 16:33:19 +02:00
if ( serviceRecord . Oid is null )
2023-10-25 21:52:23 +02:00
{
continue ;
}
var oid = serviceRecord . Oid . Value ;
2024-04-17 16:33:19 +02:00
if ( serviceRecordsWithDeletedSingleSignatures . All ( a = > a . Oid . HasValue & & a . Oid . Value . Equals ( oid ) ) & &
2023-10-25 21:52:23 +02:00
serviceRecordsdWithRemovedConfirmationReceiptSignatures . All ( a = > a . ServiceRecord . Oid . HasValue & & a . ServiceRecord . Oid . Value . Equals ( oid ) ) )
{
serviceRecords2SignatureStates . AddIfNotIn ( new ServiceRecord2SignatureStates ( serviceRecord , null , null , null ) ) ;
}
}
return serviceRecords2SignatureStates ;
}
2016-06-27 01:45:38 +02:00
public void UpdateServiceRecords ( List < ServiceRecordDC > pServiceRecords )
{
try
{
2021-07-05 18:05:43 +02:00
var lOriginals = DAOFactory . GenericDAO . LoadByIDs < ServiceRecord > ( pServiceRecords . Select ( sr = > sr . ServiceRecordOid . Value ) ) ;
2016-06-27 01:45:38 +02:00
2023-10-25 21:52:23 +02:00
// ToDo: KGW? Man kann bei ServiceReocrds die Uhrzeiten, die eine Einzelunterschrift ungültig machen würde, nicht ändern.
var serviceRecordsWithDeletedSingleSignatures = DeleteSignaturesFromServiceRecords ( pServiceRecords , lOriginals ) ;
var serviceRecordsdWithRemovedConfirmationReceiptSignatures = RemoveServiceRecordsFromConfirmationReceiptSignatures ( pServiceRecords , lOriginals , false ) ;
2023-06-18 17:11:35 +02:00
2020-04-08 14:25:01 +02:00
if ( lOriginals . Count = = 1 & & pServiceRecords . Count = = 1 )
2017-06-28 09:00:09 +02:00
{
var srDc = pServiceRecords [ 0 ] ;
var srOrg = lOriginals [ 0 ] ;
var originalStart = srOrg . Start ;
var originalEnde = srOrg . End ;
2020-04-08 14:25:01 +02:00
if ( originalStart . HasValue & & originalEnde . HasValue & & srDc . Start . HasValue & & srDc . End . HasValue )
2017-06-28 09:00:09 +02:00
{
var minutesOrg = originalEnde . Value . Subtract ( originalStart . Value ) . TotalMinutes ;
var minutesNew = srDc . End . Value . Subtract ( srDc . Start . Value ) . TotalMinutes ;
2023-10-25 21:52:23 +02:00
// Start und Ende korrigieren
2020-04-08 14:25:01 +02:00
if ( Math . Abs ( minutesNew - minutesOrg ) < 0.1 & & srDc . Start . Value . Hour = = 0 & & srDc . Start . Value . Minute = = 0 & & srDc . Start . Value . Second = = 0 )
2017-06-28 09:00:09 +02:00
{
2023-10-25 21:52:23 +02:00
// Prüfen, ob korrigiert werden muss
2020-04-08 14:25:01 +02:00
if ( originalStart . Value . Hour ! = 0 | |
2019-09-02 15:48:37 +02:00
originalStart . Value . Minute ! = 0 )
2017-06-28 09:00:09 +02:00
{
srDc . Start = originalStart ;
srDc . End = originalEnde ;
//pServiceRecordGroup.RoundedDuration = (decimal)originalEnde.Value.Subtract(originalStart.Value).TotalMinutes;
}
}
}
}
2019-07-12 12:52:47 +02:00
2016-06-27 01:45:38 +02:00
MapperFactory . ServiceRecordDC_ServiceRecord . MergeWithEntitys ( pServiceRecords , lOriginals ) ;
2023-10-25 21:52:23 +02:00
var serviceRecordDurationCalculator = PluginLoader . FindClass < ServiceRecordDurationCalculator > ( ) ;
var groupDurationCalculator = PluginLoader . FindClass < GroupDurationCalculator > ( ) ;
2019-07-12 12:52:47 +02:00
2024-04-17 16:33:19 +02:00
foreach ( var serviceRecord in lOriginals )
2017-05-18 21:47:09 +02:00
{
2023-10-25 21:52:23 +02:00
serviceRecordDurationCalculator ? . CalculateRoundedDuration ( serviceRecord ) ;
2019-09-02 15:48:37 +02:00
2023-10-25 21:52:23 +02:00
if ( serviceRecord . GroupOid . HasValue & & serviceRecord . GroupPersonCount . HasValue & & serviceRecord . GroupEmployeeCount . HasValue & & groupDurationCalculator ! = null )
2017-06-28 09:00:09 +02:00
{
2023-10-25 21:52:23 +02:00
var groupDuration = groupDurationCalculator . CalculateGroupDuration ( serviceRecord . GroupPersonCount . Value , serviceRecord . GroupEmployeeCount . Value , serviceRecord . RoundedDuration ) ;
2017-06-28 09:00:09 +02:00
2024-04-21 22:40:53 +02:00
var singleduration = Math . Ceiling ( serviceRecord . RoundedDuration / serviceRecord . GroupPersonCount . Value ) ;
2023-10-25 21:52:23 +02:00
if ( groupDuration ! = null )
2017-06-28 09:00:09 +02:00
{
2023-10-25 21:52:23 +02:00
singleduration = groupDuration . SingleDuration ;
2017-06-28 09:00:09 +02:00
}
serviceRecord . RoundedDuration = singleduration ;
}
2017-05-18 21:47:09 +02:00
}
2023-10-25 21:52:23 +02:00
var saveInterceptor = PluginLoader . FindClass < SaveInterceptor > ( ) ;
2024-04-17 16:33:19 +02:00
if ( saveInterceptor ! = null )
2017-06-28 09:00:09 +02:00
{
2024-04-17 16:33:19 +02:00
foreach ( var serviceRecord in lOriginals )
2019-07-12 12:52:47 +02:00
{
2023-10-25 21:52:23 +02:00
saveInterceptor . BeforeSaveServiceRecord ( serviceRecord ) ;
2019-07-12 12:52:47 +02:00
}
}
2019-09-02 15:48:37 +02:00
2019-07-12 12:52:47 +02:00
DAOFactory . GenericDAO . Update ( lOriginals ) ;
2016-06-27 01:45:38 +02:00
2023-10-25 21:52:23 +02:00
var serviceRecords2SignatureStates = GenerateSignatureStates ( serviceRecordsWithDeletedSingleSignatures , serviceRecordsdWithRemovedConfirmationReceiptSignatures , lOriginals ) ; //new List<ServiceRecord2SignatureStates>();
2016-06-27 01:45:38 +02:00
2023-10-25 21:52:23 +02:00
MakeServiceRecordHistoryEntryWithSignatureStates ( serviceRecords2SignatureStates , StatementType . Update ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public bool DoesNotOverlapWithOtherServiceRecord ( ServiceRecordDC pServiceRecord , long customerOid , long? employeeOid )
{
2019-07-12 12:52:47 +02:00
//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)};
2016-06-27 01:45:38 +02:00
2019-07-12 12:52:47 +02:00
//List<ServiceRecord> records = DAOFactory.SearchDAO.FindCustomerServiceRecords(customerOid, span, employeeOid, null).ToList();
2016-06-27 01:45:38 +02:00
2019-07-12 12:52:47 +02:00
//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);
2016-06-27 01:45:38 +02:00
}
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 ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < AdditionalServiceGroupOfPeopleDC > GetAllAdditionalServiceGroupOfPeople ( )
{
try
{
List < AdditionalServiceGroupOfPeopleDC > result =
MapperFactory . AdditionalServiceGroupOfPeopleCD_AdditionalServiceGroupOfPeople . MapToNewDCs (
DAOFactory . GenericDAO . GetAll < AdditionalServiceGroupOfPeople > ( ) ) . ToList ( ) ;
return result ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < AdditionalServiceBookingDC > GetAllAdditionalServiceBookings ( long? regionOid , DateTime start , DateTime end )
{
try
{
2021-07-07 15:05:45 +02:00
//Filtere Customer mit TerminationDate raus
var clist = DAOFactory . GenericDAO . GetAllActiveAndArchived < Customer > ( ) ;
var notAllowedCustomerOids = new List < long > ( ) ;
foreach ( var c in clist )
{
if ( c . TerminationDate . HasValue & & c . TerminationDate . Value < start )
{
notAllowedCustomerOids . Add ( c . Oid . Value ) ;
}
}
2016-06-27 01:45:38 +02:00
List < AdditionalServiceBookingDC > result =
MapperFactory . AdditionalServiceBookingDC_AdditionalServiceBooking . MapToNewDCs (
DAOFactory . SearchDAO . GetAdditionalServiceBookings ( regionOid , start , end ) ) . ToList ( ) ;
2021-07-07 15:05:45 +02:00
foreach ( var booking in result )
{
foreach ( var oid in notAllowedCustomerOids )
{
if ( booking . CustomerOidDict . ContainsKey ( oid ) )
{
booking . CustomerOidDict . Remove ( oid ) ;
}
}
}
2016-06-27 01:45:38 +02:00
return result ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2023-12-20 00:51:44 +01:00
public List < AdditionalServiceNoticeDC > GetAdditionalServiceNoticeList ( long? regionOid , DateTime start , DateTime end )
{
try
{
var result =
MapperFactory . AdditionalServiceNoticeDC_AdditionalServiceNotice . MapToNewDCs (
DAOFactory . SearchDAO . GetAdditionalServiceNoticeList ( regionOid , start , end ) ) . ToList ( ) ;
return result ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < AdditionalServiceNoticeDC > UpdateAdditionalServiceNoticeList ( List < AdditionalServiceNoticeDC > additionalServiceNoticeList )
{
try
{
var newDcs = additionalServiceNoticeList . Where ( dc = > ! dc . Oid . HasValue ) ;
var newEntities = MapperFactory . AdditionalServiceNoticeDC_AdditionalServiceNotice . MapToNewEntities ( newDcs ) ;
DAOFactory . GenericDAO . Insert ( newEntities ) ;
var existingNotices = additionalServiceNoticeList . Where ( dc = > dc . Oid . HasValue ) . ToList ( ) ;
List < AdditionalServiceNotice > originals = DAOFactory . GenericDAO . LoadByIDs < AdditionalServiceNotice > ( existingNotices . Select ( dc = > dc . Oid . Value ) ) ;
MapperFactory . AdditionalServiceNoticeDC_AdditionalServiceNotice . MergeWithEntitys ( existingNotices , originals ) ;
DAOFactory . GenericDAO . Update ( originals ) ;
var result = MapperFactory . AdditionalServiceNoticeDC_AdditionalServiceNotice . MapToNewDCs ( originals ) ;
result . AddRange ( MapperFactory . AdditionalServiceNoticeDC_AdditionalServiceNotice . MapToNewDCs ( newEntities ) ) ;
return result ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2016-06-27 01:45:38 +02:00
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 )
{
2019-07-12 12:52:47 +02:00
var validator = PluginLoader . FindClass < ServiceRecordValidator > ( ) ;
2021-07-05 18:05:43 +02:00
return validator . ValidateGroupServiceRecordEntry ( pServiceRecord , groupServiceRecords , employees , date , maxDaysEditServiceRecordsAllowed , flsTotalRounded , out overlappingRecords , out overlappingEmployees ) ;
2016-06-27 01:45:38 +02:00
}
2017-09-26 12:48:29 +02:00
public List < ServiceRecordValidationResultDC > ValidateServiceRecordEntry ( ServiceRecordDC newServiceRecord , SupportConceptStatisticsDC statistics , int maxDaysEditServiceRecordsAllowed , bool isGroupRecord , IList < long > employeeOids )
2016-06-27 01:45:38 +02:00
{
2017-09-26 12:48:29 +02:00
return ValidateServiceRecord ( newServiceRecord , statistics , maxDaysEditServiceRecordsAllowed , employeeOids , null ) ;
2016-06-27 01:45:38 +02:00
}
2017-09-26 12:48:29 +02:00
public List < ServiceRecordValidationResultDC > ValidateServiceRecord ( ServiceRecordDC newServiceRecord , SupportConceptStatisticsDC statistics , int maxDaysEditServiceRecordsAllowed , IList < long > employeeOids , IList < long > cb2scOids )
2016-06-27 01:45:38 +02:00
{
2019-07-12 12:52:47 +02:00
var validator = PluginLoader . FindClass < ServiceRecordValidator > ( ) ;
return validator . ValidateServiceRecord ( newServiceRecord , statistics , maxDaysEditServiceRecordsAllowed , employeeOids , cb2scOids ) ;
2016-06-27 01:45:38 +02:00
}
2017-02-22 17:59:08 +01:00
public List < ServiceRecordValidationResultDC > ValidateServiceRecordDeletion ( ServiceRecordDC serviceRecord , long employeeOid )
{
var validator = PluginLoader . FindClass < ServiceRecordValidator > ( ) ;
return validator . ValidateServiceRecordDeletion ( serviceRecord , employeeOid ) ;
}
2021-07-05 18:05:43 +02:00
public ServiceRecordValidationResultDC CheckForExistingSignature ( ServiceRecordDC serviceRecord )
{
var validator = PluginLoader . FindClass < ServiceRecordValidator > ( ) ;
return validator . CheckForExistingSignature ( serviceRecord ) ;
}
2024-04-17 16:33:19 +02:00
2024-11-05 14:26:49 +01:00
public CheckObjectDeletionResultDC CheckObjectDeletionAllowed ( long objectoid , TableID tableId )
{
try
{
var s = PluginLoader . FindClass < OperationService > ( ) ;
return s . CheckObjectDeletionAllowed ( objectoid , tableId ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2016-06-27 01:45:38 +02:00
public List < ServiceRecordValidationResult > CheckExistingSettlementInvoices ( ServiceRecordDC pServiceRecord )
{
var result = new List < ServiceRecordValidationResult > ( ) ;
// 6. SettlementInvoiceAlreadyExisting
try
{
IList < SettlementInvoice > allSettlementInvoices = DAOFactory . GenericDAO . GetAll < SettlementInvoice > ( ) ;
2020-04-08 14:25:01 +02:00
foreach ( SettlementInvoice rechnung in allSettlementInvoices )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
if ( rechnung . InvoiceBase . CostBearer2SupportConcept . Oid . HasValue )
if ( rechnung . InvoiceBase . CostBearer2SupportConcept . Oid . Value . Equals ( pServiceRecord . CostBearer2SupportConceptOid . Value ) & & rechnung . IsActive . Equals ( ActivationTypeId . Active ) )
2016-06-27 01:45:38 +02:00
{
result . Add ( ServiceRecordValidationResult . SettlementInvoiceAlreadyExisting ) ;
break ;
}
}
}
2020-04-08 14:25:01 +02:00
catch ( Exception )
2016-06-27 01:45:38 +02:00
{
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 ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public ServiceRecordDC GetServiceRecordById ( long pId )
{
try
{
var sr = DAOFactory . GenericDAO . GetByID < ServiceRecord > ( pId ) ;
2020-04-08 14:25:01 +02:00
if ( sr = = null )
2016-06-27 01:45:38 +02:00
return null ;
ServiceRecordDC result = MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDC ( sr ) ;
return result ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < FileAttachmentDC > GetFileAttachmentInfoByType ( FileAttachmentType fileAttachmentType )
{
try
{
return MapperFactory . FileAttachmentDC_FileAttachmentInfo . MapToNewDCs ( DAOFactory . SearchDAO . FindFileAttachmentInfoByType ( fileAttachmentType ) ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < ServiceRecordDC > GetActiveServiceRecordsBySupportConcept ( long pSupportConceptOid )
{
try
{
return MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDCs ( DAOFactory . SearchDAO . FindServiceRecordsForSupportConcept ( pSupportConceptOid ) ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void InsertBeWoMobilBrowserInfo ( BeWoMobilBrowserInfoDC browserInfo )
{
try
{
BeWoMobilBrowserInfo info = MapperFactory . BeWoMobilBrowserInfoDC_BeWoMobilBrowserInfo . MapToNewEntity ( browserInfo ) ;
DAOFactory . GenericDAO . Insert ( info ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ) ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public IEnumerable < CompactSupportConceptDC > GetCompactSupportConcepts ( long supportConceptOid , long? employeeOid )
{
try
{
2019-07-12 12:52:47 +02:00
var s = PluginLoader . FindClass < CustomerService > ( ) ;
return s . GetCompactSupportConcepts ( supportConceptOid , employeeOid ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-09-26 12:48:29 +02:00
private static ServiceRecordDC CreateServiceRecordDCCompact ( ServiceRecord sr )
2016-06-27 01:45:38 +02:00
{
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 ;
2020-04-08 14:25:01 +02:00
if ( sr . ServiceDescription ! = null )
2016-06-27 01:45:38 +02:00
dc . ServiceDescription = MapperFactory . ServiceDescriptionDC_ServiceDescription . MapToNewDC ( sr . ServiceDescription ) ;
2019-07-12 12:52:47 +02:00
2016-06-27 01:45:38 +02:00
dc . RoundedDuration = sr . RoundedDuration ;
2019-07-12 12:52:47 +02:00
2022-11-09 09:44:24 +01:00
dc . DistanceInMeter = ( int? ) sr . DistanceInMeter ;
dc . DistanceInMeterDecimal = sr . DistanceInMeter ;
2020-10-27 12:29:59 +01:00
dc . Betrag = sr . Betrag ;
2016-06-27 01:45:38 +02:00
dc . InsertedOn = sr . InsTs ;
dc . InsUser = sr . InsUser ;
2017-02-01 09:24:33 +01:00
dc . DurationInStunden = sr . DurationInStunden ;
2017-03-08 13:05:45 +01:00
dc . ServiceRecordFormat = sr . ServiceRecordFormat ;
2016-06-27 01:45:38 +02:00
dc . GroupEmployeeCount = sr . GroupEmployeeCount ;
dc . GroupPersonCount = sr . GroupPersonCount ;
dc . GroupRoundedDuration = sr . GroupRoundedDuration ;
dc . ServiceRecordType = sr . ServiceRecordType ? ? ServiceRecordTypeId . DefaultActivity ;
dc . GroupOid = sr . GroupOid ;
2017-02-15 10:54:29 +01:00
dc . SignatureOid = sr . SignatureOid ;
2016-06-27 01:45:38 +02:00
2021-02-22 10:14:07 +01:00
if ( sr . GroupOid . HasValue )
{
dc . BackgroundColor = "#FFFDC784" ;
}
if ( sr . ServiceRecordType . HasValue & & sr . ServiceRecordType . Value = = ServiceRecordTypeId . Content )
{
2021-02-24 11:00:38 +01:00
dc . BackgroundColor = "#FF78BFFF" ;
2021-02-22 10:14:07 +01:00
}
2024-04-17 16:33:19 +02:00
2020-04-08 14:25:01 +02:00
if ( sr . Employee ! = null )
2016-06-27 01:45:38 +02:00
{
//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 ;
}
2017-02-01 09:24:33 +01:00
//if(sr.DurationInStunden == ZeiterfassungsDauer.Stunden)
// dc.RoundedDuration = sr.RoundedDuration /60;
//else
// dc.RoundedDuration = sr.RoundedDuration;
2016-06-27 01:45:38 +02:00
//Goals -------------------------
var list = new List < ValueListEntryType > ( ) ;
list . Add ( ValueListEntryType . SupportConceptGoalType ) ;
2019-07-12 12:52:47 +02:00
list . Add ( ValueListEntryType . SupportConceptGoalCategoryType ) ;
list . Add ( ValueListEntryType . SupportConceptIndividualGoalCategoryType ) ;
2016-06-27 01:45:38 +02:00
list . Add ( ValueListEntryType . SupportConceptIndividualGoalType ) ;
2019-10-10 22:07:42 +02:00
dc . Goals = new List < ValueListEntryDC > ( ) ;
foreach ( var v2o in sr . ValueList . FindByTypes ( list ) )
{
var entryDc = MapperFactory . ValueListEntryDC_ValueListEntry . MapToNewDC ( v2o . Entry ) ;
2020-08-17 15:50:00 +02:00
entryDc . RatingTypeOid = v2o . RatingTypeOid ;
2024-07-01 12:44:07 +02:00
//CB 1.7.24: Nach nächstem Update wieder rausnehmen:
if ( entryDc . ParentOid . HasValue )
{
var p = DAOFactory . GenericDAO . LoadByID < ValueListEntry > ( entryDc . ParentOid . Value ) ;
if ( p . IsActive ! = ActivationTypeId . Active )
{
entryDc . Parent = null ;
entryDc . ParentOid = null ;
}
}
//###########
2019-10-10 22:07:42 +02:00
dc . Goals . Add ( entryDc ) ;
}
2020-04-08 14:25:01 +02:00
2016-06-27 01:45:38 +02:00
return dc ;
}
2017-09-26 12:48:29 +02:00
private static ServiceRecordDC CreateServiceRecordDCIfSupportConceptIsActive ( ServiceRecord sr , Customer cust , bool checkArchivedSupportConcepts )
2016-06-27 01:45:38 +02:00
{
ServiceRecordDC dc = null ;
2020-04-08 14:25:01 +02:00
if ( ! checkArchivedSupportConcepts | | ( sr . SupportConcept ! = null & & sr . SupportConcept . IsActive = = ActivationTypeId . Active ) )
2016-06-27 01:45:38 +02:00
{
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 ;
2020-04-08 14:25:01 +02:00
if ( sr . ServiceDescription ! = null )
2016-06-27 01:45:38 +02:00
dc . ServiceDescription = MapperFactory . ServiceDescriptionDC_ServiceDescription . MapToNewDC ( sr . ServiceDescription ) ;
dc . RoundedDuration = sr . RoundedDuration ;
dc . InsertedOn = sr . InsTs ;
dc . InsUser = sr . InsUser ;
2017-02-01 09:24:33 +01:00
dc . DurationInStunden = sr . DurationInStunden ;
2017-02-14 13:55:40 +01:00
dc . SignatureOid = sr . SignatureOid ;
2017-03-08 13:05:45 +01:00
dc . ServiceRecordFormat = sr . ServiceRecordFormat ;
2016-06-27 01:45:38 +02:00
//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 -----------------
2020-04-08 14:25:01 +02:00
if ( sr . Employee ! = null )
2016-06-27 01:45:38 +02:00
{
//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 -----------------
2020-04-08 14:25:01 +02:00
if ( sr . SupportConcept ! = null )
2016-06-27 01:45:38 +02:00
{
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 -----------------
2020-04-08 14:25:01 +02:00
if ( sr . CostBearer2SupportConcept ! = null )
2016-06-27 01:45:38 +02:00
{
dc . CostBearer2SupportConceptOid = sr . CostBearer2SupportConcept . Oid . Value ;
2020-04-08 14:25:01 +02:00
if ( dc . SupportConcept ! = null )
2016-06-27 01:45:38 +02:00
{
var costBearer = new CompactCostBearerDC ( ) ;
2020-04-08 14:25:01 +02:00
if ( sr . CostBearer2SupportConcept . CostBearer . Organisation ! = null )
2016-06-27 01:45:38 +02:00
{
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 ;
}
2019-09-02 15:48:37 +02:00
2016-06-27 01:45:38 +02:00
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 ) ;
}
2020-04-08 14:25:01 +02:00
if ( dc . CostBearer = = null )
2016-06-27 01:45:38 +02:00
{
2020-04-08 14:25:01 +02:00
if ( sr . CostBearer2SupportConcept . CostBearer . Organisation ! = null )
2016-06-27 01:45:38 +02:00
dc . CostBearer = MapperFactory . CompactOrganisationDC_Organisation . MapToNewDC ( sr . CostBearer2SupportConcept . CostBearer . Organisation ) ;
}
}
//Goals -------------------------
var list = new List < ValueListEntryType > ( ) ;
2019-07-12 12:52:47 +02:00
list . Add ( ValueListEntryType . SupportConceptGoalType ) ;
list . Add ( ValueListEntryType . SupportConceptGoalCategoryType ) ;
list . Add ( ValueListEntryType . SupportConceptIndividualGoalCategoryType ) ;
list . Add ( ValueListEntryType . SupportConceptIndividualGoalType ) ;
2016-06-27 01:45:38 +02:00
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 ;
}
2019-09-02 15:48:37 +02:00
2016-06-27 01:45:38 +02:00
return dc ;
}
2017-09-26 12:48:29 +02:00
public static Dictionary < string , string > GetSettingsValueDict ( string settings )
2016-06-27 01:45:38 +02:00
{
var dict = new Dictionary < String , String > ( ) ;
2020-04-08 14:25:01 +02:00
if ( ! String . IsNullOrEmpty ( settings ) )
2016-06-27 01:45:38 +02:00
{
string [ ] keyValuePairs = settings . Split ( ';' ) ;
2020-04-08 14:25:01 +02:00
foreach ( string pair in keyValuePairs )
2016-06-27 01:45:38 +02:00
{
string [ ] keyValuePair = pair . Split ( '=' ) ;
2020-04-08 14:25:01 +02:00
if ( keyValuePair . Length = = 2 )
2016-06-27 01:45:38 +02:00
{
dict . Add ( keyValuePair [ 0 ] , keyValuePair [ 1 ] ) ;
}
}
}
return dict ;
}
2023-05-02 14:24:26 +02:00
2017-09-26 12:48:29 +02:00
private static string GetContractState ( )
2016-06-27 01:45:38 +02:00
{
try
{
2023-05-02 14:24:26 +02:00
String responseStr = "" ;
String tenant = "" ;
String typ = "&t=0" ;
2020-04-08 14:25:01 +02:00
if ( MultitenancyOperationContextExt . Current ! = null )
2018-05-21 16:39:24 +02:00
{
2023-05-02 14:24:26 +02:00
tenant = MultitenancyOperationContextExt . Current . Tenant ;
2018-05-21 16:39:24 +02:00
}
else
{
2023-05-02 14:24:26 +02:00
tenant = SessionFacade . Tenant ;
typ = "&t=1" ;
}
2024-04-17 16:33:19 +02:00
2023-05-02 14:24:26 +02:00
if ( String . IsNullOrEmpty ( tenant ) )
{
return "" ;
2018-05-21 16:39:24 +02:00
}
2019-09-02 15:48:37 +02:00
2023-05-02 14:24:26 +02:00
Monitor . Enter ( _Lock ) ;
2019-07-12 12:52:47 +02:00
2023-05-02 14:24:26 +02:00
if ( _ContractStateDate . ContainsKey ( tenant ) )
2016-06-27 01:45:38 +02:00
{
2023-05-02 14:24:26 +02:00
DateTime oldDate = _ContractStateDate [ tenant ] ;
if ( DateTime . Now . Subtract ( oldDate ) . TotalMinutes > 5 )
{
//Aktualisiere ContractState alle 5 Minuten
_ContractStates . Remove ( tenant ) ;
_ContractStateDate . Remove ( tenant ) ;
}
}
if ( ! _ContractStates . ContainsKey ( tenant ) )
2024-04-17 16:33:19 +02:00
{
2023-05-02 14:24:26 +02:00
string url = ConfigurationManager . AppSettings . Get ( "ContractStateUrl" ) ;
url = url . Replace ( "[TENANT]" , tenant ) ;
url + = typ ;
2016-06-27 01:45:38 +02:00
2023-05-02 14:24:26 +02:00
using ( var client = new WebClient ( ) )
{
//MessageBox.Show(hostAddress);
byte [ ] response = client . DownloadData ( url ) ;
responseStr = Encoding . ASCII . GetString ( response ) ;
_ContractStates [ tenant ] = responseStr ;
_ContractStateDate [ tenant ] = DateTime . Now ;
}
}
else
{
responseStr = _ContractStates [ tenant ] ;
2016-06-27 01:45:38 +02:00
}
2023-05-02 14:24:26 +02:00
return responseStr ;
2016-06-27 01:45:38 +02:00
}
2023-05-02 14:24:26 +02:00
catch ( Exception e )
{
2023-09-08 15:52:55 +02:00
return "Fehler" ;
2023-05-02 14:24:26 +02:00
}
finally
2016-06-27 01:45:38 +02:00
{
2023-05-02 14:24:26 +02:00
Monitor . Exit ( _Lock ) ;
2016-06-27 01:45:38 +02:00
}
2023-05-02 14:24:26 +02:00
return "" ;
2016-06-27 01:45:38 +02:00
}
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 ( ) ;
2020-04-08 14:25:01 +02:00
if ( srListToDelete . Count > 0 )
2016-06-27 01:45:38 +02:00
DAOFactory . GenericDAO . Delete ( srListToDelete ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
private static void AttachAddServiceToAssessment ( AdditionalServiceBooking pAdditionalServiceBookingDC )
{
try
{
2020-04-08 14:25:01 +02:00
var newCategoryDC = new AssessmentSheetCategoryDC { Description = pAdditionalServiceBookingDC . AdditionalServiceRegion . AdditionalService . Name } ;
2016-06-27 01:45:38 +02:00
AssessmentSheetCategory lCategory = MapperFactory . AssessmentSheetCategoryDC_AssessmentSheetCategory . MapToNewEntity ( newCategoryDC ) ;
lCategory . SystemEntryID = SystemEntryID . AdditionalServiceAssessmentSheet ;
AssessmentSheetCategory cat = DAOFactory . SearchDAO . GetAddServiceAssessmentSheetCategoryWithName ( lCategory . Description ) ;
2020-04-08 14:25:01 +02:00
if ( cat = = null )
2016-06-27 01:45:38 +02:00
{
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
} ;
2020-04-08 14:25:01 +02:00
if ( ! yesExists )
2016-06-27 01:45:38 +02:00
{
DAOFactory . GenericDAO . Insert ( lYes ) ;
}
else
{
lYes = values . First (
c = >
c . SystemEntryID . Equals ( SystemEntryID . AdditionalServiceAssessmentSheet ) & &
c . Description . Equals ( lYes . Description ) ) ;
}
2020-04-08 14:25:01 +02:00
if ( ! noExists )
2016-06-27 01:45:38 +02:00
{
DAOFactory . GenericDAO . Insert ( lNo ) ;
}
else
{
lNo = values . First (
c = >
c . SystemEntryID . Equals ( SystemEntryID . AdditionalServiceAssessmentSheet ) & &
c . Description . Equals ( lNo . Description ) ) ;
}
2020-04-08 14:25:01 +02:00
if ( ! lCategory . PossibleValues . Contains ( lYes ) )
2016-06-27 01:45:38 +02:00
DAOFactory . AdoDAO . ExecuteQuery ( string . Format ( "INSERT INTO assessmentsheetcategory2assessmentsheetvalue(assessmentsheetcategoryoid, assessmentsheetvalueoid) VALUES({0}, {1})" , lCategory . Oid . Value , lYes . Oid . Value ) ) ;
2020-04-08 14:25:01 +02:00
if ( ! lCategory . PossibleValues . Contains ( lNo ) )
2016-06-27 01:45:38 +02:00
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 ;
2020-04-08 14:25:01 +02:00
foreach ( Customer2AddServiceBooking customerParticipated in pAdditionalServiceBookingDC . Customer2AddServiceBookings )
2016-06-27 01:45:38 +02:00
{
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 ) ) ;
2020-04-08 14:25:01 +02:00
if ( f . Customers = = null | | ! f . Customers . Contains ( customer ) )
2016-06-27 01:45:38 +02:00
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 ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2023-10-25 21:52:23 +02:00
// ToDo: Unterschriftenbemerkung hier einbauen
private static void MakeServiceRecordHistoryEntry ( List < ServiceRecord > lOriginals , IEnumerable < long > serviceRecordOidList , StatementType statementType )
2016-06-27 01:45:38 +02:00
{
2023-10-25 21:52:23 +02:00
var serviceRecordHistoryEntries = new List < ServiceRecordHistory > ( ) ;
2016-06-27 01:45:38 +02:00
2020-04-08 14:25:01 +02:00
if ( statementType . Equals ( StatementType . Insert ) & & serviceRecordOidList ! = null )
2016-06-27 01:45:38 +02:00
{
2023-10-25 21:52:23 +02:00
var iterator = 0 ;
2024-11-12 18:37:23 +01:00
foreach ( var history in lOriginals . Select ( serviceRecordOriginal = > new ServiceRecordHistory
2023-10-25 21:52:23 +02:00
{
2024-11-12 18:37:23 +01:00
TimeStamp = DateTime . Now ,
ChangeType = statementType ,
CostBearer2SupportConcept = serviceRecordOriginal . CostBearer2SupportConcept ,
2023-10-25 21:52:23 +02:00
CostBearer2SupportConceptOid = serviceRecordOriginal . CostBearer2SupportConceptOid ,
2024-11-12 18:37:23 +01:00
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 ? ? 0 ,
ServiceRecordInsUser = serviceRecordOriginal . InsUser ,
ServiceRecordUdpUser = serviceRecordOriginal . UdpUser ,
Start = serviceRecordOriginal . Start ,
SupportConcept = serviceRecordOriginal . SupportConcept ,
SystemEntryID = serviceRecordOriginal . SystemEntryID ,
DistanceInMeter = serviceRecordOriginal . DistanceInMeter ,
IsCreatedInMobileClient = serviceRecordOriginal . IsCreatedInMobileClient
2016-06-27 01:45:38 +02:00
} ) )
{
iterator + + ;
2023-10-25 21:52:23 +02:00
serviceRecordHistoryEntries . Add ( history ) ;
2016-06-27 01:45:38 +02:00
}
}
else
{
2024-11-12 18:37:23 +01:00
foreach ( var original in lOriginals )
2016-06-27 01:45:38 +02:00
{
2023-11-02 16:25:36 +01:00
SignatureStateInfoFromServiceRecordHistoryEntry previousRecordHistorySignatureInfo = null ;
2023-10-25 21:52:23 +02:00
2024-04-17 16:33:19 +02:00
if ( original . Oid . HasValue )
2023-10-25 21:52:23 +02:00
{
2023-11-02 16:25:36 +01:00
previousRecordHistorySignatureInfo = DAOFactory . SearchDAO . FindMostRecentSignatureStatusInfoByServiceRecordOid ( original . Oid . Value ) ;
2023-10-25 21:52:23 +02:00
}
serviceRecordHistoryEntries . AddIfNotIn ( new ServiceRecordHistory
{
2024-11-12 18:37:23 +01:00
TimeStamp = DateTime . Now ,
ChangeType = statementType ,
CostBearer2SupportConcept = original . CostBearer2SupportConcept ,
CostBearer2SupportConceptOid = original . CostBearer2SupportConceptOid ,
Customer = original . Customer ,
CustomerOid = original . CustomerOid ,
Employee = original . Employee ,
EmployeeOid = original . EmployeeOid ,
End = original . End ,
Group = original . Group ,
GroupEmployeeCount = original . GroupEmployeeCount ,
GroupOid = original . GroupOid ,
GroupPersonCount = original . GroupPersonCount ,
GroupRoundedDuration = original . GroupRoundedDuration ,
IP = original . IP ,
IsActive = original . IsActive ,
Notice = original . Notice ,
ServiceRecordOid = original . Oid ,
RoundedDuration = original . RoundedDuration ,
ServiceDescription = original . ServiceDescription ,
ServiceRecordType = original . ServiceRecordType ,
ServiceRecordInsTs = original . InsTs ,
ServiceRecordVersion = original . Version ? ? 0 ,
ServiceRecordInsUser = original . InsUser ,
ServiceRecordUdpUser = original . UdpUser ,
Start = original . Start ,
SupportConcept = original . SupportConcept ,
SystemEntryID = original . SystemEntryID ,
DistanceInMeter = original . DistanceInMeter ,
IsCreatedInMobileClient = original . IsCreatedInMobileClient ,
ServiceRecordSignatureStateType = previousRecordHistorySignatureInfo ? . ServiceRecordSignatureStateType ? ? SignatureStateType . None ,
2023-11-02 16:25:36 +01:00
CustomerConfirmationReceiptSignatureStateType = previousRecordHistorySignatureInfo ? . CustomerConfirmationReceiptSignatureStateType ? ? SignatureStateType . None ,
EmployeeConfirmationReceiptSignatureStateType = previousRecordHistorySignatureInfo ? . EmployeeConfirmationReceiptSignatureStateType ? ? SignatureStateType . None ,
2024-11-12 18:37:23 +01:00
CustomerConfirmationReceiptSignatureOid = previousRecordHistorySignatureInfo ? . CustomerConfirmationReceiptSignatureOid ,
EmployeeConfirmationReceiptSignatureOid = previousRecordHistorySignatureInfo ? . EmployeeConfirmationReceiptSignatureOid
2023-10-25 21:52:23 +02:00
} ) ;
}
2016-06-27 01:45:38 +02:00
}
2023-10-25 21:52:23 +02:00
DAOFactory . GenericDAO . Insert ( serviceRecordHistoryEntries ) ;
2016-06-27 01:45:38 +02:00
}
2019-07-12 12:52:47 +02:00
2017-09-26 12:48:29 +02:00
public IList < TextModuleDC > GetAllTextModules ( )
2016-06-27 01:45:38 +02:00
{
try
{
2023-03-29 15:49:20 +02:00
var allTextModules = DAOFactory . GenericDAO . GetAll < TextModule > ( ) ;
return MapperFactory . TextModuleDC_TextModule . CreateDcList ( allTextModules ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
public IList < TextModuleDC > GetTextModules ( bool pShouldShowAllTextModules , long pEmployeeOid , bool pHasRightToSeeAllTextModules , bool pIsInAdministrationView )
{
try
{
2020-12-30 02:46:55 +01:00
var textmodules = DAOFactory . SearchDAO . GetActiveTextModules ( pShouldShowAllTextModules , pHasRightToSeeAllTextModules , pIsInAdministrationView , pEmployeeOid ) ;
2022-12-30 16:28:23 +01:00
var abc = textmodules . FirstOrDefault ( f = > f . Oid = = 41 ) ;
var isActive = abc ? . IsActive ;
2020-12-30 02:46:55 +01:00
var list = MapperFactory . TextModuleDC_TextModule . CreateDcList ( textmodules ) ;
2022-12-30 16:28:23 +01:00
var abcDC = list . FirstOrDefault ( f = > f . TextModuleOid = = 41 ) ;
var activationType = abcDC ? . ActivationType ;
2019-07-12 12:52:47 +02:00
return list . OrderBy ( t = > t . Name ) . ToList ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2019-07-12 12:52:47 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-09-26 12:48:29 +02:00
2019-07-12 12:52:47 +02:00
public IList < TextModuleDC > GetTextModulesByServiceCategory ( long pServiceCategoryOid )
2016-06-27 01:45:38 +02:00
{
try
{
2017-11-17 22:24:00 +01:00
return MapperFactory . TextModuleDC_TextModule . MapToNewDCs ( DAOFactory . SearchDAO . GetActiveTextModuleByServiceCategory ( pServiceCategoryOid ) ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-09-26 12:48:29 +02:00
public IList < long > InsertNewTextModules ( IEnumerable < TextModuleDC > pTextbausteine )
2016-06-27 01:45:38 +02:00
{
try
{
2017-09-26 12:48:29 +02:00
var lTextbausteine = MapperFactory . TextModuleDC_TextModule . MapToNewEntities ( pTextbausteine ) ;
2020-11-11 23:26:35 +01:00
foreach ( var tm in lTextbausteine )
{
tm . IsActive = ActivationTypeId . Active ;
}
2016-06-27 01:45:38 +02:00
DAOFactory . GenericDAO . Insert ( lTextbausteine ) ;
return lTextbausteine . Select ( asb = > asb . Oid . Value ) . ToList ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-09-26 12:48:29 +02:00
public void UpdateTextModules ( List < TextModuleDC > pTextbausteine )
2016-06-27 01:45:38 +02:00
{
try
{
2017-09-26 12:48:29 +02:00
var lOriginals = DAOFactory . GenericDAO . LoadByIDs < TextModule > ( pTextbausteine . Select ( sc = > sc . TextModuleOid . Value ) ) ;
2022-12-28 23:57:47 +01:00
foreach ( var item in pTextbausteine )
{
item . ActivationType = ActivationTypeId . Active ;
}
2017-09-26 12:48:29 +02:00
MapperFactory . TextModuleDC_TextModule . MergeWithEntitys ( pTextbausteine , lOriginals ) ;
2016-06-27 01:45:38 +02:00
DAOFactory . GenericDAO . Update ( lOriginals ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-09-26 12:48:29 +02:00
public void DeleteTextModules ( Dictionary < long , long > pOid2Version )
2016-06-27 01:45:38 +02:00
{
try
{
2017-09-26 12:48:29 +02:00
var lOriginals = DAOFactory . GenericDAO . LoadByIDs < TextModule > ( pOid2Version . Select ( e = > e . Key ) ) ;
lOriginals . DoForEach ( or = > MapperFactory . TextModuleDC_TextModule . ConcurrencyCheck ( pOid2Version [ or . Oid . Value ] , or ) ) ;
2016-06-27 01:45:38 +02:00
2018-10-08 11:57:16 +02:00
IList < TextModule > modulesToDelete = new List < TextModule > ( ) ;
2020-04-08 14:25:01 +02:00
foreach ( var textModule in lOriginals )
2018-10-08 11:57:16 +02:00
{
AddModuleAndChildsToList ( textModule , modulesToDelete ) ;
}
2019-09-02 15:48:37 +02:00
2019-07-12 12:52:47 +02:00
DAOFactory . GenericDAO . Delete ( modulesToDelete ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2018-10-08 11:57:16 +02:00
private void AddModuleAndChildsToList ( TextModule textModule , IList < TextModule > modulesToDelete )
{
var children = DAOFactory . SearchDAO . GetChildTextModules ( textModule ) ;
2020-04-08 14:25:01 +02:00
foreach ( var child in children )
2018-10-08 11:57:16 +02:00
{
AddModuleAndChildsToList ( child , modulesToDelete ) ;
}
2019-09-02 15:48:37 +02:00
2018-10-08 11:57:16 +02:00
modulesToDelete . Add ( textModule ) ;
}
public IList < ServiceRecordDC > FindServiceRecordsInSpan ( long pCostBearer2SupportConceptOid , DateTimeSpan period )
2019-07-12 12:52:47 +02:00
{
try
{
var records = DAOFactory . SearchDAO . FindServiceRecordsInSpan ( pCostBearer2SupportConceptOid , period ) ;
return MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDCs ( records ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2019-07-12 12:52:47 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2016-06-27 01:45:38 +02:00
public SignatureDC InsertSignature ( SignatureDC s )
{
try
{
var lSignature = MapperFactory . SignatureDC_Signature . MapToNewEntity ( s ) ;
DAOFactory . GenericDAO . Insert ( lSignature ) ;
2023-04-24 19:20:02 +02:00
var updatedSignatureDC = MapperFactory . SignatureDC_Signature . MapToNewDC ( lSignature ) ;
2016-06-27 01:45:38 +02:00
2024-04-17 16:33:19 +02:00
if ( s . ServiceRecordOid is null )
2016-06-27 01:45:38 +02:00
{
2024-04-17 16:33:19 +02:00
if ( s . BargeldtransaktionsOid . HasValue )
2024-02-20 14:42:04 +01:00
{
var transaction = DAOFactory . GenericDAO . LoadByID < Bargeldtransaktion > ( s . BargeldtransaktionsOid . Value ) ;
CreateTransactionHistoryObject ( transaction , StatementType . Signature , SignatureStateType . Valid ) ;
}
2023-04-24 19:20:02 +02:00
return updatedSignatureDC ;
}
2016-06-27 01:45:38 +02:00
2023-04-24 19:20:02 +02:00
var sr = DAOFactory . GenericDAO . LoadByID < ServiceRecord > ( s . ServiceRecordOid . Value ) ;
2016-06-27 01:45:38 +02:00
2023-04-24 19:20:02 +02:00
sr . SignatureOid = lSignature . Oid ;
DAOFactory . GenericDAO . Update ( sr ) ;
2016-06-27 01:45:38 +02:00
2023-10-28 13:34:32 +02:00
MakeSignatureStatusTypeServiceRecordHistoryEntry ( sr , SignatureStateType . Valid , null , null , null , null ) ;
2023-10-25 21:52:23 +02:00
2016-06-27 01:45:38 +02:00
return updatedSignatureDC ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-11-14 10:46:54 +01:00
public EmployeeAPPCodeDC CreateNewEmployeeAPPCodeDC ( long employeeOid , string kundennummer , string apikey )
2019-07-12 12:52:47 +02:00
{
2016-06-27 01:45:38 +02:00
try
{
2017-11-13 16:37:21 +01:00
#if DEBUG
kundennummer = "0000000001" ;
apikey = "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97" ;
#endif
2020-04-14 11:49:16 +02:00
var appCodes = DAOFactory . SearchDAO . FindAllEmployeeAppCodes ( employeeOid ) . ToList ( ) ;
2016-08-05 12:48:13 +02:00
2021-05-17 14:01:06 +02:00
if ( appCodes . Any ( c = > ! string . IsNullOrWhiteSpace ( c . EmployeeCode ) ) )
2016-08-05 12:48:13 +02:00
{
2017-11-16 15:37:29 +01:00
var response = DeletZufallsCode ( apikey , kundennummer , "E" + employeeOid ) ;
2016-08-05 12:48:13 +02:00
2020-10-13 14:35:06 +02:00
if ( response ! = 0 )
2017-11-13 16:37:21 +01:00
{
2020-08-19 12:15:10 +02:00
return new EmployeeAPPCodeDC { Result = response } ;
2017-11-13 16:37:21 +01:00
}
2017-11-16 15:37:29 +01:00
}
2020-04-16 15:57:01 +02:00
var zufallscode = ErzeugeZufallsCode ( apikey , kundennummer , "E" + employeeOid ) ;
2017-11-16 15:37:29 +01:00
2020-10-13 14:35:06 +02:00
if ( zufallscode ! = null )
2019-07-12 12:52:47 +02:00
{
2020-04-16 15:57:01 +02:00
var appcodes = DAOFactory . SearchDAO . FindAllEmployeeAppCodes ( employeeOid ) . ToList ( ) ;
2017-11-16 15:37:29 +01:00
2020-08-19 12:15:10 +02:00
var newCode = appcodes . Count > 0 ? appcodes [ 0 ] : new EmployeeAPPCode { EmployeeOid = employeeOid } ;
2017-11-16 15:37:29 +01:00
2020-08-19 12:15:10 +02:00
newCode . EmployeeCode = zufallscode ;
2020-04-16 15:57:01 +02:00
newCode . EmployeeCodeGenDate = DateTime . Now ;
2020-08-19 12:15:10 +02:00
newCode . NotfallStatement = string . Empty ;
newCode . IsChatAktiv = 1 ;
2019-07-12 12:52:47 +02:00
2020-04-16 15:57:01 +02:00
DAOFactory . GenericDAO . Insert ( newCode ) ;
2016-06-27 01:45:38 +02:00
2021-05-17 14:01:06 +02:00
var employeeAppCodeDC = MapperFactory . EmployeeAPPCodeDC_EmployeeAPPCode . MapToNewDC ( newCode ) ;
2016-06-27 01:45:38 +02:00
2021-05-17 14:01:06 +02:00
return employeeAppCodeDC ;
2017-10-06 12:06:34 +02:00
}
return null ;
2016-06-27 01:45:38 +02:00
}
2020-10-13 14:35:06 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2016-08-05 12:48:13 +02:00
public void UpdateIsChatActiveEmployeeAPPCodeDC ( long employeeOid , int activeType )
2016-06-27 01:45:38 +02:00
{
try
2016-08-05 12:48:13 +02:00
{
2020-04-16 15:57:01 +02:00
var employeecode = DAOFactory . SearchDAO . FindAllEmployeeAppCodes ( employeeOid ) . ToList ( ) ;
2016-06-27 01:45:38 +02:00
2020-04-08 14:25:01 +02:00
foreach ( var items in employeecode )
2016-08-05 12:48:13 +02:00
{
2020-04-16 15:57:01 +02:00
items . IsChatAktiv = activeType = = 1 ? activeType : 0 ;
2016-08-05 12:48:13 +02:00
}
2016-06-27 01:45:38 +02:00
2016-08-05 12:48:13 +02:00
DAOFactory . GenericDAO . Update ( employeecode ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2016-08-05 12:48:13 +02:00
public void UpdateNotfallNacrichtEmployeeAPPCodeDC ( long employeeOid , String notfallstate )
2016-06-27 01:45:38 +02:00
{
try
{
2020-04-16 15:57:01 +02:00
var employeecode = DAOFactory . SearchDAO . FindAllEmployeeAppCodes ( employeeOid ) . ToList ( ) ;
2016-06-27 01:45:38 +02:00
2020-04-08 14:25:01 +02:00
foreach ( var items in employeecode )
2016-08-05 12:48:13 +02:00
{
items . NotfallStatement = notfallstate ;
}
2016-06-27 01:45:38 +02:00
2019-07-12 12:52:47 +02:00
DAOFactory . GenericDAO . Update ( employeecode ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-11-14 10:46:54 +01:00
2019-07-12 12:52:47 +02:00
public CustomerAPPCodeDC CreateNewCustomerAPPCodeDC ( long customerOid , string kundennummer , string apikey )
2016-06-27 01:45:38 +02:00
{
try
{
2017-11-06 10:30:25 +01:00
#if DEBUG
2017-11-13 16:37:21 +01:00
kundennummer = "0000000001" ;
2017-11-06 10:30:25 +01:00
apikey = "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97" ;
#endif
2016-08-05 12:48:13 +02:00
2017-11-16 15:37:29 +01:00
var aa = DAOFactory . SearchDAO . FindAllCustomerAppCodes ( customerOid ) . ToList ( ) ;
bool isOk = false ;
2020-04-08 14:25:01 +02:00
if ( aa . Where ( c = > ! String . IsNullOrWhiteSpace ( c . CustomerCode ) ) . Count ( ) > 0 )
2016-08-05 12:48:13 +02:00
{
2017-11-16 15:37:29 +01:00
var response = DeletZufallsCode ( apikey , kundennummer , "C" + customerOid ) ;
2020-04-08 14:25:01 +02:00
if ( response = = 0 )
2017-10-06 12:06:34 +02:00
{
2017-11-16 15:37:29 +01:00
isOk = true ;
2017-10-06 12:06:34 +02:00
}
2017-11-06 10:30:25 +01:00
else
{
2017-11-16 15:37:29 +01:00
CustomerAPPCodeDC appcode = new CustomerAPPCodeDC ( ) ;
2017-10-06 12:06:34 +02:00
2017-11-16 15:37:29 +01:00
appcode . Result = response ;
2017-10-06 12:06:34 +02:00
2017-11-16 15:37:29 +01:00
return appcode ;
}
}
else
{
isOk = true ;
}
2017-11-06 10:30:25 +01:00
2019-07-12 12:52:47 +02:00
2020-04-08 14:25:01 +02:00
if ( isOk )
2017-11-16 15:37:29 +01:00
{
string zufallscode = ErzeugeZufallsCode ( apikey , kundennummer , "C" + customerOid ) ;
2017-10-06 12:06:34 +02:00
2020-04-08 14:25:01 +02:00
if ( zufallscode ! = null )
2017-11-16 15:37:29 +01:00
{
var appcodes = DAOFactory . SearchDAO . FindAllCustomerAppCodes ( customerOid ) . ToList ( ) ;
CustomerAPPCode newCode = null ;
2020-04-08 14:25:01 +02:00
if ( appcodes . Count > 0 )
2017-11-16 15:37:29 +01:00
{
newCode = appcodes [ 0 ] ;
}
else
{
newCode = new CustomerAPPCode ( ) ;
newCode . CustomerOid = customerOid ;
}
2019-09-02 15:48:37 +02:00
2017-11-16 15:37:29 +01:00
newCode . CustomerCode = zufallscode ; //bei C noch die UserID mitgeben
newCode . CustomerCodeGenDate = DateTime . Now ;
newCode . IsChatAktiv = 1 ;
2017-10-06 12:06:34 +02:00
2017-11-16 15:37:29 +01:00
DAOFactory . GenericDAO . Insert ( newCode ) ;
2017-10-06 12:06:34 +02:00
2017-11-16 15:37:29 +01:00
var customerAPPCodeDC = MapperFactory . CustomerAPPCodeDC_CustomerAPPCode . MapToNewDC ( newCode ) ;
2017-10-06 12:06:34 +02:00
2017-11-16 15:37:29 +01:00
return customerAPPCodeDC ;
}
else
{
return null ;
}
2017-10-06 12:06:34 +02:00
}
else
{
return null ;
}
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
public ChatMessageDC CreateNewChatMessagesDC ( long senderOid , long empfängerOid , string message , bool isDeliverd , long teamid , string messageid )
2016-06-27 01:45:38 +02:00
{
try
{
2016-09-13 11:42:30 +02:00
var chatMessage = new ChatMessage
{
2016-09-30 10:19:11 +02:00
EmpfaengerPersonOid = empfängerOid ,
2016-09-13 11:42:30 +02:00
SenderPersonOid = senderOid ,
Uhrzeit = DateTime . Now ,
IsDelivered = isDeliverd ,
ChatText = Encoding . UTF8 . GetBytes ( message ) ,
2016-11-08 13:50:58 +01:00
IstGelesen = 0 ,
MessageId = messageid
2019-07-12 12:52:47 +02:00
2016-10-21 11:26:42 +02:00
} ;
2016-08-05 12:48:13 +02:00
2020-04-08 14:25:01 +02:00
if ( teamid ! = 0 )
2016-09-13 11:42:30 +02:00
{
chatMessage . TeamOid = teamid ;
}
2016-08-05 12:48:13 +02:00
else
2016-09-13 11:42:30 +02:00
{
chatMessage . TeamOid = null ;
}
2019-07-12 12:52:47 +02:00
DAOFactory . GenericDAO . Insert ( chatMessage ) ;
2016-06-27 01:45:38 +02:00
2016-09-22 10:57:02 +02:00
var ChatMessagesDC = MapperFactory . ChatMessagesDC_ChatMessages . MapToNewDC ( chatMessage ) ;
2016-06-27 01:45:38 +02:00
2016-09-22 10:57:02 +02:00
return ChatMessagesDC ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
public void UpdateIsChatActiveCustomerAPPCodeDC ( long customerOid , int activeType )
2016-06-27 01:45:38 +02:00
{
try
{
2020-04-17 16:09:09 +02:00
var customerChatCodes = DAOFactory . SearchDAO . FindAllCustomerAppCodes ( customerOid ) . ToList ( ) ;
2016-06-27 01:45:38 +02:00
2020-10-13 14:35:06 +02:00
foreach ( var items in customerChatCodes )
2016-08-05 12:48:13 +02:00
{
2020-04-17 16:09:09 +02:00
items . IsChatAktiv = activeType = = 1 ? activeType : 0 ;
2016-08-05 12:48:13 +02:00
}
2019-09-02 15:48:37 +02:00
2020-04-17 16:09:09 +02:00
DAOFactory . GenericDAO . Update ( customerChatCodes ) ;
2016-08-05 12:48:13 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-08-05 12:48:13 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public IList < CustomerAPPCodeDC > GetIsChatActiveCustomerAPPCodeDC ( long customerOid , int activeType )
{
try
{
var customercode = DAOFactory . SearchDAO . FindAllCustomerAppCodes ( customerOid ) ;
2019-07-12 12:52:47 +02:00
2020-04-17 16:09:09 +02:00
return MapperFactory . CustomerAPPCodeDC_CustomerAPPCode . MapToNewDCs ( customercode ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
public int DeletZufallsCode ( string apikey , string customerId , string userId )
2016-11-21 11:20:47 +01:00
{
try
{
2017-11-13 16:37:21 +01:00
#if DEBUG
customerId = "0000000001" ;
apikey = "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97" ;
2021-02-22 10:14:07 +01:00
//customerId = "4526293996";
2017-11-13 16:37:21 +01:00
#endif
2020-11-25 11:40:05 +01:00
var serverUrl = OwnChatHelper . ErmittleServerURL ( customerId ) ;
2017-11-16 15:37:29 +01:00
2020-10-13 14:35:06 +02:00
if ( serverUrl . IsNullOrEmpty ( ) )
2016-11-21 11:20:47 +01:00
{
2017-11-16 15:37:29 +01:00
return 3 ; // ServerURl konnte nicht ermittelt werden
}
2017-10-06 12:06:34 +02:00
2020-04-16 15:57:01 +02:00
try
{
ServicePointManager . SecurityProtocol = SecurityProtocolType . Tls12 ;
2017-10-06 12:06:34 +02:00
2020-04-16 15:57:01 +02:00
var url = $"{serverUrl}/api/ownchat/chatcode/revoke/{apikey}/{customerId}/{userId}" ;
2017-10-06 12:06:34 +02:00
2020-04-16 15:57:01 +02:00
var client = new RestClient ( url ) ;
var request = new RestRequest ( Method . GET ) ;
2019-07-12 12:52:47 +02:00
2020-04-16 15:57:01 +02:00
var response = client . Execute ( request ) ;
2019-07-12 12:52:47 +02:00
2020-08-19 12:15:10 +02:00
var result = JsonConvert . DeserializeAnonymousType ( response . Content , new { Result = string . Empty } ) ;
2019-07-12 12:52:47 +02:00
2020-04-16 15:57:01 +02:00
return Convert . ToInt32 ( result . Result ) ;
}
2020-10-13 14:35:06 +02:00
catch ( Exception e )
2020-04-16 15:57:01 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
2016-11-21 11:20:47 +01:00
}
}
2020-10-13 14:35:06 +02:00
catch ( Exception e )
2016-11-21 11:20:47 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
public string ErzeugeZufallsCode ( string apikey , string customerId , string userId )
2016-06-27 01:45:38 +02:00
{
2019-07-12 12:52:47 +02:00
2020-11-25 11:40:05 +01:00
var serverUrl = OwnChatHelper . ErmittleServerURL ( customerId ) ;
2019-07-12 12:52:47 +02:00
2017-10-06 12:06:34 +02:00
try
2016-11-17 14:46:54 +01:00
{
2020-04-16 15:57:01 +02:00
ServicePointManager . SecurityProtocol = SecurityProtocolType . Tls12 ;
2017-10-06 12:06:34 +02:00
2020-04-16 15:57:01 +02:00
var url = $"{serverUrl}/api/ownchat/chatcode/create/{apikey}/{customerId}/{userId}" ;
2016-11-21 11:20:47 +01:00
2020-04-16 15:57:01 +02:00
var client = new RestClient ( url ) ;
var request = new RestRequest ( Method . GET ) ;
2016-11-17 14:46:54 +01:00
2020-04-16 15:57:01 +02:00
var response = client . Execute ( request ) ;
2019-07-12 12:52:47 +02:00
2020-08-19 12:15:10 +02:00
var result = JsonConvert . DeserializeAnonymousType ( response . Content , new { Result = string . Empty , ChatCode = string . Empty } ) ;
2019-07-12 12:52:47 +02:00
2020-04-16 15:57:01 +02:00
return ! result . Result . Equals ( "0" ) ? null : result . ChatCode ;
2017-10-06 12:06:34 +02:00
2020-04-16 15:57:01 +02:00
//var request = WebRequest.Create(url);
2017-10-06 12:06:34 +02:00
2020-04-16 15:57:01 +02:00
//request.Credentials = CredentialCache.DefaultCredentials;
2016-11-17 14:46:54 +01:00
2020-04-16 15:57:01 +02:00
//var response = request.GetResponse();
2017-10-06 12:06:34 +02:00
2020-04-16 15:57:01 +02:00
//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;
2017-10-06 12:06:34 +02:00
}
2020-10-13 14:35:06 +02:00
catch ( Exception e )
2019-07-12 12:52:47 +02:00
{
2017-10-06 12:06:34 +02:00
throw Utils . CreateBeWoFaultException ( e ) ;
2016-11-17 14:46:54 +01:00
}
2017-10-06 12:06:34 +02:00
}
2016-06-27 01:45:38 +02:00
2020-11-25 11:40:05 +01:00
//private static string ErmittleServerURL(string customerId)
//{
// try
// {
// ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
2017-10-06 12:06:34 +02:00
2020-11-25 11:40:05 +01:00
// var url = "https://dict.ownchat.de/api/server/resolve/1/" + customerId;
2017-10-06 12:06:34 +02:00
2020-11-25 11:40:05 +01:00
// var client = new RestClient(url);
// var request = new RestRequest(Method.GET);
2017-10-06 12:06:34 +02:00
2020-11-25 11:40:05 +01:00
// var response = client.Execute(request);
2017-10-06 12:06:34 +02:00
2020-11-25 11:40:05 +01:00
// var result = JsonConvert.DeserializeAnonymousType(response.Content, new { Status = string.Empty, Url = string.Empty, SyncType = string.Empty });
2017-10-06 12:06:34 +02:00
2020-11-25 11:40:05 +01:00
// return result.Url;
// }
// catch (Exception e)
// {
// throw Utils.CreateBeWoFaultException(e);
// }
//}
2017-10-06 12:06:34 +02:00
2020-04-16 15:57:01 +02:00
private static string ReadStreamForChatCode ( WebResponse response )
2017-10-06 12:06:34 +02:00
{
try
2019-07-12 12:52:47 +02:00
{
2020-04-16 15:57:01 +02:00
var dataStream = response . GetResponseStream ( ) ;
2017-10-06 12:06:34 +02:00
2020-04-16 15:57:01 +02:00
var reader = new StreamReader ( dataStream ) ;
2019-07-12 12:52:47 +02:00
2020-04-16 15:57:01 +02:00
var responseFromServer = reader . ReadToEnd ( ) ;
2017-10-06 12:06:34 +02:00
dataStream . Dispose ( ) ;
reader . Dispose ( ) ;
dataStream . Close ( ) ;
reader . Close ( ) ;
return responseFromServer ;
}
2021-10-13 16:00:33 +02:00
catch ( Exception )
2019-07-12 12:52:47 +02:00
{
2017-10-06 12:06:34 +02:00
return null ;
2016-11-17 14:46:54 +01:00
}
2016-06-27 01:45:38 +02:00
}
2019-07-12 12:52:47 +02:00
2016-09-22 14:29:57 +02:00
public List < ChatMessageDC > FindUnreadChatMessagesForRecipient ( long personOid )
2016-09-22 10:57:02 +02:00
{
try
{
2016-09-22 14:29:57 +02:00
var chatMessage = DAOFactory . SearchDAO . FindUnreadChatMessagesForRecipient ( personOid ) ;
2016-09-22 10:57:02 +02:00
var ChatMessagesDC = MapperFactory . ChatMessagesDC_ChatMessages . MapToNewDCs ( chatMessage ) ;
return ChatMessagesDC ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-09-22 10:57:02 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
public long InsertNewServiceRecordAndSignature ( ServiceRecordDC sr , SignatureDC sig )
{
2016-06-27 01:45:38 +02:00
try
{
2020-10-13 14:35:06 +02:00
var dcList = new List < ServiceRecordDC > { sr } ;
2016-06-27 01:45:38 +02:00
var oidList = InsertNewServiceRecords ( dcList ) ;
var serviceRecordOid = oidList [ 0 ] ;
2024-11-12 18:37:23 +01:00
if ( ! string . IsNullOrEmpty ( sig . DataBild ) )
2016-06-27 01:45:38 +02:00
{
var lSignature = MapperFactory . SignatureDC_Signature . MapToNewEntity ( sig ) ;
DAOFactory . GenericDAO . Insert ( lSignature ) ;
2023-10-25 21:52:23 +02:00
var serviceRecord = DAOFactory . GenericDAO . LoadByID < ServiceRecord > ( serviceRecordOid ) ;
2023-10-28 13:34:32 +02:00
MakeSignatureStatusTypeServiceRecordHistoryEntry ( serviceRecord , SignatureStateType . Valid , null , null , null , null ) ;
2016-06-27 01:45:38 +02:00
}
2019-09-02 15:48:37 +02:00
2016-06-27 01:45:38 +02:00
return serviceRecordOid ;
}
2024-11-12 18:37:23 +01:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2020-04-16 15:57:01 +02:00
public string CreateDefaultServiceRecords ( DateTime monat , IList < long > oids )
2019-07-12 17:36:37 +02:00
{
try
{
var s = PluginLoader . FindClass < SchulbegleitenderDienstService > ( ) ;
return s . CreateDefaultServiceRecords ( monat , oids ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2022-04-25 15:45:02 +02:00
public String CreateDefaultCustomerServiceRecords ( DateTime start , DateTime end , IList < long > customerOids )
{
try
{
var s = PluginLoader . FindClass < OperationService > ( ) ;
return s . CreateDefaultCustomerServiceRecords ( start , end , customerOids ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2016-06-27 01:45:38 +02:00
public List < OrganisationPersonRelationDC > LoadOrganisationPersonRelationsByOid ( IEnumerable < long > pOids )
{
try
{
var customerPersonRels = DAOFactory . GenericDAO . LoadByIDs < Organisation2Person > ( pOids ) ;
return MapperFactory . OrganisationPersonRelDC_Organisation2PersonMapper . MapToNewDCs ( customerPersonRels ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2022-04-25 15:45:02 +02:00
public List < ArbeitszeitDC > LoadArbeitszeitenForObject ( TableID objectTid , long objectOid )
{
try
{
var arbeitszeiten = DAOFactory . SearchDAO . FindArbeitszeiten ( objectTid , objectOid ) ;
return MapperFactory . ArbeitszeitDC_Arbeitszeit . MapToNewDCs ( arbeitszeiten ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2016-06-27 01:45:38 +02:00
public List < BargeldkassenDC > LoadBargeldkassenForObject ( TableID objectTid , long objectOid )
{
try
{
var bargeldkassen = DAOFactory . SearchDAO . FindBargeldkasse ( objectTid , objectOid ) ;
return MapperFactory . BargeldkassenDCBargeldkasseDC_BargeldkassenDCBargeldkasse . MapToNewDCs ( bargeldkassen ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
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 ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public BargeldkassenDC UpdateBargeldkasse ( BargeldkassenDC pBargeldkasse )
{
try
{
var lOriginal = DAOFactory . GenericDAO . LoadByID < Bargeldkasse > ( pBargeldkasse . BargeldkassenOid . Value ) ;
2024-02-20 14:42:04 +01:00
#region Transaktionshistorie
var changedTransactionOids = new List < long > ( ) ;
var transactionHistoryEntries = new List < Bargeldtransaktionshistory > ( ) ;
// Oid zu Änderungsart und Unterschriftenstatus zum Speichern nach dem Bargeldkassen-Update
var oids2ChangeTypes = new Dictionary < long , KeyValuePair < StatementType , SignatureStateType > > ( ) ;
// Oids der Unterschriften, die durch die Änderung ungültig wurden
var signatureOids2Delete = new List < long > ( ) ;
// Die unveränderten Transaktionen laden, um sie mit den geänderten zu vergleichen und herauszufinden, was geändert wurde.
var originalTransactions = MapperFactory . BargeldtransaktionDC_Bargeldtransaktion . MapToNewDCs ( lOriginal . Bargeldtransaktionen ) ;
// Die Oids der gelöschten Transaktionen, um die damit verbundenen Unterschriften zu löschen
var deletedOids = new List < long > ( ) ;
2024-04-17 16:33:19 +02:00
foreach ( var originalTransaction in originalTransactions )
2024-02-20 14:42:04 +01:00
{
var changedOrDeletedTransactionDC = pBargeldkasse . Bargeldtransaktionen . FirstOrDefault ( transaction = > transaction . BargeldtransaktionOid . HasValue & & transaction . BargeldtransaktionOid . Value . Equals ( originalTransaction . BargeldtransaktionOid . Value ) ) ;
2024-02-23 17:25:02 +01:00
// Die Transaktion wurde entfernt
2024-04-17 16:33:19 +02:00
if ( changedOrDeletedTransactionDC is null & & originalTransaction . BargeldtransaktionOid . HasValue )
2024-02-20 14:42:04 +01:00
{
2024-04-17 16:33:19 +02:00
if ( originalTransaction . SignatureOid . HasValue )
2024-02-20 14:42:04 +01:00
{
2024-03-01 16:59:35 +01:00
signatureOids2Delete . AddRangeIfElementsNotIn ( DAOFactory . SearchDAO . LoadSignatureOidsByTransaktionOid ( originalTransaction . BargeldtransaktionOid . Value ) ) ;
2024-02-20 14:42:04 +01:00
signatureOids2Delete . AddIfNotIn ( originalTransaction . SignatureOid . Value ) ;
}
deletedOids . AddIfNotIn ( originalTransaction . BargeldtransaktionOid . Value ) ;
}
// Die Transaktion ist nicht neu und wurde geändert
2024-04-17 16:33:19 +02:00
if ( ( changedOrDeletedTransactionDC ? . BargeldtransaktionOid . HasValue ? ? false ) & & ! originalTransaction . Equals ( changedOrDeletedTransactionDC ) )
2024-02-20 14:42:04 +01:00
{
// Es wurde eine Transaktion unterschrieben.
2024-04-17 16:33:19 +02:00
if ( originalTransaction . SignatureOid is null & & changedOrDeletedTransactionDC . SignatureOid . HasValue )
2024-02-20 14:42:04 +01:00
{
oids2ChangeTypes . AddIfNotIn (
new KeyValuePair < long , KeyValuePair < StatementType , SignatureStateType > > (
2024-04-17 16:33:19 +02:00
changedOrDeletedTransactionDC . BargeldtransaktionOid . Value ,
2024-02-20 14:42:04 +01:00
new KeyValuePair < StatementType , SignatureStateType > ( StatementType . Signature , SignatureStateType . Valid ) ) ) ;
}
else // Es wurde eine andere Eigenschaft geändert als die Unterschrift
{
var newSignatureState = SignatureStateType . None ;
2024-03-01 16:59:35 +01:00
// Wenn die Transaktion eine Unterschrift vor der Änderung hatte, wird diese als ungültig gespeichert und gelöscht.
2024-04-17 16:33:19 +02:00
if ( changedOrDeletedTransactionDC . SignatureOid . HasValue )
2024-02-20 14:42:04 +01:00
{
newSignatureState = SignatureStateType . Invalid ;
2024-04-17 16:33:19 +02:00
2024-03-01 16:59:35 +01:00
signatureOids2Delete . AddRangeIfElementsNotIn ( DAOFactory . SearchDAO . LoadSignatureOidsByTransaktionOid ( changedOrDeletedTransactionDC . BargeldtransaktionOid . Value ) ) ;
signatureOids2Delete . AddIfNotIn ( changedOrDeletedTransactionDC . SignatureOid . Value ) ;
changedOrDeletedTransactionDC . SignatureOid = null ;
}
// Die Unterschrift wurde gelöscht
2024-04-17 16:33:19 +02:00
else if ( changedOrDeletedTransactionDC . SignatureOid is null & & originalTransaction . SignatureOid . HasValue )
2024-03-01 16:59:35 +01:00
{
signatureOids2Delete . AddRangeIfElementsNotIn ( DAOFactory . SearchDAO . LoadSignatureOidsByTransaktionOid ( changedOrDeletedTransactionDC . BargeldtransaktionOid . Value ) ) ;
newSignatureState = SignatureStateType . ManuallyDeleted ;
2024-02-20 14:42:04 +01:00
}
oids2ChangeTypes . AddIfNotIn ( new KeyValuePair < long , KeyValuePair < StatementType , SignatureStateType > > (
changedOrDeletedTransactionDC . BargeldtransaktionOid . Value ,
new KeyValuePair < StatementType , SignatureStateType > ( StatementType . Update , newSignatureState ) ) ) ;
}
changedTransactionOids . AddIfNotIn ( changedOrDeletedTransactionDC . BargeldtransaktionOid . Value ) ;
}
}
#endregion
2024-04-17 16:33:19 +02:00
2024-02-20 14:42:04 +01:00
var deletedTransactions = DAOFactory . GenericDAO . LoadByIDs < Bargeldtransaktion > ( deletedOids ) ;
var signatures2Delete = new List < Signature > ( ) ;
2024-03-01 16:59:35 +01:00
// Die Transaktion wurde gelöscht
2024-04-17 16:33:19 +02:00
foreach ( var deletedTransaction in deletedTransactions )
2024-02-20 14:42:04 +01:00
{
var signatureStateType = SignatureStateType . None ;
2024-04-17 16:33:19 +02:00
if ( deletedTransaction . SignatureOid . HasValue )
2024-02-20 14:42:04 +01:00
{
var signature = DAOFactory . GenericDAO . LoadByID < Signature > ( deletedTransaction . SignatureOid . Value ) ;
signatures2Delete . Add ( signature ) ;
deletedTransaction . SignatureOid = null ;
signatureStateType = SignatureStateType . ManuallyDeleted ;
}
transactionHistoryEntries . Add ( CreateTransactionHistoryObject ( deletedTransaction , StatementType . Delete , signatureStateType ) ) ;
}
2016-06-27 01:45:38 +02:00
MapperFactory . BargeldkassenDCBargeldkasseDC_BargeldkassenDCBargeldkasse . MergeWithEntity ( pBargeldkasse , lOriginal ) ;
2024-02-20 14:42:04 +01:00
var newTransactions = lOriginal . Bargeldtransaktionen . Where ( transaction = > transaction . Oid is null ) . ToList ( ) ;
2016-06-27 01:45:38 +02:00
DAOFactory . GenericDAO . Update ( lOriginal ) ;
2024-03-01 16:59:35 +01:00
// Nach dem Insert der neuen Transaktionen haben diese eine Oid und es können die History-Einträge gemacht werden
2024-04-17 16:33:19 +02:00
foreach ( var newTransaction in newTransactions )
2024-02-20 14:42:04 +01:00
{
transactionHistoryEntries . Add ( CreateTransactionHistoryObject ( newTransaction , StatementType . Insert , SignatureStateType . None ) ) ;
}
2024-03-01 16:59:35 +01:00
// Die History-Einträge für die bearbeiteten werden gemacht
2024-04-17 16:33:19 +02:00
foreach ( var oid2ChangeTypes in oids2ChangeTypes )
2024-02-20 14:42:04 +01:00
{
var editedTransaction = lOriginal . Bargeldtransaktionen . FirstOrDefault ( transaction = > transaction . Oid . HasValue & & transaction . Oid . Value . Equals ( oid2ChangeTypes . Key ) ) ;
2024-04-17 16:33:19 +02:00
if ( editedTransaction is null )
2024-02-20 14:42:04 +01:00
{
continue ;
}
transactionHistoryEntries . Add ( CreateTransactionHistoryObject ( editedTransaction , oid2ChangeTypes . Value . Key , oid2ChangeTypes . Value . Value ) ) ;
}
DAOFactory . GenericDAO . Insert ( transactionHistoryEntries ) ;
2024-03-01 16:59:35 +01:00
signatureOids2Delete . AddRangeIfElementsNotIn ( signatures2Delete . Where ( s = > s . Oid . HasValue ) . Select ( s = > s . Oid . Value ) ) ;
DAOFactory . GenericDAO . Delete ( DAOFactory . GenericDAO . LoadByIDs < Signature > ( signatureOids2Delete ) ) ;
2024-02-23 17:25:02 +01:00
2016-06-27 01:45:38 +02:00
return MapperFactory . BargeldkassenDCBargeldkasseDC_BargeldkassenDCBargeldkasse . MapToNewDC ( lOriginal ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2024-02-20 14:42:04 +01:00
public void DeleteBargeldtransaktionSignature ( long signatureOid )
{
try
{
var signature2Delete = DAOFactory . GenericDAO . LoadByID < Signature > ( signatureOid ) ;
DAOFactory . GenericDAO . Delete ( signature2Delete ) ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2024-02-20 14:42:04 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2016-06-27 01:45:38 +02:00
public void DeactivateBargeldkasse ( long pOid , long pVersion )
{
try
{
2024-02-20 14:42:04 +01:00
var bargeldkasse = DAOFactory . GenericDAO . LoadByID < Bargeldkasse > ( pOid ) ;
2024-03-01 16:59:35 +01:00
var signatures2Delete = DAOFactory . SearchDAO . LoadSignaturesByTransactionOids ( bargeldkasse . Bargeldtransaktionen . Where ( transaction = > transaction . SignatureOid . HasValue ) . Select ( transaction = > transaction . SignatureOid . Value ) . ToList ( ) ) ;
2024-02-20 14:42:04 +01:00
var historyEntries = new List < Bargeldtransaktionshistory > ( ) ;
2024-04-17 16:33:19 +02:00
foreach ( var transaction in bargeldkasse . Bargeldtransaktionen )
2024-02-20 14:42:04 +01:00
{
var signatureState = transaction . SignatureOid is null ? SignatureStateType . None : SignatureStateType . AutomaticallyDeleted ;
historyEntries . Add ( CreateTransactionHistoryObject ( transaction , StatementType . Delete , signatureState ) ) ;
}
DAOFactory . GenericDAO . Delete ( signatures2Delete ) ;
DAOFactory . GenericDAO . Insert ( historyEntries ) ;
2020-04-08 14:25:01 +02:00
ServiceLogic . SetActivationType < Bargeldkasse > ( new Dictionary < long , long > { { pOid , pVersion } } , ActivationTypeId . Deleted ) ;
2024-03-01 16:59:35 +01:00
// SignatureOids aus den Transaktionen löschen, da die Signature-Objekte gelöscht wurden
bargeldkasse = DAOFactory . GenericDAO . LoadByID < Bargeldkasse > ( pOid ) ;
2024-04-17 16:33:19 +02:00
foreach ( var transaction in bargeldkasse . Bargeldtransaktionen )
2024-03-01 16:59:35 +01:00
{
transaction . SignatureOid = null ;
}
DAOFactory . GenericDAO . Update ( bargeldkasse ) ;
2016-06-27 01:45:38 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2024-02-20 14:42:04 +01:00
private static Bargeldtransaktionshistory CreateTransactionHistoryObject ( Bargeldtransaktion transaction , StatementType changeType , SignatureStateType signatureState )
{
return new Bargeldtransaktionshistory
{
2024-04-17 16:33:19 +02:00
Betrag = transaction . Betrag ,
BargeldtransaktionOid = transaction . Oid ,
BargeldtransaktionInsTs = transaction . InsTs ,
2024-02-20 14:42:04 +01:00
BargeldtransaktionInsUser = transaction . InsUser ,
BargeldtransaktionUdpUser = transaction . UdpUser ,
BargeldtransaktionVersion = transaction . Version ,
2024-04-17 16:33:19 +02:00
ChangeType = changeType ,
Belegnummer = transaction . Belegnummer ,
Notice = transaction . Notice ,
IsActive = ActivationTypeId . Active ,
SignatureOid = transaction . SignatureOid ,
SignatureState = signatureState ,
Zahlungstyp = transaction . Zahlungstyp ,
Zahlungsdatum = transaction . Zahlungsdatum
2024-02-20 14:42:04 +01:00
} ;
}
2018-10-08 11:57:16 +02:00
public List < NotizenKategorieDC > LoadNotizenKategorienForObject ( TableID objectTid , long objectOid )
{
try
{
var kategorien = DAOFactory . SearchDAO . FindNotizenKategorien ( objectTid , objectOid ) ;
2020-04-08 14:25:01 +02:00
if ( kategorien . Count = = 0 )
2018-10-08 11:57:16 +02:00
{
var newKat = new NotizenKategorie ( ) ;
newKat . KategorieName = "Gesprächsnotizen" ;
newKat . ObjectOid = objectOid ;
newKat . ObjectTid = objectTid ;
DAOFactory . GenericDAO . Insert ( newKat ) ;
kategorien . Add ( newKat ) ;
}
2019-09-02 15:48:37 +02:00
2018-10-08 11:57:16 +02:00
return MapperFactory . NotizenKategorieDC_NotizenKategorie . MapToNewDCs ( kategorien . Where ( k = > k . IsActive = = ActivationTypeId . Active ) ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2018-10-08 11:57:16 +02:00
{
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 ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2018-10-08 11:57:16 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public NotizenKategorieDC UpdateNotizenKategorie ( NotizenKategorieDC kategorie )
{
try
{
var lOriginal = DAOFactory . GenericDAO . LoadByID < NotizenKategorie > ( kategorie . NotizenKategorieOid . Value ) ;
2020-11-29 17:56:11 +01:00
kategorie . NotizenKategorieVersion = lOriginal . Version ;
2018-10-08 11:57:16 +02:00
MapperFactory . NotizenKategorieDC_NotizenKategorie . MergeWithEntity ( kategorie , lOriginal ) ;
DAOFactory . GenericDAO . Update ( lOriginal ) ;
return MapperFactory . NotizenKategorieDC_NotizenKategorie . MapToNewDC ( lOriginal ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2018-10-08 11:57:16 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeactivateNotizenEintrag ( long pOid , long pVersion )
{
try
{
2020-04-08 14:25:01 +02:00
ServiceLogic . SetActivationType < NotizenEintrag > ( new Dictionary < long , long > { { pOid , pVersion } } , ActivationTypeId . Deleted ) ;
2018-10-08 11:57:16 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2018-10-08 11:57:16 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeactivateNotizenKategorie ( long pOid , long pVersion )
{
try
{
2020-04-08 14:25:01 +02:00
ServiceLogic . SetActivationType < NotizenKategorie > ( new Dictionary < long , long > { { pOid , pVersion } } , ActivationTypeId . Deleted ) ;
2018-10-08 11:57:16 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2018-10-08 11:57:16 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
public void DeactivateAbsenceTime ( Dictionary < long , long > pOid2Version )
2017-03-30 06:19:17 +02:00
{
try
2017-04-07 13:44:07 +02:00
{
2018-10-08 11:57:16 +02:00
//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 ) ;
2017-05-15 09:11:13 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-05-15 09:11:13 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-04-07 13:44:07 +02:00
2017-05-18 16:54:33 +02:00
public void InsertNewEmployeeAbsenceTime ( long employeeOid , AbsenceTimeDC at )
2017-03-30 06:19:17 +02:00
{
try
2019-07-12 12:52:47 +02:00
{
2017-05-18 16:54:33 +02:00
var emp = DAOFactory . GenericDAO . GetByID < Employee > ( employeeOid ) ;
emp . AbsenceTimes . Add ( MapperFactory . AbsenceTimeDC_AbsenceTime . MapToNewEntity ( at ) ) ;
2019-07-12 12:52:47 +02:00
2017-05-18 16:54:33 +02:00
DAOFactory . GenericDAO . Update ( emp ) ;
2017-03-30 06:19:17 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-03-30 06:19:17 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-05-18 16:54:33 +02:00
public void InsertNewCustomerAbsenceTime ( long customerOid , AbsenceTimeDC at )
2017-03-30 06:19:17 +02:00
{
try
{
2017-05-18 16:54:33 +02:00
var cust = DAOFactory . GenericDAO . GetByID < Customer > ( customerOid ) ;
cust . AbsenceTimes . Add ( MapperFactory . AbsenceTimeDC_AbsenceTime . MapToNewEntity ( at ) ) ;
2017-04-28 14:08:23 +02:00
2017-05-18 16:54:33 +02:00
DAOFactory . GenericDAO . Update ( cust ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-05-18 16:54:33 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-04-28 14:08:23 +02:00
2017-05-15 09:11:13 +02:00
public void DeleteVertretung ( long vert )
2017-04-07 13:44:07 +02:00
{
try
{
2017-05-15 09:11:13 +02:00
var origVertretung = DAOFactory . GenericDAO . LoadByID < Vertretung > ( vert ) ;
2017-04-07 13:44:07 +02:00
DAOFactory . GenericDAO . Delete ( origVertretung ) ;
2017-03-30 06:19:17 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-03-30 06:19:17 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
2019-07-12 12:52:47 +02:00
}
2017-03-30 06:19:17 +02:00
}
2017-05-18 16:54:33 +02:00
public void UpdateVertretung ( VertretungDC vert )
2017-04-07 13:44:07 +02:00
{
try
{
var origVertretung = DAOFactory . GenericDAO . LoadByID < Vertretung > ( vert . VertretungOid . Value ) ;
2019-09-02 15:48:37 +02:00
// 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 ) ;
2019-08-08 14:47:53 +02:00
2017-04-07 13:44:07 +02:00
MapperFactory . VertretungDC_Vertretung . MergeWithEntity ( vert , origVertretung ) ;
DAOFactory . GenericDAO . Update ( origVertretung ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-04-07 13:44:07 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
2017-05-18 16:54:33 +02:00
}
2017-04-07 13:44:07 +02:00
}
2017-05-18 16:54:33 +02:00
public void UpdateVertretungAndAbsenceTime ( VertretungDC vert , AbsenceTimeDC abs )
2017-04-07 13:44:07 +02:00
{
try
{
var origVertretung = DAOFactory . GenericDAO . LoadByID < Vertretung > ( vert . VertretungOid . Value ) ;
MapperFactory . VertretungDC_Vertretung . MergeWithEntity ( vert , origVertretung ) ;
DAOFactory . GenericDAO . Update ( origVertretung ) ;
2017-05-15 09:11:13 +02:00
2018-10-08 11:57:16 +02:00
//Update AbsenceTime
2017-05-18 16:54:33 +02:00
var origAbsenceTime = DAOFactory . GenericDAO . LoadByID < AbsenceTime > ( abs . AbsenceTimeOid . Value ) ;
2017-05-15 09:11:13 +02:00
2017-05-18 16:54:33 +02:00
MapperFactory . AbsenceTimeDC_AbsenceTime . MergeWithEntity ( abs , origAbsenceTime ) ;
2017-05-15 09:11:13 +02:00
DAOFactory . GenericDAO . Update ( origAbsenceTime ) ;
2017-05-18 16:54:33 +02:00
2017-04-07 13:44:07 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-04-07 13:44:07 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
2017-05-18 16:54:33 +02:00
public void CreateVertretung ( VertretungDC vertretung )
2017-04-07 13:44:07 +02:00
{
try
{
2023-08-23 23:15:58 +02:00
var vm = PluginLoader . FindClass < VertretungsManager > ( ) ;
2017-04-07 13:44:07 +02:00
2023-08-23 23:15:58 +02:00
vm . SaveVertretung ( vertretung ) ;
2017-04-28 14:08:23 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-04-28 14:08:23 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-04-07 13:44:07 +02:00
2017-05-18 16:54:33 +02:00
public void UpdateAbsenceTime ( AbsenceTimeDC abs )
{
2019-07-12 12:52:47 +02:00
try
{
var x = DAOFactory . GenericDAO . LoadByID < AbsenceTime > ( abs . AbsenceTimeOid . Value ) ;
2017-04-28 14:08:23 +02:00
2019-07-12 12:52:47 +02:00
MapperFactory . AbsenceTimeDC_AbsenceTime . MergeWithEntity ( abs , x ) ;
2017-04-07 13:44:07 +02:00
2019-07-12 12:52:47 +02:00
DAOFactory . GenericDAO . Update ( x ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-04-28 14:08:23 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-04-07 13:44:07 +02:00
2018-05-21 16:39:24 +02:00
public List < VertretungsItemDC > GetVertretungsListe ( DateTime datum )
2017-04-28 14:08:23 +02:00
{
try
2019-07-12 12:52:47 +02:00
{
2023-08-23 23:15:58 +02:00
var vm = PluginLoader . FindClass < VertretungsManager > ( ) ;
return vm . CreateVertretungsListe ( datum . Date , datum . Date ) ;
2017-06-02 13:35:42 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-06-02 13:35:42 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-04-28 14:08:23 +02:00
2019-07-12 12:52:47 +02:00
public List < VertretungsListeMitarbeiterItemsDC > VertretungsMitarbeiterListeWoechentlich ( DateTime start , DateTime ende )
{
try
{
// VertretungsManager mgr = new VertretungsManager();
2017-07-25 10:50:45 +02:00
2019-07-12 12:52:47 +02:00
//var x = mgr.CreateVertretungsListe(start, ende);
2017-07-25 10:50:45 +02:00
2019-07-12 12:52:47 +02:00
// return x;
return null ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2019-07-12 12:52:47 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-07-25 10:50:45 +02:00
2017-08-08 13:13:22 +02:00
public VertretungsKlientAccountingsListeItemsDC KlientenAbschlagsInfoListe ( DateTime start , DateTime end )
2017-08-04 14:20:36 +02:00
{
try
{
2018-05-21 16:39:24 +02:00
//VertretungsAlgorithmus alorythmus = new VertretungsAlgorithmus(start, end,3);
2019-07-12 12:52:47 +02:00
2018-05-21 16:39:24 +02:00
//VertretungsKlientAccountingsListeItemsDC cusAcc = new VertretungsKlientAccountingsListeItemsDC();
2017-08-04 14:20:36 +02:00
2018-05-21 16:39:24 +02:00
//cusAcc.CustomerAccountItemList = alorythmus.c2a;
2017-08-04 14:20:36 +02:00
2018-05-21 16:39:24 +02:00
//return cusAcc;
return null ;
2017-08-04 14:20:36 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-08-04 14:20:36 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2018-05-21 16:39:24 +02:00
public List < VertretungsItemDC > GetVertretungsListeForTimeSpan ( DateTime start , DateTime ende )
2017-06-02 13:35:42 +02:00
{
try
{
2023-08-23 23:15:58 +02:00
var vm = PluginLoader . FindClass < VertretungsManager > ( ) ;
2017-04-28 14:08:23 +02:00
2023-08-23 23:15:58 +02:00
return vm . CreateVertretungsListe ( start . Date , ende . Date ) ;
2017-04-07 13:44:07 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-04-07 13:44:07 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
2017-06-02 13:35:42 +02:00
2017-04-07 13:44:07 +02:00
}
2017-06-02 13:35:42 +02:00
2017-09-26 14:08:38 +02:00
public List < CompactVertreterEmployeeDC > GetLastVertreter ( long? klientenOid )
{
try
{
2023-08-23 23:15:58 +02:00
var vertreterListe = DAOFactory . SearchDAO . FindLastVertretungen ( klientenOid . Value ) ;
2017-09-26 14:08:38 +02:00
List < long > emOidList = new List < long > ( ) ;
2023-08-23 23:15:58 +02:00
foreach ( var v in vertreterListe )
2017-09-26 14:08:38 +02:00
{
2023-08-23 23:15:58 +02:00
if ( v . VertretenderMitarbeiterOid . HasValue )
2017-09-26 14:08:38 +02:00
{
2023-08-23 23:15:58 +02:00
emOidList . Add ( v . VertretenderMitarbeiterOid . Value ) ;
2017-09-26 14:08:38 +02:00
}
}
2019-07-12 12:52:47 +02:00
2017-09-26 14:08:38 +02:00
var employee = DAOFactory . GenericDAO . GetActiveByIDs < Employee > ( emOidList ) ;
2023-08-23 23:15:58 +02:00
var x = MapperFactory . CompactVertreterEmployeeDC_VertreterEmployee . MapToNewDCs ( employee ) . OrderBy ( e = > e . LastName ) . ToList ( ) ;
2017-09-26 14:08:38 +02:00
//var x = MapperFactory.CompactEmployeeDC_Employee.MapToNewDCs(employee);
return x ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-09-26 14:08:38 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-09-26 12:48:29 +02:00
public List < CompactTokenDC > GetAllTokens ( SchulbegleitenderZugehoerigkeitsTyp zugehoerigkeitsTyp , long? oid )
2017-06-28 09:05:53 +02:00
{
try
{
var token = DAOFactory . GenericDAO . GetAllActive < Token > ( ) ;
IList < Token > fToken = new List < Token > ( ) ;
2020-04-08 14:25:01 +02:00
if ( zugehoerigkeitsTyp = = SchulbegleitenderZugehoerigkeitsTyp . Klient )
2017-06-28 09:05:53 +02:00
{
2023-08-23 23:15:58 +02:00
IList < Customer2Token > c2tList = new List < Customer2Token > ( ) ;
if ( oid . HasValue )
{
c2tList = DAOFactory . SearchDAO . GetCustomer2TokensByCustomerOid ( oid . Value ) ;
}
2024-04-17 16:33:19 +02:00
2017-06-28 09:05:53 +02:00
2020-04-08 14:25:01 +02:00
foreach ( var item in token )
2017-06-28 09:05:53 +02:00
{
2023-08-23 23:15:58 +02:00
fToken . Add ( item ) ;
foreach ( var c2t in c2tList )
2017-06-28 09:05:53 +02:00
{
2023-08-23 23:15:58 +02:00
if ( item . Oid = = c2t . TokenOid )
2017-06-28 09:05:53 +02:00
{
2024-04-17 16:33:19 +02:00
item . MemberOid = oid ;
2017-06-28 09:05:53 +02:00
}
}
}
}
2020-04-08 14:25:01 +02:00
else if ( zugehoerigkeitsTyp = = SchulbegleitenderZugehoerigkeitsTyp . Mitarbeiter )
2017-06-28 09:05:53 +02:00
{
2023-08-23 23:15:58 +02:00
IList < Employee2Token > e2tList = new List < Employee2Token > ( ) ;
2017-06-28 09:05:53 +02:00
2023-08-23 23:15:58 +02:00
if ( oid . HasValue )
{
e2tList = DAOFactory . SearchDAO . GeEmployee2TokensByEmployeeOid ( oid . Value ) ;
}
2024-04-17 16:33:19 +02:00
2020-04-08 14:25:01 +02:00
foreach ( var item in token )
2017-06-28 09:05:53 +02:00
{
2023-08-23 23:15:58 +02:00
fToken . Add ( item ) ;
foreach ( var e2t in e2tList )
2017-06-28 09:05:53 +02:00
{
2023-08-23 23:15:58 +02:00
if ( item . Oid = = e2t . TokenOid )
2017-06-30 13:33:49 +02:00
{
item . MemberOid = oid ;
2024-04-17 16:33:19 +02:00
2017-06-28 09:05:53 +02:00
}
}
}
}
2017-08-04 14:20:36 +02:00
return MapperFactory . CompactTokenDC_Token . MapToNewDCs ( fToken ) ;
2017-06-28 09:05:53 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-06-28 09:05:53 +02:00
{
2019-07-12 12:52:47 +02:00
throw Utils . CreateBeWoFaultException ( e ) ;
2017-06-28 09:05:53 +02:00
}
}
2019-07-12 12:52:47 +02:00
2017-06-28 09:05:53 +02:00
public void UpdateToken ( TokenDC token )
{
try
{
var t = MapperFactory . TokenDC_Token . MapToNewEntity ( token ) ;
DAOFactory . GenericDAO . Update ( t ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-06-28 09:05:53 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-09-26 12:48:29 +02:00
public void InsertNewToken ( string beschreibung , TokenTyp typ , SchulbegleitenderZugehoerigkeitsTyp zugehoerigkeitsTyp , long? oid )
2017-06-28 09:05:53 +02:00
{
try
2019-07-12 12:52:47 +02:00
{
2017-06-28 09:05:53 +02:00
TokenDC token = new TokenDC ( )
{
Beschreibung = beschreibung ,
TokenTyp = typ
} ;
2020-04-08 14:25:01 +02:00
if ( zugehoerigkeitsTyp = = SchulbegleitenderZugehoerigkeitsTyp . Klient )
2017-06-28 09:05:53 +02:00
{
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 ;
}
2020-04-08 14:25:01 +02:00
else if ( zugehoerigkeitsTyp = = SchulbegleitenderZugehoerigkeitsTyp . Mitarbeiter )
2017-06-28 09:05:53 +02:00
{
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 ) ;
2019-07-12 12:52:47 +02:00
token . RelatedEmployees = e2tList ;
2017-06-28 09:05:53 +02:00
}
var t = MapperFactory . TokenDC_Token . MapToNewEntity ( token ) ;
DAOFactory . GenericDAO . Insert ( t ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-06-28 09:05:53 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-09-26 12:48:29 +02:00
public void DoTokenAusschlussOperation ( int art , long? Oid , SchulbegleitenderZugehoerigkeitsTyp zugehoerigkeitsTyp , Dictionary < string , CompactTokenDC > verfuegbarerAusschlussToken , string token )
2017-07-14 14:17:02 +02:00
{
try
{
2020-04-08 14:25:01 +02:00
if ( art = = 1 )
2019-07-12 12:52:47 +02:00
{
2020-04-08 14:25:01 +02:00
if ( verfuegbarerAusschlussToken . ContainsKey ( token ) )
2017-08-08 13:13:22 +02:00
{
CompactTokenDC nToken = null ;
2020-04-08 14:25:01 +02:00
foreach ( var tokenkey in verfuegbarerAusschlussToken )
2017-08-08 13:13:22 +02:00
{
2020-04-08 14:25:01 +02:00
if ( tokenkey . Key . Equals ( token ) )
2017-08-08 13:13:22 +02:00
{
nToken = tokenkey . Value ;
}
}
2020-04-08 14:25:01 +02:00
if ( nToken ! = null )
2017-08-08 13:13:22 +02:00
{
InsertNewRelationToken ( nToken , TokenTyp . AusschlussKriterium , zugehoerigkeitsTyp , Oid ) ;
}
}
else
{
InsertNewToken ( token , TokenTyp . AusschlussKriterium , zugehoerigkeitsTyp , Oid ) ;
}
2019-07-12 12:52:47 +02:00
}
2017-08-08 13:13:22 +02:00
2020-04-08 14:25:01 +02:00
if ( art = = 0 )
2019-07-12 12:52:47 +02:00
{
2020-04-08 14:25:01 +02:00
if ( verfuegbarerAusschlussToken . ContainsKey ( token ) )
2017-08-08 13:13:22 +02:00
{
CompactTokenDC nToken = null ;
2020-04-08 14:25:01 +02:00
foreach ( var tokenkey in verfuegbarerAusschlussToken )
2017-08-08 13:13:22 +02:00
{
2020-04-08 14:25:01 +02:00
if ( tokenkey . Key . Equals ( token ) )
2017-08-08 13:13:22 +02:00
{
nToken = tokenkey . Value ;
}
}
2020-04-08 14:25:01 +02:00
if ( nToken ! = null )
2017-08-08 13:13:22 +02:00
{
DeletTokenRelation ( nToken , Oid , zugehoerigkeitsTyp ) ;
}
}
else
{
2020-04-08 14:25:01 +02:00
if ( zugehoerigkeitsTyp = = SchulbegleitenderZugehoerigkeitsTyp . Klient )
2017-08-08 13:13:22 +02:00
{
var c2tList = GetCustomer2TokenList ( ) ;
List < CompactTokenDC > otoken = new List < CompactTokenDC > ( ) ;
2020-04-08 14:25:01 +02:00
foreach ( var ct2 in c2tList )
2017-08-08 13:13:22 +02:00
{
2020-04-08 14:25:01 +02:00
if ( ct2 . Token . Beschreibung . Equals ( token ) & & ct2 . Customer . CustomerOid = = Oid )
2017-08-08 13:13:22 +02:00
{
otoken . Add ( ct2 . Token ) ;
}
}
2020-04-08 14:25:01 +02:00
foreach ( var ken in otoken )
2017-08-08 13:13:22 +02:00
{
2020-04-08 14:25:01 +02:00
if ( ken ! = null )
2017-08-08 13:13:22 +02:00
DeletTokenRelation ( ken , Oid , zugehoerigkeitsTyp ) ;
}
}
2020-04-08 14:25:01 +02:00
else if ( zugehoerigkeitsTyp = = SchulbegleitenderZugehoerigkeitsTyp . Mitarbeiter )
2017-08-08 13:13:22 +02:00
{
var e2tList = GetEmployee2TokenList ( ) ;
List < CompactTokenDC > otoken = new List < CompactTokenDC > ( ) ;
2020-04-08 14:25:01 +02:00
foreach ( var et2 in e2tList )
2017-08-08 13:13:22 +02:00
{
2020-04-08 14:25:01 +02:00
if ( et2 . Token . Beschreibung . Equals ( token ) & & et2 . Employee . EmployeeOid = = Oid )
2017-08-08 13:13:22 +02:00
{
otoken . Add ( et2 . Token ) ;
}
}
2019-09-02 15:48:37 +02:00
2020-04-08 14:25:01 +02:00
foreach ( var ken in otoken )
2017-08-08 13:13:22 +02:00
{
DeletTokenRelation ( ken , Oid , zugehoerigkeitsTyp ) ;
}
}
2019-07-12 12:52:47 +02:00
}
}
2017-08-08 13:13:22 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-08-08 13:13:22 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
public void DoTokenWunschOperation ( int art , long? Oid , SchulbegleitenderZugehoerigkeitsTyp zugehoerigkeitsTyp , Dictionary < string , CompactTokenDC > verfuegbarerWunschToken , string token )
{
2017-08-08 13:13:22 +02:00
try
{
2020-04-08 14:25:01 +02:00
if ( art = = 1 )
2019-07-12 12:52:47 +02:00
{
2020-04-08 14:25:01 +02:00
if ( verfuegbarerWunschToken . ContainsKey ( token ) )
2017-08-08 13:13:22 +02:00
{
CompactTokenDC nToken = null ;
2020-04-08 14:25:01 +02:00
foreach ( var tokenkey in verfuegbarerWunschToken )
2017-08-08 13:13:22 +02:00
{
2020-04-08 14:25:01 +02:00
if ( tokenkey . Key . Equals ( token ) )
2017-08-08 13:13:22 +02:00
{
nToken = tokenkey . Value ;
}
}
2020-04-08 14:25:01 +02:00
if ( nToken ! = null )
2017-08-08 13:13:22 +02:00
{
InsertNewRelationToken ( nToken , TokenTyp . WunschKriterium , zugehoerigkeitsTyp , Oid ) ;
}
}
else
{
InsertNewToken ( token . ToString ( ) , TokenTyp . WunschKriterium , zugehoerigkeitsTyp , Oid ) ;
}
2019-07-12 12:52:47 +02:00
2017-08-08 13:13:22 +02:00
}
2020-04-08 14:25:01 +02:00
if ( art = = 0 )
2019-07-12 12:52:47 +02:00
{
2020-04-08 14:25:01 +02:00
if ( verfuegbarerWunschToken . ContainsKey ( token ) )
2017-08-08 13:13:22 +02:00
{
CompactTokenDC nToken = null ;
2020-04-08 14:25:01 +02:00
foreach ( var tokenkey in verfuegbarerWunschToken )
2017-08-08 13:13:22 +02:00
{
2020-04-08 14:25:01 +02:00
if ( tokenkey . Key . Equals ( token ) )
2017-08-08 13:13:22 +02:00
{
nToken = tokenkey . Value ;
}
}
2020-04-08 14:25:01 +02:00
if ( nToken ! = null )
2017-08-08 13:13:22 +02:00
{
DeletTokenRelation ( nToken , Oid , zugehoerigkeitsTyp ) ;
}
}
else
{
2020-04-08 14:25:01 +02:00
if ( zugehoerigkeitsTyp = = SchulbegleitenderZugehoerigkeitsTyp . Klient )
2017-08-08 13:13:22 +02:00
{
var c2tList = GetCustomer2TokenList ( ) ;
List < CompactTokenDC > otoken = new List < CompactTokenDC > ( ) ;
2020-04-08 14:25:01 +02:00
foreach ( var ct2 in c2tList )
2017-08-08 13:13:22 +02:00
{
2020-04-08 14:25:01 +02:00
if ( ct2 . Token . Beschreibung . Equals ( token ) & & ct2 . Customer . CustomerOid = = Oid )
2017-08-08 13:13:22 +02:00
{
otoken . Add ( ct2 . Token ) ;
}
}
2020-04-08 14:25:01 +02:00
foreach ( var ken in otoken )
2017-08-08 13:13:22 +02:00
{
DeletTokenRelation ( ken , Oid , zugehoerigkeitsTyp ) ;
}
}
2020-04-08 14:25:01 +02:00
else if ( zugehoerigkeitsTyp = = SchulbegleitenderZugehoerigkeitsTyp . Mitarbeiter )
2017-08-08 13:13:22 +02:00
{
var e2tList = GetEmployee2TokenList ( ) ;
List < CompactTokenDC > otoken = new List < CompactTokenDC > ( ) ;
2020-04-08 14:25:01 +02:00
foreach ( var et2 in e2tList )
2017-08-08 13:13:22 +02:00
{
2020-04-08 14:25:01 +02:00
if ( et2 . Token . Beschreibung . Equals ( token ) & & et2 . Employee . EmployeeOid = = Oid )
2017-08-08 13:13:22 +02:00
{
otoken . Add ( et2 . Token ) ;
}
}
2019-09-02 15:48:37 +02:00
2020-04-08 14:25:01 +02:00
foreach ( var ken in otoken )
2017-08-08 13:13:22 +02:00
{
2019-07-12 12:52:47 +02:00
DeletTokenRelation ( ken , Oid , zugehoerigkeitsTyp ) ;
2017-08-08 13:13:22 +02:00
}
}
2019-07-12 12:52:47 +02:00
}
2017-08-08 13:13:22 +02:00
}
2019-07-12 12:52:47 +02:00
2017-08-08 13:13:22 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-08-08 13:13:22 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-09-26 12:48:29 +02:00
public void InsertNewRelationToken ( CompactTokenDC ctoken , TokenTyp typ , SchulbegleitenderZugehoerigkeitsTyp zugehoerigkeitsTyp , long? oid )
2017-07-14 14:17:02 +02:00
{
try
{
2017-08-04 14:20:36 +02:00
var tk = DAOFactory . GenericDAO . GetByID < Token > ( ctoken . TokenOid . Value ) ;
var token = MapperFactory . TokenDC_Token . MapToNewDC ( tk ) ;
2020-04-08 14:25:01 +02:00
if ( zugehoerigkeitsTyp = = SchulbegleitenderZugehoerigkeitsTyp . Klient )
2017-07-14 14:17:02 +02:00
{
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 ;
}
2020-04-08 14:25:01 +02:00
else if ( zugehoerigkeitsTyp = = SchulbegleitenderZugehoerigkeitsTyp . Mitarbeiter )
2017-07-14 14:17:02 +02:00
{
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 ) ;
2019-07-12 12:52:47 +02:00
var t = MapperFactory . TokenDC_Token . MergeWithEntity ( token , tok ) ;
2017-07-14 14:17:02 +02:00
DAOFactory . GenericDAO . Update ( t ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-07-14 14:17:02 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-06-28 09:05:53 +02:00
public void DeleteToken ( TokenDC token )
{
try
{
var t = MapperFactory . TokenDC_Token . MapToNewEntity ( token ) ;
DAOFactory . GenericDAO . Delete ( t ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-06-28 09:05:53 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
public void DeletTokenRelation ( CompactTokenDC token , long? oid , SchulbegleitenderZugehoerigkeitsTyp typ )
2017-08-04 14:20:36 +02:00
{
try
{
2020-04-08 14:25:01 +02:00
if ( typ = = SchulbegleitenderZugehoerigkeitsTyp . Klient )
2017-08-08 13:13:22 +02:00
{
var tokenEntity = DAOFactory . GenericDAO . LoadByID < Token > ( token . TokenOid . Value ) ;
2019-07-12 12:52:47 +02:00
Customer2Token t = null ;
2017-08-04 14:20:36 +02:00
2020-04-08 14:25:01 +02:00
foreach ( var c2tToken in tokenEntity . Customer2TokenList )
2019-07-12 12:52:47 +02:00
{
2020-04-08 14:25:01 +02:00
if ( c2tToken . Customer . Oid = = oid )
2017-08-04 14:20:36 +02:00
{
t = c2tToken ;
}
}
2017-08-08 13:13:22 +02:00
2020-04-08 14:25:01 +02:00
if ( t ! = null )
2017-08-08 13:13:22 +02:00
{
tokenEntity . Customer2TokenList . Remove ( t ) ;
DAOFactory . GenericDAO . Update ( tokenEntity ) ;
}
2017-08-04 14:20:36 +02:00
}
2020-04-08 14:25:01 +02:00
else if ( typ = = SchulbegleitenderZugehoerigkeitsTyp . Mitarbeiter )
2017-08-04 14:20:36 +02:00
{
2017-08-08 13:13:22 +02:00
var tokenEntity = DAOFactory . GenericDAO . LoadByID < Token > ( token . TokenOid . Value ) ;
2017-08-04 14:20:36 +02:00
Employee2Token t = null ;
2020-04-08 14:25:01 +02:00
foreach ( var e2tToken in tokenEntity . Employee2TokenList )
2017-08-04 14:20:36 +02:00
{
2020-04-08 14:25:01 +02:00
if ( e2tToken . Employee . Oid = = oid )
2017-08-04 14:20:36 +02:00
{
t = e2tToken ;
}
}
2020-04-08 14:25:01 +02:00
if ( t ! = null )
2019-07-12 12:52:47 +02:00
{
2017-08-08 13:13:22 +02:00
tokenEntity . Employee2TokenList . Remove ( t ) ;
DAOFactory . GenericDAO . Update ( tokenEntity ) ;
}
2017-08-04 14:20:36 +02:00
}
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-08-04 14:20:36 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-06-28 09:05:53 +02:00
public List < CustomerTokenRelationDC > GetCustomer2TokenList ( )
{
try
{
var x = DAOFactory . GenericDAO . GetAllActive < Customer2Token > ( ) ;
var y = MapperFactory . CustomerTokenRelationDC_Customer2Token . MapToNewDCs ( x ) ;
return y ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-06-28 09:05:53 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < EmployeeTokenRelationDC > GetEmployee2TokenList ( )
{
try
{
var x = DAOFactory . GenericDAO . GetAllActive < Employee2Token > ( ) ;
var y = MapperFactory . EmployeeTokenRelationDC_Employee2Token . MapToNewDCs ( x ) ;
return y ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-06-28 09:05:53 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
2016-06-27 01:45:38 +02:00
public string PrepareAuslastungReport ( AuslastungAnalysisRootDC pReport , string id )
{
try
{
string lResult = id + ".xml" ;
2020-09-23 22:10:52 +02:00
string lDir = BS . Shared . Core . Utils . CreateSavePath ( AppDomain . CurrentDomain . BaseDirectory , MultitenancyOperationContextExt . Current . Tenant + @"\temp" ) ;
string lPath = BS . Shared . Core . Utils . CreateSavePath ( lDir , lResult ) ;
2016-06-27 01:45:38 +02:00
BS . Shared . Core . Utils . XMLSerialize ( lPath , pReport ) ;
return lResult ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-06-27 01:45:38 +02:00
{
throw ( Utils . CreateBeWoFaultException ( e ) ) ;
}
}
public ServiceRecordStatisticsInfoDC GetServiceRecordStatisticInfo ( long costBearer2SupportConceptOid , DateTime statisticsDate )
{
var factory = PluginLoader . FindClass < ServiceRecordStatisticFactory > ( ) ;
2020-04-08 14:25:01 +02:00
if ( factory ! = null )
2016-06-27 01:45:38 +02:00
{
return factory . GetServiceRecordStatisticInfo ( costBearer2SupportConceptOid , statisticsDate ) ;
}
2019-09-02 15:48:37 +02:00
2016-06-27 01:45:38 +02:00
return null ;
}
public SupportConceptStatisticsDC CreateSupportConceptStatistics ( long costBearer2SupportConceptOid , DateTime statisticsDate )
{
var factory = PluginLoader . FindClass < ServiceRecordStatisticFactory > ( ) ;
2020-04-08 14:25:01 +02:00
if ( factory = = null )
2016-06-27 01:45:38 +02:00
{
factory = new ServiceRecordStatisticFactory ( ) ;
}
2019-09-02 15:48:37 +02:00
2016-06-27 01:45:38 +02:00
return factory . CreateSupportConceptStatistics ( costBearer2SupportConceptOid , statisticsDate ) ;
}
public void ResetTenant ( String tenant )
{
WCFHibernateSessionManager . ResetSessionFactory ( tenant ) ;
}
public void ResetAllTenants ( )
{
2021-03-30 10:58:50 +02:00
//WCFHibernateSessionManager.ResetAllSessionFactories();
2016-06-27 01:45:38 +02:00
}
public String GetLicenseOrderUrl ( )
{
2020-04-16 15:57:01 +02:00
var url = ConfigurationManager . AppSettings . Get ( "LicenseOrderUrl" ) ;
2016-06-27 01:45:38 +02:00
url = url . Replace ( "[TENANT]" , MultitenancyOperationContextExt . Current . Tenant ) ;
2024-04-17 16:33:19 +02:00
2022-12-15 23:16:04 +01:00
return url ;
}
public String GetLicenseOrderUrlNeu ( String type )
{
var url = ConfigurationManager . AppSettings . Get ( "LicenseOrderUrl" ) ;
url = url . Replace ( "[TENANT]" , MultitenancyOperationContextExt . Current . Tenant ) ;
2022-12-16 01:05:29 +01:00
if ( type = = "1" )
{
url + = "&LicenseType=1" ;
}
else if ( type = = "2" )
{
var m = GetMandator2 ( false ) ;
if ( ! m . AllowSbd )
{
return "" ;
}
url + = "&LicenseType=2" ;
}
2022-12-15 23:16:04 +01:00
2016-06-27 01:45:38 +02:00
return url ;
}
public LicenseInfoDC GetLicenseInfo ( )
{
return SecurityUtils . GetLicenseInfo ( ) ;
}
public GroupDurationDC CalculateGroupDuration ( int personCount , int employeeCount , decimal totalDuration )
{
var calc = PluginLoader . FindClass < GroupDurationCalculator > ( ) ;
2020-04-16 15:57:01 +02:00
return calc ? . CalculateGroupDuration ( personCount , employeeCount , totalDuration ) ;
2016-06-27 01:45:38 +02:00
}
2019-07-12 12:52:47 +02:00
public GroupDurationDC CalculateGroupDuration2 ( int personCount , int employeeCount , decimal totalDuration , long [ ] costBearer2SupportConceptArray )
{
var calc = PluginLoader . FindClass < GroupDurationCalculator > ( ) ;
2016-06-27 01:45:38 +02:00
2020-04-16 15:57:01 +02:00
return calc ? . CalculateGroupDuration ( personCount , employeeCount , totalDuration , costBearer2SupportConceptArray ) ;
2019-07-12 12:52:47 +02:00
}
2016-06-27 01:45:38 +02:00
public IList < UiElementDC > GetUiElements ( UiElementType ? uiType , long? employeeOid , long? teamOid , long [ ] oidArray )
{
2020-04-16 15:57:01 +02:00
var factory = PluginLoader . FindClass < UiElementFactory > ( ) ? ? new UiElementFactory ( ) ;
2016-06-27 01:45:38 +02:00
return factory . GetUiElements ( uiType , employeeOid , teamOid ) ;
}
private static List < SupportConceptTreeNodeDC > BuildTree ( IEnumerable < SupportConcept > pSupportConcepts )
{
var lResult = new List < SupportConceptTreeNodeDC > ( ) ;
2020-08-19 12:15:10 +02:00
2020-10-13 14:35:06 +02:00
foreach ( var iSc in pSupportConcepts )
2016-06-27 01:45:38 +02:00
{
var lScNode = new SupportConceptTreeNodeDC
{
2020-10-13 14:35:06 +02:00
NodeType = NodeType . SupportConcept ,
SupportConcept = MapperFactory . CompactSupportConceptDC_SupportConcept . MapToNewDC ( iSc ) ,
2020-04-16 15:57:01 +02:00
Description = $"{iSc.Customer.Person.LastName}, {iSc.Customer.Person.FirstName}"
2016-06-27 01:45:38 +02:00
} ;
2020-10-13 14:35:06 +02:00
foreach ( var iSc2Cb in iSc . CostBearer2SupportConceptList )
2016-06-27 01:45:38 +02:00
{
2020-04-16 15:57:01 +02:00
var treeNode = new SupportConceptTreeNodeDC
{
2020-10-13 14:35:06 +02:00
NodeType = NodeType . SupportConceptCostBearerRelDC ,
SupportConcept = lScNode . SupportConcept ,
2020-04-16 15:57:01 +02:00
SupportConceptCostBearerRelDC = MapperFactory . SupportConceptCostBearerRelDC_CostBearer2SupportConcept . MapToNewDC ( iSc2Cb )
} ;
2016-06-27 01:45:38 +02:00
2020-10-13 14:35:06 +02:00
if ( iSc2Cb . CostBearer . Organisation ! = null )
2016-06-27 01:45:38 +02:00
{
2020-04-16 15:57:01 +02:00
treeNode . Description = iSc2Cb . CostBearer . Organisation . Name ;
2016-06-27 01:45:38 +02:00
}
2020-04-16 15:57:01 +02:00
lScNode . ChildNodes . Add ( treeNode ) ;
2016-06-27 01:45:38 +02:00
}
lResult . Add ( lScNode ) ;
}
return lResult . OrderBy ( s = > s . Description ) . ToList ( ) ;
}
2018-02-19 18:34:20 +01:00
public void CreateNewPerson2OrganisationRelation ( long pOrganisationOid , ValueListEntryDC pValue , long personOid , string pMailAddress , string pFaxNumber , string pPhoneNumber , string pNotice )
2016-12-08 14:17:41 +01:00
{
try
{
2018-02-19 18:34:20 +01:00
var contactList = new List < Contact >
{
2019-07-12 12:52:47 +02:00
new Contact { Type = ContactType . business_Fax , Value = pFaxNumber } ,
new Contact { Type = ContactType . business_Mail , Value = pMailAddress } ,
2018-02-19 18:34:20 +01:00
new Contact { Type = ContactType . business_Phone , Value = pPhoneNumber }
} ;
2016-12-08 14:17:41 +01:00
2018-02-19 18:34:20 +01:00
var organisation2Person = new Organisation2Person
2016-12-08 14:17:41 +01:00
{
2019-09-02 15:48:37 +02:00
Organisation = DAOFactory . GenericDAO . LoadByID < Organisation > ( pOrganisationOid ) ,
2018-02-19 18:34:20 +01:00
Notice = pNotice ,
RolleInOrganisation = pValue ! = null ? DAOFactory . GenericDAO . LoadByID < ValueListEntry > ( pValue . ValueListEntryOid . Value ) : null ,
2019-09-02 15:48:37 +02:00
Person = DAOFactory . GenericDAO . LoadByID < Person > ( personOid ) ,
2019-07-12 12:52:47 +02:00
Contacts = contactList
2016-12-08 14:17:41 +01:00
} ;
2018-02-19 18:34:20 +01:00
DAOFactory . GenericDAO . Insert ( organisation2Person ) ;
2016-12-08 14:17:41 +01:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2016-12-08 14:17:41 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2017-11-14 10:46:54 +01:00
2018-05-23 10:37:57 +02:00
public void DeletePerson2OrganisationRelation ( long oid )
{
try
{
var organisation2Person = DAOFactory . GenericDAO . LoadByID < Organisation2Person > ( oid ) ;
DAOFactory . GenericDAO . Delete ( organisation2Person ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2018-05-23 10:37:57 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
public PdfChatHandoutDC GetHandOutPdfForChat ( string customerId , string apikey )
2017-10-11 14:45:11 +02:00
{
try
{
var handout = new PdfChatHandoutDC ( ) ;
2021-10-13 16:00:33 +02:00
var serverUrl = OwnChatHelper . ErmittleServerURL ( customerId ) ;
2017-10-12 12:58:09 +02:00
2020-04-08 14:25:01 +02:00
if ( serverUrl = = null )
2017-10-12 12:58:09 +02:00
{
handout . Result = 11 ;
return handout ;
}
2021-10-13 16:00:33 +02:00
if ( string . IsNullOrEmpty ( serverUrl ) )
2017-10-11 14:45:11 +02:00
{
handout . Result = 11 ;
return handout ;
}
var endurl = serverUrl + "/api/ownchat/createpdfmanual/" + apikey + "/" + customerId ;
2019-07-12 12:52:47 +02:00
2017-11-07 06:49:45 +01:00
//Bereich zum Testen Multiform Test gedönse
//using (MultipartFormDataContent multiPartContent = new MultipartFormDataContent())
//{
// Uri requestUri = new Uri(ChatDaten.ServerUrl + "/api/ownchat/createpdfmanual/");
2017-10-17 14:55:50 +02:00
2017-11-07 06:49:45 +01:00
// Links Content / Rechts name
// multiPartContent.Add(new StringContent(chatcode + ""), "chatcode");
// multiPartContent.Add(new StringContent(login + ""), "login");
// multiPartContent.Add(new StringContent(password + ""), "password");
2023-12-20 00:51:44 +01:00
// multiPartContent.Add(new StringContent("https://support.bewoplaner.de/bewoplaner_logo_small.png"), "custom_logo_url");
2017-10-17 14:55:50 +02:00
2017-11-07 06:49:45 +01:00
// httpRequest = new HttpRequestMessage();
// httpRequest.Method = HttpMethod.Post;
// httpRequest.RequestUri = requestUri;
// httpRequest.Content = multiPartContent;
2017-10-17 14:55:50 +02:00
2017-11-07 06:49:45 +01:00
// httpRequest.Headers.Add("Token", apikey);
// httpRequest.Headers.Add("CustomerID", customerId);
2017-10-17 14:55:50 +02:00
2017-11-07 06:49:45 +01:00
// 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;
//}
2017-10-12 12:58:09 +02:00
//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");
2023-12-20 00:51:44 +01:00
//dic.Add("custom_logo_url", "https://support.bewoplaner.de/bewoplaner_logo_small.png");
2017-10-12 12:58:09 +02:00
//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
2019-07-12 12:52:47 +02:00
2017-10-11 14:45:11 +02:00
2017-11-07 06:49:45 +01:00
//############################
2021-10-13 16:00:33 +02:00
var postparameter = new Dictionary < string , string >
{
{ "username" , "HAns" } ,
{ "password" , "Dito" } ,
//neu | hinzufügen laut document
{ "chatcode" , "yyAbrams" }
} ;
2017-11-07 06:49:45 +01:00
2021-10-13 16:00:33 +02:00
var postdaten = "" ;
//int i = 0;
2020-04-08 14:25:01 +02:00
foreach ( var key in postparameter . Keys )
2017-11-07 06:49:45 +01:00
{
//hier noch chatcode übergeben
postdaten + = HttpUtility . UrlEncode ( key ) + "=" + HttpUtility . UrlEncode ( postparameter [ key ] ) + "&" ;
}
2021-10-13 16:00:33 +02:00
var requesten = WebRequest . Create ( endurl ) ;
2017-11-07 06:49:45 +01:00
requesten . Method = "POST" ;
requesten . ContentType = "application/x-www-form-urlencoded" ;
2021-10-13 16:00:33 +02:00
var daten = Encoding . ASCII . GetBytes ( postdaten ) ;
2017-11-07 06:49:45 +01:00
requesten . ContentLength = daten . Length ;
try
{
2021-10-13 16:00:33 +02:00
var requestStream = requesten . GetRequestStream ( ) ;
2017-11-07 06:49:45 +01:00
requestStream . Write ( daten , 0 , daten . Length ) ;
requestStream . Close ( ) ;
}
2021-10-13 16:00:33 +02:00
catch ( Exception )
2017-11-07 06:49:45 +01:00
{
MessageBox . Show ( "Es konnte keine Verbindung aufgebaut werden." , "Fehler" , MessageBoxButton . OK ) ;
2019-07-12 12:52:47 +02:00
2017-11-07 06:49:45 +01:00
}
//response bereich | Verarbeiten
2021-10-13 16:00:33 +02:00
var response = ( HttpWebResponse ) requesten . GetResponse ( ) ;
2017-11-07 06:49:45 +01:00
//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();
2021-10-13 16:00:33 +02:00
using ( var stream = response . GetResponseStream ( ) )
2017-11-07 06:49:45 +01:00
{
2021-10-13 16:00:33 +02:00
var buffer = new byte [ stream . Length ] ;
2017-11-07 06:49:45 +01:00
stream . Read ( buffer , 0 , buffer . Length ) ;
File . WriteAllBytes ( "foo.pdf" , buffer ) ;
}
2017-10-11 14:45:11 +02:00
string responseFromServer = ReadStreamForChatCode ( response ) ;
2020-04-08 14:25:01 +02:00
if ( responseFromServer . Contains ( "PDF" ) )
2017-10-17 14:55:50 +02:00
{
2021-10-13 16:00:33 +02:00
var hd = new PdfChatHandoutDC
{
File = responseFromServer ,
Result = 0
} ;
2017-11-07 06:49:45 +01:00
//hd.TestStream = dataStream;
2017-10-17 14:55:50 +02:00
return hd ;
}
2021-10-13 16:00:33 +02:00
var jsonDatentyp = JsonConvert . DeserializeObject < PdfChatHandoutDC > ( responseFromServer ) ;
return jsonDatentyp ;
2017-10-11 14:45:11 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-10-11 14:45:11 +02:00
{
//throw Utils.CreateBeWoFaultException(e);
2021-10-13 16:00:33 +02:00
var handout = new PdfChatHandoutDC
{
Result = 60 ,
File = e . Message
} ;
2017-10-11 14:45:11 +02:00
2019-07-12 12:52:47 +02:00
return handout ;
2017-10-11 14:45:11 +02:00
}
2017-10-13 11:06:40 +02:00
}
2019-07-12 12:52:47 +02:00
public CustomerAPPCodeDC DeletCustomerChatCode ( string apikey , string kundennummer , long customeroid )
2017-10-13 11:06:40 +02:00
{
2020-04-16 15:57:01 +02:00
var customerAppCode = new CustomerAPPCodeDC ( ) ;
2017-11-16 15:37:29 +01:00
var result = DeletZufallsCode ( apikey , kundennummer , "C" + customeroid ) ;
2019-07-12 12:52:47 +02:00
2020-10-13 14:35:06 +02:00
if ( result = = 0 | | result = = 32 )
2017-10-13 11:06:40 +02:00
{
2017-11-16 15:37:29 +01:00
try
{
2020-04-16 15:57:01 +02:00
var customerappcode = DAOFactory . SearchDAO . FindAllCustomerAppCodes ( customeroid ) . ToList ( ) ;
2019-07-12 12:52:47 +02:00
2020-04-16 15:57:01 +02:00
var anzahl = customerappcode . Count ;
2017-10-13 11:06:40 +02:00
2020-10-13 14:35:06 +02:00
if ( anzahl > 0 )
2019-07-12 12:52:47 +02:00
{
2020-10-13 14:35:06 +02:00
foreach ( var code in customerappcode )
2017-11-16 15:37:29 +01:00
{
2020-04-16 15:57:01 +02:00
code . CustomerCode = string . Empty ;
code . CustomerCodeGenDate = DateTime . Now ;
2017-11-16 15:37:29 +01:00
}
2020-04-16 15:57:01 +02:00
DAOFactory . GenericDAO . Update ( customerappcode ) ;
customerAppCode . Result = 0 ;
return customerAppCode ;
2017-10-13 11:06:40 +02:00
}
2020-04-16 15:57:01 +02:00
customerAppCode . Result = 4 ;
return customerAppCode ;
2017-10-13 11:06:40 +02:00
}
2020-10-13 14:35:06 +02:00
catch ( Exception e )
2019-07-12 12:52:47 +02:00
{
2017-11-16 15:37:29 +01:00
throw Utils . CreateBeWoFaultException ( e ) ;
2017-10-13 11:06:40 +02:00
}
}
2020-04-16 15:57:01 +02:00
customerAppCode . Result = result ;
return customerAppCode ;
2017-10-13 11:06:40 +02:00
}
2019-07-12 12:52:47 +02:00
public EmployeeAPPCodeDC DeletEmployeeChatCode ( string apikey , string kundennummer , long employeeoid )
2017-10-13 11:06:40 +02:00
{
2020-04-16 15:57:01 +02:00
var employeeAppCode = new EmployeeAPPCodeDC ( ) ;
2017-11-16 15:37:29 +01:00
var result = DeletZufallsCode ( apikey , kundennummer , "E" + employeeoid ) ;
2017-11-13 16:37:21 +01:00
2020-10-13 14:35:06 +02:00
if ( result = = 0 | | result = = 32 )
2017-11-16 15:37:29 +01:00
{
try
{
2020-04-16 15:57:01 +02:00
var employeeappcode = DAOFactory . SearchDAO . FindAllEmployeeAppCodes ( employeeoid ) . ToList ( ) ;
2017-10-13 11:06:40 +02:00
2020-04-16 15:57:01 +02:00
var anzahl = employeeappcode . Count ;
2017-10-13 11:06:40 +02:00
2020-10-13 14:35:06 +02:00
if ( anzahl > 0 )
2017-10-13 11:06:40 +02:00
{
2020-10-13 14:35:06 +02:00
foreach ( var code in employeeappcode )
2017-11-16 15:37:29 +01:00
{
2020-04-16 15:57:01 +02:00
code . EmployeeCode = string . Empty ;
code . EmployeeCodeGenDate = DateTime . Now ;
}
2017-10-13 11:06:40 +02:00
2020-04-16 15:57:01 +02:00
DAOFactory . GenericDAO . Update ( employeeappcode ) ;
2017-10-13 11:06:40 +02:00
2020-04-16 15:57:01 +02:00
employeeAppCode . Result = 0 ; // alles ok
2017-10-13 11:06:40 +02:00
2020-04-16 15:57:01 +02:00
return employeeAppCode ;
2017-11-16 15:37:29 +01:00
}
2020-04-16 15:57:01 +02:00
employeeAppCode . Result = 4 ; // ChatCode Datensatz konnte nicht gefunden werden
return employeeAppCode ;
2017-10-13 11:06:40 +02:00
}
2020-10-13 14:35:06 +02:00
catch ( Exception e )
2017-10-13 11:06:40 +02:00
{
2017-11-16 15:37:29 +01:00
throw Utils . CreateBeWoFaultException ( e ) ;
2017-10-13 11:06:40 +02:00
}
}
2020-04-16 15:57:01 +02:00
employeeAppCode . Result = result ;
return employeeAppCode ;
2017-10-13 11:06:40 +02:00
}
2017-10-11 14:45:11 +02:00
2020-04-16 15:57:01 +02:00
public Dictionary < string , string > GetTranslationDictionary ( )
2017-11-06 10:30:25 +01:00
{
2020-04-16 15:57:01 +02:00
var translationDictionary = PluginLoader . FindClass < TranslationDictionary > ( ) ;
2017-11-06 10:30:25 +01:00
2020-04-16 15:57:01 +02:00
return translationDictionary ? . GetTranslationDictionary ( ) ;
2017-11-06 10:30:25 +01:00
}
2017-11-17 22:24:00 +01:00
public IList < TextbausteinDC > GetAllTextbausteine ( )
{
try
{
return MapperFactory . TextbausteinDC_Textbaustein . MapToNewDCs ( DAOFactory . GenericDAO . GetAllActive < Textbaustein > ( ) ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-11-17 22:24:00 +01:00
{
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 ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-11-17 22:24:00 +01:00
{
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 ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-11-17 22:24:00 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeleteTextbausteine ( Dictionary < long , long > pOid2Version )
{
try
{
2018-05-20 13:19:28 +02:00
var lOriginals = DAOFactory . GenericDAO . LoadByIDs < Textbaustein > ( pOid2Version . Select ( e = > e . Key ) ) ;
2017-11-17 22:24:00 +01:00
lOriginals . DoForEach ( or = > MapperFactory . TextbausteinDC_Textbaustein . ConcurrencyCheck ( pOid2Version [ or . Oid . Value ] , or ) ) ;
DAOFactory . GenericDAO . Delete ( lOriginals ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2017-11-17 22:24:00 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2018-10-08 11:57:16 +02:00
public SbdConfigDC GetSbdConfig ( )
{
try
{
var pi = PluginLoader . FindClass < SchulbegleitenderDienstService > ( ) ;
2020-04-08 14:25:01 +02:00
if ( pi ! = null )
2018-10-08 11:57:16 +02:00
{
return pi . GetSbdConfig ( ) ;
}
return new SbdConfigDC ( ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2018-10-08 11:57:16 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
2018-10-08 11:57:16 +02:00
public void SaveSbdConfig ( SbdConfigDC config )
{
try
{
var pi = PluginLoader . FindClass < SchulbegleitenderDienstService > ( ) ;
2020-04-16 15:57:01 +02:00
pi ? . SaveSbdConfig ( config ) ;
2018-10-08 11:57:16 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2018-10-08 11:57:16 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2018-05-22 17:19:56 +02:00
private static void AnonymizePerson ( long pPersonOid )
2018-05-20 13:19:28 +02:00
{
try
{
const string anonimyzedName = "Anonymisiert" ;
2018-05-22 17:19:56 +02:00
var pPerson = DAOFactory . GenericDAO . LoadByID < Person > ( pPersonOid ) ;
2019-07-12 12:52:47 +02:00
2018-05-22 17:19:56 +02:00
pPerson . Abbreviation = null ;
2020-04-08 14:25:01 +02:00
if ( pPerson . DateOfBirth ! = null )
2018-05-20 13:19:28 +02:00
{
2018-05-22 17:19:56 +02:00
pPerson . DateOfBirth = new DateTime ( pPerson . DateOfBirth . Value . Year , 1 , 1 ) ;
2018-05-20 13:19:28 +02:00
}
2018-05-22 17:19:56 +02:00
pPerson . FirstName = anonimyzedName ;
pPerson . LastName = anonimyzedName ;
pPerson . Notice = null ;
2020-04-08 14:25:01 +02:00
if ( pPerson . Address ! = null )
2018-05-20 13:19:28 +02:00
{
2018-05-22 17:19:56 +02:00
pPerson . Address . AddressLine1 = null ;
pPerson . Address . AddressLine2 = null ;
pPerson . Address . Country = null ;
pPerson . Address . Street = null ;
pPerson . Address . State = null ;
2018-05-23 10:45:20 +02:00
pPerson . Address . PostalCode = null ;
pPerson . Address . Town = null ;
2018-05-22 17:19:56 +02:00
pPerson . Address . InsUser = anonimyzedName ;
pPerson . Address . UdpUser = anonimyzedName ;
2018-05-20 13:19:28 +02:00
}
2018-05-22 17:19:56 +02:00
pPerson . AufenthaltsStatus = null ;
pPerson . Profession = null ;
pPerson . Title = null ;
pPerson . InsUser = anonimyzedName ;
pPerson . UdpUser = anonimyzedName ;
var bankaccountOid = pPerson . BankAccount ? . Oid ;
2018-05-20 13:19:28 +02:00
2020-04-08 14:25:01 +02:00
if ( bankaccountOid ! = null )
2018-05-20 13:19:28 +02:00
{
2018-05-22 17:19:56 +02:00
pPerson . BankAccount = null ;
2018-05-20 13:19:28 +02:00
}
2018-05-22 17:19:56 +02:00
pPerson . FamilyStatus = null ;
2020-04-08 14:25:01 +02:00
if ( pPerson . InvoiceAddress ! = null )
2018-05-20 13:19:28 +02:00
{
2018-05-22 17:19:56 +02:00
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 ;
2018-05-20 13:19:28 +02:00
}
2018-05-22 17:19:56 +02:00
pPerson . IsMigrant = false ;
pPerson . Nationalitaet = null ;
pPerson . Contacts . Clear ( ) ;
pPerson . Images ? . Clear ( ) ;
2019-07-12 12:52:47 +02:00
2018-05-22 17:19:56 +02:00
DAOFactory . GenericDAO . Update ( pPerson ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2018-05-22 17:19:56 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
2018-05-22 17:19:56 +02:00
public void AnonymizeCustomer ( long pCustomerOid )
{
try
{
const string anonimyzedName = "Anonymisiert" ;
var customer = DAOFactory . GenericDAO . GetByID < Customer > ( pCustomerOid ) ;
2018-05-20 13:19:28 +02:00
2020-04-08 14:25:01 +02:00
if ( customer . Person . Oid ! = null )
2018-05-22 17:19:56 +02:00
{
AnonymizePerson ( customer . Person . Oid . Value ) ;
}
2019-07-12 12:52:47 +02:00
2018-05-20 13:19:28 +02:00
customer . VarFieldValueList ? . Clear ( ) ;
2019-09-02 15:48:37 +02:00
customer . AbWelchemKrankheitsTag = 0 ;
2018-05-20 13:19:28 +02:00
customer . AbsenceTimes . DoForEach ( at = >
{
2019-09-02 15:48:37 +02:00
at . Notice = null ;
2018-05-20 13:19:28 +02:00
at . InsUser = anonimyzedName ;
at . UdpUser = anonimyzedName ;
} ) ;
2019-07-12 12:52:47 +02:00
2019-09-02 15:48:37 +02:00
customer . Ansprechpartner = null ;
2018-05-20 13:19:28 +02:00
customer . AssessmentSheetCategoryList ? . Clear ( ) ;
2019-09-02 15:48:37 +02:00
customer . AssistanceBegin = null ;
customer . AusstVersAmt = null ;
customer . AusweisGueltigBis = null ;
customer . AusweisGueltigVon = null ;
2018-05-20 13:19:28 +02:00
customer . AusweisUnbefristetGueltig = null ;
2021-02-15 08:04:40 +01:00
customer . AusweisAktenzeichen = null ;
2018-05-20 13:19:28 +02:00
customer . BehinderungsartenListe ? . Clear ( ) ;
2019-09-02 15:48:37 +02:00
customer . BeiblattGueltigBis = null ;
customer . Childs = null ;
customer . CostCenter = null ;
customer . Ansprechpartner = null ;
customer . AssistanceBegin = null ;
2018-05-20 13:19:28 +02:00
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 ;
} ) ;
2019-07-12 12:52:47 +02:00
2019-09-02 15:48:37 +02:00
customer . CustomerAlias = null ;
customer . DebitorNumber = null ;
customer . Diagnosis = null ;
2018-05-20 13:19:28 +02:00
customer . Diagnosis2CustomerList ? . Clear ( ) ;
2019-09-02 15:48:37 +02:00
customer . DistanceInMeter = null ;
2018-05-20 13:19:28 +02:00
customer . Employee2CustomerList ? . Clear ( ) ;
2019-09-02 15:48:37 +02:00
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 ;
2018-05-20 13:19:28 +02:00
customer . Medikamentenverordnungslisten ? . Clear ( ) ;
customer . MerkzeichenListe ? . Clear ( ) ;
2019-09-02 15:48:37 +02:00
customer . Notice = null ;
customer . Pflegegrad = null ;
2018-05-20 13:19:28 +02:00
customer . PlacementList ? . Clear ( ) ;
2019-09-02 15:48:37 +02:00
customer . ReferenceNumber = null ;
2018-05-20 13:19:28 +02:00
customer . Team2CustomerList ? . Clear ( ) ;
2019-09-02 15:48:37 +02:00
customer . TerminationDate = null ;
customer . TerminationReason = null ;
customer . UdpUser = anonimyzedName ;
2018-05-20 13:19:28 +02:00
customer . ValueList ? . Clear ( ) ;
customer . VertretungDringendErforderlich = false ;
2019-09-02 15:48:37 +02:00
customer . VertretungGewuenscht = false ;
2018-05-20 13:19:28 +02:00
2019-07-12 12:52:47 +02:00
customer . ServiceRecordList ? . DoForEach ( record = >
{
2019-09-02 15:48:37 +02:00
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 ;
2018-05-20 13:19:28 +02:00
} ) ;
customer . SupportConcepts ? . DoForEach ( supportConcept = >
{
2019-09-02 15:48:37 +02:00
supportConcept . Notice = null ;
2018-05-20 13:19:28 +02:00
supportConcept . InsUser = anonimyzedName ;
supportConcept . UdpUser = anonimyzedName ;
supportConcept . CostBearer2SupportConceptList . DoForEach ( cb2SC = >
{
cb2SC . CustomerReferenceNumber = null ;
2019-09-02 15:48:37 +02:00
cb2SC . Notice = null ;
cb2SC . InsUser = anonimyzedName ;
cb2SC . UdpUser = anonimyzedName ;
2018-05-20 13:19:28 +02:00
} ) ;
} ) ;
2020-04-08 14:25:01 +02:00
if ( customer . Oid ! = null )
2018-05-20 13:19:28 +02:00
{
var bargeldKassen = DAOFactory . SearchDAO . FindBargeldkasse ( TableID . Customer , customer . Oid . Value ) ;
2019-07-12 12:52:47 +02:00
2018-05-20 13:19:28 +02:00
DAOFactory . GenericDAO . Delete ( bargeldKassen ) ;
var fileAttachments = DAOFactory . SearchDAO . FindFileAttachments ( TableID . Customer , customer . Oid . Value ) ;
2019-07-12 12:52:47 +02:00
2021-03-30 16:35:45 +02:00
FileAttachmentUtils . DeleteFilesFromFileDirectory ( fileAttachments . Where ( fileAttachment = > fileAttachment . Oid . HasValue ) . Select ( fileAttachment = > fileAttachment . Oid . Value ) . ToList ( ) ) ;
2018-05-20 13:19:28 +02:00
DAOFactory . GenericDAO . Delete ( fileAttachments ) ;
}
2019-07-12 12:52:47 +02:00
2018-05-20 13:19:28 +02:00
DAOFactory . GenericDAO . Update ( customer ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2018-05-20 13:19:28 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-01 15:11:19 +02:00
// TODO: Den ersten Buchstaben des Klienten und den Namen des Mitarbeiters speichern, der ihn gelöscht hat. -> Neue Tabelle
2018-05-20 13:19:28 +02:00
public void DeleteCustomerForGood ( long pCustomerOid )
{
try
{
2019-07-01 15:11:19 +02:00
var deletionHistoryEntry = new DeletionHistory ( ) ;
2018-05-28 14:39:28 +02:00
var appointments = DAOFactory . SearchDAO . FindAppointmentsForCustomer ( pCustomerOid ) ;
var customer = DAOFactory . GenericDAO . LoadByID < Customer > ( pCustomerOid ) ;
2019-07-01 15:11:19 +02:00
var supportConceptOids = customer . SupportConcepts . Select ( sc = > sc . Oid . Value ) . ToList ( ) ;
UserDC user ;
2020-04-08 14:25:01 +02:00
if ( LoggedInUserOperationContextExt . Current ! = null & & LoggedInUserOperationContextExt . Current . User ! = null )
2019-07-01 15:11:19 +02:00
{
user = MapperFactory . UserDC_User . MapToNewDC ( LoggedInUserOperationContextExt . Current . User ) ;
}
else
{
user = MapperFactory . UserDC_User . MapToNewDC ( SessionFacade . LoggedInUser ) ;
}
2020-04-08 14:25:01 +02:00
if ( user ! = null )
2019-07-01 15:11:19 +02:00
{
string initial ;
2019-07-12 12:52:47 +02:00
2020-04-08 14:25:01 +02:00
if ( customer . Person . FirstName . Length > 0 )
2019-07-01 15:11:19 +02:00
{
initial = customer . Person . FirstName [ 0 ] . ToString ( ) ;
}
2020-04-08 14:25:01 +02:00
else if ( customer . Person . LastName . Length > 0 )
2019-07-01 15:11:19 +02:00
{
initial = customer . Person . LastName [ 0 ] . ToString ( ) ;
}
2020-04-08 14:25:01 +02:00
else if ( customer . CustomerAlias ? . Length > 0 )
2019-07-01 15:11:19 +02:00
{
initial = customer . CustomerAlias [ 0 ] . ToString ( ) ;
}
else
{
initial = "unbekannt" ;
}
2019-07-12 12:52:47 +02:00
2019-07-01 15:11:19 +02:00
deletionHistoryEntry . DeletingEmployeeName = $"{user.Employee.FirstName} {user.Employee.LastName}" ;
deletionHistoryEntry . DeletedEntityName = initial ;
deletionHistoryEntry . DeletedEntityTableId = TableID . Customer ;
}
2018-05-28 14:39:28 +02:00
appointments . DoForEach ( app = > app . CustomerList . Remove ( customer ) ) ;
2018-05-25 15:07:47 +02:00
2018-05-28 14:39:28 +02:00
DAOFactory . GenericDAO . Update ( appointments ) ;
2018-05-25 15:07:47 +02:00
2018-05-28 14:39:28 +02:00
var costBearer2SupportConcepts = new List < CostBearer2SupportConcept > ( ) ;
var groupsToGetReferencesRemoved = new List < GroupOfPeople > ( ) ;
2020-04-08 14:25:01 +02:00
foreach ( var sc in customer . SupportConcepts )
2018-05-28 14:39:28 +02:00
{
2020-04-08 14:25:01 +02:00
foreach ( var cb2sc in sc . CostBearer2SupportConceptList )
2018-05-28 14:39:28 +02:00
{
groupsToGetReferencesRemoved . AddRangeIfElementsNotIn ( DAOFactory . SearchDAO . GroupOfPeopleForSupportConcept ( cb2sc . Oid . Value ) ) ;
costBearer2SupportConcepts . AddIfNotIn ( cb2sc ) ;
}
}
2018-05-25 15:07:47 +02:00
2020-04-08 14:25:01 +02:00
foreach ( var group in groupsToGetReferencesRemoved )
2018-05-28 14:39:28 +02:00
{
group . CostBearer2SupportConceptList . RemoveRange ( costBearer2SupportConcepts ) ;
}
DAOFactory . GenericDAO . Update ( groupsToGetReferencesRemoved ) ;
DAOFactory . GenericDAO . Update ( customer . SupportConcepts ) ;
2019-07-01 15:11:19 +02:00
var additionalServiceGroups = DAOFactory . SearchDAO . GetAdditionalServiceGroupOfPeopleForCustomer ( customer . Oid . Value ) ;
2020-04-08 14:25:01 +02:00
foreach ( var additionalServiceGroup in additionalServiceGroups )
2019-07-01 15:11:19 +02:00
{
additionalServiceGroup . CustomerList . Remove ( customer ) ;
}
2018-05-28 14:39:28 +02:00
2019-07-01 15:11:19 +02:00
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 ) ;
2018-05-28 14:39:28 +02:00
customer . SupportConcepts . DoForEach ( s = > s . CostBearer2SupportConceptList ? . Clear ( ) ) ;
2020-04-08 14:25:01 +02:00
foreach ( var assessmentSheetCategory in customer . AssessmentSheetCategoryList )
2018-05-28 14:39:28 +02:00
{
assessmentSheetCategory . Customers . Remove ( customer ) ;
}
2019-07-01 15:11:19 +02:00
2018-05-28 14:39:28 +02:00
var assessmentSheetEntries = DAOFactory . SearchDAO . GetAssessmentSheetEntriesForCustomer ( customer . Oid . Value , DateTime . MinValue , DateTime . MaxValue ) ;
2019-07-01 15:11:19 +02:00
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 ) ;
2020-04-08 14:25:01 +02:00
if ( supportConceptOids . Any ( ) )
2019-07-01 15:11:19 +02:00
{
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 ) ;
2018-05-28 14:39:28 +02:00
DAOFactory . GenericDAO . Delete ( assessmentSheetEntries ) ;
2019-07-01 15:11:19 +02:00
2018-05-28 14:39:28 +02:00
DAOFactory . GenericDAO . Update ( customer ) ;
DAOFactory . GenericDAO . Delete ( customer . SupportConcepts ) ;
2018-05-25 15:07:47 +02:00
2018-05-28 14:39:28 +02:00
DAOFactory . GenericDAO . Delete ( DAOFactory . GenericDAO . LoadByID < Customer > ( customer . Oid . Value ) ) ;
2019-07-01 15:11:19 +02:00
2020-04-08 14:25:01 +02:00
if ( deletionHistoryEntry . DeletingEmployeeName ! = null )
2019-07-01 15:11:19 +02:00
{
DAOFactory . GenericDAO . Insert ( deletionHistoryEntry ) ;
}
2018-05-20 13:19:28 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2018-05-20 13:19:28 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
// TODO: implementieren!
public void DeletePersonForGood ( long pPersonOid )
{
try
{
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2018-05-20 13:19:28 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
// TODO: implementieren!
public void DeleteEmployeeForGood ( long pEmployeeOid )
{
try
{
2023-04-20 00:53:02 +02:00
var deletionHistoryEntry = new DeletionHistory ( ) ;
//var appointments = DAOFactory.SearchDAO.FindAppointmentsForEmployee(pEmployeeOid);
var emp = DAOFactory . GenericDAO . LoadByID < Employee > ( pEmployeeOid ) ;
//var supportConceptOids = customer.SupportConcepts.Select(sc => sc.Oid.Value).ToList();
UserDC user ;
if ( LoggedInUserOperationContextExt . Current ! = null & & LoggedInUserOperationContextExt . Current . User ! = null )
{
user = MapperFactory . UserDC_User . MapToNewDC ( LoggedInUserOperationContextExt . Current . User ) ;
}
else
{
user = MapperFactory . UserDC_User . MapToNewDC ( SessionFacade . LoggedInUser ) ;
}
if ( user ! = null )
{
string initial ;
if ( emp . Person . FirstName . Length > 0 )
{
initial = emp . Person . FirstName [ 0 ] . ToString ( ) ;
}
else if ( emp . Person . LastName . Length > 0 )
{
initial = emp . Person . LastName [ 0 ] . ToString ( ) ;
}
else
{
initial = "unbekannt" ;
}
deletionHistoryEntry . DeletingEmployeeName = $"{user.Employee.FirstName} {user.Employee.LastName}" ;
deletionHistoryEntry . DeletedEntityName = initial ;
deletionHistoryEntry . DeletedEntityTableId = TableID . Employee ;
}
//appointments.DoForEach(app => app.CustomerList.Remove(customer));
//DAOFactory.GenericDAO.Update(appointments);
//var costBearer2SupportConcepts = new List<CostBearer2SupportConcept>();
//var groupsToGetReferencesRemoved = new List<GroupOfPeople>();
//foreach (var sc in customer.SupportConcepts)
//{
// foreach (var cb2sc in sc.CostBearer2SupportConceptList)
// {
// groupsToGetReferencesRemoved.AddRangeIfElementsNotIn(DAOFactory.SearchDAO.GroupOfPeopleForSupportConcept(cb2sc.Oid.Value));
// costBearer2SupportConcepts.AddIfNotIn(cb2sc);
// }
//}
//foreach (var group in groupsToGetReferencesRemoved)
//{
// group.CostBearer2SupportConceptList.RemoveRange(costBearer2SupportConcepts);
//}
//DAOFactory.GenericDAO.Update(groupsToGetReferencesRemoved);
//DAOFactory.GenericDAO.Update(customer.SupportConcepts);
//var additionalServiceGroups = DAOFactory.SearchDAO.GetAdditionalServiceGroupOfPeopleForCustomer(customer.Oid.Value);
//foreach (var additionalServiceGroup in additionalServiceGroups)
//{
// additionalServiceGroup.CustomerList.Remove(customer);
//}
//DAOFactory.GenericDAO.Update(additionalServiceGroups);
//var additionalServiceBookings = DAOFactory.SearchDAO.GetAllAdditionalServiceBookingsForCustomer(customer.Oid.Value);
//DAOFactory.GenericDAO.Delete(additionalServiceBookings);
//var images2delete = customer.Person.Images;
//customer.Person.Images.Clear();
//DAOFactory.GenericDAO.Delete(images2delete);
//DAOFactory.GenericDAO.Update(customer);
//customer.SupportConcepts.DoForEach(s => s.CostBearer2SupportConceptList?.Clear());
//foreach (var assessmentSheetCategory in customer.AssessmentSheetCategoryList)
//{
// assessmentSheetCategory.Customers.Remove(customer);
//}
//var assessmentSheetEntries = DAOFactory.SearchDAO.GetAssessmentSheetEntriesForCustomer(customer.Oid.Value, DateTime.MinValue, DateTime.MaxValue);
//var invoiceBases2Delete = DAOFactory.SearchDAO.GetInvoiceBasesBySupportConceptOids(supportConceptOids);
//invoiceBases2Delete.DoForEach(ib => ib.InvoiceItems.Clear());
2018-05-20 13:19:28 +02:00
2023-04-20 00:53:02 +02:00
//var settlementInvoices = DAOFactory.SearchDAO.GetSettlementInvoiceBySupportConceptOids(supportConceptOids);
//var serviceInvoices = DAOFactory.SearchDAO.GetServiceInvoicesByInvoiceBaseOids(invoiceBases2Delete.Select(s => s.Oid.Value).ToList());
//var invoiceItems = new List<InvoiceItem>();
//invoiceBases2Delete.DoForEach(ib => invoiceItems.AddRange(ib.InvoiceItems));
//DAOFactory.GenericDAO.Update(invoiceBases2Delete);
//if (supportConceptOids.Any())
//{
// var tasksAndAppointments2Delete = DAOFactory.SearchDAO.GetTasksAndAppointmentsBySupportConceptOids(supportConceptOids);
// DAOFactory.GenericDAO.Delete(tasksAndAppointments2Delete);
//}
//DAOFactory.GenericDAO.Delete(invoiceItems);
//DAOFactory.GenericDAO.Delete(settlementInvoices);
//DAOFactory.GenericDAO.Delete(serviceInvoices);
//invoiceBases2Delete = DAOFactory.SearchDAO.GetInvoiceBasesBySupportConceptOids(supportConceptOids);
//DAOFactory.GenericDAO.Delete(invoiceBases2Delete);
//var customer2Tokens2Delete = DAOFactory.SearchDAO.GetCustomer2TokensByCustomerOid(customer.Oid.Value);
//DAOFactory.GenericDAO.Delete(customer2Tokens2Delete);
//DAOFactory.GenericDAO.Delete(assessmentSheetEntries);
//DAOFactory.GenericDAO.Update(customer);
//DAOFactory.GenericDAO.Delete(customer.SupportConcepts);
DAOFactory . GenericDAO . Delete ( emp ) ;
if ( deletionHistoryEntry . DeletingEmployeeName ! = null )
{
DAOFactory . GenericDAO . Insert ( deletionHistoryEntry ) ;
}
2024-04-17 16:33:19 +02:00
2018-05-20 13:19:28 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2018-05-20 13:19:28 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
// TODO: implementieren!
public void AnonymizeEmployee ( long pEmployeeOid )
{
try
{
2018-05-22 17:19:56 +02:00
var employee = DAOFactory . GenericDAO . LoadByID < Employee > ( pEmployeeOid ) ;
2020-04-08 14:25:01 +02:00
if ( employee . Person . Oid ! = null )
2018-05-22 17:19:56 +02:00
{
AnonymizePerson ( employee . Person . Oid . Value ) ;
}
var fileAttachments = DAOFactory . SearchDAO . FindFileAttachments ( TableID . Employee , pEmployeeOid ) ;
2021-03-30 16:35:45 +02:00
FileAttachmentUtils . DeleteFilesFromFileDirectory ( fileAttachments . Where ( fileAttachment = > fileAttachment . Oid . HasValue ) . Select ( fileAttachment = > fileAttachment . Oid . Value ) . ToList ( ) ) ;
2018-05-22 17:19:56 +02:00
DAOFactory . GenericDAO . Delete ( fileAttachments ) ;
employee . AbsenceTimes ? . Clear ( ) ;
2018-05-20 13:19:28 +02:00
2018-05-22 17:19:56 +02:00
DAOFactory . GenericDAO . Update ( employee ) ;
2018-05-20 13:19:28 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2018-05-20 13:19:28 +02:00
{
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
{
2018-05-23 12:33:10 +02:00
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 ) ;
2018-05-20 13:19:28 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2018-05-20 13:19:28 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-12 12:52:47 +02:00
2018-05-20 13:19:28 +02:00
public string GetMessageFromServer ( TableID pObjectTid , long? pObjectOid , MessageType pMessageType )
{
try
{
var actualTextMessage = "" ;
const string foreground = "Foreground=\"Red\"" ;
const string fontWeight = "FontWeight=\"Bold\"" ;
2019-07-12 12:52:47 +02:00
2020-04-08 14:25:01 +02:00
if ( pObjectTid = = TableID . Customer & & pMessageType = = MessageType . Anonymization )
2018-05-20 13:19:28 +02:00
{
actualTextMessage = "Achtung!

Das Anonymisieren eines Klienten kann nicht rückgängig gemacht werden!
" ;
}
2020-04-08 14:25:01 +02:00
if ( pObjectTid = = TableID . Customer & & pMessageType = = MessageType . DeleteForGood )
2018-05-20 13:19:28 +02:00
{
actualTextMessage = "Achtung!

Das endgültige Löschen eines Klienten kann nicht rückgängig gemacht werden!
" ;
}
2020-04-08 14:25:01 +02:00
if ( pObjectTid = = TableID . Person & & pMessageType = = MessageType . DeleteForGood )
2018-05-20 13:19:28 +02:00
{
actualTextMessage = "Achtung!

Das endgültige Löschen einer Person kann nicht rückgängig gemacht werden!
" ;
}
2020-04-08 14:25:01 +02:00
if ( pObjectTid = = TableID . Employee & & pMessageType = = MessageType . Anonymization )
2018-05-20 13:19:28 +02:00
{
actualTextMessage = "Achtung!

Das Anonymisieren eines Mitarbeiters kann nicht rückgängig gemacht werden!
" ;
}
2020-04-08 14:25:01 +02:00
if ( pObjectTid = = TableID . Employee & & pMessageType = = MessageType . DeleteForGood )
2018-05-20 13:19:28 +02:00
{
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}\"/>";
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2018-05-20 13:19:28 +02:00
{
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 ) ;
2019-07-12 12:52:47 +02:00
2018-05-20 13:19:28 +02:00
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}\"/>";
}
2019-04-17 17:01:37 +02:00
public SignatureDC GetSignature ( long pSignatureOid )
{
try
{
var lOriginal = DAOFactory . GenericDAO . LoadByID < Signature > ( pSignatureOid ) ;
return MapperFactory . SignatureDC_Signature . MapToNewDC ( lOriginal ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2019-04-17 17:01:37 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-10 10:11:10 +02:00
public List < BudgetDC > GetAllBudgets ( )
{
try
{
var list = DAOFactory . GenericDAO . GetAllActive < Budget > ( ) ;
return MapperFactory . BudgetDC_Budget . MapToNewDCs ( list ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2019-07-10 10:11:10 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void InsertNewBudget ( List < BudgetDC > budgets )
{
try
{
var budget = MapperFactory . BudgetDC_Budget . MapToNewEntities ( budgets ) ;
DAOFactory . GenericDAO . Insert ( budget ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2019-07-10 10:11:10 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeactivateBudget ( Dictionary < long , long > pOid2Version )
{
try
{
ServiceLogic . SetActivationType < Budget > ( pOid2Version , ActivationTypeId . Deleted ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2019-07-10 10:11:10 +02:00
{
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 ) ;
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2019-07-10 10:11:10 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-08-04 14:30:26 +02:00
public List < PreisDC > GetAllPreise ( )
{
try
{
var list = DAOFactory . GenericDAO . GetAllActive < Preis > ( ) ;
return MapperFactory . PreisDC_Preis . MapToNewDCs ( list ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void InsertNewPreis ( List < PreisDC > preise )
{
try
{
var preis = MapperFactory . PreisDC_Preis . MapToNewEntities ( preise ) ;
DAOFactory . GenericDAO . Insert ( preis ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeactivatePreis ( Dictionary < long , long > pOid2Version )
{
try
{
ServiceLogic . SetActivationType < Preis > ( pOid2Version , ActivationTypeId . Deleted ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void UpdatePreis ( List < PreisDC > preise )
{
try
{
var lOriginals = DAOFactory . GenericDAO . LoadByIDs < Preis > ( preise . Select ( sc = > sc . PreisOid . Value ) ) ;
MapperFactory . PreisDC_Preis . MergeWithEntitys ( preise , lOriginals ) ;
DAOFactory . GenericDAO . Update ( lOriginals ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-07-29 14:21:49 +02:00
public FlexibleReportResultDC GetFlexibleReportResult ( FlexibleReportFilterDC filter )
2019-07-10 10:11:10 +02:00
{
try
{
2021-02-19 11:04:33 +01:00
return FlexibleReportManager . GetFlexibleReportResult ( filter ) ;
2019-07-10 10:11:10 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2019-07-10 10:11:10 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-09-02 15:48:37 +02:00
2019-07-25 15:16:24 +02:00
public IList < FlexibleReportLayoutDC > GetFlexibleReportLayouts ( )
2019-07-10 10:11:10 +02:00
{
2021-02-19 11:04:33 +01:00
try
2019-07-10 10:11:10 +02:00
{
2021-02-19 11:04:33 +01:00
return FlexibleReportManager . GetFlexibleReportLayouts ( ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
2019-07-10 10:11:10 +02:00
}
}
2019-07-25 15:16:24 +02:00
public void InsertNewFlexibleReportLayout ( FlexibleReportLayoutDC flexibleReportLayoutDC )
2019-07-10 10:11:10 +02:00
{
2019-07-25 15:16:24 +02:00
try
2019-07-10 10:11:10 +02:00
{
2021-02-19 11:04:33 +01:00
FlexibleReportManager . InsertNewFlexibleReportLayout ( flexibleReportLayoutDC ) ;
2019-07-10 10:11:10 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2019-07-12 12:52:47 +02:00
{
2019-07-25 15:16:24 +02:00
throw Utils . CreateBeWoFaultException ( e ) ;
2019-07-12 12:52:47 +02:00
}
}
2019-07-25 15:16:24 +02:00
public void UpdateFlexibleReportLayouts ( IList < FlexibleReportLayoutDC > flexibleReportLayouts )
2019-07-12 12:52:47 +02:00
{
2019-07-25 15:16:24 +02:00
try
2019-07-10 10:11:10 +02:00
{
2021-02-19 11:04:33 +01:00
FlexibleReportManager . UpdateFlexibleReportLayouts ( flexibleReportLayouts ) ;
2019-07-15 17:18:09 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception e )
2019-07-15 17:18:09 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2019-08-08 14:47:53 +02:00
2019-09-02 15:48:37 +02:00
public bool CheckForOverlappingSubstitutionEntries ( DateTime startDate , DateTime endDate , long? employeeOid , long? customerOid , long? substitutionOid )
2019-08-08 14:47:53 +02:00
{
try
{
2019-09-02 15:48:37 +02:00
return DAOFactory . SearchDAO . CheckForOverlappingSubstitutions ( employeeOid , customerOid , startDate , endDate , substitutionOid ) ;
2019-08-08 14:47:53 +02:00
}
2019-08-26 16:11:00 +02:00
catch ( Exception e )
2019-08-08 14:47:53 +02:00
{
2019-08-26 16:11:00 +02:00
throw Utils . CreateBeWoFaultException ( e ) ;
2019-08-08 14:47:53 +02:00
}
}
2019-08-12 16:49:42 +02:00
public IList < HomeViewPanelDC > GetHomeViewPanels ( )
{
try
{
2023-06-07 17:38:11 +02:00
var hcg = PluginLoader . FindClass < HomeContentGenerator > ( ) ;
return hcg . GetHomeViewPanels ( ) ;
2019-08-12 16:49:42 +02:00
}
2020-04-08 14:25:01 +02:00
catch ( Exception exception )
2019-09-02 15:48:37 +02:00
{
throw Utils . CreateBeWoFaultException ( exception ) ;
}
}
public bool CheckForOverlappingAbsenceTimes ( DateTime startDate , DateTime endDate , long? employeeOid , long? customerOid )
{
try
{
return DAOFactory . SearchDAO . CheckForOverlappingAbsenceTimes ( startDate , endDate , employeeOid , customerOid ) ;
}
2019-08-26 16:11:00 +02:00
catch ( Exception e )
2019-08-12 16:49:42 +02:00
{
2019-08-26 16:11:00 +02:00
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2020-04-08 14:25:01 +02:00
2019-08-26 16:11:00 +02:00
public IList < ValueListEntryDC > GetIcf ( )
{
try
2019-08-12 16:49:42 +02:00
{
2021-12-13 08:07:09 +01:00
#region auskommentiert
2019-11-14 16:05:43 +01:00
//string key = "2BT%eGprU\"E$!\"5Flq@l^^KZaYa\"u/icq@MMSWsy$XFo@#q3Arbnx@Plzv7s\\+$a";
2019-09-17 17:44:57 +02:00
2019-11-14 16:05:43 +01:00
//string url = "https://support.bewoplaner.de/api/geticf.php?k=[TENANT]";
2019-09-17 17:44:57 +02:00
2019-11-14 16:05:43 +01:00
//if (MultitenancyOperationContextExt.Current != null)
//{
// url = url.Replace("[TENANT]", MultitenancyOperationContextExt.Current.Tenant);
//}
//else
//{
// url = url.Replace("[TENANT]", SessionFacade.Tenant);
//}
2019-09-17 17:44:57 +02:00
2019-11-14 16:05:43 +01:00
//String json = "";
2019-09-17 17:44:57 +02:00
2019-11-14 16:05:43 +01:00
//using (var client = new WebClient())
//{
// byte[] response = client.UploadValues(url, "POST", new NameValueCollection()
// {
// {"API-KEY", key}
// });
2019-09-17 17:44:57 +02:00
2019-11-14 16:05:43 +01:00
// json = System.Text.Encoding.ASCII.GetString(response);
2019-09-17 17:44:57 +02:00
2019-11-14 16:05:43 +01:00
//}
2019-09-17 17:44:57 +02:00
//[{"Oid":"1","Code":"","Bezeichnung":"Kapitel 1: Lernen und Wissensanwendung","Beschreibung":"","ParentOID":""}
//var icfentry = new { Oid = 0, Code = "", Bezeichnung = "", Beschreibung = "", ParentOid = 0 };
2019-11-14 16:05:43 +01:00
//var icfList = JsonConvert.DeserializeObject<List<Icf>>(json);
2019-09-17 17:44:57 +02:00
2019-11-14 16:05:43 +01:00
////var rawList = DAOFactory.GenericDAO.GetAll<Icf>().ToList();
2019-08-26 16:11:00 +02:00
2019-11-14 16:05:43 +01:00
//var icfs = new List<ValueListEntryDC>
//{
// new ValueListEntryDC() {ParentOid = -1, TypeDescription = "ICF"}
//};
2019-08-26 16:11:00 +02:00
2019-11-14 16:05:43 +01:00
//icfs.AddRange(icfList.Select(x => new ValueListEntryDC()
//{
// ValueListEntryOid = x.Oid,
// ParentOid = x.ParentOID,
// TypeDescription = x.Bezeichnung,
// Abbreviation = x.Code,
// Notice = x.Beschreibung
//}));
2021-11-09 16:48:58 +01:00
//var wholeICF = ICFDAO.GetWholeIcf();
2021-12-13 08:07:09 +01:00
#endregion
2019-11-14 16:05:43 +01:00
return ICFDAO . GetIcf ( ) ;
2019-08-26 16:11:00 +02:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-12-01 14:09:56 +01:00
public List < ValueListEntryDC > GetWholeIcf ( )
2021-11-09 16:48:58 +01:00
{
try
2024-04-17 16:33:19 +02:00
{
2021-11-09 16:48:58 +01:00
return ICFDAO . GetWholeIcf ( ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2022-08-10 14:13:29 +02:00
2021-12-13 08:07:09 +01:00
public List < ValueListEntryDC > GetWholeIcfOhneImportierte ( List < ValueListEntryDC > vorhandeneZiele )
{
try
{
List < ValueListEntryDC > listeMitUeberschneidungen = new List < ValueListEntryDC > ( ) ;
var icf = ICFDAO . GetWholeIcf ( ) ;
foreach ( var chapter in icf )
{
foreach ( var vorhandenesKapitel in vorhandeneZiele )
2024-04-17 16:33:19 +02:00
{
2021-12-13 08:07:09 +01:00
// TEMPORÄR ZUM TESTEN; Richtiger Ansatz, aber muss differenzieren, ob es oberkapitel sind
2024-04-17 16:33:19 +02:00
if ( vorhandenesKapitel ! = null & & vorhandenesKapitel . DisplayName = = chapter . DisplayName & & ! vorhandenesKapitel . DisplayName . Contains ( "ICF" ) & &
2021-12-13 08:07:09 +01:00
! vorhandenesKapitel . DisplayName . Contains ( "Komponente" ) & & ! vorhandenesKapitel . DisplayName . Contains ( "Kapitel" ) )
{
if ( ! icf . Any ( c = > c . ParentOid = = vorhandenesKapitel . ValueListEntryOid ) )
{
2024-04-17 16:33:19 +02:00
listeMitUeberschneidungen . Add ( chapter ) ;
2021-12-13 08:07:09 +01:00
}
}
}
}
// Statt Parent-Objekten vllt eher Children zusammensuchen?
List < ValueListEntryDC > parentObjekte = new List < ValueListEntryDC > ( ) ;
foreach ( var item in listeMitUeberschneidungen )
{
if ( item . ValueListEntryOid = = 85 )
Console . WriteLine ( "hallo" ) ;
if ( item . ParentOid ! = null )
{
var parent = listeMitUeberschneidungen . FirstOrDefault ( i = > i . ValueListEntryOid = = item . ParentOid ) ;
if ( parent ! = null )
{
parentObjekte . Add ( parent ) ;
}
}
}
//listeMitUeberschneidungen.RemoveRange(parentObjekte);
Dictionary < long? , List < ValueListEntryDC > > alleKinderDerVadderOid = new Dictionary < long? , List < ValueListEntryDC > > ( ) ;
foreach ( var item in icf )
{
if ( item . ParentOid . HasValue & & ! alleKinderDerVadderOid . ContainsKey ( item . ParentOid . Value ) )
{
alleKinderDerVadderOid . Add ( item . ParentOid . Value , new List < ValueListEntryDC > ( ) ) ;
}
if ( alleKinderDerVadderOid . ContainsKey ( item . ParentOid . Value ) )
{
alleKinderDerVadderOid [ item . ParentOid . Value ] . Add ( item ) ;
}
}
//icf.RemoveRange(listeMitUeberschneidungen);
icf = EntferneParentOhneKinder ( listeMitUeberschneidungen , alleKinderDerVadderOid , icf ) ;
var funktionenDesBewusstseins = icf . Where ( i = > i . DisplayName . Contains ( "Funktionen des Bewusstseins" ) ) . ToList ( ) ;
return icf ;
// Komplett importiertes verschwindet jetzt, außer alles, wo "Kapitel", "Komponente" oder "ICF" enthalten ist (if-Bedingungen weiter oben)
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2024-04-17 16:33:19 +02:00
// enthält alles, außer das, was gebraucht wird
2021-12-13 08:07:09 +01:00
private List < ValueListEntryDC > EntferneParentOhneKinder ( List < ValueListEntryDC > listeMitUeberschneidungen , Dictionary < long? , List < ValueListEntryDC > > alleKinderDerVadderOid , List < ValueListEntryDC > icf )
{
// Zum Zeitpunkt des Aufrufens dieser Methode sind alle Ziele, die bereits importiert wurden, aus dem ICF entfernt, sofern diese keine Kinder mehr haben
// (also alle "Blätter" des Baums. Die leeren Äste sind allerdings noch da. Jeder Ast muss jetzt geprüft werden, und zwar darauf, ob er noch mindestens ein Blatt hat)
List < ValueListEntryDC > toRemove = new List < ValueListEntryDC > ( ) ;
foreach ( var item in listeMitUeberschneidungen )
{
var kinderlisteFuerCurrent = ( alleKinderDerVadderOid . ContainsKey ( item . ValueListEntryOid ) ) ? alleKinderDerVadderOid [ item . ValueListEntryOid ] : null ;
bool enthealtBereitsAlleKinder = true ;
if ( kinderlisteFuerCurrent ! = null )
{
foreach ( var child in kinderlisteFuerCurrent )
{
if ( ! listeMitUeberschneidungen . Contains ( child ) )
{
enthealtBereitsAlleKinder = false ;
break ;
}
}
}
if ( enthealtBereitsAlleKinder )
toRemove . Add ( item ) ;
}
//icf.RemoveRange(toRemove); // Entfernen klappt nicht
for ( int i = icf . Count - 1 ; i > = 0 ; i - - )
{
var current = icf [ i ] ;
foreach ( var c in toRemove ) // In toRemove stehen alle drin, die nicht sollen, und nur das gewollte fehlt (noch in listeMitUeberschneidungen)
{
if ( current . ValueListEntryOid = = 85 )
Console . WriteLine ( "hallo" ) ; // Es gibt im ICF keinen Eintrag damit.. hä?
if ( c . ValueListEntryOid = = 85 )
Console . WriteLine ( "hallo" ) ;
if ( c . ValueListEntryOid = = current . ValueListEntryOid )
{
icf . Remove ( c ) ; // Code kommt hier nicht an
}
}
}
return icf ;
}
2019-08-29 12:38:48 +02:00
public IList < ReportTemplateDC > GetReportTemplates ( string url )
2019-08-26 16:11:00 +02:00
{
try
{
2019-08-29 12:38:48 +02:00
if ( url . IsNullOrEmpty ( ) )
return null ;
var index = url . IndexOf ( "type=" ) + 5 ;
var typeString = url . Substring ( index ) ;
2021-10-28 12:07:51 +02:00
if ( typeString . IndexOf ( "&" ) > 0 )
{
typeString = typeString . Substring ( 0 , typeString . IndexOf ( "&" ) ) ;
}
2019-08-29 12:38:48 +02:00
if ( ! Enum . TryParse ( typeString , out ReportTypes reportType ) )
return null ;
2020-04-08 14:25:01 +02:00
2021-10-28 12:07:51 +02:00
var list = MapperFactory . ReportTemplateDC_ReportTemplate . MapToNewDCs ( DAOFactory . GenericDAO . GetAllActive < ReportTemplate > ( ) . Where ( x = > x . ReportTemplateType = = reportType ) ) ;
if ( list . Count = = 0 & & reportType = = ReportTypes . RosterReport )
{
list . Add ( new ReportTemplateDC
{
DisplayName = "Dienstplanung" ,
ReportTemplateType = ReportTypes . RosterReport ,
Oid = - 1
} ) ;
list . Add ( new ReportTemplateDC
{
DisplayName = "Arbeitszeiterfassung" ,
ReportTemplateType = ReportTypes . RosterReportIst ,
Oid = - 2
} ) ;
}
return list ;
2019-08-26 16:11:00 +02:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
2019-08-12 16:49:42 +02:00
}
}
2019-12-12 18:30:58 +01:00
2020-10-13 14:35:06 +02:00
//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);
// }
//}
2019-12-12 18:30:58 +01:00
public IList < AbsenceReasonDC > GetAllAbsenceReason ( )
{
2020-09-30 10:00:31 +02:00
try
{
var list = DAOFactory . GenericDAO . GetAllActive < AbsenceReason > ( ) ;
return MapperFactory . AbsenceReasonDC_AbsenceReason . MapToNewDCs ( list ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
2019-12-12 18:30:58 +01:00
}
2020-01-30 20:44:35 +01:00
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 ) ;
}
}
2020-04-02 13:19:14 +02:00
public List < SupportConceptCostBearerRelDC > GetSupportConceptCostBearerRelDCsByOids ( List < long > supportConcept2CostbearerOids )
{
var costbearer2SupportConcepts = DAOFactory . SearchDAO . FindCostBearer2SupportConceptsByOids ( supportConcept2CostbearerOids ) ;
return MapperFactory . SupportConceptCostBearerRelDC_CostBearer2SupportConcept . MapToNewDCs ( costbearer2SupportConcepts ) ;
}
2020-08-19 12:15:10 +02:00
2021-10-12 16:00:17 +02:00
public List < DienstInfoDC > GetAllDienste ( long? wOid )
2020-04-08 14:25:01 +02:00
{
2020-09-30 10:00:31 +02:00
try
{
2021-10-12 16:00:17 +02:00
return DienstplanungsManager . GetAllDienste ( wOid ) ;
2020-09-30 10:00:31 +02:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
2020-04-08 14:25:01 +02:00
}
2020-09-30 10:00:31 +02:00
public void InsertNewDienst ( List < DienstInfoDC > dienst )
2020-04-08 14:25:01 +02:00
{
try
{
2021-02-15 08:04:40 +01:00
DienstplanungsManager . InsertNewDienst ( dienst ) ;
2020-04-08 14:25:01 +02:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeactivateDienst ( Dictionary < long , long > pOid2Version )
{
try
{
2021-02-15 08:04:40 +01:00
DienstplanungsManager . DeactivateDienst ( pOid2Version ) ;
2020-04-08 14:25:01 +02:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2020-09-30 10:00:31 +02:00
public void UpdateDienst ( List < DienstInfoDC > dienste )
2020-04-08 14:25:01 +02:00
{
try
{
2021-02-15 08:04:40 +01:00
DienstplanungsManager . UpdateDienst ( dienste ) ;
2020-04-08 14:25:01 +02:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2020-08-17 15:50:00 +02:00
public List < RatingTypeDC > GetAllRatingTypes ( )
{
try
{
var list = DAOFactory . GenericDAO . GetAllActive < RatingType > ( ) ;
var result = MapperFactory . RatingTypeDC_RatingType . MapToNewDCs ( list ) ;
2020-10-13 14:35:06 +02:00
2020-08-17 15:50:00 +02:00
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
{
2020-09-23 22:10:52 +02:00
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 ) ) ;
}
}
2020-08-17 15:50:00 +02:00
var allRatingTypes = MapperFactory . RatingTypeDC_RatingType . MapToNewDCs ( DAOFactory . GenericDAO . GetAllActive < RatingType > ( ) ) ;
2020-10-13 14:35:06 +02:00
2020-08-17 15:50:00 +02:00
List < GoalRatingDC > result = new List < GoalRatingDC > ( ) ;
2022-02-15 14:59:07 +01:00
if ( end . HasValue )
{
end = end . Value . Date . AddDays ( 1 ) . AddSeconds ( - 1 ) ;
}
2020-08-17 15:50:00 +02:00
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 )
{
2022-06-23 21:14:29 +02:00
var gr = new GoalRatingDC ( ) ;
gr . GoalEntry = ve ;
2024-04-17 16:33:19 +02:00
2022-06-23 21:14:29 +02:00
2022-02-15 14:59:07 +01:00
if ( ve . Type = = ValueListEntryType . SupportConceptGoalType | | ve . Type = = ValueListEntryType . SupportConceptIndividualGoalType )
2024-04-17 16:33:19 +02:00
{
2022-02-15 14:59:07 +01:00
//Bei Maßnahmen nimm das übergeordnete Ziel
if ( ve . ParentOid . HasValue & & oid2Entry . ContainsKey ( ve . ParentOid . Value ) )
2020-08-17 15:50:00 +02:00
{
2022-02-15 14:59:07 +01:00
gr . GoalEntry = oid2Entry [ ve . ParentOid . Value ] ;
}
2022-06-23 21:14:29 +02:00
}
2020-09-23 22:10:52 +02:00
2022-06-23 21:14:29 +02:00
gr . ServiceRecord = dc ;
if ( ve . RatingTypeOid . HasValue )
{
gr . RatingType = allRatingTypes . FirstOrDefault ( r = > r . RatingTypeOid . HasValue & & r . RatingTypeOid = = ve . RatingTypeOid ) ;
2020-08-17 15:50:00 +02:00
}
2022-06-23 21:14:29 +02:00
result . Add ( gr ) ;
2020-08-17 15:50:00 +02:00
}
}
2020-10-13 14:35:06 +02:00
2020-08-17 15:50:00 +02:00
}
2020-10-13 14:35:06 +02:00
2020-08-17 15:50:00 +02:00
return result ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2020-09-23 16:00:51 +02:00
2021-03-15 13:30:34 +01:00
public List < DienstEintragDC > GetAllDienstEintraegeAsList ( long wOid , int year , int month )
{
try
{
return DienstplanungsManager . GetAllDienstEintraegeAsList ( wOid , year , month ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < DienstvertretungDC > GetAllDienstvertretungenAsList ( long wOid , int year , int month )
{
try
{
return DienstplanungsManager . GetAllDienstvertretungenAsList ( wOid , year , month ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2020-09-30 10:00:31 +02:00
public List < DienstBlockDC > GetDienstEintraege ( long wOid , int year , int month )
{
try
{
2021-02-15 08:04:40 +01:00
return DienstplanungsManager . GetDienstEintraege ( wOid , year , month ) ;
2020-09-30 10:00:31 +02:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-03-09 15:23:06 +01:00
public List < DienstBlockDC > GetDienstvertretungen ( long wOid , int year , int month )
{
try
{
return DienstplanungsManager . GetDienstvertretungen ( wOid , year , month ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2020-09-30 10:00:31 +02:00
2021-01-29 14:37:43 +01:00
2020-09-30 10:00:31 +02:00
public void InsertNewDienstEintrag ( DienstEintragDC dienstEintrag )
{
try
{
2021-02-15 08:04:40 +01:00
DienstplanungsManager . InsertNewDienstEintrag ( dienstEintrag ) ;
2020-09-30 10:00:31 +02:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2022-03-14 07:08:32 +01:00
public bool InsertNewDienstEintrag2 ( DienstEintragDC dienstEintrag , List < DienstEintragDC > alleDiensteintraege , List < DienstvertretungDC > alleDienstvertretungen ,
int day , DateTime pflichtStart , DateTime pflichtEnde )
{
try
{
return DienstplanungsManager . InsertNewDienstEintrag2 ( dienstEintrag , alleDiensteintraege , alleDienstvertretungen , day , pflichtStart , pflichtEnde ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-09-22 15:34:38 +02:00
public void InsertNewDienstEintraege ( List < DienstEintragDC > dienstEintraege )
{
try
{
DienstplanungsManager . InsertNewDienstEintraege ( dienstEintraege ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
2020-09-30 10:00:31 +02:00
}
}
2021-03-09 15:23:06 +01:00
public void InsertNewDienstvertretung ( DienstvertretungDC dienstvertretung )
{
try
{
DienstplanungsManager . InsertNewDienstvertretung ( dienstvertretung ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2022-03-14 07:08:32 +01:00
public bool InsertNewDienstvertretung2 ( DienstvertretungDC dienstvertretung , List < DienstEintragDC > alleDiensteintraege , List < DienstvertretungDC > alleDienstvertretungen ,
int day , DateTime pflichtStart , DateTime pflichtEnde )
{
try
{
return DienstplanungsManager . InsertNewDienstvertretung2 ( dienstvertretung , alleDiensteintraege , alleDienstvertretungen , day , pflichtStart , pflichtEnde ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-03-09 15:23:06 +01:00
2020-09-30 10:00:31 +02:00
public void UpdateDienstEintrag ( DienstEintragDC dienstEintrag )
{
try
{
2021-03-09 15:23:06 +01:00
DienstplanungsManager . UpdateDienstEintrag ( dienstEintrag ) ;
2020-09-30 10:00:31 +02:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeleteDienstEintrag ( long empId , long wohnId , int zeile , DateTime date )
{
try
{
2021-02-15 08:04:40 +01:00
DienstplanungsManager . DeleteDienstEintrag ( empId , wohnId , zeile , date ) ;
2020-09-30 10:00:31 +02:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2024-04-17 16:33:19 +02:00
public bool DeleteDienstEintrag2 ( long empId , long wohnId , int zeile , DateTime date , DienstEintragDC dienstEintrag , List < DienstEintragDC > alleDiensteintraege ,
2022-03-14 07:08:32 +01:00
List < DienstvertretungDC > alleDienstvertretungen , int day , DateTime pflichtStart , DateTime pflichtEnde )
{
try
{
return DienstplanungsManager . DeleteDienstEintrag2 ( empId , wohnId , zeile , date , dienstEintrag , alleDiensteintraege , alleDienstvertretungen , day , pflichtStart , pflichtEnde ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-03-10 12:31:31 +01:00
public void DeleteDienstvertretung ( long empId , long wohnId , int zeile , DateTime date )
{
try
{
DienstplanungsManager . DeleteDienstvertretung ( empId , wohnId , zeile , date ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2022-03-14 07:08:32 +01:00
public bool DeleteDienstvertretung2 ( long empId , long wohnId , int zeile , DateTime date , DienstvertretungDC dienstvertretung , List < DienstEintragDC > alleDiensteintraege ,
List < DienstvertretungDC > alleDienstvertretungen , int day , DateTime pflichtStart , DateTime pflichtEnde )
{
try
{
return DienstplanungsManager . DeleteDienstvertretung2 ( empId , wohnId , zeile , date , dienstvertretung , alleDiensteintraege , alleDienstvertretungen , day , pflichtStart , pflichtEnde ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-02-10 14:02:59 +01:00
public void DeleteCertainDienstEintragOutOfTable ( long dienstEintragOid )
{
try
{
2021-02-15 08:04:40 +01:00
DienstplanungsManager . DeleteCertainDienstEintragOutOfTable ( dienstEintragOid ) ;
2021-02-10 14:02:59 +01:00
}
catch ( Exception ex )
{
throw Utils . CreateBeWoFaultException ( ex ) ;
}
}
2021-03-09 15:23:06 +01:00
public string GetBemerkungForDienstEintrag ( long empId , long wohnId , int zeile , DateTime date )
{
try
{
return DienstplanungsManager . GetBemerkungForDienstEintrag ( empId , wohnId , zeile , date ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public DienstEintragDC GetDienstEintrag ( long empId , long wohnId , int zeile , DateTime date )
{
try
{
return DienstplanungsManager . GetDienstEintrag ( empId , wohnId , zeile , date ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-03-10 12:31:31 +01:00
public DienstvertretungDC GetDienstvertretung ( long empId , long wohnId , int zeile , DateTime date )
{
try
{
return DienstplanungsManager . GetDienstvertretung ( empId , wohnId , zeile , date ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2020-09-30 10:00:31 +02:00
public virtual List < FeiertagDC > ErstelleDefaultFeiertage ( int year )
{
try
{
var vs = PluginLoader . FindClass < VacationService > ( ) ;
2022-08-30 08:53:24 +02:00
var list = vs . GetFeiertage ( year , vs . Bundesland ) ;
2020-09-30 10:00:31 +02:00
return list ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-04-15 07:34:33 +02:00
public List < FeiertagDC > GetDefaultFeiertageForYear ( int year )
{
try
{
var vs = PluginLoader . FindClass < VacationService > ( ) ;
2022-03-22 11:38:58 +01:00
var ber = PluginLoader . FindClass < MitarbeiterstundenkontoBerechnung > ( ) ;
var altList = ber . GetFeiertage ( year ) ;
2022-08-30 08:53:24 +02:00
var list = vs . GetFeiertage ( year , vs . Bundesland ) ;
2021-04-15 07:34:33 +02:00
return list ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-05-03 15:13:53 +02:00
public void InsertRegelmaessigerDienst ( RegelmaessigerDienstDC dienst )
{
try
{
DAOFactory . GenericDAO . Insert ( MapperFactory . RegelmaessigerDienstDC_RegelmaessigerDienst . MapToNewEntity ( dienst ) ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2022-03-14 07:08:32 +01:00
public List < DienstEintragDC > InsertRegelmaessigerDienst2 ( RegelmaessigerDienstDC dienst , List < DienstEintragDC > alleDienstEintraege , List < DienstvertretungDC > alleDienstvertretungen ,
List < AbsenceTimeDC > absenceTimes , bool enableDiensteAnFeiertagen , List < FeiertagDC > feiertage , List < DienstZeileDC > dienstZeilenListe , DateTime pflichtStart , DateTime pflichtEnde ,
bool enableStatusZeile , DateTime datum )
{
try
{
DAOFactory . GenericDAO . Insert ( MapperFactory . RegelmaessigerDienstDC_RegelmaessigerDienst . MapToNewEntity ( dienst ) ) ;
return DienstplanungsManager . AddRegelmaessigeDiensteToDienstplaner ( dienst , alleDienstEintraege , alleDienstvertretungen , absenceTimes , feiertage , enableDiensteAnFeiertagen ,
dienstZeilenListe , pflichtStart , pflichtEnde , enableStatusZeile , datum ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-05-03 15:13:53 +02:00
public void DeleteRegelmaessigerDienst ( RegelmaessigerDienstDC dienst )
{
try
{
DAOFactory . GenericDAO . Delete ( DAOFactory . GenericDAO . GetByID < RegelmaessigerDienst > ( ( long ) dienst . Oid ) ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2024-04-17 16:33:19 +02:00
2020-09-23 16:00:51 +02:00
public void InsertConfirmationReceiptSignature ( ConfirmationReceiptSignatureDC confirmationReceiptSignature )
{
try
{
var confRecSig = MapperFactory . ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature . MapToNewEntity ( confirmationReceiptSignature ) ;
DAOFactory . GenericDAO . Insert ( confRecSig ) ;
2023-10-25 21:52:23 +02:00
MakeHistoryEntriesForConfirmationReceiptSignatures ( new List < ConfirmationReceiptSignature > { confRecSig } , SignatureStateType . Valid ) ;
2020-09-23 16:00:51 +02:00
}
2020-10-13 14:35:06 +02:00
catch ( Exception exception )
2020-09-23 16:00:51 +02:00
{
throw Utils . CreateBeWoFaultException ( exception ) ;
}
}
public void InsertConfirmationReceiptSignatures ( List < ConfirmationReceiptSignatureDC > confirmationReceiptSignatures )
{
try
{
var confRecSigs = MapperFactory . ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature . MapToNewEntities ( confirmationReceiptSignatures ) ;
DAOFactory . GenericDAO . Insert ( confRecSigs ) ;
2023-10-25 21:52:23 +02:00
MakeHistoryEntriesForConfirmationReceiptSignatures ( confRecSigs , SignatureStateType . Valid ) ;
2020-09-23 16:00:51 +02:00
}
2020-10-13 14:35:06 +02:00
catch ( Exception exception )
2020-09-23 16:00:51 +02:00
{
throw Utils . CreateBeWoFaultException ( exception ) ;
}
}
2023-10-28 13:34:32 +02:00
// ToDo: Ist der SignatureStateType Valid und ist die CRSOid null, die CRSOid hinzufügen!
2023-10-25 21:52:23 +02:00
private static void MakeHistoryEntriesForConfirmationReceiptSignatures ( List < ConfirmationReceiptSignature > confirmationReceiptSignatures , SignatureStateType signatureStateType )
{
2024-04-17 16:33:19 +02:00
foreach ( var confirmationReceiptSignature in confirmationReceiptSignatures )
2023-10-25 21:52:23 +02:00
{
2024-04-17 16:33:19 +02:00
foreach ( var serviceRecord in confirmationReceiptSignature . ServiceRecords )
2023-10-25 21:52:23 +02:00
{
SignatureStateType ? customerMonthlySignatureStateType ;
2023-10-28 13:34:32 +02:00
SignatureStateType ? employeeMonthlySignatureStateType ;
long? customerConfirmationReceiptSignatureOid = null ;
long? employeeConfirmationReceiptSignatureOid = null ;
2023-10-25 21:52:23 +02:00
2024-04-17 16:33:19 +02:00
if ( confirmationReceiptSignature . SignatureType = = SignatureType . Customer )
2023-10-25 21:52:23 +02:00
{
customerMonthlySignatureStateType = signatureStateType ;
2023-10-28 13:34:32 +02:00
employeeMonthlySignatureStateType = null ;
2024-04-17 16:33:19 +02:00
if ( signatureStateType = = SignatureStateType . Valid )
2023-10-28 13:34:32 +02:00
{
customerConfirmationReceiptSignatureOid = confirmationReceiptSignature . Oid ;
}
2023-10-25 21:52:23 +02:00
}
else
{
customerMonthlySignatureStateType = null ;
2023-10-28 13:34:32 +02:00
employeeMonthlySignatureStateType = signatureStateType ;
2024-04-17 16:33:19 +02:00
if ( signatureStateType = = SignatureStateType . Valid )
2023-10-28 13:34:32 +02:00
{
employeeConfirmationReceiptSignatureOid = confirmationReceiptSignature . Oid ;
}
2023-10-25 21:52:23 +02:00
}
2023-10-28 13:34:32 +02:00
MakeSignatureStatusTypeServiceRecordHistoryEntry ( serviceRecord , null , customerMonthlySignatureStateType , employeeMonthlySignatureStateType , customerConfirmationReceiptSignatureOid , employeeConfirmationReceiptSignatureOid ) ;
2023-10-25 21:52:23 +02:00
}
}
}
2020-09-23 16:00:51 +02:00
public void DeleteConfirmationReceiptSignature ( long confirmationReceiptSignatureOid )
{
try
{
var confirmationReceiptSignatureToDelete = DAOFactory . GenericDAO . LoadByID < ConfirmationReceiptSignature > ( confirmationReceiptSignatureOid ) ;
2023-08-16 14:18:27 +02:00
//DAOFactory.GenericDAO.Delete(confirmationReceiptSignatureToDelete);
ServiceLogic . SetActivationType < ConfirmationReceiptSignature > ( new Dictionary < long , long > { { confirmationReceiptSignatureOid , confirmationReceiptSignatureToDelete . Version . Value } } , ActivationTypeId . Deleted ) ;
2023-10-25 21:52:23 +02:00
MakeHistoryEntriesForConfirmationReceiptSignatures ( new List < ConfirmationReceiptSignature > { confirmationReceiptSignatureToDelete } , SignatureStateType . ManuallyDeleted ) ;
2020-09-23 16:00:51 +02:00
}
2020-10-13 14:35:06 +02:00
catch ( Exception exception )
2020-09-23 16:00:51 +02:00
{
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 ) ;
}
2020-10-13 14:35:06 +02:00
catch ( Exception exception )
2020-09-23 16:00:51 +02:00
{
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 ;
}
2020-10-13 14:35:06 +02:00
catch ( Exception exception )
2020-09-23 16:00:51 +02:00
{
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 ;
}
2020-10-13 14:35:06 +02:00
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 ( ) ;
2021-05-03 15:13:53 +02:00
List < Team > teams = new List < Team > ( ) ;
if ( filter . Teams ! = null )
teams = DAOFactory . GenericDAO . GetActiveByIDs < Team > ( filter . Teams ) as List < Team > ;
2022-03-25 15:05:39 +01:00
//foreach (var emp in allEmployees.OrderBy(x => x.Person.LastNameFirstName))
List < Employee > benoetigteMitarbeiter = new List < Employee > ( ) ;
if ( teams . Count = = 0 )
benoetigteMitarbeiter = allEmployees ;
else
{
foreach ( var team in teams )
{
benoetigteMitarbeiter . AddRange ( team . MemberList ) ;
}
}
benoetigteMitarbeiter . OrderBy ( x = > x . Person . LastNameFirstName ) . ToList ( ) ;
foreach ( var emp in benoetigteMitarbeiter )
2020-10-13 14:35:06 +02:00
{
if ( filter . EmploymentType ! = null )
if ( ! emp . Contracts . Any ( x = > x . EmploymentType ! = null & & filter . EmploymentType . Contains ( x . EmploymentType . Oid . Value ) ) )
continue ;
2020-12-15 12:45:07 +01:00
2020-10-13 14:35:06 +02:00
var dict = vs . BerechneUrlaubskonto ( emp , filter . Year ) ;
2020-12-15 12:45:07 +01:00
if ( filter . AbsenceReasons ! = null )
2020-10-13 14:35:06 +02:00
emp . AbsenceTimes . RemoveRange ( x = > ! filter . AbsenceReasons . Contains ( x . AbsenceReason . Oid . Value ) ) ;
2022-03-25 15:05:39 +01:00
//if (filter.Teams != null)
//{
// bool isInTeam = false;
// foreach (var team in teams)
// {
// if (team.MemberList.Contains(emp))
// isInTeam = true;
// }
// if (!isInTeam)
// continue;
//}
2021-05-03 15:13:53 +02:00
2020-10-13 14:35:06 +02:00
var empDC = MapperFactory . EmployeeDC_Employee . MapToNewDC ( emp ) ;
2021-01-12 01:12:03 +01:00
if ( dict . ContainsKey ( filter . Year ) )
{
empDC . Urlaubskonto = dict [ filter . Year ] ;
}
else
{
int test = 0 ;
}
2020-10-13 14:35:06 +02:00
res . Add ( empDC ) ;
}
2022-03-25 15:05:39 +01:00
return res . OrderBy ( e = > e . LastNameFirstName ) . ToList ( ) ;
2020-10-13 14:35:06 +02:00
}
catch ( Exception exception )
{
throw Utils . CreateBeWoFaultException ( exception ) ;
}
}
2021-05-03 15:13:53 +02:00
public List < CompactTeamDC > GetCertainTeamsById ( List < long > oids )
{
var teams = DAOFactory . GenericDAO . GetActiveByIDs < Team > ( oids ) ;
return MapperFactory . CompactTeamDC_Team . MapToNewDCs ( teams ) ;
}
2020-10-13 14:35:06 +02:00
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 )
2020-09-23 16:00:51 +02:00
{
throw Utils . CreateBeWoFaultException ( exception ) ;
}
}
2021-05-04 08:14:15 +02:00
public List < AbsenceTimeDC > GetAbsenceTimesForMonth ( long empOid , int month , int year , long absenceReason )
{
// monat und jahr sind 0
var date = new DateTime ( year , month , 1 ) ;
List < AbsenceTime > timesForMonth = DAOFactory . SearchDAO . FindAbsenceTimesForEmployee ( date , date . AddMonths ( 1 ) . AddTicks ( - 1 ) , empOid ) as List < AbsenceTime > ;
2021-05-03 15:13:53 +02:00
2021-05-04 08:14:15 +02:00
List < AbsenceTime > urlaub = new List < AbsenceTime > ( ) ;
2021-05-03 15:13:53 +02:00
2021-05-04 08:14:15 +02:00
foreach ( var item in timesForMonth )
{
if ( item . AbsenceReason . Description . Equals ( "Urlaub" ) )
urlaub . Add ( item ) ;
}
List < AbsenceTimeDC > dcs = MapperFactory . AbsenceTimeDC_AbsenceTime . MapToNewDCs ( urlaub ) ;
return dcs ;
}
2020-09-30 19:23:42 +02:00
public List < ConfirmationReceiptSignatureDC > GetAllConfirmationReceiptSignatures ( )
{
try
{
return MapperFactory . ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature . MapToNewDCs ( DAOFactory . GenericDAO . GetAllActive < ConfirmationReceiptSignature > ( ) ) ;
}
2020-12-15 12:45:07 +01:00
catch ( Exception exception )
2020-09-30 19:23:42 +02:00
{
throw Utils . CreateBeWoFaultException ( exception ) ;
}
}
2020-10-07 19:42:17 +02:00
public List < ServiceRecordDC > GetServiceRecordsByIds ( List < long > serviceRecordOids )
{
try
{
return MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDCs ( DAOFactory . GenericDAO . LoadByIDs < ServiceRecord > ( serviceRecordOids ) ) ;
}
2020-12-15 12:45:07 +01:00
catch ( Exception exception )
2020-10-07 19:42:17 +02:00
{
throw Utils . CreateBeWoFaultException ( exception ) ;
}
}
2020-11-10 02:25:15 +01:00
2020-11-10 02:55:53 +01:00
2020-11-10 02:25:15 +01:00
public String GetOwnChatSettingsUrl ( )
{
//var url = ConfigurationManager.AppSettings.Get("OwnChatSettingsUrl");
//url = url.Replace("[TENANT]", MultitenancyOperationContextExt.Current.Tenant);
//return url;
2024-04-17 16:33:19 +02:00
2021-08-03 14:08:22 +02:00
if ( MultitenancyOperationContextExt . Current ! = null )
{
var tenant = MultitenancyOperationContextExt . Current . Tenant ;
var mandant = GetMandatorEntity ( ) ;
var apikey = mandant . Apikey ;
2023-08-01 16:03:19 +02:00
#if DEBUG
2021-08-03 14:08:22 +02:00
tenant = "6000000000" ;
apikey = "CpmUcJGhFwySzMjFrahNKeWdv4paFo5VTfdS6ebq111DpL8LurkX3aKOPwiLVCdv" ;
#endif
2023-08-01 16:03:19 +02:00
2021-08-03 14:08:22 +02:00
var serverUrl = OwnChatHelper . ErmittleServerURL ( tenant ) ;
2023-08-01 16:03:19 +02:00
if ( String . IsNullOrEmpty ( serverUrl ) )
{
return "https://www.bewoplaner.de" ;
}
2021-08-03 14:08:22 +02:00
String accesstokenUrl = String . Format ( "{0}/api/ownchat/settings/accesstoken/{1}/{2}" , serverUrl , tenant , apikey ) ;
WebRequest request = WebRequest . Create ( accesstokenUrl ) ;
request . Credentials = CredentialCache . DefaultCredentials ;
WebResponse response = request . GetResponse ( ) ;
string responseFromServer = ReadStreamForChatCode ( response ) ;
var definition = new { result = "" , errortext = "" , token = "" } ;
var jsondaten = JsonConvert . DeserializeAnonymousType ( responseFromServer , definition ) ;
response . Close ( ) ;
2024-04-17 16:33:19 +02:00
2021-08-03 14:08:22 +02:00
return String . Format ( "{0}/settings/{1}/{2}" , serverUrl , tenant , jsondaten . token ) ;
}
2024-04-17 16:33:19 +02:00
2020-11-10 02:25:15 +01:00
2022-04-13 17:40:15 +02:00
return "https://www.bewoplaner.de" ;
2020-12-15 12:45:07 +01:00
}
2020-11-09 17:55:01 +01:00
public bool HasConfirmationReceiptSignaturesByEmployeeAndServiceRecords ( long employeeOid , IEnumerable < long > serviceRecordOids )
{
try
{
return DAOFactory . SearchDAO . HasConfirmationReceiptSignaturesByEmployeeAndServiceRecords ( employeeOid , serviceRecordOids ) ;
}
2020-12-15 12:45:07 +01:00
catch ( Exception exception )
2020-11-09 17:55:01 +01:00
{
throw Utils . CreateBeWoFaultException ( exception ) ;
}
}
2021-02-17 16:59:26 +01:00
public bool HasConfirmationReceiptSignatureByDateAndCustomer ( long customerOid , DateTimeSpan timeSpan , SignatureType signatureType )
2020-11-09 17:55:01 +01:00
{
try
{
2021-02-17 16:59:26 +01:00
return DAOFactory . SearchDAO . HasConfirmationReceiptSignatureByDateAndCustomer ( customerOid , timeSpan , signatureType ) ;
2020-11-09 17:55:01 +01:00
}
2020-12-15 12:45:07 +01:00
catch ( Exception exception )
2020-11-09 17:55:01 +01:00
{
throw Utils . CreateBeWoFaultException ( exception ) ;
}
}
public ServiceCategoryDC LoadServiceCategory ( long serviceCategoryOid )
{
try
{
var serviceCategory = DAOFactory . GenericDAO . LoadByID < ServiceCategory > ( serviceCategoryOid ) ;
return MapperFactory . ServiceCategoryDC_ServiceCategory . MapToNewDC ( serviceCategory ) ;
}
2020-12-15 12:45:07 +01:00
catch ( Exception e )
2020-11-09 17:55:01 +01:00
{
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 ) ;
}
2020-12-15 12:45:07 +01:00
catch ( Exception e )
2020-11-09 17:55:01 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
2020-11-10 02:25:15 +01:00
}
2020-11-20 23:28:09 +01:00
2020-12-11 11:44:05 +01:00
public List < VorlagentabelleDC > GetVorlagentabelleDCs ( )
{
try
{
2021-02-15 08:04:40 +01:00
return VorlagenManager . GetVorlagentabelleDCs ( ) ;
2020-12-11 11:44:05 +01:00
}
catch ( Exception ex )
{
throw Utils . CreateBeWoFaultException ( ex ) ;
}
}
2021-01-13 11:21:51 +01:00
public DokumentvorlageDC InsertTemplate ( DokumentvorlageDC dc )
2020-12-11 11:44:05 +01:00
{
try
{
2021-02-15 08:04:40 +01:00
return VorlagenManager . InsertTemplate ( dc ) ;
2020-12-11 11:44:05 +01:00
}
catch ( Exception ex )
{
throw Utils . CreateBeWoFaultException ( ex ) ;
}
}
public List < PlatzhalterDC > GetPlatzhalterForCustomer ( )
2020-12-15 12:45:07 +01:00
{
try
{
2021-02-15 08:04:40 +01:00
return VorlagenManager . GetPlatzhalterForCustomer ( ) ;
2020-12-15 12:45:07 +01:00
}
catch ( Exception ex )
{
throw Utils . CreateBeWoFaultException ( ex ) ;
}
}
public List < PlatzhalterDC > GetPlatzhalterForSupportConcept ( )
{
try
{
2021-02-15 08:04:40 +01:00
return VorlagenManager . GetPlatzhalterForSupportConcept ( ) ;
2020-12-15 12:45:07 +01:00
}
catch ( Exception ex )
{
throw Utils . CreateBeWoFaultException ( ex ) ;
}
}
public List < PlatzhalterDC > GetPlatzhalterForEmployee ( )
2020-12-11 11:44:05 +01:00
{
try
{
2021-02-15 08:04:40 +01:00
return VorlagenManager . GetPlatzhalterForEmployee ( ) ;
2020-12-11 11:44:05 +01:00
}
2020-12-15 12:45:07 +01:00
catch ( Exception ex )
2020-12-11 11:44:05 +01:00
{
throw Utils . CreateBeWoFaultException ( ex ) ;
}
}
public BeWoFolderDC GetFolderById ( long oid )
{
try
{
2021-02-15 08:04:40 +01:00
return VorlagenManager . GetFolderById ( oid ) ;
2020-12-11 11:44:05 +01:00
}
catch ( Exception ex )
{
throw Utils . CreateBeWoFaultException ( ex ) ;
}
}
public VorlagentabelleDC GetVorlagentabelleById ( long oid )
{
2021-02-15 08:04:40 +01:00
try
{
return VorlagenManager . GetVorlagentabelleById ( oid ) ;
}
catch ( Exception ex )
{
throw Utils . CreateBeWoFaultException ( ex ) ;
}
2020-12-11 11:44:05 +01:00
}
public List < DokumentvorlageDC > GetDokumentvorlagenInFolder ( long folderOid )
{
2021-02-15 08:04:40 +01:00
try
{
return VorlagenManager . GetDokumentvorlagenInFolder ( folderOid ) ;
}
catch ( Exception ex )
{
throw Utils . CreateBeWoFaultException ( ex ) ;
}
2020-12-11 12:30:41 +01:00
}
2020-11-20 23:28:09 +01:00
public List < SupportConceptDC > GetSupportConceptsById ( IEnumerable < long > supportConceptOids )
{
try
{
var supportConcepts = DAOFactory . GenericDAO . LoadByIDs < SupportConcept > ( supportConceptOids ) ;
return MapperFactory . SupportConceptDC_SupportConcept . MapToNewDCs ( supportConcepts ) ;
}
2020-12-15 12:45:07 +01:00
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeleteTemplates ( List < DokumentvorlageDC > vorlagen )
{
try
{
2021-02-15 08:04:40 +01:00
VorlagenManager . DeleteTemplates ( vorlagen ) ;
2020-12-15 12:45:07 +01:00
}
catch ( Exception e )
2020-11-20 23:28:09 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2020-12-15 12:45:07 +01:00
2021-02-17 16:59:26 +01:00
public bool HasConfirmationReceiptSignature ( IList < long > serviceRecordOids , SignatureType signatureType )
2021-01-14 16:30:28 +01:00
{
try
{
2021-02-17 16:59:26 +01:00
return DAOFactory . SearchDAO . HasConfirmationReceiptSignature ( serviceRecordOids , signatureType ) ;
2021-01-14 16:30:28 +01:00
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2021-01-14 16:30:28 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-01-14 17:03:49 +01:00
2021-01-13 11:21:51 +01:00
public string ReplacePlaceholdersInTemplate ( DokumentvorlageDC template , long? objectOid , long? tableOid )
{
try
{
2021-02-15 08:04:40 +01:00
return VorlagenManager . ReplacePlaceholdersInTemplate ( template , objectOid , tableOid ) ;
2021-01-13 11:21:51 +01:00
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2021-01-13 11:21:51 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-02-15 08:04:40 +01:00
public void InsertFileAttachment ( FileAttachmentDC fileAttachmentDC )
2021-01-13 11:21:51 +01:00
{
try
{
2021-02-15 08:04:40 +01:00
DokumentManager . InsertFileAttachment ( fileAttachmentDC ) ;
2021-01-13 11:21:51 +01:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-02-15 08:04:40 +01:00
public List < FileAttachmentDC > SearchForFiles ( string nutzereingabe )
2021-01-13 11:21:51 +01:00
{
try
{
2021-02-15 08:04:40 +01:00
return DokumentManager . SearchForFiles ( nutzereingabe ) ;
2021-01-13 11:21:51 +01:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-02-15 08:04:40 +01:00
public string GetObjectForFilePath ( TableID table , long? oid )
2021-01-13 11:21:51 +01:00
{
try
{
2021-02-15 08:04:40 +01:00
return DokumentManager . GetObjectForFilePath ( table , oid ) ;
2021-01-13 11:21:51 +01:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2024-04-17 16:33:19 +02:00
2021-01-13 11:21:51 +01:00
2021-12-01 14:09:56 +01:00
public void RemoveAllDiensteForOneMonth ( CompactWohnheimDC wh , DateTime month , List < RegelmaessigerDienstDC > rd )
2021-01-13 11:21:51 +01:00
{
2021-02-15 08:04:40 +01:00
try
2024-04-17 16:33:19 +02:00
{
2021-12-01 14:09:56 +01:00
DienstplanungsManager . RemoveAllDiensteForOneMonth ( wh , month , rd ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
2024-04-17 16:33:19 +02:00
}
2021-12-01 14:09:56 +01:00
public void RemoveAllDiensteForOneYear ( CompactWohnheimDC wh , DateTime year , List < RegelmaessigerDienstDC > rd )
{
try
2024-04-17 16:33:19 +02:00
{
2021-12-01 14:09:56 +01:00
DienstplanungsManager . RemoveAllDiensteForOneYear ( wh , year , rd ) ;
2021-02-15 08:04:40 +01:00
}
catch ( Exception e )
2021-01-13 11:21:51 +01:00
{
2021-02-15 08:04:40 +01:00
throw Utils . CreateBeWoFaultException ( e ) ;
2021-01-13 11:21:51 +01:00
}
}
2021-02-15 08:04:40 +01:00
public string GetColorForStatus ( bool status )
2021-01-13 11:21:51 +01:00
{
2021-02-15 08:04:40 +01:00
try
2021-01-13 11:21:51 +01:00
{
2021-02-15 08:04:40 +01:00
return DienstplanungsManager . GetColorForStatus ( status ) ;
2021-01-13 11:21:51 +01:00
}
2021-02-15 08:04:40 +01:00
catch ( Exception e )
2021-01-29 14:37:43 +01:00
{
2021-02-15 08:04:40 +01:00
throw Utils . CreateBeWoFaultException ( e ) ;
2021-01-13 11:21:51 +01:00
}
}
2021-04-06 08:06:51 +02:00
public string GetColorForForeground ( )
{
try
{
return DienstplanungsManager . GetColorForForeground ( ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-02-15 15:06:17 +01:00
public string GetColorForServiceRecordView2 ( )
2021-01-13 11:21:51 +01:00
{
2021-02-15 15:06:17 +01:00
try
2021-01-13 11:21:51 +01:00
{
2021-02-19 13:21:30 +01:00
return "#008EED" ;
2021-01-13 11:21:51 +01:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
2021-01-29 14:37:43 +01:00
}
2021-02-25 10:46:26 +01:00
2021-05-03 15:13:53 +02:00
public DienstplanerRootDC BuildDienstplanerRootObject ( DateTime date , long wohnheimOid )
2021-04-15 07:34:33 +02:00
{
try
{
2021-05-03 15:13:53 +02:00
DienstplanerRootDC root = DienstplanungsManager . BuildDienstplanerRootObject ( date , wohnheimOid ) ;
2022-09-07 15:03:33 +02:00
//root.Feiertage = GetDefaultFeiertageForYear(date.Year);
2021-04-15 07:34:33 +02:00
return root ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-10-15 13:13:27 +02:00
public void DeleteRegelmaessigeDiensteOfRemovedEmployee ( List < CompactEmployeeDC > employee , long wOid )
{
try
{
DienstplanungsManager . DeleteRegelmaessigeDiensteOfRemovedEmployee ( employee , wOid ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-04-15 07:34:33 +02:00
2021-12-01 14:09:56 +01:00
public List < CompactEmployeeDC > GetCompactEmployeesForTeam ( long teamOid )
{
try
{
return DienstplanungsManager . GetCompactEmployeesForTeam ( teamOid ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2022-02-24 08:11:58 +01:00
public DienstZeileDC InitStatusZeile ( DateTime date )
{
2024-04-17 16:33:19 +02:00
2022-02-24 08:11:58 +01:00
try
{
return DienstplanungsManager . InitStatusZeile ( date ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2022-02-02 17:50:40 +01:00
public List < string > SetSortierMethoden ( )
{
try
{
return DienstplanungsManager . SetSortierMethoden ( ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < DienstBlockDC > DienstBloeckeNeuSortieren ( List < DienstBlockDC > bloecke , string auswahl , bool aufsteigend )
{
try
{
return DienstplanungsManager . DienstBloeckeNeuSortieren ( bloecke , auswahl , aufsteigend ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-12-01 14:09:56 +01:00
2021-02-25 10:46:26 +01:00
public Dictionary < string , string > GetAdditionalEmployeeInformationForScheduler ( long empOid )
{
Dictionary < string , string > dict = new Dictionary < string , string > ( ) ;
var employee = DAOFactory . GenericDAO . GetByID < Employee > ( empOid ) ;
dict . Add ( "Vorname" , employee . Person . FirstName ) ;
dict . Add ( "Nachname" , employee . Person . LastName ) ;
2024-04-17 16:33:19 +02:00
if ( employee . Person . DateOfBirth ! = null )
2021-02-25 10:46:26 +01:00
{
var dateAndTime = employee . Person . DateOfBirth . ToString ( ) . Split ( ' ' ) ;
dict . Add ( "Geburtstag" , dateAndTime [ 0 ] ) ;
}
//if(employee.AbsenceTimes != null)
//{
// int c = 1;
// foreach (var item in employee.AbsenceTimes)
// {
// dict.Add("Abwesenheit " + c, item.AbsenceSpan.ToDateString());
// c++;
// }
//}
2024-04-17 16:33:19 +02:00
if ( employee . IsQualified ! = null )
2021-02-25 10:46:26 +01:00
dict . Add ( "Qualifiziert" , ( ( bool ) employee . IsQualified ) ? "Ja" : "Nein" ) ;
2024-04-17 16:33:19 +02:00
if ( employee . Schutzstufe ! = null )
2021-02-25 10:46:26 +01:00
dict . Add ( "Schutzstufe" , employee . Schutzstufe ) ;
2024-04-17 16:33:19 +02:00
2021-02-25 10:46:26 +01:00
return dict ;
}
2021-03-02 13:10:21 +01:00
public string GetXAMLInformationStringForEmployee ( long empOid )
{
try
{
return XAMLInformation . InfoViaXAMLManager . GetXAMLInformationStringForEmployee ( empOid , null ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-11-09 16:48:58 +01:00
public string GetXAMLInformationStringForScheduler ( long customerOid )
{
try
{
return XAMLInformation . InfoViaXAMLManager . GetXAMLInformationStringForScheduler ( customerOid ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2021-03-02 13:10:21 +01:00
public string GetXAMLInformationStringForCustomer ( long customerOid )
{
try
{
return XAMLInformation . InfoViaXAMLManager . GetXAMLInformationStringForCustomer ( customerOid , null ) ;
2021-02-15 15:06:17 +01:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
2021-01-13 11:21:51 +01:00
}
}
2021-02-17 16:59:26 +01:00
public List < ConfirmationReceiptSignatureDC > LoadConfirmationReceiptSignaturesByServiceRecordOids ( IList < long > serviceRecordOids , SignatureType signatureType , out List < long > serviceRecordOidsWithSignatures )
{
try
{
var signatures = DAOFactory . SearchDAO . LoadConfirmationReceiptSignaturesByServiceRecordOids ( serviceRecordOids , signatureType ) ;
serviceRecordOidsWithSignatures = new List < long > ( ) ;
2024-11-12 18:37:23 +01:00
foreach ( var crs in signatures )
2021-02-17 16:59:26 +01:00
{
2024-11-12 18:37:23 +01:00
foreach ( var sr in crs . ServiceRecords )
2021-02-17 16:59:26 +01:00
{
2024-11-12 18:37:23 +01:00
if ( sr . Oid . HasValue & & serviceRecordOids . Contains ( sr . Oid . Value ) )
2021-02-17 16:59:26 +01:00
{
serviceRecordOidsWithSignatures . AddIfNotIn ( sr . Oid . Value ) ;
}
}
}
return MapperFactory . ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature . MapToNewDCs ( signatures ) ;
}
2024-11-12 18:37:23 +01:00
catch ( Exception e )
2021-02-17 16:59:26 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < ConfirmationReceiptSignatureDC > UpdateConfirmationReceiptSignatures ( IList < ConfirmationReceiptSignatureDC > confirmationReceiptSignatures2Update )
{
try
{
2024-11-12 18:37:23 +01:00
var originalConfirmationReceiptSignatures = DAOFactory . GenericDAO . LoadByIDs < ConfirmationReceiptSignature > ( confirmationReceiptSignatures2Update . Where ( w = > w . ConfirmationReceiptSignatureOid . HasValue ) . Select ( confirmationReceiptSignatur = > confirmationReceiptSignatur . ConfirmationReceiptSignatureOid . Value ) ) ;
2021-02-17 16:59:26 +01:00
2024-11-12 18:37:23 +01:00
MapperFactory . ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature . MergeWithEntitys ( confirmationReceiptSignatures2Update , originalConfirmationReceiptSignatures ) ;
2021-02-17 16:59:26 +01:00
2024-11-12 18:37:23 +01:00
DAOFactory . GenericDAO . Update ( originalConfirmationReceiptSignatures ) ;
2021-02-17 16:59:26 +01:00
2024-11-12 18:37:23 +01:00
originalConfirmationReceiptSignatures = DAOFactory . GenericDAO . LoadByIDs < ConfirmationReceiptSignature > ( confirmationReceiptSignatures2Update . Where ( w = > w . ConfirmationReceiptSignatureOid . HasValue ) . Select ( confirmationReceiptSignatur = > confirmationReceiptSignatur . ConfirmationReceiptSignatureOid . Value ) ) ;
2021-02-17 16:59:26 +01:00
2024-11-12 18:37:23 +01:00
return MapperFactory . ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature . MapToNewDCs ( originalConfirmationReceiptSignatures ) ;
2021-02-17 16:59:26 +01:00
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2021-02-17 16:59:26 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public void DeleteConfirmationReceiptSignatures ( Dictionary < long , long > oid2Version )
{
try
{
2023-10-25 21:52:23 +02:00
var originals = DAOFactory . GenericDAO . LoadByIDs < ConfirmationReceiptSignature > ( oid2Version . Select ( e = > e . Key ) ) ;
2023-07-24 17:57:14 +02:00
ServiceLogic . SetActivationType < ConfirmationReceiptSignature > ( oid2Version , ActivationTypeId . Deleted ) ;
2023-10-25 21:52:23 +02:00
MakeHistoryEntriesForConfirmationReceiptSignatures ( originals , SignatureStateType . ManuallyDeleted ) ;
2021-02-17 16:59:26 +01:00
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2021-02-17 16:59:26 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public bool HasConfirmationReceiptSignaturesByCustomerAndServiceRecords ( long customerOid , IEnumerable < long > serviceRecordOids )
{
try
{
return DAOFactory . SearchDAO . HasConfirmationReceiptSignaturesByCustomerAndServiceRecords ( customerOid , serviceRecordOids ) ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception exception )
2021-02-17 16:59:26 +01:00
{
throw Utils . CreateBeWoFaultException ( exception ) ;
}
}
public List < ConfirmationReceiptSignatureDC > LoadAllConfirmationReceiptSignaturesByServiceRecordOids ( IList < long > serviceRecordOids , out Dictionary < SignatureType , List < long > > serviceRecordOidsWithSignature )
{
try
{
var confirmationReceiptSignatures = DAOFactory . SearchDAO . LoadConfirmationReceiptSignaturesByServiceRecordOids ( serviceRecordOids ) ;
serviceRecordOidsWithSignature = new Dictionary < SignatureType , List < long > > ( ) ;
2024-04-17 16:33:19 +02:00
foreach ( var csr in confirmationReceiptSignatures )
2021-02-17 16:59:26 +01:00
{
serviceRecordOidsWithSignature . AddOrUpdateValueInDictionary ( csr . SignatureType , csr . ServiceRecords . Where ( sr = > sr . Oid . HasValue ) . Select ( sr = > sr . Oid . Value ) . ToList ( ) ) ;
}
return MapperFactory . ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature . MapToNewDCs ( confirmationReceiptSignatures ) ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception exception )
2021-02-17 16:59:26 +01:00
{
throw Utils . CreateBeWoFaultException ( exception ) ;
}
}
public List < long > LoadServiceRecordOidsWithConfirmationReceiptSignatures ( IList < long > serviceRecordOids )
{
try
{
return DAOFactory . SearchDAO . LoadServiceRecordOidsWithConfirmationReceiptSignatures ( serviceRecordOids ) ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception exception )
2021-02-17 16:59:26 +01:00
{
throw Utils . CreateBeWoFaultException ( exception ) ;
}
}
public List < long > LoadServiceRecordOidsWithCustomerConfirmationReceiptSignatures ( IList < long > serviceRecordOids , SignatureType signatureType )
{
try
{
return DAOFactory . SearchDAO . LoadServiceRecordOidsWithConfirmationReceiptSignatures ( serviceRecordOids , signatureType ) ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception exception )
2021-02-17 16:59:26 +01:00
{
throw Utils . CreateBeWoFaultException ( exception ) ;
}
}
public List < ServiceRecordDC > GetServiceRecordsWithoutConfirmationReceiptSignature ( IList < long > serviceRecordOids , SignatureType signatureType )
{
try
{
return MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDCs ( DAOFactory . SearchDAO . GetServiceRecordsWithoutConfirmationReceiptSignature ( serviceRecordOids , signatureType ) ) ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception exception )
2021-02-17 16:59:26 +01:00
{
throw Utils . CreateBeWoFaultException ( exception ) ;
}
}
2021-03-17 18:44:40 +01:00
2023-07-12 11:38:39 +02:00
/// <summary>
/// Entfernt ServiceRecords von ConfirmationReceiptSignature-Objekten (Monatsunterschriften).
/// Hat ein ConfirmationReceiptSignature-Objekt keine verknüpften ServiceRecords, wird es gelöscht.
/// </summary>
/// <param name="serviceRecordsToUpdate">ServiceRecords, die geändert oder gelöscht werden</param>
/// <param name="oldServiceRecords">Die originalen ServiceRecords, mit denen die geänderten verglichen werden</param>
/// <param name="isDeleting">Ist true, wenn es sich um das Löschen von ServiceRecords handelt</param>
2023-10-25 21:52:23 +02:00
private static List < ServiceRecord2SignatureStates > RemoveServiceRecordsFromConfirmationReceiptSignatures ( List < ServiceRecordDC > serviceRecordsToUpdate , IEnumerable < ServiceRecord > oldServiceRecords , bool isDeleting )
2021-03-17 18:44:40 +01:00
{
2024-04-17 16:33:19 +02:00
var result = new List < ServiceRecord2SignatureStates > ( ) ;
2021-03-17 18:44:40 +01:00
var serviceRecordOids = new List < long > ( ) ;
2024-04-17 16:33:19 +02:00
var oldVsNew = new Dictionary < ServiceRecord , ServiceRecordDC > ( ) ;
var orderedOldOnes = oldServiceRecords . Where ( x = > x . Oid . HasValue ) . OrderBy ( x = > x . Oid . Value ) . ToList ( ) ;
var orderedNewOnes = serviceRecordsToUpdate . Where ( x = > x . ServiceRecordOid . HasValue ) . OrderBy ( x = > x . ServiceRecordOid . Value ) . ToList ( ) ;
2023-06-18 17:11:35 +02:00
2024-11-12 18:37:23 +01:00
foreach ( var oldSr in orderedOldOnes )
2023-06-18 17:11:35 +02:00
{
var newSr = orderedNewOnes . FirstOrDefault ( f = > f . ServiceRecordOid = = oldSr . Oid ) ;
2024-11-12 18:37:23 +01:00
if ( newSr ! = null )
2023-06-18 17:11:35 +02:00
{
oldVsNew . Add ( oldSr , newSr ) ;
}
}
2021-03-17 18:44:40 +01:00
2024-11-12 18:37:23 +01:00
foreach ( var kvp in oldVsNew )
2021-03-17 18:44:40 +01:00
{
2024-11-12 18:37:23 +01:00
if ( kvp . Value . ServiceRecordOid . HasValue & & ( kvp . Key . Start ! = kvp . Value . Start | | kvp . Key . End ! = kvp . Value . End | | isDeleting ) )
2023-06-18 17:11:35 +02:00
{
serviceRecordOids . AddIfNotIn ( kvp . Value . ServiceRecordOid . Value ) ;
}
2021-03-17 18:44:40 +01:00
}
2023-10-28 13:34:32 +02:00
var confirmationReceiptSignatures = DAOFactory . SearchDAO . LoadAllActiveConfirmationReceiptSignaturesByServiceRecordOids ( serviceRecordOids ) ;
2021-03-17 18:44:40 +01:00
var confirmationReceiptSignatures2Delete = new List < ConfirmationReceiptSignature > ( ) ;
var confirmationReceiptSignatures2Update = new List < ConfirmationReceiptSignature > ( ) ;
2024-11-12 18:37:23 +01:00
foreach ( var signature in confirmationReceiptSignatures )
2021-03-17 18:44:40 +01:00
{
var signatures2Keep = signature . ServiceRecords . Where ( sr = > sr . Oid . HasValue & & ! serviceRecordOids . Contains ( sr . Oid . Value ) ) . ToList ( ) ;
2024-11-12 18:37:23 +01:00
if ( signatures2Keep . Count = = 0 )
2021-03-17 18:44:40 +01:00
{
confirmationReceiptSignatures2Delete . AddIfNotIn ( signature ) ;
continue ;
}
signature . ServiceRecords = signatures2Keep ;
confirmationReceiptSignatures2Update . AddIfNotIn ( signature ) ;
}
DAOFactory . GenericDAO . Update ( confirmationReceiptSignatures2Update ) ;
2023-07-12 11:38:39 +02:00
var oids2Versions = new Dictionary < long , long > ( ) ;
confirmationReceiptSignatures2Delete . DoForEach ( signature = >
{
2024-11-12 18:37:23 +01:00
if ( signature . Oid is null | | signature . Version is null )
2023-10-25 21:52:23 +02:00
{
return ;
}
2023-07-12 11:38:39 +02:00
oids2Versions . Add ( signature . Oid . Value , signature . Version . Value ) ;
} ) ;
ServiceLogic . SetActivationType < ConfirmationReceiptSignature > ( oids2Versions , ActivationTypeId . Deleted ) ;
2023-10-25 21:52:23 +02:00
var timeAlteredServiceRecords = DAOFactory . GenericDAO . LoadByIDs < ServiceRecord > ( serviceRecordOids ) ;
2024-04-17 16:33:19 +02:00
2023-11-02 17:45:53 +01:00
var mostRecentSignatureStatusInfos = DAOFactory . SearchDAO . FindMostRecentSignatureStatusInfoByServiceRecords ( serviceRecordOids ) ;
2023-10-25 21:52:23 +02:00
2024-11-12 18:37:23 +01:00
if ( confirmationReceiptSignatures2Update . Any ( ) )
2023-10-25 21:52:23 +02:00
{
2024-11-12 18:37:23 +01:00
foreach ( var serviceRecord in timeAlteredServiceRecords )
2023-10-25 21:52:23 +02:00
{
2023-11-02 17:45:53 +01:00
SignatureStateInfoFromServiceRecordHistoryEntry previousRecordHistorySignatureInfo = null ;
2023-10-25 21:52:23 +02:00
2024-04-17 16:33:19 +02:00
if ( serviceRecord . Oid . HasValue & & mostRecentSignatureStatusInfos . ContainsKey ( serviceRecord . Oid . Value ) )
2023-10-25 21:52:23 +02:00
{
2023-11-02 17:45:53 +01:00
previousRecordHistorySignatureInfo = mostRecentSignatureStatusInfos [ serviceRecord . Oid . Value ] ;
2023-10-25 21:52:23 +02:00
}
2024-04-17 16:33:19 +02:00
2023-11-02 17:45:53 +01:00
var newCustomerSignatureState = DetermineNewSignatureState ( previousRecordHistorySignatureInfo ? . CustomerConfirmationReceiptSignatureStateType ) ;
var newEmployeeSignatureState = DetermineNewSignatureState ( previousRecordHistorySignatureInfo ? . EmployeeConfirmationReceiptSignatureStateType ) ;
2023-10-25 21:52:23 +02:00
var newSignatureStatesObject = new ServiceRecord2SignatureStates (
serviceRecord ,
null ,
newCustomerSignatureState ,
newEmployeeSignatureState
) ;
result . Add ( newSignatureStatesObject ) ;
}
}
2024-11-12 18:37:23 +01:00
foreach ( var confirmationReceiptSignature in confirmationReceiptSignatures2Delete )
2023-10-25 21:52:23 +02:00
{
var first = confirmationReceiptSignature . ServiceRecords . FirstOrDefault ( ) ;
2023-10-28 13:34:32 +02:00
// Eine Unterschrift, die in der confirmationReceiptSignatures2Delete ist, hat nur noch den einen ServiceRecord, der gerade in der Zeit bearbeitet wird!
2024-11-12 18:37:23 +01:00
if ( first ! = null & & confirmationReceiptSignature . Oid . HasValue )
2023-10-25 21:52:23 +02:00
{
2023-10-28 13:34:32 +02:00
var signatureOid = confirmationReceiptSignature . Oid . Value ;
2023-10-25 21:52:23 +02:00
2023-10-28 13:34:32 +02:00
var formerlySignedServiceRecords = DAOFactory . SearchDAO . FindFormerlyLinkedServiceRecordsBySignatureOid ( signatureOid ) ;
2023-10-25 21:52:23 +02:00
2024-11-12 18:37:23 +01:00
var blah = DAOFactory . SearchDAO . FindMostRecentSignatureStatusInfoByServiceRecords ( formerlySignedServiceRecords . Where ( sr = > sr . Oid . HasValue ) . Select ( sr = > sr . Oid . Value ) . ToList ( ) ) ;
2023-10-25 21:52:23 +02:00
2023-11-02 17:45:53 +01:00
mostRecentSignatureStatusInfos . AddAndIgnoreDuplicates ( blah ) ;
2023-10-25 21:52:23 +02:00
confirmationReceiptSignature . ServiceRecords . AddRangeIfElementsNotIn ( formerlySignedServiceRecords ) ;
}
2024-11-12 18:37:23 +01:00
foreach ( var serviceRecord in confirmationReceiptSignature . ServiceRecords )
2023-10-25 21:52:23 +02:00
{
var previousServiceRecord2SignatureStates = result . FirstOrDefault ( f = > f . ServiceRecord . Equals ( serviceRecord ) ) ;
var newSignatureStatesObject = new ServiceRecord2SignatureStates (
serviceRecord ,
null ,
SignatureStateType . None ,
SignatureStateType . None
) ;
2024-11-12 18:37:23 +01:00
if ( previousServiceRecord2SignatureStates is null )
2023-10-25 21:52:23 +02:00
{
2023-11-02 17:45:53 +01:00
SignatureStateInfoFromServiceRecordHistoryEntry previousRecordHistorySignatureInfo = null ;
2023-10-25 21:52:23 +02:00
2024-11-12 18:37:23 +01:00
if ( serviceRecord . Oid . HasValue & & mostRecentSignatureStatusInfos . ContainsKey ( serviceRecord . Oid . Value ) )
2023-10-25 21:52:23 +02:00
{
2023-11-02 17:45:53 +01:00
previousRecordHistorySignatureInfo = mostRecentSignatureStatusInfos [ serviceRecord . Oid . Value ] ;
2023-10-25 21:52:23 +02:00
}
2023-11-02 17:45:53 +01:00
newSignatureStatesObject . CustomerMonthlySignatureStateType = DetermineNewDeletedSignatureState ( previousRecordHistorySignatureInfo ? . CustomerConfirmationReceiptSignatureStateType ) ;
newSignatureStatesObject . EmployeeMonthlySignatreStateType = DetermineNewDeletedSignatureState ( previousRecordHistorySignatureInfo ? . EmployeeConfirmationReceiptSignatureStateType ) ;
2023-10-25 21:52:23 +02:00
}
else
{
newSignatureStatesObject . CustomerMonthlySignatureStateType = DetermineNewDeletedSignatureState ( previousServiceRecord2SignatureStates . CustomerMonthlySignatureStateType ) ;
newSignatureStatesObject . EmployeeMonthlySignatreStateType = DetermineNewDeletedSignatureState ( previousServiceRecord2SignatureStates . EmployeeMonthlySignatreStateType ) ;
}
result . AddIfNotIn ( newSignatureStatesObject ) ;
}
}
return result ;
}
private static SignatureStateType DetermineNewDeletedSignatureState ( SignatureStateType ? previouSignatureStateType )
{
2024-04-17 16:33:19 +02:00
switch ( previouSignatureStateType )
2023-10-25 21:52:23 +02:00
{
case null :
return SignatureStateType . None ;
case SignatureStateType . None :
return SignatureStateType . None ;
case SignatureStateType . ManuallyDeleted :
return SignatureStateType . ManuallyDeleted ;
default :
return SignatureStateType . AutomaticallyDeleted ;
}
}
private static SignatureStateType DetermineNewSignatureState ( SignatureStateType ? previousSignatureStateType )
{
var newSignatureStateType = SignatureStateType . None ;
2024-04-17 16:33:19 +02:00
switch ( previousSignatureStateType )
2023-10-25 21:52:23 +02:00
{
case SignatureStateType . Valid :
newSignatureStateType = SignatureStateType . Invalid ;
break ;
case SignatureStateType . Invalid :
newSignatureStateType = SignatureStateType . Invalid ;
break ;
case SignatureStateType . ManuallyDeleted :
2024-04-17 16:33:19 +02:00
newSignatureStateType = ( SignatureStateType ) previousSignatureStateType ;
2023-10-25 21:52:23 +02:00
break ;
case SignatureStateType . AutomaticallyDeleted :
2024-04-17 16:33:19 +02:00
newSignatureStateType = ( SignatureStateType ) previousSignatureStateType ;
2023-10-25 21:52:23 +02:00
break ;
}
return newSignatureStateType ;
2021-03-17 18:44:40 +01:00
}
2021-06-10 14:40:23 +02:00
2023-10-25 21:52:23 +02:00
/// <summary>
/// Löscht die Zeiterfassungseinträge aus der Linktable, die Zeiterfassungseinträge mit Monatsunterschriften verbindet.
/// </summary>
/// <param name="serviceRecords">Die Zeiterfassungseinträge, die gelöscht werden und eventuell mit Monatsunterschriften verknüpft sind.</param>
2023-07-24 17:57:14 +02:00
private static void RemoveServiceRecordsFromConfirmationReceiptSignatureForDeletion ( IEnumerable < ServiceRecord > serviceRecords )
{
2024-11-12 18:37:23 +01:00
var serviceRecordOids = serviceRecords . Where ( serviceRecord = > serviceRecord . Oid . HasValue ) . Select ( serviceRecord = > serviceRecord . Oid . Value ) . ToList ( ) ;
2023-07-24 17:57:14 +02:00
var confirmationReceiptSignatures = DAOFactory . SearchDAO . LoadAllConfirmationReceiptSignaturesByServiceRecordOids ( serviceRecordOids ) ;
2024-04-17 16:33:19 +02:00
foreach ( var signature in confirmationReceiptSignatures )
2023-07-24 17:57:14 +02:00
{
2024-11-12 18:37:23 +01:00
signature . ServiceRecords = signature . ServiceRecords . Where ( serviceRecord = > serviceRecord . Oid . HasValue & & ! serviceRecordOids . Contains ( serviceRecord . Oid . Value ) ) . ToList ( ) ;
2023-07-24 17:57:14 +02:00
}
DAOFactory . GenericDAO . Update ( confirmationReceiptSignatures ) ;
}
2021-06-16 15:11:39 +02:00
public List < RatingTypeDC > GetRatingTypesByOids ( List < long > ratingTypeOids )
{
try
{
var ratingTypes = DAOFactory . GenericDAO . LoadByIDs < RatingType > ( ratingTypeOids ) ;
return MapperFactory . RatingTypeDC_RatingType . MapToNewDCs ( ratingTypes ) ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception exception )
2021-06-16 15:11:39 +02:00
{
throw Utils . CreateBeWoFaultException ( exception ) ;
}
}
2021-06-16 15:44:45 +02:00
2021-08-27 07:34:43 +02:00
public UrlaubsplanerRootDC BuildUrlaubsplanerRootObject ( AbsenceOverviewFilterDC filter )
2021-06-10 14:40:23 +02:00
{
UrlaubsplanerRootDC root = new UrlaubsplanerRootDC ( ) ;
var empService = new EmployeeServiceImp ( ) ;
2021-08-27 07:34:43 +02:00
root . Feiertage = GetDefaultFeiertageForYear ( filter . Year ) . Where ( f = > f . Datum . Month = = filter . Month ) . ToList ( ) ;
root . Abwesenheiten = empService . GetAllEmployeeAbsenceTimesForMonth ( filter . Year , filter . Month ) ;
root . GeschenkteUrlaubstage = empService . GetGeschenkteUrlaubstageForYear ( filter . Year ) ;
var DCsToDelete = empService . GetAllAbwesenheitsInformationPrints ( ) ;
empService . DeleteAbwesenheitsInformationPrints ( DCsToDelete ) ;
//root.AlleAbwesenheitsInformationDCs = new List<AbwesenheitsInformationDC>();
//var employee = GetAbsenceOverview(filter);
//foreach (var emp in employee)
//{
// root.AlleAbwesenheitsInformationDCs.Add(new AbwesenheitsInformationDC()
// {
// Employee = emp,
// Month = filter.Month,
// Year = filter.Year,
// AbsenceTimes = root.Abwesenheiten.Where(a => a.EmployeeOid == emp.EmployeeOid).ToList(),
// GeschenkteUrlaubstage = root.GeschenkteUrlaubstage.Where(u => u.Employee == emp.EmployeeOid).ToList()
// });
//}
2021-06-10 14:40:23 +02:00
return root ;
}
2021-06-18 13:34:42 +02:00
public string GetInformationStringForUrlaubsplaner ( UrlaubskontoDC dc , decimal tageUrlaub , decimal tageKrank , bool urlaubVerfallen )
{
try
{
return XAMLInformation . InfoViaXAMLManager . GetXAMLInformationStringForUrlaubsplaner ( dc , tageUrlaub , tageKrank , urlaubVerfallen ) ;
}
catch ( Exception exception )
{
throw Utils . CreateBeWoFaultException ( exception ) ;
}
}
2021-07-05 18:05:43 +02:00
2023-10-25 21:52:23 +02:00
/// <summary>
/// Löscht die Einzelunterschriften von ServiceRecords und aktualisiert die ServiceRecords
/// </summary>
/// <param name="serviceRecords"></param>
/// <param name="originals"></param>
private static List < ServiceRecord > DeleteSignaturesFromServiceRecords ( IEnumerable < ServiceRecordDC > serviceRecords , List < ServiceRecord > originals )
2021-07-05 18:05:43 +02:00
{
2024-11-12 18:37:23 +01:00
// ToDo: Nur noch ServiceRecords aktualisieren, weil es jetzt einen Fremdschlüssel gibt!
2023-10-25 21:52:23 +02:00
var result = new List < ServiceRecord > ( ) ;
2021-07-05 18:05:43 +02:00
var oldVsNew = new Dictionary < ServiceRecord , ServiceRecordDC > ( ) ;
var orderedOldOnes = originals . Where ( x = > x . Oid . HasValue ) . OrderBy ( x = > x . Oid . Value ) . ToList ( ) ;
var orderedNewOnes = serviceRecords . Where ( x = > x . ServiceRecordOid . HasValue ) . OrderBy ( x = > x . ServiceRecordOid . Value ) . ToList ( ) ;
foreach ( var oldSr in orderedOldOnes )
{
var newSr = orderedNewOnes . FirstOrDefault ( f = > f . ServiceRecordOid = = oldSr . Oid ) ;
if ( newSr ! = null )
{
oldVsNew . Add ( oldSr , newSr ) ;
}
}
var signatureOids = new List < long > ( ) ;
foreach ( var kvp in oldVsNew )
{
if ( ( kvp . Key . Start ! = kvp . Value . Start | | kvp . Key . End ! = kvp . Value . End ) & & kvp . Key . SignatureOid . HasValue )
{
signatureOids . AddIfNotIn ( kvp . Key . SignatureOid . Value ) ;
kvp . Value . SignatureOid = null ;
}
}
2024-04-17 16:33:19 +02:00
if ( signatureOids . Any ( ) )
2021-07-05 18:05:43 +02:00
{
var signatures2Delete = DAOFactory . GenericDAO . LoadByIDs < Signature > ( signatureOids ) ;
2023-07-12 11:38:39 +02:00
var oids2Versions = new Dictionary < long , long > ( ) ;
signatures2Delete . DoForEach ( signature = >
{
oids2Versions . Add ( signature . Oid . Value , signature . Version . Value ) ;
} ) ;
ServiceLogic . SetActivationType < Signature > ( oids2Versions , ActivationTypeId . Deleted ) ;
2023-10-25 21:52:23 +02:00
2024-04-17 16:33:19 +02:00
foreach ( var serviceRecord in originals )
2023-10-25 21:52:23 +02:00
{
//MakeSignatureStatusTypeServiceRecordHistoryEntry(serviceRecord, SignatureStateType.Invalid, null, null);
result . AddIfNotIn ( serviceRecord ) ;
}
2021-07-05 18:05:43 +02:00
}
2023-10-25 21:52:23 +02:00
return result ;
2021-07-05 18:05:43 +02:00
}
2022-03-14 07:08:32 +01:00
2022-03-25 15:05:39 +01:00
public List < DienstZeileDC > InitDienstzeilen ( DienstBlockDC block , List < DienstInfoDC > dienste , DateTime date , int? standardanzahlZeilen )
2022-03-14 07:08:32 +01:00
{
try
{
2022-03-25 15:05:39 +01:00
return DienstplanungsManager . Init ( block , dienste , date , standardanzahlZeilen ) ;
2022-03-14 07:08:32 +01:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2022-03-25 15:05:39 +01:00
public List < DienstZeileDC > InitDienstzeilenNachSortieren ( List < DienstBlockDC > bloecke , List < DienstInfoDC > dienste , DateTime date , int? standardanzahlZeilen )
2022-03-14 07:08:32 +01:00
{
try
{
2022-03-25 15:05:39 +01:00
return DienstplanungsManager . InitNachSortieren ( bloecke , dienste , date , standardanzahlZeilen ) ;
2022-03-14 07:08:32 +01:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2022-03-22 11:38:58 +01:00
public DienstplanerMonthlySummaryDC BerechneSollSaldoUndIstFuerEinzelnenMitarbeiter ( DateTime date , long empOid , List < DienstEintragDC > dienstEintraege , List < DienstvertretungDC > dienstvertretungen ,
List < AbsenceTimeDC > absenceTimes , List < OvertimeDC > overtimes , out long stundenBeiAbwesenheitKey , out decimal stundenBeiAbwesenheitValue )
{
return DienstplanungsManager . BerechneSollSaldoUndIstFuerEinzelnenMitarbeiter ( date , empOid , dienstEintraege , dienstvertretungen , absenceTimes , overtimes , out stundenBeiAbwesenheitKey , out stundenBeiAbwesenheitValue ) ;
}
2022-10-10 12:57:34 +02:00
public void SaveAllFilesToDisk ( )
{
var oid = DAOFactory . SearchDAO . GetMaxOidFromFileAttachment ( ) ;
for ( int i = 1 ; i < = oid ; i + + )
{
var file = DAOFactory . GenericDAO . LoadByID < FileAttachment > ( i ) ;
try
{
//prüfe ob Datei existiert, sonst kommt ein Hibernate Fehler
2024-04-17 16:33:19 +02:00
2022-10-10 12:57:34 +02:00
if ( file . Data ? . Length > 0 )
{
FileAttachmentUtils . SaveFileToFileDirectory ( file ) ;
}
}
catch ( Exception )
{
}
2024-04-17 16:33:19 +02:00
2022-10-10 12:57:34 +02:00
}
}
2022-12-30 16:28:23 +01:00
public List < ServiceRecordDC > GetCustomerServiceRecordsWithStartEndDate ( long pCustomerOid , long costbearer2SupportConceptOid , DateTime start , DateTime ende )
{
try
{
2023-03-31 17:07:46 +02:00
var serviceRecords = DAOFactory . SearchDAO . FindServiceRecordsDetailsForLastDaysWithStartEndDate ( costbearer2SupportConceptOid , start , ende ) ;
var distinctServiceRecords = serviceRecords . Distinct ( ) ;
return MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDCs ( distinctServiceRecords ) ;
2022-12-30 16:28:23 +01:00
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2022-12-30 16:28:23 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2023-01-26 12:55:56 +01:00
public List < ConfirmationReceiptSignatureDC > GetConfirmationReceiptSignatures ( List < long > oids )
{
try
{
var signatures = DAOFactory . GenericDAO . GetActiveByIDs < ConfirmationReceiptSignature > ( oids ) ;
return MapperFactory . ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature . MapToNewDCs ( signatures ) ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2023-01-26 12:55:56 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2023-03-03 21:54:36 +01:00
public SchedulerAppointmentDC GetRootAppointment ( string recurrenceId )
{
try
{
2024-04-17 16:33:19 +02:00
if ( Guid . TryParse ( recurrenceId , out var guid ) )
2023-03-03 21:54:36 +01:00
{
var rootAppointment = DAOFactory . SearchDAO . FindRootAppointmentByRecurrenceId ( recurrenceId ) ;
return MapperFactory . SchedulerAppointmentDCSchedulerAppointment . MapToNewDC ( rootAppointment ) ;
}
return null ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2023-03-03 21:54:36 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2023-05-23 13:56:22 +02:00
public Dictionary < string , string > GetDiagiosisStringsForICD10Codes ( List < string > icd10Codes )
{
try
{
var result = new Dictionary < string , string > ( ) ;
2024-04-17 16:33:19 +02:00
foreach ( var code in icd10Codes )
2023-05-23 13:56:22 +02:00
{
result . AddIfNotIn ( new KeyValuePair < string , string > ( code , ICD10DAO . GetDiagnosisForCode ( code ) ) ) ;
}
return result ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2023-05-23 13:56:22 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2023-06-18 17:11:35 +02:00
public void DeleteSignature ( long signatureOid , long serviceRecordOid )
{
try
{
var serviceRecord = DAOFactory . GenericDAO . LoadByID < ServiceRecord > ( serviceRecordOid ) ;
serviceRecord . SignatureOid = null ;
DAOFactory . GenericDAO . Update ( serviceRecord ) ;
2023-10-28 13:34:32 +02:00
MakeSignatureStatusTypeServiceRecordHistoryEntry ( serviceRecord , SignatureStateType . ManuallyDeleted , null , null , null , null ) ;
2023-06-18 17:11:35 +02:00
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2023-06-18 17:11:35 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2023-06-19 16:03:55 +02:00
/// <summary>
/// Prüft, ob der angegebene ServiceRecord auch eine Monatsunterschrift(ConfirmationReceiptSignature) hat.
/// </summary>
/// <param name="serviceRecordOid">Oid des ServiceRecords</param>
/// <param name="signatureType">Mitarbeiter- oder Klientenunterschrift</param>
/// <returns>Ob der ServiceRecord mit einer Monatsunterschrift verknüpft ist</returns>
public bool CheckForConfirmationReceiptSignatureForServiceRecord ( long serviceRecordOid , SignatureType signatureType )
{
try
{
return DAOFactory . SearchDAO . CheckForConfirmationReceiptSignatureForServiceRecord ( serviceRecordOid , signatureType ) ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2023-06-19 16:03:55 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2024-04-17 16:33:19 +02:00
2023-10-28 13:34:32 +02:00
private static void MakeSignatureStatusTypeServiceRecordHistoryEntry ( ServiceRecord serviceRecord , SignatureStateType ? singleSignatureStateType , SignatureStateType ? customerMonthlySignatureStateType , SignatureStateType ? employeeMonthlySignatureStateType , long? customerConfirmationReceiptSignatureOid , long? employeeConfirmationReceiptsignatureOid )
2023-10-25 21:52:23 +02:00
{
2023-11-02 16:25:36 +01:00
// Alten Unterschriftenstatus aus ServiceRecordHistory laden
SignatureStateInfoFromServiceRecordHistoryEntry previousRecordHistorySignatureInfo = null ;
2024-11-12 18:37:23 +01:00
if ( serviceRecord . Oid . HasValue )
2023-11-02 16:25:36 +01:00
{
previousRecordHistorySignatureInfo = DAOFactory . SearchDAO . FindMostRecentSignatureStatusInfoByServiceRecordOid ( serviceRecord . Oid . Value ) ;
}
2023-10-25 21:52:23 +02:00
var seviceRecordHistoryEntry = new ServiceRecordHistory
{
2024-11-12 18:37:23 +01:00
TimeStamp = DateTime . Now ,
ChangeType = StatementType . Signature ,
CostBearer2SupportConcept = serviceRecord . CostBearer2SupportConcept ,
CostBearer2SupportConceptOid = serviceRecord . CostBearer2SupportConceptOid ,
Customer = serviceRecord . Customer ,
CustomerOid = serviceRecord . CustomerOid ,
Employee = serviceRecord . Employee ,
EmployeeOid = serviceRecord . EmployeeOid ,
End = serviceRecord . End ,
Group = serviceRecord . Group ,
GroupEmployeeCount = serviceRecord . GroupEmployeeCount ,
GroupOid = serviceRecord . GroupOid ,
GroupPersonCount = serviceRecord . GroupPersonCount ,
GroupRoundedDuration = serviceRecord . GroupRoundedDuration ,
IP = serviceRecord . IP ,
IsActive = serviceRecord . IsActive ,
Notice = serviceRecord . Notice ,
ServiceRecordOid = serviceRecord . Oid ,
RoundedDuration = serviceRecord . RoundedDuration ,
ServiceDescription = serviceRecord . ServiceDescription ,
ServiceRecordType = serviceRecord . ServiceRecordType ,
ServiceRecordInsTs = serviceRecord . InsTs ,
ServiceRecordVersion = serviceRecord . Version . Value ,
ServiceRecordInsUser = serviceRecord . InsUser ,
ServiceRecordUdpUser = serviceRecord . UdpUser ,
Start = serviceRecord . Start ,
SupportConcept = serviceRecord . SupportConcept ,
SystemEntryID = serviceRecord . SystemEntryID ,
DistanceInMeter = serviceRecord . DistanceInMeter ,
IsCreatedInMobileClient = serviceRecord . IsCreatedInMobileClient ,
2023-11-02 16:25:36 +01:00
CustomerConfirmationReceiptSignatureStateType = customerMonthlySignatureStateType ? ? previousRecordHistorySignatureInfo ? . CustomerConfirmationReceiptSignatureStateType ? ? SignatureStateType . None ,
EmployeeConfirmationReceiptSignatureStateType = employeeMonthlySignatureStateType ? ? previousRecordHistorySignatureInfo ? . EmployeeConfirmationReceiptSignatureStateType ? ? SignatureStateType . None ,
2024-11-12 18:37:23 +01:00
ServiceRecordSignatureStateType = singleSignatureStateType ? ? previousRecordHistorySignatureInfo ? . ServiceRecordSignatureStateType ? ? SignatureStateType . None ,
CustomerConfirmationReceiptSignatureOid = customerConfirmationReceiptSignatureOid ? ? previousRecordHistorySignatureInfo ? . CustomerConfirmationReceiptSignatureOid ,
EmployeeConfirmationReceiptSignatureOid = employeeConfirmationReceiptsignatureOid ? ? previousRecordHistorySignatureInfo ? . EmployeeConfirmationReceiptSignatureOid
2023-10-25 21:52:23 +02:00
} ;
DAOFactory . GenericDAO . Insert ( seviceRecordHistoryEntry ) ;
}
2023-12-21 20:46:13 +00:00
public string GetDakotaFileFormat ( object param )
{
try
{
2024-04-17 16:33:19 +02:00
//var test_oid = Convert.ToInt64(param);
//var test_invoicebase = DAOFactory.GenericDAO.GetByID<InvoiceBase>(test_oid);
//var test_datetime = test_invoicebase.InvoiceDate.Value;
2023-08-21 14:45:00 +02:00
2024-04-17 16:33:19 +02:00
//var manager = new DakotaManager(test_datetime.Month, DateTime.Now);
//var oids = new List<Int64>();
2023-09-15 16:33:11 +02:00
2024-04-17 16:33:19 +02:00
//oids.Add(test_oid);
2023-09-21 16:49:31 +02:00
2024-04-17 16:33:19 +02:00
//foreach (var invoicebase_oid in oids)
//{
// var service = DAOFactory.SearchDAO.GetServiceInvoiceByInvoiceBaseOid(invoicebase_oid);
// var invoicebase = DAOFactory.GenericDAO.GetByID<InvoiceBase>(invoicebase_oid);
// var orga = invoicebase.CostBearer2SupportConcept.CostBearer.Organisation;
// var customer = invoicebase.CostBearer2SupportConcept.SupportConcept.Customer;
// var mandator = GetMandatorEntity();
// var servicedc = MapperFactory.ServiceInvoiceDC_ServiceInvoice.MapToNewDC(service);
// var orgadc = MapperFactory.OrganisationDC_OrganisationMapper.MapToNewDC(orga);
// var customerdc = MapperFactory.CustomerDC_Customer.MapToNewDC(customer);
// var mandatordc = MapperFactory.MandatorDC_Mandator.MapToNewDC(mandator);
// manager.Add(servicedc, orgadc, customerdc, mandatordc);
//}
2023-09-15 16:33:11 +02:00
2023-12-21 20:46:13 +00:00
2024-04-17 16:33:19 +02:00
//manager.Apply();
2023-10-17 12:53:39 +02:00
2024-04-17 16:33:19 +02:00
//manager.Save(@"C:\Projects\GKV Abrechnung Tests", true);
2023-08-21 14:45:00 +02:00
2024-04-17 16:33:19 +02:00
////return manager.DakotaFileDict.First().Value.GetNutzdatendatei();
2024-01-08 18:36:29 +01:00
2024-04-17 16:33:19 +02:00
//var nutzdatendatei = manager.DakotaFileDict.First().Value.GetNutzdatendatei();
2024-01-08 18:36:29 +01:00
2024-04-17 16:33:19 +02:00
//String url = "http://localhost:3777/Host/GkvAbrechnungView.aspx";
////String url = "https://app8.bewoplaner.de/service/GkvAbrechnungView.aspx";
//using (WebClient client = new WebClient())
//{
// //MessageBox.Show(hostAddress);
2024-01-08 18:36:29 +01:00
2024-04-17 16:33:19 +02:00
// var nvc = new NameValueCollection();
// nvc.Add("Kundennummer", "7375324044");
// nvc.Add("IKDatenannahmestelle", manager.DakotaFileDict.First().Value.GetIKEmpfang());
// nvc.Add("IKEmpfang", manager.DakotaFileDict.First().Value.GetIKEmpfang());
// nvc.Add("TransferName", manager.DakotaFileDict.First().Value.GetTransferName());
// nvc.Add("Nutzdatendatei", nutzdatendatei);
// nvc.Add("Auftragsdatei", manager.DakotaFileDict.First().Value.GetAuftragsdatei());
2024-01-08 18:36:29 +01:00
2024-04-17 16:33:19 +02:00
// byte[] response = client.UploadValues(url, "POST", nvc);
2024-01-08 18:36:29 +01:00
2024-04-17 16:33:19 +02:00
// String responseStr = System.Text.Encoding.ASCII.GetString(response);
//}
2024-01-08 18:36:29 +01:00
2024-04-17 16:33:19 +02:00
//return nutzdatendatei;
2023-08-21 14:45:00 +02:00
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
2024-04-17 16:33:19 +02:00
throw new NotImplementedException ( ) ;
2023-08-21 14:45:00 +02:00
}
2024-01-15 11:34:45 +01:00
2024-01-12 17:16:52 +01:00
public List < ServiceRecordDC > GetEmployeesServiceRecordsWithStartEndDatePaginated ( long pEmployeeOid , DateTime start , DateTime ende , int firstResult , int maxResults , out int rowCount )
{
try
{
var serviceRecords = DAOFactory . SearchDAO . FindEmployeeServiceRecordsWithoutCustomerWithStartEndDatePaginated ( pEmployeeOid , start , ende , firstResult , maxResults , out rowCount ) ;
return MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDCs ( serviceRecords ) ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2024-01-12 17:16:52 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < ServiceRecordDC > GetEmployeesServiceRecords2Paginated ( long pEmployeeOid , long? days , int firstResult , int maxResults , out int rowCount )
{
try
{
var serviceRecords = DAOFactory . SearchDAO . FindEmployeeServiceRecordsWithoutCustomerPaginated ( pEmployeeOid , days , firstResult , maxResults , out rowCount ) ;
return MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDCs ( serviceRecords ) ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2024-01-12 17:16:52 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public List < ServiceRecordDC > GetCustomerServiceRecordsWithStartEndDatePaginated ( long pCustomerOid , long costbearer2SupportConceptOid , DateTime start , DateTime ende , int firstResult , int maxResults , out int rowCount )
{
try
{
var serviceRecords = DAOFactory . SearchDAO . FindServiceRecordsDetailsForLastDaysWithStartEndDatePaginated ( costbearer2SupportConceptOid , start , ende , firstResult , maxResults , out rowCount ) ;
var distinctServiceRecords = serviceRecords . Distinct ( ) ;
return MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDCs ( distinctServiceRecords ) ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2024-01-12 17:16:52 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public IList < ServiceRecordDC > FindServiceRecordsForLastDaysPaginated ( long? costbearer2SupportConceptOid , int days , long? employeeOid , int firstResult , int maxResults , out int rowCount )
{
try
{
return MapperFactory . ServiceRecordDC_ServiceRecord . MapToNewDCs ( DAOFactory . SearchDAO . FindServiceRecordsForDaysPaginated ( costbearer2SupportConceptOid , days , employeeOid , firstResult , maxResults , out rowCount ) ) ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2024-01-12 17:16:52 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2024-02-20 14:42:04 +01:00
public List < BargeldtransaktionshistoryDC > LoadBargeldtransaktionshistoryEntries ( long transaktionsOid )
{
try
{
var historyEntries = DAOFactory . SearchDAO . LoadBargeldtransaktionshistoryEntries ( transaktionsOid ) ;
return MapperFactory . BargeldtransaktionshistoryDC_Bargeldtransaktionshistory . MapToNewDCs ( historyEntries ) ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2024-02-20 14:42:04 +01:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2024-04-15 13:59:42 +02:00
public List < SignatureDC > GetAllSignatures ( )
{
try
{
return MapperFactory . SignatureDC_Signature . MapToNewDCs ( DAOFactory . GenericDAO . GetAllActive < Signature > ( ) ) ;
}
2024-04-17 16:33:19 +02:00
catch ( Exception e )
2024-04-15 13:59:42 +02:00
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2024-04-18 16:14:20 +02:00
public List < BargeldtransaktionshistoryDC > LoadBargeldtransaktionshistoryEntriesByTransaktionsOids ( List < long > transaktionsOids )
{
try
{
return MapperFactory . BargeldtransaktionshistoryDC_Bargeldtransaktionshistory . MapToNewDCs ( DAOFactory . SearchDAO . LoadBargeldtransaktionshistoryEntriesByTransaktionsOids ( transaktionsOids ) ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2024-06-19 16:13:56 +02:00
public AiChatDC CreateAiQueryForServiceRecords ( AiChatDC acdc , long cb2scOid , DateTime startdate , DateTime enddate )
{
try
{
var s = PluginLoader . FindClass < AiService > ( ) ;
return s . CreateAiQueryForServiceRecords ( acdc , cb2scOid , startdate , enddate ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2024-06-24 16:30:36 +02:00
public AiChatDC CreateAiQueryForSingleCustomer ( AiChatDC acdc , long customerOid )
{
try
{
var s = PluginLoader . FindClass < AiService > ( ) ;
return s . CreateAiQueryForSingleCustomer ( acdc , customerOid ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
public AiChatDC CreateAiQueryForObjects ( AiChatDC acdc , long objectTid )
{
try
{
var s = PluginLoader . FindClass < AiService > ( ) ;
return s . CreateAiQueryForObjects ( acdc , objectTid ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2024-09-25 16:57:03 +02:00
public AiSettingsDC GetAiSettings ( int settingsId )
{
try
{
var s = PluginLoader . FindClass < AiService > ( ) ;
return s . GetAiSettings ( settingsId ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2024-09-26 11:40:30 +02:00
public AiSettingsDC UpdateAiSettings ( AiSettingsDC settings )
{
try
{
AiSettings ais = null ;
if ( settings . Oid . HasValue )
{
ais = DAOFactory . GenericDAO . LoadByID < AiSettings > ( settings . Oid . Value ) ;
ais = MapperFactory . AiSettingsDC_AiSettings . MergeWithEntity ( settings , ais ) ;
DAOFactory . GenericDAO . Update ( ais ) ;
}
else
{
ais = MapperFactory . AiSettingsDC_AiSettings . MapToNewEntity ( settings ) ;
DAOFactory . GenericDAO . Insert ( ais ) ;
}
return MapperFactory . AiSettingsDC_AiSettings . MapToNewDC ( ais ) ;
}
catch ( Exception e )
{
throw Utils . CreateBeWoFaultException ( e ) ;
}
}
2023-10-25 21:52:23 +02:00
}
public class ServiceRecord2SignatureStates
{
public ServiceRecord ServiceRecord { get ; }
public SignatureStateType ? SingleSignatureStateType { get ; set ; }
public SignatureStateType ? CustomerMonthlySignatureStateType { get ; set ; }
public SignatureStateType ? EmployeeMonthlySignatreStateType { get ; set ; }
/// <summary>
/// Erzeugt das Objekt mit den SignatureStates. Wird als Wert eines States null übergeben, wird beim Erzeugen des ServiceRecordHistory-Eintrags der Wert des vorherigen ServiceRecordHistory-Eintrags genommen, falls vorhanden.
/// </summary>
/// <param name="serviceRecord"></param>
/// <param name="singleSignatureStateType"></param>
/// <param name="customerMonthlySignatureStateType"></param>
/// <param name="employeeMonthlySignatreStateType"></param>
public ServiceRecord2SignatureStates ( ServiceRecord serviceRecord , SignatureStateType ? singleSignatureStateType , SignatureStateType ? customerMonthlySignatureStateType , SignatureStateType ? employeeMonthlySignatreStateType )
{
2024-04-17 16:33:19 +02:00
ServiceRecord = serviceRecord ;
SingleSignatureStateType = singleSignatureStateType ;
2023-10-25 21:52:23 +02:00
CustomerMonthlySignatureStateType = customerMonthlySignatureStateType ;
2024-04-17 16:33:19 +02:00
EmployeeMonthlySignatreStateType = employeeMonthlySignatreStateType ;
2023-10-25 21:52:23 +02:00
}
public override bool Equals ( object obj )
{
2024-11-12 18:37:23 +01:00
if ( obj is ServiceRecord2SignatureStates sr2Ss & & sr2Ss . ServiceRecord ! = null )
2023-10-25 21:52:23 +02:00
{
return ServiceRecord ? . Equals ( sr2Ss . ServiceRecord ) ? ? false ;
}
return false ;
}
2021-01-14 16:30:28 +01:00
}
2019-07-15 11:24:48 +02:00
}