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 26b9127 commit 4634e13
Show file tree
Hide file tree
Showing 22 changed files with 106 additions and 36 deletions.
1 change: 1 addition & 0 deletions src/Live/Sucrose.Live.Aurora/Sucrose.Live.Aurora.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
</ItemGroup>

<Import Project="..\..\Shared\Sucrose.Shared.Zip\Sucrose.Shared.Zip.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Live\Sucrose.Shared.Live.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Space\Sucrose.Shared.Space.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Theme\Sucrose.Shared.Theme.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Watchdog\Sucrose.Shared.Watchdog.projitems" Label="Shared" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
</ItemGroup>

<Import Project="..\..\Shared\Sucrose.Shared.Zip\Sucrose.Shared.Zip.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Live\Sucrose.Shared.Live.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Space\Sucrose.Shared.Space.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Theme\Sucrose.Shared.Theme.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Watchdog\Sucrose.Shared.Watchdog.projitems" Label="Shared" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
</ItemGroup>

<Import Project="..\..\Shared\Sucrose.Shared.Zip\Sucrose.Shared.Zip.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Live\Sucrose.Shared.Live.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Space\Sucrose.Shared.Space.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Theme\Sucrose.Shared.Theme.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Watchdog\Sucrose.Shared.Watchdog.projitems" Label="Shared" />
Expand Down
1 change: 1 addition & 0 deletions src/Live/Sucrose.Live.Nebula/Sucrose.Live.Nebula.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
</ItemGroup>

<Import Project="..\..\Shared\Sucrose.Shared.Zip\Sucrose.Shared.Zip.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Live\Sucrose.Shared.Live.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Space\Sucrose.Shared.Space.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Theme\Sucrose.Shared.Theme.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Watchdog\Sucrose.Shared.Watchdog.projitems" Label="Shared" />
Expand Down
1 change: 1 addition & 0 deletions src/Live/Sucrose.Live.Vexana/Sucrose.Live.Vexana.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
</ItemGroup>

<Import Project="..\..\Shared\Sucrose.Shared.Zip\Sucrose.Shared.Zip.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Live\Sucrose.Shared.Live.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Space\Sucrose.Shared.Space.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Theme\Sucrose.Shared.Theme.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Watchdog\Sucrose.Shared.Watchdog.projitems" Label="Shared" />
Expand Down
1 change: 1 addition & 0 deletions src/Live/Sucrose.Live.WebView/Sucrose.Live.WebView.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
</ItemGroup>

<Import Project="..\..\Shared\Sucrose.Shared.Zip\Sucrose.Shared.Zip.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Live\Sucrose.Shared.Live.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Space\Sucrose.Shared.Space.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Theme\Sucrose.Shared.Theme.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Watchdog\Sucrose.Shared.Watchdog.projitems" Label="Shared" />
Expand Down
11 changes: 1 addition & 10 deletions src/Project/Sucrose.Backgroundog/Helper/Attempt.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
using System.Diagnostics;
using SBEL = Sucrose.Backgroundog.Extension.Lifecycle;
using SBMI = Sucrose.Backgroundog.Manage.Internal;
using SMR = Sucrose.Memory.Readonly;
using SBMI = Sucrose.Backgroundog.Manage.Internal;
using SSSHL = Sucrose.Shared.Space.Helper.Live;
using SSSHM = Sucrose.Shared.Space.Helper.Management;

namespace Sucrose.Backgroundog.Helper
{
Expand All @@ -24,11 +20,6 @@ public static async Task Start()
await Task.Delay(TimeSpan.FromSeconds(IntervalSeconds));
}

Process.GetProcesses()
.Where(Process => (Process.ProcessName.Contains(SMR.WebViewProcessName) || Process.ProcessName.Contains(SMR.CefSharpProcessName)) && SSSHM.GetCommandLine(Process).Contains(SMR.AppName))
.ToList()
.ForEach(Process => SBEL.Resume(Process));

SBMI.Exit = false;
SBMI.Initialize.Stop();

