85 lines
2.6 KiB
C#
85 lines
2.6 KiB
C#
using BeWo.Data;
|
|
using BeWo.Data.Access;
|
|
using BeWo.Data.Entities;
|
|
using BeWo.Data.Models.XRechnung;
|
|
using BeWo.Data.Security;
|
|
using BeWo.Service.Core;
|
|
using BeWo.Service.DCEntityMapper;
|
|
using BeWo.Service.ServiceContracts.Enhanced;
|
|
using BeWo.Service.ServiceProxy;
|
|
using BeWo.Service.ServiceUtils;
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Feature.AI;
|
|
using BS.Shared.DataContracts.Invoicing.XRechnung;
|
|
using BS.Shared.DataContracts.MikePHPContracts;
|
|
using DevExpress.CodeParser;
|
|
using DevExpress.Entity.Model.Metadata;
|
|
using DevExpress.XtraRichEdit.Model;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security.Cryptography;
|
|
using System.ServiceModel;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace BeWo.Service.ServiceImplementations.Enhanced
|
|
{
|
|
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Single)]
|
|
public class AccountingEnhancedServiceImp : IAccountingEnhancedService
|
|
{
|
|
public ApiResponse<byte[]> GetXRechnung(long invoice_base_oid, int report_type, string report_url)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(report_url))
|
|
throw new ArgumentNullException(nameof(report_url));
|
|
|
|
// Hole Parameter
|
|
var lStoragePath = MergedConfig.GetSetting(WebConfigSetting.StoredTenantFilesFolderPath);
|
|
var lStorage = DAOFactory.GetLocalTenantFileStorage(lStoragePath);
|
|
|
|
var lFileName = lStorage.GetXRechnungFileName(invoice_base_oid);
|
|
var lFile = lStorage.GetFileInfo(BWPFeature.XRechnung, lFileName);
|
|
|
|
if (lFile is object)
|
|
{
|
|
|
|
}
|
|
|
|
// Berechne XRechnung
|
|
var str = ServiceConfigReader.GetInvoiceTestJsonString();
|
|
|
|
// Erstelle Url ohne weitere Authentifizierung
|
|
var download_url = report_url + "&mode=pdf";
|
|
var token_url = new DownloadServiceImp().CreateTemporaryUrl(download_url, false);
|
|
|
|
var response = ServiceFacade.XRechnung.Create(str, token_url);
|
|
|
|
if (response.Success)
|
|
{
|
|
//try
|
|
//{
|
|
// var file = storage.SaveXRechnungPdf(tenant, invoice_base_oid, response.ResponseBytes);
|
|
// ServiceHelper.CoreLogger.Log(LogLevel.Info, $"Tenant: {tenant}, FilePath: {file.FilePath}", $"{nameof(LocalFileStorageDAO)}.{nameof(storage.SaveXRechnungPdf)}");
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
// try
|
|
// {
|
|
// ServiceHelper.CoreLogger.LogError(ex, nameof(GetXRechnung));
|
|
// }
|
|
// catch(Exception ex2)
|
|
// {
|
|
// response.Errors.Add("AccountingEnhancedServiceImp: " + ex2.ToString());
|
|
// }
|
|
// response.Errors.Add("AccountingEnhancedServiceImp: " + ex.ToString());
|
|
//}
|
|
}
|
|
|
|
return response;
|
|
}
|
|
}
|
|
}
|