A:调整打包构建
This commit is contained in:
1 parent
fc31e0341c
commit
b68a847677
8 files changed
+92
-175
No files matched your search
@@ -1,127 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.IO;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using Data;
|
|
||||||
using Common.Logger;
|
|
||||||
using Dapper;
|
|
||||||
|
|
||||||
class CheckDbSchema
|
|
||||||
{
|
|
||||||
static async Task Main(string[] args)
|
|
||||||
{
|
|
||||||
Log.Initialize();
|
|
||||||
|
|
||||||
var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
|
|
||||||
var dbPath = Path.Combine(appDataPath, "NetVizor", "netvizor.db");
|
|
||||||
|
|
||||||
Console.WriteLine($"检查数据库: {dbPath}");
|
|
||||||
|
|
||||||
if (!File.Exists(dbPath))
|
|
||||||
{
|
|
||||||
Console.WriteLine("❌ 数据库文件不存在");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
using var context = new NetVizorDbContext(dbPath);
|
|
||||||
var connection = context.Connection;
|
|
||||||
|
|
||||||
Console.WriteLine("✓ 数据库连接成功");
|
|
||||||
|
|
||||||
// 检查所有表
|
|
||||||
var tables = await connection.QueryAsync<string>(
|
|
||||||
"SELECT name FROM sqlite_master WHERE type='table' ORDER BY name");
|
|
||||||
|
|
||||||
Console.WriteLine($"\n📋 现有表 ({tables.Count()}个):");
|
|
||||||
foreach (var table in tables)
|
|
||||||
{
|
|
||||||
Console.WriteLine($" - {table}");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查聚合表是否存在
|
|
||||||
var aggregationTables = new[]
|
|
||||||
{
|
|
||||||
"AppNetworkHourly", "AppNetworkDaily", "AppNetworkWeekly", "AppNetworkMonthly",
|
|
||||||
"GlobalNetworkHourly", "GlobalNetworkDaily", "GlobalNetworkWeekly", "GlobalNetworkMonthly"
|
|
||||||
};
|
|
||||||
|
|
||||||
Console.WriteLine("\n🔍 聚合表检查:");
|
|
||||||
var missingTables = new List<string>();
|
|
||||||
|
|
||||||
foreach (var tableName in aggregationTables)
|
|
||||||
{
|
|
||||||
if (tables.Contains(tableName))
|
|
||||||
{
|
|
||||||
// 检查表结构
|
|
||||||
var columns = await connection.QueryAsync<dynamic>(
|
|
||||||
$"PRAGMA table_info({tableName})");
|
|
||||||
|
|
||||||
var columnNames = columns.Select(c => c.name.ToString()).ToArray();
|
|
||||||
Console.WriteLine($" ✓ {tableName} (列: {string.Join(", ", columnNames)})");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine($" ❌ {tableName} - 缺失");
|
|
||||||
missingTables.Add(tableName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (missingTables.Count > 0)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"\n⚠ 发现 {missingTables.Count} 个缺失的聚合表,需要运行数据库初始化");
|
|
||||||
|
|
||||||
// 运行初始化以创建缺失的表
|
|
||||||
Console.WriteLine("\n🔄 正在创建缺失的聚合表...");
|
|
||||||
await context.InitializeDatabaseAsync();
|
|
||||||
Console.WriteLine("✓ 数据库表结构更新完成");
|
|
||||||
|
|
||||||
// 再次检查
|
|
||||||
var updatedTables = await connection.QueryAsync<string>(
|
|
||||||
"SELECT name FROM sqlite_master WHERE type='table' ORDER BY name");
|
|
||||||
Console.WriteLine($"\n📋 更新后的表 ({updatedTables.Count()}个):");
|
|
||||||
foreach (var table in updatedTables)
|
|
||||||
{
|
|
||||||
Console.WriteLine($" - {table}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Console.WriteLine("\n✅ 所有聚合表都已存在");
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查数据数量
|
|
||||||
Console.WriteLine("\n📊 数据统计:");
|
|
||||||
var appNetworkCount = await connection.QuerySingleAsync<int>("SELECT COUNT(*) FROM AppNetwork");
|
|
||||||
var globalNetworkCount = await connection.QuerySingleAsync<int>("SELECT COUNT(*) FROM GlobalNetwork");
|
|
||||||
var appInfoCount = await connection.QuerySingleAsync<int>("SELECT COUNT(*) FROM AppInfo");
|
|
||||||
|
|
||||||
Console.WriteLine($" - AppNetwork: {appNetworkCount:N0} 条记录");
|
|
||||||
Console.WriteLine($" - GlobalNetwork: {globalNetworkCount:N0} 条记录");
|
|
||||||
Console.WriteLine($" - AppInfo: {appInfoCount:N0} 条记录");
|
|
||||||
|
|
||||||
// 检查聚合表数据
|
|
||||||
foreach (var tableName in aggregationTables)
|
|
||||||
{
|
|
||||||
if (tables.Contains(tableName) || missingTables.Count == 0)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
var count = await connection.QuerySingleAsync<int>($"SELECT COUNT(*) FROM {tableName}");
|
|
||||||
Console.WriteLine($" - {tableName}: {count:N0} 条记录");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine($" - {tableName}: 查询失败 ({ex.Message})");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
Console.WriteLine($"❌ 错误: {ex.Message}");
|
|
||||||
Console.WriteLine($"详细: {ex}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,6 +9,12 @@
|
|||||||
<UseWindowsForms>true</UseWindowsForms> <!-- 加上这句,才能正确启用 Forms 支持 -->
|
<UseWindowsForms>true</UseWindowsForms> <!-- 加上这句,才能正确启用 Forms 支持 -->
|
||||||
<ApplicationManifest>app.manifest</ApplicationManifest>
|
<ApplicationManifest>app.manifest</ApplicationManifest>
|
||||||
<ApplicationIcon>Assets\Icons\app.ico</ApplicationIcon>
|
<ApplicationIcon>Assets\Icons\app.ico</ApplicationIcon>
|
||||||
|
<AssemblyTitle>NetVizor</AssemblyTitle>
|
||||||
|
<AssemblyDescription>网络监控与管理工具</AssemblyDescription>
|
||||||
|
<AssemblyCompany>YuanLL</AssemblyCompany>
|
||||||
|
<AssemblyProduct>NetVizor</AssemblyProduct>
|
||||||
|
<AssemblyVersion>1.0.0.0</AssemblyVersion>
|
||||||
|
<FileVersion>1.0.0.0</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -42,51 +48,10 @@
|
|||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</Content>
|
</Content>
|
||||||
<None Remove="Assets\Icons\app.ico"/>
|
<None Remove="Assets\Icons\app.ico"/>
|
||||||
<Content Include="Assets\Icons\app.ico">
|
<Resource Include="Assets\Icons\app.ico"/>
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<Content Include="wwwroot\**\*">
|
||||||
</Content>
|
|
||||||
<None Update="wwwroot\assets\js\views.BdKezxME.js">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</Content>
|
||||||
<None Update="wwwroot\assets\js\vendor.CniNRiIb.js">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="wwwroot\favicon.ico">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="wwwroot\assets\js\utils-vendor.G8u8hGnM.js">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="wwwroot\assets\js\components.UDtJ8svY.js">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="wwwroot\assets\js\vue-vendor.IL9U3oRS.js">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="wwwroot\index.html">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="wwwroot\assets\js\charts-vendor.D6DPwxZz.js">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="wwwroot\assets\js\icons-vendor.txK6AxSp.js">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="wwwroot\assets\css\vue-vendor.BCw0uU-l.css">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="wwwroot\assets\js\index.rwl-8vkS.js">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="wwwroot\assets\css\components.BcFSLL5H.css">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="wwwroot\assets\css\index.BMG5FuIJ.css">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
<None Update="wwwroot\assets\css\views.DcUNVeyP.css">
|
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
|
||||||
</None>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
xmlns:userControls="clr-namespace:Shell.UserControls"
|
xmlns:userControls="clr-namespace:Shell.UserControls"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
Title="NetVizor Dashboard"
|
Title="NetVizor Dashboard"
|
||||||
Icon="/Assets/Icons/app.ico"
|
Icon="pack://application:,,,/Assets/Icons/app.ico"
|
||||||
Height="900"
|
Height="900"
|
||||||
Width="1500">
|
Width="1500">
|
||||||
<Grid>
|
<Grid>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@
|
|||||||
MinWidth="560"
|
MinWidth="560"
|
||||||
WindowStartupLocation="CenterScreen"
|
WindowStartupLocation="CenterScreen"
|
||||||
ResizeMode="NoResize"
|
ResizeMode="NoResize"
|
||||||
Icon="/Assets/Icons/app.ico"
|
Icon="pack://application:,,,/Assets/Icons/app.ico"
|
||||||
Background="#F8F9FA">
|
Background="#F8F9FA">
|
||||||
|
|
||||||
<!-- 窗口资源 -->
|
<!-- 窗口资源 -->
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||||
<security>
|
<security>
|
||||||
<requestedPrivileges>
|
<requestedPrivileges>
|
||||||
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
|
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
|
||||||
</requestedPrivileges>
|
</requestedPrivileges>
|
||||||
</security>
|
</security>
|
||||||
</trustInfo>
|
</trustInfo>
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
"Version": "0.0.1",
|
"Version": "0.0.1",
|
||||||
"Logging": {
|
"Logging": {
|
||||||
"EnableConsole": true,
|
"EnableConsole": true,
|
||||||
"EnableFile": false,
|
"EnableFile": true,
|
||||||
"LogPath": "logs",
|
"LogPath": "logs",
|
||||||
"MaxFileSizeMB": 1,
|
"MaxFileSizeMB": 1,
|
||||||
"RetentionDays": 30,
|
"RetentionDays": 30,
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
@echo off
|
||||||
|
echo 开始发布 NetVizor 单文件版本...
|
||||||
|
|
||||||
|
REM 清理之前的发布文件
|
||||||
|
if exist "publish\exe" rmdir /s /q "publish\exe"
|
||||||
|
mkdir "publish\exe"
|
||||||
|
|
||||||
|
REM 发布为单文件可执行程序
|
||||||
|
dotnet publish Shell\Shell.csproj ^
|
||||||
|
--configuration Release ^
|
||||||
|
--output "publish\exe" ^
|
||||||
|
--self-contained true ^
|
||||||
|
--runtime win-x64 ^
|
||||||
|
--property:PublishSingleFile=true ^
|
||||||
|
--property:IncludeNativeLibrariesForSelfExtract=true ^
|
||||||
|
--property:DebugType=None ^
|
||||||
|
--property:DebugSymbols=false
|
||||||
|
|
||||||
|
if %ERRORLEVEL% equ 0 (
|
||||||
|
echo.
|
||||||
|
echo 发布成功!
|
||||||
|
echo 输出目录: publish\exe
|
||||||
|
echo 可执行文件: publish\exe\Shell.exe
|
||||||
|
echo.
|
||||||
|
echo 文件列表:
|
||||||
|
dir "publish\exe" /b
|
||||||
|
echo.
|
||||||
|
pause
|
||||||
|
) else (
|
||||||
|
echo 发布失败!
|
||||||
|
pause
|
||||||
|
)
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
# NetVizor 单文件发布脚本
|
||||||
|
Write-Host "开始发布 NetVizor 单文件版本..." -ForegroundColor Green
|
||||||
|
|
||||||
|
# 清理之前的发布文件
|
||||||
|
$publishPath = "publish\exe"
|
||||||
|
if (Test-Path $publishPath) {
|
||||||
|
Remove-Item $publishPath -Recurse -Force
|
||||||
|
Write-Host "已清理旧的发布文件" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
New-Item -ItemType Directory -Path $publishPath -Force | Out-Null
|
||||||
|
|
||||||
|
# 发布为单文件可执行程序
|
||||||
|
Write-Host "正在编译和打包..." -ForegroundColor Cyan
|
||||||
|
$publishResult = dotnet publish Shell\Shell.csproj `
|
||||||
|
--configuration Release `
|
||||||
|
--output $publishPath `
|
||||||
|
--self-contained true `
|
||||||
|
--runtime win-x64 `
|
||||||
|
--property:PublishSingleFile=true `
|
||||||
|
--property:IncludeNativeLibrariesForSelfExtract=true `
|
||||||
|
--property:DebugType=None `
|
||||||
|
--property:DebugSymbols=false
|
||||||
|
|
||||||
|
if ($LASTEXITCODE -eq 0) {
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "发布成功!" -ForegroundColor Green
|
||||||
|
Write-Host "输出目录: $publishPath" -ForegroundColor White
|
||||||
|
Write-Host "可执行文件: $publishPath\Shell.exe" -ForegroundColor White
|
||||||
|
|
||||||
|
# 显示文件信息
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "发布文件列表:" -ForegroundColor Cyan
|
||||||
|
Get-ChildItem $publishPath | Format-Table Name, Length, LastWriteTime -AutoSize
|
||||||
|
|
||||||
|
# 显示主要文件大小
|
||||||
|
$exeFile = "$publishPath\Shell.exe"
|
||||||
|
if (Test-Path $exeFile) {
|
||||||
|
$size = (Get-Item $exeFile).Length / 1MB
|
||||||
|
Write-Host "主程序大小: $([math]::Round($size, 2)) MB" -ForegroundColor Yellow
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Host "发布失败!请检查错误信息。" -ForegroundColor Red
|
||||||
|
}
|
||||||
|
|
||||||
|
Write-Host ""
|
||||||
|
Write-Host "按任意键继续..." -ForegroundColor Gray
|
||||||
|
$null = $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
|
||||||
Reference in new issue
Block a user