Skip to content

Commit

Permalink
Preparing Backgroundog
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Sep 18, 2023
1 parent 68663d7 commit 7e6d4af
Show file tree
Hide file tree
Showing 10 changed files with 156 additions and 45 deletions.
2 changes: 2 additions & 0 deletions src/Library/Sucrose.Manager/Manage/Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public static class Manager

public static int TitleLength => SHS.Clamp(SMMI.PortalSettingManager.GetSettingStable(SMC.TitleLength, 25), 10, 100);

public static string GraphicAdapter => SMMI.BackgroundogSettingManager.GetSetting(SMC.GraphicAdapter, string.Empty);

public static string NetworkAdapter => SMMI.BackgroundogSettingManager.GetSetting(SMC.NetworkAdapter, string.Empty);

public static bool PerformanceCounter => SMMI.BackgroundogSettingManager.GetSetting(SMC.PerformanceCounter, true);
Expand Down
2 changes: 2 additions & 0 deletions src/Library/Sucrose.Memory/Constant.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ public static class Constant

public const string DiscordRefresh = "DiscordRefresh";

public const string GraphicAdapter = "GraphicAdapter";

public const string NetworkAdapter = "NetworkAdapter";

public const string StorePagination = "StorePagination";
Expand Down
10 changes: 5 additions & 5 deletions src/Project/Sucrose.Backgroundog/Extension/Data.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public static JObject GetMemoryInfo()
{
return new JObject
{
{ "Name", SBMI.CpuData.Name },
{ "Name", SBMI.MemoryData.Name },
{ "MemoryUsed", SBMI.MemoryData.MemoryUsed },
{ "MemoryLoad", SBMI.MemoryData.MemoryLoad },
{ "MemoryAvailable", SBMI.MemoryData.MemoryAvailable },
Expand Down Expand Up @@ -85,17 +85,17 @@ public static JObject GetNetworkInfo()
{
{ "Text", SBMI.NetworkData.UploadData.Text },
{ "Value", SBMI.NetworkData.UploadData.Value },
{ "Type", SBMI.NetworkData.UploadData.Type.ToString() },
{ "Short", SBMI.NetworkData.UploadData.Short.ToString() },
{ "Type", $"{SBMI.NetworkData.UploadData.Type}" },
{ "Short", $"{SBMI.NetworkData.UploadData.Short}" }
}
},
{
"DownloadData", new JObject
{
{ "Text", SBMI.NetworkData.DownloadData.Text },
{ "Value", SBMI.NetworkData.DownloadData.Value },
{ "Type", SBMI.NetworkData.DownloadData.Type.ToString() },
{ "Short", SBMI.NetworkData.DownloadData.Short.ToString() },
{ "Type", $"{SBMI.NetworkData.DownloadData.Type}" },
{ "Short", $"{SBMI.NetworkData.DownloadData.Short}" }
}
},
};
Expand Down
51 changes: 26 additions & 25 deletions src/Project/Sucrose.Backgroundog/Helper/Specification.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ public static async Task Start()
if (SBMI.Exit)
{
Console.WriteLine("Specification");
//Libredeki cpu, ram, net bilgileri değişkene atılacak

SBMI.Computer.Accept(new UpdateVisitor());

Expand All @@ -42,25 +41,9 @@ public static async Task Start()
Thread = SBMI.CpuData.Thread,
Fullname = SBMI.CpuData.Fullname
};
}
}

if (SBMI.CpuManagement)
{
SBMI.CpuManagement = false;

_ = Task.Run(() =>
{
ManagementObjectSearcher Searcher = new("SELECT * FROM Win32_Processor");

foreach (ManagementObject Object in Searcher.Get().Cast<ManagementObject>())
{
SBMI.CpuData.Core = Convert.ToInt32(Object["NumberOfCores"]);
SBMI.CpuData.Fullname = Object["Name"].ToString().TrimStart().TrimEnd();
SBMI.CpuData.Thread = Convert.ToInt32(Object["NumberOfLogicalProcessors"]);
break;
}
});
break;
}
}
}
else if (Hardware.HardwareType == HardwareType.Memory)
Expand Down Expand Up @@ -164,6 +147,24 @@ public static async Task Start()
}
}

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

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

