|
@@ -1,9 +1,9 @@
|
|
|
using System;
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
|
+using System.IO;
|
|
|
using System.IO.Abstractions;
|
|
using System.IO.Abstractions;
|
|
|
using System.Net.Http;
|
|
using System.Net.Http;
|
|
|
using System.Net.Http.Headers;
|
|
using System.Net.Http.Headers;
|
|
|
-using System.Text.Json;
|
|
|
|
|
using System.Threading.Tasks;
|
|
using System.Threading.Tasks;
|
|
|
using BO.AppServer.Metadata.Dto;
|
|
using BO.AppServer.Metadata.Dto;
|
|
|
using Quadarax.Foundation.Core.Data.Interface;
|
|
using Quadarax.Foundation.Core.Data.Interface;
|
|
@@ -54,9 +54,11 @@ namespace BO.Connector
|
|
|
_client = CreateClient();
|
|
_client = CreateClient();
|
|
|
InitTicket(magicKey);
|
|
InitTicket(magicKey);
|
|
|
Login(userName, userPassword);
|
|
Login(userName, userPassword);
|
|
|
|
|
+ OnOpening();
|
|
|
Log(LogSeverityEnum.Debug, $"Connector '{ApiName}' open for user '{userName}' with timeout setting {_timeout}.");
|
|
Log(LogSeverityEnum.Debug, $"Connector '{ApiName}' open for user '{userName}' with timeout setting {_timeout}.");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
public void Close()
|
|
public void Close()
|
|
|
{
|
|
{
|
|
|
_client?.CancelPendingRequests();
|
|
_client?.CancelPendingRequests();
|
|
@@ -138,7 +140,23 @@ namespace BO.Connector
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- protected async Task<TResult> CallRequestAsync<TResult>(string relativeUrlApiCall,RestCallTypeEnum method, IDto data = null,IDictionary<string,string> headerAttributes = null, bool silent = false) where TResult : ResultDto
|
|
|
|
|
|
|
+ protected async Task<Stream> CallGetStreamAsync(string relativeUrlApiCall,
|
|
|
|
|
+ IDictionary<string, string> headerAttributes = null, bool silent = false)
|
|
|
|
|
+ {
|
|
|
|
|
+ Log(LogSeverityEnum.Trace, $"Calling REST API GET STREAM {_uriApiBase.AbsoluteUri + relativeUrlApiCall}");
|
|
|
|
|
+ if (headerAttributes != null)
|
|
|
|
|
+ {
|
|
|
|
|
+ foreach (var key in headerAttributes.Keys)
|
|
|
|
|
+ {
|
|
|
|
|
+ _client.DefaultRequestHeaders.Remove(key);
|
|
|
|
|
+ _client.DefaultRequestHeaders.Add(key,headerAttributes[key]);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return await _client.GetStreamAsync(relativeUrlApiCall);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ protected async Task<TResult> CallRequestAsync<TResult>(string relativeUrlApiCall,RestCallTypeEnum method, IDto data = null,IDictionary<string,string> headerAttributes = null, bool silent = false)
|
|
|
|
|
+ where TResult : ResultDto
|
|
|
{
|
|
{
|
|
|
if (data == null)
|
|
if (data == null)
|
|
|
if(method != RestCallTypeEnum.Get && method != RestCallTypeEnum.GetStream && method != RestCallTypeEnum.Delete)
|
|
if(method != RestCallTypeEnum.Get && method != RestCallTypeEnum.GetStream && method != RestCallTypeEnum.Delete)
|
|
@@ -219,7 +237,9 @@ namespace BO.Connector
|
|
|
|
|
|
|
|
throw new AggregateException(excps);
|
|
throw new AggregateException(excps);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ protected virtual void OnOpening()
|
|
|
|
|
+ {
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
private HttpClient CreateClient()
|
|
private HttpClient CreateClient()
|
|
|
{
|
|
{
|