PocketBaseImportWithDeno
This commit is contained in:
parent
384c83304b
commit
e89e11dcf6
17
.vscode/launch.json
vendored
17
.vscode/launch.json
vendored
@ -11,6 +11,18 @@
|
|||||||
"preLaunchTask": "build",
|
"preLaunchTask": "build",
|
||||||
"program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll",
|
"program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll",
|
||||||
"args": [
|
"args": [
|
||||||
|
"s",
|
||||||
|
"X",
|
||||||
|
"L:/Git/pocketbase_0.25.8_windows_amd64",
|
||||||
|
"Day-Helper-2025-03-01",
|
||||||
|
"*.json",
|
||||||
|
"-",
|
||||||
|
"L:/Git/pocketbase-import",
|
||||||
|
"json.ts",
|
||||||
|
"input",
|
||||||
|
"777",
|
||||||
|
"888",
|
||||||
|
"999",
|
||||||
"s",
|
"s",
|
||||||
"X",
|
"X",
|
||||||
"L:/Git/pocketbase_0.25.8_windows_amd64",
|
"L:/Git/pocketbase_0.25.8_windows_amd64",
|
||||||
@ -18,11 +30,6 @@
|
|||||||
"immich-db-backup-1739350800014.sql",
|
"immich-db-backup-1739350800014.sql",
|
||||||
"COPY_public.",
|
"COPY_public.",
|
||||||
"FROM_stdin",
|
"FROM_stdin",
|
||||||
"555",
|
|
||||||
"666",
|
|
||||||
"777",
|
|
||||||
"888",
|
|
||||||
"999",
|
|
||||||
"s",
|
"s",
|
||||||
"X",
|
"X",
|
||||||
"\\\\mesfs.infineon.com\\EC_Characterization_Si\\Archive\\BIORAD4\\2025_Week_09\\2025-02-28\\-660626-_2025-02-28_04;49_PM_395577460",
|
"\\\\mesfs.infineon.com\\EC_Characterization_Si\\Archive\\BIORAD4\\2025_Week_09\\2025-02-28\\-660626-_2025-02-28_04;49_PM_395577460",
|
||||||
|
62
ADO2025/PI5/Helper-2025-03-01.cs
Normal file
62
ADO2025/PI5/Helper-2025-03-01.cs
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
|
||||||
|
namespace File_Folder_Helper.ADO2025.PI5;
|
||||||
|
|
||||||
|
internal static partial class Helper20250301
|
||||||
|
{
|
||||||
|
|
||||||
|
private static ReadOnlyCollection<string> CopyFiles(char split, string workingDirectory, string directory, string[] files)
|
||||||
|
{
|
||||||
|
List<string> results = [];
|
||||||
|
string fileName;
|
||||||
|
string checkFile;
|
||||||
|
string checkDirectory = Path.Combine(workingDirectory, directory);
|
||||||
|
if (!Directory.Exists(checkDirectory))
|
||||||
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
|
foreach (string file in files)
|
||||||
|
{
|
||||||
|
fileName = Path.GetFileName(file).Split(split)[^1];
|
||||||
|
checkFile = Path.Combine(checkDirectory, fileName);
|
||||||
|
if (File.Exists(checkFile))
|
||||||
|
File.Delete(checkFile);
|
||||||
|
File.Copy(file, checkFile);
|
||||||
|
results.Add(fileName);
|
||||||
|
}
|
||||||
|
return results.AsReadOnly();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void PocketBaseImportWithDeno(ILogger<Worker> logger, char split, string workingDirectory, string scriptName, string directory, string[] files)
|
||||||
|
{
|
||||||
|
string checkFile = Path.Combine(workingDirectory, scriptName);
|
||||||
|
if (!File.Exists(checkFile))
|
||||||
|
logger.LogWarning("<{checkFile}> doesn't exist!", checkFile);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ReadOnlyCollection<string> fileNames = CopyFiles(split, workingDirectory, directory, files);
|
||||||
|
if (fileNames.Count == 0)
|
||||||
|
logger.LogWarning("<{fileNames}>(s)", fileNames.Count);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
foreach (string fileName in fileNames)
|
||||||
|
logger.LogInformation("deno run --unstable --allow-read --allow-env --allow-net {scriptName} --id=true --input={fileName}", scriptName, fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void PocketBaseImportWithDeno(ILogger<Worker> logger, List<string> args)
|
||||||
|
{
|
||||||
|
char split = args[3][0];
|
||||||
|
string directory = args[6];
|
||||||
|
string scriptName = args[5];
|
||||||
|
string searchPattern = args[2];
|
||||||
|
string sourceDirectory = Path.GetFullPath(args[0]);
|
||||||
|
string workingDirectory = Path.GetFullPath(args[4]);
|
||||||
|
string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.AllDirectories);
|
||||||
|
if (files.Length == 0)
|
||||||
|
logger.LogWarning("<{files}>(s)", files.Length);
|
||||||
|
else
|
||||||
|
PocketBaseImportWithDeno(logger, split, workingDirectory, scriptName, directory, files);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -139,6 +139,8 @@ internal static class HelperDay
|
|||||||
ADO2025.PI5.Helper20250219.Compare(logger, args);
|
ADO2025.PI5.Helper20250219.Compare(logger, args);
|
||||||
else if (args[1] == "Day-Helper-2025-02-28")
|
else if (args[1] == "Day-Helper-2025-02-28")
|
||||||
ADO2025.PI5.Helper20250228.PostgresDumpToJson(logger, args);
|
ADO2025.PI5.Helper20250228.PostgresDumpToJson(logger, args);
|
||||||
|
else if (args[1] == "Day-Helper-2025-03-01")
|
||||||
|
ADO2025.PI5.Helper20250301.PocketBaseImportWithDeno(logger, args);
|
||||||
else
|
else
|
||||||
throw new Exception(appSettings.Company);
|
throw new Exception(appSettings.Company);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user