StoredFile
This commit is contained in:
@@ -122,6 +122,7 @@
|
||||
<Compile Include="Services\IWindowService.cs" />
|
||||
<Compile Include="ViewModel\AddressVM.cs" />
|
||||
<Compile Include="ViewModel\AiConfigVM.cs" />
|
||||
<Compile Include="ViewModel\StoredFileVM.cs" />
|
||||
<Compile Include="View\Detail\AI\AiConfigView.xaml.cs">
|
||||
<DependentUpon>AiConfigView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
||||
@@ -660,8 +660,6 @@ namespace BeWo.View.Detail.Accounting
|
||||
x => x.CreateXRechnung(invoice_base_oid, invoice_type, report_link),
|
||||
cb =>
|
||||
{
|
||||
|
||||
|
||||
if (cb is byte[] bytes)
|
||||
{
|
||||
File.WriteAllBytes(@"C:\Users\ownSoft\Desktop\XRechnung\test.pdf", bytes);
|
||||
|
||||
@@ -923,6 +923,8 @@ namespace BeWo.ViewModel
|
||||
|
||||
public IList<IInvoiceItem> IInvoiceItems => throw new NotImplementedException();
|
||||
|
||||
public long? Oid => DataContract.InvoiceBaseOid;
|
||||
|
||||
protected override void InitByDataContract(InvoiceBaseDC pDataContract)
|
||||
{
|
||||
_SupportConceptOid = pDataContract.SupportConceptOid;
|
||||
|
||||
89
BeWo/ViewModel/StoredFileVM.cs
Normal file
89
BeWo/ViewModel/StoredFileVM.cs
Normal file
@@ -0,0 +1,89 @@
|
||||
using System;
|
||||
|
||||
using BS.Shared;
|
||||
using BS.Shared.DataContracts;
|
||||
|
||||
namespace BeWo.ViewModel
|
||||
{
|
||||
public class StoredFileVM : AbstractDCMapperVM<StoredFileDC>
|
||||
{
|
||||
private string _FileName;
|
||||
private string _FilePath;
|
||||
private string _ContentType;
|
||||
private long _Size;
|
||||
private string _Checksum;
|
||||
private int? _BeWoObjectTid;
|
||||
private long? _BeWoObjectOid;
|
||||
|
||||
public StoredFileVM(StoredFileDC dc) : base(dc, dc.Oid)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public string FileName
|
||||
{
|
||||
get => _FileName;
|
||||
set => SetProperty(ref _FileName, value, nameof(FileName), () => DataContract.FileName);
|
||||
}
|
||||
|
||||
public string FilePath
|
||||
{
|
||||
get => _FilePath;
|
||||
set => SetProperty(ref _FilePath, value, nameof(FilePath), () => DataContract.FilePath);
|
||||
}
|
||||
|
||||
public string ContentType
|
||||
{
|
||||
get => _ContentType;
|
||||
set => SetProperty(ref _ContentType, value, nameof(ContentType), () => DataContract.ContentType);
|
||||
}
|
||||
|
||||
public long Size
|
||||
{
|
||||
get => _Size;
|
||||
set => SetProperty(ref _Size, value, nameof(Size), () => DataContract.Size);
|
||||
}
|
||||
|
||||
public string Checksum
|
||||
{
|
||||
get => _Checksum;
|
||||
set => SetProperty(ref _Checksum, value, nameof(Checksum), () => DataContract.Checksum);
|
||||
}
|
||||
|
||||
public int? BeWoObjectTid
|
||||
{
|
||||
get => _BeWoObjectTid;
|
||||
set => SetProperty(ref _BeWoObjectTid, value, nameof(BeWoObjectTid), () => DataContract.BeWoObjectTid);
|
||||
}
|
||||
|
||||
public long? BeWoObjectOid
|
||||
{
|
||||
get => _BeWoObjectOid;
|
||||
set => SetProperty(ref _BeWoObjectOid, value, nameof(BeWoObjectOid), () => DataContract.BeWoObjectOid);
|
||||
}
|
||||
|
||||
protected override void InitByDataContract(StoredFileDC pDataContract)
|
||||
{
|
||||
_FileName = pDataContract.FileName;
|
||||
_FilePath = pDataContract.FilePath;
|
||||
_ContentType = pDataContract.ContentType;
|
||||
_Size = pDataContract.Size;
|
||||
_Checksum = pDataContract.Checksum;
|
||||
_BeWoObjectTid = pDataContract.BeWoObjectTid;
|
||||
_BeWoObjectOid = pDataContract.BeWoObjectOid;
|
||||
}
|
||||
|
||||
protected override StoredFileDC MapToDataContract(StoredFileDC pDataContract, bool doCommit)
|
||||
{
|
||||
pDataContract.FileName = _FileName;
|
||||
pDataContract.FilePath = _FilePath;
|
||||
pDataContract.ContentType = _ContentType;
|
||||
pDataContract.Size = _Size;
|
||||
pDataContract.Checksum = _Checksum;
|
||||
pDataContract.BeWoObjectTid = _BeWoObjectTid;
|
||||
pDataContract.BeWoObjectOid = _BeWoObjectOid;
|
||||
|
||||
return pDataContract;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ namespace BeWo.Data.Access
|
||||
public static SearchDAO SearchDAO => _SearchDAO.Value;
|
||||
public static UserDAO UserDAO => _UserDAO.Value;
|
||||
|
||||
public static IFileStorageDAO GetLocalFileStorage(string rootpath)
|
||||
public static LocalFileStorageDAO GetLocalFileStorage(string rootpath)
|
||||
{
|
||||
return new LocalFileStorageDAO(rootpath);
|
||||
}
|
||||
|
||||
@@ -1,16 +1,21 @@
|
||||
using BS.Shared;
|
||||
using BeWo.Data.Entities;
|
||||
using BS.Shared;
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.Exceptions;
|
||||
using BS.Shared.Interface;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.Remoting.Messaging;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Task = System.Threading.Tasks.Task;
|
||||
|
||||
namespace BeWo.Data.Access
|
||||
{
|
||||
public class LocalFileStorageDAO : IFileStorageDAO
|
||||
public class LocalFileStorageDAO
|
||||
{
|
||||
private readonly string _rootPath;
|
||||
|
||||
@@ -19,31 +24,69 @@ namespace BeWo.Data.Access
|
||||
_rootPath = rootPath;
|
||||
}
|
||||
|
||||
private string GetFilePath(string customerId, BWPFeature feature, string fileName)
|
||||
private string GetFilePath(string tenant, string filePath)
|
||||
{
|
||||
return Path.Combine(_rootPath, customerId, feature.ToString(), fileName);
|
||||
return Path.Combine(_rootPath, tenant, filePath);
|
||||
}
|
||||
|
||||
public async Task SaveFileAsync(string customerId, BWPFeature feature, string fileName, Stream content, CancellationToken cancellationToken = default)
|
||||
public async Task<IStoredFile> SaveXRechnungPdfAsync(string tenant, IInvoiceBase invoicebase, Stream content)
|
||||
{
|
||||
var path = GetFilePath(customerId, feature, fileName);
|
||||
var lTid = (int)TableID.InvoiceBase;
|
||||
var lOid = invoicebase.Oid;
|
||||
var lFileName = $"{lOid}.XRechnung.pdf";
|
||||
|
||||
return await SaveFileAsync(tenant, BWPFeature.XRechnung, lFileName, "application/pdf", content, lTid, lOid).ConfigureAwait(true);
|
||||
}
|
||||
|
||||
private async Task<IStoredFile> SaveFileAsync(string tenant, BWPFeature feature, string pFileName, string pContentType, Stream content, int? pBeWoObjectTid = null, long? pBeWoObjectOid = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var lFilePath = feature.ToString();
|
||||
|
||||
return await SaveFileAsync(tenant, lFilePath, pFileName, pContentType, content, pBeWoObjectTid, pBeWoObjectOid, cancellationToken).ConfigureAwait(true);
|
||||
}
|
||||
|
||||
private async Task<IStoredFile> SaveFileAsync(string tenant, string pFilePath, string pFileName, string pContentType, Stream content, int? pBeWoObjectTid = null, long? pBeWoObjectOid = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
// Prüfe Namen
|
||||
if (SecurityUtils.ContainsInvalidFilenameChars(pFilePath))
|
||||
throw new BeWoInvalidOperationException(AppError.LocalFileStorageFileNameInvalidChar);
|
||||
|
||||
if (Path.GetFileName(pFilePath) != pFileName)
|
||||
throw new BeWoInvalidOperationException(AppError.LocalFileStorageFileNameNotEqFilePath);
|
||||
|
||||
// Erstelle DB Eintrag
|
||||
var storedfile = new StoredFile();
|
||||
|
||||
storedfile.FileName = pFileName;
|
||||
storedfile.FilePath = pFilePath;
|
||||
storedfile.ContentType = pContentType;
|
||||
storedfile.BeWoObjectTid = pBeWoObjectTid;
|
||||
storedfile.BeWoObjectOid = pBeWoObjectOid;
|
||||
|
||||
// Erstelle File Ordner
|
||||
var path = GetFilePath(tenant, pFilePath);
|
||||
var directory = Path.GetDirectoryName(path);
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
// Speichere Datei
|
||||
using (var stream = File.Create(path))
|
||||
{
|
||||
await content.CopyToAsync(stream, bufferSize: 81920, cancellationToken).ConfigureAwait(true);
|
||||
};
|
||||
await content.CopyToAsync(stream, bufferSize: 81920, cancellationToken).ConfigureAwait(true);
|
||||
storedfile.Size = content.Position;
|
||||
storedfile.Checksum = SecurityUtils.GetChecksumBuffered(content);
|
||||
}
|
||||
|
||||
return storedfile;
|
||||
}
|
||||
|
||||
public Task<bool> FileExistsAsync(string customerId, BWPFeature feature, string fileName, CancellationToken cancellationToken = default)
|
||||
public Task<bool> FileExistsAsync(string tenant, IStoredFile storedFile, CancellationToken cancellationToken = default)
|
||||
{
|
||||
return Task.FromResult(File.Exists(GetFilePath(customerId, feature, fileName)));
|
||||
return Task.FromResult(File.Exists(GetFilePath(tenant, storedFile.FilePath)));
|
||||
}
|
||||
|
||||
public Task<Stream> GetFileAsync(string customerId, BWPFeature feature, string fileName, CancellationToken cancellationToken = default)
|
||||
public Task<Stream> GetFileAsync(string tenant, IStoredFile storedFile, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var path = GetFilePath(customerId, feature, fileName);
|
||||
var path = GetFilePath(tenant, storedFile.FilePath);
|
||||
if (!File.Exists(path))
|
||||
return Task.FromResult<Stream>(null);
|
||||
|
||||
@@ -51,9 +94,9 @@ namespace BeWo.Data.Access
|
||||
return Task.FromResult(stream);
|
||||
}
|
||||
|
||||
public Task<bool> DeleteFileAsync(string customerId, BWPFeature feature, string fileName, CancellationToken cancellationToken = default)
|
||||
public Task<bool> DeleteFileAsync(string tenant, IStoredFile storedFile, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var path = GetFilePath(customerId, feature, fileName);
|
||||
var path = GetFilePath(tenant, storedFile.FilePath);
|
||||
if (File.Exists(path))
|
||||
{
|
||||
File.Delete(path);
|
||||
|
||||
@@ -236,6 +236,7 @@
|
||||
<Compile Include="Entities\Light\InvoiceBaseLight.cs" />
|
||||
<Compile Include="Entities\Light\LightEntity.cs" />
|
||||
<Compile Include="Entities\Light\OrganisationLight.cs" />
|
||||
<Compile Include="Entities\StoredFile.cs" />
|
||||
<Compile Include="Entities\TwoFactorCode.cs" />
|
||||
<Compile Include="Entities\AbwesenheitsInformationPrint.cs" />
|
||||
<Compile Include="Entities\AddressHistory.cs" />
|
||||
@@ -830,6 +831,7 @@
|
||||
<EmbeddedResource Include="Mappings\AiConversationMessage.hbm.xml" />
|
||||
<EmbeddedResource Include="Mappings\AiModel.hbm.xml" />
|
||||
<EmbeddedResource Include="Mappings\AiConfig.hbm.xml" />
|
||||
<EmbeddedResource Include="Mappings\StoredFile.hbm.xml" />
|
||||
<Content Include="Mappings\Timesheet2Mail.hbm.xml" />
|
||||
<EmbeddedResource Include="Mappings\ContactHistory.hbm.xml">
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
31
Data/Entities/StoredFile.cs
Normal file
31
Data/Entities/StoredFile.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using BS.Shared;
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.Interface;
|
||||
|
||||
namespace BeWo.Data.Entities
|
||||
{
|
||||
public class StoredFile : BeWoEntityBase, IStoredFile
|
||||
{
|
||||
public StoredFile()
|
||||
{
|
||||
_Tid = TableID.StoredFile;
|
||||
}
|
||||
|
||||
public virtual string FileName { get; set; }
|
||||
|
||||
public virtual string FilePath { get; set; }
|
||||
|
||||
public virtual string ContentType { get; set; }
|
||||
|
||||
public virtual long Size { get; set; }
|
||||
|
||||
public virtual string Checksum { get; set; }
|
||||
|
||||
public virtual int? BeWoObjectTid { get; set; }
|
||||
|
||||
public virtual long? BeWoObjectOid { get; set; }
|
||||
}
|
||||
}
|
||||
24
Data/Mappings/StoredFile.hbm.xml
Normal file
24
Data/Mappings/StoredFile.hbm.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
|
||||
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2">
|
||||
<class name="BeWo.Data.Entities.StoredFile,BeWo.Data" table="StoredFile">
|
||||
<id name="Oid" column ="Oid" unsaved-value="null">
|
||||
<generator class="identity" />
|
||||
</id>
|
||||
<version type="Int64" column="Version" name="Version" />
|
||||
<property name="InsTs"/>
|
||||
<property name="InsUser"/>
|
||||
<property column="Tid" type="BS.Shared.TableID, BS.Shared" name="_Tid" access="field" />
|
||||
<property name="UdpUser"/>
|
||||
<property name="IsActive" type="BS.Shared.ActivationTypeId, BS.Shared" />
|
||||
<property name="SystemEntryID" type="BS.Shared.SystemEntryID, BS.Shared" />
|
||||
<property name="Notice"/>
|
||||
<property name="FileName"/>
|
||||
<property name="FilePath"/>
|
||||
<property name="ContentType"/>
|
||||
<property name="Size"/>
|
||||
<property name="Checksum"/>
|
||||
<property name="BeWoObjectTid"/>
|
||||
<property name="BeWoObjectOid"/>
|
||||
</class>
|
||||
</hibernate-mapping>
|
||||
@@ -7,6 +7,7 @@ using BeWo.Data;
|
||||
|
||||
using BS.Shared.Core;
|
||||
using BeWo.Service.Security;
|
||||
using SecurityUtils = BeWo.Service.Security.SecurityUtils;
|
||||
|
||||
public partial class Download : Page
|
||||
{
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<NameOfLastUsedPublishProfile>C:\Projects\Bewo\BeWo - Main\Host\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>
|
||||
<UseIISExpress>true</UseIISExpress>
|
||||
<LastActiveSolutionConfig>Release|Any CPU</LastActiveSolutionConfig>
|
||||
<LastActiveSolutionConfig>Debug|Any CPU</LastActiveSolutionConfig>
|
||||
<Use64BitIISExpress>false</Use64BitIISExpress>
|
||||
<IISExpressSSLPort />
|
||||
<IISExpressAnonymousAuthentication />
|
||||
|
||||
@@ -24,6 +24,8 @@ using BeWo.Data.Entities;
|
||||
using BeWo.Service.DCEntityMapper;
|
||||
using BS.Shared.ReportRequests;
|
||||
|
||||
using SecurityUtils = BeWo.Service.Security.SecurityUtils;
|
||||
|
||||
namespace Host
|
||||
{
|
||||
public partial class ReportView : Page
|
||||
|
||||
19
Model/Changes_2025_06_03 StoredFile.txt
Normal file
19
Model/Changes_2025_06_03 StoredFile.txt
Normal file
@@ -0,0 +1,19 @@
|
||||
CREATE TABLE `StoredFile` (
|
||||
`Oid` bigint NOT NULL AUTO_INCREMENT,
|
||||
`InsTs` datetime DEFAULT NULL,
|
||||
`InsUser` varchar(255) DEFAULT NULL,
|
||||
`Notice` varchar(1024) DEFAULT NULL,
|
||||
`Tid` int DEFAULT NULL,
|
||||
`UdpUser` varchar(255) DEFAULT NULL,
|
||||
`Version` bigint DEFAULT NULL,
|
||||
`IsActive` tinyint DEFAULT NULL,
|
||||
`SystemEntryID` int DEFAULT NULL,
|
||||
`FileName` varchar(255),
|
||||
`FilePath` varchar(1024),
|
||||
`ContentType` varchar(127),
|
||||
`Size` bigint,
|
||||
`Checksum` varchar(64),
|
||||
`BeWoObjectTid` int,
|
||||
`BeWoObjectOid` bigint,
|
||||
PRIMARY KEY (`Oid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=latin1;
|
||||
@@ -4,10 +4,12 @@ using BS.Shared.DataContracts;
|
||||
|
||||
namespace BeWo.Service.DCEntityMapper
|
||||
{
|
||||
public class AddressDC_Address : AbstractIDCEntityMapper<Address, AddressDC>
|
||||
public class AddressDC_Address : BeWoDataContract_BeWoEntityBase<Address, AddressDC>
|
||||
{
|
||||
public override AddressDC MergeWithDC(Address pEntity, AddressDC pDataContract)
|
||||
{
|
||||
base.MergeWithDC(pEntity, pDataContract);
|
||||
|
||||
pDataContract.AddressLine1 = pEntity.AddressLine1;
|
||||
pDataContract.AddressLine2 = pEntity.AddressLine2;
|
||||
pDataContract.Country = pEntity.Country;
|
||||
@@ -24,6 +26,8 @@ namespace BeWo.Service.DCEntityMapper
|
||||
|
||||
public override Address MergeWithEntity(AddressDC pDataContract, Address pEntity)
|
||||
{
|
||||
base.MergeWithEntity(pDataContract, pEntity);
|
||||
|
||||
pEntity.AddressLine1 = pDataContract.AddressLine1;
|
||||
pEntity.AddressLine2 = pDataContract.AddressLine2;
|
||||
pEntity.Country = pDataContract.Country;
|
||||
@@ -37,12 +41,5 @@ namespace BeWo.Service.DCEntityMapper
|
||||
|
||||
return pEntity;
|
||||
}
|
||||
|
||||
protected override bool AreDCAndEntityEqual(AddressDC pDC, Address pEntity)
|
||||
{
|
||||
if (pDC.Oid == null)
|
||||
return false;
|
||||
return pDC.Oid == pEntity.Oid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
44
Service/DCEntityMapper/BeWoDataContract_BeWoEntityBase.cs
Normal file
44
Service/DCEntityMapper/BeWoDataContract_BeWoEntityBase.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
using BS.Shared.DataContracts;
|
||||
using BS.Shared.DataContracts.Feature.AI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BeWo.Service.DCEntityMapper
|
||||
{
|
||||
public class BeWoDataContract_BeWoEntityBase<Entity, DataContract> : AbstractIDCEntityMapper<Entity, DataContract>
|
||||
where Entity : BeWoEntityBase, new()
|
||||
where DataContract : BeWoDataContract, new()
|
||||
{
|
||||
public override DataContract MergeWithDC(Entity pEntity, DataContract pDataContract)
|
||||
{
|
||||
pDataContract.Oid = pEntity.Oid;
|
||||
pDataContract.Version = pEntity.Version;
|
||||
pDataContract.Notice = pEntity.Notice;
|
||||
|
||||
return pDataContract;
|
||||
}
|
||||
|
||||
public override Entity MergeWithEntity(DataContract pDataContract, Entity pEntity)
|
||||
{
|
||||
ConcurrencyCheck(pDataContract.Version, pEntity);
|
||||
|
||||
pEntity.Oid = pDataContract.Oid;
|
||||
pEntity.Version = pDataContract.Version;
|
||||
pEntity.Notice = pDataContract.Notice;
|
||||
|
||||
return pEntity;
|
||||
}
|
||||
|
||||
protected override bool AreDCAndEntityEqual(DataContract pDC, Entity pEntity)
|
||||
{
|
||||
if (pDC.Oid == null)
|
||||
return false;
|
||||
return pDC.Oid == pEntity.Oid;
|
||||
}
|
||||
}
|
||||
}
|
||||
45
Service/DCEntityMapper/StoredFileDC_StoredFile.cs
Normal file
45
Service/DCEntityMapper/StoredFileDC_StoredFile.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using BeWo.Data.Access;
|
||||
using BeWo.Data.Entities;
|
||||
|
||||
using BS.Shared;
|
||||
using BS.Shared.Core;
|
||||
using BS.Shared.DataContracts;
|
||||
|
||||
namespace BeWo.Service.DCEntityMapper
|
||||
{
|
||||
public class StoredFileDC_StoredFile : BeWoDataContract_BeWoEntityBase<StoredFile, StoredFileDC>
|
||||
{
|
||||
public override StoredFileDC MergeWithDC(StoredFile pEntity, StoredFileDC pDataContract)
|
||||
{
|
||||
base.MergeWithDC(pEntity, pDataContract);
|
||||
|
||||
pDataContract.FileName = pEntity.FileName;
|
||||
pDataContract.FilePath = pEntity.FilePath;
|
||||
pDataContract.ContentType = pEntity.ContentType;
|
||||
pDataContract.Size = pEntity.Size;
|
||||
pDataContract.Checksum = pEntity.Checksum;
|
||||
pDataContract.BeWoObjectTid = pEntity.BeWoObjectTid;
|
||||
pDataContract.BeWoObjectOid = pEntity.BeWoObjectOid;
|
||||
|
||||
return pDataContract;
|
||||
}
|
||||
|
||||
public override StoredFile MergeWithEntity(StoredFileDC pDataContract, StoredFile pEntity)
|
||||
{
|
||||
base.MergeWithDC(pEntity, pDataContract);
|
||||
|
||||
pEntity.FileName = pDataContract.FileName;
|
||||
pEntity.FilePath = pDataContract.FilePath;
|
||||
pEntity.ContentType = pDataContract.ContentType;
|
||||
pEntity.Size = pDataContract.Size;
|
||||
pEntity.Checksum = pDataContract.Checksum;
|
||||
pEntity.BeWoObjectTid = pDataContract.BeWoObjectTid;
|
||||
pEntity.BeWoObjectOid = pDataContract.BeWoObjectOid;
|
||||
|
||||
return pEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,8 @@ using BeWo.Service.Configuration;
|
||||
using BeWo.Data.Security;
|
||||
using BeWo.Service.Security;
|
||||
|
||||
using SecurityUtils = BeWo.Service.Security.SecurityUtils;
|
||||
|
||||
namespace BeWo.Service.Plugins
|
||||
{
|
||||
public class ServiceRecordValidator : AbstractIDSpecificDefaultClass<ServiceRecordValidator>
|
||||
|
||||
@@ -244,6 +244,7 @@
|
||||
<Compile Include="DCEntityMapper\AiModelDC_AiModel.cs" />
|
||||
<Compile Include="DCEntityMapper\BankAccountDC_BankAccount.cs" />
|
||||
<Compile Include="DCEntityMapper\BargeldtransaktionshistoryDC_Bargeldtransaktionshistory.cs" />
|
||||
<Compile Include="DCEntityMapper\BeWoDataContract_BeWoEntityBase.cs" />
|
||||
<Compile Include="DCEntityMapper\Compact\CompactInvoiceBaseDC_InvoiceBase.cs" />
|
||||
<Compile Include="DCEntityMapper\Light\GkvAbrechnungLightDC_GkvAbrechnungLight.cs" />
|
||||
<Compile Include="DCEntityMapper\ConfirmationReceiptSignatureDC_ConfirmationReceiptSignature.cs" />
|
||||
@@ -345,6 +346,7 @@
|
||||
<Compile Include="DCEntityMapper\BudgetDC_Budget.cs" />
|
||||
<Compile Include="DCEntityMapper\QuittierungsCheckDC_QuittierungsCheck.cs" />
|
||||
<Compile Include="DCEntityMapper\RatingDC_Rating.cs" />
|
||||
<Compile Include="DCEntityMapper\StoredFileDC_StoredFile.cs" />
|
||||
<Compile Include="DCEntityMapper\TextbausteinDC_Textbaustein.cs" />
|
||||
<Compile Include="DCEntityMapper\TokenDC_Token.cs" />
|
||||
<Compile Include="DCEntityMapper\VertretungsListeDC_VertretungsListe.cs" />
|
||||
|
||||
@@ -24,6 +24,8 @@ using BS.Shared.Translation;
|
||||
using BeWo.Service.Reporting;
|
||||
using BS.Shared.Core;
|
||||
|
||||
using SecurityUtils = BeWo.Service.Security.SecurityUtils;
|
||||
|
||||
namespace BeWo.Service.ServiceImplementations
|
||||
{
|
||||
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
|
||||
|
||||
@@ -41,6 +41,8 @@ using Utils = BeWo.Service.Core.Utils;
|
||||
using System.Collections.Specialized;
|
||||
using BeWo.ServiceUtils.History;
|
||||
|
||||
using SecurityUtils = BeWo.Service.Security.SecurityUtils;
|
||||
|
||||
namespace BeWo.Service.ServiceImplementations
|
||||
{
|
||||
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
|
||||
|
||||
@@ -188,7 +188,8 @@ namespace BS.Shared
|
||||
AiModel = 179,
|
||||
AiConversationMessage = 180,
|
||||
AiContext2BeWoObject = 181,
|
||||
AiConfig = 182
|
||||
AiConfig = 182,
|
||||
StoredFile = 183
|
||||
}
|
||||
|
||||
public enum SystemEntryID
|
||||
|
||||
@@ -33,6 +33,8 @@ namespace BS.Shared.Core
|
||||
|
||||
//public static readonly AppError Example = new AppError("Code", "Message");
|
||||
|
||||
public static readonly AppError LocalFileStorageFileNameInvalidChar = new AppError("DATA.LFS.60001", "Fehler beim Speichern");
|
||||
public static readonly AppError LocalFileStorageFileNameNotEqFilePath = new AppError("DATA.LFS.60002", "Fehler beim Speichern");
|
||||
public static readonly Func<OrganisationDC, AppError> GkvDatenannahmestelleAdresseNotFound = (dc) => new AppError("GKV.70001", $"Unbekannte Datenannahmestelle. Bitte neu in der Organisation {dc.Name} ermitteln");
|
||||
}
|
||||
}
|
||||
|
||||
40
Shared/Core/SecurityUtils.cs
Normal file
40
Shared/Core/SecurityUtils.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.Shared.Core
|
||||
{
|
||||
public static class SecurityUtils
|
||||
{
|
||||
private static readonly char[] InvalidFilenameChars = Path.GetInvalidFileNameChars();
|
||||
|
||||
public static bool ContainsInvalidFilenameChars(string fileName)
|
||||
{
|
||||
return fileName.IndexOfAny(InvalidFilenameChars) >= 0;
|
||||
}
|
||||
|
||||
public static string GetChecksum(string filePath)
|
||||
{
|
||||
using (FileStream stream = File.OpenRead(filePath))
|
||||
{
|
||||
var sha = new SHA256Managed();
|
||||
byte[] checksum = sha.ComputeHash(stream);
|
||||
return BitConverter.ToString(checksum).Replace("-", String.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetChecksumBuffered(Stream stream)
|
||||
{
|
||||
using (var bufferedStream = new BufferedStream(stream, 1024 * 32))
|
||||
{
|
||||
var sha = new SHA256Managed();
|
||||
byte[] checksum = sha.ComputeHash(bufferedStream);
|
||||
return BitConverter.ToString(checksum).Replace("-", String.Empty);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,6 +126,8 @@ namespace BS.Shared.DataContracts
|
||||
|
||||
public IList<IInvoiceItem> IInvoiceItems => throw new NotImplementedException();
|
||||
|
||||
public long? Oid => InvoiceBaseOid;
|
||||
|
||||
public bool ContainsRecipientAddressData()
|
||||
{
|
||||
return !Utils.AreAllNullOrEmpty(this.RecipientStreet, this.RecipientPostCode, this.RecipientTown);
|
||||
|
||||
17
Shared/DataContracts/StoredFileDC.cs
Normal file
17
Shared/DataContracts/StoredFileDC.cs
Normal file
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Runtime.Serialization;
|
||||
|
||||
namespace BS.Shared.DataContracts
|
||||
{
|
||||
[DataContract]
|
||||
public class StoredFileDC : BeWoDataContract
|
||||
{
|
||||
[DataMember] public string FileName { get; set; }
|
||||
[DataMember] public string FilePath { get; set; }
|
||||
[DataMember] public string ContentType { get; set; }
|
||||
[DataMember] public long Size { get; set; }
|
||||
[DataMember] public string Checksum { get; set; }
|
||||
[DataMember] public int? BeWoObjectTid { get; set; }
|
||||
[DataMember] public long? BeWoObjectOid { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,11 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace BS.Shared.Interface
|
||||
{
|
||||
public interface IFileStorageDAO
|
||||
{
|
||||
Task SaveFileAsync(string tenant, BWPFeature feature, string fileName, Stream content, CancellationToken cancellationToken = default);
|
||||
Task<Stream> GetFileAsync(string tenant, BWPFeature feature, string fileName, CancellationToken cancellationToken = default);
|
||||
Task<bool> DeleteFileAsync(string tenant, BWPFeature feature, string fileName, CancellationToken cancellationToken = default);
|
||||
Task<bool> FileExistsAsync(string tenant, BWPFeature feature, string fileName, CancellationToken cancellationToken = default);
|
||||
}
|
||||
//public interface IFileStorageDAO
|
||||
//{
|
||||
// Task<IStoredFile> SaveFileAsync(BWPFeature feature, string fileName, Stream content, CancellationToken cancellationToken = default);
|
||||
// Task<Stream> GetFileAsync(BWPFeature feature, string fileName, CancellationToken cancellationToken = default);
|
||||
// Task<bool> DeleteFileAsync(BWPFeature feature, string fileName, CancellationToken cancellationToken = default);
|
||||
// Task<bool> FileExistsAsync(BWPFeature feature, string fileName, CancellationToken cancellationToken = default);
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace BS.Shared.Interface
|
||||
{
|
||||
public interface IInvoiceBase
|
||||
{
|
||||
long? Oid { get; }
|
||||
string SenderStreet { get; }
|
||||
string SenderTown { get; }
|
||||
string SenderPostCode { get; }
|
||||
|
||||
19
Shared/Interface/IStoredFile.cs
Normal file
19
Shared/Interface/IStoredFile.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BS.Shared.Interface
|
||||
{
|
||||
public interface IStoredFile
|
||||
{
|
||||
string FileName { get; }
|
||||
string FilePath { get; }
|
||||
string ContentType { get; }
|
||||
long Size { get; }
|
||||
string Checksum { get; }
|
||||
int? BeWoObjectTid { get; }
|
||||
long? BeWoObjectOid { get; }
|
||||
}
|
||||
}
|
||||
@@ -147,6 +147,7 @@
|
||||
<Compile Include="Core\AbstractIDSpecificDefaultClass.cs" />
|
||||
<Compile Include="Core\JsonUtils.cs" />
|
||||
<Compile Include="Core\MailUtils.cs" />
|
||||
<Compile Include="Core\SecurityUtils.cs" />
|
||||
<Compile Include="Core\TokenUtils.cs" />
|
||||
<Compile Include="Core\Validator.cs" />
|
||||
<Compile Include="Core\DebugUtils.cs" />
|
||||
@@ -328,6 +329,7 @@
|
||||
<Compile Include="DataContracts\CustomerTokenRelationDC.cs" />
|
||||
<Compile Include="DataContracts\EmployeeTokenRelationDC.cs" />
|
||||
<Compile Include="DataContracts\ChatBewoMessageSyncDC.cs" />
|
||||
<Compile Include="DataContracts\StoredFileDC.cs" />
|
||||
<Compile Include="DataContracts\VertreterSucheFilterDC.cs" />
|
||||
<Compile Include="DataContracts\SbdConfigDC.cs" />
|
||||
<Compile Include="DataContracts\QuittierungsCheckDC.cs" />
|
||||
@@ -408,6 +410,7 @@
|
||||
<Compile Include="Interface\IInvoiceBase.cs" />
|
||||
<Compile Include="Interface\IOrganisation.cs" />
|
||||
<Compile Include="Interface\IInvoiceItem.cs" />
|
||||
<Compile Include="Interface\IStoredFile.cs" />
|
||||
<Compile Include="Packet.cs" />
|
||||
<Compile Include="ReportRequests\AbstractReportRequest.cs" />
|
||||
<Compile Include="ReportRequests\GkvAbrechnungReportRequest.cs" />
|
||||
|
||||
Reference in New Issue
Block a user