commit bae64833d815d2ac787a1a31e54c8d7c253a374d
Author: woni <320753691@qq.com>
Date: Tue Sep 5 01:00:39 2023 +0800
first commit
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..9a1b056
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+.vs
+bin
+obj
+
diff --git a/ExportAssiatantLog.csproj b/ExportAssiatantLog.csproj
new file mode 100644
index 0000000..61ad872
--- /dev/null
+++ b/ExportAssiatantLog.csproj
@@ -0,0 +1,17 @@
+
+
+
+ Exe
+ net8.0
+ enable
+ enable
+ true
+ true
+
+
+
+
+
+
+
+
diff --git a/ExportAssiatantLog.csproj.user b/ExportAssiatantLog.csproj.user
new file mode 100644
index 0000000..0976d52
--- /dev/null
+++ b/ExportAssiatantLog.csproj.user
@@ -0,0 +1,6 @@
+
+
+
+ <_LastSelectedProfileId>D:\CS\ExportAssiatantLog\Properties\PublishProfiles\FolderProfile.pubxml
+
+
\ No newline at end of file
diff --git a/ExportAssiatantLog.sln b/ExportAssiatantLog.sln
new file mode 100644
index 0000000..0e20ca9
--- /dev/null
+++ b/ExportAssiatantLog.sln
@@ -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
diff --git a/Program.cs b/Program.cs
new file mode 100644
index 0000000..f45c673
--- /dev/null
+++ b/Program.cs
@@ -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 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; }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Properties/PublishProfiles/FolderProfile.pubxml b/Properties/PublishProfiles/FolderProfile.pubxml
new file mode 100644
index 0000000..8a033a1
--- /dev/null
+++ b/Properties/PublishProfiles/FolderProfile.pubxml
@@ -0,0 +1,18 @@
+
+
+
+
+ Release
+ Any CPU
+ bin\Release\net8.0\publish\win-x64\
+ FileSystem
+ <_TargetId>Folder
+ net8.0
+ win-x64
+ false
+ true
+ true
+
+
\ No newline at end of file
diff --git a/Properties/PublishProfiles/FolderProfile.pubxml.user b/Properties/PublishProfiles/FolderProfile.pubxml.user
new file mode 100644
index 0000000..af1321b
--- /dev/null
+++ b/Properties/PublishProfiles/FolderProfile.pubxml.user
@@ -0,0 +1,10 @@
+
+
+
+
+ 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;
+
+
+
\ No newline at end of file