temp
This commit is contained in:
@@ -4,6 +4,7 @@ using BS.Shared.DataContracts.Invoicing.XRechnung;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -11,20 +12,49 @@ namespace BeWo.Service.ServiceUtils.XRechnung
|
||||
{
|
||||
public static class XRechnungSender
|
||||
{
|
||||
public static string Send(string url, XRechnungRequest req)
|
||||
private static readonly string XRECHNUNG_SERVER_URL = "https://test2.evplaner.de/xrg/create";
|
||||
|
||||
public static string Send(XRechnungRequest request)
|
||||
{
|
||||
var data = req.ToData();
|
||||
var dict = request.ToDict();
|
||||
|
||||
var response = Send(url, data);
|
||||
var response = GetResponse(dict);
|
||||
|
||||
return response;
|
||||
if (response is null)
|
||||
return null;
|
||||
|
||||
var test_str = Encoding.UTF8.GetString(response);
|
||||
|
||||
return test_str;
|
||||
}
|
||||
|
||||
public static string Send(string url, string data)
|
||||
private static byte[] GetResponse(IEnumerable<KeyValuePair<string, string>> kvp)
|
||||
{
|
||||
var response = OwnSoftSender.SendFormUrlEncoded(url, data);
|
||||
HttpResponseMessage response;
|
||||
using (var httpClient = new HttpClient())
|
||||
{
|
||||
using (var content = new FormUrlEncodedContent(kvp))
|
||||
{
|
||||
content.Headers.Clear();
|
||||
content.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
|
||||
|
||||
return response;
|
||||
var task = Task.Run(() => httpClient.PostAsync(XRECHNUNG_SERVER_URL, content));
|
||||
task.Wait();
|
||||
response = task.Result;
|
||||
}
|
||||
}
|
||||
|
||||
if (response is null)
|
||||
return null;
|
||||
|
||||
if (!response.IsSuccessStatusCode)
|
||||
return null;
|
||||
|
||||
var task2 = Task.Run(() => response.Content.ReadAsByteArrayAsync());
|
||||
|
||||
task2.Wait();
|
||||
|
||||
return task2.Result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user