foreach (ManagementObject Object in Searcher.Get().Cast<ManagementObject>())
{
SBMI.CpuData.Core = Convert.ToInt32(Object["NumberOfCores"]);
SBMI.CpuData.Fullname = Object["Name"].ToString().TrimStart().TrimEnd();
SBMI.CpuData.Thread = Convert.ToInt32(Object["NumberOfLogicalProcessors"]);
break;
}
}
});

_ = Task.Run(() =>
{
foreach (string Name in SSSHN.InstanceNetworkInterfaces())
Expand Down Expand Up @@ -192,12 +193,12 @@ public static async Task Start()
}
});

//Console.WriteLine(JsonConvert.SerializeObject(Data.GetCpuInfo(), Formatting.Indented));
//Console.WriteLine(JsonConvert.SerializeObject(Data.GetDateInfo(), Formatting.Indented));
//Console.WriteLine(JsonConvert.SerializeObject(Data.GetMemoryInfo(), Formatting.Indented));
//Console.WriteLine(JsonConvert.SerializeObject(Data.GetBatteryInfo(), Formatting.Indented));
Console.WriteLine(JsonConvert.SerializeObject(Data.GetNetworkInfo(), Formatting.Indented));
//Console.WriteLine(JsonConvert.SerializeObject(Data.GetMotherboardInfo(), Formatting.Indented));
Console.WriteLine("Cpu" + Environment.NewLine + JsonConvert.SerializeObject(Data.GetCpuInfo(), Formatting.Indented));
Console.WriteLine("Date" + Environment.NewLine + JsonConvert.SerializeObject(Data.GetDateInfo(), Formatting.Indented));
Console.WriteLine("Memory" + Environment.NewLine + JsonConvert.SerializeObject(Data.GetMemoryInfo(), Formatting.Indented));
Console.WriteLine("Battery" + Environment.NewLine + JsonConvert.SerializeObject(Data.GetBatteryInfo(), Formatting.Indented));
Console.WriteLine("Network" + Environment.NewLine + JsonConvert.SerializeObject(Data.GetNetworkInfo(), Formatting.Indented));
Console.WriteLine("Motherboard" + Environment.NewLine + JsonConvert.SerializeObject(Data.GetMotherboardInfo(), Formatting.Indented));

