diff --git a/GPW.CORE.Comp/IpUtils.cs b/GPW.CORE.Comp/IpUtils.cs
new file mode 100644
index 0000000..19ed680
--- /dev/null
+++ b/GPW.CORE.Comp/IpUtils.cs
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Sockets;
+using System.Net;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace GPW.CORE.Comp
+{
+ public class IpUtils
+ {
+ ///
+ /// Restituisce l'IP v4 locale dato uno degli ip machcina (anche IPV6)
+ ///
+ ///
+ ///
+ public static string getLocalIpv4(string firstIp)
+ {
+ string devIp = firstIp;
+ IPAddress clientIP = IPAddress.Parse(devIp);
+ IPHostEntry GetIPHost = Dns.GetHostEntry(clientIP);
+ if (GetIPHost != null)
+ {
+ // se trovo + di 1 ip cerco il primo NON IPV6...
+ if (GetIPHost.AddressList.Count() > 1)
+ {
+ foreach (IPAddress item in GetIPHost.AddressList)
+ {
+ if (item.AddressFamily == AddressFamily.InterNetwork)
+ {
+ devIp = item.ToString();
+ break;
+ }
+ }
+ }
+ }
+ return devIp;
+ }
+ }
+}
diff --git a/GPW.CORE.SMART/Components/BottoniEntrEsc.razor.cs b/GPW.CORE.SMART/Components/BottoniEntrEsc.razor.cs
index fa54934..5c3ae65 100644
--- a/GPW.CORE.SMART/Components/BottoniEntrEsc.razor.cs
+++ b/GPW.CORE.SMART/Components/BottoniEntrEsc.razor.cs
@@ -1,3 +1,4 @@
+using GPW.CORE.Comp;
using GPW.CORE.Data.DbModels;
using GPW.CORE.Data.DTO;
using GPW.CORE.Smart.Data;
@@ -40,17 +41,13 @@ namespace GPW.CORE.Smart.Components
{
// var accessorie / base
TimbratureModel currRecord = new TimbratureModel();
- string remoteIp = "";
+ string ipv4 = "::";
if (httpContextAccessor.HttpContext != null)
{
- remoteIp = $"{httpContextAccessor.HttpContext.Connection?.RemoteIpAddress}";
+ var remoteIp = $"{httpContextAccessor.HttpContext.Connection?.RemoteIpAddress}";
+ // provo a recuperare ipV4...
+ ipv4 = IpUtils.getLocalIpv4(remoteIp);
}
-#if false
- if (ListTimbRich == null)
- {
- ListTimbRich = new List();
- }
-#endif
// verifico se si trattasse di timbratura uscita da attività del giorno precedente...
if (IsUscita)
@@ -79,12 +76,8 @@ namespace GPW.CORE.Smart.Components
CodTipoTimb = "Web",
DataOra = ieri.AddDays(1).AddSeconds(-1),
IdxDipendente = MService.IdxDipendente,
- Ipv4 = $"{remoteIp}"
+ Ipv4 = $"{ipv4}"
};
-#if false
- ListTimb.Add(currRecord);
- ListTimbRich.Add(currRecord);
-#endif
await CDataServ.TimbratureUpdate(currRecord);
// aggiungo apertura ad oggi
@@ -95,12 +88,8 @@ namespace GPW.CORE.Smart.Components
CodTipoTimb = "Web",
DataOra = ieri.AddDays(1),
IdxDipendente = MService.IdxDipendente,
- Ipv4 = $"{remoteIp}"
+ Ipv4 = $"{ipv4}"
};
-#if false
- ListTimb.Add(currRecord);
- ListTimbRich.Add(currRecord);
-#endif
await CDataServ.TimbratureUpdate(currRecord);
}
}
@@ -114,14 +103,9 @@ namespace GPW.CORE.Smart.Components
CodTipoTimb = "Web",
DataOra = DataRif,
IdxDipendente = MService.IdxDipendente,
- Ipv4 = $"{remoteIp}"
+ Ipv4 = $"{ipv4}"
};
-#if false
- // aggiungo alla lista...
- ListTimb.Add(currRecord);
- ListTimbRich.Add(currRecord);
-#endif
// aggiorno
await CDataServ.TimbratureUpdate(currRecord);
await Task.Delay(1);
diff --git a/GPW.CORE.SMART/Pages/Jumper.razor.cs b/GPW.CORE.SMART/Pages/Jumper.razor.cs
index 4852d9a..abaf3bf 100644
--- a/GPW.CORE.SMART/Pages/Jumper.razor.cs
+++ b/GPW.CORE.SMART/Pages/Jumper.razor.cs
@@ -21,6 +21,7 @@ using GPW.CORE.Data.DbModels;
using Org.BouncyCastle.Asn1.Ocsp;
using System.Net;
using System.Net.Sockets;
+using Microsoft.AspNetCore.Http;
namespace GPW.CORE.Smart.Pages
{
@@ -52,6 +53,8 @@ namespace GPW.CORE.Smart.Pages
private Random rnd = new Random();
+ [Inject]
+ private IHttpContextAccessor httpContextAccessor { get; set; } = null!;
///
/// Prova login da dati URL
@@ -81,9 +84,20 @@ namespace GPW.CORE.Smart.Pages
string devAgent = await JSRuntime.InvokeAsync("getUserAgent");
var dimension = await JSRuntime.InvokeAsync("getWindowDimensions");
string screenSize = $"{dimension.Width}x{dimension.Height}";
- string devIp = await JSRuntime.InvokeAsync("getIpAddress");
+ string devIp = ":";
+ if (httpContextAccessor.HttpContext != null)
+ {
+ var remoteIp = $"{httpContextAccessor.HttpContext.Connection?.RemoteIpAddress}";
+ // provo a recuperare ipV4...
+ devIp = IpUtils.getLocalIpv4(remoteIp);
+ }
+
+#if false
+ string devIp = await JSRuntime.InvokeAsync("getIpAddress");
+#endif
IPAddress clientIP = IPAddress.Parse(devIp);
IPHostEntry GetIPHost = Dns.GetHostEntry(clientIP);
+#if false
// se trovo + di 1 ip cerco il primo NON IPV6...
if (GetIPHost.AddressList.Count() > 1)
{
@@ -95,7 +109,9 @@ namespace GPW.CORE.Smart.Pages
break;
}
}
- }
+ }
+#endif
+
List compName = GetIPHost.HostName.ToString().Split('.').ToList();
string devName = compName != null && compName.Count > 0 ? compName[0] : "NA";
string rndTxt01 = SteamCrypto.RandomString(16, true);
diff --git a/GPW.CORE.SMART/wwwroot/favicon.ico b/GPW.CORE.SMART/wwwroot/favicon.ico
index 63e859b..4f0e0ad 100644
Binary files a/GPW.CORE.SMART/wwwroot/favicon.ico and b/GPW.CORE.SMART/wwwroot/favicon.ico differ