diff --git a/Data/Models/XRechnung/XRechnungRequest.cs b/Data/Models/XRechnung/XRechnungRequest.cs
deleted file mode 100644
index 94e4df7c7..000000000
--- a/Data/Models/XRechnung/XRechnungRequest.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace BeWo.Data.Models.XRechnung
-{
- public class XRechnungRequest
- {
- [JsonProperty("json")]
- public XRechnung Json { get; set; }
-
- [JsonProperty("pdf")]
- public string Url { get; set; }
- }
-}
diff --git a/Host/DownloadFile.aspx b/Host/DownloadFile.aspx
new file mode 100644
index 000000000..7a6bdc15d
--- /dev/null
+++ b/Host/DownloadFile.aspx
@@ -0,0 +1,3 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="DownloadFile.aspx.cs" Inherits="Host.DownloadFile" %>
+
+
diff --git a/Host/DownloadFile.aspx.cs b/Host/DownloadFile.aspx.cs
new file mode 100644
index 000000000..6948b2473
--- /dev/null
+++ b/Host/DownloadFile.aspx.cs
@@ -0,0 +1,44 @@
+using BeWo.Data;
+using BeWo.Service.Security;
+using BS.Shared.Core;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Security;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+
+namespace Host
+{
+ public partial class DownloadFile : System.Web.UI.Page
+ {
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ try
+ {
+ var key = this.Request.Params["key"];
+
+ if (key != "jhkf4589141324h6543958")
+ {
+ throw new SecurityException("Invalid authentication");
+ }
+
+ string lPath = @"C:\BeWoPlaner\Test\test.pdf";
+
+ Response.AddHeader("content-disposition", "attachment;filename=test.pdf");
+ Response.Charset = string.Empty;
+ Response.ContentType = "application/.pdf";
+
+ Response.TransmitFile(lPath);
+ }
+ catch (Exception ex)
+ {
+ Response.Write(ex.ToString());
+ }
+
+ Response.End();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Host/DownloadFile.aspx.designer.cs b/Host/DownloadFile.aspx.designer.cs
new file mode 100644
index 000000000..36a6f969d
--- /dev/null
+++ b/Host/DownloadFile.aspx.designer.cs
@@ -0,0 +1,17 @@
+//------------------------------------------------------------------------------
+//
+// Dieser Code wurde von einem Tool generiert.
+//
+// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn
+// der Code neu generiert wird.
+//
+//------------------------------------------------------------------------------
+
+namespace Host
+{
+
+
+ public partial class DownloadFile
+ {
+ }
+}
diff --git a/Host/Host.csproj b/Host/Host.csproj
index 5e278ece5..eb09fe91c 100644
--- a/Host/Host.csproj
+++ b/Host/Host.csproj
@@ -201,6 +201,7 @@
+
@@ -259,6 +260,13 @@
Download.aspx
+
+ DownloadFile.aspx
+ ASPXCodeBehind
+
+
+ DownloadFile.aspx
+
DX.aspx
ASPXCodeBehind
diff --git a/Service/Service.csproj b/Service/Service.csproj
index afb041a13..3decde834 100644
--- a/Service/Service.csproj
+++ b/Service/Service.csproj
@@ -511,6 +511,7 @@
+
diff --git a/Service/ServiceContracts/IAccountingService.cs b/Service/ServiceContracts/IAccountingService.cs
index fe2192efb..5c63a2adf 100644
--- a/Service/ServiceContracts/IAccountingService.cs
+++ b/Service/ServiceContracts/IAccountingService.cs
@@ -1,7 +1,7 @@
using System;
using System.Collections.Generic;
using System.ServiceModel;
-
+using BeWo.Data.Models.XRechnung;
using BS.Shared;
using BS.Shared.Core;
using BS.Shared.DataContracts;
diff --git a/Service/ServiceImplementations/AccountingServiceImp.cs b/Service/ServiceImplementations/AccountingServiceImp.cs
index 7a4d1e066..36c7a1907 100644
--- a/Service/ServiceImplementations/AccountingServiceImp.cs
+++ b/Service/ServiceImplementations/AccountingServiceImp.cs
@@ -28,6 +28,7 @@ using BS.Shared.Extensions;
using BS.Shared.Exceptions;
using BS.Shared.AppSender;
using BeWo.Data.Security;
+using BeWo.Data.Models.XRechnung;
using BS.Shared.DataContracts.Invoicing.XRechnung;
namespace BeWo.Service.ServiceImplementations
diff --git a/Service/ServiceUtils/XRechnung/XRechnungSender.cs b/Service/ServiceUtils/XRechnung/XRechnungSender.cs
new file mode 100644
index 000000000..639857ad5
--- /dev/null
+++ b/Service/ServiceUtils/XRechnung/XRechnungSender.cs
@@ -0,0 +1,30 @@
+using BeWo.Data.Models.XRechnung;
+using BS.Shared.AppSender;
+using BS.Shared.DataContracts.Invoicing.XRechnung;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace BeWo.Service.ServiceUtils.XRechnung
+{
+ public static class XRechnungSender
+ {
+ public static string Send(string url, XRechnungRequest req)
+ {
+ var data = req.ToData();
+
+ var response = Send(url, data);
+
+ return response;
+ }
+
+ public static string Send(string url, string data)
+ {
+ var response = OwnSoftSender.SendFormUrlEncoded(url, data);
+
+ return response;
+ }
+ }
+}
diff --git a/Shared/AppSender/OwnSoftSender.cs b/Shared/AppSender/OwnSoftSender.cs
index f642ce9af..02aa7b965 100644
--- a/Shared/AppSender/OwnSoftSender.cs
+++ b/Shared/AppSender/OwnSoftSender.cs
@@ -1,4 +1,5 @@
-using System;
+using BS.Shared.Core;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@@ -9,7 +10,7 @@ namespace BS.Shared.AppSender
{
public static class OwnSoftSender
{
- public static string Send(string url, string dataString)
+ public static string SendFormUrlEncoded(string url, string dataString)
{
string response;
diff --git a/Shared/Core/Utils.cs b/Shared/Core/Utils.cs
index e3ce8f05d..0640c8fba 100644
--- a/Shared/Core/Utils.cs
+++ b/Shared/Core/Utils.cs
@@ -1,6 +1,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
@@ -1160,6 +1162,17 @@ namespace BS.Shared.Core
return age;
}
+
+ public static NameValueCollection ToNameValueCollection(T dynamicObject)
+ {
+ var nameValueCollection = new NameValueCollection();
+ foreach (PropertyDescriptor propertyDescriptor in TypeDescriptor.GetProperties(dynamicObject))
+ {
+ string value = propertyDescriptor.GetValue(dynamicObject).ToString();
+ nameValueCollection.Add(propertyDescriptor.Name, value);
+ }
+ return nameValueCollection;
+ }
}
public struct NullCompareResult
diff --git a/Shared/DataContracts/Invoicing/XRechnung/XRechnungRequest.cs b/Shared/DataContracts/Invoicing/XRechnung/XRechnungRequest.cs
index b5bdf1e94..abddc554e 100644
--- a/Shared/DataContracts/Invoicing/XRechnung/XRechnungRequest.cs
+++ b/Shared/DataContracts/Invoicing/XRechnung/XRechnungRequest.cs
@@ -1,4 +1,6 @@
-using System;
+using BS.Shared.DataContracts;
+using Newtonsoft.Json;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
@@ -8,6 +10,18 @@ namespace BS.Shared.DataContracts.Invoicing.XRechnung
{
public class XRechnungRequest : OwnSoftRequest
{
- public string Data { get; set; }
+ public string XRechnung { get; set; }
+
+ public string Url { get; set; }
+
+ public string ToData()
+ {
+ var json = $"json={XRechnung}";
+
+ if (string.IsNullOrEmpty(Url))
+ return json;
+
+ return json + $"&pdf={Url}";
+ }
}
}
diff --git a/Shared/DataContracts/Invoicing/XRechnung/XRechnungResponse.cs b/Shared/DataContracts/Invoicing/XRechnung/XRechnungResponse.cs
index 42569e864..f45db44b6 100644
--- a/Shared/DataContracts/Invoicing/XRechnung/XRechnungResponse.cs
+++ b/Shared/DataContracts/Invoicing/XRechnung/XRechnungResponse.cs
@@ -1,4 +1,5 @@
-using System;
+using BS.Shared.DataContracts;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
diff --git a/Shared/Shared.csproj b/Shared/Shared.csproj
index 2bc0ba8d8..2d4e7196a 100644
--- a/Shared/Shared.csproj
+++ b/Shared/Shared.csproj
@@ -115,6 +115,10 @@
3.5
+
+ False
+ ..\..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.7.2\System.Net.Http.dll
+
3.0
diff --git a/XRechnungUnitTest/UnitTest1.cs b/XRechnungUnitTest/UnitTest1.cs
index 6face0be2..b1c93f7f1 100644
--- a/XRechnungUnitTest/UnitTest1.cs
+++ b/XRechnungUnitTest/UnitTest1.cs
@@ -1,5 +1,7 @@
using BeWo.Data.Models.XRechnung;
+using BeWo.Service.ServiceUtils.XRechnung;
using BS.Shared.AppSender;
+using BS.Shared.DataContracts.Invoicing.XRechnung;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Newtonsoft.Json;
using System;
@@ -42,7 +44,46 @@ namespace XRechnungUnitTest
var txt = $"json={xrr}";
- var response = OwnSoftSender.Send(url, txt);
+ var response = OwnSoftSender.SendFormUrlEncoded(url, txt);
+
+ Assert.IsTrue(!string.IsNullOrWhiteSpace(response) && !response.ToLower().Contains("error"));
+ }
+
+ [TestMethod]
+ public void SendTestAsRequest()
+ {
+ var url = "https://test2.evplaner.de/xrg/create";
+
+ var json = File.ReadAllText("invoicetest.json", System.Text.Encoding.UTF8);
+
+ var xr = JsonConvert.DeserializeObject(json);
+ var xrr = JsonConvert.SerializeObject(xr);
+
+ var req = new XRechnungRequest();
+
+ req.XRechnung = xrr;
+
+ var response = XRechnungSender.Send(url, req);
+
+ Assert.IsTrue(!string.IsNullOrWhiteSpace(response) && !response.ToLower().Contains("error"));
+ }
+
+ [TestMethod]
+ public void SendTestWithUrl()
+ {
+ var url = "https://test2.evplaner.de/xrg/create";
+
+ var json = File.ReadAllText("invoicetest.json", System.Text.Encoding.UTF8);
+
+ var xr = JsonConvert.DeserializeObject(json);
+ var xrr = JsonConvert.SerializeObject(xr);
+
+ var req = new XRechnungRequest();
+
+ req.XRechnung = xrr;
+ req.Url = Uri.EscapeDataString("https://app5.bewoplaner.de/service/DownloadFile.aspx?key=jhkf4589141324h6543958");
+
+ var response = XRechnungSender.Send(url, req);
Assert.IsTrue(!string.IsNullOrWhiteSpace(response) && !response.ToLower().Contains("error"));
}
diff --git a/XRechnungUnitTest/XRechnungUnitTest.csproj b/XRechnungUnitTest/XRechnungUnitTest.csproj
index b59b74daa..3f2e901ad 100644
--- a/XRechnungUnitTest/XRechnungUnitTest.csproj
+++ b/XRechnungUnitTest/XRechnungUnitTest.csproj
@@ -66,6 +66,10 @@
{b0d73e3d-4ae7-4024-93a6-db1f46d7ccee}
Data
+
+ {094331C3-ECEE-4C89-BBFD-4C9DED89F0EF}
+ Service
+
{2F50B83D-A3F0-4EC4-979A-3F9B7E3D8ED4}
Shared