Skip to content

Commit

Permalink
Preparing Backgroundog
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Sep 19, 2023
1 parent b5ef1f8 commit 94b647b
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 13 deletions.
14 changes: 14 additions & 0 deletions src/Project/Sucrose.Backgroundog/Extension/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,20 @@ public static JObject GetCpuInfo()
{ "Fullname", SBMI.CpuData.Fullname }
};
}
public static JObject GetBiosInfo()
{
return new JObject
{
{ "Name", SBMI.BiosData.Name },
{ "Caption", SBMI.BiosData.Caption },
{ "Version", SBMI.BiosData.Version },
{ "Description", SBMI.BiosData.Description },
{ "ReleaseDate", SBMI.BiosData.ReleaseDate },
{ "Manufacturer", SBMI.BiosData.Manufacturer },
{ "SerialNumber", SBMI.BiosData.SerialNumber },
{ "CurrentLanguage", SBMI.BiosData.CurrentLanguage }
};
}

public static JObject GetDateInfo()
{
Expand Down
23 changes: 23 additions & 0 deletions src/Project/Sucrose.Backgroundog/Helper/Specification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,29 @@ public static async Task Start()
}
});

_ = Task.Run(() =>
{
if (SBMI.BiosManagement)
{
SBMI.BiosManagement = false;

ManagementObjectSearcher Searcher = new("SELECT * FROM Win32_BIOS");

foreach (ManagementObject Object in Searcher.Get().Cast<ManagementObject>())
{
SBMI.BiosData.Name = Object["Name"].ToString();
SBMI.BiosData.Caption = Object["Caption"].ToString();
SBMI.BiosData.Version = Object["Version"].ToString();
SBMI.BiosData.Description = Object["Description"].ToString();
SBMI.BiosData.ReleaseDate = Object["ReleaseDate"].ToString();
SBMI.BiosData.Manufacturer = Object["Manufacturer"].ToString();
SBMI.BiosData.SerialNumber = Object["SerialNumber"].ToString();
SBMI.BiosData.CurrentLanguage = Object["CurrentLanguage"].ToString();
break;
}
}
});

_ = Task.Run(() =>
{
foreach (string Name in SSSHN.InstanceNetworkInterfaces())
Expand Down
41 changes: 28 additions & 13 deletions src/Project/Sucrose.Backgroundog/Manage/Internal.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
using LibreHardwareMonitor.Hardware;
using System.Diagnostics;
using SBHI = Sucrose.Backgroundog.Helper.Initialize;
using SBSDBS = Sucrose.Backgroundog.Struct.Data.BatteryStruct;
using SBSDBSS = Sucrose.Backgroundog.Struct.Data.BiosStruct;
using SBSDBYS = Sucrose.Backgroundog.Struct.Data.BatteryStruct;
using SBSDCS = Sucrose.Backgroundog.Struct.Data.CpuStruct;
using SBSDMDS = Sucrose.Backgroundog.Struct.Data.MotherboardStruct;
using SBSDMYS = Sucrose.Backgroundog.Struct.Data.MemoryStruct;
Expand All @@ -22,6 +23,8 @@ internal static class Internal

public static bool CpuManagement = true;

public static bool BiosManagement = true;

public static Timer InitializeTimer = null;

public static PerformanceCounter UploadCounter = null;
Expand All @@ -39,6 +42,18 @@ internal static class Internal
Fullname = string.Empty
};

public static SBSDBSS BiosData = new()
{
Name = string.Empty,
Caption = string.Empty,
Version = string.Empty,
Description = string.Empty,
ReleaseDate = string.Empty,
Manufacturer = string.Empty,
SerialNumber = string.Empty,
CurrentLanguage = string.Empty
};

public static SBSDMYS MemoryData = new()
{
MemoryUsed = 0f,
Expand All @@ -63,7 +78,18 @@ internal static class Internal
IsMotherboardEnabled = true,
};

public static SBSDBS BatteryData = new()
public static SBSDNS NetworkData = new()
{
Upload = 0f,
Download = 0f,
UploadData = new(),
Name = string.Empty,
DownloadData = new(),
FormatUploadData = string.Empty,
FormatDownloadData = string.Empty
};

public static SBSDBYS BatteryData = new()
{
Voltage = 0f,
ChargeRate = 0f,
Expand All @@ -82,17 +108,6 @@ internal static class Internal
RemainingTimeEstimated = 0f
};

public static SBSDNS NetworkData = new()
{
Upload = 0f,
Download = 0f,
UploadData = new(),
Name = string.Empty,
DownloadData = new(),
FormatUploadData = string.Empty,
FormatDownloadData = string.Empty
};

public static SBSDMDS MotherboardData = new()
{
Name = string.Empty
Expand Down
40 changes: 40 additions & 0 deletions src/Project/Sucrose.Backgroundog/Struct/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,46 @@ public struct CpuStruct
public string Fullname;
}

/// <summary>
///
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct BiosStruct
{
/// <summary>
///
/// </summary>
public string Name;
/// <summary>
///
/// </summary>
public string Caption;
/// <summary>
///
/// </summary>
public string Version;
/// <summary>
///
/// </summary>
public string Description;
/// <summary>
///
/// </summary>
public string ReleaseDate;
/// <summary>
///
/// </summary>
public string Manufacturer;
/// <summary>
///
/// </summary>
public string SerialNumber;
/// <summary>
///
/// </summary>
public string CurrentLanguage;
}

/// <summary>
///
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/Shared/Engine/Sucrose.Shared.Engine/Helper/Compatible.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public static void ExecuteNormal(SESMIEN Function)
Function(string.Format(SSEMI.Compatible.SystemCpu, SSEHS.GetSystemCpu()));
}

