Add project files.

This commit is contained in:
Admin
2024-09-02 10:03:23 +07:00
parent 42def0d4aa
commit 6219298497
361 changed files with 58423 additions and 0 deletions
@@ -0,0 +1,69 @@
using HandyControl.Tools.Extension;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
namespace SafeBagDE70.Admin
{
/// <summary>
/// Interaction logic for AdminWindow.xaml
/// </summary>
public partial class AdminWindow : HandyControl.Controls.Window
{
LogViewerUC loguc;
AdminConfigurationUC configuration;
public AdminWindow()
{
InitializeComponent();
loguc= new LogViewerUC();
configuration = new AdminConfigurationUC();
this.MainContentControl.Content = loguc;
this.Loaded += AdminWindow_Loaded;
}
private void AdminWindow_Loaded(object sender, RoutedEventArgs e)
{
lblStatus.DataContext = AppData.CDMSTATE;
}
private void LogoutButton_Click(object sender, RoutedEventArgs e)
{
}
private void UserManagementButton_Click(object sender, RoutedEventArgs e)
{
}
private void DashboardButton_Click(object sender, RoutedEventArgs e)
{
this.MainContentControl.Content = loguc;
}
private void SettingsButton_Click(object sender, RoutedEventArgs e)
{
}
private void ReportsButton_Click(object sender, RoutedEventArgs e)
{
}
private void ConfigurationButton_Click(object sender, RoutedEventArgs e)
{
this.MainContentControl.Content = configuration;
}
}
}
@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Management;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace SafeBagDE70.Services
{
public static class HardwareInforManager
{
public static string GetHardwareId()
{
string cpuId = GetCpuId();
string biosId = GetBiosId();
string motherboardId = GetMotherboardId();
// Combine the strings and create a hash
string combined = cpuId + biosId + motherboardId;
string hardwareId = CreateMD5Hash(combined);
return hardwareId;
}
public static string GetCpuId()
{
return GetHardwareInfo("Win32_Processor", "ProcessorId");
}
public static string GetBiosId()
{
return GetHardwareInfo("Win32_BIOS", "SerialNumber");
}
public static string GetMotherboardId()
{
return GetHardwareInfo("Win32_BaseBoard", "SerialNumber");
}
private static string GetHardwareInfo(string wmiClass, string wmiProperty)
{
try
{
ManagementObjectSearcher searcher = new ManagementObjectSearcher($"select {wmiProperty} from {wmiClass}");
foreach (ManagementObject obj in searcher.Get())
{
return obj[wmiProperty]?.ToString() ?? string.Empty;
}
}
catch (Exception ex)
{
throw new Exception($"Failed to retrieve {wmiClass} {wmiProperty}: " + ex.Message);
}
return string.Empty;
}
private static string CreateMD5Hash(string input)
{
using (MD5 md5 = MD5.Create())
{
byte[] inputBytes = Encoding.ASCII.GetBytes(input);
byte[] hashBytes = md5.ComputeHash(inputBytes);
return string.Join("", hashBytes.Select(b => b.ToString("X2")));
}
}
}
}