commitaf28476b76Merge:b76e16946c3b6a1e9cAuthor: Marcel Hirschle <marcel.hirschle@ownsoft.de> Date: Thu Jun 20 11:53:31 2024 +0200 Merge branch 'master' of ssh://float.ownsoft.de/git/beyondSoft/BeWo # Conflicts: # ReportImp/VkmHamm/CustomerMitarbeiterstundenkontoBerechnung.cs commitb76e169462Author: Marcel Hirschle <marcel.hirschle@ownsoft.de> Date: Thu Jun 20 11:40:08 2024 +0200 MH: vkm hamm stundenkonto commitc3b6a1e9c0Author: Christian <christian.baeurle@beyondsoft.de> Date: Thu Jun 20 10:58:05 2024 +0200 Mergemarker entfernt commit5ff8fe343bMerge:c1aa61f05fc57725f4Author: Christian <christian.baeurle@beyondsoft.de> Date: Thu Jun 20 10:52:16 2024 +0200 Merge branch 'master' of ssh://float.beyondsoft.de/git/beyondSoft/BeWo commitc1aa61f058Merge:12faccb711c0a94c60Author: Christian <christian.baeurle@beyondsoft.de> Date: Thu Jun 20 10:51:59 2024 +0200 Merge branch 'master' of ssh://float.beyondsoft.de/git/beyondSoft/BeWo # Conflicts: # BeWo/ServiceProxy/Generated.cs # Data/Security/UserRightHelper.cs # Shared/BeWoEntityEnums.cs # Shared/Core/EnumTranslations.cs commit12faccb71bAuthor: Christian <christian.baeurle@beyondsoft.de> Date: Wed Jun 19 16:13:56 2024 +0200 Perseh Hilfeplan Import + KI Prototyp,
291 lines
10 KiB
C#
291 lines
10 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Configuration;
|
|
using System.Linq;
|
|
using System.ServiceModel;
|
|
using System.Text;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Service.Core;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.Import.Perseh;
|
|
using BeWo.Service.MessageContracts;
|
|
using BeWo.Service.Plugins;
|
|
using BeWo.Service.ServiceContracts;
|
|
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using Utils = BeWo.Service.Core.Utils;
|
|
|
|
namespace BeWo.Service.ServiceImplementations
|
|
{
|
|
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
|
|
public class StreamingServiceImp : IStreamingService
|
|
{
|
|
public void DeactivateBeWoFolders(List<BeWoFolderDC> dcs)
|
|
{
|
|
try
|
|
{
|
|
ServiceLogic.SetActivationType<BeWoFolder>(dcs.ToDictionary(i => i.BeWoFolderOid.Value, i => i.BeWoFolderVersion.Value), ActivationTypeId.Deleted);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<BeWoFolderDC> GetAllBeWoFolders()
|
|
{
|
|
try
|
|
{
|
|
return MapperFactory.BeWoFolderDC_BeWoFolder.MapToNewDCs(DAOFactory.GenericDAO.GetAllActive<BeWoFolder>());
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public List<long> InsertNewBeWoFolders(List<BeWoFolderDC> dcs)
|
|
{
|
|
try
|
|
{
|
|
var newBeWoFolders = MapperFactory.BeWoFolderDC_BeWoFolder.MapToNewEntities(dcs);
|
|
DAOFactory.GenericDAO.Insert(newBeWoFolders);
|
|
return newBeWoFolders.Select(i => i.Oid.Value).ToList();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public void UpdateBeWoFolders(List<BeWoFolderDC> dcs)
|
|
{
|
|
try
|
|
{
|
|
var originals = DAOFactory.GenericDAO.LoadByIDs<BeWoFolder>(dcs.Select(i => i.BeWoFolderOid.Value));
|
|
MapperFactory.BeWoFolderDC_BeWoFolder.MergeWithEntitys(dcs, originals);
|
|
DAOFactory.GenericDAO.Update(originals);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public UploadResult UploadDocument(UploadPackage pUpload)
|
|
{
|
|
PluginLoader.FindClass<IpAddressChecker>().CheckIpAddress();
|
|
|
|
var entityData = BS.Shared.Core.Utils.ReadFully(pUpload.Stream);
|
|
|
|
var lEntity = new FileAttachment
|
|
{
|
|
IsLocked = false,
|
|
Path = pUpload.FileName,
|
|
Notice = pUpload.Notice,
|
|
ObjectTid = (TableID)pUpload.TableID,
|
|
ObjectOid = pUpload.ObjectOid,
|
|
BeWoFolderOid = pUpload.BeWoFolderOid,
|
|
Type = (FileAttachmentType)pUpload.FileAttachmentTypeId
|
|
};
|
|
|
|
pUpload.Stream.Close();
|
|
pUpload.Stream.Dispose();
|
|
|
|
long maxSize = 20 * 1024 * 1024;
|
|
|
|
var maxSizeConfig = ConfigurationManager.AppSettings.Get("MaxDocumentSize");
|
|
if (!string.IsNullOrEmpty(maxSizeConfig))
|
|
{
|
|
var s = 0L;
|
|
if (long.TryParse(maxSizeConfig, out s))
|
|
{
|
|
maxSize = s;
|
|
}
|
|
}
|
|
|
|
if (entityData != null && entityData.Length > 0)
|
|
{
|
|
if (entityData.Length > maxSize)
|
|
{
|
|
throw new FaultException<BeWoFault>(new BeWoFault(
|
|
$"Fehler beim Speichern des Dokuments. Das Dokument überschreitet die maximale erlaubte Größe.\nDie maximale Größe liegt bei {maxSize / (1024 * 1024):0.##} MB", BeWoFaultType.Unknown));
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Insert(lEntity);
|
|
|
|
FileAttachmentUtils.SaveFileToFileDirectory(lEntity, entityData);
|
|
}
|
|
else
|
|
{
|
|
throw new FaultException<BeWoFault>(new BeWoFault("Fehler beim Speichern des Dokuments. Das Dokument enthält keine Daten.", BeWoFaultType.Unknown));
|
|
}
|
|
|
|
try
|
|
{
|
|
var a = MapperFactory.FileAttachmentDC_FileAttachmentInfo.MapToNewDC(DAOFactory.GenericDAO.LoadByID<FileAttachmentInfo>(lEntity.Oid.Value));
|
|
|
|
return new UploadResult { Attachment = a };
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
|
|
}
|
|
|
|
public UploadResult UpdateDocument(UpdatePackage pUpload)
|
|
{
|
|
try
|
|
{
|
|
PluginLoader.FindClass<IpAddressChecker>().CheckIpAddress();
|
|
|
|
var pFileId = pUpload.FileOid;
|
|
|
|
var original = DAOFactory.GenericDAO.GetByID<FileAttachment>(pFileId);
|
|
|
|
original.IsLocked = false;
|
|
original.Path = pUpload.FileName;
|
|
original.Notice = pUpload.Notice;
|
|
original.ObjectTid = (TableID) pUpload.TableID;
|
|
original.ObjectOid = pUpload.ObjectOid;
|
|
original.BeWoFolderOid = pUpload.BeWoFolderOid;
|
|
original.Data = BS.Shared.Core.Utils.ReadFully(pUpload.Stream);
|
|
original.Type = (FileAttachmentType) pUpload.FileAttachmentTypeId;
|
|
|
|
pUpload.Stream.Close();
|
|
pUpload.Stream.Dispose();
|
|
|
|
if (original.Data != null && original.Data.Length > 0)
|
|
{
|
|
FileAttachmentUtils.SaveFileToFileDirectory(original);
|
|
}
|
|
else
|
|
{
|
|
throw new FaultException<BeWoFault>(new BeWoFault("Fehler beim Speichern des Dokuments. Das Dokument enthält keine Daten.", BeWoFaultType.Unknown));
|
|
}
|
|
|
|
return new UploadResult { Attachment = MapperFactory.FileAttachmentDC_FileAttachment.MapToNewDC(original) };
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
|
|
public UploadImportFileResult UploadImportFile(UploadPackage upload)
|
|
{
|
|
try
|
|
{
|
|
var filename = upload.FileName;
|
|
var daten = BS.Shared.Core.Utils.ReadFully(upload.Stream);
|
|
|
|
upload.Stream.Close();
|
|
upload.Stream.Dispose();
|
|
|
|
var importer = PluginLoader.FindClass<DataImporter>();
|
|
var result = new UploadImportFileResult
|
|
{
|
|
ResultMessage = "Die Datei konnte nicht importiert werden."
|
|
};
|
|
|
|
if (importer != null)
|
|
{
|
|
result = importer.ImportData(filename, daten);
|
|
}
|
|
|
|
return result;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public UploadPersehDocumentResult UploadPersehFile(UploadPackage upload)
|
|
{
|
|
try
|
|
{
|
|
|
|
var filename = upload.FileName;
|
|
var daten = BS.Shared.Core.Utils.ReadFully(upload.Stream);
|
|
|
|
upload.Stream.Close();
|
|
upload.Stream.Dispose();
|
|
|
|
var pr = PluginLoader.FindClass<PersehReader>();
|
|
|
|
var result = new UploadPersehDocumentResult();
|
|
result.HilfeplanImportData = pr.ReadPdfDocument(daten);
|
|
return result;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
|
|
}
|
|
}
|
|
|
|
public UploadChatResult CreateNewSpeziallStreamChatMessagesDC(UploadChatPackage istream)
|
|
{
|
|
try
|
|
{
|
|
var chatMessage = new ChatMessage
|
|
{
|
|
EmpfaengerPersonOid = istream.empfängerOid,
|
|
SenderPersonOid = istream.senderOid,
|
|
Uhrzeit = DateTime.Now,
|
|
IsDelivered = istream.isDeliverd,
|
|
ChatText = Encoding.UTF8.GetBytes(istream.message),
|
|
MediaTyp = istream.mediatype,
|
|
IstGelesen = 0,
|
|
MessageId = istream.messageid
|
|
};
|
|
|
|
if (istream.teamid != 0)
|
|
{
|
|
chatMessage.TeamOid = istream.teamid;
|
|
}
|
|
else
|
|
{
|
|
chatMessage.TeamOid = null;
|
|
}
|
|
|
|
DAOFactory.GenericDAO.Insert(chatMessage);
|
|
|
|
var media = BS.Shared.Core.Utils.ReadFully(istream.Stream);
|
|
byte[] ThImage = null;
|
|
|
|
if (istream.mediatype == 1)
|
|
{
|
|
ThImage = media;
|
|
}
|
|
|
|
var chatMediaMessage = new ChatMediaMessage
|
|
{
|
|
Media = media,
|
|
ImageThumpNail = BS.Shared.Core.Utils.ErstelleThumbnail(ThImage, 150, 150),
|
|
ChatMessageOid = chatMessage.Oid
|
|
};
|
|
|
|
DAOFactory.GenericDAO.Insert(chatMediaMessage);
|
|
|
|
istream.Stream.Close();
|
|
istream.Stream.Dispose();
|
|
|
|
var result = MapperFactory.ChatMessagesDC_ChatMessages.MapToNewDC(chatMessage);
|
|
result.ImageThumpNail = null;
|
|
//return new UploadChatResult { ChatMessage = MapperFactory.ChatMessagesDC_ChatMessages.MapToNewDC(chatMessage)};
|
|
return new UploadChatResult {ChatMessage = result};
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw Utils.CreateBeWoFaultException(e);
|
|
}
|
|
}
|
|
}
|
|
} |