using System; using System.Collections.Generic; using System.Configuration; using System.IO; using System.Linq; using System.Net; using System.ServiceModel; using System.Text; using System.Threading; using System.Windows.Documents; using BeWo.Data; using BeWo.Data.Access; using BeWo.Data.Entities; using BeWo.Data.ICD10; using BeWo.Service.Configuration; using BeWo.Service.Core; using BeWo.Service.DCEntityMapper; using BeWo.Service.Invoicing; using BeWo.Service.Plugins; using BeWo.Service.Security; using BeWo.Service.ServiceContracts; using BS.Shared; using BS.Shared.Core; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using BS.Shared.DataContracts.Reports; using BS.Shared.Extensions; using BS.Shared.Services; using Utils = BeWo.Service.Core.Utils; namespace BeWo.Service.ServiceImplementations { [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)] public class OperationsServiceImp : IOperationsService { #region Public Methods public Mandator GetMandatorEntity() { return AppSettings.GetMandatorEntity(); } #endregion #region Implemented Interfaces #region IOperationsService public void DeactivateInvoices(List pInvoices) { try { ServiceLogic.SetActivationType(pInvoices.ToDictionary(i => i.InvoiceOid.Value, i => i.InvoiceVersion.Value), ActivationTypeId.Deleted); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeactivateServiceCategories(Dictionary pOid2Version) { try { ServiceLogic.SetActivationType(pOid2Version, ActivationTypeId.Deleted); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeactivateAdditionalServices(Dictionary pOid2Version) { try { ServiceLogic.SetActivationType(pOid2Version, ActivationTypeId.Deleted); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeactivateServiceCategory(long pOid, long pVersion) { try { ServiceLogic.SetActivationType(new Dictionary { { pOid, pVersion } }, ActivationTypeId.Deleted); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeactivateServiceDescription(long pOid, long pVersion) { try { ServiceLogic.SetActivationType(new Dictionary { { pOid, pVersion } }, ActivationTypeId.Deleted); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeactivateServiceDescriptions(Dictionary pOid2Version) { try { ServiceLogic.SetActivationType(pOid2Version, ActivationTypeId.Deleted); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeactivateAdditionalServiceRegions(Dictionary pOid2Version) { try { ServiceLogic.SetActivationType(pOid2Version, ActivationTypeId.Deleted); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeleteAccountingTransaction(long pOid, long pVersion) { try { DeleteAccountingTransactions(new Dictionary { { pOid, pVersion } }); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeleteAccountingTransactions(Dictionary pOid2Version) { try { List lOriginals = DAOFactory.GenericDAO.LoadByIDs(pOid2Version.Select(e => e.Key)); lOriginals.DoForEach(or => MapperFactory.AccountingTransactionDC_AccountingTransaction.ConcurrencyCheck(pOid2Version[or.Oid.Value], or)); // DAOFactory.GenericDAO.Deactivate(lOriginals); DAOFactory.GenericDAO.Delete(lOriginals); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeleteFileAttachment(long pOid, long pVersion) { try { DeleteFileAttachments(new Dictionary { { pOid, pVersion } }); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeleteFileAttachments(Dictionary pOid2Version) { try { List lOriginals = DAOFactory.GenericDAO.LoadByIDs(pOid2Version.Select(e => e.Key)); lOriginals.DoForEach(or => MapperFactory.FileAttachmentDC_FileAttachment.ConcurrencyCheck(pOid2Version[or.Oid.Value], or)); DAOFactory.GenericDAO.Delete(lOriginals); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeleteServiceCategories(Dictionary pOid2Version) { try { List lOriginals = DAOFactory.GenericDAO.LoadByIDs(pOid2Version.Select(e => e.Key)); lOriginals.DoForEach(or => MapperFactory.ServiceCategoryDC_ServiceCategory.ConcurrencyCheck(pOid2Version[or.Oid.Value], or)); DAOFactory.GenericDAO.Delete(lOriginals); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeleteServiceCategory(long pOid, long pVersion) { try { DeleteServiceCategories(new Dictionary { { pOid, pVersion } }); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeleteServiceDescription(long pOid, long pVersion) { try { DeleteServiceDescriptions(new Dictionary { { pOid, pVersion } }); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeleteServiceDescriptions(Dictionary pOid2Version) { try { List lOriginals = DAOFactory.GenericDAO.LoadByIDs(pOid2Version.Select(e => e.Key)); lOriginals.DoForEach(or => MapperFactory.ServiceDescriptionDC_ServiceDescription.ConcurrencyCheck(pOid2Version[or.Oid.Value], or)); DAOFactory.GenericDAO.Delete(lOriginals); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeleteServiceRecord(long pOid, long pVersion) { try { DeleteServiceRecords(new Dictionary { { pOid, pVersion } }); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeleteServiceRecords(Dictionary pOid2Version) { InternalDeleteServicerecords(pOid2Version); } public static void InternalDeleteServicerecords(IDictionary pOid2Version) { try { var lOriginals = DAOFactory.GenericDAO.LoadByIDs(pOid2Version.Select(e => e.Key)); lOriginals.DoForEach(or => MapperFactory.ServiceRecordDC_ServiceRecord.ConcurrencyCheck(pOid2Version[or.Oid.Value], or)); var srListToDelete = new List(); foreach (var item in lOriginals) { if (item.Group != null) { MakeServiceRecordHistoryEntry(item.Group.ServiceRecordList, null, StatementType.Delete); DAOFactory.GenericDAO.Delete(item.Group); } else { srListToDelete.Add(item); } } if (srListToDelete.Count > 0) { MakeServiceRecordHistoryEntry(srListToDelete, null, StatementType.Delete); DAOFactory.GenericDAO.Delete(srListToDelete); } } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public Settlement2DC GenerateInitialSettlementDC(long pCostBearer2SupportConceptOid) { return GenerateInitialSettlementDCForPeriod(pCostBearer2SupportConceptOid, null, null); } public Settlement2DC GenerateInitialSettlementDCForPeriod(long pCostBearer2SupportConceptOid, DateTime? periodStart, DateTime? periodEnd) { try { var lCb2Sc = DAOFactory.GenericDAO.LoadByID(pCostBearer2SupportConceptOid); var costBearer = lCb2Sc.CostBearer; string tenant = null; if (MultitenancyOperationContextExt.Current != null) { tenant = MultitenancyOperationContextExt.Current.Tenant; } var factory = PluginLoader.FindClass(costBearer.ID); if (factory == null) { factory = InvoiceFactory.GetInstance(costBearer.ID, tenant); } var creator = factory.CreateSettlementInvoiceCreator(costBearer.ID, tenant, lCb2Sc); var lResult = creator.GenerateSettlementInvoice(lCb2Sc, periodStart, periodEnd); return lResult; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GenerateInitialSettlementDCsForPeriod(long pCostBearer, DateTime periodStart, DateTime periodEnd) { return new CustomerServiceImp() .GetAllActiveSupportConceptsCompact() .Where(i => i.IsApproved && i.CostBearerOids2CostBearerRelOids.ContainsKey(pCostBearer)) .Select(i => GenerateInitialSettlementDCForPeriod(i.CostBearerOids2CostBearerRelOids[pCostBearer], periodStart, periodEnd)) .ToList(); } public List GetAccountingTransactions(DateTimeSpan pSpan, long? pSupportConceptOid, long? pSupportConceptCostBearerRelOid) { try { return MapperFactory.AccountingTransactionDC_AccountingTransaction.MapToNewDCs(DAOFactory.SearchDAO.FindAccoutingTransactions(pSpan, pSupportConceptOid, pSupportConceptCostBearerRelOid)); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetAllActiveInvoices() { try { return MapperFactory.InvoiceDC_Invoice.MapToNewDCs(DAOFactory.GenericDAO.GetAllActive()); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetAllActiveSupportConceptCostbearer(bool onlyApproved, bool onlyWithAssignedCostbearer, long employeeOid) { try { IList list; if (onlyApproved) { list = DAOFactory.SearchDAO.FindAllActiveApprovedSupportConcepts(); } else { list = DAOFactory.GenericDAO.GetAllActive(); } List result = CreateFlatSupportConceptCostBearerDCList(list, onlyWithAssignedCostbearer, employeeOid); if (onlyApproved) { return result.Where(i => i.IsApproved).ToList(); } return result; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetAllAdditionalService() { try { IList list = DAOFactory.GenericDAO.GetAllActive(); return MapperFactory.AdditionalServiceDC_AdditionalService.MapToNewDCs(list); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetAllAdditionalServiceRegion() { try { var result = new List(); result = MapperFactory.AdditionalServiceRegionDC_AdditionalServiceRegion.MapToNewDCs( DAOFactory.GenericDAO.GetAllActive()); return result; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetAllServiceCategories() { try { IList list = DAOFactory.GenericDAO.GetAllActive(); return MapperFactory.ServiceCategoryDC_ServiceCategory.MapToNewDCs(list); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetAllServiceDescriptions() { try { IList list = DAOFactory.GenericDAO.GetAllActive(); AppSettings settings = AppSettings.CreateSettings(); if (settings.SortServiceDescriptionAlphabetically) { list = list.OrderBy(sd => sd.Name).ToList(); } return MapperFactory.ServiceDescriptionDC_ServiceDescription.MapToNewDCs(list); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List FindServiceDescriptionsForCategory(long pCategoryOid) { try { return MapperFactory.ServiceDescriptionDC_ServiceDescription.MapToNewDCs(DAOFactory.SearchDAO.FindServiceDescriptionForCategory(pCategoryOid)); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public ServiceDescriptionDC GetServiceDescription(long pServiceDescriptionOid) { try { return MapperFactory.ServiceDescriptionDC_ServiceDescription.MapToNewDC(DAOFactory.GenericDAO.GetByID(pServiceDescriptionOid)); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public string GetCompressedICD10Diagnosis() { try { return ICD10DAO.GetCompressedString(); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public CustomerInfoDC GetCustomerInfosForCustomerOid(long customerOid) { try { var result = new CustomerInfoDC(); var customer = DAOFactory.GenericDAO.LoadByID(customerOid); if (customer.SupportConcepts == null || !customer.SupportConcepts.Exists(sc => sc.IsActive == ActivationTypeId.Active)) { result.CurrentSupportConcept = "Kein aktueller Hilfeplan"; } else { SupportConcept currentSC = customer.SupportConcepts.Where(sc => sc.IsActive == ActivationTypeId.Active).OrderByDescending(sc => sc.StartDate).First(); result.CurrentSupportConcept = "Akt. HP: "; if (currentSC.StartDate.HasValue) { result.CurrentSupportConcept += currentSC.StartDate.Value.ToShortDateString().Remove(6, 2); } if (currentSC.EndDate.HasValue) { result.CurrentSupportConcept += " - " + currentSC.EndDate.Value.ToShortDateString().Remove(6, 2); } result.SupportConceptInfos = GetSupportConceptInfosForSupportConceptOid(currentSC.Oid.Value); } return result; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetCustomerServiceRecordsCompact(long pCustomerOid, long costbearer2SupportConceptOid, long? days) { try { var result = new List(); var srList = DAOFactory.SearchDAO.FindServiceRecordsDetailsForLastDays(costbearer2SupportConceptOid, days); if (srList != null) { var serviceRecordsProcessed = new Dictionary(); foreach (var item in srList) { if (!serviceRecordsProcessed.ContainsKey(item.Oid.Value)) { //ServiceRecordDC dc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(item); //result.Add(dc); var dc = CreateServiceRecordDCCompact(item); if (dc != null) { result.Add(dc); } serviceRecordsProcessed.Add(item.Oid.Value, true); } } } return result; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetCustomerServiceRecords(long pCustomerOid, bool fetchArchivedSupportConcepts) { try { var result = new List(); var lCustomer = DAOFactory.SearchDAO.FindCustomerWithServiceRecordsWithDetail(pCustomerOid); if (lCustomer != null) { var srList = lCustomer.ServiceRecordList; if (srList != null) { var serviceRecordsProcessed = new Dictionary(); foreach (var item in srList) { if (!serviceRecordsProcessed.ContainsKey(item.Oid.Value)) { var dc = CreateServiceRecordDCIfSupportConceptIsActive(item, lCustomer, !fetchArchivedSupportConcepts); if (dc != null) { result.Add(dc); } serviceRecordsProcessed.Add(item.Oid.Value, true); } } } } return result; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetCustomerServiceRecordsInMonth(long pCustomerOid, DateTime pMonth) { try { var list = GetCustomerServiceRecords(pCustomerOid, false); return list.Where(i => i.Start.HasValue && i.Start.Value.Year.Equals(pMonth.Year) && i.Start.Value.Month.Equals(pMonth.Month)).ToList(); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetEmployeesServiceRecords(long pEmployeeOid) { try { IEnumerable list = DAOFactory.SearchDAO.FindEmployeeServiceRecordsWithoutCustomer(pEmployeeOid, null); return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(list); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetEmployeesServiceRecords2(long pEmployeeOid, long? days) { try { IEnumerable list = DAOFactory.SearchDAO.FindEmployeeServiceRecordsWithoutCustomer(pEmployeeOid, days); return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(list); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetEmployeesServiceRecordsWithStartEndDate(long pEmployeeOid, DateTime start, DateTime ende) { try { IEnumerable list = DAOFactory.SearchDAO.FindEmployeeServiceRecordsWithoutCustomerWithStartEndDate(pEmployeeOid,start,ende); return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(list); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetCustomerServiceRecordsCompactWithStartEndDate(long pCustomerOid, long costbearer2SupportConceptOid, DateTime start, DateTime ende) { try { var result = new List(); var srList = DAOFactory.SearchDAO.FindServiceRecordsDetailsForLastDaysWithStartEndDate(costbearer2SupportConceptOid, start,ende); if (srList != null) { var serviceRecordsProcessed = new Dictionary(); foreach (var item in srList) { if (!serviceRecordsProcessed.ContainsKey(item.Oid.Value)) { //ServiceRecordDC dc = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(item); //result.Add(dc); var dc = CreateServiceRecordDCCompact(item); if (dc != null) { result.Add(dc); } serviceRecordsProcessed.Add(item.Oid.Value, true); } } } return result; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetEmployeesServiceRecordsInSpan(long pEmployeeOid, DateTimeSpan limitinDateTimeSpan) { try { IEnumerable list = DAOFactory.SearchDAO.FindEmployeeServiceRecordsWithoutCustomerInSpan(pEmployeeOid, limitinDateTimeSpan); return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(list); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetFileAttachments(TableID pObjectTid, long pObjectOid) { try { IEnumerable files = DAOFactory.SearchDAO.FindFileAttachmentInfos(pObjectTid, pObjectOid); return files.Select(item => MapperFactory.FileAttachmentDC_FileAttachmentInfo.MapToNewDC(item)).ToList(); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetFolderTree(TableID pObjectTid, long pObjectOid) { try { IList folder = DAOFactory.SearchDAO.FindBeWoFolders(pObjectTid, pObjectOid); bool templateFolder = folder.Any(f => f.SystemEntryID.Equals(SystemEntryID.TemplateDirectory)); var folderDCList = new List(); foreach (BeWoFolder item in folder) { folderDCList.Add(MapperFactory.BeWoFolderDC_BeWoFolder.MapToNewDC(item)); } IEnumerable files = DAOFactory.SearchDAO.FindFileAttachmentInfos(pObjectTid, pObjectOid); var fileDCList = new List(); foreach (FileAttachmentInfo item in files) { fileDCList.Add(MapperFactory.FileAttachmentDC_FileAttachmentInfo.MapToNewDC(item)); } Thread.Sleep(500); return CreateFolderTree(folderDCList, fileDCList, pObjectTid, pObjectOid, templateFolder); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeleteFolder(long pBeWoFolderOid, long pVersion) { try { var origFolder = DAOFactory.GenericDAO.LoadByID(pBeWoFolderOid); MapperFactory.BeWoFolderDC_BeWoFolder.ConcurrencyCheck(pVersion, origFolder); DAOFactory.GenericDAO.Delete(origFolder); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public long InsertNewFolder(BeWoFolderDC folder) { try { BeWoFolder newFolder = MapperFactory.BeWoFolderDC_BeWoFolder.MapToNewEntity(folder); DAOFactory.GenericDAO.Insert(newFolder); BeWoFolderDC newFolderDC = MapperFactory.BeWoFolderDC_BeWoFolder.MapToNewDC(newFolder); return newFolderDC.BeWoFolderOid.Value; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public BeWoFolderDC UpdateFolder(BeWoFolderDC folder) { try { //Root Folder kann nicht umbenannt werden var origFolder = DAOFactory.GenericDAO.LoadByID(folder.BeWoFolderOid.Value); MapperFactory.BeWoFolderDC_BeWoFolder.MergeWithEntity(folder, origFolder); DAOFactory.GenericDAO.Update(origFolder); BeWoFolderDC updatedFolderDC = MapperFactory.BeWoFolderDC_BeWoFolder.MapToNewDC(origFolder); return updatedFolderDC; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public FileAttachmentDC UpdateFileAttachment(FileAttachmentDC file) { try { var origFile = DAOFactory.GenericDAO.LoadByID(file.FileAttachmentOid.Value); MapperFactory.FileAttachmentDC_FileAttachmentInfo.MergeWithEntity(file, origFile); DAOFactory.GenericDAO.Update(origFile); FileAttachmentDC updatedFileDC = MapperFactory.FileAttachmentDC_FileAttachmentInfo.MapToNewDC(origFile); return updatedFileDC; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public FileAttachmentDC DoTheRealFileUpdate(FileAttachmentDC file) { try { var origFile = DAOFactory.GenericDAO.LoadByID(file.FileAttachmentOid.Value); if (!origFile.Data.Equals(file.BinaryData)) { } MapperFactory.FileAttachmentDC_FileAttachment.MergeWithEntity(file, origFile); DAOFactory.GenericDAO.Update(origFile); FileAttachmentDC updatedFileDC = MapperFactory.FileAttachmentDC_FileAttachment.MapToNewDC(origFile); return updatedFileDC; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public MandatorDC GetMandator() { try { Mandator man = GetMandatorEntity(); MandatorDC manDc = MapperFactory.MandatorDC_Mandator.MapToNewDC(man); Dictionary settingValueDict = GetSettingsValueDict(manDc.Settings); string contractState = GetContractState(); Dictionary contractStateDict = GetSettingsValueDict(contractState); foreach (var kv in contractStateDict) { if (settingValueDict.ContainsKey(kv.Key)) { settingValueDict.Remove(kv.Key); } settingValueDict.Add(kv.Key, kv.Value); } if (!settingValueDict.ContainsKey("ShowScheduler") && man.IsSchedulerAllowed) { settingValueDict.Add("ShowScheduler", "1"); } if (!settingValueDict.ContainsKey("ShowMedication") && man.IsMedicationAllowed) { settingValueDict.Add("ShowMedication", "1"); } manDc.Settings = ""; foreach (var kv in settingValueDict) { if (manDc.Settings.Length > 0) { manDc.Settings += ";"; } manDc.Settings += String.Format("{0}={1}", kv.Key, kv.Value); } return manDc; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetServiceRecordHistory(long serviceRecordOid) { try { IEnumerable historyList = DAOFactory.SearchDAO.FindServiceRecordHistory(serviceRecordOid); List result = MapperFactory.ServiceRecordHistoryDC_ServiceRecordHistory.MapToNewDCs(historyList); return result; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public ServiceRecordGroupDC GetServiceRecordGroup(long pGroupOid) { try { ServiceRecordGroup group = DAOFactory.SearchDAO.FindServiceRecordGroup(pGroupOid); ServiceRecordGroupDC groupDC = MapperFactory.ServiceRecordGroupDC_ServiceRecordGroup.MapToNewDC(group); var result = new List(); var serviceRecordsProcessed = new Dictionary(); foreach (ServiceRecord item in group.ServiceRecordList) { if (!serviceRecordsProcessed.ContainsKey(item.Oid.Value)) { var dc = new ServiceRecordDC(); dc.ServiceRecordOid = item.Oid; dc.ServiceRecordVersion = item.Version; dc.Start = item.Start; dc.End = item.End; dc.Notice = item.Notice; dc.Notice2 = item.Notice2; dc.Notice3 = item.Notice3; dc.Notice4 = item.Notice4; dc.Notice5 = item.Notice5; dc.RoundedDuration = item.RoundedDuration; dc.InsertedOn = item.InsTs; dc.InsUser = item.InsUser; dc.DurationInStunden = item.DurationInStunden; dc.ServiceRecordFormat = item.ServiceRecordFormat; CompactCustomerDC customerDC = null; if (item.Customer != null) { customerDC = new CompactCustomerDC(); customerDC.CustomerOid = item.Customer.Oid.Value; customerDC.CustomerVersion = item.Customer.Version.Value; customerDC.FirstName = item.Customer.Person.FirstName; customerDC.LastName = item.Customer.Person.LastName; customerDC.DateOfBirth = item.Customer.Person.DateOfBirth; customerDC.Sex = item.Customer.Person.Sex; customerDC.ActivationType = item.Customer.IsActive; customerDC.TerminationDate = item.Customer.TerminationDate; customerDC.EquityContribution = item.Customer.EquityContribution; } dc.Customer = customerDC; if (item.Employee != null) { var employeeDC = new CompactEmployeeDC(); employeeDC.EmployeeOid = item.Employee.Oid.Value; employeeDC.EmployeeVersion = item.Employee.Version.Value; employeeDC.FirstName = item.Employee.Person.FirstName; employeeDC.LastName = item.Employee.Person.LastName; employeeDC.PersonnelNumber = item.Employee.PersonnelNumber; //employeeDC.FLSPerWeek = item.Employee.WeeklyFLS; dc.Employee = employeeDC; } CompactSupportConceptDC scDC = null; if (item.SupportConcept != null) { scDC = new CompactSupportConceptDC(); scDC.SupportConceptOid = item.SupportConcept.Oid.Value; scDC.SupportConceptVersion = item.SupportConcept.Version.Value; scDC.Customer = customerDC; scDC.ActivationType = item.SupportConcept.IsActive; scDC.ConferenceDate = item.SupportConcept.ConferenceDate; } dc.SupportConcept = scDC; CostBearer2SupportConcept cb2sc = item.CostBearer2SupportConcept; if (cb2sc != null) { dc.CostBearer2SupportConceptOid = cb2sc.Oid.Value; if (scDC != null) { var costBearer = new CompactCostBearerDC(); costBearer.IsCalculatingWithFactor = cb2sc.CostBearer.IsCalculatingWithFactor; costBearer.CostBearerID = cb2sc.CostBearer.ID; costBearer.CostBearerOid = cb2sc.CostBearer.Oid.Value; costBearer.CostBearer2SupportConceptOid = cb2sc.Oid.Value; costBearer.SupportConceptStatus = cb2sc.Status; costBearer.RequestedStartDate = cb2sc.RequestedStartDate; costBearer.RequestedEndDate = cb2sc.RequestedEndDate; costBearer.ApprovedStartDate = cb2sc.ApprovedStartDate; costBearer.ApprovedEndDate = cb2sc.ApprovedEndDate; // costBearer.ApprovedFLS = cb2sc.ApprovedFLS; // costBearer.ApprovedFLSTotal = cb2sc.ApprovedFLSTotal; costBearer.CustomerReferenceNumber = cb2sc.CustomerReferenceNumber; if (cb2sc.CostBearer.Organisation != null) { CompactOrganisationDC orgDC = MapperFactory.CompactOrganisationDC_Organisation.MapToNewDC(cb2sc.CostBearer.Organisation); costBearer.Organisation = orgDC; dc.CostBearer = orgDC; } scDC.CostBearerList.Add(costBearer); scDC.CustomerReferenceNumbers.Add(cb2sc.CustomerReferenceNumber); scDC.CostBearerRelOids.Add(cb2sc.Oid.Value); } } dc.GroupEmployeeCount = item.GroupEmployeeCount; dc.GroupPersonCount = item.GroupPersonCount; dc.GroupRoundedDuration = item.GroupRoundedDuration; dc.GroupOid = item.GroupOid; result.Add(dc); serviceRecordsProcessed.Add(item.Oid.Value, true); } } groupDC.ServiceRecordList = result; return groupDC; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public long GetLastServiceRecordGroupOid() { var sc = DAOFactory.GenericDAO.GetAllActiveAndArchived(); long x = sc.Last().Oid.Value; return x; } public List GetSupportConceptInfosForSupportConceptOid(long supportConceptOid) { try { var sc = DAOFactory.GenericDAO.LoadByID(supportConceptOid); return sc.CostBearer2SupportConceptList.Select( cb2sc => { Calculations calc = PluginLoader.FindClass(cb2sc.CostBearer.ID) ?? Calculations.GetInstance(cb2sc.CostBearer.ID); var res = new SupportConcetInfoDC { CostBearer = cb2sc.CostBearer.Organisation.Name, ApprovedHours = calc.GetApprovedHoursTotal(cb2sc.MapToNewDC(), true) ?? 0m, RecordedHours = calc.GetBillableDurationInMinutes(cb2sc.ServiceRecords.MapToNewDCsCompact())/60 }; // if (cb2sc.ApprovedStartDate.HasValue && cb2sc.ApprovedEndDate.HasValue) // { // decimal lDurationInWeeks = Convert.ToDecimal((cb2sc.ApprovedEndDate.Value - cb2sc.ApprovedStartDate.Value).Days + 1) / 7; // if (cb2sc.ApprovedFLSTotal == null) // { // if (cb2sc.ApprovedFLS.HasValue) // { // res.ApprovedHours = cb2sc.ApprovedFLS.Value * lDurationInWeeks; // } // } // else // { // res.ApprovedHours = cb2sc.ApprovedFLSTotal.Value; // } // } // res.RecordedHours = 0; // if (cb2sc.ServiceRecords != null) // { // foreach (var sr in cb2sc.ServiceRecords) // { // if (sr.ServiceDescription != null && sr.ServiceDescription.ServiceCategory != null && sr.ServiceDescription.ServiceCategory.IsBillable) // { // decimal rd = sr.RoundedDuration; // if (sr.ServiceDescription.ServiceCategory.Percentage != 100) // { // rd = (rd * sr.ServiceDescription.ServiceCategory.Percentage) / 100; // } // res.RecordedHours += rd; // } // } // } // res.RecordedHours /= 60; return res; }).ToList(); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetSupportConceptTreeAllActive() { try { return BuildTree(DAOFactory.GenericDAO.GetAllActiveAndArchived()); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetSupportConceptTreeAllActiveWithCostbearer() { try { return BuildTree(DAOFactory.GenericDAO.GetAllActive().Where(sc => sc.CostBearer2SupportConceptList.Count > 0)); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetSupportConceptTreeAllCurrent() { try { return BuildTree(DAOFactory.SearchDAO.FindCurrentSupportConcepts()); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetSupportConceptTreeByEmployee(long pEmployeeOid) { try { long starttime = DateTime.Now.Ticks; var lResult = new List(); var lEmployee = DAOFactory.GenericDAO.LoadByID(pEmployeeOid); IList persons = DAOFactory.SearchDAO.GetActivePersonsWithType(PersonType.Customer); IEnumerable customers = DAOFactory.SearchDAO.GetAllActiveCustomersWithSupportConceptData(); // int test = customers.Count; // customers = customers.Distinct().ToList(); // test = customers.Count; IList list = lEmployee.Employee2CustomerList; var customerOIDs = new Dictionary(); foreach (Employee2Customer item in list) { if (!customerOIDs.ContainsKey(item.Customer.Oid.Value)) { customerOIDs.Add(item.Customer.Oid.Value, item.Customer.Oid.Value); } } // IList
Addresses = DAOFactory.GenericDAO.GetAll
(); // IList costbearer2supportconcept = DAOFactory.GenericDAO.GetAll(); // IList supportConcepts = DAOFactory.GenericDAO.GetAll(); // IList Organisations = DAOFactory.GenericDAO.GetAll(); // IList Costbearer = DAOFactory.GenericDAO.GetAll(); // IList AbsenceReasons = DAOFactory.GenericDAO.GetAll(); // IList AbsenceTimes = DAOFactory.GenericDAO.GetAll(); // IList Customer2CostBearers = DAOFactory.GenericDAO.GetAll(); // IList CostRatePeriods = DAOFactory.GenericDAO.GetAll(); // IList ServiceRecords = DAOFactory.GenericDAO.GetAll(); // foreach (var iCustomer in lEmployee.Employee2CustomerList // .Where(e2c => (e2c.IsActive == ActivationTypeId.Active || e2c.IsActive == ActivationTypeId.Archived) && (e2c.Customer.IsActive == ActivationTypeId.Active || e2c.Customer.IsActive == ActivationTypeId.Archived)) // .Select(e2c => e2c.Customer).Distinct()) var customerProcessed = new Dictionary(); var supportConceptProcessed = new Dictionary(); foreach (Customer iCustomer in customers) { if (iCustomer.Oid.Value == 53) { int test = 0; } if (!customerProcessed.ContainsKey(iCustomer.Oid.Value)) { var lCustomerNode = new SupportConceptTreeNodeDC { NodeType = iCustomer.Person.Sex == Sex.Male ? NodeType.Customer_Male : NodeType.Customer_Female, Employee = MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(lEmployee), Customer = CreateCustomerForSupportConceptTree(iCustomer) // MapperFactory.CompactCustomerDC_Customer.MapToNewDC(iCustomer) }; if (customerOIDs.ContainsKey(iCustomer.Oid.Value)) { lCustomerNode.IsRelatedToEmployee = true; } lResult.Add(lCustomerNode); foreach (SupportConcept iSupportConcept in iCustomer.SupportConcepts.Where(e2c => (e2c.IsActive == ActivationTypeId.Active || e2c.IsActive == ActivationTypeId.Archived))) { if (!supportConceptProcessed.ContainsKey(iSupportConcept.Oid.Value)) { var lSupportConceptNode = new SupportConceptTreeNodeDC { NodeType = NodeType.SupportConcept, Employee = lCustomerNode.Employee, Customer = lCustomerNode.Customer, SupportConcept = CreateSCForSupportConceptTree(iSupportConcept) // MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDC(iSupportConcept) }; lSupportConceptNode.SupportConcept.Customer = lCustomerNode.Customer; // if (getSupportConceptGoals) // { // lSupportConceptNode.SupportConcept.Goals = MapperFactory.ValueListEntryDC_ValueListEntry.MapToNewDCs( // iSupportConcept.ValueList.FindByType(ValueListEntryType.CustomerCareType).Select(e2o => e2o.Entry)); // } lSupportConceptNode.IsRelatedToEmployee = lCustomerNode.IsRelatedToEmployee; lCustomerNode.ChildNodes.Add(lSupportConceptNode); foreach (CostBearer2SupportConcept iSC2Cb in iSupportConcept.CostBearer2SupportConceptList.Where(e2c => (e2c.IsActive == ActivationTypeId.Active || e2c.IsActive == ActivationTypeId.Archived))) { var lSC2CbNode = new SupportConceptTreeNodeDC { NodeType = NodeType.CostBearer, Employee = lSupportConceptNode.Employee, Customer = lSupportConceptNode.Customer, SupportConcept = lSupportConceptNode.SupportConcept, SupportConceptCostBearerRelDC = CreateSCCostBearerRelForSupportConceptTree(iSC2Cb) // ??? warum nicht mapper? // MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(iSC2Cb) }; lSC2CbNode.SupportConceptCostBearerRelDC.SupportConcept = lSupportConceptNode.SupportConcept; lSC2CbNode.IsRelatedToEmployee = lCustomerNode.IsRelatedToEmployee; if (iSC2Cb.CostBearer.Organisation != null) { lSC2CbNode.CostBearer = MapperFactory.CompactOrganisationDC_Organisation.MapToNewDC(iSC2Cb.CostBearer.Organisation); } lSupportConceptNode.ChildNodes.Add(lSC2CbNode); } supportConceptProcessed.Add(iSupportConcept.Oid.Value, true); } } customerProcessed.Add(iCustomer.Oid.Value, true); } } long endtime = DateTime.Now.Ticks; long diff = endtime - starttime; double secs = diff/(double) 10000000; // 10 Mio Ticks = 1Sec. return lResult; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetSupportConceptTreeInSpan(DateTimeSpan pSpan) { try { return BuildTree(DAOFactory.SearchDAO.FindSupportConceptsInSpan(pSpan)); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public SupportConceptTreeNodeDetailInfoDC GetSupportConceptTreeNodeDetailInfo(long pCustomerOid, long? pSupportConceptOid, long? pCostbearer2SupportConceptOid) { try { var dc = new SupportConceptTreeNodeDetailInfoDC(); var customer = DAOFactory.GenericDAO.LoadByID(pCustomerOid); dc.CustomerAbsenceTimes = MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewDCs(customer.AbsenceTimes); if (pSupportConceptOid != null) { var sc = DAOFactory.GenericDAO.LoadByID(pSupportConceptOid.Value); var list = new List(); list.Add(ValueListEntryType.SupportConceptGoalType); list.Add(ValueListEntryType.SupportConceptGoalCategoryType); list.Add(ValueListEntryType.SupportConceptIndividualGoalCategoryType); list.Add(ValueListEntryType.SupportConceptIndividualGoalType); dc.SupportConceptGoals = MapperFactory.ValueListEntryDC_ValueListEntry.MapToNewDCs( sc.ValueList.FindByTypes(list) .Select(e2o => e2o.Entry) .Where(e => e.IsActive == ActivationTypeId.Active)); dc.ServiceAccountings = MapperFactory.ServiceAccountingDC_ServiceAccounting.MapToNewDCs(sc.ServiceAccountings); } if (pCostbearer2SupportConceptOid != null) { var c2s = DAOFactory.GenericDAO.LoadByID(pCostbearer2SupportConceptOid.Value); dc.ApprovalPeriods = MapperFactory.SupportConceptApprovalPeriodDC_SupportConceptApprovalPeriod.MapToNewDCs(c2s.ApprovalPeriodList); if (dc.ApprovalPeriods != null) { foreach (SupportConceptApprovalPeriodDC item in dc.ApprovalPeriods) { if (!item.StartDate.HasValue) { item.StartDate = c2s.ApprovedStartDate.HasValue ? c2s.ApprovedStartDate : c2s.RequestedStartDate; } if (!item.EndDate.HasValue) { item.EndDate = c2s.ApprovedEndDate.HasValue ? c2s.ApprovedEndDate : c2s.RequestedEndDate; } } } } return dc; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public CompactOrganisationDC FillCostbearerDetails(CompactOrganisationDC dc) { try { if (dc.CostRatePeriods == null || dc.CostRatePeriods.Count == 0) { var org = DAOFactory.GenericDAO.LoadByID(dc.OrganisationOid); if (org != null) { MapperFactory.CompactOrganisationDC_Organisation.MergeWithDC(org, dc); } } return dc; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetUnassignedAccountingTransactions() { try { IEnumerable list = DAOFactory.SearchDAO.FindUnassignedAccountingTransactions(); return MapperFactory.AccountingTransactionDC_AccountingTransaction.MapToNewDCs(list); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetVarFieldDefs(TableID tid) { try { return MapperFactory.VarFieldDC_VarField.VarFieldMapToDCs(DAOFactory.SearchDAO.GetVarFieldDefs(tid), null); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List InsertNewAccountingTransactions(List pAccountingTransactions) { try { foreach (var at in pAccountingTransactions) { if (at.SupportConceptCostBearerRelDC.CostBearer2SupportConceptOid.HasValue && !at.SupportConceptCostBearerRelDC.CostBearer2SupportConceptVersion.HasValue) { var c2s = DAOFactory.GenericDAO.LoadByID(at.SupportConceptCostBearerRelDC.CostBearer2SupportConceptOid.Value); var c2sDc = MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(c2s); at.SupportConceptCostBearerRelDC = c2sDc; } } List lEntities = MapperFactory.AccountingTransactionDC_AccountingTransaction.MapToNewEntities(pAccountingTransactions); DAOFactory.GenericDAO.Insert(lEntities); return lEntities.Select(e => e.Oid.Value).ToList(); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void InsertNewInvoices(List pInvoices) { try { DAOFactory.GenericDAO.Insert(MapperFactory.InvoiceDC_Invoice.MapToNewEntities(pInvoices)); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List InsertNewServiceCategories(List pServiceCategories) { try { List lServiceCategories = MapperFactory.ServiceCategoryDC_ServiceCategory.MapToNewEntities(pServiceCategories); DAOFactory.GenericDAO.Insert(lServiceCategories); return lServiceCategories.Select(sc => sc.Oid.Value).ToList(); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List InsertNewAdditionalServices(IEnumerable pAdditionalServiceDcs) { try { List lAdditionalServices = MapperFactory.AdditionalServiceDC_AdditionalService.MapToNewEntities(pAdditionalServiceDcs); DAOFactory.GenericDAO.Insert(lAdditionalServices); return lAdditionalServices.Select(ads => ads.Oid.Value).ToList(); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List InsertNewServiceDescriptions(List pServiceDescriptions) { try { List lServiceDescriptions = MapperFactory.ServiceDescriptionDC_ServiceDescription.MapToNewEntities(pServiceDescriptions); DAOFactory.GenericDAO.Insert(lServiceDescriptions); IList scToSave = new List(); //Prüfe ob es HPs gibt wo die Leistung hinterlegt werden muss IList newServiceDescriptionOids = new List(); foreach (ServiceDescription newSd in lServiceDescriptions) { newServiceDescriptionOids.Add(newSd.Oid.Value); } foreach (ServiceDescription newSd in lServiceDescriptions) { ServiceCategory cat = newSd.ServiceCategory; IEnumerable descList = DAOFactory.SearchDAO.FindServiceDescriptionForCategory(cat.Oid.Value); IList oids = new List(); foreach (ServiceDescription oldSd in descList) { if (!newServiceDescriptionOids.Contains(oldSd.Oid.Value)) { oids.Add(oldSd.Oid.Value); } } //Prüfe für alle Leistungen dieser Kategorie, ob sie im Hilfeplan angehakt wurden IEnumerable accountingList = DAOFactory.SearchDAO.FindServiceAccountingsForServiceDescriptions(oids); var supportConceptCountDict = new Dictionary(); foreach (ServiceAccounting acc in accountingList) { if (acc.SupportConceptOid.HasValue) { if (supportConceptCountDict.ContainsKey(acc.SupportConceptOid.Value)) { supportConceptCountDict[acc.SupportConceptOid.Value]++; } else { supportConceptCountDict.Add(acc.SupportConceptOid.Value, 1); } } } IList supportConceptToUpdateOids = new List(); foreach (var pair in supportConceptCountDict) { if (pair.Value == oids.Count) { //Wenn es für alle alten Leistungen eine ServiceAccounting gibt, füge die neue Leistung auch hinzu supportConceptToUpdateOids.Add(pair.Key); } } foreach (long scOid in supportConceptToUpdateOids) { var sc = DAOFactory.GenericDAO.LoadByID(scOid); var newSa = new ServiceAccounting(); newSa.ServiceDescription = newSd; sc.ServiceAccountings.Add(newSa); scToSave.Add(sc); } } if (scToSave.Count > 0) { DAOFactory.GenericDAO.Insert(scToSave); } return lServiceDescriptions.Select(sd => sd.Oid.Value).ToList(); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List InsertNewAdditionalServiceRegions(List pAdditionalServiceRegions) { try { List lAdditionalServiceRegions = MapperFactory.AdditionalServiceRegionDC_AdditionalServiceRegion.MapToNewEntities(pAdditionalServiceRegions); DAOFactory.GenericDAO.Insert(lAdditionalServiceRegions); return lAdditionalServiceRegions.Select(asr => asr.Oid.Value).ToList(); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public long InsertNewAdditionalServiceRegion(AdditionalServiceRegionDC pAdditionalServiceRegionDC) { try { AdditionalServiceRegion lAdditionalServiceRegion = MapperFactory.AdditionalServiceRegionDC_AdditionalServiceRegion.MapToNewEntity(pAdditionalServiceRegionDC); DAOFactory.GenericDAO.Insert(lAdditionalServiceRegion); return lAdditionalServiceRegion.Oid.Value; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public AdditionalServiceRegionDC GetAdditionalServiceRegion(long pRegionOid) { try { return MapperFactory.AdditionalServiceRegionDC_AdditionalServiceRegion.MapToNewDC(DAOFactory.GenericDAO.GetByID(pRegionOid)); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public ServiceRecordGroupDC InsertNewServiceRecordGroup(ServiceRecordGroupDC pServiceRecordGroup) { try { ServiceRecordGroup group = MapperFactory.ServiceRecordGroupDC_ServiceRecordGroup.MapToNewEntity(pServiceRecordGroup); var lServiceRecords = new List(); if (pServiceRecordGroup.ServiceRecordList != null && pServiceRecordGroup.ServiceRecordList.Count > 0) { lServiceRecords = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewEntities(pServiceRecordGroup.ServiceRecordList); foreach (ServiceRecord iServiceRecord in lServiceRecords) { iServiceRecord.IP = Utils.GetClientIP(); // iServiceRecord.Group = group; } group.ServiceRecordList = lServiceRecords; } DAOFactory.GenericDAO.Insert(group); if (lServiceRecords.Count > 0) MakeServiceRecordHistoryEntry(lServiceRecords, lServiceRecords.Select(sr => sr.Oid.Value).ToList(), StatementType.Insert); ServiceRecordGroupDC newGroupDC = MapperFactory.ServiceRecordGroupDC_ServiceRecordGroup.MapToNewDC(group); newGroupDC.ServiceRecordList = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(group.ServiceRecordList); return newGroupDC; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeleteAdditionalServiceGroupOfPeopleRelation(long pOid, long pVersion) { try { DeleteAdditionalServiceGroupOfPeopleRelations(new Dictionary {{pOid, pVersion}}); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeleteAdditionalServiceBookings(Dictionary pOid2Version) { try { List lOriginals = DAOFactory.GenericDAO.LoadByIDs(pOid2Version.Select(e => e.Key)); lOriginals.DoForEach(or => MapperFactory.AdditionalServiceBookingDC_AdditionalServiceBooking.ConcurrencyCheck(pOid2Version[or.Oid.Value], or)); List asbListToDelete = lOriginals.ToList(); if (asbListToDelete.Count <= 0) return; DAOFactory.GenericDAO.Delete(asbListToDelete); IList allEntries = DAOFactory.GenericDAO.GetAll(); var entries2Delete = new List(); foreach (AdditionalServiceBooking item in lOriginals) { entries2Delete.AddRange(allEntries.Where(e => pOid2Version.ContainsKey(e.Customer.Oid.Value) && e.Day.Equals(item.Datum.Value) && e.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet)).ToList()); } DAOFactory.GenericDAO.Delete(entries2Delete); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void UpdateAdditionalServiceGroupOfPeopleRelations(List pAdditionalServiceGroupOfPeopleRelations) { try { List lOriginals = DAOFactory.GenericDAO.LoadByIDs(pAdditionalServiceGroupOfPeopleRelations.Select(dc => dc.AdditionalService2GroupOfPeopleOid.Value)); MapperFactory.AdditionalServiceGroupOfPeopleRelationDC_AdditionalService2GroupOfPeople.MergeWithEntitys(pAdditionalServiceGroupOfPeopleRelations, lOriginals); DAOFactory.GenericDAO.Update(lOriginals); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void UpdateAdditionalServiceBookings(List pAdditionalServiceBookings) { try { List lOriginals = DAOFactory.GenericDAO.LoadByIDs(pAdditionalServiceBookings.Select(dc => dc.AdditionalServiceBookingOid.Value)); MapperFactory.AdditionalServiceBookingDC_AdditionalServiceBooking.MergeWithEntitys(pAdditionalServiceBookings, lOriginals); DAOFactory.GenericDAO.Update(lOriginals); var entries2Update = new List(); var entries2Delete = new List(); var newEntries = new List(); IList avList = DAOFactory.GenericDAO.GetAll(); AssessmentSheetValue yes = avList.First(v => !String.IsNullOrEmpty(v.Description) && v.Description.Equals("Ja") && v.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet)); //var no = avList.First(v => !String.IsNullOrEmpty(v.Description) && v.Description.Equals("Nein") && // v.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet)); foreach (AdditionalServiceBooking item in lOriginals) { IEnumerable list = DAOFactory.SearchDAO.GetAdditionalAssessmentSheetEntries(item.Datum.Value); IEnumerable list2 = list.Where(e => !String.IsNullOrEmpty(e.AssessmentSheetCategory.Description) && e.AssessmentSheetCategory.Description.Equals(item.AdditionalServiceRegion.AdditionalService.Name) && item.Customer2AddServiceBookings.Exists(c2a => c2a.CustomerOid == e.Customer.Oid)); entries2Update.AddRange(list2); foreach (Customer2AddServiceBooking c2a in item.Customer2AddServiceBookings) { bool containsEntry = false; foreach (AssessmentSheetEntry entry in entries2Update) { if (entry.Customer.Oid == null) continue; if (entry.Customer.Oid.Value.Equals(c2a.CustomerOid)) { containsEntry = true; if (c2a.Participated) entry.AssessmentSheetValue = yes; else entries2Delete.Add(entry); } } if (c2a.Participated && !containsEntry) { AssessmentSheetCategory cat = DAOFactory.SearchDAO.GetAddServiceAssessmentSheetCategoryWithName( item.AdditionalServiceRegion.AdditionalService.Name); if (cat != null) { newEntries.Add(new AssessmentSheetEntry { Customer = DAOFactory.GenericDAO.GetByID(c2a.CustomerOid), AssessmentSheetCategory = cat, AssessmentSheetValue = yes, SystemEntryID = SystemEntryID.AdditionalServiceAssessmentSheet, Day = item.Datum.Value }); } } } } entries2Update.RemoveRange(entries2Delete); DAOFactory.GenericDAO.Update(entries2Update); DAOFactory.GenericDAO.Delete(entries2Delete); DAOFactory.GenericDAO.Insert(newEntries); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public bool AssessmentSheetEntryBelongsToAddServices(long assessmentSheetCategoryOid) { var lOriginal = DAOFactory.GenericDAO.GetByID(assessmentSheetCategoryOid); IList services = DAOFactory.GenericDAO.GetAll(); 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( pAdditionalServiceGroupOfPeople.AdditionalServiceGroupOfPeopleOid.Value); MapperFactory.AdditionalServiceGroupOfPeopleCD_AdditionalServiceGroupOfPeople.MergeWithEntity( pAdditionalServiceGroupOfPeople, lOriginal); MapperFactory.CompactCustomerDC_Customer.MergeWithEntitys( pAdditionalServiceGroupOfPeople.CustomerList, lOriginal.CustomerList); DAOFactory.GenericDAO.Update(lOriginal); AdditionalServiceGroupOfPeopleDC newGroupDC = MapperFactory.AdditionalServiceGroupOfPeopleCD_AdditionalServiceGroupOfPeople.MapToNewDC( lOriginal); newGroupDC.CustomerList = MapperFactory.CompactCustomerDC_Customer.MapToNewDCs(lOriginal.CustomerList); return newGroupDC; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List InsertNewAdditionalServiceGroupOfPeopleRelations(List pAdditionalServiceGroupOfPeopleRelations) { try { List lAdditionalServiceGroupOfPeopleRelations = MapperFactory.AdditionalServiceGroupOfPeopleRelationDC_AdditionalService2GroupOfPeople. MapToNewEntities(pAdditionalServiceGroupOfPeopleRelations); DAOFactory.GenericDAO.Insert(lAdditionalServiceGroupOfPeopleRelations); return lAdditionalServiceGroupOfPeopleRelations.Select(asgopr => asgopr.Oid.Value).ToList(); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List InsertNewAdditionalServiceGroupsOfPeople(List pGroups) { try { List lGroups = MapperFactory.AdditionalServiceGroupOfPeopleCD_AdditionalServiceGroupOfPeople.MapToNewEntities( pGroups); DAOFactory.GenericDAO.Insert(lGroups); return lGroups.Select(asgop => asgop.Oid.Value).ToList(); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List InsertNewServiceRecords(List pServiceRecords) { return InternalInsertNewServiceRecords(MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewEntities(pServiceRecords)); } public static List InternalInsertNewServiceRecords(IEnumerable lServiceRecords) { try { ServiceRecordGroup group = null; foreach (var iServiceRecord in lServiceRecords) { if (string.IsNullOrEmpty(iServiceRecord.IP)) { iServiceRecord.IP = OperationContext.Current != null ? Utils.GetClientIP() : "::1"; } if (iServiceRecord.InsTs == null) { iServiceRecord.InsTs = DateTime.Now; } if (iServiceRecord.GroupEmployeeCount != null && iServiceRecord.GroupPersonCount != null && (iServiceRecord.GroupEmployeeCount.Value + iServiceRecord.GroupPersonCount.Value > 2)) { if (group == null) { group = new ServiceRecordGroup { CustomerCount = iServiceRecord.GroupPersonCount.Value, EmployeeCount = iServiceRecord.GroupEmployeeCount.Value, RoundedDuration = iServiceRecord.GroupRoundedDuration.Value, StartDate = iServiceRecord.Start, EndDate = iServiceRecord.End }; } iServiceRecord.Group = group; } else { var bsi = PluginLoader.FindClass(); if (bsi != null) { bsi.BeforeSaveServiceRecord(iServiceRecord); } } } DAOFactory.GenericDAO.Insert(lServiceRecords); MakeServiceRecordHistoryEntry(lServiceRecords, lServiceRecords.Select(sr => sr.Oid.Value).ToList(), StatementType.Insert); return lServiceRecords.Select(sr => sr.Oid.Value).ToList(); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List InsertNewAdditionalServiceBookings(List pAdditionalServiceBookings) { try { List lAdditionalServiceBookings = MapperFactory.AdditionalServiceBookingDC_AdditionalServiceBooking.MapToNewEntities(pAdditionalServiceBookings); DAOFactory.GenericDAO.Insert(lAdditionalServiceBookings); foreach (AdditionalServiceBooking booking in lAdditionalServiceBookings) { AttachAddServiceToAssessment(booking); } return lAdditionalServiceBookings.Select(asb => asb.Oid.Value).ToList(); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public bool IsAlive() { return true; } public string PrepareFLSReport(FLSAnalysisDataReportDC pReportDC, string id) { try { string lResult = id + ".xml"; string lDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, MultitenancyOperationContextExt.Current.Tenant + @"\temp"); string lPath = Path.Combine(lDir, lResult); BS.Shared.Core.Utils.XMLSerialize(lPath, pReportDC); return lResult; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public string PrepareSettlementReport(Settlement2DC pSettlementDC) { try { string lResult = Guid.NewGuid() + ".xml"; string lDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, MultitenancyOperationContextExt.Current.Tenant + @"\temp"); string lPath = Path.Combine(lDir, lResult); BS.Shared.Core.Utils.XMLSerialize(lPath, pSettlementDC); return lResult; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void UpdateAccountingTransactions(List pAccountingTransactions) { try { List lOriginals = DAOFactory.GenericDAO.LoadByIDs(pAccountingTransactions.Select(dc => dc.AccountingTransactionOid.Value)); MapperFactory.AccountingTransactionDC_AccountingTransaction.MergeWithEntitys(pAccountingTransactions, lOriginals); DAOFactory.GenericDAO.Update(lOriginals); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void UpdateInvoices(List invoices) { try { List lOriginals = DAOFactory.GenericDAO.LoadByIDs(invoices.Select(dc => dc.InvoiceOid.Value)); MapperFactory.InvoiceDC_Invoice.MergeWithEntitys(invoices, lOriginals); DAOFactory.GenericDAO.Update(lOriginals); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public MandatorDC UpdateMandator(MandatorDC mandator) { try { Mandator lOriginal = GetMandatorEntity(); MapperFactory.MandatorDC_Mandator.MergeWithEntity(mandator, lOriginal); DAOFactory.GenericDAO.Update(lOriginal); return MapperFactory.MandatorDC_Mandator.MapToNewDC(lOriginal); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void UpdateServiceCategories(List pServiceCategories) { try { List lOriginals = DAOFactory.GenericDAO.LoadByIDs(pServiceCategories.Select(sc => sc.ServiceCategoryOid.Value)); MapperFactory.ServiceCategoryDC_ServiceCategory.MergeWithEntitys(pServiceCategories, lOriginals); DAOFactory.GenericDAO.Update(lOriginals); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void UpdateAdditionalServices(List pAdditionalServices) { try { List lOriginals = DAOFactory.GenericDAO.LoadByIDs(pAdditionalServices.Select(sc => sc.AdditionalServiceOid.Value)); MapperFactory.AdditionalServiceDC_AdditionalService.MergeWithEntitys(pAdditionalServices, lOriginals); DAOFactory.GenericDAO.Update(lOriginals); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void UpdateServiceDescriptions(List pServiceDescriptions) { try { List lOriginals = DAOFactory.GenericDAO.LoadByIDs(pServiceDescriptions.Select(sc => sc.ServiceDescriptionOid.Value)); MapperFactory.ServiceDescriptionDC_ServiceDescription.MergeWithEntitys(pServiceDescriptions, lOriginals); DAOFactory.GenericDAO.Update(lOriginals); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void UpdateAdditionalServiceRegions(List pAdditionalServiceRegions) { try { List lOriginals = DAOFactory.GenericDAO.LoadByIDs(pAdditionalServiceRegions.Select(sc => sc.AdditionalServiceRegionOid.Value)); MapperFactory.AdditionalServiceRegionDC_AdditionalServiceRegion.MergeWithEntitys(pAdditionalServiceRegions, lOriginals); DAOFactory.GenericDAO.Update(lOriginals); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public ServiceRecordGroupDC UpdateServiceRecordGroup(ServiceRecordGroupDC pServiceRecordGroup) { try { var lOriginal = DAOFactory.GenericDAO.LoadByID(pServiceRecordGroup.ServiceRecordGroupOid.Value); MapperFactory.ServiceRecordGroupDC_ServiceRecordGroup.MergeWithEntity(pServiceRecordGroup, lOriginal); var lServiceRecords = new List(); // update servicerecords MapperFactory.ServiceRecordDC_ServiceRecord.MergeWithEntitys(pServiceRecordGroup.ServiceRecordList, lOriginal.ServiceRecordList); foreach (ServiceRecord iServiceRecord in lOriginal.ServiceRecordList) { if (String.IsNullOrEmpty(iServiceRecord.IP)) iServiceRecord.IP = Utils.GetClientIP(); iServiceRecord.GroupOid = lOriginal.Oid; lServiceRecords.Add(iServiceRecord); } DAOFactory.GenericDAO.Update(lOriginal); MakeServiceRecordHistoryEntry(lServiceRecords, null, StatementType.Update); ServiceRecordGroupDC newGroupDC = MapperFactory.ServiceRecordGroupDC_ServiceRecordGroup.MapToNewDC(lOriginal); newGroupDC.ServiceRecordList = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(lOriginal.ServiceRecordList); return newGroupDC; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void UpdateServiceRecords(List pServiceRecords) { try { List lOriginals = DAOFactory.GenericDAO.LoadByIDs( pServiceRecords.Select(sr => sr.ServiceRecordOid.Value)); MapperFactory.ServiceRecordDC_ServiceRecord.MergeWithEntitys(pServiceRecords, lOriginals); var si = PluginLoader.FindClass(); if (si != null) { foreach (var serviceRecord in lOriginals) { si.BeforeSaveServiceRecord(serviceRecord); } } DAOFactory.GenericDAO.Update(lOriginals); lOriginals = DAOFactory.GenericDAO.LoadByIDs( pServiceRecords.Select(sr => sr.ServiceRecordOid.Value)); MakeServiceRecordHistoryEntry(lOriginals, null, StatementType.Update); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public bool DoesNotOverlapWithOtherServiceRecord(ServiceRecordDC pServiceRecord, long customerOid, long? employeeOid) { //obsolete return false; //if (pServiceRecord.ServiceDescription.DoNotCheckOverlapping) //{ // return false; //} //var span = new DateTimeSpan //{StartDate = pServiceRecord.Start.Value, EndDate = pServiceRecord.End.Value.AddDays(1).AddTicks(-1)}; //List records = DAOFactory.SearchDAO.FindCustomerServiceRecords(customerOid, span, employeeOid, null).ToList(); //return records.Count <= 0 || records.Where(record => record.CostBearer2SupportConcept.CostBearer.Oid == pServiceRecord.CostBearer.OrganisationOid).Select(record => TimeSpanOverlapsWithOtherTimeSpan(pServiceRecord.Start, record.Start, pServiceRecord.RoundedDuration, record.RoundedDuration)).All(timeCheck => !timeCheck); } public bool OverlapsWithAnotherAdditionalServiceBooking(long additionalServiceRegionOid, List customerOids, DateTime pDatum) { List bookings = DAOFactory.GenericDAO.GetAll().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 GetAllAdditionalServiceGroupOfPeopleRelation() { try { IList as2gop = DAOFactory.GenericDAO.GetAll(); return as2gop.Select(item => MapperFactory.AdditionalServiceGroupOfPeopleRelationDC_AdditionalService2GroupOfPeople.MergeWithDC(item, new AdditionalServiceGroupOfPeopleRelationDC())).ToList(); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetAllAdditionalServiceGroupOfPeople() { try { List result = MapperFactory.AdditionalServiceGroupOfPeopleCD_AdditionalServiceGroupOfPeople.MapToNewDCs( DAOFactory.GenericDAO.GetAll()).ToList(); return result; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetAllAdditionalServiceBookings(long? regionOid, DateTime start, DateTime end) { try { List result = MapperFactory.AdditionalServiceBookingDC_AdditionalServiceBooking.MapToNewDCs( DAOFactory.SearchDAO.GetAdditionalServiceBookings(regionOid, start, end)).ToList(); return result; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public Dictionary> ValidateGroupServiceRecordEntry(ServiceRecordDC pServiceRecord, List groupServiceRecords, List employees, DateTime? date, int maxDaysEditServiceRecordsAllowed, decimal flsTotalRounded, out Dictionary overlappingRecords, out Dictionary overlappingEmployees) { var validator = PluginLoader.FindClass(); return validator.ValidateGroupServiceRecordEntry(pServiceRecord, groupServiceRecords, employees, date, maxDaysEditServiceRecordsAllowed, flsTotalRounded, out overlappingRecords, out overlappingEmployees); } public List ValidateServiceRecordEntry(ServiceRecordDC newServiceRecord, SupportConceptStatisticsDC statistics, int maxDaysEditServiceRecordsAllowed, bool isGroupRecord, IList employeeOids) { return ValidateServiceRecord(newServiceRecord, statistics, maxDaysEditServiceRecordsAllowed, employeeOids, null); } public List ValidateServiceRecord(ServiceRecordDC newServiceRecord, SupportConceptStatisticsDC statistics, int maxDaysEditServiceRecordsAllowed, IList employeeOids, IList cb2scOids) { var validator = PluginLoader.FindClass(); return validator.ValidateServiceRecord(newServiceRecord, statistics, maxDaysEditServiceRecordsAllowed, employeeOids, cb2scOids); } public List ValidateServiceRecordDeletion(ServiceRecordDC serviceRecord, long employeeOid) { var validator = PluginLoader.FindClass(); return validator.ValidateServiceRecordDeletion(serviceRecord, employeeOid); } public List CheckExistingSettlementInvoices(ServiceRecordDC pServiceRecord) { var result = new List(); // 6. SettlementInvoiceAlreadyExisting try { IList allSettlementInvoices = DAOFactory.GenericDAO.GetAll(); foreach (SettlementInvoice rechnung in allSettlementInvoices) { if (rechnung.InvoiceBase.CostBearer2SupportConcept.Oid.HasValue) if (rechnung.InvoiceBase.CostBearer2SupportConcept.Oid.Value.Equals(pServiceRecord.CostBearer2SupportConceptOid.Value) && rechnung.IsActive.Equals(ActivationTypeId.Active)) { result.Add(ServiceRecordValidationResult.SettlementInvoiceAlreadyExisting); break; } } } catch (Exception) { result.Add(ServiceRecordValidationResult.Error); } return result; } public List GetAllAdditionalServiceBookingsForCustomer(long customerOid, DateTime start, DateTime end) { try { ; List result = MapperFactory.AdditionalServiceBookingDC_AdditionalServiceBooking.MapToNewDCs( DAOFactory.SearchDAO.GetAdditionalServiceBookingsForCustomer(customerOid, start, end)); //var result = // MapperFactory.AdditionalServiceBookingDC_AdditionalServiceBooking.MapToNewDCs( // DAOFactory.GenericDAO.GetAll()).ToList().Where(b => b.CustomerOidDict.Any(c => c.Key.Equals(customerOid))).ToList(); return result; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public ServiceRecordDC GetServiceRecordById(long pId) { try { var sr = DAOFactory.GenericDAO.GetByID(pId); if (sr == null) return null; ServiceRecordDC result = MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDC(sr); return result; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetFileAttachmentInfoByType(FileAttachmentType fileAttachmentType) { try { return MapperFactory.FileAttachmentDC_FileAttachmentInfo.MapToNewDCs(DAOFactory.SearchDAO.FindFileAttachmentInfoByType(fileAttachmentType)); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List GetActiveServiceRecordsBySupportConcept(long pSupportConceptOid) { try { return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(DAOFactory.SearchDAO.FindServiceRecordsForSupportConcept(pSupportConceptOid)); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void InsertBeWoMobilBrowserInfo(BeWoMobilBrowserInfoDC browserInfo) { try { BeWoMobilBrowserInfo info = MapperFactory.BeWoMobilBrowserInfoDC_BeWoMobilBrowserInfo.MapToNewEntity(browserInfo); DAOFactory.GenericDAO.Insert(info); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public IList FindServiceRecordsForLastDays(long? costbearer2SupportConceptOid, int days, long? employeeOid) { try { return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(DAOFactory.SearchDAO.FindServiceRecordsForDays(costbearer2SupportConceptOid, days, employeeOid)); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public IEnumerable GetCompactSupportConcepts(long supportConceptOid, long? employeeOid) { try { var list = new List(); list.Add(DAOFactory.GenericDAO.GetByID(supportConceptOid)); List result = CreateFlatSupportConceptCostBearerDCList(list, true, employeeOid); return result; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } private ServiceRecordDC CreateServiceRecordDCCompact(ServiceRecord sr) { var dc = new ServiceRecordDC(); dc.ServiceRecordOid = sr.Oid; dc.ServiceRecordVersion = sr.Version; dc.Start = sr.Start; dc.End = sr.End; dc.Notice = sr.Notice; dc.Notice2 = sr.Notice2; dc.Notice3 = sr.Notice3; dc.Notice4 = sr.Notice4; dc.Notice5 = sr.Notice5; if (sr.ServiceDescription != null) dc.ServiceDescription = MapperFactory.ServiceDescriptionDC_ServiceDescription.MapToNewDC(sr.ServiceDescription); dc.RoundedDuration = sr.RoundedDuration; dc.DistanceInMeter = sr.DistanceInMeter; dc.InsertedOn = sr.InsTs; dc.InsUser = sr.InsUser; dc.DurationInStunden = sr.DurationInStunden; dc.ServiceRecordFormat = sr.ServiceRecordFormat; dc.GroupEmployeeCount = sr.GroupEmployeeCount; dc.GroupPersonCount = sr.GroupPersonCount; dc.GroupRoundedDuration = sr.GroupRoundedDuration; dc.ServiceRecordType = sr.ServiceRecordType ?? ServiceRecordTypeId.DefaultActivity; dc.GroupOid = sr.GroupOid; dc.SignatureOid = sr.SignatureOid; if (sr.Employee != null) { //dc.Employee = MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(sr.Employee); dc.Employee = new CompactEmployeeDC(); dc.Employee.EmployeeOid = sr.Employee.Oid.Value; dc.Employee.EmployeeVersion = sr.Employee.Version.Value; dc.Employee.FirstName = sr.Employee.Person.FirstName; dc.Employee.LastName = sr.Employee.Person.LastName; dc.Employee.PersonnelNumber = sr.Employee.PersonnelNumber; //pDataContract.FLSPerWeek = pEntity.WeeklyFLS; dc.Employee.ActivationType = sr.Employee.IsActive; } //if(sr.DurationInStunden == ZeiterfassungsDauer.Stunden) // dc.RoundedDuration = sr.RoundedDuration /60; //else // dc.RoundedDuration = sr.RoundedDuration; //Goals ------------------------- var list = new List(); list.Add(ValueListEntryType.SupportConceptGoalType); list.Add(ValueListEntryType.SupportConceptGoalCategoryType); list.Add(ValueListEntryType.SupportConceptIndividualGoalCategoryType); list.Add(ValueListEntryType.SupportConceptIndividualGoalType); dc.Goals = MapperFactory.ValueListEntryDC_ValueListEntry.MapToNewDCs( sr.ValueList.FindByTypes(list).Select(e2o => e2o.Entry)); return dc; } private ServiceRecordDC CreateServiceRecordDCIfSupportConceptIsActive(ServiceRecord sr, Customer cust, bool checkArchivedSupportConcepts) { ServiceRecordDC dc = null; if (!checkArchivedSupportConcepts || (sr.SupportConcept != null && sr.SupportConcept.IsActive == ActivationTypeId.Active)) { dc = new ServiceRecordDC(); dc.ServiceRecordOid = sr.Oid; dc.ServiceRecordVersion = sr.Version; dc.Start = sr.Start; dc.End = sr.End; dc.Notice = sr.Notice; dc.Notice2 = sr.Notice2; dc.Notice3 = sr.Notice3; dc.Notice4 = sr.Notice4; dc.Notice5 = sr.Notice5; if (sr.ServiceDescription != null) dc.ServiceDescription = MapperFactory.ServiceDescriptionDC_ServiceDescription.MapToNewDC(sr.ServiceDescription); dc.RoundedDuration = sr.RoundedDuration; dc.InsertedOn = sr.InsTs; dc.InsUser = sr.InsUser; dc.DurationInStunden = sr.DurationInStunden; dc.SignatureOid = sr.SignatureOid; dc.ServiceRecordFormat = sr.ServiceRecordFormat; //Customer ----------------- dc.Customer = new CompactCustomerDC(); dc.Customer.CustomerOid = cust.Oid.Value; dc.Customer.CustomerVersion = cust.Version.Value; dc.Customer.FirstName = cust.Person.FirstName; dc.Customer.LastName = cust.Person.LastName; dc.Customer.Sex = cust.Person.Sex; //dc.Customer.DateOfBirth = cust.Person.DateOfBirth; //dc.Customer.ActivationType = cust.IsActive; //dc.Customer.TerminationDate = cust.TerminationDate; //dc.Customer.EquityContribution = cust.EquityContribution; //pDataContract.AbsenceTimes = MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewDCs(pEntity.AbsenceTimes); //Employee ----------------- if (sr.Employee != null) { //dc.Employee = MapperFactory.CompactEmployeeDC_Employee.MapToNewDC(sr.Employee); dc.Employee = new CompactEmployeeDC(); dc.Employee.EmployeeOid = sr.Employee.Oid.Value; dc.Employee.EmployeeVersion = sr.Employee.Version.Value; dc.Employee.FirstName = sr.Employee.Person.FirstName; dc.Employee.LastName = sr.Employee.Person.LastName; dc.Employee.PersonnelNumber = sr.Employee.PersonnelNumber; //pDataContract.FLSPerWeek = pEntity.WeeklyFLS; dc.Employee.ActivationType = sr.Employee.IsActive; } //SupportConcept ----------------- if (sr.SupportConcept != null) { dc.SupportConcept = new CompactSupportConceptDC(); dc.SupportConcept.SupportConceptOid = sr.SupportConcept.Oid.Value; dc.SupportConcept.SupportConceptVersion = sr.SupportConcept.Version.Value; dc.SupportConcept.Customer = dc.Customer; //pDataContract.Customer = MapperFactory.CompactCustomerDC_Customer.MapToNewDC(pEntity.Customer); dc.SupportConcept.ActivationType = sr.SupportConcept.IsActive; dc.SupportConcept.ConferenceDate = sr.SupportConcept.ConferenceDate; //foreach (var iCBRel in pEntity.CostBearer2SupportConceptList) //{ // CompactCostBearerDC costBearer = new CompactCostBearerDC(); // if (iCBRel.CostBearer.Organisation != null) // { // CompactOrganisationDC orgDC = new CompactOrganisationDC(); // orgDC.Name = iCBRel.CostBearer.Organisation.Name; // orgDC.OrganisationOid = iCBRel.CostBearer.Organisation.Oid.Value; // if (iCBRel.CostBearer.Organisation.Address != null) // { // orgDC.Street = iCBRel.CostBearer.Organisation.Address.Street; // orgDC.PostalCode = iCBRel.CostBearer.Organisation.Address.PostalCode; // orgDC.Town = iCBRel.CostBearer.Organisation.Address.Town; // } // costBearer.Organisation = orgDC; // } // costBearer.CostBearerOid = iCBRel.CostBearer.Oid.Value; // costBearer.CostBearer2SupportConceptOid = iCBRel.Oid.Value; // costBearer.SupportConceptStatus = iCBRel.Status; // costBearer.RequestedStartDate = iCBRel.RequestedStartDate; // costBearer.RequestedEndDate = iCBRel.RequestedEndDate; // costBearer.ApprovedStartDate = iCBRel.ApprovedStartDate; // costBearer.ApprovedEndDate = iCBRel.ApprovedEndDate; // costBearer.ApprovedFLS = iCBRel.ApprovedFLS; // costBearer.ApprovedFLSTotal = iCBRel.ApprovedFLSTotal; // costBearer.CustomerReferenceNumber = iCBRel.CustomerReferenceNumber; // costBearer.IsCalculatingWithFactor = iCBRel.CostBearer.IsCalculatingWithFactor; // pDataContract.CostBearerList.Add(costBearer); // pDataContract.CustomerReferenceNumbers.Add(iCBRel.CustomerReferenceNumber); // pDataContract.CostBearerRelOids.Add(iCBRel.Oid.Value); //} //dc.SupportConcept = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDC(sr.SupportConcept); } //Costbearer ----------------- if (sr.CostBearer2SupportConcept != null) { dc.CostBearer2SupportConceptOid = sr.CostBearer2SupportConcept.Oid.Value; if (dc.SupportConcept != null) { var costBearer = new CompactCostBearerDC(); if (sr.CostBearer2SupportConcept.CostBearer.Organisation != null) { var orgDC = new CompactOrganisationDC(); orgDC.Name = sr.CostBearer2SupportConcept.CostBearer.Organisation.Name; orgDC.OrganisationOid = sr.CostBearer2SupportConcept.CostBearer.Organisation.Oid.Value; orgDC.CostBearerOid = sr.CostBearer2SupportConcept.CostBearer.Oid; dc.CostBearer = orgDC; costBearer.Organisation = orgDC; } costBearer.CostBearerID = sr.CostBearer2SupportConcept.CostBearer.ID; costBearer.CostBearerOid = sr.CostBearer2SupportConcept.CostBearer.Oid.Value; costBearer.CostBearer2SupportConceptOid = sr.CostBearer2SupportConcept.Oid.Value; costBearer.SupportConceptStatus = sr.CostBearer2SupportConcept.Status; costBearer.RequestedStartDate = sr.CostBearer2SupportConcept.RequestedStartDate; costBearer.RequestedEndDate = sr.CostBearer2SupportConcept.RequestedEndDate; costBearer.ApprovedStartDate = sr.CostBearer2SupportConcept.ApprovedStartDate; costBearer.ApprovedEndDate = sr.CostBearer2SupportConcept.ApprovedEndDate; costBearer.CustomerReferenceNumber = sr.CostBearer2SupportConcept.CustomerReferenceNumber; costBearer.IsCalculatingWithFactor = sr.CostBearer2SupportConcept.CostBearer.IsCalculatingWithFactor; dc.SupportConcept.CostBearerList.Add(costBearer); dc.SupportConcept.CustomerReferenceNumbers.Add(sr.CostBearer2SupportConcept.CustomerReferenceNumber); dc.SupportConcept.CostBearerRelOids.Add(sr.CostBearer2SupportConcept.Oid.Value); } if (dc.CostBearer == null) { if (sr.CostBearer2SupportConcept.CostBearer.Organisation != null) dc.CostBearer = MapperFactory.CompactOrganisationDC_Organisation.MapToNewDC(sr.CostBearer2SupportConcept.CostBearer.Organisation); } } //Goals ------------------------- var list = new List(); list.Add(ValueListEntryType.SupportConceptGoalType); list.Add(ValueListEntryType.SupportConceptGoalCategoryType); list.Add(ValueListEntryType.SupportConceptIndividualGoalCategoryType); list.Add(ValueListEntryType.SupportConceptIndividualGoalType); dc.Goals = MapperFactory.ValueListEntryDC_ValueListEntry.MapToNewDCs( sr.ValueList.FindByTypes(list).Select(e2o => e2o.Entry)); dc.GroupEmployeeCount = sr.GroupEmployeeCount; dc.GroupPersonCount = sr.GroupPersonCount; dc.GroupRoundedDuration = sr.GroupRoundedDuration; dc.GroupOid = sr.GroupOid; dc.ServiceRecordType = sr.ServiceRecordType ?? ServiceRecordTypeId.DefaultActivity; } return dc; } private List CreateFolderTree(List folderDCList, List fileDCList, TableID pObjectTid, long pObjectOid, bool templateFolder = false) { Dictionary folderDict = folderDCList.ToDictionary(fo => fo.BeWoFolderOid.Value); Dictionary fileDict = fileDCList.ToDictionary(fi => fi.FileAttachmentOid.Value); var resultList = new List(); var root = new BeWoFolderDC { ObjectTid = pObjectTid, ObjectOid = pObjectOid, Name = "Alle Ordner", SubFolders = new List(), Files = new List() }; if (templateFolder) root = folderDCList.First(f => f.Name.Equals("Vorlagen")); resultList.Add(root); foreach (BeWoFolderDC cfo in folderDCList) { if (root.Equals(cfo)) continue; if (cfo.ParentBeWoFolderOid.HasValue) { if (folderDict.ContainsKey(cfo.ParentBeWoFolderOid.Value)) { BeWoFolderDC parent = folderDict[cfo.ParentBeWoFolderOid.Value]; parent.SubFolders.Add(cfo); } else { root.SubFolders.Add(cfo); } } else { root.SubFolders.Add(cfo); } } foreach (FileAttachmentDC fi in fileDCList) { if (fi.BeWoFolderOid.HasValue) { if (folderDict.ContainsKey(fi.BeWoFolderOid.Value)) { BeWoFolderDC parent = folderDict[fi.BeWoFolderOid.Value]; parent.Files.Add(fi); } else { root.Files.Add(fi); } } else { root.Files.Add(fi); } } return resultList; } public static Dictionary GetSettingsValueDict(string settings) { var dict = new Dictionary(); if (!String.IsNullOrEmpty(settings)) { string[] keyValuePairs = settings.Split(';'); foreach (string pair in keyValuePairs) { string[] keyValuePair = pair.Split('='); if (keyValuePair.Length == 2) { dict.Add(keyValuePair[0], keyValuePair[1]); } } } return dict; } private static String GetContractState() { //#if DEBUG // info.MaxLicenseCount = 9999; // info.PercentFreeEmployee = 100; // info.LicenseInUseCount = DAOFactory.GenericDAO.GetAllActive().Count; // info.EmployeeCount = DAOFactory.GenericDAO.GetAllActive().Count; // info.MaxEmployeeCount = (int)Math.Ceiling(1000000 * ((100 + 100m) / 100)); // return info; //#endif try { string url = ConfigurationManager.AppSettings.Get("ContractStateUrl"); url = url.Replace("[TENANT]", MultitenancyOperationContextExt.Current.Tenant); using (var client = new WebClient()) { //MessageBox.Show(hostAddress); byte[] response = client.DownloadData(url); return Encoding.ASCII.GetString(response); } } catch (Exception) { } return String.Empty; } public static void DeleteAdditionalServiceGroupOfPeopleRelations(Dictionary pOid2Version) { try { List lOriginals = DAOFactory.GenericDAO.LoadByIDs(pOid2Version.Select(e => e.Key)); lOriginals.DoForEach(or => MapperFactory.AdditionalServiceGroupOfPeopleRelationDC_AdditionalService2GroupOfPeople.ConcurrencyCheck(pOid2Version[or.Oid.Value], or)); List srListToDelete = lOriginals.ToList(); if (srListToDelete.Count > 0) DAOFactory.GenericDAO.Delete(srListToDelete); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } private static void AttachAddServiceToAssessment(AdditionalServiceBooking pAdditionalServiceBookingDC) { try { var newCategoryDC = new AssessmentSheetCategoryDC {Description = pAdditionalServiceBookingDC.AdditionalServiceRegion.AdditionalService.Name}; AssessmentSheetCategory lCategory = MapperFactory.AssessmentSheetCategoryDC_AssessmentSheetCategory.MapToNewEntity(newCategoryDC); lCategory.SystemEntryID = SystemEntryID.AdditionalServiceAssessmentSheet; AssessmentSheetCategory cat = DAOFactory.SearchDAO.GetAddServiceAssessmentSheetCategoryWithName(lCategory.Description); if (cat == null) { DAOFactory.GenericDAO.Insert(lCategory); } else { lCategory = cat; } IList values = DAOFactory.GenericDAO.GetAll(); bool yesExists = values.Count( v => v.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet) && v.Description.Equals("Ja")) == 1; bool noExists = values.Count( v => v.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet) && v.Description.Equals("Nein")) == 1; var lYes = new AssessmentSheetValue { Color = "#FF7FFF00", Description = "Ja", Position = 0, Sign = "", SystemEntryID = SystemEntryID.AdditionalServiceAssessmentSheet }; var lNo = new AssessmentSheetValue { Color = "#FFFF0000", Description = "Nein", Position = 0, Sign = "x", SystemEntryID = SystemEntryID.AdditionalServiceAssessmentSheet }; if (!yesExists) { DAOFactory.GenericDAO.Insert(lYes); } else { lYes = values.First( c => c.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet) && c.Description.Equals(lYes.Description)); } if (!noExists) { DAOFactory.GenericDAO.Insert(lNo); } else { lNo = values.First( c => c.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet) && c.Description.Equals(lNo.Description)); } if (!lCategory.PossibleValues.Contains(lYes)) DAOFactory.AdoDAO.ExecuteQuery(string.Format("INSERT INTO assessmentsheetcategory2assessmentsheetvalue(assessmentsheetcategoryoid, assessmentsheetvalueoid) VALUES({0}, {1})", lCategory.Oid.Value, lYes.Oid.Value)); if (!lCategory.PossibleValues.Contains(lNo)) DAOFactory.AdoDAO.ExecuteQuery(string.Format("INSERT INTO assessmentsheetcategory2assessmentsheetvalue(assessmentsheetcategoryoid, assessmentsheetvalueoid) VALUES({0}, {1})", lCategory.Oid.Value, lNo.Oid.Value)); var entryList = new List(); string sqlString = string.Empty; foreach (Customer2AddServiceBooking customerParticipated in pAdditionalServiceBookingDC.Customer2AddServiceBookings) { var customer = DAOFactory.GenericDAO.GetByID(customerParticipated.CustomerOid); entryList.Add(new AssessmentSheetEntry { Customer = customer, AssessmentSheetCategory = lCategory, AssessmentSheetValue = (customerParticipated.Participated ? lYes : lNo), SystemEntryID = SystemEntryID.AdditionalServiceAssessmentSheet, Day = pAdditionalServiceBookingDC.Datum }); IList customer2Category = DAOFactory.GenericDAO.GetAll(); AssessmentSheetCategory f = customer2Category.First( abc => abc.SystemEntryID.Equals(SystemEntryID.AdditionalServiceAssessmentSheet) && abc.Description.Equals(lCategory.Description)); if (f.Customers == null || !f.Customers.Contains(customer)) sqlString += string.Format("INSERT INTO customer2assessmentsheetcategory(customeroid, assessmentsheetoid) VALUES({0}, {1});", customer.Oid.Value, lCategory.Oid.Value); } DAOFactory.GenericDAO.Insert(entryList); DAOFactory.AdoDAO.ExecuteQuery(sqlString); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } private static void MakeServiceRecordHistoryEntry(IEnumerable lOriginals, IEnumerable serviceRecordOidList, StatementType statementType) { var hServiceRecords = new List(); if (statementType.Equals(StatementType.Insert) && serviceRecordOidList != null) { int iterator = 0; foreach (ServiceRecordHistory history in lOriginals.Select(ServiceRecordOriginal => new ServiceRecordHistory { TimeStamp = DateTime.Now, ChangeType = statementType, CostBearer2SupportConcept = ServiceRecordOriginal.CostBearer2SupportConcept, CostBearer2SupportConceptOid = ServiceRecordOriginal.CostBearer2SupportConceptOid, Customer = ServiceRecordOriginal.Customer, CustomerOid = ServiceRecordOriginal.CustomerOid, Employee = ServiceRecordOriginal.Employee, EmployeeOid = ServiceRecordOriginal.EmployeeOid, End = ServiceRecordOriginal.End, Group = ServiceRecordOriginal.Group, GroupEmployeeCount = ServiceRecordOriginal.GroupEmployeeCount, GroupOid = ServiceRecordOriginal.GroupOid, GroupPersonCount = ServiceRecordOriginal.GroupPersonCount, GroupRoundedDuration = ServiceRecordOriginal.GroupRoundedDuration, IP = ServiceRecordOriginal.IP, IsActive = ServiceRecordOriginal.IsActive, Notice = ServiceRecordOriginal.Notice, ServiceRecordOid = serviceRecordOidList.ElementAt(iterator), RoundedDuration = ServiceRecordOriginal.RoundedDuration, ServiceDescription = ServiceRecordOriginal.ServiceDescription, ServiceRecordType = ServiceRecordOriginal.ServiceRecordType, ServiceRecordInsTs = ServiceRecordOriginal.InsTs, ServiceRecordVersion = ServiceRecordOriginal.Version.Value, ServiceRecordInsUser = ServiceRecordOriginal.InsUser, ServiceRecordUdpUser = ServiceRecordOriginal.UdpUser, Start = ServiceRecordOriginal.Start, SupportConcept = ServiceRecordOriginal.SupportConcept, SystemEntryID = ServiceRecordOriginal.SystemEntryID, DistanceInMeter = ServiceRecordOriginal.DistanceInMeter, IsCreatedInMobileClient = ServiceRecordOriginal.IsCreatedInMobileClient })) { iterator++; hServiceRecords.Add(history); } } else { hServiceRecords.AddRange(lOriginals.Select(ServiceRecordOriginal => new ServiceRecordHistory { TimeStamp = DateTime.Now, ChangeType = statementType, CostBearer2SupportConcept = ServiceRecordOriginal.CostBearer2SupportConcept, CostBearer2SupportConceptOid = ServiceRecordOriginal.CostBearer2SupportConceptOid, Customer = ServiceRecordOriginal.Customer, CustomerOid = ServiceRecordOriginal.CustomerOid, Employee = ServiceRecordOriginal.Employee, EmployeeOid = ServiceRecordOriginal.EmployeeOid, End = ServiceRecordOriginal.End, Group = ServiceRecordOriginal.Group, GroupEmployeeCount = ServiceRecordOriginal.GroupEmployeeCount, GroupOid = ServiceRecordOriginal.GroupOid, GroupPersonCount = ServiceRecordOriginal.GroupPersonCount, GroupRoundedDuration = ServiceRecordOriginal.GroupRoundedDuration, IP = ServiceRecordOriginal.IP, IsActive = ServiceRecordOriginal.IsActive, Notice = ServiceRecordOriginal.Notice, ServiceRecordOid = ServiceRecordOriginal.Oid, RoundedDuration = ServiceRecordOriginal.RoundedDuration, ServiceDescription = ServiceRecordOriginal.ServiceDescription, ServiceRecordType = ServiceRecordOriginal.ServiceRecordType, ServiceRecordInsTs = ServiceRecordOriginal.InsTs, ServiceRecordVersion = ServiceRecordOriginal.Version.Value, ServiceRecordInsUser = ServiceRecordOriginal.InsUser, ServiceRecordUdpUser = ServiceRecordOriginal.UdpUser, Start = ServiceRecordOriginal.Start, SupportConcept = ServiceRecordOriginal.SupportConcept, SystemEntryID = ServiceRecordOriginal.SystemEntryID, DistanceInMeter = ServiceRecordOriginal.DistanceInMeter, IsCreatedInMobileClient = ServiceRecordOriginal.IsCreatedInMobileClient })); } DAOFactory.GenericDAO.Insert(hServiceRecords); } public IList GetAllTextbausteine() { try { return MapperFactory.TextbausteinDC_Textbaustein.MapToNewDCs(DAOFactory.GenericDAO.GetAllActive()); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public IList GetTextbausteineByServiceCategory(long pServiceCategoryOid) { try { return MapperFactory.TextbausteinDC_Textbaustein.MapToNewDCs(DAOFactory.SearchDAO.GetActiveTextbausteineByServiceCategory(pServiceCategoryOid)); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public IList InsertNewTextbausteine(IEnumerable pTextbausteine) { try { var lTextbausteine = MapperFactory.TextbausteinDC_Textbaustein.MapToNewEntities(pTextbausteine); DAOFactory.GenericDAO.Insert(lTextbausteine); return lTextbausteine.Select(asb => asb.Oid.Value).ToList(); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void UpdateTextbausteine(List pTextbausteine) { try { var lOriginals = DAOFactory.GenericDAO.LoadByIDs(pTextbausteine.Select(sc => sc.TextbausteinOid.Value)); MapperFactory.TextbausteinDC_Textbaustein.MergeWithEntitys(pTextbausteine, lOriginals); DAOFactory.GenericDAO.Update(lOriginals); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeleteTextbausteine(Dictionary pOid2Version) { try { List lOriginals = DAOFactory.GenericDAO.LoadByIDs(pOid2Version.Select(e => e.Key)); lOriginals.DoForEach(or => MapperFactory.TextbausteinDC_Textbaustein.ConcurrencyCheck(pOid2Version[or.Oid.Value], or)); DAOFactory.GenericDAO.Delete(lOriginals); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public IList FindServiceRecordsInSpan(long pCostBearer2SupportConceptOid, DateTimeSpan period) { try { var records = DAOFactory.SearchDAO.FindServiceRecordsInSpan(pCostBearer2SupportConceptOid, period); return MapperFactory.ServiceRecordDC_ServiceRecord.MapToNewDCs(records); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public SignatureDC InsertSignature(SignatureDC s) { try { var lSignature = MapperFactory.SignatureDC_Signature.MapToNewEntity(s); DAOFactory.GenericDAO.Insert(lSignature); SignatureDC updatedSignatureDC = MapperFactory.SignatureDC_Signature.MapToNewDC(lSignature); if (s.ServiceRecordOid.HasValue) { var sr = DAOFactory.GenericDAO.LoadByID(s.ServiceRecordOid.Value); sr.SignatureOid = lSignature.Oid; DAOFactory.GenericDAO.Update(sr); } return updatedSignatureDC; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public EmployeeAPPCodeDC CreateNewEmployeeAPPCodeDC(long employeeOid) { try { EmployeeAPPCode newCode = new EmployeeAPPCode(); newCode.EmployeeCode = ErzeugeZufallsCode(1); newCode.EmployeeOid = employeeOid; newCode.EmployeeCodeGenDate = DateTime.Now; var x = DAOFactory.SearchDAO.FindAllEmployeeAppCodes(employeeOid); int ischatAktive = 0; string notfallstate = ""; foreach (var item in x) { ischatAktive = item.IsChatAktiv; notfallstate = item.NotfallStatement; break; } var code = x.Last().EmployeeCode; DeletZufallsCode(code); newCode.IsChatAktiv = ischatAktive; newCode.NotfallStatement = notfallstate; DAOFactory.GenericDAO.Insert(newCode); var employeeAPPCodeDC = MapperFactory.EmployeeAPPCodeDC_EmployeeAPPCode.MapToNewDC(newCode); return employeeAPPCodeDC; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void UpdateIsChatActiveEmployeeAPPCodeDC(long employeeOid, int activeType) { try { var employeecode = DAOFactory.SearchDAO.FindAllEmployeeAppCodes(employeeOid); foreach (var items in employeecode) { if (activeType == 1) items.IsChatAktiv = activeType; else items.IsChatAktiv = 0; } DAOFactory.GenericDAO.Update(employeecode); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void UpdateNotfallNacrichtEmployeeAPPCodeDC(long employeeOid, String notfallstate) { try { var employeecode = DAOFactory.SearchDAO.FindAllEmployeeAppCodes(employeeOid); foreach (var items in employeecode) { items.NotfallStatement = notfallstate; } DAOFactory.GenericDAO.Update(employeecode); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public CustomerAPPCodeDC CreateNewCustomerAPPCodeDC(long customerOid) { try { CustomerAPPCode newCode = new CustomerAPPCode(); newCode.CustomerCode = ErzeugeZufallsCode(2); newCode.CustomerOid = customerOid; newCode.CustomerCodeGenDate = DateTime.Now; var x = DAOFactory.SearchDAO.FindAllCustomerAppCodes(customerOid); int ischatAktive = 0; foreach (var item in x) { ischatAktive = item.IsChatAktiv; break; } var code = x.Last().CustomerCode; DeletZufallsCode(code); newCode.IsChatAktiv = ischatAktive; DAOFactory.GenericDAO.Insert(newCode); var customerAPPCodeDC = MapperFactory.CustomerAPPCodeDC_CustomerAPPCode.MapToNewDC(newCode); return customerAPPCodeDC; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public ChatMessageDC CreateNewChatMessagesDC(long senderOid, long empfängerOid, string message, bool isDeliverd, long teamid,string messageid) { try { var chatMessage = new ChatMessage { EmpfaengerPersonOid = empfängerOid, SenderPersonOid = senderOid, Uhrzeit = DateTime.Now, IsDelivered = isDeliverd, ChatText = Encoding.UTF8.GetBytes(message), IstGelesen = 0, MessageId = messageid }; if (teamid != 0) { chatMessage.TeamOid = teamid; } else { chatMessage.TeamOid = null; } DAOFactory.GenericDAO.Insert(chatMessage); var ChatMessagesDC = MapperFactory.ChatMessagesDC_ChatMessages.MapToNewDC(chatMessage); return ChatMessagesDC; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void UpdateIsChatActiveCustomerAPPCodeDC(long customerOid,int activeType) { try { var customercode = DAOFactory.SearchDAO.FindAllCustomerAppCodes(customerOid); foreach (var items in customercode) { if (activeType == 1) { items.IsChatAktiv = activeType; // Erstelle hier ein weiteren Code } else { items.IsChatAktiv = 0; //Lösche hier den aktuellen Code } } DAOFactory.GenericDAO.Update(customercode); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public IList GetIsChatActiveCustomerAPPCodeDC(long customerOid, int activeType) { try { var customercode = DAOFactory.SearchDAO.FindAllCustomerAppCodes(customerOid); var customerAPPCodeDC = MapperFactory.CustomerAPPCodeDC_CustomerAPPCode.MapToNewDCs(customercode); return customerAPPCodeDC; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeletZufallsCode(string code) { try { using (WebClient client = new WebClient()) { var x = client.DownloadData("https://bewoplaner.beyondsoft.de/appvoucher.php?Action=DELETE&Voucher="+code+"&ajfho374873hfklasjf9012z44ublfkhao894zuu2ebmsadvuw48=tzrghvcjgr8t975gjliuoe8s89zdsgjb32h3qae7t"); } } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public string ErzeugeZufallsCode(int appType) { String[] resultArray; using (WebClient client = new WebClient()) { byte[] response = client.DownloadData("https://bewoplaner.beyondsoft.de/appvoucher.php?k=1234567890&Action=CREATE&AppType=" + appType + "&ajfho374873hfklasjf9012z44ublfkhao894zuu2ebmsadvuw48=tzrghvcjgr8t975gjliuoe8s89zdsgjb32h3qae7t"); String result = System.Text.Encoding.ASCII.GetString(response); resultArray = result.Split(';'); } /* int lenght = 12; const string chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789"; var random = new Random(); String Code = new string(Enumerable.Repeat(chars, lenght) .Select(s => s[random.Next(s.Length)]).ToArray()); */ if (resultArray[0].Equals("TRUE")) { return resultArray[1]; } else { return ""; } } public List FindUnreadChatMessagesForRecipient(long personOid) { try { var chatMessage = DAOFactory.SearchDAO.FindUnreadChatMessagesForRecipient(personOid); var ChatMessagesDC = MapperFactory.ChatMessagesDC_ChatMessages.MapToNewDCs(chatMessage); return ChatMessagesDC; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public long InsertNewServiceRecordAndSignature(ServiceRecordDC sr, SignatureDC sig) { try { var dcList = new List(); dcList.Add(sr); var oidList = InsertNewServiceRecords(dcList); var serviceRecordOid = oidList[0]; if (!String.IsNullOrEmpty(sig.DataBild)) { var lSignature = MapperFactory.SignatureDC_Signature.MapToNewEntity(sig); // lSignature.ServiceRecordOid = serviceRecordOid; DAOFactory.GenericDAO.Insert(lSignature); } return serviceRecordOid; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List LoadOrganisationPersonRelationsByOid(IEnumerable pOids) { try { var customerPersonRels = DAOFactory.GenericDAO.LoadByIDs(pOids); return MapperFactory.OrganisationPersonRelDC_Organisation2PersonMapper.MapToNewDCs(customerPersonRels); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public List LoadBargeldkassenForObject(TableID objectTid, long objectOid) { try { var bargeldkassen = DAOFactory.SearchDAO.FindBargeldkasse(objectTid, objectOid); return MapperFactory.BargeldkassenDCBargeldkasseDC_BargeldkassenDCBargeldkasse.MapToNewDCs(bargeldkassen); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public long InsertNewBargeldkasse(BargeldkassenDC pBargeldkasse) { try { var lBargeldkasse = MapperFactory.BargeldkassenDCBargeldkasseDC_BargeldkassenDCBargeldkasse.MapToNewEntity(pBargeldkasse); DAOFactory.GenericDAO.Insert(lBargeldkasse); return lBargeldkasse.Oid.Value; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public BargeldkassenDC UpdateBargeldkasse(BargeldkassenDC pBargeldkasse) { try { var lOriginal = DAOFactory.GenericDAO.LoadByID(pBargeldkasse.BargeldkassenOid.Value); MapperFactory.BargeldkassenDCBargeldkasseDC_BargeldkassenDCBargeldkasse.MergeWithEntity(pBargeldkasse, lOriginal); DAOFactory.GenericDAO.Update(lOriginal); return MapperFactory.BargeldkassenDCBargeldkasseDC_BargeldkassenDCBargeldkasse.MapToNewDC(lOriginal); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeactivateBargeldkasse(long pOid, long pVersion) { try { ServiceLogic.SetActivationType(new Dictionary{{pOid, pVersion}}, ActivationTypeId.Deleted); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } //####################### Schulbegleitender Dienst ############################################## public void DeletAbsenceTime(long absenceoid) { try { var x = DAOFactory.GenericDAO.GetByID(absenceoid); DAOFactory.GenericDAO.Delete(x); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeactivateAbsenceTime( Dictionary pOid2Version) { try { ServiceLogic.SetActivationType(pOid2Version, ActivationTypeId.Deleted); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public ListGetAllVertretungen() { try { var x = DAOFactory.GenericDAO.GetAllActive(); return MapperFactory.VertretungDC_Vertretung.MapToNewDCs(x); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void InsertNewMitarbeiterVertretung(VertretungDC vertretungM, long? absenceReasonOid, DateTime krankheitsMeldung) { try { //################# AbsenceTime ########################### AbsenceTimeDC abstm = new AbsenceTimeDC(); abstm.Start = vertretungM.VertretungsZeitraumVon; abstm.End = vertretungM.VertretungsZeitraumBis; abstm.EmployeeOid = vertretungM.EmployeeOid; abstm.KrankheitsMeldung = krankheitsMeldung; var x = DAOFactory.GenericDAO.GetByID(absenceReasonOid.Value); abstm.Reason = MapperFactory.AbsenceReasonDC_AbsenceReason.MapToNewDC(x); var lAbsenceTime = MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewEntity(abstm); DAOFactory.GenericDAO.Insert(lAbsenceTime); vertretungM.AbsenceTimeOid = lAbsenceTime.Oid; //######################################################### var lVertretung = MapperFactory.VertretungDC_Vertretung.MapToNewEntity(vertretungM); DAOFactory.GenericDAO.Insert(lVertretung); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void InsertNewKlientenVertretung(VertretungDC vertretungK, long? absenceReasonOid,DateTime krankheitsMeldung) { try { //################# AbsenceTime ########################### AbsenceTimeDC abstm = new AbsenceTimeDC(); abstm.Start = vertretungK.VertretungsZeitraumVon; abstm.End = vertretungK.VertretungsZeitraumBis; abstm.CustomerOid = vertretungK.CustomerOid; abstm.KrankheitsMeldung = krankheitsMeldung; var x = DAOFactory.GenericDAO.GetByID(absenceReasonOid.Value); abstm.Reason = MapperFactory.AbsenceReasonDC_AbsenceReason.MapToNewDC(x); var lAbsenceTime = MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewEntity(abstm); DAOFactory.GenericDAO.Insert(lAbsenceTime); vertretungK.AbsenceTimeOid = lAbsenceTime.Oid; //######################################################### var lVertretung = MapperFactory.VertretungDC_Vertretung.MapToNewEntity(vertretungK); DAOFactory.GenericDAO.Insert(lVertretung); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void DeleteVertretung(long vert) { try { var origVertretung = DAOFactory.GenericDAO.LoadByID(vert); DAOFactory.GenericDAO.Delete(origVertretung); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } public void UpdateVertretung(VertretungDC vert, AbsenceReasonDC absenceReason) { try { //update auch die dazugehörige AbsenceTime var origVertretung = DAOFactory.GenericDAO.LoadByID(vert.VertretungOid.Value); MapperFactory.VertretungDC_Vertretung.MergeWithEntity(vert, origVertretung); DAOFactory.GenericDAO.Update(origVertretung); //Upadate AbsenceTime var origAbsenceTime = DAOFactory.GenericDAO.LoadByID(vert.AbsenceTimeOid.Value); //AbsenceReason abs = new AbsenceReason(); //abs.Oid = absenceReason.AbsenceReasonOid; //abs.Description = absenceReason.Description; //abs.BillableMinutes = absenceReason.BillableMinutes; //abs.Color = absenceReason.Color; //MapperFactory.AbsenceReasonDC_AbsenceReason.MergeWithEntity(absenceReason,abs); var abs = DAOFactory.GenericDAO.LoadByID(absenceReason.AbsenceReasonOid.Value); origAbsenceTime.AbsenceReason = abs; DAOFactory.GenericDAO.Update(origAbsenceTime); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } //verbesserungswürdig public VertretungDC CreateVertretung(long mitarbeiterOid, long klientenOid,long vertretenderMitarbeiterOid,long absencetimeOid,string notiz, DateTime vertretungszeitraumVon, DateTime vertretungszeitraumBis) { try { VertretungDC ahh = new VertretungDC() { EmployeeOid = mitarbeiterOid, CustomerOid = klientenOid, VertretenderMitarbeiterOid = vertretenderMitarbeiterOid, Notice = notiz, VertretungsZeitraumVon = vertretungszeitraumVon, VertretungsZeitraumBis = vertretungszeitraumBis, AbsenceTimeOid = absencetimeOid }; var x = MapperFactory.VertretungDC_Vertretung.MapToNewEntity(ahh); DAOFactory.GenericDAO.Insert(x); return ahh; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } //Fertig public VertretungsListeDC VertretungsListe(DateTime absenceTime) { try { var x = DAOFactory.SearchDAO.VertretungListe(absenceTime); var schulbegleitenderDienst = MapperFactory.VertretungsListeDC_VertretungsListe.MapToNewDC(x); Dictionary> Employee2CustomerHaupt = new Dictionary>(); foreach (var xa in schulbegleitenderDienst.Employeesliste) { List klientoids = new List(); Employee e = DAOFactory.GenericDAO.LoadByID(xa.EmployeeOid); foreach (var e2c in e.Employee2CustomerList) { foreach (var v2o in e2c.ValueList) { if (v2o.Entry.Type == ValueListEntryType.StaffRoleType && v2o.Entry.SystemEntryID.HasValue && v2o.Entry.SystemEntryID.Value == SystemEntryID.EmployeeRoleMainAttendant) { klientoids.Add(e2c.CustomerOid.Value); } } } if (!Employee2CustomerHaupt.ContainsKey(xa.EmployeeOid)) Employee2CustomerHaupt.Add(xa.EmployeeOid,klientoids); } schulbegleitenderDienst.Employee2CustomerHauptbetreuung = Employee2CustomerHaupt; return schulbegleitenderDienst; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } //################################################################# public ArbeitszeitListeDC GetAlleArbeitszeiten(long employeeOid) { try { var x = DAOFactory.SearchDAO.FindEmployeeArbeitszeitListe(employeeOid); var aff = MapperFactory.ArbeitszeitListeDC_ArbeitszeitListe.MapToNewDC(x); return aff; } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } #endregion #endregion #region Methods public string PrepareAuslastungReport(AuslastungAnalysisRootDC pReport, string id) { try { string lResult = id + ".xml"; string lDir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, MultitenancyOperationContextExt.Current.Tenant + @"\temp"); string lPath = Path.Combine(lDir, lResult); BS.Shared.Core.Utils.XMLSerialize(lPath, pReport); return lResult; } catch (Exception e) { throw (Utils.CreateBeWoFaultException(e)); } } public ServiceRecordStatisticsInfoDC GetServiceRecordStatisticInfo(long costBearer2SupportConceptOid, DateTime statisticsDate) { var factory = PluginLoader.FindClass(); if (factory != null) { return factory.GetServiceRecordStatisticInfo(costBearer2SupportConceptOid, statisticsDate); } return null; } public SupportConceptStatisticsDC CreateSupportConceptStatistics(long costBearer2SupportConceptOid, DateTime statisticsDate) { var factory = PluginLoader.FindClass(); if (factory == null) { factory = new ServiceRecordStatisticFactory(); } return factory.CreateSupportConceptStatistics(costBearer2SupportConceptOid, statisticsDate); } public void ResetTenant(String tenant) { WCFHibernateSessionManager.ResetSessionFactory(tenant); } public void ResetAllTenants() { WCFHibernateSessionManager.ResetAllSessionFactories(); } public String GetLicenseOrderUrl() { string url = ConfigurationManager.AppSettings.Get("LicenseOrderUrl"); url = url.Replace("[TENANT]", MultitenancyOperationContextExt.Current.Tenant); return url; } public LicenseInfoDC GetLicenseInfo() { return SecurityUtils.GetLicenseInfo(); } public GroupDurationDC CalculateGroupDuration(int personCount, int employeeCount, decimal totalDuration) { var calc = PluginLoader.FindClass(); if (calc != null) { return calc.CalculateGroupDuration(personCount, employeeCount, totalDuration); } return null; } public GroupDurationDC CalculateGroupDuration2(int personCount, int employeeCount, decimal totalDuration, long[] costBearer2SupportConceptArray) { var calc = PluginLoader.FindClass(); if (calc != null) { return calc.CalculateGroupDuration(personCount, employeeCount, totalDuration, costBearer2SupportConceptArray); } return null; } public IList GetUiElements(UiElementType? uiType, long? employeeOid, long? teamOid, long[] oidArray) { var factory = PluginLoader.FindClass(); if (factory == null) { factory = new UiElementFactory(); } return factory.GetUiElements(uiType, employeeOid, teamOid); } private static List BuildTree(IEnumerable pSupportConcepts) { var lResult = new List(); foreach (SupportConcept iSC in pSupportConcepts) { var lScNode = new SupportConceptTreeNodeDC { NodeType = NodeType.SupportConcept, SupportConcept = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDC(iSC), }; lScNode.Description = String.Format("{0}, {1}", iSC.Customer.Person.LastName, iSC.Customer.Person.FirstName); foreach (CostBearer2SupportConcept iSC2Cb in iSC.CostBearer2SupportConceptList) { var tnode = new SupportConceptTreeNodeDC(); tnode.NodeType = NodeType.SupportConceptCostBearerRelDC; tnode.SupportConcept = lScNode.SupportConcept; tnode.SupportConceptCostBearerRelDC = MapperFactory.SupportConceptCostBearerRelDC_CostBearer2SupportConcept.MapToNewDC(iSC2Cb); if (iSC2Cb.CostBearer.Organisation != null) { tnode.Description = iSC2Cb.CostBearer.Organisation.Name; } lScNode.ChildNodes.Add(tnode); } lResult.Add(lScNode); } return lResult.OrderBy(s => s.Description).ToList(); } private static CompactCustomerDC CreateCustomerForSupportConceptTree(Customer pEntity) { var dc = new CompactCustomerDC(); dc.CustomerOid = pEntity.Oid.Value; dc.CustomerVersion = pEntity.Version.Value; dc.FirstName = pEntity.Person.FirstName; dc.LastName = pEntity.Person.LastName; dc.DateOfBirth = pEntity.Person.DateOfBirth; dc.ActivationType = pEntity.IsActive; dc.TerminationDate = pEntity.TerminationDate; dc.Sex = pEntity.Person.Sex; return dc; } private List CreateFlatSupportConceptCostBearerDCList(IEnumerable pEntityList, bool onlyWithAssignedCostbearer, long? employeeOid) { var list = new List(); var customerOIDs = new Dictionary(); if (employeeOid.HasValue) { var lEmployee = DAOFactory.GenericDAO.LoadByID(employeeOid.Value); IList e2cList = lEmployee.Employee2CustomerList; foreach (Employee2Customer item in e2cList) { if (!customerOIDs.ContainsKey(item.Customer.Oid.Value)) { customerOIDs.Add(item.Customer.Oid.Value, item.Customer.Oid.Value); } } } //var t = new List(); var c2sOids = new Dictionary(); foreach (SupportConcept sc in pEntityList) { if (sc.CostBearer2SupportConceptList != null && sc.CostBearer2SupportConceptList.Count > 0) { foreach (CostBearer2SupportConcept cb2sc in sc.CostBearer2SupportConceptList) { //t.Add(cb2sc.Oid.Value); if (!c2sOids.ContainsKey(cb2sc.Oid.Value)) { CompactSupportConceptDC dc = CreateFlatSupportConcept(sc, cb2sc); if (customerOIDs.ContainsKey(sc.Customer.Oid.Value)) { dc.IsRelatedToEmployee = true; dc.Customer.IsRelatedToEmployee = true; } list.Add(dc); c2sOids.Add(cb2sc.Oid.Value, true); } } } else { if (!onlyWithAssignedCostbearer) { list.Add(MapperFactory.CompactSupportConceptDC_SupportConcept.MergeWithDC(sc, new CompactSupportConceptDC())); } } } return list; } public static CompactSupportConceptDC CreateFlatSupportConcept(SupportConcept sc, CostBearer2SupportConcept cb2sc) { var dc = new CompactSupportConceptDC(); dc.SupportConceptOid = sc.Oid.Value; dc.SupportConceptVersion = sc.Version.Value; dc.Customer = CreateCustomerForSupportConceptTree(sc.Customer); dc.ActivationType = sc.IsActive; dc.ConferenceDate = sc.ConferenceDate; dc.IsApproved = cb2sc.Status == CostBearer2SupportConceptStatus.Approved; var costBearer = new CompactCostBearerDC(); if (cb2sc.CostBearer.Organisation != null) { costBearer.Organisation = MapperFactory.CompactOrganisationDC_Organisation.MapToNewDC(cb2sc.CostBearer.Organisation); } 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.Bezeichnung = cb2sc.AuswahlBezeichnung; // costBearer.ApprovedFLS = cb2sc.ApprovedFLS; // costBearer.ApprovedFLSTotal = cb2sc.ApprovedFLSTotal; costBearer.CustomerReferenceNumber = cb2sc.CustomerReferenceNumber; costBearer.IsCalculatingWithFactor = cb2sc.CostBearer.IsCalculatingWithFactor; dc.CostBearerList.Add(costBearer); dc.CustomerReferenceNumbers.Add(cb2sc.CustomerReferenceNumber); dc.CostBearerRelOids.Add(cb2sc.Oid.Value); dc.CostBearerOids2CostBearerRelOids.Add(costBearer.CostBearerOid, cb2sc.Oid.Value); return dc; } private static SupportConceptCostBearerRelDC CreateSCCostBearerRelForSupportConceptTree(CostBearer2SupportConcept pEntity) { var dc = new SupportConceptCostBearerRelDC(); // dc.ApprovedFLS = pEntity.ApprovedFLS; // dc.ApprovedFLSTotal = pEntity.ApprovedFLSTotal; dc.CostBearer2SupportConceptOid = pEntity.Oid; dc.CostBearer2SupportConceptVersion = pEntity.Version; dc.Notice = pEntity.Notice; dc.Status = pEntity.Status; dc.RequestedStartDate = pEntity.RequestedStartDate; dc.RequestedEndDate = pEntity.RequestedEndDate; dc.ApprovedStartDate = pEntity.ApprovedStartDate; dc.ApprovedEndDate = pEntity.ApprovedEndDate; dc.CustomerReferenceNumber = pEntity.CustomerReferenceNumber; dc.MonthlyPayment = pEntity.MonthlyPayment; // dc.NoRelationExists = pEntity.ServiceRecords.Count == 0; if (pEntity.CostBearer.Organisation != null) { dc.CostBearer = MapperFactory.CompactOrganisationDC_Organisation.MapToNewDC(pEntity.CostBearer.Organisation); } // pDataContract.SupportConcept = MapperFactory.CompactSupportConceptDC_SupportConcept.MapToNewDC(pEntity.SupportConcept); return dc; } private static CompactSupportConceptDC CreateSCForSupportConceptTree(SupportConcept pEntity) { var dc = new CompactSupportConceptDC(); dc.SupportConceptOid = pEntity.Oid.Value; dc.SupportConceptVersion = pEntity.Version.Value; // dc.Customer = MapperFactory.CompactCustomerDC_Customer.MapToNewDC(pEntity.Customer); dc.ActivationType = pEntity.IsActive; dc.ConferenceDate = pEntity.ConferenceDate; // foreach (var iCBRel in pEntity.CostBearer2SupportConceptList) // { // CompactCostBearerDC costBearer = new CompactCostBearerDC(); // if (iCBRel.CostBearer.Organisation != null) // costBearer.OrganisationName = iCBRel.CostBearer.Organisation.Name; // 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.CustomerReferenceNumber = iCBRel.CustomerReferenceNumber; // pDataContract.CostBearerList.Add(costBearer); // pDataContract.CustomerReferenceNumbers.Add(iCBRel.CustomerReferenceNumber); // pDataContract.CostBearerRelOids.Add(iCBRel.Oid.Value); // } return dc; } public void CreateNewPerson2OrganisationRelation(long organi, ValueListEntryDC value, long personOid, string mail, string fax, string tele, string notice) { try { List continuiti = new List(); continuiti.Add(new Contact() {Type = ContactType.business_Fax, Value = fax }); continuiti.Add(new Contact() { Type = ContactType.business_Mail, Value = mail }); continuiti.Add(new Contact() { Type = ContactType.business_Phone, Value = tele }); var x = new Organisation2Person() { Organisation = DAOFactory.GenericDAO.LoadByID(organi), Notice = notice, RolleInOrganisation = DAOFactory.GenericDAO.LoadByID(value.ValueListEntryOid.Value), Person = DAOFactory.GenericDAO.LoadByID(personOid), Contacts = continuiti }; DAOFactory.GenericDAO.Insert(x); } catch (Exception e) { throw Utils.CreateBeWoFaultException(e); } } #endregion } }