添加项目文件。
This commit is contained in:
14
DumpConfiguration/ConfigurationEntry.cs
Normal file
14
DumpConfiguration/ConfigurationEntry.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace DumpConfiguration
|
||||
{
|
||||
public partial class ConfigurationEntry
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public int ConfigurationGroupId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Value { get; set; } = string.Empty;
|
||||
public int DataTypeId { get; set; }
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public bool IsEncrypted { get; set; }
|
||||
public bool IsRequired { get; set; }
|
||||
}
|
||||
}
|
||||
9
DumpConfiguration/ConfigurationGroup.cs
Normal file
9
DumpConfiguration/ConfigurationGroup.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace DumpConfiguration
|
||||
{
|
||||
public partial class ConfigurationGroup
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
14
DumpConfiguration/DumpConfiguration.csproj
Normal file
14
DumpConfiguration/DumpConfiguration.csproj
Normal file
@@ -0,0 +1,14 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="NTDLS.SqliteDapperWrapper" Version="1.1.4" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
41
DumpConfiguration/Program.cs
Normal file
41
DumpConfiguration/Program.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Dapper;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using System.Text;
|
||||
|
||||
namespace DumpConfiguration
|
||||
{
|
||||
internal class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
{
|
||||
Console.WriteLine("DumpConfiguration.exe <sqliteFile>");
|
||||
return;
|
||||
}
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
using var dbConnection = new SqliteConnection($"Data Source={args[0]}");
|
||||
dbConnection.Open();
|
||||
|
||||
var configurationGroups = dbConnection.Query<ConfigurationGroup>("SELECT * FROM ConfigurationGroup");
|
||||
foreach (var cg in configurationGroups)
|
||||
{
|
||||
sb.AppendLine("INSERT INTO ConfigurationGroup(Id, Name, Description)");
|
||||
sb.AppendLine($"SELECT {cg.Id}, '{cg.Name}', '{cg.Description}'");
|
||||
sb.AppendLine($"ON CONFLICT(Name) DO UPDATE SET Description = '{cg.Description}';");
|
||||
}
|
||||
|
||||
var ConfigurationEntries = dbConnection.Query<ConfigurationEntry>("SELECT * FROM ConfigurationEntry");
|
||||
foreach (var ce in ConfigurationEntries)
|
||||
{
|
||||
sb.AppendLine("INSERT INTO ConfigurationEntry(Id, ConfigurationGroupId, Name, Value, DataTypeId, Description, IsEncrypted, IsRequired)");
|
||||
sb.AppendLine($"SELECT {ce.Id}, {ce.ConfigurationGroupId}, '{ce.Name}', '{ce.Value.Replace("'", "''")}', {ce.DataTypeId}, '{ce.Description}', {(ce.IsEncrypted ? 1 : 0)}, {(ce.IsRequired ? 1 : 0)}");
|
||||
sb.AppendLine($"ON CONFLICT(ConfigurationGroupId, Name) DO UPDATE SET Name = '{ce.Name}', DataTypeId = {ce.DataTypeId}, Description = '{ce.Description}', IsEncrypted = '{(ce.IsEncrypted ? 1 : 0)}', IsRequired = '{(ce.IsRequired ? 1 : 0)}';");
|
||||
}
|
||||
|
||||
Console.WriteLine(sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
8
DumpConfiguration/Properties/launchSettings.json
Normal file
8
DumpConfiguration/Properties/launchSettings.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"profiles": {
|
||||
"DumpConfiguration": {
|
||||
"commandName": "Project",
|
||||
"commandLineArgs": "\"C:\\NTDLS\\TightWiki\\Data\\config.db\""
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user