//foreach (IHardware Hardware in SBMI.Computer.Hardware)
//{
Expand Down
12 changes: 5 additions & 7 deletions src/Project/Sucrose.Backgroundog/Manage/Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ internal static class Internal
{
public static bool Exit = true;

public static bool State = true;

public static bool Condition = false;

public static bool Processing = true;
Expand Down Expand Up @@ -51,15 +49,15 @@ internal static class Internal

public static Computer Computer = new()
{
IsCpuEnabled = false,
IsGpuEnabled = true,
IsCpuEnabled = true,
IsGpuEnabled = false,
IsPsuEnabled = false,
IsMemoryEnabled = false,
IsMemoryEnabled = true,
IsBatteryEnabled = true,
IsNetworkEnabled = false,
IsStorageEnabled = false,
IsBatteryEnabled = false,
IsControllerEnabled = false,
IsMotherboardEnabled = false,
IsMotherboardEnabled = true,
};

public static SBSDBS BatteryData = new()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,41 @@
using Grpc.Core;
using Sucrose.Grpc.Common;
using static Sucrose.Grpc.Common.Backgroundog;
using SBMI = Sucrose.Backgroundog.Manage.Internal;
using SBED = Sucrose.Backgroundog.Extension.Data;
using Newtonsoft.Json;

namespace Sucrose.Shared.Server.Services
{
public class BackgroundogServerService : BackgroundogBase
{
public override Task<BackgroundogStateResponse> StateBackgroundog(Empty _, ServerCallContext Context)
public override Task<BackgroundogMotherboardResponse> MotherboardBackgroundog(Empty _, ServerCallContext Context)
{
return Task.FromResult(new BackgroundogStateResponse { State = SBMI.State });
return Task.FromResult(new BackgroundogMotherboardResponse { Info = JsonConvert.SerializeObject(SBED.GetMotherboardInfo(), Formatting.Indented) });
}

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

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

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

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

public override Task<BackgroundogCpuResponse> CpuBackgroundog(Empty _, ServerCallContext Context)
{
return Task.FromResult(new BackgroundogCpuResponse { Info = JsonConvert.SerializeObject(SBED.GetCpuInfo(), Formatting.Indented) });
}
}
}
Expand Down
21 changes: 21 additions & 0 deletions src/Shared/Sucrose.Shared.Space/Helper/Graphic.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Management;

namespace Sucrose.Shared.Space.Helper
{
internal static class Graphic
{
public static List<string> AllVideoController()
{
List<string> Names = new();

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

foreach (ManagementObject Object in Searcher.Get().Cast<ManagementObject>())
{
Names.Add(Object["Name"].ToString().TrimStart().TrimEnd());
}

return Names;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Helper\Copy.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helper\Graphic.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helper\Network.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helper\Clean.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helper\Size.cs" />
Expand Down
39 changes: 37 additions & 2 deletions src/gRPC/Sucrose.Grpc.Client/Services/BackgroundogClientService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,44 @@ namespace Sucrose.Grpc.Client.Services
{
public static class BackgroundogClientService
{
public static BackgroundogStateResponse GetState(BackgroundogClient Client)
public static BackgroundogMotherboardResponse GetMotherboard(BackgroundogClient Client)
{
BackgroundogStateResponse Response = Client.StateBackgroundog(new Empty());
BackgroundogMotherboardResponse Response = Client.MotherboardBackgroundog(new Empty());

return Response;
}

public static BackgroundogNetworkResponse GetNetwork(BackgroundogClient Client)
{
BackgroundogNetworkResponse Response = Client.NetworkBackgroundog(new Empty());

return Response;
}

public static BackgroundogBatteryResponse GetBattery(BackgroundogClient Client)
{
BackgroundogBatteryResponse Response = Client.BatteryBackgroundog(new Empty());

return Response;
}

public static BackgroundogMemoryResponse GetMemory(BackgroundogClient Client)
{
BackgroundogMemoryResponse Response = Client.MemoryBackgroundog(new Empty());

return Response;
}

public static BackgroundogDateResponse GetDate(BackgroundogClient Client)
{
BackgroundogDateResponse Response = Client.DateBackgroundog(new Empty());

return Response;
}

public static BackgroundogCpuResponse GetCpu(BackgroundogClient Client)
{
BackgroundogCpuResponse Response = Client.CpuBackgroundog(new Empty());

return Response;
}
Expand Down
31 changes: 28 additions & 3 deletions src/gRPC/Sucrose.Grpc.Common/Proto/Backgroundog.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,34 @@ option csharp_namespace = "Sucrose.Grpc.Common";
import "google/protobuf/empty.proto";

service Backgroundog {
rpc StateBackgroundog (google.protobuf.Empty) returns (BackgroundogStateResponse);
rpc MotherboardBackgroundog (google.protobuf.Empty) returns (BackgroundogMotherboardResponse);
rpc NetworkBackgroundog (google.protobuf.Empty) returns (BackgroundogNetworkResponse);
rpc BatteryBackgroundog (google.protobuf.Empty) returns (BackgroundogBatteryResponse);
rpc MemoryBackgroundog (google.protobuf.Empty) returns (BackgroundogMemoryResponse);
rpc DateBackgroundog (google.protobuf.Empty) returns (BackgroundogDateResponse);
rpc CpuBackgroundog (google.protobuf.Empty) returns (BackgroundogCpuResponse);
}

message BackgroundogStateResponse {
bool state = 1;
message BackgroundogMotherboardResponse {
string info = 1;
}

message BackgroundogNetworkResponse {
string info = 1;
}

message BackgroundogBatteryResponse {
string info = 1;
}

message BackgroundogMemoryResponse {
string info = 1;
}

message BackgroundogDateResponse {
string info = 1;
}

message BackgroundogCpuResponse {
string info = 1;
}

0 comments on commit 7e6d4af

Please sign in to comment.