From 88bdd33285a8f605cf776907bad49e657097ad6a Mon Sep 17 00:00:00 2001 From: "phares@iscn5cg20977xq" Date: Mon, 11 Aug 2025 09:08:14 -0700 Subject: [PATCH] created-date-offset (Day-Helper-2025-08-03) P and J drives Tasks json file inputs IDE0005 none --- .editorconfig | 2 +- .vscode/launch.json | 15 +- .vscode/tasks.json | 297 +++++++++++++++++++++---------- ADO2025/PI6/Helper-2025-07-26.cs | 44 +++-- 4 files changed, 240 insertions(+), 118 deletions(-) diff --git a/.editorconfig b/.editorconfig index eb38845..ccc040f 100644 --- a/.editorconfig +++ b/.editorconfig @@ -120,7 +120,7 @@ dotnet_diagnostic.CA2254.severity = none # CA2254: The logging message template dotnet_diagnostic.IDE0001.severity = warning # IDE0001: Simplify name dotnet_diagnostic.IDE0002.severity = warning # Simplify (member access) - System.Version.Equals("1", "2"); Version.Equals("1", "2"); dotnet_diagnostic.IDE0004.severity = warning # IDE0004: Cast is redundant. -dotnet_diagnostic.IDE0005.severity = warning # Using directive is unnecessary +dotnet_diagnostic.IDE0005.severity = none # Using directive is unnecessary dotnet_diagnostic.IDE0010.severity = none # Add missing cases to switch statement (IDE0010) dotnet_diagnostic.IDE0028.severity = error # IDE0028: Collection initialization can be simplified dotnet_diagnostic.IDE0031.severity = warning # Use null propagation (IDE0031) diff --git a/.vscode/launch.json b/.vscode/launch.json index bb200f7..8fedabc 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,19 +8,20 @@ "name": ".NET Core Launch (console)", "type": "coreclr", "request": "launch", - "preLaunchTask": "build", + "preLaunchTask": "Build", "program": "${workspaceFolder}/bin/Debug/net8.0/win-x64/File-Folder-Helper.dll", "args": [ "s", "X", - "V:/7-Question/Event 2024 Directories-xmp", + "P:/1-Images-A/Images-0b793904", "Day-Helper-2025-07-26", + "4e+9", "L:/Git/AA/Rename/.vscode/.UserSecrets/secrets.json", - "*.xmp", - "V:/7-Question/Event 2024 Directories-xmp-moved", + ".avif~.bmp~.gif~.heic~.insp~.jp2~.jpe~.jpeg~.jpg~.jxl~.png~.psd~.raw~.rw2~.svg~.tif~.tiff~.webp~.3gp~.3gpp~.avi~.dvr-ms~.flv~.insv~.m2t~.m2ts~.m4v~.mkv~.mov~.mp4~.mpe~.mpeg~.mpg~.mts~.ts~.webm~.wmv", + "P:/6-Other-Large-Z/Current-Results/C)Resize/0b793904/Original/(helper)", "s", "X", - "V:/1-Images-A/Images-0b793904", + "P:/1-Images-A/Images-0b793904", "Day-Helper-2024-12-17", ".job.json", "thumbs.db~sync.ffs_db~verify.json~.html", @@ -28,7 +29,7 @@ "D:/5-Other-Small/Disk/Snap2HTML/Snap2HTML.exe", "s", "X", - "V:/Tmp/Phares/Helper-2025-07-20", + "P:/Tmp/Phares/Helper-2025-07-20", "Day-Helper-2025-07-20", "871467010009.jpg", "L:/Git/AA/Rename/.vscode/.UserSecrets/secrets.json", @@ -74,7 +75,7 @@ "\"vp154\"", "s", "X", - "V:/Tmp/Phares/Pictures/2023 TI2023.6 Fall Samsung", + "P:/Tmp/Phares/Pictures/2023 TI2023.6 Fall Samsung", "Day-Helper-2025-07-05", "x-653889110721.jpg~401223300869.jpg", "3648,2736,1~3024,4032,6", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 842e9d3..302fc46 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -1,22 +1,135 @@ { - "version": "2.0.0", + "inputs": [ + { + "default": "Development", + "description": "Which ASP Net Core Environment?", + "id": "ASPNETCORE_ENVIRONMENT", + "options": [ + "Development", + "Production" + ], + "type": "pickString" + }, + { + "default": "{AssemblyTitle}", + "description": "What Assembly Title?", + "id": "AssemblyTitle", + "type": "promptString" + }, + { + "default": "{Build.BuildId}", + "description": "Which Build BuildId?", + "id": "Build.BuildId", + "type": "promptString" + }, + { + "default": "{Build.Reason}", + "description": "Which Build Reason?", + "id": "Build.Reason", + "type": "promptString" + }, + { + "default": "{Build.Repository.Id}", + "description": "Which Build Repository Id?", + "id": "Build.Repository.Id", + "type": "promptString" + }, + { + "default": "{Build.Repository.Name}", + "description": "Which Build Repository Name?", + "id": "Build.Repository.Name", + "type": "promptString" + }, + { + "default": "{Build.SourceVersion}", + "description": "Which Build Source Version?", + "id": "Build.SourceVersion", + "type": "promptString" + }, + { + "default": "Debug", + "description": "Which Configuration?", + "id": "Configuration", + "options": [ + "Debug", + "Release" + ], + "type": "pickString" + }, + { + "default": "net8.0", + "description": "Which Core Version?", + "id": "CoreVersion", + "options": [ + "net8.0" + ], + "type": "pickString" + }, + { + "default": "C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/MSBuild.exe", + "description": "Which MS Build?", + "id": "MSBuild", + "type": "promptString" + }, + { + "default": "https://artifactory.intra.infineon.com/artifactory/api/nuget/ngt-fi-package-main-vir/", + "description": "Which Nuget Source?", + "id": "NugetSource", + "type": "promptString" + }, + { + "default": "win-x64", + "description": "Which Runtime?", + "id": "Runtime", + "options": [ + "win-x64", + "win-x32", + "linux-x64", + "linux-x32" + ], + "type": "pickString" + }, + { + "default": "L:/", + "description": "Which System DefaultWorkingDirectory?", + "id": "System.DefaultWorkingDirectory", + "options": [ + "L:/", + "D:/", + "C:/" + ], + "type": "pickString" + }, + { + "default": "v4.8", + "description": "Which Core Target Framework Version?", + "id": "TargetFrameworkVersion", + "options": [ + "v4.8" + ], + "type": "pickString" + }, + { + "default": "{UserSecretsId}", + "description": "Which Core User Secrets Id?", + "id": "UserSecretsId", + "type": "promptString" + } + ], "tasks": [ { - "label": "User Secrets Init", - "command": "dotnet", - "type": "process", "args": [ "user-secrets", "-p", "${workspaceFolder}/File-Folder-Helper.csproj", "init" ], - "problemMatcher": "$msCompile" + "command": "dotnet", + "label": "User Secrets Init", + "problemMatcher": "$msCompile", + "type": "process" }, { - "label": "User Secrets Set", - "command": "dotnet", - "type": "process", "args": [ "user-secrets", "-p", @@ -25,12 +138,12 @@ "_UserSecretsId", "0c43f9aa-96e9-4298-967c-ed069d79e262" ], - "problemMatcher": "$msCompile" + "command": "dotnet", + "label": "User Secrets Set", + "problemMatcher": "$msCompile", + "type": "process" }, { - "label": "Format", - "command": "dotnet", - "type": "process", "args": [ "format", "--report", @@ -40,82 +153,78 @@ "--severity", "warn" ], - "problemMatcher": "$msCompile" + "command": "dotnet", + "label": "Format", + "problemMatcher": "$msCompile", + "type": "process" }, { - "label": "Format-Whitespaces", - "command": "dotnet", - "type": "process", "args": [ "format", "whitespace" ], - "problemMatcher": "$msCompile" + "command": "dotnet", + "label": "Format Whitespaces", + "problemMatcher": "$msCompile", + "type": "process" }, { - "label": "build", - "command": "dotnet", - "type": "process", "args": [ "build", "-r", "win-x64", - "${workspaceFolder}/File-Folder-Helper.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" + "${workspaceFolder}/File-Folder-Helper.csproj" ], - "problemMatcher": "$msCompile" + "command": "dotnet", + "label": "Build", + "problemMatcher": "$msCompile", + "type": "process" }, { - "label": "build Linux", - "command": "dotnet", - "type": "process", "args": [ "build", "-r", "linux-x64", - "${workspaceFolder}/File-Folder-Helper.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" + "${workspaceFolder}/File-Folder-Helper.csproj" ], - "problemMatcher": "$msCompile" + "command": "dotnet", + "label": "Build Linux", + "problemMatcher": "$msCompile", + "type": "process" }, { - "label": "podmanLogin", - "command": "podman", - "type": "process", "args": [ "login", "gitea.phares.duckdns.org:443" ], - "problemMatcher": "$msCompile" + "command": "podman", + "label": "Podman Login", + "problemMatcher": "$msCompile", + "type": "process" }, { - "label": "podmanBuild", - "command": "podman", - "type": "process", "args": [ "build", "-t", "file-folder-helper", "." ], - "problemMatcher": "$msCompile" + "command": "podman", + "label": "Podman Build", + "problemMatcher": "$msCompile", + "type": "process" }, { - "label": "podmanImageList", - "command": "podman", - "type": "process", "args": [ "image", "ls" ], - "problemMatcher": "$msCompile" + "command": "podman", + "label": "Podman Image List", + "problemMatcher": "$msCompile", + "type": "process" }, { - "label": "podmanRun", - "command": "podman", - "type": "process", "args": [ "run", "-p", @@ -124,57 +233,55 @@ "file-folder-helper-001", "a3de856b5731" ], - "problemMatcher": "$msCompile" + "command": "podman", + "label": "Podman Run", + "problemMatcher": "$msCompile", + "type": "process" }, { - "label": "podmanTag", - "command": "podman", - "type": "process", "args": [ "tag", "a3de856b5731", "gitea.phares.duckdns.org:443/phares3757/file-folder-helper:latest" ], - "problemMatcher": "$msCompile" + "command": "podman", + "label": "Podman Tag", + "problemMatcher": "$msCompile", + "type": "process" }, { - "label": "podmanPush", - "command": "podman", - "type": "process", "args": [ "push", "gitea.phares.duckdns.org:443/phares3757/file-folder-helper:latest" ], - "problemMatcher": "$msCompile" + "command": "podman", + "label": "Podman Push", + "problemMatcher": "$msCompile", + "type": "process" }, { - "label": "publish", - "command": "dotnet", - "type": "process", "args": [ "publish", - "${workspaceFolder}/File-Folder-Helper.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" + "${workspaceFolder}/File-Folder-Helper.csproj" ], - "problemMatcher": "$msCompile" + "command": "dotnet", + "label": "Publish", + "problemMatcher": "$msCompile", + "type": "process" }, { - "label": "watch", - "command": "dotnet", - "type": "process", "args": [ "watch", "run", "--project", "${workspaceFolder}/File-Folder-Helper.csproj" ], - "problemMatcher": "$msCompile" + "command": "dotnet", + "label": "Watch", + "problemMatcher": "$msCompile", + "type": "process" }, { - "label": "Publish AOT", - "command": "dotnet", - "type": "process", "args": [ "publish", "-r", @@ -182,16 +289,14 @@ "-c", "Release", "-p:PublishAot=true", - "${workspaceFolder}/File-Folder-Helper.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" + "${workspaceFolder}/File-Folder-Helper.csproj" ], - "problemMatcher": "$msCompile" + "command": "dotnet", + "label": "Publish AOT", + "problemMatcher": "$msCompile", + "type": "process" }, { - "label": "Publish AOT Linux", - "command": "dotnet", - "type": "process", "args": [ "publish", "-r", @@ -199,40 +304,38 @@ "-c", "Release", "-p:PublishAot=true", - "${workspaceFolder}/File-Folder-Helper.csproj", - "/property:GenerateFullPaths=true", - "/consoleloggerparameters:NoSummary" + "${workspaceFolder}/File-Folder-Helper.csproj" ], - "problemMatcher": "$msCompile" + "command": "dotnet", + "label": "Publish AOT Linux", + "problemMatcher": "$msCompile", + "type": "process" }, { "label": "Kanbn Console", - "type": "npm", + "problemMatcher": [], "script": "kanbn.board", - "problemMatcher": [] + "type": "npm" }, { - "label": "Kanbn Write Boad", - "type": "shell", "command": "& kanbn board -j | L:/Git/kanbn2md/kanbn2md.exe >.kanbn/board.md", - "problemMatcher": [] + "label": "Kanbn Write Boad", + "problemMatcher": [], + "type": "shell" }, { "label": "Kanbn Write json", - "type": "npm", + "problemMatcher": [], "script": "kanbn.board.json", - "problemMatcher": [] + "type": "npm" }, { - "label": "Jest", - "type": "shell", "command": "npx jest", - "problemMatcher": [] + "label": "Jest", + "problemMatcher": [], + "type": "shell" }, { - "label": "File-Folder-Helper AOT s X Day-Helper-2025-03-20", - "type": "shell", - "command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe", "args": [ "s", "X", @@ -241,7 +344,11 @@ "false", "4" ], - "problemMatcher": [] + "command": "L:/DevOps/Mesa_FI/File-Folder-Helper/bin/Release/net8.0/win-x64/publish/File-Folder-Helper.exe", + "label": "File-Folder-Helper AOT s X Day-Helper-2025-03-20", + "problemMatcher": [], + "type": "shell" } - ] + ], + "version": "2.0.0" } \ No newline at end of file diff --git a/ADO2025/PI6/Helper-2025-07-26.cs b/ADO2025/PI6/Helper-2025-07-26.cs index e2678bb..bc188fc 100644 --- a/ADO2025/PI6/Helper-2025-07-26.cs +++ b/ADO2025/PI6/Helper-2025-07-26.cs @@ -1,13 +1,10 @@ - +using Microsoft.Extensions.Logging; +using Phares.Shared.Models; +using Phares.Shared.Models.Stateless; using System.Collections.ObjectModel; using System.Text.Json; using System.Text.Json.Serialization; -using Microsoft.Extensions.Logging; - -using Phares.Shared.Models; -using Phares.Shared.Models.Stateless; - namespace File_Folder_Helper.ADO2025.PI6; internal static partial class Helper20250726 { @@ -27,23 +24,36 @@ internal static partial class Helper20250726 { logger.LogInformation(args[2]); logger.LogInformation(args[3]); logger.LogInformation(args[4]); - string searchPattern = args[3]; - string jsonFile = Path.GetFullPath(args[2]); + logger.LogInformation(args[5]); + string[] files; + string[] searchPatterns = args[4].Split('~'); + string jsonFile = Path.GetFullPath(args[3]); if (!File.Exists(jsonFile)) { throw new Exception($"json file doesn't exist! <{jsonFile}>"); } + ReadOnlyCollection records; string json = File.ReadAllText(jsonFile); + ReadOnlyDictionary> keyValues; string sourceDirectory = Path.GetFullPath(args[0].Split('~')[0]); - string destinationDirectory = Path.GetFullPath(args[4].Split('~')[0]); + string destinationDirectory = Path.GetFullPath(args[5].Split('~')[0]); + long maxSize = long.Parse(args[2], System.Globalization.NumberStyles.Float); + ReadOnlyDictionary>> keyValuePairs; Helper20250726Settings? settings = JsonSerializer.Deserialize(json, Helper20250726SettingsSourceGenerationContext.Default.Helper20250726Settings); if (settings?.ResultSettings is null || settings.ResultSettings.ResultAllInOneSubdirectoryLength < 1 || settings.MetadataSettings is null) { throw new Exception(nameof(Helper20250726Settings)); } - string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.AllDirectories); - ReadOnlyDictionary>> keyValuePairs = GetKeyValuePairs(destinationDirectory, settings.ResultSettings); - ReadOnlyCollection records = GetRecords(logger, settings.ResultSettings, settings.MetadataSettings, files); - ReadOnlyDictionary> keyValues = keyValuePairs.ElementAt(0).Value; - CopyToCombinedEnumAndIndexFormat(logger, records, keyValues); + foreach (string searchPattern in searchPatterns) { + files = Directory.GetFiles(sourceDirectory, $"*{searchPattern}", SearchOption.AllDirectories); + if (files.Length == 0) { + logger.LogInformation($"Didn't find any {searchPattern} files"); + continue; + } + logger.LogInformation($"Found {files.Length} {searchPattern} files"); + keyValuePairs = GetKeyValuePairs(destinationDirectory, settings.ResultSettings); + records = GetRecords(logger, settings.ResultSettings, settings.MetadataSettings, files); + keyValues = keyValuePairs.ElementAt(0).Value; + CopyToCombinedEnumAndIndexFormat(logger, maxSize, records, keyValues); + } Helpers.HelperDeleteEmptyDirectories.DeleteEmptyDirectories(logger, destinationDirectory); } @@ -84,11 +94,15 @@ internal static partial class Helper20250726 { return results.AsReadOnly(); } - private static void CopyToCombinedEnumAndIndexFormat(ILogger logger, ReadOnlyCollection records, ReadOnlyDictionary> keyValuePairs) { + private static void CopyToCombinedEnumAndIndexFormat(ILogger logger, long maxSize, ReadOnlyCollection records, ReadOnlyDictionary> keyValuePairs) { string checkFile; FileInfo fileInfo; FileAttributes fileAttributes; foreach (Record record in records) { + if (record.FilePath.Length > maxSize) { + logger.LogWarning("<{file}> skipped because it is over {size}!", record.FilePath.Name, maxSize); + continue; + } checkFile = Path.Combine(keyValuePairs[record.CombinedEnumAndIndex.Enum][record.CombinedEnumAndIndex.Index], record.FilePath.Name); if (File.Exists(checkFile)) { logger.LogWarning("<{file}> skipped because it already exists!", record.FilePath.Name);