Expand Down
24 changes: 17 additions & 7 deletions src/Project/Sucrose.Backgroundog/Helper/Condition.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Skylark.Enum;
using Skylark.Standard.Extension.Storage;
using System.Diagnostics;
using SBEL = Sucrose.Backgroundog.Extension.Lifecycle;
using SBMI = Sucrose.Backgroundog.Manage.Internal;
using SBMM = Sucrose.Backgroundog.Manage.Manager;
using SMMM = Sucrose.Manager.Manage.Manager;
Expand All @@ -10,9 +9,11 @@
using SSDENPT = Sucrose.Shared.Dependency.Enum.NetworkPerformanceType;
using SSDEPT = Sucrose.Shared.Dependency.Enum.PerformanceType;
using SSLHR = Sucrose.Shared.Live.Helper.Run;
using SSSEL = Sucrose.Shared.Space.Extension.Lifecycle;
using SSSHL = Sucrose.Shared.Space.Helper.Live;
using SSSHM = Sucrose.Shared.Space.Helper.Management;
using SSSHP = Sucrose.Shared.Space.Helper.Processor;
using SSWW = Sucrose.Shared.Watchdog.Watch;

namespace Sucrose.Backgroundog.Helper
{
Expand Down Expand Up @@ -72,14 +73,23 @@ private static void Lifecycle()

if (SBMI.Live != null && !SBMI.Live.HasExited)
{
SBEL.Resume(SBMI.Live);
SSSEL.Resume(SBMI.Live);

if (SMR.WebViewLive.Contains(SBMI.Live.ProcessName) || SMR.CefSharpLive.Contains(SBMI.Live.ProcessName))
{
Process.GetProcesses()
.Where(Process => (Process.ProcessName.Contains(SMR.WebViewProcessName) || Process.ProcessName.Contains(SMR.CefSharpProcessName)) && SSSHM.GetCommandLine(Process).Contains(SMR.AppName))
.ToList()
.ForEach(Process => SBEL.Resume(Process));
try
{
Process[] Processes = Process.GetProcesses();

Processes
.Where(Process => (Process.ProcessName.Contains(SMR.WebViewProcessName) || Process.ProcessName.Contains(SMR.CefSharpProcessName)) && SSSHM.GetCommandLine(Process).Contains(SMR.AppName))
.ToList()
.ForEach(Process => SSSEL.Resume(Process));
}
catch (Exception Exception)
{
SSWW.Watch_CatchException(Exception);
}
}
}

Expand All @@ -89,7 +99,7 @@ private static void Lifecycle()

if (SBMI.App != null && !SBMI.App.HasExited)
{
SBEL.Resume(SBMI.App);
SSSEL.Resume(SBMI.App);
}
}
}
Expand Down
24 changes: 17 additions & 7 deletions src/Project/Sucrose.Backgroundog/Helper/Performance.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Skylark.Enum;
using Skylark.Standard.Extension.Storage;
using System.Diagnostics;
using SBEL = Sucrose.Backgroundog.Extension.Lifecycle;
using SBMI = Sucrose.Backgroundog.Manage.Internal;
using SBMM = Sucrose.Backgroundog.Manage.Manager;
using SMMM = Sucrose.Manager.Manage.Manager;
Expand All @@ -10,9 +9,11 @@
using SSDENPT = Sucrose.Shared.Dependency.Enum.NetworkPerformanceType;
using SSDEPT = Sucrose.Shared.Dependency.Enum.PerformanceType;
using SSLHK = Sucrose.Shared.Live.Helper.Kill;
using SSSEL = Sucrose.Shared.Space.Extension.Lifecycle;
using SSSHL = Sucrose.Shared.Space.Helper.Live;
using SSSHM = Sucrose.Shared.Space.Helper.Management;
using SSSHP = Sucrose.Shared.Space.Helper.Processor;
using SSWW = Sucrose.Shared.Watchdog.Watch;

