-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request !57 from Juster Zhu/dev
- Loading branch information
Showing
309 changed files
with
4,589 additions
and
11,542 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
@echo off | ||
setlocal | ||
|
||
if "%~1"=="" ( | ||
echo Please provide the export path as the first parameter. | ||
exit /b 1 | ||
) | ||
|
||
set exportDir=%~1 | ||
|
||
if not exist "%exportDir%" ( | ||
mkdir "%exportDir%" | ||
) | ||
|
||
set outputFile=%exportDir%\driverInfo.txt | ||
|
||
:: 导出驱动信息 | ||
driverquery /v /fo table > "%outputFile%" | ||
echo %outputFile% Export successfully. | ||
|
||
:: 导出系统信息 | ||
set systemInfoFile=%exportDir%\systeminfo.txt | ||
systeminfo > "%systemInfoFile%" | ||
echo %systemInfoFile% Export successfully. | ||
|
||
:: 获取当前日期 | ||
for /f "tokens=1-4 delims=/- " %%i in ('date /t') do ( | ||
set yyyy=%%i | ||
set mm=%%j | ||
set dd=%%k | ||
) | ||
|
||
:: 设置日志文件名 | ||
set logFile=%exportDir%\systemlog.evtx | ||
|
||
:: 导出系统日志 | ||
wevtutil epl System "%logFile%" /q:"*[System[TimeCreated[timediff(@SystemTime) <= 86400000]]]" | ||
echo %logFile% Export successfully. | ||
|
||
endlocal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,58 @@ | ||
using System; | ||
using System.IO; | ||
using System.Runtime.InteropServices; | ||
using System.Text.Json; | ||
using GeneralUpdate.Bowl.Strategys; | ||
using GeneralUpdate.Common.Internal.JsonContext; | ||
using GeneralUpdate.Common.Shared.Object; | ||
|
||
namespace GeneralUpdate.Bowl; | ||
|
||
public class Bowl | ||
/// <summary> | ||
/// Surveillance Main Program. | ||
/// </summary> | ||
public sealed class Bowl | ||
{ | ||
private IStrategy _strategy; | ||
private static IStrategy? _strategy; | ||
|
||
public Bowl(MonitorParameter parameter = null) | ||
{ | ||
CreateStrategy(); | ||
_strategy!.SetParameter(parameter); | ||
} | ||
private Bowl() { } | ||
|
||
private void CreateStrategy() | ||
private static void CreateStrategy() | ||
{ | ||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) | ||
{ | ||
_strategy = new WindowStrategy(); | ||
} | ||
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux)) | ||
{ | ||
_strategy = new LinuxStrategy(); | ||
} | ||
|
||
if (_strategy == null) | ||
throw new PlatformNotSupportedException("Unsupported operating system"); | ||
} | ||
|
||
public static void Launch(MonitorParameter? monitorParameter = null) | ||
{ | ||
monitorParameter ??= CreateParameter(); | ||
CreateStrategy(); | ||
_strategy?.SetParameter(monitorParameter); | ||
_strategy?.Launch(); | ||
} | ||
|
||
public Bowl SetParameter(MonitorParameter parameter) | ||
private static MonitorParameter CreateParameter() | ||
{ | ||
if(parameter.Verify()) | ||
throw new ArgumentException("Parameter contains illegal values"); | ||
var json = Environment.GetEnvironmentVariable("ProcessInfo", EnvironmentVariableTarget.User); | ||
if(string.IsNullOrWhiteSpace(json)) | ||
throw new ArgumentNullException("ProcessInfo environment variable not set !"); | ||
|
||
_strategy.SetParameter(parameter); | ||
return this; | ||
var processInfo = JsonSerializer.Deserialize<ProcessInfo>(json, ProcessInfoJsonContext.Default.ProcessInfo); | ||
if(processInfo == null) | ||
throw new ArgumentNullException("ProcessInfo json deserialize fail!"); | ||
|
||
return new MonitorParameter | ||
{ | ||
ProcessNameOrId = processInfo.AppName, | ||
DumpFileName = $"{processInfo.LastVersion}_fail.dmp", | ||
FailFileName = $"{processInfo.LastVersion}_fail.json", | ||
TargetPath = processInfo.InstallPath, | ||
FailDirectory = Path.Combine(processInfo.InstallPath, "fail", processInfo.LastVersion), | ||
BackupDirectory = Path.Combine(processInfo.InstallPath, processInfo.LastVersion), | ||
ExtendedField = processInfo.LastVersion | ||
}; | ||
} | ||
|
||
public void Launch() => _strategy.Launch(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Collections.Generic; | ||
using GeneralUpdate.Bowl.Strategys; | ||
|
||
namespace GeneralUpdate.Bowl.Internal; | ||
|
||
internal class Crash | ||
{ | ||
public MonitorParameter Parameter { get; set; } | ||
|
||
public List<string> ProcdumpOutPutLines { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace GeneralUpdate.Bowl.Internal; | ||
|
||
[JsonSerializable(typeof(Crash))] | ||
internal partial class CrashJsonContext : JsonSerializerContext; |
2 changes: 1 addition & 1 deletion
2
...neralUpdate.Bowl/Strategys/LinuxSystem.cs → ...eneralUpdate.Bowl/Internal/LinuxSystem.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
namespace GeneralUpdate.Bowl.Strategys; | ||
namespace GeneralUpdate.Bowl.Internal; | ||
|
||
internal class LinuxSystem | ||
{ | ||
|
Oops, something went wrong.