This commit is contained in:
2025-06-12 14:08:39 +02:00
parent bcad1dd270
commit 960d6a7db6
3 changed files with 36 additions and 22 deletions

View File

@@ -39,7 +39,7 @@ namespace BeWo.Data.Access
} }
public StoredFile SaveHybridFile(BWPFeature feature, string pFileName, string pContentType, Stream content, public StoredFile SaveHybridFile(BWPFeature feature, string pFileName, string pContentType, Stream content,
int? pBeWoObjectTid = null, long? pBeWoObjectOid = null, CancellationToken cancellationToken = default) TableID? pBeWoObjectTid = null, long? pBeWoObjectOid = null, CancellationToken cancellationToken = default)
{ {
// Prüfe Namen // Prüfe Namen
if (SecurityUtils.ContainsInvalidFilenameChars(pFileName)) if (SecurityUtils.ContainsInvalidFilenameChars(pFileName))
@@ -61,7 +61,7 @@ namespace BeWo.Data.Access
storedfile.FileName = pFileName; storedfile.FileName = pFileName;
storedfile.FilePath = lFilePath; storedfile.FilePath = lFilePath;
storedfile.ContentType = pContentType; storedfile.ContentType = pContentType;
storedfile.BeWoObjectTid = pBeWoObjectTid; storedfile.BeWoObjectTid = (int?)pBeWoObjectTid;
storedfile.BeWoObjectOid = pBeWoObjectOid; storedfile.BeWoObjectOid = pBeWoObjectOid;
// Speichere FileAsync // Speichere FileAsync

View File

@@ -19,6 +19,7 @@ using DevExpress.XtraRichEdit.Model;
using Newtonsoft.Json; using Newtonsoft.Json;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.ServiceModel; using System.ServiceModel;
@@ -45,7 +46,15 @@ namespace BeWo.Service.ServiceImplementations.Enhanced
if (lFile is object) if (lFile is object)
{ {
using (Stream file_stream = lStorage.GetFileContent(lFile))
{
using (MemoryStream ms = new MemoryStream())
{
file_stream.CopyTo(ms);
var bytes = ms.ToArray();
return ApiResponse<byte[]>.SuccessResponse(bytes);
}
}
} }
// Berechne XRechnung // Berechne XRechnung
@@ -55,27 +64,32 @@ namespace BeWo.Service.ServiceImplementations.Enhanced
var download_url = report_url + "&mode=pdf"; var download_url = report_url + "&mode=pdf";
var token_url = new DownloadServiceImp().CreateTemporaryUrl(download_url, false); var token_url = new DownloadServiceImp().CreateTemporaryUrl(download_url, false);
// Response
var response = ServiceFacade.XRechnung.Create(str, token_url); var response = ServiceFacade.XRechnung.Create(str, token_url);
if (response.Success) if (response.Success)
{ {
//try try
//{ {
// var file = storage.SaveXRechnungPdf(tenant, invoice_base_oid, response.ResponseBytes); var bytes = response.Data;
// ServiceHelper.CoreLogger.Log(LogLevel.Info, $"Tenant: {tenant}, FilePath: {file.FilePath}", $"{nameof(LocalFileStorageDAO)}.{nameof(storage.SaveXRechnungPdf)}"); using (MemoryStream ms = new MemoryStream(bytes))
//} {
//catch (Exception ex) var file = lStorage.SaveHybridFile(BWPFeature.XRechnung, lFileName, "application/pdf", ms, TableID.InvoiceBase, invoice_base_oid);
//{ ServiceHelper.CoreLogger.Log(LogLevel.Info, $"Tenant: {lStorage.Tenant}, FilePath: {file.FilePath}", $"{nameof(LocalFileStorageDAO)}.{nameof(lStorage.SaveHybridFile)}");
// try }
// { }
// ServiceHelper.CoreLogger.LogError(ex, nameof(GetXRechnung)); catch (Exception ex)
// } {
// catch(Exception ex2) try
// { {
// response.Errors.Add("AccountingEnhancedServiceImp: " + ex2.ToString()); ServiceHelper.CoreLogger.LogError(ex, nameof(GetXRechnung));
// } }
// response.Errors.Add("AccountingEnhancedServiceImp: " + ex.ToString()); catch (Exception ex2)
//} {
response.ErrorStrings.Add("AccountingEnhancedServiceImp: " + ex2.ToString());
}
response.ErrorStrings.Add("AccountingEnhancedServiceImp: " + ex.ToString());
}
} }
return response; return response;

View File

@@ -11,8 +11,8 @@ namespace BS.Shared.Interface
string FileName { get; } string FileName { get; }
string FilePath { get; } string FilePath { get; }
string ContentType { get; } string ContentType { get; }
long Size { get; } long Size { get; set; }
string Checksum { get; } string Checksum { get; set; }
int? BeWoObjectTid { get; } int? BeWoObjectTid { get; }
long? BeWoObjectOid { get; } long? BeWoObjectOid { get; }
} }