diff --git a/.vscode/mklink.md b/.vscode/mklink.md index 3b47e79..8cec5ac 100644 --- a/.vscode/mklink.md +++ b/.vscode/mklink.md @@ -15,7 +15,7 @@ mklink /J "L:\DevOps\Mesa_FI\File-Folder-Helper\.kanbn" "D:\5-Other-Small\Kanban ``` ```bash -mklink /J "L:\DevOps\Mesa_FI\File-Folder-Helper\.extensions-vscode" "C:\Users\phares\.vscode\extensions\ifx.type-script-helper-1.6.0" -mklink /J "L:\DevOps\Mesa_FI\File-Folder-Helper\.extensions-vscode-oss" "C:\Users\phares\.vscode-oss\extensions\ifx.type-script-helper-1.6.0" -mklink /J "L:\DevOps\Mesa_FI\File-Folder-Helper\.extensions-vscode-insiders" "C:\Users\phares\.vscode-insiders\extensions\ifx.type-script-helper-1.6.0" +mklink /J "L:\DevOps\Mesa_FI\File-Folder-Helper\.extensions-vscode" "C:\Users\phares\.vscode\extensions\ifx.type-script-helper-1.6.1" +mklink /J "L:\DevOps\Mesa_FI\File-Folder-Helper\.extensions-vscode-oss" "C:\Users\phares\.vscode-oss\extensions\ifx.type-script-helper-1.6.1" +mklink /J "L:\DevOps\Mesa_FI\File-Folder-Helper\.extensions-vscode-insiders" "C:\Users\phares\.vscode-insiders\extensions\ifx.type-script-helper-1.6.1" ``` diff --git a/Day/2024-Q1/Helper-2024-01-07.cs b/Day/2024-Q1/Helper-2024-01-07.cs index 7b6765d..17e870e 100644 --- a/Day/2024-Q1/Helper-2024-01-07.cs +++ b/Day/2024-Q1/Helper-2024-01-07.cs @@ -33,7 +33,10 @@ internal static partial class Helper20240107 string destinationDirectory = args[3]; logger.LogInformation(sourceDirectory); if (sourceDirectory == "C:/ProgramData") + { sourceDirectory = destinationDirectory; + destinationDirectory = Path.GetDirectoryName(destinationDirectory) ?? throw new NotSupportedException(); + } bool mapOnly = sourceDirectory.Length == 2; if (!Directory.Exists(destinationDirectory)) _ = Directory.CreateDirectory(destinationDirectory); diff --git a/Day/2024-Q2/Helper-2024-05-10.cs b/Day/2024-Q2/Helper-2024-05-10.cs new file mode 100644 index 0000000..21bb653 --- /dev/null +++ b/Day/2024-Q2/Helper-2024-05-10.cs @@ -0,0 +1,34 @@ +using Microsoft.Extensions.Logging; + +namespace File_Folder_Helper.Day; + +internal static partial class Helper20240510 +{ + + internal static void PullIconsForBLM(ILogger logger, List args) + { + string fileName; + FileInfo fileInfo; + string searchPattern = args[4]; + string sourceDirectory = args[3]; + string root = Path.GetFullPath(args[0]); + string createDirectory = Path.Combine(root, args[2]); + if (!Directory.Exists(createDirectory)) + _ = Directory.CreateDirectory(createDirectory); + string[] files = Directory.GetFiles(sourceDirectory, searchPattern, SearchOption.TopDirectoryOnly); + foreach (string file in files) + { + fileName = Path.GetFileName(file); + fileInfo = new(Path.Combine(createDirectory, fileName)); + if (fileInfo.Exists && fileInfo.LastWriteTime == new FileInfo(file).LastWriteTime) + continue; + File.Copy(file, fileInfo.FullName, overwrite: true); + logger.LogInformation("<{fileName}> copied", fileName); + } + logger.LogWarning("What reactor is this near?"); + string? reactor = Console.ReadLine(); + if (!string.IsNullOrEmpty(reactor)) + _ = Directory.CreateDirectory(Path.Combine(sourceDirectory, Environment.MachineName, reactor)); + } + +} \ No newline at end of file diff --git a/Day/2024-Q2/Helper-2024-05-13.cs b/Day/2024-Q2/Helper-2024-05-13.cs new file mode 100644 index 0000000..562c491 --- /dev/null +++ b/Day/2024-Q2/Helper-2024-05-13.cs @@ -0,0 +1,39 @@ +using File_Folder_Helper.Models; +using Microsoft.Extensions.Logging; +using System.Text.Json; + +namespace File_Folder_Helper.Day; + +internal static partial class Helper20240513 +{ + + internal static void PersonKeyToName(ILogger logger, List args) + { + Person? person; + string directoryName; + string checkDirectory; + string root = Path.GetFullPath(args[0]); + string json = File.ReadAllText(args[2]); + Dictionary keyValuePairs = []; + string[] directories = Directory.GetDirectories(root, "*", SearchOption.TopDirectoryOnly); + Dictionary people = JsonSerializer.Deserialize(json, PeopleSourceGenerationContext.Default.DictionaryInt64Person) ?? throw new NullReferenceException(); + foreach (KeyValuePair keyValuePair in people) + { + if (keyValuePair.Value.Birth?.Note is null) + continue; + keyValuePairs.Add(keyValuePair.Value.Birth.Note, keyValuePair.Value); + } + foreach (string directory in directories) + { + directoryName = Path.GetFileName(directory); + if (!keyValuePairs.TryGetValue(directoryName, out person) || person.Name?.ForwardSlashFull is null) + continue; + checkDirectory = Path.Combine(root, $"{person.Name.ForwardSlashFull.Replace('/', '-')}{directoryName}-{person.Id}"); + if (Directory.Exists(checkDirectory)) + continue; + Directory.Move(directory, checkDirectory); + logger.LogInformation("<{directory}> was moved", directory); + } + } + +} \ No newline at end of file diff --git a/Day/2024-Q2/Helper-2024-05-17.cs b/Day/2024-Q2/Helper-2024-05-17.cs new file mode 100644 index 0000000..8892f3c --- /dev/null +++ b/Day/2024-Q2/Helper-2024-05-17.cs @@ -0,0 +1,334 @@ +using Microsoft.Extensions.Logging; +using System.Collections.ObjectModel; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace File_Folder_Helper.Day; + +internal static partial class Helper20240517 +{ + + public record ContentSignature([property: JsonPropertyName("contentSignature")] string Value, + [property: JsonPropertyName("contentSignatureType")] string ContentSignatureType); + + [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSerializable(typeof(ContentSignature))] + public partial class ContentSignatureGenerationContext : JsonSerializerContext + { + } + + public record Type([property: JsonPropertyName("count")] int Count, + [property: JsonPropertyName("match")] string Match, + [property: JsonPropertyName("searchData")] SearchData SearchData); + + [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSerializable(typeof(Type))] + public partial class TypeGenerationContext : JsonSerializerContext + { + } + + public record ImageAmazon([property: JsonPropertyName("colorSpace")] string ColorSpace, + [property: JsonPropertyName("dateTime")] DateTime DateTime, + [property: JsonPropertyName("dateTimeDigitized")] DateTime DateTimeDigitized, + [property: JsonPropertyName("dateTimeOriginal")] DateTime DateTimeOriginal, + [property: JsonPropertyName("exposureMode")] string ExposureMode, + [property: JsonPropertyName("exposureProgram")] string ExposureProgram, + [property: JsonPropertyName("exposureTime")] string ExposureTime, + [property: JsonPropertyName("flash")] string Flash, + [property: JsonPropertyName("focalLength")] string FocalLength, + [property: JsonPropertyName("height")] int Height, + [property: JsonPropertyName("make")] string Make, + [property: JsonPropertyName("meteringMode")] string MeteringMode, + [property: JsonPropertyName("model")] string Model, + [property: JsonPropertyName("orientation")] string Orientation, + [property: JsonPropertyName("resolutionUnit")] string ResolutionUnit, + [property: JsonPropertyName("sensingMethod")] string SensingMethod, + [property: JsonPropertyName("sharpness")] string Sharpness, + [property: JsonPropertyName("software")] string Software, + [property: JsonPropertyName("subSecTime")] string SubSecTime, + [property: JsonPropertyName("subSecTimeDigitized")] string SubSecTimeDigitized, + [property: JsonPropertyName("subSecTimeOriginal")] string SubSecTimeOriginal, + [property: JsonPropertyName("whiteBalance")] string WhiteBalance, + [property: JsonPropertyName("width")] int Width, + [property: JsonPropertyName("apertureValue")] string ApertureValue); + + [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSerializable(typeof(ImageAmazon))] + public partial class ImageAmazonGenerationContext : JsonSerializerContext + { + } + + public record ContentProperties([property: JsonPropertyName("contentDate")] DateTime ContentDate, + [property: JsonPropertyName("contentSignatures")] IReadOnlyList ContentSignatures, + [property: JsonPropertyName("contentType")] string ContentType, + [property: JsonPropertyName("extension")] string Extension, + [property: JsonPropertyName("image")] ImageAmazon Image, + [property: JsonPropertyName("md5")] string Md5, + [property: JsonPropertyName("size")] int Size, + [property: JsonPropertyName("version")] int Version); + + [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSerializable(typeof(ContentProperties))] + public partial class ContentPropertiesGenerationContext : JsonSerializerContext + { + } + + public record XAccntParentMap(); + + [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSerializable(typeof(XAccntParentMap))] + public partial class XAccntParentMapGenerationContext : JsonSerializerContext + { + } + + public record Datum([property: JsonPropertyName("accessRuleIds")] IReadOnlyList AccessRuleIds, + [property: JsonPropertyName("childAssetTypeInfo")] IReadOnlyList ChildAssetTypeInfo, + [property: JsonPropertyName("contentProperties")] ContentProperties ContentProperties, + [property: JsonPropertyName("createdBy")] string CreatedBy, + [property: JsonPropertyName("createdDate")] DateTime CreatedDate, + [property: JsonPropertyName("eTagResponse")] string ETagResponse, + [property: JsonPropertyName("groupPermissions")] IReadOnlyList GroupPermissions, + [property: JsonPropertyName("id")] string Id, + [property: JsonPropertyName("isRoot")] bool IsRoot, + [property: JsonPropertyName("isShared")] bool IsShared, + [property: JsonPropertyName("keywords")] IReadOnlyList Keywords, + [property: JsonPropertyName("kind")] string Kind, + [property: JsonPropertyName("labels")] IReadOnlyList Labels, + [property: JsonPropertyName("modifiedDate")] DateTime ModifiedDate, + [property: JsonPropertyName("name")] string Name, + [property: JsonPropertyName("ownerId")] string OwnerId, + [property: JsonPropertyName("parentMap")] ParentMap ParentMap, + [property: JsonPropertyName("parents")] IReadOnlyList Parents, + [property: JsonPropertyName("protectedFolder")] bool ProtectedFolder, + [property: JsonPropertyName("restricted")] bool Restricted, + [property: JsonPropertyName("status")] string Status, + [property: JsonPropertyName("subKinds")] IReadOnlyList SubKinds, + [property: JsonPropertyName("transforms")] IReadOnlyList Transforms, + [property: JsonPropertyName("version")] int Version, + [property: JsonPropertyName("xAccntParentMap")] XAccntParentMap XAccntParentMap, + [property: JsonPropertyName("xAccntParents")] IReadOnlyList XAccntParents, + [property: JsonPropertyName("match")] bool? Match); + + [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSerializable(typeof(Datum))] + public partial class DatumGenerationContext : JsonSerializerContext + { + } + + [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSerializable(typeof(Dictionary))] + public partial class DictionaryDatumGenerationContext : JsonSerializerContext + { + } + + public record LocationAmazon([property: JsonPropertyName("count")] int Count, + [property: JsonPropertyName("match")] string Match, + [property: JsonPropertyName("searchData")] SearchData SearchData); + + [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSerializable(typeof(LocationAmazon))] + public partial class LocationAmazonGenerationContext : JsonSerializerContext + { + } + + public record LocationInfo([property: JsonPropertyName("city")] string City, + [property: JsonPropertyName("country")] string Country, + [property: JsonPropertyName("countryIso3Code")] string CountryIso3Code, + [property: JsonPropertyName("state")] string State, + [property: JsonPropertyName("stateCode")] string StateCode); + + [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSerializable(typeof(LocationInfo))] + public partial class LocationInfoGenerationContext : JsonSerializerContext + { + } + + public record SearchData([property: JsonPropertyName("clusterName")] string ClusterName, + [property: JsonPropertyName("locationId")] string LocationId, + [property: JsonPropertyName("locationInfo")] LocationInfo LocationInfo, + [property: JsonPropertyName("thingId")] string ThingId); + + [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSerializable(typeof(SearchData))] + public partial class SearchDataGenerationContext : JsonSerializerContext + { + } + + public record AllPerson([property: JsonPropertyName("count")] int Count, + [property: JsonPropertyName("match")] string Match, + [property: JsonPropertyName("searchData")] SearchData SearchData); + + [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSerializable(typeof(AllPerson))] + public partial class AllPersonGenerationContext : JsonSerializerContext + { + } + + public record PersonAmazon([property: JsonPropertyName("count")] int Count, + [property: JsonPropertyName("match")] string Match, + [property: JsonPropertyName("searchData")] SearchData SearchData); + + [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSerializable(typeof(PersonAmazon))] + public partial class PersonAmazonGenerationContext : JsonSerializerContext + { + } + + public record ClusterId([property: JsonPropertyName("count")] int Count, + [property: JsonPropertyName("match")] string Match, + [property: JsonPropertyName("searchData")] SearchData SearchData); + + [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSerializable(typeof(ClusterId))] + public partial class ClusterIdGenerationContext : JsonSerializerContext + { + } + + public record Thing([property: JsonPropertyName("count")] int Count, + [property: JsonPropertyName("match")] string Match, + [property: JsonPropertyName("searchData")] SearchData SearchData); + + [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSerializable(typeof(Thing))] + public partial class ThingGenerationContext : JsonSerializerContext + { + } + + public record Time([property: JsonPropertyName("count")] int Count, + [property: JsonPropertyName("match")] string Match, + [property: JsonPropertyName("searchData")] SearchData SearchData); + + [JsonSourceGenerationOptions(WriteIndented = true)] + [JsonSerializable(typeof(Time))] + public partial class TimeGenerationContext : JsonSerializerContext + { + } + + public record ParentMap([property: JsonPropertyName("FOLDER")] IReadOnlyList FOLDER); + + public record Aggregations([property: JsonPropertyName("allPeople")] IReadOnlyList AllPeople, + [property: JsonPropertyName("clusterId")] IReadOnlyList ClusterId, + [property: JsonPropertyName("location")] IReadOnlyList Location, + [property: JsonPropertyName("people")] IReadOnlyList People, + [property: JsonPropertyName("things")] IReadOnlyList Things, + [property: JsonPropertyName("time")] IReadOnlyList