if (!string.IsNullOrEmpty(SSEMI.Compatible.SystemBios))
{
Function(string.Format(SSEMI.Compatible.SystemBios, SSEHS.GetSystemBios()));
}

if (!string.IsNullOrEmpty(SSEMI.Compatible.SystemDate))
{
Function(string.Format(SSEMI.Compatible.SystemDate, SSEHS.GetSystemDate()));
Expand Down
22 changes: 22 additions & 0 deletions src/Shared/Engine/Sucrose.Shared.Engine/Helper/System.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,28 @@ public static string GetSystemCpu()
return string.Empty;
}

public static string GetSystemBios()
{
if (SSSHP.Work(SMR.Backgroundog))
{
try
{
SGSGSS.ChannelCreate($"{SSEMM.Host}", SSEMM.Port);
SSEMI.Client = new(SGSGSS.ChannelInstance);

BackgroundogBiosResponse Response = SGCSBCS.GetBios(SSEMI.Client);

return Response.Info;
}
catch
{
//
}
}

return string.Empty;
}

public static string GetSystemDate()
{
if (SSSHP.Work(SMR.Backgroundog))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public enum CompatibilityType
/// </summary>
InvalidUrl,
/// <summary>
/// Geçersiz sistem bios değeri!
/// </summary>
SystemBios,
/// <summary>
/// Geçersiz sistem zamanı değeri!
/// </summary>
SystemDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ public override Task<BackgroundogDateResponse> DateBackgroundog(Empty _, ServerC
return Task.FromResult(new BackgroundogDateResponse { Info = JsonConvert.SerializeObject(SBED.GetDateInfo(), Formatting.Indented) });
}

public override Task<BackgroundogBiosResponse> BiosBackgroundog(Empty _, ServerCallContext Context)
{
return Task.FromResult(new BackgroundogBiosResponse { Info = JsonConvert.SerializeObject(SBED.GetBiosInfo(), Formatting.Indented) });
}

public override Task<BackgroundogCpuResponse> CpuBackgroundog(Empty _, ServerCallContext Context)
{
return Task.FromResult(new BackgroundogCpuResponse { Info = JsonConvert.SerializeObject(SBED.GetCpuInfo(), Formatting.Indented) });
Expand Down
3 changes: 3 additions & 0 deletions src/Shared/Sucrose.Shared.Theme/Helper/Compatible.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ internal partial class Compatible
[JsonProperty("SystemCpu", Required = Required.Default)]
public string SystemCpu { get; set; }

[JsonProperty("SystemBios", Required = Required.Default)]
public string SystemBios { get; set; }

[JsonProperty("SystemDate", Required = Required.Default)]
public string SystemDate { get; set; }

Expand Down
6 changes: 6 additions & 0 deletions src/Shared/Sucrose.Shared.Theme/Helper/Zip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,12 @@ public static SSDECT Check(string Archive)
return SSDECT.SystemCpu;
}

// Compatible içindeki SystemBios değeri boş değil ve {0} içermiyor mu?
if (!string.IsNullOrEmpty(Compatible.SystemBios) && !Compatible.SystemBios.Contains("{0}"))
{
return SSDECT.SystemBios;
}

// Compatible içindeki SystemDate değeri boş değil ve {0} içermiyor mu?
if (!string.IsNullOrEmpty(Compatible.SystemDate) && !Compatible.SystemDate.Contains("{0}"))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ public static BackgroundogDateResponse GetDate(BackgroundogClient Client)
return Response;
}

public static BackgroundogBiosResponse GetBios(BackgroundogClient Client)
{
BackgroundogBiosResponse Response = Client.BiosBackgroundog(new Empty());

return Response;
}

public static BackgroundogCpuResponse GetCpu(BackgroundogClient Client)
{
BackgroundogCpuResponse Response = Client.CpuBackgroundog(new Empty());
Expand Down
5 changes: 5 additions & 0 deletions src/gRPC/Sucrose.Grpc.Common/Proto/Backgroundog.proto
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ service Backgroundog {
rpc BatteryBackgroundog (google.protobuf.Empty) returns (BackgroundogBatteryResponse);
rpc MemoryBackgroundog (google.protobuf.Empty) returns (BackgroundogMemoryResponse);
rpc DateBackgroundog (google.protobuf.Empty) returns (BackgroundogDateResponse);
rpc BiosBackgroundog (google.protobuf.Empty) returns (BackgroundogBiosResponse);
rpc CpuBackgroundog (google.protobuf.Empty) returns (BackgroundogCpuResponse);
}

Expand All @@ -34,6 +35,10 @@ message BackgroundogDateResponse {
string info = 1;
}

message BackgroundogBiosResponse {
string info = 1;
}

message BackgroundogCpuResponse {
string info = 1;
}

0 comments on commit 94b647b

Please sign in to comment.