From 94cc36d3383c4499c01f78816714ed4f9fb46898 Mon Sep 17 00:00:00 2001 From: Hadi Khazaee Asl Date: Wed, 5 Nov 2025 05:05:51 +0330 Subject: [PATCH] Add Support for Device Generator for Open Actions ... --- Interfaces/IXIdentityProvider.cs | 3 ++ Partial/XIdentityProvider+Open.cs | 50 +++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/Interfaces/IXIdentityProvider.cs b/Interfaces/IXIdentityProvider.cs index 772baac..b7bcb5c 100644 --- a/Interfaces/IXIdentityProvider.cs +++ b/Interfaces/IXIdentityProvider.cs @@ -297,6 +297,9 @@ namespace xIdentityService.Interfaces // #region Open Actions ... + // + Task GetDevice(); + // Task OpenGet( XOpenActionInnerDto model diff --git a/Partial/XIdentityProvider+Open.cs b/Partial/XIdentityProvider+Open.cs index 0f59210..21d7ecd 100644 --- a/Partial/XIdentityProvider+Open.cs +++ b/Partial/XIdentityProvider+Open.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Runtime.InteropServices; using System.Threading.Tasks; using MongoDB.Bson; using xCommons.Constants; @@ -15,6 +16,55 @@ namespace xIdentityService.Providers { public partial class XIdentityProvider { + /// + /// Prepare API Based Device to Open Actions ... + /// + /// + public async Task GetDevice() + { + // + var os = "XSaherElmOS"; + bool isOSX = RuntimeInformation.IsOSPlatform(OSPlatform.OSX); + bool isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux); + bool isWindows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); + if (isOSX) + { + os = "MacOs"; + } + else if (isLinux) + { + os = "Linux"; + } + else if (isWindows) + { + os = "Windows"; + } + var agent = RuntimeInformation.FrameworkDescription; + if (agent.IsNullOrEmpty()) + { + agent = "XSaherElmOSAgent"; + } + var version = RuntimeInformation.OSArchitecture + ", " + RuntimeInformation.OSDescription; + if (version.IsNullOrEmpty()) + { + version = "XSaherElmOSVersion"; + } + var browser = "XSaherElmBrowser_" + RevisionSecretKey.ToMd5String(); + + // + var result = new XDeviceDto + { + Os = os, + Browser = browser, + UserAgent = agent, + OsVersion = version, + DeviceType = XDeviceType.Desktop, + }; + + // + return result; + } + // #region OpenGet ... public async Task OpenGet(