Added Live Update mode and SQL Output File

This commit is contained in:
2025-05-04 14:10:23 -04:00
parent fdb80e7191
commit e6b6289aea
2 changed files with 10 additions and 6 deletions

View File

@@ -30,6 +30,7 @@ namespace PhotosImporter
public string PhotosPath { get; set; } public string PhotosPath { get; set; }
public string PhotosTable { get; set; } public string PhotosTable { get; set; }
public bool LiveUpdate { get; set; }
private static bool HasNonASCIIChars(string str) private static bool HasNonASCIIChars(string str)
{ {
@@ -230,6 +231,7 @@ namespace PhotosImporter
// Required options/flags, append '=' to obtain the required value. // Required options/flags, append '=' to obtain the required value.
HasRequiredOption("p|path=", "Path", p => PhotosPath = p); HasRequiredOption("p|path=", "Path", p => PhotosPath = p);
HasRequiredOption("t|table=", "Table", t => PhotosTable = t); HasRequiredOption("t|table=", "Table", t => PhotosTable = t);
HasOption("l|live=", "Live Update", l => LiveUpdate = false);
// Optional options/flags, append ':' to obtain an optional value, or null if not specified. // Optional options/flags, append ':' to obtain an optional value, or null if not specified.
//HasOption("s|strip:", "Strips ',' from the file before writing to output.", //HasOption("s|strip:", "Strips ',' from the file before writing to output.",
@@ -241,7 +243,7 @@ namespace PhotosImporter
string sqlFilePath = Path.Combine(System.AppContext.BaseDirectory, "output.sql"); string sqlFilePath = Path.Combine(System.AppContext.BaseDirectory, "output.sql");
StreamWriter sqlFile = File.CreateText(sqlFilePath); // base class not allowed??? // null; StreamWriter sqlFile = File.CreateText(sqlFilePath); // base class not allowed??? // null;
sqlFile.AutoFlush = true; sqlFile.AutoFlush = true;
sqlFile.WriteLine($"DELETE FROM {PhotosTable}"); sqlFile.WriteLine($"DELETE FROM {PhotosTable};");
sqlFile.WriteLine($"ALTER TABLE {PhotosTable} AUTO_INCREMENT = 1;"); sqlFile.WriteLine($"ALTER TABLE {PhotosTable} AUTO_INCREMENT = 1;");
string bannedExtensionsPath = "C:/Deps/bannedExtensions.json"; string bannedExtensionsPath = "C:/Deps/bannedExtensions.json";
@@ -252,10 +254,11 @@ namespace PhotosImporter
List<string> badFileNotifications = new List<string>(); List<string> badFileNotifications = new List<string>();
Console.WriteLine("Deleting and re-indexing in 10 seconds..."); Console.WriteLine("Deleting and re-indexing in 10 seconds...");
// System.Threading.Thread.Sleep(10000); // System.Threading.Thread.Sleep(10000);
if (LiveUpdate) {
DeleteRecords(PhotosTable); DeleteRecords(PhotosTable);
ReIndexRecords(PhotosTable); ReIndexRecords(PhotosTable);
}
foreach (string filename in Directory.GetFiles(PhotosPath)) foreach (string filename in Directory.GetFiles(PhotosPath))
{ {
FileInfo file = new(filename); FileInfo file = new(filename);

View File

@@ -2,7 +2,8 @@
"profiles": { "profiles": {
"PhotosImporter": { "PhotosImporter": {
"commandName": "Project", "commandName": "Project",
"commandLineArgs": "Import -t test -p C:\\Users\\ZStrike\\Downloads\\DPRK\\" "commandLineArgs": "-t badq -p F:\\ant\\Pictures",
"workingDirectory": "C:\\Users\\ZStrike\\Desktop"
} }
} }
} }