first commit

This commit is contained in:
jianxin committed 2023-09-05 01:00:39 +08:00
commit bae64833d8
7 files changed
+171

No files matched your search

+4
View File
@@ -0,0 +1,4 @@
.vs
bin
obj
+17
View File
@@ -0,0 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PublishAot>true</PublishAot>
<InvariantGlobalization>true</InvariantGlobalization>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="CsvHelper" Version="30.0.1" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.118" />
</ItemGroup>
</Project>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>D:\CS\ExportAssiatantLog\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup>
</Project>
+25
View File
@@ -0,0 +1,25 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34024.191
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExportAssiatantLog", "ExportAssiatantLog.csproj", "{73F594F6-BE9B-4580-B7EC-B864394E3A26}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{73F594F6-BE9B-4580-B7EC-B864394E3A26}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73F594F6-BE9B-4580-B7EC-B864394E3A26}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73F594F6-BE9B-4580-B7EC-B864394E3A26}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73F594F6-BE9B-4580-B7EC-B864394E3A26}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {858EF043-7C6A-4799-89F0-D9C18BD67843}
EndGlobalSection
EndGlobal
+91
View File
@@ -0,0 +1,91 @@
using System;
using System.Data.SQLite;
using System.Globalization;
using System.IO;
using System.Text;
using CsvHelper;
namespace ExportAssiatantLog
{
class Program
{
static void Main(string[] args)
{
var localAppDataPath = Environment.GetEnvironmentVariable("LOCALAPPDATA");
var dbPath = Path.Combine(localAppDataPath, "ShadowBot", "users", "Assistant", "assistant.db3");
var downloadPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "Downloads");
var dateString = DateTime.UtcNow.ToString("yyyy-MM-dd");
var filename = $"{dateString}-assistant-job-logs.csv";
var exportPath = Path.Combine(downloadPath, filename);
using var conn = new SQLiteConnection($"Data Source={dbPath}");
conn.Open();
using var cmd = new SQLiteCommand(conn);
using var writer = new StreamWriter(exportPath, false, Encoding.UTF8);
using var csv = new CsvWriter(writer, CultureInfo.InvariantCulture);
csv.WriteRecords(GetData(cmd));
}
static IEnumerable<DataRecord> GetData(SQLiteCommand cmd)
{
int i = 1;
while (true)
{
var tableName = $"assistant_job_logs_{i}";
var query = $@"SELECT `sceneInstJobUuid`, `level`, `time`, `content` FROM `{tableName}`";
cmd.CommandText = query;
SQLiteDataReader reader = null;
try
{
reader = cmd.ExecuteReader();
}
catch (SQLiteException e)
{
break;
}
if (!reader.HasRows)
{
break;
}
while (reader.Read())
{
yield return new DataRecord
{
SceneInstJobUuid = reader.GetString(0),
Level = reader.GetString(1),
Time = reader.GetString(2),
Content = reader.GetString(3)
};
}
reader.Close();
i++;
}
}
class DataRecord
{
public string SceneInstJobUuid { get; set; }
public string Level { get; set; }
public string Time { get; set; }
public string Content { get; set; }
}
}
}
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>Any CPU</Platform>
<PublishDir>bin\Release\net8.0\publish\win-x64\</PublishDir>
<PublishProtocol>FileSystem</PublishProtocol>
<_TargetId>Folder</_TargetId>
<TargetFramework>net8.0</TargetFramework>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
<SelfContained>false</SelfContained>
<PublishSingleFile>true</PublishSingleFile>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
</Project>
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<History>False|2023-09-04T16:57:21.6374168Z;False|2023-09-05T00:54:21.0789671+08:00;False|2023-09-05T00:54:02.1221891+08:00;</History>
<LastFailureDetails />
</PropertyGroup>
</Project>