Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Triky313 committed Dec 1, 2024
2 parents dbffb66 + 149dbfe commit 5427878
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 18 deletions.
61 changes: 46 additions & 15 deletions src/StatisticsAnalysisTool/Common/SystemInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Serilog;
using System;
using System.Diagnostics;
using System.Linq;
using System.Management;
Expand All @@ -12,20 +13,50 @@ public class SystemInfo
{
public static void LogSystemInfo()
{
var osVersion = RuntimeInformation.OSDescription;

var processor = new ManagementObjectSearcher("select * from Win32_Processor").Get().OfType<ManagementObject>().FirstOrDefault()?["Name"].ToString();

var videoController = new ManagementObjectSearcher("select * from Win32_VideoController").Get().OfType<ManagementObject>().FirstOrDefault()?["Name"].ToString();

var isAdmin = new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);

var isDebug = Debugger.IsAttached;

var osArchitecture = RuntimeInformation.OSArchitecture;

var activeNetworks = NetworkInterface.GetAllNetworkInterfaces().Where(nic => nic.OperationalStatus == OperationalStatus.Up).Select(nic => nic.Name).ToList();

Log.Information($"OS Version: {osVersion} - {osArchitecture} | Processor: {processor} | Video: {videoController} | Is Admin: {isAdmin} | Is Debug: {isDebug} | Active Networks: {string.Join(", ", activeNetworks)}");
try
{
var osVersion = RuntimeInformation.OSDescription;
var osArchitecture = RuntimeInformation.OSArchitecture;
var isAdmin = new WindowsPrincipal(WindowsIdentity.GetCurrent()).IsInRole(WindowsBuiltInRole.Administrator);
var isDebug = Debugger.IsAttached;

string processor = "Unknown";
try
{
processor = new ManagementObjectSearcher("SELECT Name FROM Win32_Processor")
.Get()
.OfType<ManagementObject>()
.FirstOrDefault()?["Name"]?.ToString() ?? "Unknown";
}
catch (Exception ex)
{
Log.Warning("Failed to retrieve processor info: {Error}", ex.Message);
}

string videoController = "Unknown";
try
{
videoController = new ManagementObjectSearcher("SELECT Name FROM Win32_VideoController")
.Get()
.OfType<ManagementObject>()
.FirstOrDefault()?["Name"]?.ToString() ?? "Unknown";
}
catch (Exception ex)
{
Log.Warning("Failed to retrieve video controller info: {Error}", ex.Message);
}

var activeNetworks = NetworkInterface.GetAllNetworkInterfaces()
.Where(nic => nic.OperationalStatus == OperationalStatus.Up)
.Select(nic => nic.Name)
.ToList();

Log.Information("OS Version: {OSVersion} - {OSArchitecture} | Processor: {Processor} | Video: {VideoController} | Is Admin: {IsAdmin} | Is Debug: {IsDebug} | Active Networks: {ActiveNetworks}",
osVersion, osArchitecture, processor, videoController, isAdmin, isDebug, string.Join(", ", activeNetworks));
}
catch (Exception ex)
{
Log.Error("An unexpected error occurred in LogSystemInfo: {Error}", ex.Message);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ private void OnReceive(IAsyncResult ar)
}

Socket socket = (Socket) ar.AsyncState;
socket?.EndReceive(ar);

try
{
Expand Down
4 changes: 2 additions & 2 deletions src/StatisticsAnalysisTool/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@
// Sie können alle Werte angeben oder Standardwerte für die Build- und Revisionsnummern verwenden,
// indem Sie "*" wie unten gezeigt eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("7.8.2.*")]
[assembly: AssemblyFileVersion("7.8.2.0")]
[assembly: AssemblyVersion("7.8.3.*")]
[assembly: AssemblyFileVersion("7.8.3.0")]

0 comments on commit 5427878

Please sign in to comment.