添加项目文件。

This commit is contained in:
Zel
2025-01-22 23:31:03 +08:00
parent 1b8ba6771f
commit 2ae76476fb
894 changed files with 774558 additions and 0 deletions

View 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; }
}
}

View 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;
}
}

View 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>

View 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());
}
}
}

View File

@@ -0,0 +1,8 @@
{
"profiles": {
"DumpConfiguration": {
"commandName": "Project",
"commandLineArgs": "\"C:\\NTDLS\\TightWiki\\Data\\config.db\""
}
}
}