diff --git a/LaserCatEyes.DataServiceSdk.DotNetStandard/LaserCatEyes.DataServiceSdk.DotNetStandard.csproj b/LaserCatEyes.DataServiceSdk.DotNetStandard/LaserCatEyes.DataServiceSdk.DotNetStandard.csproj
index 17479fb..39fb1b4 100644
--- a/LaserCatEyes.DataServiceSdk.DotNetStandard/LaserCatEyes.DataServiceSdk.DotNetStandard.csproj
+++ b/LaserCatEyes.DataServiceSdk.DotNetStandard/LaserCatEyes.DataServiceSdk.DotNetStandard.csproj
@@ -6,7 +6,7 @@
https://portal.lasercateyes.com
LaserCatEyes_Logo.png
true
- 1.0.0
+ 1.0.1
Betalgo Up Ltd.
Betalgo Up Ltd.
Laser Cat Eyes
@@ -24,6 +24,7 @@
+
@@ -38,4 +39,4 @@
-
+
\ No newline at end of file
diff --git a/LaserCatEyes.DataServiceSdk.DotNetStandard/LaserCatEyesDataService.cs b/LaserCatEyes.DataServiceSdk.DotNetStandard/LaserCatEyesDataService.cs
index 9257f4d..a1f2f92 100644
--- a/LaserCatEyes.DataServiceSdk.DotNetStandard/LaserCatEyesDataService.cs
+++ b/LaserCatEyes.DataServiceSdk.DotNetStandard/LaserCatEyesDataService.cs
@@ -3,6 +3,7 @@
using System.Threading.Tasks;
using LaserCatEyes.Domain;
using LaserCatEyes.Domain.Models;
+using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace LaserCatEyes.DataServiceSdk.DotNetStandard
@@ -13,19 +14,21 @@ public class LaserCatEyesDataService : ILaserCatEyesDataService
{
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
});
+
private readonly Guid _deviceId;
private readonly LaserCatEyesOptions _laserCatEyesOptions;
private readonly LaserCatEyesSystemOptions _laserCatEyesSystemOptions;
+ private readonly bool _serviceReady;
- public LaserCatEyesDataService(IOptions laserCatEyesOptions, IOptions laserCatEyesSystemOptions)
+ public LaserCatEyesDataService(IOptions laserCatEyesOptions, IOptions laserCatEyesSystemOptions, ILogger logger)
{
-
_laserCatEyesOptions = laserCatEyesOptions.Value;
_laserCatEyesSystemOptions = laserCatEyesSystemOptions.Value;
if (string.IsNullOrEmpty(_laserCatEyesOptions.AppKey))
{
- throw new Exception("LaserCatEyes AppKey can not be null!");
+ logger.LogWarning("LaserCatEyes AppKey is NULL!");
+ return;
}
var deviceName = $"{Environment.MachineName}:{Environment.UserName}";
@@ -61,18 +64,35 @@ public LaserCatEyesDataService(IOptions laserCatEyesOptions
_deviceId = httpResponseMessage.Content.ReadAsAsync().Result.DeviceId;
_client.DefaultRequestHeaders.Add(Constants.Headers.AlgoronaDeviceId, _deviceId.ToString());
+ _serviceReady = true;
}
public async Task ReportTask(PackageData data)
{
+ if (!_serviceReady)
+ {
+ return null;
+ }
+
data.DeviceUuid = _laserCatEyesOptions.DeviceUuid;
data.DeviceId = _deviceId;
return await _client.PostAsJsonAsync(_laserCatEyesSystemOptions.Endpoints.DataSendPackage, data);
}
+
+ public bool IsServiceReady()
+ {
+ return _serviceReady;
+ }
+
public void Report(PackageData data)
{
+ if (!_serviceReady)
+ {
+ return;
+ }
+
Task.Run(() => ReportTask(data)).Forget();
}
diff --git a/LaserCatEyes.DataServiceSdk/LaserCatEyes.DataServiceSdk.csproj b/LaserCatEyes.DataServiceSdk/LaserCatEyes.DataServiceSdk.csproj
index ff70f18..47782ce 100644
--- a/LaserCatEyes.DataServiceSdk/LaserCatEyes.DataServiceSdk.csproj
+++ b/LaserCatEyes.DataServiceSdk/LaserCatEyes.DataServiceSdk.csproj
@@ -6,7 +6,7 @@
https://portal.lasercateyes.com
LaserCatEyes_Logo.png
true
- 1.0.0
+ 1.0.1
Betalgo Up Ltd.
Betalgo Up Ltd.
Laser Cat Eyes
diff --git a/LaserCatEyes.DataServiceSdk/LaserCatEyesDataService.cs b/LaserCatEyes.DataServiceSdk/LaserCatEyesDataService.cs
index 7d39fc0..46b6b7f 100644
--- a/LaserCatEyes.DataServiceSdk/LaserCatEyesDataService.cs
+++ b/LaserCatEyes.DataServiceSdk/LaserCatEyesDataService.cs
@@ -3,6 +3,7 @@
using System.Threading.Tasks;
using LaserCatEyes.Domain;
using LaserCatEyes.Domain.Models;
+using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
namespace LaserCatEyes.DataServiceSdk
@@ -13,18 +14,21 @@ public class LaserCatEyesDataService : ILaserCatEyesDataService
{
ServerCertificateCustomValidationCallback = (sender, cert, chain, sslPolicyErrors) => true
});
+
private readonly Guid _deviceId;
private readonly LaserCatEyesOptions _laserCatEyesOptions;
private readonly LaserCatEyesSystemOptions _laserCatEyesSystemOptions;
+ private readonly bool _serviceReady;
- public LaserCatEyesDataService(IOptions laserCatEyesOptions, IOptions laserCatEyesSystemOptions)
+ public LaserCatEyesDataService(IOptions laserCatEyesOptions, IOptions laserCatEyesSystemOptions, ILogger logger)
{
_laserCatEyesOptions = laserCatEyesOptions.Value;
_laserCatEyesSystemOptions = laserCatEyesSystemOptions.Value;
-
+
if (string.IsNullOrEmpty(_laserCatEyesOptions.AppKey))
{
- throw new Exception("LaserCatEyes AppKey can not be null!");
+ logger.LogWarning("LaserCatEyes AppKey is NULL!");
+ return;
}
var deviceName = $"{Environment.MachineName}:{Environment.UserName}";
@@ -57,18 +61,35 @@ public LaserCatEyesDataService(IOptions laserCatEyesOptions
_deviceId = httpResponseMessage.Content.ReadAsAsync().Result.DeviceId;
_client.DefaultRequestHeaders.Add(Constants.Headers.AlgoronaDeviceId, _deviceId.ToString());
+ _serviceReady = true;
}
public async Task ReportTask(PackageData data)
{
+ if (!_serviceReady)
+ {
+ return null;
+ }
+
data.DeviceUuid = _laserCatEyesOptions.DeviceUuid;
data.DeviceId = _deviceId;
return await _client.PostAsJsonAsync(_laserCatEyesSystemOptions.Endpoints.DataSendPackage, data);
}
+
+ public bool IsServiceReady()
+ {
+ return _serviceReady;
+ }
+
public void Report(PackageData data)
{
+ if (!_serviceReady)
+ {
+ return;
+ }
+
Task.Run(() => ReportTask(data)).Forget();
}
diff --git a/LaserCatEyes.Domain/ILaserCatEyesDataService.cs b/LaserCatEyes.Domain/ILaserCatEyesDataService.cs
index 8149b21..a8da4dc 100644
--- a/LaserCatEyes.Domain/ILaserCatEyesDataService.cs
+++ b/LaserCatEyes.Domain/ILaserCatEyesDataService.cs
@@ -6,6 +6,7 @@ namespace LaserCatEyes.Domain
{
public interface ILaserCatEyesDataService
{
+ bool IsServiceReady();
void Report(PackageData data);
Task ReportTask(PackageData data);
}
diff --git a/LaserCatEyes.Domain/LaserCatEyes.Domain.csproj b/LaserCatEyes.Domain/LaserCatEyes.Domain.csproj
index 56a1269..be957e7 100644
--- a/LaserCatEyes.Domain/LaserCatEyes.Domain.csproj
+++ b/LaserCatEyes.Domain/LaserCatEyes.Domain.csproj
@@ -6,7 +6,7 @@
https://portal.lasercateyes.com
LaserCatEyes_Logo.png
true
- 1.0.0
+ 1.0.1
Betalgo Up Ltd.
Betalgo Up Ltd.
Laser Cat Eyes
diff --git a/LaserCatEyes.Domain/Models/PackageData.cs b/LaserCatEyes.Domain/Models/PackageData.cs
index ccba743..10a80b4 100644
--- a/LaserCatEyes.Domain/Models/PackageData.cs
+++ b/LaserCatEyes.Domain/Models/PackageData.cs
@@ -12,13 +12,17 @@ public class PackageData
public Guid? DeviceId { get; set; }
public Guid? DeviceUuid { get; set; }
public Guid? AppId { get; set; }
+ public string LocalIpAddress { get; set; }
+ public string RemoteIpAddress { get; set; }
- public static PackageData CreateRequestPackage(Guid id, string url, MethodType methodType, List headers, string body, DateTime? timeStamp)
+ public static PackageData CreateRequestPackage(Guid id, string url, MethodType methodType, List headers, string body, DateTime? timeStamp, string localIpAddress, string remoteIpAddress)
{
return new PackageData
{
Id = id,
- RequestPackage = new RequestPackage(id, url, methodType, headers, body, timeStamp)
+ RequestPackage = new RequestPackage(id, url, methodType, headers, body, timeStamp),
+ LocalIpAddress = localIpAddress,
+ RemoteIpAddress = remoteIpAddress
};
}
diff --git a/LaserCatEyes.DotNetSdk.sln.DotSettings b/LaserCatEyes.DotNetSdk.sln.DotSettings
new file mode 100644
index 0000000..723cdf3
--- /dev/null
+++ b/LaserCatEyes.DotNetSdk.sln.DotSettings
@@ -0,0 +1,5 @@
+
+ True
\ No newline at end of file
diff --git a/LaserCatEyes.EndpointListener/HttpListenerMiddleware.cs b/LaserCatEyes.EndpointListener/HttpListenerMiddleware.cs
index 639a588..87e710c 100644
--- a/LaserCatEyes.EndpointListener/HttpListenerMiddleware.cs
+++ b/LaserCatEyes.EndpointListener/HttpListenerMiddleware.cs
@@ -6,21 +6,33 @@
using LaserCatEyes.Domain;
using LaserCatEyes.Domain.Models;
using Microsoft.AspNetCore.Http;
+using Microsoft.Extensions.Logging;
namespace LaserCatEyes.EndpointListener
{
public class EndpointListenerMiddleware : IMiddleware
{
private readonly ILaserCatEyesDataService _laserCatEyesDataService;
-
- public EndpointListenerMiddleware(ILaserCatEyesDataService laserCatEyesDataService)
+ private readonly bool _isServiceReady;
+ public EndpointListenerMiddleware(ILaserCatEyesDataService laserCatEyesDataService, ILogger logger)
{
+ if (laserCatEyesDataService == null)
+ {
+ logger.LogWarning($"Couldn't bind {nameof(EndpointListenerMiddleware)} because {nameof(ILaserCatEyesDataService)} is null");
+ return;
+ }
+ if(!laserCatEyesDataService.IsServiceReady())
+ {
+ logger.LogWarning($"Couldn't bind {nameof(EndpointListenerMiddleware)} because {nameof(ILaserCatEyesDataService)} was not ready");
+ return;
+ }
_laserCatEyesDataService = laserCatEyesDataService;
+ _isServiceReady = true;
}
public async Task InvokeAsync(HttpContext context, RequestDelegate next)
{
- if (context?.Request == null)
+ if (context?.Request == null || !_isServiceReady)
{
await next(context);
return;
@@ -35,7 +47,9 @@ public async Task InvokeAsync(HttpContext context, RequestDelegate next)
Utilities.HttpMethodStringToEnumConverter(context.Request.Method),
context.Request.Headers?.SelectMany(r => r.Value.Select(value => $"{r.Key}:{value}")).ToList(),
await Utilities.ReadBodyStream(context.Request.Body),
- DateTime.UtcNow
+ DateTime.UtcNow,
+ context.Connection?.LocalIpAddress?.ToString(),
+ context.Connection?.RemoteIpAddress?.ToString()
));
var originalResponseBody = context.Response.Body;
diff --git a/LaserCatEyes.EndpointListener/LaserCatEyes.EndpointListener.csproj b/LaserCatEyes.EndpointListener/LaserCatEyes.EndpointListener.csproj
index b4cb4ed..dc4095d 100644
--- a/LaserCatEyes.EndpointListener/LaserCatEyes.EndpointListener.csproj
+++ b/LaserCatEyes.EndpointListener/LaserCatEyes.EndpointListener.csproj
@@ -6,7 +6,7 @@
https://portal.lasercateyes.com
LaserCatEyes_Logo.png
true
- 1.0.0
+ 1.0.1
Betalgo Up Ltd.
Betalgo Up Ltd.
Laser Cat Eyes
diff --git a/LaserCatEyes.HttpClientListener.DotNetStandard/LaserCatEyes.HttpClientListener.DotNetStandard.csproj b/LaserCatEyes.HttpClientListener.DotNetStandard/LaserCatEyes.HttpClientListener.DotNetStandard.csproj
index 209c596..b92ae68 100644
--- a/LaserCatEyes.HttpClientListener.DotNetStandard/LaserCatEyes.HttpClientListener.DotNetStandard.csproj
+++ b/LaserCatEyes.HttpClientListener.DotNetStandard/LaserCatEyes.HttpClientListener.DotNetStandard.csproj
@@ -6,7 +6,7 @@
https://portal.lasercateyes.com
LaserCatEyes_Logo.png
true
- 1.0.0
+ 1.0.1
Betalgo Up Ltd.
Betalgo Up Ltd.
Laser Cat Eyes
diff --git a/LaserCatEyes.HttpClientListener.DotNetStandard/LaserCatEyesHttpMessageHandler.cs b/LaserCatEyes.HttpClientListener.DotNetStandard/LaserCatEyesHttpMessageHandler.cs
index fdb7931..c307170 100644
--- a/LaserCatEyes.HttpClientListener.DotNetStandard/LaserCatEyesHttpMessageHandler.cs
+++ b/LaserCatEyes.HttpClientListener.DotNetStandard/LaserCatEyesHttpMessageHandler.cs
@@ -3,31 +3,44 @@
using System.Threading;
using System.Threading.Tasks;
using LaserCatEyes.Domain;
+using Microsoft.Extensions.Logging;
namespace LaserCatEyes.HttpClientListener.DotNetStandard
{
public class LaserCatEyesHttpMessageHandler : DelegatingHandler
{
private readonly ILaserCatEyesDataService _laserCatEyesDataService;
+ private readonly bool _serviceReady;
- public LaserCatEyesHttpMessageHandler(ILaserCatEyesDataService laserCatEyesDataService)
+ public LaserCatEyesHttpMessageHandler(ILaserCatEyesDataService laserCatEyesDataService,ILogger logger)
{
- _laserCatEyesDataService = laserCatEyesDataService ?? throw new ArgumentNullException(nameof(laserCatEyesDataService));
+ if (laserCatEyesDataService == null)
+ {
+ logger.LogWarning($"Couldn't bind {nameof(LaserCatEyesHttpMessageHandler)} because {nameof(ILaserCatEyesDataService)} is null");
+ return;
+ }
+ if (!laserCatEyesDataService.IsServiceReady())
+ {
+ logger.LogWarning($"Couldn't bind {nameof(LaserCatEyesHttpMessageHandler)} because {nameof(ILaserCatEyesDataService)} was not ready");
+ return;
+ }
+ _laserCatEyesDataService = laserCatEyesDataService;
+ _serviceReady = true;
}
protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
- if (request == null)
+ if (request == null || !_serviceReady)
{
- return await base.SendAsync(null, cancellationToken);
+ return await base.SendAsync(request, cancellationToken);
}
var operationId = Guid.NewGuid();
-
_laserCatEyesDataService.Report(PackageDataHelper.RequestPackageDataFromHttpRequestMessage(operationId, request));
+
var response = await base.SendAsync(request, cancellationToken);
+
_laserCatEyesDataService.Report(PackageDataHelper.ResponsePackageDataFromHttpResponseMessage(operationId, response));
-
return response;
}
}
diff --git a/LaserCatEyes.HttpClientListener.DotNetStandard/PackageDataHelper.cs b/LaserCatEyes.HttpClientListener.DotNetStandard/PackageDataHelper.cs
index fa287ab..cdbeb78 100644
--- a/LaserCatEyes.HttpClientListener.DotNetStandard/PackageDataHelper.cs
+++ b/LaserCatEyes.HttpClientListener.DotNetStandard/PackageDataHelper.cs
@@ -15,7 +15,10 @@ public static PackageData RequestPackageDataFromHttpRequestMessage(Guid id, Http
request.RequestUri.ToString(),
Utilities.HttpMethodStringToEnumConverter(request.Method.Method),
request.Headers.SelectMany(r => r.Value.Select(value => $"{r.Key}:{value}")).ToList(),
- request.Content?.ReadAsStringAsync().Result, DateTime.UtcNow);
+ request.Content?.ReadAsStringAsync().Result,
+ DateTime.UtcNow,
+ null,
+ null);
}
public static PackageData ResponsePackageDataFromHttpResponseMessage(Guid id, HttpResponseMessage response)
diff --git a/LaserCatEyes.HttpClientListener/LaserCatEyes.HttpClientListener.csproj b/LaserCatEyes.HttpClientListener/LaserCatEyes.HttpClientListener.csproj
index 05d880f..7870f38 100644
--- a/LaserCatEyes.HttpClientListener/LaserCatEyes.HttpClientListener.csproj
+++ b/LaserCatEyes.HttpClientListener/LaserCatEyes.HttpClientListener.csproj
@@ -6,7 +6,7 @@
https://portal.lasercateyes.com
LaserCatEyes_Logo.png
true
- 1.0.0
+ 1.0.1
Betalgo Up Ltd.
Betalgo Up Ltd.
Laser Cat Eyes
diff --git a/LaserCatEyes.HttpClientListener/LaserCatEyesHttpMessageHandler.cs b/LaserCatEyes.HttpClientListener/LaserCatEyesHttpMessageHandler.cs
index a12acfb..88e5fe9 100644
--- a/LaserCatEyes.HttpClientListener/LaserCatEyesHttpMessageHandler.cs
+++ b/LaserCatEyes.HttpClientListener/LaserCatEyesHttpMessageHandler.cs
@@ -3,23 +3,36 @@
using System.Threading;
using System.Threading.Tasks;
using LaserCatEyes.Domain;
+using Microsoft.Extensions.Logging;
namespace LaserCatEyes.HttpClientListener
{
public class LaserCatEyesHttpMessageHandler : DelegatingHandler
{
private readonly ILaserCatEyesDataService _laserCatEyesDataService;
+ private readonly bool _serviceReady;
- public LaserCatEyesHttpMessageHandler(ILaserCatEyesDataService laserCatEyesDataService)
+ public LaserCatEyesHttpMessageHandler(ILaserCatEyesDataService laserCatEyesDataService,ILogger logger)
{
- _laserCatEyesDataService = laserCatEyesDataService ?? throw new ArgumentNullException(nameof(laserCatEyesDataService));
+ if (laserCatEyesDataService == null)
+ {
+ logger.LogWarning($"Couldn't bind {nameof(LaserCatEyesHttpMessageHandler)} because {nameof(ILaserCatEyesDataService)} is null");
+ return;
+ }
+ if (!laserCatEyesDataService.IsServiceReady())
+ {
+ logger.LogWarning($"Couldn't bind {nameof(LaserCatEyesHttpMessageHandler)} because {nameof(ILaserCatEyesDataService)} was not ready");
+ return;
+ }
+ _laserCatEyesDataService = laserCatEyesDataService;
+ _serviceReady = true;
}
protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
- if (request == null)
+ if (request == null || !_serviceReady)
{
- return await base.SendAsync(null, cancellationToken);
+ return await base.SendAsync(request, cancellationToken);
}
var operationId = Guid.NewGuid();
diff --git a/LaserCatEyes.HttpClientListener/PackageDataHelper.cs b/LaserCatEyes.HttpClientListener/PackageDataHelper.cs
index f5255a0..75a0f6c 100644
--- a/LaserCatEyes.HttpClientListener/PackageDataHelper.cs
+++ b/LaserCatEyes.HttpClientListener/PackageDataHelper.cs
@@ -15,7 +15,10 @@ public static PackageData RequestPackageDataFromHttpRequestMessage(Guid id, Http
request.RequestUri.ToString(),
Utilities.HttpMethodStringToEnumConverter(request.Method.Method),
request.Headers.SelectMany(r => r.Value.Select(value => $"{r.Key}:{value}")).ToList(),
- request.Content?.ReadAsStringAsync().Result, DateTime.UtcNow);
+ request.Content?.ReadAsStringAsync().Result,
+ DateTime.UtcNow,
+ null,
+ null);
}
public static PackageData ResponsePackageDataFromHttpResponseMessage(Guid id, HttpResponseMessage response)