namespace Sucrose.Backgroundog.Helper
{
Expand Down Expand Up @@ -62,14 +63,23 @@ private static void Lifecycle()

if (SBMI.Live != null && !SBMI.Live.HasExited)
{
SBEL.Suspend(SBMI.Live);
SSSEL.Suspend(SBMI.Live);

if (SMR.WebViewLive.Contains(SBMI.Live.ProcessName) || SMR.CefSharpLive.Contains(SBMI.Live.ProcessName))
{
Process.GetProcesses()
.Where(Process => (Process.ProcessName.Contains(SMR.WebViewProcessName) || Process.ProcessName.Contains(SMR.CefSharpProcessName)) && SSSHM.GetCommandLine(Process).Contains(SMR.AppName))
.ToList()
.ForEach(Process => SBEL.Suspend(Process));
try
{
Process[] Processes = Process.GetProcesses();

Processes
.Where(Process => (Process.ProcessName.Contains(SMR.WebViewProcessName) || Process.ProcessName.Contains(SMR.CefSharpProcessName)) && SSSHM.GetCommandLine(Process).Contains(SMR.AppName))
.ToList()
.ForEach(Process => SSSEL.Suspend(Process));
}
catch (Exception Exception)
{
SSWW.Watch_CatchException(Exception);
}
}
}

Expand All @@ -79,7 +89,7 @@ private static void Lifecycle()

if (SBMI.App != null && !SBMI.App.HasExited)
{
SBEL.Suspend(SBMI.App);
SSSEL.Suspend(SBMI.App);
}
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/Project/Sucrose.Backgroundog/Manage/Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ internal static class Internal

public static PerformanceCounter DownloadCounter = null;

public static readonly int THREAD_SUSPEND_RESUME = 0x0002;

public static NowPlayingSessionManager SessionManager = null;

public static SBSDCS CpuData = new()
Expand Down
6 changes: 6 additions & 0 deletions src/Project/Sucrose.Commandog/Sucrose.Commandog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,16 @@
<PackageReference Include="Skylark.Wing" Version="3.1.1.3" />
</ItemGroup>

<ItemGroup Condition="$(TargetFramework.StartsWith('net48'))">
<Reference Include="System.Web" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\Library\Sucrose.Manager\Sucrose.Manager.csproj" />
</ItemGroup>

<Import Project="..\..\Shared\Sucrose.Shared.Live\Sucrose.Shared.Live.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Theme\Sucrose.Shared.Theme.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Space\Sucrose.Shared.Space.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Watchdog\Sucrose.Shared.Watchdog.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Dependency\Sucrose.Shared.Dependency.projitems" Label="Shared" />
Expand Down
1 change: 1 addition & 0 deletions src/Project/Sucrose.WPF.CS/Sucrose.WPF.CS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
</ItemGroup>

<Import Project="..\..\Shared\Sucrose.Shared.Zip\Sucrose.Shared.Zip.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Live\Sucrose.Shared.Live.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Space\Sucrose.Shared.Space.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Theme\Sucrose.Shared.Theme.projitems" Label="Shared" />
<Import Project="..\..\Shared\Sucrose.Shared.Server\Sucrose.Shared.Server.projitems" Label="Shared" />
Expand Down
4 changes: 4 additions & 0 deletions src/Shared/Sucrose.Shared.Launcher/Command/Close.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ public static void Command()
{
SSLHK.Stop();
}
else
{
SSLHK.StopSubprocess();
}

if (SSSHP.Work(SMR.Portal))
{
Expand Down
26 changes: 25 additions & 1 deletion src/Shared/Sucrose.Shared.Live/Helper/Kill.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
using SMC = Sucrose.Memory.Constant;
using System.Diagnostics;
using SMC = Sucrose.Memory.Constant;
using SMMI = Sucrose.Manager.Manage.Internal;
using SMMM = Sucrose.Manager.Manage.Manager;
using SMR = Sucrose.Memory.Readonly;
using SSSEL = Sucrose.Shared.Space.Extension.Lifecycle;
using SSSHL = Sucrose.Shared.Space.Helper.Live;
using SSSHM = Sucrose.Shared.Space.Helper.Management;
using SSSHP = Sucrose.Shared.Space.Helper.Processor;
using SWUD = Skylark.Wing.Utility.Desktop;

Expand All @@ -13,6 +17,8 @@ public static void Stop()
{
SSSHL.Kill();

StopSubprocess();

if (!string.IsNullOrEmpty(SMMM.App))
{
SSSHP.Kill(SMMM.App);
Expand All @@ -22,5 +28,23 @@ public static void Stop()

SMMI.AuroraSettingManager.SetSetting(SMC.App, string.Empty);
}

public static void StopSubprocess()
{
try
{
Process[] Processes = Process.GetProcesses();

Processes
.Where(Process => (Process.ProcessName.Contains(SMR.WebViewProcessName) || Process.ProcessName.Contains(SMR.CefSharpProcessName)) && SSSHM.GetCommandLine(Process).Contains(SMR.AppName))
.ToList()
.ForEach(Process =>
{
SSSEL.Resume(Process);
Process.Kill();
});
}
catch { }
}
}
}
3 changes: 3 additions & 0 deletions src/Shared/Sucrose.Shared.Live/Helper/Run.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using SMR = Sucrose.Memory.Readonly;
using SSDECT = Sucrose.Shared.Dependency.Enum.CommandsType;
using SSDEWT = Sucrose.Shared.Dependency.Enum.WallpaperType;
using SSLHK = Sucrose.Shared.Live.Helper.Kill;
using SSLMM = Sucrose.Shared.Live.Manage.Manager;
using SSSHP = Sucrose.Shared.Space.Helper.Processor;
using SSSMI = Sucrose.Shared.Space.Manage.Internal;
Expand All @@ -23,6 +24,8 @@ public static void Start()

if (Info.AppVersion.CompareTo(SHV.Entry()) <= 0)
{
SSLHK.StopSubprocess();

if (SMMM.PerformanceCounter)
{
SSSHP.Run(SSSMI.Commandog, $"{SMR.StartCommand}{SSDECT.Backgroundog}{SMR.ValueSeparator}{SSSMI.Backgroundog}");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
using System.Diagnostics;
using System.Runtime.InteropServices;
using SBMI = Sucrose.Backgroundog.Manage.Internal;
using SSSMI = Sucrose.Shared.Space.Manage.Internal;

namespace Sucrose.Backgroundog.Extension
namespace Sucrose.Shared.Space.Extension
{
internal static class Lifecycle
{
Expand Down Expand Up @@ -48,7 +48,7 @@ public static void ResumeThread(Process Process)
{
foreach (ProcessThread Thread in Process.Threads)
{
IntPtr Threading = OpenThread(SBMI.THREAD_SUSPEND_RESUME, false, Thread.Id);
IntPtr Threading = OpenThread(SSSMI.THREAD_SUSPEND_RESUME, false, Thread.Id);

ResumeThread(Threading);
}
Expand All @@ -58,7 +58,7 @@ public static void SuspendThread(Process Process)
{
foreach (ProcessThread Thread in Process.Threads)
{
IntPtr Threading = OpenThread(SBMI.THREAD_SUSPEND_RESUME, false, Thread.Id);
IntPtr Threading = OpenThread(SSSMI.THREAD_SUSPEND_RESUME, false, Thread.Id);

SuspendThread(Threading);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Shared/Sucrose.Shared.Space/Helper/Import.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System.IO;
using SMR = Sucrose.Memory.Readonly;
using SSSHL = Sucrose.Shared.Space.Helper.Live;
using SSLHK = Sucrose.Shared.Live.Helper.Kill;
using SSSHP = Sucrose.Shared.Space.Helper.Processor;

namespace Sucrose.Shared.Space.Helper
Expand All @@ -11,7 +11,7 @@ public static void Start(string Destination, string Application)
{
try
{
SSSHL.Kill();
SSLHK.Stop();
SSSHP.Kill(Application);

foreach (string Setting in Settings(Destination))
Expand Down
6 changes: 3 additions & 3 deletions src/Shared/Sucrose.Shared.Space/Helper/Temporary.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using System.IO;
using SSSHL = Sucrose.Shared.Space.Helper.Live;
using SSLHK = Sucrose.Shared.Live.Helper.Kill;
using SSSHP = Sucrose.Shared.Space.Helper.Processor;

namespace Sucrose.Shared.Space.Helper
Expand All @@ -10,7 +10,7 @@ public static void Delete(string Path, string Application)
{
try
{
SSSHL.Kill();
SSLHK.Stop();
SSSHP.Kill(Application);

Directory.Delete(Path, true);
Expand All @@ -21,7 +21,7 @@ public static void Delete(string Path, string Application)
{
try
{
SSSHL.Kill();
SSLHK.Stop();
SSSHP.Kill(Application);

File.Delete(Path);
Expand Down
2 changes: 2 additions & 0 deletions src/Shared/Sucrose.Shared.Space/Manage/Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ internal static class Internal

public static SSDEAET ApplicationEngine = SSDEAET.Aurora;

public static int THREAD_SUSPEND_RESUME => 0x0002;

public static string This => Path.GetDirectoryName(App);

public static string Folder => Path.Combine(This, @"..\");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<Import_RootNamespace>Sucrose.Shared.Space</Import_RootNamespace>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildThisFileDirectory)Extension\Lifecycle.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helper\Copy.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helper\Graphic.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Helper\Management.cs" />
Expand Down
Loading

0 comments on commit 4634e13

Please sign in to comment.