Skip to content

Commit

Permalink
Preparing Backgroundog
Browse files Browse the repository at this point in the history
  • Loading branch information
Taiizor committed Sep 21, 2023
1 parent 2e7740d commit 6373847
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 171 deletions.
22 changes: 13 additions & 9 deletions src/Shared/Engine/Sucrose.Shared.Engine/Helper/Compatible.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,35 @@ namespace Sucrose.Shared.Engine.Helper
{
internal static class Compatible
{
public static void ExecuteNormal(SESMIEN Function)
public static async void ExecuteNormal(SESMIEN Function)
{
if (SSEMI.Initialized)
{
_ = Task.Run(SSEHS.GetSystem);

if (!string.IsNullOrEmpty(SSEMI.Compatible.LoopMode))
{
Function(string.Format(SSEMI.Compatible.LoopMode, SSEHD.GetLoop()));
}

if (!string.IsNullOrEmpty(SSEMI.Compatible.SystemCpu))
{
Function(string.Format(SSEMI.Compatible.SystemCpu, SSEHS.GetSystemCpu()));
Function(string.Format(SSEMI.Compatible.SystemCpu, SSEMI.CpuData));
}

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

if (!string.IsNullOrEmpty(SSEMI.Compatible.SystemDate))
{
Function(string.Format(SSEMI.Compatible.SystemDate, SSEHS.GetSystemDate()));
Function(string.Format(SSEMI.Compatible.SystemDate, SSEMI.DateData));
}

if (!string.IsNullOrEmpty(SSEMI.Compatible.SystemAudio))
{
Function(string.Format(SSEMI.Compatible.SystemAudio, SSEHS.GetSystemAudio()));
Function(string.Format(SSEMI.Compatible.SystemAudio, SSEMI.AudioData));
}

if (!string.IsNullOrEmpty(SSEMI.Compatible.VolumeLevel))
Expand All @@ -54,24 +56,26 @@ public static void ExecuteNormal(SESMIEN Function)

if (!string.IsNullOrEmpty(SSEMI.Compatible.SystemMemory))
{
Function(string.Format(SSEMI.Compatible.SystemMemory, SSEHS.GetSystemMemory()));
Function(string.Format(SSEMI.Compatible.SystemMemory, SSEMI.MemoryData));
}

if (!string.IsNullOrEmpty(SSEMI.Compatible.SystemBattery))
{
Function(string.Format(SSEMI.Compatible.SystemBattery, SSEHS.GetSystemBattery()));
Function(string.Format(SSEMI.Compatible.SystemBattery, SSEMI.BatteryData));
}

if (!string.IsNullOrEmpty(SSEMI.Compatible.SystemNetwork))
{
Function(string.Format(SSEMI.Compatible.SystemNetwork, SSEHS.GetSystemNetwork()));
Function(string.Format(SSEMI.Compatible.SystemNetwork, SSEMI.NetworkData));
}

if (!string.IsNullOrEmpty(SSEMI.Compatible.SystemMotherboard))
{
Function(string.Format(SSEMI.Compatible.SystemMotherboard, SSEHS.GetSystemMotherboard()));
Function(string.Format(SSEMI.Compatible.SystemMotherboard, SSEMI.MotherboardData));
}
}

await Task.CompletedTask;
}

public static void ExecuteTask(SESMIET Function)
Expand Down
217 changes: 55 additions & 162 deletions src/Shared/Engine/Sucrose.Shared.Engine/Helper/System.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,180 +10,73 @@ namespace Sucrose.Shared.Engine.Helper
{
internal static class System
{
public static string GetSystemCpu()
public static async void GetSystem()
{
if (SSSHP.Work(SMR.Backgroundog))
{
try
{
SGSGSS.ChannelCreate($"{SSEMM.Host}", SSEMM.Port);
SSEMI.Client = new(SGSGSS.ChannelInstance);

BackgroundogCpuResponse Response = SGCSBCS.GetCpu(SSEMI.Client);

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

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))
{
try
{
SGSGSS.ChannelCreate($"{SSEMM.Host}", SSEMM.Port);
SSEMI.Client = new(SGSGSS.ChannelInstance);

BackgroundogDateResponse Response = SGCSBCS.GetDate(SSEMI.Client);

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

return string.Empty;
}

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

BackgroundogAudioResponse Response = SGCSBCS.GetAudio(SSEMI.Client);

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

return string.Empty;
}

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

BackgroundogMemoryResponse Response = SGCSBCS.GetMemory(SSEMI.Client);

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

return string.Empty;
}

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

BackgroundogBatteryResponse Response = SGCSBCS.GetBattery(SSEMI.Client);

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

return string.Empty;
}

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

BackgroundogNetworkResponse Response = SGCSBCS.GetNetwork(SSEMI.Client);

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

return string.Empty;
}

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

BackgroundogMotherboardResponse Response = SGCSBCS.GetMotherboard(SSEMI.Client);

return Response.Info;
if (SSEMI.Client == null)
{
SGSGSS.ChannelCreate($"{SSEMM.Host}", SSEMM.Port);
SSEMI.Client = new(SGSGSS.ChannelInstance);
}

_ = Task.Run(() =>
{
BackgroundogCpuResponse Response = SGCSBCS.GetCpu(SSEMI.Client);
SSEMI.CpuData = Response.Info;
});

_ = Task.Run(() =>
{
BackgroundogBiosResponse Response = SGCSBCS.GetBios(SSEMI.Client);
SSEMI.BiosData = Response.Info;
});

_ = Task.Run(() =>
{
BackgroundogDateResponse Response = SGCSBCS.GetDate(SSEMI.Client);
SSEMI.DateData = Response.Info;
});

_ = Task.Run(() =>
{
BackgroundogAudioResponse Response = SGCSBCS.GetAudio(SSEMI.Client);
SSEMI.AudioData = Response.Info;
});

_ = Task.Run(() =>
{
BackgroundogMemoryResponse Response = SGCSBCS.GetMemory(SSEMI.Client);
SSEMI.MemoryData = Response.Info;
});

_ = Task.Run(() =>
{
BackgroundogBatteryResponse Response = SGCSBCS.GetBattery(SSEMI.Client);
SSEMI.BatteryData = Response.Info;
});

_ = Task.Run(() =>
{
BackgroundogNetworkResponse Response = SGCSBCS.GetNetwork(SSEMI.Client);
SSEMI.NetworkData = Response.Info;
});

_ = Task.Run(() =>
{
BackgroundogMotherboardResponse Response = SGCSBCS.GetMotherboard(SSEMI.Client);
SSEMI.MotherboardData = Response.Info;
});
}
catch
{
//
}
}

return string.Empty;
await Task.CompletedTask;
}
}
}
16 changes: 16 additions & 0 deletions src/Shared/Engine/Sucrose.Shared.Engine/Manage/Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,24 @@ internal static class Internal

public static SSTHC Compatible = new();

public static string CpuData = string.Empty;

public static string BiosData = string.Empty;

public static string DateData = string.Empty;

public static string AudioData = string.Empty;

public static string MemoryData = string.Empty;

public static string NetworkData = string.Empty;

public static string BatteryData = string.Empty;

public delegate void ExecuteNormal(string Script);

public static string MotherboardData = string.Empty;

public delegate Task<string> ExecuteTask(string script);

public static readonly DispatcherTimer GeneralTimer = new();
Expand Down

0 comments on commit 6373847

Please sign in to comment.